Browse Source

ftw() is obsolescent in SUSv4

  Apps should switch to nftw()

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Bernhard Reutner-Fischer 14 years ago
parent
commit
946b7b5ab8
5 changed files with 31 additions and 14 deletions
  1. 1 1
      Makefile.in
  2. 15 3
      extra/Configs/Config.in
  3. 10 8
      include/ftw.h
  4. 1 1
      libc/misc/ftw/Makefile.in
  5. 4 1
      libc/misc/ftw/ftw.c

+ 1 - 1
Makefile.in

@@ -258,7 +258,7 @@ HEADERS_RM-$(UCLIBC_HAS_BSD_ERR)             += err.h
 HEADERS_RM-$(UCLIBC_HAS_CRYPT)               += crypt.h
 HEADERS_RM-$(UCLIBC_HAS_EPOLL)               += sys/epoll.h
 HEADERS_RM-$(UCLIBC_HAS_FENV)                += fenv.h bits/fenv.h bits/fenvinline.h
-HEADERS_RM-$(UCLIBC_HAS_FTW)                 += ftw.h
+HEADERS_RM-$(findstring y,$(UCLIBC_HAS_FTW)$(UCLIBC_HAS_NFTW))  += ftw.h
 HEADERS_RM-$(UCLIBC_HAS_GETTEXT_AWARENESS)   += libintl.h
 HEADERS_RM-$(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF) += printf.h
 HEADERS_RM-$(UCLIBC_HAS_GLOB)                += glob.h

+ 15 - 3
extra/Configs/Config.in

@@ -1754,15 +1754,27 @@ config UCLIBC_HAS_WORDEXP
 	  This interface is rarely used, and very large.  Unless you have a
 	  pressing need for wordexp(), you should probably answer N.
 
+config UCLIBC_HAS_NFTW
+	bool "Support the nftw() interface"
+	default n
+	help
+	  The SuSv3 nftw() interface is used to recursively descend
+	  directory paths while repeatedly calling a function.
+
+	  This interface is rarely used, and adds around 4.5k.  Unless you have
+	  a pressing need for nftw(), you should probably answer N.
+
 config UCLIBC_HAS_FTW
-	bool "Support the ftw() and nftw() interfaces"
+	bool "Support the ftw() interface"
 	default n
+	depends on UCLIBC_SUSV4_LEGACY
 	help
-	  The SuSv3 ftw() and nftw() interfaces are used to recursively descend
+	  The SuSv3 ftw() interface is used to recursively descend
 	  directory paths while repeatedly calling a function.
 
 	  This interface is rarely used, and adds around 4.5k.  Unless you have
-	  a pressing need for ftw() or nftw(), you should probably answer N.
+	  a pressing need for ftw(), you should probably answer N.
+
 
 config UCLIBC_HAS_GLOB
 	bool "Support the glob() interface"

+ 10 - 8
include/ftw.h

@@ -129,27 +129,29 @@ typedef int (*__nftw64_func_t) (__const char *__filename,
 # endif
 #endif
 
+#if __UCLIBC_HAS_FTW__
 /* Call a function on every element in a directory tree.
 
    This function is a possible cancellation point and therefore not
    marked with __THROW.  */
-#ifndef __USE_FILE_OFFSET64
+# ifndef __USE_FILE_OFFSET64
 extern int ftw (__const char *__dir, __ftw_func_t __func, int __descriptors)
      __nonnull ((1, 2));
-#else
-# ifdef __REDIRECT
+# else
+#  ifdef __REDIRECT
 extern int __REDIRECT (ftw, (__const char *__dir, __ftw_func_t __func,
 			     int __descriptors), ftw64) __nonnull ((1, 2));
-# else
-#  define ftw ftw64
+#  else
+#   define ftw ftw64
+#  endif
 # endif
-#endif
-#ifdef __USE_LARGEFILE64
+# ifdef __USE_LARGEFILE64
 extern int ftw64 (__const char *__dir, __ftw64_func_t __func,
 		  int __descriptors) __nonnull ((1, 2));
+# endif
 #endif
 
-#ifdef __USE_XOPEN_EXTENDED
+#if __UCLIBC_HAS_NFTW__ && defined __USE_XOPEN_EXTENDED
 /* Call a function on every element in a directory tree.  FLAG allows
    to specify the behaviour more detailed.
 

+ 1 - 1
libc/misc/ftw/Makefile.in

@@ -18,7 +18,7 @@ MISC_FTW_OUT := $(top_builddir)libc/misc/ftw
 MISC_FTW_SRC := $(patsubst %.c,$(MISC_FTW_DIR)/%.c,$(CSRC))
 MISC_FTW_OBJ := $(patsubst %.c,$(MISC_FTW_OUT)/%.o,$(CSRC))
 
-libc-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ)
+libc-$(findstring y,$(UCLIBC_HAS_FTW)$(UCLIBC_HAS_NFTW)) += $(MISC_FTW_OBJ)
 
 objclean-y += misc_ftw_clean
 

+ 4 - 1
libc/misc/ftw/ftw.c

@@ -752,13 +752,15 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
 
 
 /* Entry points.  */
-
+#if __UCLIBC_HAS_FTW__
 int
 FTW_NAME (const char *path, FTW_FUNC_T func, int descriptors)
 {
   return ftw_startup (path, 0, func, descriptors, 0);
 }
+#endif
 
+#if __UCLIBC_HAS_NFTW__
 #ifndef _LIBC
 int
 NFTW_NAME (const char *path, NFTW_FUNC_T func, int descriptors, int flags)
@@ -802,3 +804,4 @@ NFTW_OLD_NAME (const char *path, NFTW_FUNC_T func, int descriptors, int flags)
 compat_symbol (libc, NFTW_OLD_NAME, NFTW_NAME, GLIBC_2_1);
 #endif
 #endif
+#endif