Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / talloc / libreplace / repdir.m4
blob682ab44c564e224fa02645116e5e0ee411e1f8ea
1 AC_CACHE_CHECK([for broken readdir],libreplace_cv_READDIR_NEEDED,[
2         AC_TRY_RUN([
3 #define test_readdir_os2_delete main
4 #include "$libreplacedir/test/os2_delete.c"],
5         [libreplace_cv_READDIR_NEEDED=no],
6         [libreplace_cv_READDIR_NEEDED=yes],
7         [libreplace_cv_READDIR_NEEDED="assuming not"])
8 ])
10 AC_CHECK_FUNCS(dirfd)
11 AC_HAVE_DECL(dirfd, [#include <dirent.h>])
14 # try to replace with getdirentries() if needed
16 if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
17 AC_CHECK_FUNCS(getdirentries)
18 AC_VERIFY_C_PROTOTYPE([long telldir(const DIR *dir)],
19         [
20         return 0;
21         ],[
22         AC_DEFINE(TELLDIR_TAKES_CONST_DIR, 1, [Whether telldir takes a const pointer])
23         ],[],[
24         #include <dirent.h>
25         ])
27 AC_VERIFY_C_PROTOTYPE([int seekdir(DIR *dir, long ofs)],
28         [
29         return 0;
30         ],[
31         AC_DEFINE(SEEKDIR_RETURNS_INT, 1, [Whether seekdir returns an int])
32         ],[],[
33         #include <dirent.h>
34         ])
35 AC_CACHE_CHECK([for replacing readdir using getdirentries()],libreplace_cv_READDIR_GETDIRENTRIES,[
36         AC_TRY_RUN([
37 #define _LIBREPLACE_REPLACE_H
38 #include "$libreplacedir/repdir_getdirentries.c"
39 #define test_readdir_os2_delete main
40 #include "$libreplacedir/test/os2_delete.c"],
41         [libreplace_cv_READDIR_GETDIRENTRIES=yes],
42         [libreplace_cv_READDIR_GETDIRENTRIES=no])
45 if test x"$libreplace_cv_READDIR_GETDIRENTRIES" = x"yes"; then
46         AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
47         AC_DEFINE(REPLACE_READDIR_GETDIRENTRIES,1,[replace readdir using getdirentries()])
48         LIBREPLACEOBJ="${LIBREPLACEOBJ} $libreplacedir/repdir_getdirentries.o"
49         libreplace_cv_READDIR_NEEDED=no
53 # try to replace with getdents() if needed
55 if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
56 AC_CHECK_FUNCS(getdents)
57 AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_cv_READDIR_GETDENTS,[
58         AC_TRY_RUN([
59 #define _LIBREPLACE_REPLACE_H
60 #error _donot_use_getdents_replacement_anymore
61 #include "$libreplacedir/repdir_getdents.c"
62 #define test_readdir_os2_delete main
63 #include "$libreplacedir/test/os2_delete.c"],
64         [libreplace_cv_READDIR_GETDENTS=yes],
65         [libreplace_cv_READDIR_GETDENTS=no])
68 if test x"$libreplace_cv_READDIR_GETDENTS" = x"yes"; then
69         AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
70         AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()])
71         LIBREPLACEOBJ="${LIBREPLACEOBJ} $libreplacedir/repdir_getdents.o"
72         libreplace_cv_READDIR_NEEDED=no
75 AC_MSG_CHECKING([a usable readdir()])
76 if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
77         AC_MSG_RESULT(no)
78         AC_MSG_WARN([the provided readdir() is broken])
79 else
80         AC_MSG_RESULT(yes)