Author: metze
Date: 2006-09-14 08:26:41 +0000 (Thu, 14 Sep 2006)
New Revision: 18505

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18505

Log:
add configure checks for telldir() and seekdir()

telldir() is different on older OpenBSD versions
seekdir() is different Tru64

tridge: OpenBSD seems to like this replacement:-)
        while MAC OS 10 gets 134 runtime error:-(
        lets wait what Tru64 will give

metze

Modified:
   branches/SAMBA_4_0/source/lib/replace/libreplace_macros.m4
   branches/SAMBA_4_0/source/lib/replace/repdir.m4
   branches/SAMBA_4_0/source/lib/replace/repdir_getdirentries.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/replace/libreplace_macros.m4
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/libreplace_macros.m4  2006-09-14 
07:57:49 UTC (rev 18504)
+++ branches/SAMBA_4_0/source/lib/replace/libreplace_macros.m4  2006-09-14 
08:26:41 UTC (rev 18505)
@@ -268,3 +268,23 @@
 dnl in autoconf 2.59, so define AS_HELP_STRING to be AC_HELP_STRING unless it 
is already
 dnl defined.
 m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], 
m4_defn([AC_HELP_STRING]))])
+
+dnl check if the prototype in the header matches the given one
+dnl 
AC_VERIFY_C_PROTOTYPE(prototype,functionbody,[IF-TRUE].[IF-FALSE],[extraheaders])
+AC_DEFUN(AC_VERIFY_C_PROTOTYPE,
+[AC_CACHE_CHECK([for prototype $1], AS_TR_SH([ac_cv_c_prototype_$1]),
+       AC_COMPILE_IFELSE([
+               AC_INCLUDES_DEFAULT
+               $5
+               $1
+               {
+                       $2
+               }
+       ],[
+               AS_TR_SH([ac_cv_c_prototype_$1])=yes
+               $3
+       ],[
+               AS_TR_SH([ac_cv_c_prototype_$1])=no
+               $4
+       ])
+)])

Modified: branches/SAMBA_4_0/source/lib/replace/repdir.m4
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/repdir.m4     2006-09-14 07:57:49 UTC 
(rev 18504)
+++ branches/SAMBA_4_0/source/lib/replace/repdir.m4     2006-09-14 08:26:41 UTC 
(rev 18505)
@@ -14,7 +14,7 @@
 AC_CHECK_FUNCS(getdents)
 AC_CACHE_CHECK([for replacing readdir using 
getdents()],libreplace_READDIR_GETDENTS,[
        AC_TRY_RUN([
-#include "confdefs.h"
+#define _LIBREPLACE_REPLACE_H
 #include "$libreplacedir/repdir_getdents.c"
 #define test_readdir_os2_delete main
 #include "$libreplacedir/test/os2_delete.c"],
@@ -34,9 +34,26 @@
 #
 if test x"$libreplace_READDIR_NEEDED" = x"yes"; then
 AC_CHECK_FUNCS(getdirentries)
+AC_VERIFY_C_PROTOTYPE([long telldir(const DIR *dir)],
+       [
+       return 0;
+       ],[
+       AC_DEFINE(TELLDIR_TAKES_CONST_DIR, 1, [Whether telldir takes a const 
pointer])
+       ],[],[
+       #include <dirent.h>
+       ])
+
+AC_VERIFY_C_PROTOTYPE([int seekdir(DIR *dir, long ofs)],
+       [
+       return 0;
+       ],[
+       AC_DEFINE(SEEKDIR_RETURNS_INT, 1, [Whether seekdir returns an int])
+       ],[],[
+       #include <dirent.h>
+       ])
 AC_CACHE_CHECK([for replacing readdir using 
getdirentries()],libreplace_READDIR_GETDIRENTRIES,[
        AC_TRY_RUN([
-#include "confdefs.h"
+#define _LIBREPLACE_REPLACE_H
 #include "$libreplacedir/repdir_getdirentries.c"
 #define test_readdir_os2_delete main
 #include "$libreplacedir/test/os2_delete.c"],

Modified: branches/SAMBA_4_0/source/lib/replace/repdir_getdirentries.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/repdir_getdirentries.c        
2006-09-14 07:57:49 UTC (rev 18504)
+++ branches/SAMBA_4_0/source/lib/replace/repdir_getdirentries.c        
2006-09-14 08:26:41 UTC (rev 18505)
@@ -48,6 +48,7 @@
   well. Contact the author.
 */
 
+#include "replace.h"
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -104,8 +105,6 @@
        return de;
 }
 
-#define TELLDIR_TAKES_CONST_DIR
-
 #ifdef TELLDIR_TAKES_CONST_DIR
 long telldir(const DIR *dir)
 #else
@@ -126,7 +125,11 @@
        return d->seekpos + d->ofs;
 }
 
+#ifdef SEEKDIR_RETURNS_INT
+int seekdir(DIR *dir, long ofs)
+#else
 void seekdir(DIR *dir, long ofs)
+#endif
 {
        struct dir_buf *d = (struct dir_buf *)dir;
        long pos;
@@ -136,6 +139,9 @@
        while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) {
                if (readdir(dir) == NULL) break;
        }
+#ifdef SEEKDIR_RETURNS_INT
+       return -1;
+#endif
 }
 
 void rewinddir(DIR *dir)

Reply via email to