summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/unistd/.cvsignore2
-rw-r--r--libc/unistd/Makefile61
-rw-r--r--libc/unistd/sysconf.c162
3 files changed, 4 insertions, 221 deletions
diff --git a/libc/unistd/.cvsignore b/libc/unistd/.cvsignore
deleted file mode 100644
index dba071497..000000000
--- a/libc/unistd/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-sysconf_*.c
-gen_sysconf
diff --git a/libc/unistd/Makefile b/libc/unistd/Makefile
index a8d974734..2ab770cab 100644
--- a/libc/unistd/Makefile
+++ b/libc/unistd/Makefile
@@ -1,7 +1,6 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU Library General Public License as published by the Free
@@ -16,17 +15,13 @@
# You should have received a copy of the GNU Library General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# Derived in part from the Linux-8086 C library, the GNU C Library, and several
-# other sundry sources. Files within this library are copyright by their
-# respective copyright holders.
TOPDIR=../../
include $(TOPDIR)Rules.mak
DIRS:=
CSRC=execl.c execlp.c execv.c execvep.c execvp.c execle.c \
- sleep.c usleep.c getpass.c sysconf_src.c getlogin.c \
+ sleep.c usleep.c getpass.c sysconf.c getlogin.c \
fpathconf.c confstr.c pathconf.c swab.c usershell.c \
getsubopt.c
ifeq ($(strip $(UCLIBC_HAS_MMU)),y)
@@ -38,13 +33,6 @@ else
CSRC += getopt-susv3.c
endif
-# TESTING -- comment this out if it breaks for you
-ifeq ($(TARGET_ARCH), $(HOST_ARCH))
- SYSCONF = sysconf_native
-else
- SYSCONF = sysconf_$(TARGET_ARCH).c
-endif
-
COBJS=$(patsubst %.c,%.o, $(CSRC))
OBJS=$(COBJS)
@@ -55,47 +43,6 @@ $(LIBC): ar-target subdirs
ar-target: $(OBJS)
$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
-# We are cross-compiling so use the generic sysconf.c.
-sysconf_$(TARGET_ARCH).c: sysconf.c
- @echo warning: sysconf_$(HOST_ARCH).c is older then sysconf.c so using generic sysconf.c
- @echo To build sysconf_$(HOST_ARCH).c run gen_sysconf \> sysconf_$(HOST_ARCH).c on
- @echo your target platform, place in the unistd directory, and rebuild
- cp -f sysconf.c sysconf_$(TARGET_ARCH).c
-
-# We are compiling for the native platform, so build an optimized sysconf.c.
-getpagesize_tester.o:
- $(CC) $(CFLAGS) -D_UCLIBC_GENERATE_SYSCONF_ARCH \
- -c ../sysdeps/linux/common/getpagesize.c -o getpagesize_tester.o
-
-sysconf_tester.o: sysconf.c
- $(CC) $(CFLAGS) -D_UCLIBC_GENERATE_SYSCONF_ARCH -c sysconf.c \
- -o sysconf_tester.o
-
-gen_sysconf_tester.o: sysconf_tester.o getpagesize_tester.o
- @ld -r -o gen_sysconf_tester.o sysconf_tester.o getpagesize_tester.o
- @if nm -s gen_sysconf_tester.o | grep -v "U errno" | grep " U "; then \
- set -e -x; \
- echo warning: missing symbols in gen_sysconf_tester.o so using generic sysconf.c ;\
- cp -f sysconf.c sysconf_src.c ;\
- else \
- set -e -x; \
- if ../extra/gcc-uClibc/gcc-uClibc-$(HOST_ARCH) -static \
- -D_UCLIBC_GENERATE_SYSCONF_MAIN sysconf.c sysconf_tester.o \
- -o gen_sysconf && ./gen_sysconf > sysconf_$(HOST_ARCH).c ;\
- then \
- echo successfully built sysconf_$(HOST_ARCH).c ;\
- else \
- echo warning: build of gen_sysconf failed so using generic sysconf.c ;\
- cp -f sysconf.c sysconf_$(HOST_ARCH).c ;\
- fi ;\
- fi
-
-sysconf_native: gen_sysconf_tester.o
-
-sysconf_src.c: sysconf_$(TARGET_ARCH).c
- cp -f sysconf_$(TARGET_ARCH).c sysconf_src.c
-
-
$(COBJS): %.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
@@ -111,9 +58,9 @@ $(patsubst %, _dir_%, $(DIRS)) : dummy
$(patsubst %, _dirclean_%, $(DIRS)) : dummy
$(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
-.PHONY: dummy sysconf_native
+.PHONY: dummy
dummy:
clean:
- $(RM) *.[oa] *~ core gen_sysconf sysconf_*.c
+ $(RM) *.[oa] *~ core
diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c
index 3aa03ea49..daf0e6144 100644
--- a/libc/unistd/sysconf.c
+++ b/libc/unistd/sysconf.c
@@ -47,7 +47,6 @@ extern int getdtablesize (void);
* repeats and moving to a table-based implementation, we generate 283
* bytes on i386 (-Os -fomit-frame-pointer).
*/
-#ifndef _UCLIBC_GENERATE_SYSCONF_MAIN
#ifdef _UCLIBC_GENERATE_SYSCONF_ARCH
/*
@@ -900,164 +899,3 @@ long int __sysconf(int name)
}
weak_alias(__sysconf, sysconf);
-#endif /* _UCLIBC_GENERATE_SYSCONF_MAIN */
-/***********************************************************************/
-#ifdef _UCLIBC_GENERATE_SYSCONF_MAIN
-
-static long int ret_vals[_UCLIBC_SYSCONF_NUM_VALID_ARGS];
-
-static const char *type_str[] = {
- "char", "short", "int", "long"
-};
-
-static const char *type_fmt[] = { " %4ld", " %6ld", " %8ld", " %8ld" };
-static const int type_mod[] = { 13, 9, 6, 6 };
-
-static int find_or_add_in_table(int index, long int val, int *table,
- int *num_in_table, int add_flag)
-{
- int i;
-
- for (i=0 ; i<*num_in_table ; i++) {
- if (ret_vals[table[i]] == val) {
- return i;
- }
- }
- if (add_flag) {
- table[(*num_in_table)++] = index;
- return i;
- } else {
- return -1;
- }
-}
-
-
-int main(void)
-{
- long int r;
- int type_table[5][_UCLIBC_SYSCONF_NUM_VALID_ARGS];
- int ret_type[_UCLIBC_SYSCONF_NUM_VALID_ARGS];
- int num_type[5];
- int i, j, k, code;
-
- for (i=0 ; i<5 ; i++) {
- num_type[i] = 0;
- }
-
- for (i=0; i<_UCLIBC_SYSCONF_NUM_VALID_ARGS ; i++) {
- __set_errno(0);
- r = ret_vals[i] = sysconf(i);
- switch(errno) {
- case EINVAL: /* we're missing a case! */
- fprintf(stderr,"sysconf.c is broken! case %d missing!\n", i);
- return EXIT_FAILURE;
- case EISNAM: /* function */
- find_or_add_in_table(i,r,type_table[4],num_type+4,1);
- ret_type[i] = 4;
- break;
- case ENOSYS: /* defaults to -1 */
- /* why does this break for shared???? */
- fprintf(stderr,"gen_sysconf advisory --"
- "case %d defaults to -1\n", i);
- /* fall through */
- case 0:
- if ((r>=CHAR_MIN) && (r<=CHAR_MAX)) {
- ret_type[i] = 0;
- find_or_add_in_table(i,r,type_table[0],num_type+0,1);
- } else if ((r>=SHRT_MIN) && (r<=SHRT_MAX)) {
- ret_type[i] = 1;
- find_or_add_in_table(i,r,type_table[1],num_type+1,1);
- } else if ((r>=INT_MIN) && (r<=INT_MAX)) {
- ret_type[i] = 2;
- find_or_add_in_table(i,r,type_table[2],num_type+2,1);
- } else {
- ret_type[i] = 3;
- find_or_add_in_table(i,r,type_table[3],num_type+3,1);
- }
- break;
- default:
- fprintf(stderr,"sysconf.c is broken! errno = %d!\n", errno);
- break;
- }
- }
-
- printf("#include <errno.h>\n#include <unistd.h>\n#include <limits.h>\n\n");
-
- printf("static const unsigned char index[%d] = {",
- _UCLIBC_SYSCONF_NUM_VALID_ARGS);
- for (i=0 ; i<_UCLIBC_SYSCONF_NUM_VALID_ARGS ; i++) {
- if (i) printf(",");
- if (i%15 == 0) printf("\n");
- code = 0;
- for (j=0 ; j<4 ; j++) {
- k = find_or_add_in_table(i,ret_vals[i],type_table[j],num_type+j,0);
- if (k>=0) {
- code += k;
- break;
- }
- code += num_type[j];
- }
- printf(" %3d", code);
- }
- printf("\n};\n\n");
-
- for (j=0 ; j < 4 ; j++) {
- if (num_type[j]) {
- printf("static const %s %s_vals[%d] = {",
- type_str[j], type_str[j], num_type[j]);
- for (i = 0 ; i<num_type[j] ; i++) {
- if (i) printf(",");
- if (i%13 == 0) printf("\n");
- if (ret_vals[type_table[j][i]] == INT_MIN) {
- printf("%12s","INT_MIN");
- } else {
- printf(type_fmt[j], ret_vals[type_table[j][i]]);
- }
-
- }
- printf("\n};\n\n");
- }
- }
-
- printf("long int sysconf(int name)\n{\n\tint i;\n\n"
- "\tif ((name < 0) || (name >= %d)) {\n"
- "\t\terrno=EINVAL;\n"
- "\t\treturn -1;\n"
- "\t}\n\n", _UCLIBC_SYSCONF_NUM_VALID_ARGS);
-
- printf("\ti = index[name];\n\n");
- k = 0;
- for (i=0 ; i<4 ; i++) {
- if (num_type[i]) {
- if (k>0) {
- printf("\ti -= %d;\n", k);
- }
- printf("\tif (i < %d) {\n"
- "\t\treturn %s_vals[i];\n"
- "\t}\n\n",
- num_type[i], type_str[i]);
- k = num_type[i];
- }
- }
-
- if (num_type[4]) {
- if (k>0) {
- printf("\ti -= %d;\n", k);
- }
- printf("\tswitch(i) {\n");
- for (i = 0 ; i<num_type[4] ; i++) {
- printf("\t\tcase %d:\n"
- "\t\t\treturn %s;\n",
- i, (const char *)ret_vals[type_table[4][i]]);
- }
- printf("\t}\n\n");
- }
-
- printf("\treturn -1;\n"
- "}\n");
-
-
- return EXIT_SUCCESS;
-}
-/***********************************************************************/
-#endif