Add check for the getcwd function being able to take NULL,0 arguments.
authorJeremy Allison <jra@samba.org>
Tue, 31 May 2011 22:38:55 +0000 (15:38 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 1 Jun 2011 00:54:51 +0000 (02:54 +0200)
source3/configure.in
source3/wscript

index e1e2d39acd75c61b4875a14a7651a5e442622bd7..12d083b46841019e72e1145f9bc610ddb3bbb515 100644 (file)
@@ -2602,6 +2602,17 @@ if test x"$samba_cv_HAVE_LINUX_FALLOCATE64" = x"yes" && test x"$ac_cv_func_fallo
     AC_DEFINE(HAVE_LINUX_FALLOCATE64,1,[Whether the Linux 'fallocate64' function is available])
 fi
 
+AC_CACHE_CHECK([for getcwd takes NULL],samba_cv_GETCWD_TAKES_NULL,[
+AC_TRY_RUN([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+main() { char *s = getcwd(NULL,0); if (s) exit(0); exit(1); }],
+samba_cv_GETCWD_TAKES_NULL=yes,samba_cv_GETCWD_TAKES_NULL=no,samba_cv_GETCWD_TAKES_NULL=cross)])
+if test x"$samba_cv_GETCWD_TAKES_NULL" = x"yes"; then
+    AC_DEFINE(GETCWD_TAKES_NULL,1,[Whether the getcwd function takes NULL as an argument])
+fi
+
 ICONV_LOOK_DIRS="/usr /usr/local /sw /opt"
 AC_ARG_WITH(libiconv,
 [AS_HELP_STRING([--with-libiconv=BASEDIR], [Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto)])],
index ee4a98c85d584c3c942c46147f0ed1e8c12536b0..83b0a0ef04d6138a7b62990e999b822a2f2bd4bc 100644 (file)
@@ -1420,6 +1420,16 @@ main() {
                 conf.DEFINE('AIX_SENDFILE_API', '1')
                 conf.DEFINE('WITH_SENDFILE', '1')
 
+    # Check for getcwd allowing a NULL arg.
+    conf.CHECK_CODE('''
+#include <unistd.h>
+main() {
+       char *s = getcwd(NULL,0);
+        exit(s != NULL ?  0 : 1);
+}''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
+        msg="getcwd takes a NULL argument")
+
+
     conf.CHECK_CODE('''enum TDB_ERROR err = TDB_ERR_NESTING''',
                    'HAVE_TDB_ERR_NESTING',
                    headers='tdb.h',