]> git.sur5r.net Git - openldap/blob - include/ac/errno.h
Latest changes from devel
[openldap] / include / ac / errno.h
1 /* Generic errno.h */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2000 The OpenLDAP Foundation, Redwood City, California, USA
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms are permitted only
8  * as authorized by the OpenLDAP Public License.  A copy of this
9  * license is available at http://www.OpenLDAP.org/license.html or
10  * in file LICENSE in the top-level directory of the distribution.
11  */
12
13 #ifndef _AC_ERRNO_H
14 #define _AC_ERRNO_H
15
16 #if defined( HAVE_ERRNO_H )
17 # include <errno.h>
18 #elif defined( HAVE_SYS_ERRNO_H )
19 # include <sys/errno.h>
20 #endif
21
22 #ifndef HAVE_SYS_ERRLIST
23         /* no sys_errlist */
24 #       define          sys_nerr        0
25 #       define          sys_errlist     ((char **)0)
26 #elif DECL_SYS_ERRLIST 
27         /* have sys_errlist but need declaration */
28         LDAP_LIBC_V(int)      sys_nerr;
29         LDAP_LIBC_V(char)    *sys_errlist[];
30 #endif
31
32 #undef _AC_ERRNO_UNKNOWN
33 #define _AC_ERRNO_UNKNOWN "unknown error"
34
35 #ifdef HAVE_SYS_ERRLIST
36         /* this is thread safe */
37 #       define  STRERROR(e) ( (e) > -1 && (e) < sys_nerr \
38                         ? sys_errlist[(e)] : _AC_ERRNO_UNKNOWN )
39
40 #elif defined( HAVE_STRERROR )
41         /* this may not be thread safe */
42         /* and, yes, some implementations of strerror may return NULL */
43 #       define  STRERROR(e) ( strerror(e) \
44                 ? strerror(e) : _AC_ERRNO_UNKNOWN )
45
46 #else
47         /* this is thread safe */
48 #       define  STRERROR(e) ( _AC_ERRNO_UNKNOWN )
49 #endif
50
51 #endif /* _AC_ERRNO_H */