From: Andreas Schneider Date: Thu, 29 Nov 2018 07:12:06 +0000 (+0100) Subject: replace: Correctly check for 'extern char **environ' in unistd.h X-Git-Tag: tdb-1.3.17~534 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3490049574d2e9651a402d6335fa23cefb182c5;p=thirdparty%2Fsamba.git replace: Correctly check for 'extern char **environ' in unistd.h Signed-off-by: Andreas Schneider Reviewed-by: Martin Schwenke Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Fri Nov 30 11:41:44 CET 2018 on sn-devel-144 --- diff --git a/lib/replace/replace.h b/lib/replace/replace.h index ece71b74107..0055255a9a5 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -162,6 +162,10 @@ #include #endif +#ifdef HAVE_UNISTD_H +#include +#endif + #ifdef HAVE_STRING_H #include #endif @@ -272,16 +276,14 @@ char *rep_strndup(const char *s, size_t n); size_t rep_strnlen(const char *s, size_t n); #endif -#if defined(HAVE_DECL_ENVIRON) -#if !HAVE_DECL_ENVIRON -#ifdef __APPLE__ -#include -#define environ (*_NSGetEnviron()) -#else +#if !defined(HAVE_DECL_ENVIRON) +# ifdef __APPLE__ +# include +# define environ (*_NSGetEnviron()) +# else /* __APPLE__ */ extern char **environ; -#endif -#endif -#endif /* defined(HAVE_DECL_ENVIRON) */ +# endif /* __APPLE */ +#endif /* !defined(HAVE_DECL_ENVIRON) */ #ifndef HAVE_SETENV #define setenv rep_setenv diff --git a/lib/replace/wscript b/lib/replace/wscript index ff918146ffa..173d7e6d29a 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -613,7 +613,8 @@ def configure(conf): conf.CHECK_DECLS('errno', headers='errno.h', reverse=True) conf.CHECK_DECLS('EWOULDBLOCK', headers='errno.h') - conf.CHECK_DECLS('environ getgrent_r getpwent_r', reverse=True, headers='pwd.h grp.h') + conf.CHECK_DECLS('environ', reverse=True, headers='unistd.h') + conf.CHECK_DECLS('getgrent_r getpwent_r', reverse=True, headers='pwd.h grp.h') conf.CHECK_DECLS('pread pwrite setenv setresgid setresuid', reverse=True) if conf.CONFIG_SET('HAVE_EPOLL_CREATE') and conf.CONFIG_SET('HAVE_SYS_EPOLL_H'):