diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/pg_config.h.in | 3 | ||||
-rw-r--r-- | src/port/thread.c | 17 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index f9c3d5ade7f..5d3351a006d 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -607,6 +607,9 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Define to 1 if strerror_r() returns a int. */ +#undef STRERROR_R_INT + /* Define to 1 if your <sys/time.h> declares `struct tm'. */ #undef TM_IN_SYS_TIME diff --git a/src/port/thread.c b/src/port/thread.c index 474ef969457..47615962e74 100644 --- a/src/port/thread.c +++ b/src/port/thread.c @@ -7,7 +7,7 @@ * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/port/thread.c,v 1.20 2004/04/23 18:15:55 momjian Exp $ + * $PostgreSQL: pgsql/src/port/thread.c,v 1.21 2004/06/07 22:39:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -70,12 +70,17 @@ pqStrerror(int errnum, char *strerrbuf, size_t buflen) { #if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(HAVE_STRERROR_R) /* reentrant strerror_r is available */ - /* some early standards had strerror_r returning char * */ - strerror_r(errnum, strerrbuf, buflen); - return strerrbuf; - +#ifdef STRERROR_R_INT + /* SUSv3 version */ + if (strerror_r(errnum, strerrbuf, buflen) == 0) + return strerrbuf; + else + return NULL; +#else + /* GNU libc */ + return strerror_r(errnum, strerrbuf, buflen); +#endif #else - /* no strerror_r() available, just use strerror */ StrNCpy(strerrbuf, strerror(errnum), buflen); |