(root)/
gcc-13.2.0/
libgo/
runtime/
go-strerror.c
       1  /* go-strerror.c -- wrapper around XSI-compliant strerror_r.
       2  
       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.  */
       6  
       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).  */
      14  
      15  #if defined(__linux__) || defined(__gnu_hurd__)
      16  
      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
      23  
      24  #endif /* defined(__linux__) || defined(__gnu_hurd__) */
      25  
      26  #include <string.h>
      27  
      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
      32  
      33  int
      34  go_strerror (int errnum, char *buf, size_t buflen)
      35  {
      36    return strerror_r (errnum, buf, buflen);
      37  }