From 26604c14e7db0eac6be0a0e5929e1c7894ca9ea0 Mon Sep 17 00:00:00 2001 From: brarcher Date: Wed, 25 Dec 2013 03:04:07 +0000 Subject: [PATCH] libcompat.h: rename several functions if the _ variant exists For fileno, getpid, pipe, putenv, read, strdup, and write, if the name append with _ exists, use that instead. This likely only applied to MSVC. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@933 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- lib/libcompat.h | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/lib/libcompat.h b/lib/libcompat.h index b1f2911..0a12356 100644 --- a/lib/libcompat.h +++ b/lib/libcompat.h @@ -82,9 +82,15 @@ void *rpl_realloc (void *p, size_t n); #endif /* !HAVE_REALLOC */ /* functions that may be undeclared */ -#if !HAVE_DECL_FILENO +#if !HAVE_DECL_FILENO && !HAVE__FILENO int fileno (FILE *stream); -#endif /* !HAVE_DECL_FILENO */ +#elif !HAVE_FILENO && HAVE__FILENO +#define fileno _fileno; +#endif /* !HAVE_DECL_FILENO && !HAVE__FILENO */ + +#if !HAVE_GETPID && HAVE__GETPID +#define getpid _getpid; +#endif /* !HAVE_GETPID && HAVE__GETPID */ #if !HAVE_DECL_LOCALTIME_R #if !defined(localtime_r) @@ -92,13 +98,21 @@ struct tm *localtime_r (const time_t *clock, struct tm *result); #endif #endif /* !HAVE_DECL_LOCALTIME_R */ -#if !HAVE_DECL_PIPE -int pipe (int *fildes); -#endif /* !HAVE_DECL_PIPE */ +#if !HAVE_DECL_PIPE && !HAVE__PIPE + int pipe (int *fildes); +#elif !HAVE_DECL_PIPE && HAVE__PIPE +#define pipe _pipe; +#endif /* !HAVE_DECL_PIPE && HAVE__PIPE */ + +#if !HAVE_DECL_PUTENV && !HAVE__PUTENV + int putenv (const char *string); +#elif !HAVE_DECL_PUTENV && HAVE__PUTENV +#define putenv _putenv; +#endif /* HAVE_DECL_PUTENV && !HAVE__PUTENV */ -#if !HAVE_DECL_PUTENV -int putenv (const char *string); -#endif /* !HAVE_DECL_PUTENV */ +#if !HAVE_READ && HAVE__READ +#define read _read +#endif /* !HAVE_READ && HAVE__READ */ #if !HAVE_DECL_SETENV int setenv (const char *name, const char *value, int overwrite); @@ -115,9 +129,11 @@ int setenv (const char *name, const char *value, int overwrite); unsigned int sleep (unsigned int seconds); #endif /* !HAVE_DECL_SLEEP */ -#if !HAVE_DECL_STRDUP -char *strdup (const char *str); -#endif /* !HAVE_DECL_STRDUP */ +#if !HAVE_DECL_STRDUP && !HAVE__STRDUP + char *strdup (const char *str); +#elif !HAVE_DECL_STRDUP && HAVE__STRDUP +#define strdup _strdup; +#endif /* !HAVE_DECL_STRDUP && HAVE__STRDUP */ #if !HAVE_DECL_STRSIGNAL const char *strsignal (int sig); @@ -127,6 +143,10 @@ const char *strsignal (int sig); int unsetenv (const char *name); #endif /* !HAVE_DECL_UNSETENV */ +#if !HAVE_WRITE && HAVE_WRITE +#define write _write +#endif /* !HAVE_WRITE && HAVE__WRITE */ + /* * On systems where clock_gettime() is not available, or * on systems where some clocks may not be supported, the -- 2.40.0