@@ -363,7 +363,31 @@ else
$(Q)cd $(PREFIX)$(DEVEL_PREFIX)include && $(RM) -f wchar-stub.h
endif
-EMPTY_LIB_NAMES = m crypt nsl resolv util dl rt pthread intl
+EMPTY_LIB_NAMES = dl
+ifeq ($(DO_C99_MATH),y)
+EMPTY_LIB_NAMES += m
+endif
+ifeq ($(UCLIBC_HAS_THREADS),y)
+EMPTY_LIB_NAMES += pthread
+endif
+ifeq ($(UCLIBC_HAS_REALTIME),y)
+EMPTY_LIB_NAMES += rt
+endif
+ifeq ($(UCLIBC_HAS_CRYPT),y)
+EMPTY_LIB_NAMES += crypt
+endif
+ifeq ($(UCLIBC_HAS_LIBUTIL),y)
+EMPTY_LIB_NAMES += util
+endif
+ifeq ($(UCLIBC_HAS_LIBRESOLV_STUB),y)
+EMPTY_LIB_NAMES += resolv
+endif
+ifeq ($(UCLIBC_HAS_LIBNSL_STUB),y)
+EMPTY_LIB_NAMES += nsl
+endif
+ifeq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
+EMPTY_LIB_NAMES += intl
+endif
EMPTY_LIBS = $(EMPTY_LIB_NAMES:%=lib/lib%.a)
$(EMPTY_LIBS):
@@ -42,9 +42,9 @@ else
libc-a-y = $(libc-y) $(libc-static-y)
endif
-libc-a-y += $(libnsl-a-y)
-libc-a-y += $(libresolv-a-y)
-libc-a-y += $(libm-a-y)
+libc-a-$(DO_C99_MATH) += $(libm-a-y)
+libc-a-$(UCLIBC_HAS_LIBNSL_STUB) += $(libnsl-a-y)
+libc-a-$(UCLIBC_HAS_LIBRESOLV_STUB) += $(libresolv-a-y)
libc-a-$(UCLIBC_HAS_LIBUTIL) += $(libutil-a-y)
libc-a-$(UCLIBC_HAS_CRYPT) += $(libcrypt-a-y)
libc-a-$(UCLIBC_HAS_ARGP) += $(libuargp-a-y)
@@ -55,10 +55,10 @@ libc-a-$(UCLIBC_HAS_BACKTRACE) += $(libubacktrace-a-y)
libc-so-y = $(libc-y:.o=.os) $(libc-shared-y)
-libc-so-y += $(libnsl-so-y)
-libc-so-y += $(libresolv-so-y)
libc-so-y += $(libdl-so-y)
-libc-so-y += $(libm-so-y)
+libc-so-$(DO_C99_MATH) += $(libm-so-y)
+libc-so-$(UCLIBC_HAS_LIBNSL_STUB) += $(libnsl-so-y)
+libc-so-$(UCLIBC_HAS_LIBRESOLV_STUB) += $(libresolv-so-y)
libc-so-$(UCLIBC_HAS_LIBUTIL) += $(libutil-so-y)
libc-so-$(UCLIBC_HAS_CRYPT) += $(libcrypt-so-y)
libc-so-$(UCLIBC_HAS_ARGP) += $(libuargp-so-y)
@@ -558,19 +558,14 @@ fail:
--data->ftw.level;
data->ftw.base = previous_base;
- /* Finally, if we process depth-first report the directory. */
- if (result == 0 && (data->flags & FTW_DEPTH))
- result = (*data->func) (data->dirbuf, st, FTW_DP, &data->ftw);
-
- if (old_dir
- && (data->flags & FTW_CHDIR)
+ if ((data->flags & FTW_CHDIR)
&& (result == 0
|| ((data->flags & FTW_ACTIONRETVAL)
&& (result != -1 && result != FTW_STOP))))
{
/* Change back to the parent directory. */
int done = 0;
- if (old_dir->stream != NULL)
+ if (old_dir && old_dir->stream != NULL)
if (__fchdir (dirfd (old_dir->stream)) == 0)
done = 1;
@@ -587,6 +582,10 @@ fail:
}
}
+ /* Finally, if we process depth-first report the directory. */
+ if (result == 0 && (data->flags & FTW_DEPTH))
+ result = (*data->func) (data->dirbuf, st, FTW_DP, &data->ftw);
+
return result;
}
@@ -72,5 +72,9 @@ __start:
0: .asciz "GNU" /* Vendor name */
1: .align 4
2: .long 0 /* Note data: Linux executable */
- .long 3,9,0 /* Earliest compatible kernel */
+#if (__GNUC__ > 4)
+ .long 4,8,0 /* Earliest compatible kernel for ABI v4 */
+#else
+ .long 3,9,0 /* Earliest compatible kernel for ABI v3 */
+#endif
3: .align 4 /* Pad out section */
new file mode 100644
@@ -0,0 +1,57 @@
+#define _XOPEN_SOURCE 500
+#define _GNU_SOURCE
+#include <ftw.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+int result = 0;
+
+static int process_one_entry(const char *fpath, const struct stat *sb,
+ int typeflag, struct FTW *ftwbuf)
+{
+
+ struct stat buf;
+ const char *rel_path = fpath+ftwbuf->base;
+
+ printf("Processing %s in working dir %s\n",
+ rel_path, get_current_dir_name());
+ if (stat(rel_path, &buf) < 0) {
+ perror("Oops...relative path does not exist in current directory");
+ result = 1;
+ }
+}
+
+static int
+do_test(void)
+{
+ char *path = "/tmp/stest_dir";
+ char *subpath = "/tmp/stest_dir/d1";
+ char *filepath = "/tmp/stest_dir/f1";
+ char *filesubpath = "/tmp/stest_dir/d1/f2";
+
+ if ((mkdir(path, 0700)) < 0)
+ perror("Creating path");
+ if ((mkdir(subpath, 0700)) < 0)
+ perror("Creating subpath");
+ if ((open(filepath, O_CREAT)) < 0)
+ perror("Opening filepath");
+ if ((open(filesubpath, O_CREAT)) < 0)
+ perror("Opening filesubpath");
+
+ if (nftw(path, process_one_entry, 100, (FTW_CHDIR|FTW_DEPTH|FTW_PHYS)) < 0)
+ perror("ntfw");
+
+ unlink(filesubpath);
+ unlink(filepath);
+ rmdir(subpath);
+ rmdir(path);
+
+ return result;
+}
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"