libstdc++: Fix std::char_traits<C>::move [PR113200]
[official-gcc.git] / libgo / runtime / go-strerror.c
blob8ff5ffbdfecbcd496ec10cb989ee532e3df43532
1 /* go-strerror.c -- wrapper around XSI-compliant strerror_r.
3 Copyright 2022 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
7 /* There are two version of strerror_r on GNU/Linux: a GNU-specific
8 and an XSI-compliant version. The former version is only available
9 on glibc. Since glibc 2.13, the XSI-compliant version is also
10 provided by glibc if _GNU_SOURCE is not defined. Since the
11 entirety of gofrontend is compiled with _GNU_SOURCE, this file
12 exists to selectively undefine it and provides an alias to the
13 XSI-compliant version of strerror_r(3). */
15 #if defined(__linux__) || defined(__gnu_hurd__)
17 /* Force selection of XSI-compliant strerror_r by glibc. */
18 #undef XOPEN_SOURCE
19 #define XOPEN_SOURCE 600
20 #undef _POSIX_C_SOURCE
21 #define _POSIX_C_SOURCE 200112L
22 #undef _GNU_SOURCE
24 #endif /* defined(__linux__) || defined(__gnu_hurd__) */
26 #include <string.h>
28 #ifndef HAVE_STRERROR_R
29 // Provided by go-nosys.c if not provided by libc itself.
30 extern int strerror_r (int, char *, size_t);
31 #endif
33 int
34 go_strerror (int errnum, char *buf, size_t buflen)
36 return strerror_r (errnum, buf, buflen);