diff options
Diffstat (limited to 'source4/lib/replace')
-rw-r--r-- | source4/lib/replace/libreplace_macros.m4 | 20 | ||||
-rw-r--r-- | source4/lib/replace/repdir.m4 | 21 | ||||
-rw-r--r-- | source4/lib/replace/repdir_getdirentries.c | 10 |
3 files changed, 47 insertions, 4 deletions
diff --git a/source4/lib/replace/libreplace_macros.m4 b/source4/lib/replace/libreplace_macros.m4 index 41ec03f07a..91f816c75d 100644 --- a/source4/lib/replace/libreplace_macros.m4 +++ b/source4/lib/replace/libreplace_macros.m4 @@ -268,3 +268,23 @@ dnl AS_HELP_STRING is not available in autoconf 2.57, and AC_HELP_STRING is depr 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 + ]) +)]) diff --git a/source4/lib/replace/repdir.m4 b/source4/lib/replace/repdir.m4 index 06a01964a8..93bf4ec911 100644 --- a/source4/lib/replace/repdir.m4 +++ b/source4/lib/replace/repdir.m4 @@ -14,7 +14,7 @@ if test x"$libreplace_READDIR_NEEDED" = x"yes"; then 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 @@ fi # 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"], diff --git a/source4/lib/replace/repdir_getdirentries.c b/source4/lib/replace/repdir_getdirentries.c index a9c1c1ce82..9e4b63145c 100644 --- a/source4/lib/replace/repdir_getdirentries.c +++ b/source4/lib/replace/repdir_getdirentries.c @@ -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 @@ struct dirent *readdir(DIR *dir) return de; } -#define TELLDIR_TAKES_CONST_DIR - #ifdef TELLDIR_TAKES_CONST_DIR long telldir(const DIR *dir) #else @@ -126,7 +125,11 @@ long telldir(DIR *dir) 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 @@ void seekdir(DIR *dir, long ofs) while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) { if (readdir(dir) == NULL) break; } +#ifdef SEEKDIR_RETURNS_INT + return -1; +#endif } void rewinddir(DIR *dir) |