diff options
Diffstat (limited to 'libc/misc/ftw')
-rw-r--r-- | libc/misc/ftw/Makefile.in | 15 | ||||
-rw-r--r-- | libc/misc/ftw/ftw.c | 68 | ||||
-rw-r--r-- | libc/misc/ftw/ftw64.c | 4 |
3 files changed, 46 insertions, 41 deletions
diff --git a/libc/misc/ftw/Makefile.in b/libc/misc/ftw/Makefile.in index 6c0304bc8..501b9084d 100644 --- a/libc/misc/ftw/Makefile.in +++ b/libc/misc/ftw/Makefile.in @@ -1,25 +1,22 @@ # Makefile for uClibc # -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> # # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -SRC := ftw.c +CSRC := ftw.c ifeq ($(UCLIBC_HAS_LFS),y) -SRC += ftw64.c +CSRC += ftw64.c endif MISC_FTW_DIR := $(top_srcdir)libc/misc/ftw MISC_FTW_OUT := $(top_builddir)libc/misc/ftw -MISC_FTW_SRC := $(patsubst %.c,$(MISC_FTW_DIR)/%.c,$(SRC)) -MISC_FTW_OBJ := $(patsubst %.c,$(MISC_FTW_OUT)/%.o,$(SRC)) +MISC_FTW_SRC := $(patsubst %.c,$(MISC_FTW_DIR)/%.c,$(CSRC)) +MISC_FTW_OBJ := $(patsubst %.c,$(MISC_FTW_OUT)/%.o,$(CSRC)) -libc-a-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ) -libc-so-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ:.o=.os) - -libc-multi-$(UCLIBC_HAS_FTW) += $(MISC_FTW_SRC) +libc-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ) objclean-y += misc_ftw_objclean diff --git a/libc/misc/ftw/ftw.c b/libc/misc/ftw/ftw.c index fdea1c208..18da40a33 100644 --- a/libc/misc/ftw/ftw.c +++ b/libc/misc/ftw/ftw.c @@ -22,7 +22,6 @@ # include <config.h> #endif -#define _GNU_SOURCE #define _XOPEN_SOURCE 500 #include <features.h> #ifdef __UCLIBC__ @@ -31,17 +30,6 @@ #define HAVE_SYS_PARAM_H 1 #define HAVE_DECL_STPCPY 1 #define HAVE_MEMPCPY 1 -#define dirfd __dirfd -#define tsearch __tsearch -#define tfind __tfind -#define tdestroy __tdestroy -#define getcwd __getcwd -#define chdir __chdir -#define fchdir __fchdir -#define mempcpy __mempcpy -#define opendir __opendir -#define closedir __closedir -#define stpcpy __stpcpy #endif #if __GNUC__ @@ -64,7 +52,7 @@ char *alloca (); #else # if HAVE_DIRENT_H # include <dirent.h> -# define NAMLEN(dirent) __strlen ((dirent)->d_name) +# define NAMLEN(dirent) strlen ((dirent)->d_name) # else # define dirent direct # define NAMLEN(dirent) (dirent)->d_namlen @@ -96,6 +84,28 @@ char *alloca (); # include <sys/stat.h> #endif +libc_hidden_proto(memset) +libc_hidden_proto(strchr) +libc_hidden_proto(strlen) +libc_hidden_proto(dirfd) +libc_hidden_proto(tsearch) +libc_hidden_proto(tfind) +libc_hidden_proto(tdestroy) +libc_hidden_proto(getcwd) +libc_hidden_proto(chdir) +libc_hidden_proto(fchdir) +libc_hidden_proto(mempcpy) +libc_hidden_proto(opendir) +#ifdef __UCLIBC_HAS_LFS__ +libc_hidden_proto(readdir64) +libc_hidden_proto(lstat64) +libc_hidden_proto(stat64) +#endif +libc_hidden_proto(closedir) +libc_hidden_proto(stpcpy) +libc_hidden_proto(lstat) +libc_hidden_proto(stat) + #if ! _LIBC && !HAVE_DECL_STPCPY && !defined stpcpy char *stpcpy (); #endif @@ -108,24 +118,30 @@ char *stpcpy (); /* #define NDEBUG 1 */ #include <assert.h> -#if !defined _LIBC && !defined __UCLIBC__ +#if !defined _LIBC # undef __chdir # define __chdir chdir # undef __closedir # define __closedir closedir # undef __fchdir # define __fchdir fchdir -# ifndef __UCLIBC__ # undef __getcwd +# ifndef __UCLIBC__ # define __getcwd(P, N) xgetcwd () extern char *xgetcwd (void); +# else +# define __getcwd getcwd # endif # undef __mempcpy # define __mempcpy mempcpy # undef __opendir # define __opendir opendir # undef __readdir64 +# ifndef __UCLIBC_HAS_LFS__ # define __readdir64 readdir +# else +# define __readdir64 readdir64 +# endif # undef __stpcpy # define __stpcpy stpcpy # undef __tdestroy @@ -136,8 +152,10 @@ extern char *xgetcwd (void); # define __tsearch tsearch # undef internal_function # define internal_function /* empty */ +# ifndef __UCLIBC_HAS_LFS__ # undef dirent64 # define dirent64 dirent +# endif # undef MAX # define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif @@ -167,21 +185,11 @@ int rpl_lstat (const char *, struct stat *); # define LXSTAT __lxstat # define XSTAT __xstat # else -# ifdef __UCLIBC__ -# define LXSTAT(V,f,sb) __lstat(f,sb) -# define XSTAT(V,f,sb) __stat(f,sb) -# define __readdir64 __readdir -# define dirent64 dirent -# else # define LXSTAT(V,f,sb) lstat (f,sb) # define XSTAT(V,f,sb) stat (f,sb) -# endif # endif # define FTW_FUNC_T __ftw_func_t # define NFTW_FUNC_T __nftw_func_t -extern struct dirent *__readdir (DIR *__dirp) __nonnull ((1)) attribute_hidden; -# else -extern struct dirent64 *__readdir64 (DIR *__dirp) __nonnull ((1)) attribute_hidden; #endif /* We define PATH_MAX if the system does not provide a definition. @@ -520,7 +528,7 @@ fail: /* Next, update the `struct FTW' information. */ ++data->ftw.level; - startp = __strchr (data->dirbuf, '\0'); + startp = strchr (data->dirbuf, '\0'); /* There always must be a directory name. */ assert (startp != data->dirbuf); if (startp[-1] != '/') @@ -556,7 +564,7 @@ fail: while (result == 0 && *runp != '\0') { - char *endp = __strchr (runp, '\0'); + char *endp = strchr (runp, '\0'); result = process_entry (data, &dir, runp, endp - runp); @@ -633,10 +641,10 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, data.actdir = 0; data.dirstreams = (struct dir_data **) alloca (data.maxdir * sizeof (struct dir_data *)); - __memset (data.dirstreams, '\0', data.maxdir * sizeof (struct dir_data *)); + memset (data.dirstreams, '\0', data.maxdir * sizeof (struct dir_data *)); /* PATH_MAX is always defined when we get here. */ - data.dirbufsize = MAX (2 * __strlen (dir), PATH_MAX); + data.dirbufsize = MAX (2 * strlen (dir), PATH_MAX); data.dirbuf = (char *) malloc (data.dirbufsize); if (data.dirbuf == NULL) return -1; @@ -749,7 +757,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, /* Return to the start directory (if necessary). */ if (cwd != NULL) { - int save_err = errno; + save_err = errno; __chdir (cwd); free (cwd); __set_errno (save_err); diff --git a/libc/misc/ftw/ftw64.c b/libc/misc/ftw/ftw64.c index c4edd4d0a..de2fe22d1 100644 --- a/libc/misc/ftw/ftw64.c +++ b/libc/misc/ftw/ftw64.c @@ -24,8 +24,8 @@ #define NFTW_NEW_NAME __new_nftw64 #define INO_T ino64_t #define STAT stat64 -#define LXSTAT(V,f,sb) __lstat64(f,sb) -#define XSTAT(V,f,sb) __stat64(f,sb) +#define LXSTAT(V,f,sb) lstat64(f,sb) +#define XSTAT(V,f,sb) stat64(f,sb) #define FTW_FUNC_T __ftw64_func_t #define NFTW_FUNC_T __nftw64_func_t |