1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-25 06:04:04 +03:00

r18505: 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
(This used to be commit 1f4e602ff239b7feabb2dd1d6938dedf91bde5cd)
This commit is contained in:
Stefan Metzmacher 2006-09-14 08:26:41 +00:00 committed by Gerald (Jerry) Carter
parent 595c141a69
commit a0e87e5dc7
3 changed files with 47 additions and 4 deletions

View File

@ -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
])
)])

View File

@ -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"],

View File

@ -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)