diff options
Diffstat (limited to 'mdk-stage1')
317 files changed, 7634 insertions, 3071 deletions
diff --git a/mdk-stage1/dietlibc/.cvsignore b/mdk-stage1/dietlibc/.cvsignore new file mode 100644 index 000000000..7c88cb004 --- /dev/null +++ b/mdk-stage1/dietlibc/.cvsignore @@ -0,0 +1,12 @@ +t +elftrunc +mapfile +t1 +load +compile +bin-alpha +bin-arm +bin-i386 +bin-mips +bin-ppc +bin-sparc diff --git a/mdk-stage1/dietlibc/Makefile b/mdk-stage1/dietlibc/Makefile index 19fac4a82..eb68a70f2 100644 --- a/mdk-stage1/dietlibc/Makefile +++ b/mdk-stage1/dietlibc/Makefile @@ -1,15 +1,27 @@ -all: start.o dietlibc.a - ARCH=$(shell uname -m | sed 's/i[4-9]86/i386/') +OBJDIR=bin-$(ARCH) + +all: $(OBJDIR) $(OBJDIR)/start.o $(OBJDIR)/dietlibc.a $(OBJDIR)/liblatin1.a $(OBJDIR)/librpc.a $(OBJDIR)/elftrunc $(OBJDIR)/diet + CFLAGS=-pipe CROSS= -VPATH=syscalls.c +CC=gcc -SYSCALLOBJ=$(patsubst syscalls.s/%.S,%.o,$(wildcard syscalls.s/*.S)) +VPATH=lib:libstdio:libugly:libcruft:libcrypt:libshell:liblatin1:librpc:libregex:syscalls.c -LIBOBJ=$(patsubst lib/%.c,%.o,$(wildcard lib/*.c)) +SYSCALLOBJ=$(patsubst syscalls.s/%.S,$(OBJDIR)/%.o,$(wildcard syscalls.s/*.S)) + +LIBOBJ=$(patsubst lib/%.c,$(OBJDIR)/%.o,$(wildcard lib/*.c)) +LIBUGLYOBJ=$(patsubst libugly/%.c,$(OBJDIR)/%.o,$(wildcard libugly/*.c)) +LIBSTDIOOBJ=$(patsubst libstdio/%.c,$(OBJDIR)/%.o,$(wildcard libstdio/*.c)) +LIBCRUFTOBJ=$(patsubst libcruft/%.c,$(OBJDIR)/%.o,$(wildcard libcruft/*.c)) +LIBCRYPTOBJ=$(patsubst libcrypt/%.c,$(OBJDIR)/%.o,$(wildcard libcrypt/*.c)) +LIBSHELLOBJ=$(patsubst libshell/%.c,$(OBJDIR)/%.o,$(wildcard libshell/*.c)) + +LIBRPCOBJ=$(patsubst librpc/%.c,$(OBJDIR)/%.o,$(wildcard librpc/*.c)) +LIBREGEXOBJ=$(patsubst libregex/%.c,$(OBJDIR)/%.o,$(wildcard libregex/*.c)) include $(ARCH)/Makefile.add @@ -17,63 +29,124 @@ ifeq ($(CFLAGS),-pipe) CFLAGS+=-O -fomit-frame-pointer endif -#CFLAGS += -g -CFLAGS += -Wall +ifneq ($(DEBUG),) +CFLAGS = -g +COMMENT = : +endif +CFLAGS += -Wall -Wno-switch + +PWD=$(shell pwd) .SUFFIXES: .SUFFIXES: .S .c -%.o: %.S - $(CROSS)gcc -I. -Iinclude $(CFLAGS) -c $< +$(OBJDIR): + mkdir $@ + +% :: %,v + +$(OBJDIR)/%.o: %.S + $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -c $< -o $@ + +$(OBJDIR)/%.o: %.c + $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -c $< -o $@ + $(COMMENT) $(CROSS)strip -x -R .comment -R .note $@ + +DIETLIBC_OBJ = $(SYSCALLOBJ) $(LIBOBJ) $(LIBSTDIOOBJ) $(LIBUGLYOBJ) \ +$(LIBCRUFTOBJ) $(LIBCRYPTOBJ) $(LIBSHELLOBJ) $(LIBREGEXOBJ) \ +$(OBJDIR)/__longjmp.o $(OBJDIR)/setjmp.o $(OBJDIR)/unified.o \ +$(OBJDIR)/mmap.o $(OBJDIR)/clone.o + +$(OBJDIR)/dietlibc.a: $(DIETLIBC_OBJ) $(OBJDIR)/start.o + $(CROSS)ar cru $@ $(DIETLIBC_OBJ) -%.o: %.c - $(CROSS)gcc -I. -Iinclude $(CFLAGS) -c $< -# $(CROSS)strip -x -R .comment -R .note $@ +$(OBJDIR)/librpc.a: $(LIBRPCOBJ) + $(CROSS)ar cru $@ $(LIBRPCOBJ) -dietlibc.a: $(SYSCALLOBJ) $(LIBOBJ) __longjmp.o longjmp.o setjmp.o \ -start.o unified.o mmap.o - $(CROSS)ar cru dietlibc.a $^ +LIBLATIN1_OBJS=$(patsubst liblatin1/%.c,$(OBJDIR)/%.o,$(wildcard liblatin1/*.c)) +$(OBJDIR)/liblatin1.a: $(LIBLATIN1_OBJS) + $(CROSS)ar cru $@ $^ -libdietc.so: dietlibc.a +$(OBJDIR)/libdietc.so: $(OBJDIR)/dietlibc.a $(CROSS)ld -whole-archive -shared -o $@ $^ $(SYSCALLOBJ): syscalls.h -djb: compile load +$(OBJDIR)/elftrunc: contrib/elftrunc.c $(OBJDIR)/start.o $(OBJDIR)/dietlibc.a + $(CROSS)$(CC) -Iinclude $(CFLAGS) -nostdlib -o $@ $^ -lgcc -compile: - echo 'exec gcc $(CFLAGS) -I$(HOME)/projects/dietlibc/include -c $${1+"$$@"}' > $@ +$(OBJDIR)/diet: diet.c $(OBJDIR)/start.o $(OBJDIR)/dietlibc.a + $(CROSS)$(CC) -Iinclude $(CFLAGS) -nostdlib -o $@ $^ -DDIETHOME=\"$(PWD)\" + $(CROSS)strip -R .comment -R .note $@ + +$(OBJDIR)/djb: $(OBJDIR)/compile $(OBJDIR)/load + +$(OBJDIR)/compile: + echo 'exec gcc $(CFLAGS) -I$(PWD)/$(OBJDIR)/include -c $${1+"$$@"}' > $@ chmod 755 $@ -load: - echo 'main="$$1"; shift; exec gcc -nostdlib -o "$$main" $(HOME)/projects/dietlibc/start.o "$$main".o $${1+"$$@"} $(HOME)/projects/dietlibc/dietlibc.a -lgcc' > $@ +$(OBJDIR)/load: + echo 'main="$$1"; shift; exec gcc -nostdlib -o "$$main" $(PWD)/$(OBJDIR)/start.o "$$main".o $${1+"$$@"} $(PWD)/$(OBJDIR)/dietlibc.a -lgcc' > $@ chmod 755 $@ clean: - rm -f *.o *.a t t1 compile load exports mapfile libdietc.so + rm -f *.o *.a t t1 compile load elftrunc exports mapfile libdietc.so + rm -rf bin-* + $(MAKE) -C examples clean tar: clean - cd .. && tar cvvf dietlibc.tar.bz2 dietlibc --use=bzip2 + rm -f armv4l + ln -sf arm armv4l + cd ..; tar cvvf dietlibc.tar.bz2 dietlibc --use=bzip2 --exclude CVS -exports: dietlibc.a - nm -g dietlibc.a | grep -w T | awk '{ print $$3 }' | sort -u > exports +$(OBJDIR)/exports: $(OBJDIR)/dietlibc.a + nm -g $(OBJDIR)/dietlibc.a | grep -w T | awk '{ print $$3 }' | sort -u > $(OBJDIR)/exports .PHONY: t t1 t: - $(CROSS)gcc -g $(CFLAGS) -fno-builtin -nostdlib -Iinclude -o t t.c start.o dietlibc.a -lgcc -Wl,-Map,mapfile + $(CROSS)$(CC) -g $(CFLAGS) -fno-builtin -nostdlib -Iinclude -o t t.c $(OBJDIR)/start.o $(OBJDIR)/dietlibc.a -lgcc -Wl,-Map,mapfile t1: - $(CROSS)gcc -g -o t1 t.c + $(CROSS)$(CC) -g -o t1 t.c -install: - cp start.o $(prefix)/lib/dietstart.o - cp dietlibc.a $(prefix)/lib/libdietc.a +install: $(OBJDIR)/start.o $(OBJDIR)/dietlibc.a $(OBJDIR)/liblatin1.a $(OBJDIR)/elftrunc $(OBJDIR)/diet + cp $(OBJDIR)/start.o $(INSTALLPREFIX)$(prefix)/lib/dietstart.o + cp $(OBJDIR)/dietlibc.a $(INSTALLPREFIX)$(prefix)/lib/libdietc.a + cp $(OBJDIR)/liblatin1.a $(INSTALLPREFIX)$(prefix)/lib/libdietlatin1.a + cp $(OBJDIR)/diet $(INSTALLPREFIX)$(prefix)/bin/diet .PHONY: sparc ppc mips arm alpha i386 -sparc ppc alpha i386: - $(MAKE) ARCH=$@ CROSS=$@-linux- all t libdietc.so +arm sparc ppc alpha i386: + $(MAKE) ARCH=$@ CROSS=$@-linux- all t bin-$@/libdietc.so + +mips: + $(MAKE) ARCH=$@ CROSS=$@-linux-gnu- all t bin-$@/libdietc.so + +cross: + $(MAKE) arm sparc ppc alpha i386 mips + + +# these depend on dietfeatures.h for large file backward compatibility +$(OBJDIR)/__fstat64.o $(OBJDIR)/__lstat64.o $(OBJDIR)/__stat64.o: dietfeatures.h + +# these depend on dietfeatures.h for thread support +$(OBJDIR)/alloc.o $(OBJDIR)/perror.o $(OBJDIR)/logging.o $(OBJDIR)/unified.o: dietfeatures.h + +# these depend on dietfeatures.h for linker warnings +$(OBJDIR)/assert_fail.o $(OBJDIR)/sprintf.o $(OBJDIR)/vsnprintf.o $(OBJDIR)/___div.o $(OBJDIR)/fflush.o $(OBJDIR)/setvbuf.o $(OBJDIR)/system.o $(OBJDIR)/sendfile.o $(OBJDIR)/setenv.o: dietfeatures.h + +# these depend on dietfeatures.h for buffered stdio +fclose.o $(OBJDIR)/fdglue.o $(OBJDIR)/fflush.o $(OBJDIR)/fgetc.o $(OBJDIR)/fputc.o $(OBJDIR)/fread.o $(OBJDIR)/fseek.o $(OBJDIR)/printf.o $(OBJDIR)/setvbuf.o $(OBJDIR)/stderr.o $(OBJDIR)/stdin.o $(OBJDIR)/stdout.o $(OBJDIR)/fwrite.o $(OBJDIR)/puts.o: dietfeatures.h + +# these depend on dietfeatures.h for fast string routines +strcasecmp.o $(OBJDIR)/strcat.o $(OBJDIR)/strchr.o $(OBJDIR)/strcmp.o $(OBJDIR)/strcpy.o $(OBJDIR)/strlen.o $(OBJDIR)/strncasecmp.o $(OBJDIR)/strncat.o $(OBJDIR)/strrchr.o: dietfeatures.h + +# these depend on dietfeatures.h for /proc +$(OBJDIR)/tty.o: dietfeatures.h -mips arm: - $(MAKE) ARCH=$@ CROSS=$@-linux-gnu- all t libdietc.so +# these depend on dietfeatures.h for ungetc support ;-) +$(OBJDIR)/ungetc.o: dietfeatures.h +# these depend on dietfeatures.h for WANT_TZFILE_PARSER +$(OBJDIR)/localtime_r.o: dietfeatures.h diff --git a/mdk-stage1/dietlibc/README b/mdk-stage1/dietlibc/README index c17aefcc5..ce9838832 100644 --- a/mdk-stage1/dietlibc/README +++ b/mdk-stage1/dietlibc/README @@ -1,11 +1,43 @@ -diet glibc to statically link programs that don't need all the bloat +diet libc to statically link programs that don't need all the bloat from glibc. malloc, printf and scanf contributed from Olaf Dreesen. -Usage: - gcc -I~/dietlibc/include -Os -pipe -c *.c - gcc -nostdlib -o ncp ~/dietlibc/start.o *.o ~/dietlibc/dietlibc.a +To compile: -If you use the glibc includes, directory reading (and maybe other -functions) will fail. You have been warned! + $ make + +make should compile the diet libc itself without warnings. In addition +to the diet libc, the default make target includes t, which is a test +program and probably contains code which produces warnings. You can +safely ignore them. + +When make is done, it will have created dietlibc.a in bin-i386 (or +bin-ppc, bin-alpha, bin-sparc, bin-ppc or bin-arm, depending on your +architecture). In that directory you will also find a program called +"diet", which you need to copy in a directory in your $PATH: + + # install bin-i386/diet /usr/local/bin + +Then you can compile programs by prepending diet to the command line, +i.e. + + $ diet gcc -s -Os -pipe -o t t.c + +diet is cross-compiler friendly and can also be used like this: + + $ diet sparc-linux-gcc -o t t.c + +diet will then link against dietlibc.a from bin-sparc, of course. +diet comes with a man page (diet.1), which you can copy to an +appropriate location, too: + + # cp diet.1 /usr/local/man/man1 + +After you compiled the diet libc successfully, I invite you to check out +the embedded utils (http://www.fefe.de/embutils/) and the diet libc +binary repository (ftp://foobar.math.fu-berlin.de/pub/dietlibc/), too. +The embedded utils are small replacements for common utilities like mv, +chown, ls, and even a small tar that can extract tar files. The binary +repository contains a few utilities I linked against the diet libc, for +example gzip, bzip2 and fdisk. diff --git a/mdk-stage1/dietlibc/alpha/Makefile.add b/mdk-stage1/dietlibc/alpha/Makefile.add index da3791eb6..10ff0faef 100644 --- a/mdk-stage1/dietlibc/alpha/Makefile.add +++ b/mdk-stage1/dietlibc/alpha/Makefile.add @@ -1,5 +1,5 @@ -CFLAGS+=-Os -fno-builtin -Iinclude -fomit-frame-pointer -fstrict-aliasing -override VPATH=alpha:syscalls.s:lib +CFLAGS+=-Os -Iinclude -fomit-frame-pointer -fstrict-aliasing +VPATH:=alpha:syscalls.s:$(VPATH) -LIBOBJ+=divq.o +LIBOBJ+=$(patsubst %,$(OBJDIR)/%,divq.o divl.o remq.o reml.o seteuid.o __time.o) diff --git a/mdk-stage1/dietlibc/alpha/__time.c b/mdk-stage1/dietlibc/alpha/__time.c new file mode 100644 index 000000000..07275e0e3 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/__time.c @@ -0,0 +1,11 @@ +#include <time.h> +#include <sys/time.h> + +time_t time(time_t *foo) { + struct timeval tv; + time_t tmp=(time_t)-1; + if (gettimeofday(&tv,0)==0) + tmp=(time_t)tv.tv_sec; + if (foo) *foo=tmp; + return tmp; +} diff --git a/mdk-stage1/dietlibc/alpha/accept.S b/mdk-stage1/dietlibc/alpha/accept.S index 43a40ee6f..459c45d7a 100644 --- a/mdk-stage1/dietlibc/alpha/accept.S +++ b/mdk-stage1/dietlibc/alpha/accept.S @@ -1,4 +1,3 @@ #include "syscalls.h" -.weak __libc_accept -syscall(accept,accept) +syscall_weak(accept,accept,__libc_accept) diff --git a/mdk-stage1/dietlibc/alpha/clone.S b/mdk-stage1/dietlibc/alpha/clone.S index f01620595..b7e32d707 100644 --- a/mdk-stage1/dietlibc/alpha/clone.S +++ b/mdk-stage1/dietlibc/alpha/clone.S @@ -7,7 +7,7 @@ clone: .global __clone .type __clone,@function -clone: +__clone: ldiq $0, EINVAL beq $16, .Lerror beq $17, .Lerror @@ -17,7 +17,7 @@ clone: stq $19, 8($17) mov $18, $16 - lda $0, __NR_pipe($31) + lda $0, __NR_clone($31) callsys bne $19, .Lerror @@ -38,5 +38,5 @@ clone: ldgp $gp, 0($26) mov $0, $16 - jsr $26, _exit + jsr $26, exit diff --git a/mdk-stage1/dietlibc/alpha/connect.S b/mdk-stage1/dietlibc/alpha/connect.S index da3675760..c191ca808 100644 --- a/mdk-stage1/dietlibc/alpha/connect.S +++ b/mdk-stage1/dietlibc/alpha/connect.S @@ -1,4 +1,3 @@ #include "syscalls.h" -.weak __libc_connect -syscall(connect,connect) +syscall_weak(connect,connect,__libc_connect) diff --git a/mdk-stage1/dietlibc/alpha/divl.S b/mdk-stage1/dietlibc/alpha/divl.S new file mode 100644 index 000000000..3af22a5e8 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/divl.S @@ -0,0 +1,101 @@ +/* taken from glibc 2.2 */ + + .set noreorder + .set noat + + .ent __divlu + .globl __divlu + + .align 3 +__divlu : + lda $30 , - 48 ($30 ) + .frame $30 , 48 , $23 , 0 + .prologue 0 +.Ludiv: + stq $1 , 0($30 ) + zapnot $25 ,15, $1 + stq $2 , 8($30 ) + zapnot $24 ,15, $2 + stq $0 , 16($30 ) + clr $27 + stq $3 , 24($30 ) + ldiq $0 , 1 + stq $4 ,32($30 ) + beq $1 , .Ldivbyzero + + .align 3 + + +1: cmpult $1 , $2 , $at + s8addq $1 , $31 , $1 + s8addq $0 , $31 , $0 + bne $at , 1b + + + +3: addq $27 ,$0 , $4 + srl $0 , 1, $0 + cmpule $1 , $2 , $at + subq $2 , $1 , $3 + cmovne $at ,$4 , $27 + srl $1 , 1, $1 + cmovne $at , $3 , $2 + bne $0 , 3b + +.Ldone: ldq $1 , 0($30 ) + ldq $2 , 8($30 ) + ldq $0 , 16($30 ) + ldq $3 , 24($30 ) + ldq $4 ,32($30 ) + lda $30 , 48 ($30 ) + ret $31 , ($23 ), 1 + +.Ldivbyzero: + mov $16 , $3 + ldiq $16 , -2 + call_pal 170 + mov $3 , $16 + clr $27 + br .Ldone + + .end __divlu + + .ent __divl + .globl __divl + + .align 3 +__divl : + lda $30 , - 48 ($30 ) + .frame $30 , 48 , $23 , 0 + .prologue 0 + or $24 , $25 , $at + sextl $at , $at + bge $at , .Ludiv + + + stq $24 , 0($30 ) + negl $24 , $at + stq $25 , 8($30 ) + cmovge $at , $at , $24 + stq $23 , 16($30 ) + negl $25 , $at + stq $3 , 24($30 ) + cmovge $at , $at , $25 + + + bsr $23 , __divlu + + + ldq $24 , 0($30 ) + ldq $25 , 8($30 ) + xor $24 , $25 , $at + negl $27 , $3 + sextl $at , $at + ldq $23 , 16($30 ) + cmovlt $at , $3 , $27 + ldq $3 , 24($30 ) + + lda $30 , 48 ($30 ) + ret $31 , ($23 ), 1 + + .end __divl diff --git a/mdk-stage1/dietlibc/alpha/msgctl.S b/mdk-stage1/dietlibc/alpha/msgctl.S new file mode 100644 index 000000000..d7caed2cc --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/msgctl.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgctl,msgctl) diff --git a/mdk-stage1/dietlibc/alpha/msgget.S b/mdk-stage1/dietlibc/alpha/msgget.S new file mode 100644 index 000000000..518d67ac4 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/msgget.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgget,msgget) diff --git a/mdk-stage1/dietlibc/alpha/msgrcv.S b/mdk-stage1/dietlibc/alpha/msgrcv.S new file mode 100644 index 000000000..ab62e6c30 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/msgrcv.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgrcv,msgrcv) diff --git a/mdk-stage1/dietlibc/alpha/msgsnd.S b/mdk-stage1/dietlibc/alpha/msgsnd.S new file mode 100644 index 000000000..890a996a2 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/msgsnd.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(msgsnd,msgsnd) diff --git a/mdk-stage1/dietlibc/alpha/recv.S b/mdk-stage1/dietlibc/alpha/recv.S index 71b2e37dc..17664f2e2 100644 --- a/mdk-stage1/dietlibc/alpha/recv.S +++ b/mdk-stage1/dietlibc/alpha/recv.S @@ -1,4 +1,3 @@ #include "syscalls.h" -.weak __libc_recv -syscall(recv,recv) +syscall_weak(recv,recv,__libc_recv) diff --git a/mdk-stage1/dietlibc/alpha/recvfrom.S b/mdk-stage1/dietlibc/alpha/recvfrom.S index 64779cbb8..d8e3922af 100644 --- a/mdk-stage1/dietlibc/alpha/recvfrom.S +++ b/mdk-stage1/dietlibc/alpha/recvfrom.S @@ -1,4 +1,3 @@ #include "syscalls.h" -.weak __libc_recvfrom -syscall(recvfrom,recvfrom) +syscall_weak(recvfrom,recvfrom,__libc_recvfrom) diff --git a/mdk-stage1/dietlibc/alpha/recvmsg.S b/mdk-stage1/dietlibc/alpha/recvmsg.S new file mode 100644 index 000000000..6ce87eebb --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/recvmsg.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(recvmsg,recvmsg) diff --git a/mdk-stage1/dietlibc/alpha/reml.S b/mdk-stage1/dietlibc/alpha/reml.S new file mode 100644 index 000000000..2d89e3280 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/reml.S @@ -0,0 +1,101 @@ +/* taken from glibc 2.2 */ + + .set noreorder + .set noat + + .ent __remlu + .globl __remlu + + .align 3 +__remlu : + lda $30 , -32($30) + .frame $30 , 32 , $23 , 0 + .prologue 0 +.Ludiv: + stq $1 , 0($30) + zapnot $25 , 15 , $1 + stq $2 , 8($30) + zapnot $24 , 15 , $27 + stq $0 , 16($30) + clr $2 + stq $3 , 24($30) + ldiq $0 , 1 + + beq $1 , .Ldivbyzero + + .align 3 + + +1: cmpult $1 , $27 , $at + s8addq $1 , $31 , $1 + s8addq $0 , $31 , $0 + bne $at , 1b + + + +3: + srl $0 , 1 , $0 + cmpule $1 , $27 , $at + subq $27 , $1 , $3 + + srl $1 , 1 , $1 + cmovne $at , $3 , $27 + bne $0 , 3b + +.Ldone: ldq $1 , 0($30) + ldq $2 , 8($30) + ldq $0 , 16($30) + ldq $3 , 24($30) + + lda $30 , 32($30) + ret $31 , ($23), 1 + +.Ldivbyzero: + mov $16 , $3 + ldiq $16 , -2 + call_pal 170 + mov $3 , $16 + clr $27 + br .Ldone + + .end __remlu + + .ent __reml + .globl __reml + + .align 3 +__reml : + lda $30 , - 32 ($30 ) + .frame $30 , 32 , $23 , 0 + .prologue 0 + or $24 , $25 , $at + sextl $at , $at + bge $at , .Ludiv + + + stq $24 , 0($30 ) + negl $24 , $at + stq $25 , 8($30 ) + cmovge $at , $at , $24 + stq $23 , 16($30 ) + negl $25 , $at + stq $3 , 24($30 ) + cmovge $at , $at , $25 + + + bsr $23 , __remlu + + + ldq $24 , 0($30 ) + ldq $25 , 8($30 ) + mov $24 , $at + negl $27 , $3 + sextl $at , $at + ldq $23 , 16($30 ) + cmovlt $at , $3 , $27 + ldq $3 , 24($30 ) + + lda $30 , 32 ($30 ) + ret $31 , ($23 ), 1 + + .end __reml diff --git a/mdk-stage1/dietlibc/alpha/remq.S b/mdk-stage1/dietlibc/alpha/remq.S new file mode 100644 index 000000000..713484da3 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/remq.S @@ -0,0 +1,97 @@ +/* taken from glibc 2.2 */ + + .set noreorder + .set noat + + .ent __remqu + .globl __remqu + + .align 3 +__remqu : + lda $30 , - 32 ($30 ) + .frame $30 , 32 , $23 , 0 + .prologue 0 +.Ludiv: + stq $1 , 0($30 ) + mov $25 , $1 + stq $2 , 8($30 ) + mov $24 , $27 + stq $0 , 16($30 ) + clr $2 + stq $3 , 24($30 ) + ldiq $0 , 1 + + beq $1 , .Ldivbyzero + + .align 3 + +1: cmpult $1 , $27 , $at + blt $1 , 2f + addq $1 , $1 , $1 + addq $0 , $0 , $0 + bne $at , 1b + unop +2: +3: + srl $0 , 1, $0 + cmpule $1 , $27 , $at + subq $27 , $1 , $3 + + srl $1 , 1, $1 + cmovne $at , $3 , $27 + bne $0 , 3b + +.Ldone: ldq $1 , 0($30 ) + ldq $2 , 8($30 ) + ldq $0 , 16($30 ) + ldq $3 , 24($30 ) + + lda $30 , 32 ($30 ) + ret $31 , ($23 ), 1 + +.Ldivbyzero: + mov $16 , $3 + ldiq $16 , -2 + call_pal 170 + mov $3 , $16 + clr $27 + br .Ldone + + .end __remqu + + .ent __remq + .globl __remq + + .align 3 +__remq : + lda $30 , - 32 ($30 ) + .frame $30 , 32 , $23 , 0 + .prologue 0 + or $24 , $25 , $at + + bge $at , .Ludiv + + stq $24 , 0($30 ) + negq $24 , $at + stq $25 , 8($30 ) + cmovge $at , $at , $24 + stq $23 , 16($30 ) + negq $25 , $at + stq $3 , 24($30 ) + cmovge $at , $at , $25 + + bsr $23 , __remqu + + ldq $24 , 0($30 ) + ldq $25 , 8($30 ) + mov $24 , $at + negq $27 , $3 + + ldq $23 , 16($30 ) + cmovlt $at , $3 , $27 + ldq $3 , 24($30 ) + + lda $30 , 32 ($30 ) + ret $31 , ($23 ), 1 + + .end __remq diff --git a/mdk-stage1/dietlibc/alpha/semctl.S b/mdk-stage1/dietlibc/alpha/semctl.S new file mode 100644 index 000000000..e215ed955 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/semctl.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(semctl,semctl) diff --git a/mdk-stage1/dietlibc/alpha/semget.S b/mdk-stage1/dietlibc/alpha/semget.S new file mode 100644 index 000000000..67f488546 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/semget.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(semget,semget) diff --git a/mdk-stage1/dietlibc/alpha/semop.S b/mdk-stage1/dietlibc/alpha/semop.S new file mode 100644 index 000000000..81b6fc606 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/semop.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(semop,semop) diff --git a/mdk-stage1/dietlibc/alpha/send.S b/mdk-stage1/dietlibc/alpha/send.S index baed3b173..cfd11be2a 100644 --- a/mdk-stage1/dietlibc/alpha/send.S +++ b/mdk-stage1/dietlibc/alpha/send.S @@ -1,4 +1,3 @@ #include "syscalls.h" -.weak __libc_send -syscall(send,send) +syscall_weak(send,send,__libc_send) diff --git a/mdk-stage1/dietlibc/alpha/sendmsg.S b/mdk-stage1/dietlibc/alpha/sendmsg.S new file mode 100644 index 000000000..14646ad68 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/sendmsg.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sendmsg,sendmsg) diff --git a/mdk-stage1/dietlibc/alpha/sendto.S b/mdk-stage1/dietlibc/alpha/sendto.S index 19169b26b..17a033011 100644 --- a/mdk-stage1/dietlibc/alpha/sendto.S +++ b/mdk-stage1/dietlibc/alpha/sendto.S @@ -1,4 +1,3 @@ #include "syscalls.h" -.weak __libc_sendto -syscall(sendto,sendto) +syscall_weak(sendto,sendto,__libc_sendto) diff --git a/mdk-stage1/dietlibc/alpha/seteuid.c b/mdk-stage1/dietlibc/alpha/seteuid.c new file mode 100644 index 000000000..a7cf47893 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/seteuid.c @@ -0,0 +1,7 @@ +#include <sys/types.h> +#include <unistd.h> + +#undef seteuid +int seteuid(uid_t euid) { + return setreuid(-1,euid); +} diff --git a/mdk-stage1/dietlibc/alpha/shmat.S b/mdk-stage1/dietlibc/alpha/shmat.S new file mode 100644 index 000000000..51248173d --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/shmat.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmat,shmat) diff --git a/mdk-stage1/dietlibc/alpha/shmctl.S b/mdk-stage1/dietlibc/alpha/shmctl.S new file mode 100644 index 000000000..d56caace4 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/shmctl.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmctl,shmctl) diff --git a/mdk-stage1/dietlibc/alpha/shmdt.S b/mdk-stage1/dietlibc/alpha/shmdt.S new file mode 100644 index 000000000..d9812a799 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/shmdt.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmdt,shmdt) diff --git a/mdk-stage1/dietlibc/alpha/shmget.S b/mdk-stage1/dietlibc/alpha/shmget.S new file mode 100644 index 000000000..82914223f --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/shmget.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shmget,shmget) diff --git a/mdk-stage1/dietlibc/alpha/shutdown.S b/mdk-stage1/dietlibc/alpha/shutdown.S new file mode 100644 index 000000000..9b5139325 --- /dev/null +++ b/mdk-stage1/dietlibc/alpha/shutdown.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(shutdown,shutdown) diff --git a/mdk-stage1/dietlibc/alpha/sigprocmask.S b/mdk-stage1/dietlibc/alpha/sigprocmask.S index 8255a739a..d9da836c2 100644 --- a/mdk-stage1/dietlibc/alpha/sigprocmask.S +++ b/mdk-stage1/dietlibc/alpha/sigprocmask.S @@ -1,7 +1,3 @@ #include "syscalls.h" -.text -.align 2 -.weak sigprocmask -sigprocmask: -syscall(osf_sigprocmask,__sigprocmask) +syscall_weak(osf_sigprocmask,sigprocmask,__sigprocmask) diff --git a/mdk-stage1/dietlibc/alpha/time.S b/mdk-stage1/dietlibc/alpha/time.S index 56a4f9b38..e69de29bb 100644 --- a/mdk-stage1/dietlibc/alpha/time.S +++ b/mdk-stage1/dietlibc/alpha/time.S @@ -1,3 +0,0 @@ -#include "syscalls.h" - -syscall(osf_gettimeofday,time) diff --git a/mdk-stage1/dietlibc/alpha/waitpid.S b/mdk-stage1/dietlibc/alpha/waitpid.S index 0ff429e17..6dc1c99db 100644 --- a/mdk-stage1/dietlibc/alpha/waitpid.S +++ b/mdk-stage1/dietlibc/alpha/waitpid.S @@ -2,8 +2,9 @@ .text .align 2 -.weak __libc_waitpid -.global waitpid +.weak waitpid waitpid: +.global __libc_waitpid +__libc_waitpid: clr $19 br wait4 diff --git a/mdk-stage1/dietlibc/diet.c b/mdk-stage1/dietlibc/diet.c new file mode 100644 index 000000000..1de6befc8 --- /dev/null +++ b/mdk-stage1/dietlibc/diet.c @@ -0,0 +1,112 @@ +#include <string.h> +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> + +/* goal: + * when invoked as + * "diet gcc -c t.c" + * exec + * "gcc -I/path/to/dietlibc/include -c t.c" + * + * when invoked as + * "diet sparc-linux-gcc -o t t.o" + * exec + * "sparc-linux-gcc -nostdlib -static -o t t.o /path/to/dietlibc/bin-sparc/start.o /path/to/dietlibc/bin-sparc/dietlibc.a" +*/ + +void error(const char *message) { + write(2,message,strlen(message)); + exit(1); +} + +int main(int argc,char *argv[]) { + int link=0; + int compile=0; + char diethome[]=DIETHOME; + char platform[1000]=DIETHOME "/bin-"; + char *nostdlib="-nostdlib"; + char *libgcc="-lgcc"; + char dashL[1000]="-L"; + int i; + + if (argc<2) { + error("usage: diet [gcc command line]\n" + "e.g. diet gcc -c t.c\n" + "or diet sparc-linux-gcc -o foo foo.c bar.o\n"); + } + { + char *tmp=strchr(argv[1],0)-2; + char *tmp2; + char *cc=argv[1]; + if (tmp<cc) goto donttouch; + if ((tmp2=strchr(cc,'-'))) { /* cross compiling? */ + int len=strlen(platform); + if (tmp2-cc>90) error("platform name too long!\n"); + memmove(platform+len,argv[1],tmp2-cc); + platform[tmp2-cc+len]=0; +/* printf("found platform %s\n",platform); */ + } else { +#ifdef __sparc__ + strcat(platform,"sparc"); +#endif +#ifdef __ppc__ + strcat(platform,"ppc"); +#endif +#ifdef __i386__ + strcat(platform,"i386"); +#endif +#ifdef __alpha__ + strcat(platform,"alpha"); +#endif +#ifdef __arm__ + strcat(platform,"arm"); +#endif +#ifdef __mips__ + strcat(platform,"mips"); +#endif + } + strcat(dashL,platform); + if (!strcmp(tmp,"cc")) { + char **newargv; + char **dest; + char *a,*b,*c; +/* we need to add -I... if the command line contains -c, -S or -E */ + for (i=2; i<argc; ++i) + if (!strcmp(argv[i],"-c") || !strcmp(argv[i],"-S") || !strcmp(argv[i],"-E")) + compile=1; +/* we need to add -nostdlib if we are not compiling*/ + link=!compile; +#if 0 + for (i=2; i<argc; ++i) + if (!strcmp(argv[i],"-o")) + if (!compile) link=1; +#endif + newargv=alloca(sizeof(char*)*(argc+6)); + a=alloca(strlen(diethome)+20); + b=alloca(strlen(platform)+20); + c=alloca(strlen(platform)+20); + + strcpy(a,"-I"); strcat(a,diethome); strcat(a,"/include"); + strcpy(b,platform); strcat(b,"/start.o"); + strcpy(c,platform); strcat(c,"/dietlibc.a"); + + dest=newargv; + *dest++=argv[1]; + if (link) { *dest++=nostdlib; *dest++=dashL; } + if (compile || link) *dest++=a; + for (i=2; i<argc; ++i) + *dest++=argv[i]; + if (link) { *dest++=b; *dest++=c; *dest++=libgcc; } + *dest=0; + execvp(newargv[0],newargv); + goto error; + } else if (!strcmp(tmp,"ld")) { + } + } +donttouch: + execvp(argv[1],argv+1); +error: + error("execvp failed!\n"); + return 1; +} diff --git a/mdk-stage1/dietlibc/dietfeatures.h b/mdk-stage1/dietlibc/dietfeatures.h index 979b40d62..4552599ea 100644 --- a/mdk-stage1/dietlibc/dietfeatures.h +++ b/mdk-stage1/dietlibc/dietfeatures.h @@ -1,8 +1,11 @@ +#ifndef _DIETFEATURES_H +#define _DIETFEATURES_H /* feel free to comment some of these out to reduce code size */ //#define WANT_FLOATING_POINT_IN_PRINTF //#define WANT_FLOATING_POINT_IN_SCANF +#define WANT_CHARACTER_CLASSES_IN_SCANF #define WANT_NULL_PRINTF #define SLASH_PROC_OK @@ -10,7 +13,30 @@ // #define WANT_BUFFERED_STDIO /* use errno_location instead of errno */ -// #define WANT_THREAD_SAVE +// #define WANT_THREAD_SAFE + +/* make the startcode, etc. dynamic aware */ +/* #undef WANT_DYNAMIC */ /* do you want smaller or faster string routines? */ +/* #define WANT_FASTER_STRING_ROUTINES */ + +/* do you want ungetc? makes fgetc more complex */ +// #define WANT_UNGETC + +// #define WANT_LINKER_WARNINGS + +/* you need to define this if you want to run your programs with large + * file support on kernel 2.2 or 2.4 */ +// #define WANT_LARGEFILE_BACKCOMPAT + +/* do you want localtime(3) to read /etc/localtime? + * Needed for daylight saving time etc. */ +// #define WANT_TZFILE_PARSER + +/* stop uncommenting here ;-) */ +#ifndef WANT_FASTER_STRING_ROUTINES #define WANT_SMALL_STRING_ROUTINES +#endif + +#endif diff --git a/mdk-stage1/dietlibc/dietstdarg.h b/mdk-stage1/dietlibc/dietstdarg.h new file mode 100644 index 000000000..827671b22 --- /dev/null +++ b/mdk-stage1/dietlibc/dietstdarg.h @@ -0,0 +1,12 @@ +#include <stdarg.h> + +/* this assumes that va_copy() will be a macro, it is on gcc */ +#ifndef va_copy +# ifdef __va_copy +# define va_copy(x, y) __va_copy(x, y) +# else +/* assume copying it works... */ +# define va_copy(x, y) x = y +# endif +#endif + diff --git a/mdk-stage1/dietlibc/dietstdio.h b/mdk-stage1/dietlibc/dietstdio.h index 5cacbde23..a1cbeba83 100644 --- a/mdk-stage1/dietlibc/dietstdio.h +++ b/mdk-stage1/dietlibc/dietstdio.h @@ -2,6 +2,9 @@ #include "dietfeatures.h" #include <sys/types.h> +#ifdef WANT_THREAD_SAVE +#include <pthread.h> +#endif #define BUFSIZE 128 @@ -9,10 +12,18 @@ typedef struct __file { int fd; int flags; #ifdef WANT_BUFFERED_STDIO - int seekofs; - int bm; + unsigned int bs; /* read: bytes in buffer */ + unsigned int bm; /* position in buffer */ char buf[BUFSIZE]; - struct __file *next; + struct __file *next; /* for fflush */ +#endif + pid_t popen_kludge; +#ifdef WANT_UNGETC + char ungetbuf; + char ungotten; +#endif +#ifdef WANT_THREAD_SAVE + pthread_mutex_t m; #endif } FILE; @@ -22,6 +33,12 @@ extern FILE *__stdio_root; #define EOFINDICATOR 2 #define BUFINPUT 4 #define BUFLINEWISE 8 +#define NOBUF 16 +#define UNSEEKABLE 32 + +#define _IONBF 0 +#define _IOLBF 1 +#define _IOFBF 2 /* internal function to flush buffer. * However, if next is BUFINPUT and the buffer is an input buffer, it @@ -45,7 +62,7 @@ int putc(int c, FILE *stream); int putchar(int c); int puts(const char *s); -int fseek( FILE *stream, long offset, int whence); +long fseek( FILE *stream, long offset, int whence); long ftell( FILE *stream); void rewind( FILE *stream); int fgetpos( FILE *stream, fpos_t *pos); diff --git a/mdk-stage1/dietlibc/dietwarning.h b/mdk-stage1/dietlibc/dietwarning.h new file mode 100644 index 000000000..f7c67a175 --- /dev/null +++ b/mdk-stage1/dietlibc/dietwarning.h @@ -0,0 +1,23 @@ +#include "dietfeatures.h" + +#ifdef WANT_LINKER_WARNINGS + +#ifndef __ASSEMBLER__ + +#define link_warning(symbol,msg) \ + asm (".section .gnu.warning." symbol "\n\t.string \"" msg "\"\n\t.previous"); + +#else + +#define link_warning(symbol,msg) \ + .section .gnu.warning.##symbol ;\ + .string msg ;\ + .previous + +#endif + +#else + +#define link_warning(foo,bar) + +#endif diff --git a/mdk-stage1/dietlibc/i386/Makefile.add b/mdk-stage1/dietlibc/i386/Makefile.add index 8d2914e66..b685cc360 100644 --- a/mdk-stage1/dietlibc/i386/Makefile.add +++ b/mdk-stage1/dietlibc/i386/Makefile.add @@ -1,3 +1,3 @@ CFLAGS+=-march=i386 -mcpu=i386 -Os -fomit-frame-pointer -override VPATH=i386:syscalls.s:lib +VPATH:=i386:syscalls.s:$(VPATH) diff --git a/mdk-stage1/dietlibc/i386/__longjmp.S b/mdk-stage1/dietlibc/i386/__longjmp.S index 312e01ed1..098275037 100644 --- a/mdk-stage1/dietlibc/i386/__longjmp.S +++ b/mdk-stage1/dietlibc/i386/__longjmp.S @@ -1,6 +1,4 @@ -#define _ASM -#define _SETJMP_H -#include <bits/setjmp.h> +#include <setjmp.h> .text .global __longjmp diff --git a/mdk-stage1/dietlibc/i386/__testandset.S b/mdk-stage1/dietlibc/i386/__testandset.S new file mode 100644 index 000000000..af7b4d5a0 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/__testandset.S @@ -0,0 +1,8 @@ +.text +.global __testandset +__testandset: + xorl %eax, %eax + movl 0x4(%esp),%edx + incl %eax + xchgl %eax,(%edx) + ret diff --git a/mdk-stage1/dietlibc/i386/clone.S b/mdk-stage1/dietlibc/i386/clone.S new file mode 100644 index 000000000..ac02eb468 --- /dev/null +++ b/mdk-stage1/dietlibc/i386/clone.S @@ -0,0 +1,51 @@ +#include <asm/unistd.h> + +.text +.weak clone +clone: +.global __clone +__clone: + movl 4(%esp), %ecx /* have non null thread_funcion */ + testl %ecx, %ecx + je .Lclone_error + + movl 8(%esp), %ecx /* have non null child_stack pointer */ + testl %ecx, %ecx + je .Lclone_error + + /* put the parameter on thread stack */ + subl $8, %ecx + + movl 16(%esp), %eax /* arg */ + movl %eax, 4(%ecx) + + movl 4(%esp), %eax /* thread_func */ + movl %eax, 0(%ecx) + + /* the syscall */ + pushl %ebx + movl 16(%esp), %ebx /* flags */ + movl $__NR_clone, %eax + int $0x80 + popl %ebx + + testl %eax, %eax + jl .Lclone_error + je .Lstart_thread + ret + +.Lstart_thread: + xorl %ebp,%ebp + call *%ebx + pushl %eax + call _exit + +.Lclone_error: + negl %eax + pushl %eax + call __errno_location + popl %ecx + movl %ecx, (%eax) + xorl %eax, %eax + decl %eax + ret diff --git a/mdk-stage1/dietlibc/i386/select.S b/mdk-stage1/dietlibc/i386/select.S index 6e9fce8e3..9e7066eae 100644 --- a/mdk-stage1/dietlibc/i386/select.S +++ b/mdk-stage1/dietlibc/i386/select.S @@ -1,6 +1,3 @@ #include "syscalls.h" -.text -.weak select -select: -syscall(_newselect,select) +syscall_weak(_newselect,select,__libc_select) diff --git a/mdk-stage1/dietlibc/i386/setjmp.S b/mdk-stage1/dietlibc/i386/setjmp.S index d7898e58f..9bfecf565 100644 --- a/mdk-stage1/dietlibc/i386/setjmp.S +++ b/mdk-stage1/dietlibc/i386/setjmp.S @@ -1,6 +1,4 @@ -#define _ASM -#define _SETJMP_H -#include <bits/setjmp.h> +#include <setjmp.h> /* setjmp for i386. Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. diff --git a/mdk-stage1/dietlibc/i386/start.S b/mdk-stage1/dietlibc/i386/start.S index 8a2ba7e38..167bb779c 100644 --- a/mdk-stage1/dietlibc/i386/start.S +++ b/mdk-stage1/dietlibc/i386/start.S @@ -6,19 +6,33 @@ _start: #if 0 popl %ecx - movl %esp, %edx + movl %esp, %esi leal 4(%esp,%ecx,4),%eax #else movl (%esp),%ecx /* %ecx = argc */ - leal 4(%esp),%edx /* %edx = argv */ + leal 4(%esp),%esi /* %esi = argv */ - leal 4(%edx,%ecx,4),%eax /* eax = 4*ecx+4 = envp */ + leal 4(%esi,%ecx,4),%eax /* eax = 4*ecx+4 = envp */ #endif pushl %eax - pushl %edx + pushl %esi pushl %ecx movl %eax,environ +#ifdef WANT_DYNAMIC +/* in %edx we have the dynamic _fini ( register this if non null ) */ + test %edx, %edx + je .Linit + push %edx + call atexit + pop %edx +.Linit: + call _init + push $_fini + call atexit + pop %edx +#endif + call main pushl %eax call exit diff --git a/mdk-stage1/dietlibc/i386/strchr.S b/mdk-stage1/dietlibc/i386/strchr.S deleted file mode 100644 index 0a2a5aa52..000000000 --- a/mdk-stage1/dietlibc/i386/strchr.S +++ /dev/null @@ -1,47 +0,0 @@ -#define NEW - -.text -.global strchr -strchr: - mov %esi,%edx - mov 0x4(%esp,1),%esi - mov 0x8(%esp,1),%cl - cld -.L1: - lods (%esi),%eax - cmp %al,%cl - jz .Lafound - test %al,%al - jz .Lnotfound - - cmp %ah,%cl - jz .Lbfound - test %ah,%ah - jz .Lnotfound - - shr $16,%eax - cmp %al,%cl - jz .Lcfound - test %al,%al - jz .Lnotfound - - cmp %ah,%cl - jz .Ldfound - test %ah,%ah - - jnz .L1 -.Lnotfound: - sub %eax,%eax - mov %edx,%esi - ret -.Lafound: - dec %esi -.Lbfound: - dec %esi -.Lcfound: - dec %esi -.Ldfound: - mov %esi,%eax - mov %edx,%esi - dec %eax - ret diff --git a/mdk-stage1/dietlibc/i386/unified.S b/mdk-stage1/dietlibc/i386/unified.S index 740cb0ecc..f182bdb4b 100644 --- a/mdk-stage1/dietlibc/i386/unified.S +++ b/mdk-stage1/dietlibc/i386/unified.S @@ -3,15 +3,16 @@ .text .global __unified_syscall __unified_syscall: - and $0xff,%eax + movzbl %al, %eax push %edi push %esi push %ebx - movl 0x10(%esp),%ebx - movl 0x14(%esp),%ecx - movl 0x18(%esp),%edx - movl 0x1c(%esp),%esi - movl 0x20(%esp),%edi + movl %esp,%edi + movl 0x10(%edi),%ebx + movl 0x14(%edi),%ecx + movl 0x18(%edi),%edx + movl 0x1c(%edi),%esi + movl 0x20(%edi),%edi int $0x80 cmp $-124,%eax jbe .Lnoerror diff --git a/mdk-stage1/dietlibc/include/alloca.h b/mdk-stage1/dietlibc/include/alloca.h new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/mdk-stage1/dietlibc/include/alloca.h diff --git a/mdk-stage1/dietlibc/include/arpa/inet.h b/mdk-stage1/dietlibc/include/arpa/inet.h index 6aa71a162..6d5a6dc35 100644 --- a/mdk-stage1/dietlibc/include/arpa/inet.h +++ b/mdk-stage1/dietlibc/include/arpa/inet.h @@ -3,6 +3,7 @@ #include <sys/cdefs.h> #include <sys/types.h> +#include <netinet/in.h> int inet_aton(const char *cp, struct in_addr *inp) __THROW; unsigned long int inet_addr(const char *cp) __THROW; @@ -12,4 +13,7 @@ struct in_addr inet_makeaddr(int net, int host) __THROW; unsigned long int inet_lnaof(struct in_addr in) __THROW; unsigned long int inet_netof(struct in_addr in) __THROW; +int inet_pton (int AF, const char* CP, void* BUF) __THROW; +const char* inet_ntop (int AF, const void* CP, char* BUF, size_t LEN) __THROW; + #endif diff --git a/mdk-stage1/dietlibc/include/arpa/nameser.h b/mdk-stage1/dietlibc/include/arpa/nameser.h new file mode 100644 index 000000000..1ee048d66 --- /dev/null +++ b/mdk-stage1/dietlibc/include/arpa/nameser.h @@ -0,0 +1,217 @@ +#ifndef _ARPA_NAMESER_H +#define _ARPA_NAMESER_H + +#include <endian.h> + +#define NS_PACKETSZ 512 /* maximum packet size */ +#define NS_MAXDNAME 1025 /* maximum domain name */ +#define NS_MAXCDNAME 255 /* maximum compressed domain name */ +#define NS_MAXLABEL 63 /* maximum length of domain label */ +#define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */ +#define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */ +#define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ +#define NS_INT32SZ 4 /* #/bytes of data in a u_int32_t */ +#define NS_INT16SZ 2 /* #/bytes of data in a u_int16_t */ +#define NS_INT8SZ 1 /* #/bytes of data in a u_int8_t */ +#define NS_INADDRSZ 4 /* IPv4 T_A */ +#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */ +#define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */ +#define NS_DEFAULTPORT 53 /* For both TCP and UDP. */ + +/* + * Currently defined type values for resources and queries. + */ +typedef enum __ns_type { + ns_t_invalid = 0, /* Cookie. */ + ns_t_a = 1, /* Host address. */ + ns_t_ns = 2, /* Authoritative server. */ + ns_t_md = 3, /* Mail destination. */ + ns_t_mf = 4, /* Mail forwarder. */ + ns_t_cname = 5, /* Canonical name. */ + ns_t_soa = 6, /* Start of authority zone. */ + ns_t_mb = 7, /* Mailbox domain name. */ + ns_t_mg = 8, /* Mail group member. */ + ns_t_mr = 9, /* Mail rename name. */ + ns_t_null = 10, /* Null resource record. */ + ns_t_wks = 11, /* Well known service. */ + ns_t_ptr = 12, /* Domain name pointer. */ + ns_t_hinfo = 13, /* Host information. */ + ns_t_minfo = 14, /* Mailbox information. */ + ns_t_mx = 15, /* Mail routing information. */ + ns_t_txt = 16, /* Text strings. */ + ns_t_rp = 17, /* Responsible person. */ + ns_t_afsdb = 18, /* AFS cell database. */ + ns_t_x25 = 19, /* X_25 calling address. */ + ns_t_isdn = 20, /* ISDN calling address. */ + ns_t_rt = 21, /* Router. */ + ns_t_nsap = 22, /* NSAP address. */ + ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */ + ns_t_sig = 24, /* Security signature. */ + ns_t_key = 25, /* Security key. */ + ns_t_px = 26, /* X.400 mail mapping. */ + ns_t_gpos = 27, /* Geographical position (withdrawn). */ + ns_t_aaaa = 28, /* Ip6 Address. */ + ns_t_loc = 29, /* Location Information. */ + ns_t_nxt = 30, /* Next domain (security). */ + ns_t_eid = 31, /* Endpoint identifier. */ + ns_t_nimloc = 32, /* Nimrod Locator. */ + ns_t_srv = 33, /* Server Selection. */ + ns_t_atma = 34, /* ATM Address */ + ns_t_naptr = 35, /* Naming Authority PoinTeR */ + ns_t_kx = 36, /* Key Exchange */ + ns_t_cert = 37, /* Certification record */ + ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */ + ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */ + ns_t_sink = 40, /* Kitchen sink (experimentatl) */ + ns_t_opt = 41, /* EDNS0 option (meta-RR) */ + ns_t_tsig = 250, /* Transaction signature. */ + ns_t_ixfr = 251, /* Incremental zone transfer. */ + ns_t_axfr = 252, /* Transfer zone of authority. */ + ns_t_mailb = 253, /* Transfer mailbox records. */ + ns_t_maila = 254, /* Transfer mail agent records. */ + ns_t_any = 255, /* Wildcard match. */ + ns_t_zxfr = 256, /* BIND-specific, nonstandard. */ + ns_t_max = 65536 +} ns_type; + +/* + * Values for class field + */ +typedef enum __ns_class { + ns_c_invalid = 0, /* Cookie. */ + ns_c_in = 1, /* Internet. */ + ns_c_2 = 2, /* unallocated/unsupported. */ + ns_c_chaos = 3, /* MIT Chaos-net. */ + ns_c_hs = 4, /* MIT Hesiod. */ + /* Query class values which do not appear in resource records */ + ns_c_none = 254, /* for prereq. sections in update requests */ + ns_c_any = 255, /* Wildcard match. */ + ns_c_max = 65536 +} ns_class; + +typedef struct { + unsigned id :16; /* query identification number */ +#if BYTE_ORDER == BIG_ENDIAN + /* fields in third byte */ + unsigned qr: 1; /* response flag */ + unsigned opcode: 4; /* purpose of message */ + unsigned aa: 1; /* authoritive answer */ + unsigned tc: 1; /* truncated message */ + unsigned rd: 1; /* recursion desired */ + /* fields in fourth byte */ + unsigned ra: 1; /* recursion available */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ad: 1; /* authentic data from named */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned rcode :4; /* response code */ +#endif +#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN + /* fields in third byte */ + unsigned rd :1; /* recursion desired */ + unsigned tc :1; /* truncated message */ + unsigned aa :1; /* authoritive answer */ + unsigned opcode :4; /* purpose of message */ + unsigned qr :1; /* response flag */ + /* fields in fourth byte */ + unsigned rcode :4; /* response code */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned ad: 1; /* authentic data from named */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ra :1; /* recursion available */ +#endif + /* remaining bytes */ + unsigned qdcount :16; /* number of question entries */ + unsigned ancount :16; /* number of answer entries */ + unsigned nscount :16; /* number of authority entries */ + unsigned arcount :16; /* number of resource entries */ +} HEADER; + +#define PACKETSZ NS_PACKETSZ +#define MAXDNAME NS_MAXDNAME +#define MAXCDNAME NS_MAXCDNAME +#define MAXLABEL NS_MAXLABEL +#define HFIXEDSZ NS_HFIXEDSZ +#define QFIXEDSZ NS_QFIXEDSZ +#define RRFIXEDSZ NS_RRFIXEDSZ +#define INT32SZ NS_INT32SZ +#define INT16SZ NS_INT16SZ +#define INADDRSZ NS_INADDRSZ +#define IN6ADDRSZ NS_IN6ADDRSZ +#define INDIR_MASK NS_CMPRSFLGS +#define NAMESERVER_PORT NS_DEFAULTPORT + +#define S_ZONE ns_s_zn +#define S_PREREQ ns_s_pr +#define S_UPDATE ns_s_ud +#define S_ADDT ns_s_ar + +#define QUERY ns_o_query +#define IQUERY ns_o_iquery +#define STATUS ns_o_status +#define NS_NOTIFY_OP ns_o_notify +#define NS_UPDATE_OP ns_o_update + +#define NOERROR ns_r_noerror +#define FORMERR ns_r_formerr +#define SERVFAIL ns_r_servfail +#define NXDOMAIN ns_r_nxdomain +#define NOTIMP ns_r_notimpl +#define REFUSED ns_r_refused +#define YXDOMAIN ns_r_yxdomain +#define YXRRSET ns_r_yxrrset +#define NXRRSET ns_r_nxrrset +#define NOTAUTH ns_r_notauth +#define NOTZONE ns_r_notzone + +#define DELETE ns_uop_delete +#define ADD ns_uop_add + +#define T_A ns_t_a +#define T_NS ns_t_ns +#define T_MD ns_t_md +#define T_MF ns_t_mf +#define T_CNAME ns_t_cname +#define T_SOA ns_t_soa +#define T_MB ns_t_mb +#define T_MG ns_t_mg +#define T_MR ns_t_mr +#define T_NULL ns_t_null +#define T_WKS ns_t_wks +#define T_PTR ns_t_ptr +#define T_HINFO ns_t_hinfo +#define T_MINFO ns_t_minfo +#define T_MX ns_t_mx +#define T_TXT ns_t_txt +#define T_RP ns_t_rp +#define T_AFSDB ns_t_afsdb +#define T_X25 ns_t_x25 +#define T_ISDN ns_t_isdn +#define T_RT ns_t_rt +#define T_NSAP ns_t_nsap +#define T_NSAP_PTR ns_t_nsap_ptr +#define T_SIG ns_t_sig +#define T_KEY ns_t_key +#define T_PX ns_t_px +#define T_GPOS ns_t_gpos +#define T_AAAA ns_t_aaaa +#define T_LOC ns_t_loc +#define T_NXT ns_t_nxt +#define T_EID ns_t_eid +#define T_NIMLOC ns_t_nimloc +#define T_SRV ns_t_srv +#define T_ATMA ns_t_atma +#define T_NAPTR ns_t_naptr +#define T_TSIG ns_t_tsig +#define T_IXFR ns_t_ixfr +#define T_AXFR ns_t_axfr +#define T_MAILB ns_t_mailb +#define T_MAILA ns_t_maila +#define T_ANY ns_t_any + +#define C_IN ns_c_in +#define C_CHAOS ns_c_chaos +#define C_HS ns_c_hs +#define C_NONE ns_c_none +#define C_ANY ns_c_any + +#endif diff --git a/mdk-stage1/dietlibc/include/assert.h b/mdk-stage1/dietlibc/include/assert.h index adf956022..bb573d0f2 100644 --- a/mdk-stage1/dietlibc/include/assert.h +++ b/mdk-stage1/dietlibc/include/assert.h @@ -15,9 +15,13 @@ extern void __assert_fail (__const char *__assertion, __const char *__file, #endif #undef assert +#ifdef NDEBUG +#define assert(expr) +#else # define assert(expr) \ ((void) ((expr) ? 0 : \ (__assert_fail (#expr, \ __FILE__, __LINE__, __ASSERT_FUNCTION), 0))) +#endif #endif diff --git a/mdk-stage1/dietlibc/include/ctype.h b/mdk-stage1/dietlibc/include/ctype.h index c8f4e5a34..9322e8c7b 100644 --- a/mdk-stage1/dietlibc/include/ctype.h +++ b/mdk-stage1/dietlibc/include/ctype.h @@ -3,11 +3,26 @@ #include <sys/cdefs.h> -extern int isascii (int c) __THROW; -extern int isblank (int c) __THROW; -extern int isalnum (int c) __THROW; -extern int isalpha (int c) __THROW; -extern int isdigit (int c) __THROW; -extern int isspace (int c) __THROW; +extern int isascii (int c) __THROW __attribute__ ((__const__)); +extern int isblank (int c) __THROW __attribute__ ((__const__)); +extern int isalnum (int c) __THROW __attribute__ ((__const__)); +extern int isalpha (int c) __THROW __attribute__ ((__const__)); +extern int isdigit (int c) __THROW __attribute__ ((__const__)); +extern int isspace (int c) __THROW __attribute__ ((__const__)); + +extern int isupper (int c) __THROW __attribute__ ((__const__)); +extern int islower (int c) __THROW __attribute__ ((__const__)); + +extern int tolower(int c) __THROW __attribute__ ((__const__)); +extern int toupper(int c) __THROW __attribute__ ((__const__)); + +extern int isprint(int c) __THROW __attribute__ ((__const__)); +extern int ispunct(int c) __THROW __attribute__ ((__const__)); +extern int iscntrl(int c) __THROW __attribute__ ((__const__)); + +/* fscking GNU extensions! */ +extern int isxdigit(int c) __THROW __attribute__ ((__const__)); + +extern int isgraph(int c) __THROW __attribute__ ((__const__)); #endif diff --git a/mdk-stage1/dietlibc/include/daemon.h b/mdk-stage1/dietlibc/include/daemon.h new file mode 100644 index 000000000..9049f367d --- /dev/null +++ b/mdk-stage1/dietlibc/include/daemon.h @@ -0,0 +1,6 @@ +#ifndef _DAEMON_H +#define _DAEMON_H + +extern int daemon (int nochdir,int noclose); + +#endif diff --git a/mdk-stage1/dietlibc/include/dirent.h b/mdk-stage1/dietlibc/include/dirent.h index d277c0762..b0ad4f5ec 100644 --- a/mdk-stage1/dietlibc/include/dirent.h +++ b/mdk-stage1/dietlibc/include/dirent.h @@ -6,33 +6,6 @@ #include <linux/dirent.h> -#if 0 -struct dirent - { -#ifndef __USE_FILE_OFFSET64 - ino_t d_ino; - off_t d_off; -#else - ino64_t d_ino; - off64_t d_off; -#endif - unsigned short int d_reclen; - unsigned char d_type; - char d_name[256]; /* We must not include limits.h! */ - }; - -#ifdef __USE_LARGEFILE64 -struct dirent64 - { - ino64_t d_ino; - off64_t d_off; - unsigned short int d_reclen; - unsigned char d_type; - char d_name[256]; /* We must not include limits.h! */ - }; -#endif -#endif - #define d_fileno d_ino /* Backwards compatibility. */ #undef _DIRENT_HAVE_D_NAMLEN @@ -40,14 +13,6 @@ struct dirent64 #define _DIRENT_HAVE_D_OFF #define _DIRENT_HAVE_D_TYPE -#define opendir(name) __dietopendir(name) -#define closedir(dir) __dietclosedir(dir) -#define readdir(dir) __dietreaddir(dir) -#define readdir64(dir) __dietreaddir64(dir) -#define rewinddir(dir) __dietrewinddir64(dir) -#define seekdir(dir,pos) __dietseekdir(dir,pos) -#define telldir(dir) __diettelldir(dir) - typedef struct __dirstream DIR; DIR *opendir (const char *__name) __THROW; diff --git a/mdk-stage1/dietlibc/include/dlfcn.h b/mdk-stage1/dietlibc/include/dlfcn.h new file mode 100644 index 000000000..b96f8f615 --- /dev/null +++ b/mdk-stage1/dietlibc/include/dlfcn.h @@ -0,0 +1,15 @@ +#ifndef _DLFCN_H +#define _DLFCN_H 1 + +#define RTLD_LAZY 0x00000 +#define RTLD_NOW 0x00001 + +#define RTLD_LOCAL 0x00000 +#define RTLD_GLOBAL 0x10000 + +void *dlopen (const char *filename, int flag); +const char *dlerror(void); +void *dlsym(void *handle, char *symbol); +int dlclose (void *handle); + +#endif diff --git a/mdk-stage1/dietlibc/include/elf.h b/mdk-stage1/dietlibc/include/elf.h index bf9f1ea89..be09dbee4 100644 --- a/mdk-stage1/dietlibc/include/elf.h +++ b/mdk-stage1/dietlibc/include/elf.h @@ -1,1989 +1 @@ -/* This file defines standard ELF types, structures, and macros. - Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library 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 Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _ELF_H -#define _ELF_H 1 - -/* Standard ELF types. */ - -#include <stdint.h> - -/* Type for a 16-bit quantity. */ -typedef uint16_t Elf32_Half; -typedef uint16_t Elf64_Half; - -/* Types for signed and unsigned 32-bit quantities. */ -typedef uint32_t Elf32_Word; -typedef int32_t Elf32_Sword; -typedef uint32_t Elf64_Word; -typedef int32_t Elf64_Sword; - -/* Types for signed and unsigned 64-bit quantities. */ -typedef uint64_t Elf32_Xword; -typedef int64_t Elf32_Sxword; -typedef uint64_t Elf64_Xword; -typedef int64_t Elf64_Sxword; - -/* Type of addresses. */ -typedef uint32_t Elf32_Addr; -typedef uint64_t Elf64_Addr; - -/* Type of file offsets. */ -typedef uint32_t Elf32_Off; -typedef uint64_t Elf64_Off; - -/* Type for section indices, which are 16-bit quantities. */ -typedef uint16_t Elf32_Section; -typedef uint16_t Elf64_Section; - -/* Type for version symbol information. */ -typedef Elf32_Half Elf32_Versym; -typedef Elf64_Half Elf64_Versym; - - -/* The ELF file header. This appears at the start of every ELF file. */ - -#define EI_NIDENT (16) - -typedef struct -{ - unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ - Elf32_Half e_type; /* Object file type */ - Elf32_Half e_machine; /* Architecture */ - Elf32_Word e_version; /* Object file version */ - Elf32_Addr e_entry; /* Entry point virtual address */ - Elf32_Off e_phoff; /* Program header table file offset */ - Elf32_Off e_shoff; /* Section header table file offset */ - Elf32_Word e_flags; /* Processor-specific flags */ - Elf32_Half e_ehsize; /* ELF header size in bytes */ - Elf32_Half e_phentsize; /* Program header table entry size */ - Elf32_Half e_phnum; /* Program header table entry count */ - Elf32_Half e_shentsize; /* Section header table entry size */ - Elf32_Half e_shnum; /* Section header table entry count */ - Elf32_Half e_shstrndx; /* Section header string table index */ -} Elf32_Ehdr; - -typedef struct -{ - unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ - Elf64_Half e_type; /* Object file type */ - Elf64_Half e_machine; /* Architecture */ - Elf64_Word e_version; /* Object file version */ - Elf64_Addr e_entry; /* Entry point virtual address */ - Elf64_Off e_phoff; /* Program header table file offset */ - Elf64_Off e_shoff; /* Section header table file offset */ - Elf64_Word e_flags; /* Processor-specific flags */ - Elf64_Half e_ehsize; /* ELF header size in bytes */ - Elf64_Half e_phentsize; /* Program header table entry size */ - Elf64_Half e_phnum; /* Program header table entry count */ - Elf64_Half e_shentsize; /* Section header table entry size */ - Elf64_Half e_shnum; /* Section header table entry count */ - Elf64_Half e_shstrndx; /* Section header string table index */ -} Elf64_Ehdr; - -/* Fields in the e_ident array. The EI_* macros are indices into the - array. The macros under each EI_* macro are the values the byte - may have. */ - -#define EI_MAG0 0 /* File identification byte 0 index */ -#define ELFMAG0 0x7f /* Magic number byte 0 */ - -#define EI_MAG1 1 /* File identification byte 1 index */ -#define ELFMAG1 'E' /* Magic number byte 1 */ - -#define EI_MAG2 2 /* File identification byte 2 index */ -#define ELFMAG2 'L' /* Magic number byte 2 */ - -#define EI_MAG3 3 /* File identification byte 3 index */ -#define ELFMAG3 'F' /* Magic number byte 3 */ - -/* Conglomeration of the identification bytes, for easy testing as a word. */ -#define ELFMAG "\177ELF" -#define SELFMAG 4 - -#define EI_CLASS 4 /* File class byte index */ -#define ELFCLASSNONE 0 /* Invalid class */ -#define ELFCLASS32 1 /* 32-bit objects */ -#define ELFCLASS64 2 /* 64-bit objects */ -#define ELFCLASSNUM 3 - -#define EI_DATA 5 /* Data encoding byte index */ -#define ELFDATANONE 0 /* Invalid data encoding */ -#define ELFDATA2LSB 1 /* 2's complement, little endian */ -#define ELFDATA2MSB 2 /* 2's complement, big endian */ -#define ELFDATANUM 3 - -#define EI_VERSION 6 /* File version byte index */ - /* Value must be EV_CURRENT */ - -#define EI_OSABI 7 /* OS ABI identification */ -#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ -#define ELFOSABI_HPUX 1 /* HP-UX */ -#define ELFOSABI_ARM 97 /* ARM */ -#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ - -#define EI_ABIVERSION 8 /* ABI version */ - -#define EI_PAD 9 /* Byte index of padding bytes */ - -/* Legal values for e_type (object file type). */ - -#define ET_NONE 0 /* No file type */ -#define ET_REL 1 /* Relocatable file */ -#define ET_EXEC 2 /* Executable file */ -#define ET_DYN 3 /* Shared object file */ -#define ET_CORE 4 /* Core file */ -#define ET_NUM 5 /* Number of defined types */ -#define ET_LOOS 0xfe00 /* OS-specific range start */ -#define ET_HIOS 0xfeff /* OS-specific range end */ -#define ET_LOPROC 0xff00 /* Processor-specific range start */ -#define ET_HIPROC 0xffff /* Processor-specific range end */ - -/* Legal values for e_machine (architecture). */ - -#define EM_NONE 0 /* No machine */ -#define EM_M32 1 /* AT&T WE 32100 */ -#define EM_SPARC 2 /* SUN SPARC */ -#define EM_386 3 /* Intel 80386 */ -#define EM_68K 4 /* Motorola m68k family */ -#define EM_88K 5 /* Motorola m88k family */ -#define EM_860 7 /* Intel 80860 */ -#define EM_MIPS 8 /* MIPS R3000 big-endian */ -#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ - -#define EM_PARISC 15 /* HPPA */ -#define EM_VPP500 17 /* Fujitsu VPP500 */ -#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ -#define EM_960 19 /* Intel 80960 */ -#define EM_PPC 20 /* PowerPC */ -#define EM_PPC64 21 /* PowerPC 64-bit */ - -#define EM_V800 36 /* NEC V800 series */ -#define EM_FR20 37 /* Fujitsu FR20 */ -#define EM_RH32 38 /* TRW RH-32 */ -#define EM_RCE 39 /* Motorola RCE */ -#define EM_ARM 40 /* ARM */ -#define EM_FAKE_ALPHA 41 /* Digital Alpha */ -#define EM_SH 42 /* Hitachi SH */ -#define EM_SPARCV9 43 /* SPARC v9 64-bit */ -#define EM_TRICORE 44 /* Siemens Tricore */ -#define EM_ARC 45 /* Argonaut RISC Core */ -#define EM_H8_300 46 /* Hitachi H8/300 */ -#define EM_H8_300H 47 /* Hitachi H8/300H */ -#define EM_H8S 48 /* Hitachi H8S */ -#define EM_H8_500 49 /* Hitachi H8/500 */ -#define EM_IA_64 50 /* Intel Merced */ -#define EM_MIPS_X 51 /* Stanford MIPS-X */ -#define EM_COLDFIRE 52 /* Motorola Coldfire */ -#define EM_68HC12 53 /* Motorola M68HC12 */ -#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ -#define EM_PCP 55 /* Siemens PCP */ -#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ -#define EM_NDR1 57 /* Denso NDR1 microprocessor */ -#define EM_STARCORE 58 /* Motorola Start*Core processor */ -#define EM_ME16 59 /* Toyota ME16 processor */ -#define EM_ST100 60 /* STMicroelectronic ST100 processor */ -#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ -#define EM_X8664 62 /* AMD x86-64 */ - -#define EM_FX66 66 /* Siemens FX66 microcontroller */ -#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ -#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ -#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ -#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ -#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ -#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ -#define EM_SVX 73 /* Silicon Graphics SVx */ -#define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */ -#define EM_VAX 75 /* Digital VAX */ -#define EM_NUM 76 - -/* If it is necessary to assign new unofficial EM_* values, please - pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the - chances of collision with official or non-GNU unofficial values. */ - -#define EM_ALPHA 0x9026 -#define EM_S390 0xA390 /* IBM S390 */ - -/* Legal values for e_version (version). */ - -#define EV_NONE 0 /* Invalid ELF version */ -#define EV_CURRENT 1 /* Current version */ -#define EV_NUM 2 - -/* Section header. */ - -typedef struct -{ - Elf32_Word sh_name; /* Section name (string tbl index) */ - Elf32_Word sh_type; /* Section type */ - Elf32_Word sh_flags; /* Section flags */ - Elf32_Addr sh_addr; /* Section virtual addr at execution */ - Elf32_Off sh_offset; /* Section file offset */ - Elf32_Word sh_size; /* Section size in bytes */ - Elf32_Word sh_link; /* Link to another section */ - Elf32_Word sh_info; /* Additional section information */ - Elf32_Word sh_addralign; /* Section alignment */ - Elf32_Word sh_entsize; /* Entry size if section holds table */ -} Elf32_Shdr; - -typedef struct -{ - Elf64_Word sh_name; /* Section name (string tbl index) */ - Elf64_Word sh_type; /* Section type */ - Elf64_Xword sh_flags; /* Section flags */ - Elf64_Addr sh_addr; /* Section virtual addr at execution */ - Elf64_Off sh_offset; /* Section file offset */ - Elf64_Xword sh_size; /* Section size in bytes */ - Elf64_Word sh_link; /* Link to another section */ - Elf64_Word sh_info; /* Additional section information */ - Elf64_Xword sh_addralign; /* Section alignment */ - Elf64_Xword sh_entsize; /* Entry size if section holds table */ -} Elf64_Shdr; - -/* Special section indices. */ - -#define SHN_UNDEF 0 /* Undefined section */ -#define SHN_LORESERVE 0xff00 /* Start of reserved indices */ -#define SHN_LOPROC 0xff00 /* Start of processor-specific */ -#define SHN_HIPROC 0xff1f /* End of processor-specific */ -#define SHN_LOOS 0xff20 /* Start of OS-specific */ -#define SHN_HIOS 0xff3f /* End of OS-specific */ -#define SHN_ABS 0xfff1 /* Associated symbol is absolute */ -#define SHN_COMMON 0xfff2 /* Associated symbol is common */ -#define SHN_XINDEX 0xffff /* Index is in extra table. */ -#define SHN_HIRESERVE 0xffff /* End of reserved indices */ - -/* Legal values for sh_type (section type). */ - -#define SHT_NULL 0 /* Section header table entry unused */ -#define SHT_PROGBITS 1 /* Program data */ -#define SHT_SYMTAB 2 /* Symbol table */ -#define SHT_STRTAB 3 /* String table */ -#define SHT_RELA 4 /* Relocation entries with addends */ -#define SHT_HASH 5 /* Symbol hash table */ -#define SHT_DYNAMIC 6 /* Dynamic linking information */ -#define SHT_NOTE 7 /* Notes */ -#define SHT_NOBITS 8 /* Program space with no data (bss) */ -#define SHT_REL 9 /* Relocation entries, no addends */ -#define SHT_SHLIB 10 /* Reserved */ -#define SHT_DYNSYM 11 /* Dynamic linker symbol table */ -#define SHT_INIT_ARRAY 14 /* Array of constructors */ -#define SHT_FINI_ARRAY 15 /* Array of destructors */ -#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ -#define SHT_GROUP 17 /* Section group */ -#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ -#define SHT_NUM 19 /* Number of defined types. */ -#define SHT_LOOS 0x60000000 /* Start OS-specific */ -#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ -#define SHT_SUNW_move 0x6ffffffa -#define SHT_SUNW_COMDAT 0x6ffffffb -#define SHT_SUNW_syminfo 0x6ffffffc -#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ -#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ -#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ -#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ -#define SHT_HIOS 0x6fffffff /* End OS-specific type */ -#define SHT_LOPROC 0x70000000 /* Start of processor-specific */ -#define SHT_HIPROC 0x7fffffff /* End of processor-specific */ -#define SHT_LOUSER 0x80000000 /* Start of application-specific */ -#define SHT_HIUSER 0x8fffffff /* End of application-specific */ - -/* Legal values for sh_flags (section flags). */ - -#define SHF_WRITE (1 << 0) /* Writable */ -#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ -#define SHF_EXECINSTR (1 << 2) /* Executable */ -#define SHF_MERGE (1 << 4) /* Might be merged */ -#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ -#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ -#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ -#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling - required */ -#define SHF_MASKOS 0x0ff00000 /* OS-specific. */ -#define SHF_MASKPROC 0xf0000000 /* Processor-specific */ - -/* Section group handling. */ -#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */ - -/* Symbol table entry. */ - -typedef struct -{ - Elf32_Word st_name; /* Symbol name (string tbl index) */ - Elf32_Addr st_value; /* Symbol value */ - Elf32_Word st_size; /* Symbol size */ - unsigned char st_info; /* Symbol type and binding */ - unsigned char st_other; /* Symbol visibility */ - Elf32_Section st_shndx; /* Section index */ -} Elf32_Sym; - -typedef struct -{ - Elf64_Word st_name; /* Symbol name (string tbl index) */ - unsigned char st_info; /* Symbol type and binding */ - unsigned char st_other; /* Symbol visibility */ - Elf64_Section st_shndx; /* Section index */ - Elf64_Addr st_value; /* Symbol value */ - Elf64_Xword st_size; /* Symbol size */ -} Elf64_Sym; - -/* The syminfo section if available contains additional information about - every dynamic symbol. */ - -typedef struct -{ - Elf32_Half si_boundto; /* Direct bindings, symbol bound to */ - Elf32_Half si_flags; /* Per symbol flags */ -} Elf32_Syminfo; - -typedef struct -{ - Elf64_Half si_boundto; /* Direct bindings, symbol bound to */ - Elf64_Half si_flags; /* Per symbol flags */ -} Elf64_Syminfo; - -/* Possible values for si_boundto. */ -#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */ -#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */ -#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */ - -/* Possible bitmasks for si_flags. */ -#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */ -#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */ -#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */ -#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy - loaded */ -/* Syminfo version values. */ -#define SYMINFO_NONE 0 -#define SYMINFO_CURRENT 1 -#define SYMINFO_NUM 2 - - -/* Special section index. */ - -#define SHN_UNDEF 0 /* No section, undefined symbol. */ - -/* How to extract and insert information held in the st_info field. */ - -#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) -#define ELF32_ST_TYPE(val) ((val) & 0xf) -#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) - -/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ -#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) -#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) -#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) - -/* Legal values for ST_BIND subfield of st_info (symbol binding). */ - -#define STB_LOCAL 0 /* Local symbol */ -#define STB_GLOBAL 1 /* Global symbol */ -#define STB_WEAK 2 /* Weak symbol */ -#define STB_NUM 3 /* Number of defined types. */ -#define STB_LOOS 10 /* Start of OS-specific */ -#define STB_HIOS 12 /* End of OS-specific */ -#define STB_LOPROC 13 /* Start of processor-specific */ -#define STB_HIPROC 15 /* End of processor-specific */ - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ - -#define STT_NOTYPE 0 /* Symbol type is unspecified */ -#define STT_OBJECT 1 /* Symbol is a data object */ -#define STT_FUNC 2 /* Symbol is a code object */ -#define STT_SECTION 3 /* Symbol associated with a section */ -#define STT_FILE 4 /* Symbol's name is file name */ -#define STT_COMMON 5 /* Symbol is a common data object */ -#define STT_NUM 6 /* Number of defined types. */ -#define STT_LOOS 10 /* Start of OS-specific */ -#define STT_HIOS 12 /* End of OS-specific */ -#define STT_LOPROC 13 /* Start of processor-specific */ -#define STT_HIPROC 15 /* End of processor-specific */ - - -/* Symbol table indices are found in the hash buckets and chain table - of a symbol hash table section. This special index value indicates - the end of a chain, meaning no further symbols are found in that bucket. */ - -#define STN_UNDEF 0 /* End of a chain. */ - - -/* How to extract and insert information held in the st_other field. */ - -#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) - -/* For ELF64 the definitions are the same. */ -#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) - -/* Symbol visibility specification encoded in the st_other field. */ -#define STV_DEFAULT 0 /* Default symbol visibility rules */ -#define STV_INTERNAL 1 /* Processor specific hidden class */ -#define STV_HIDDEN 2 /* Sym unavailable in other modules */ -#define STV_PROTECTED 3 /* Not preemptible, not exported */ - - -/* Relocation table entry without addend (in section of type SHT_REL). */ - -typedef struct -{ - Elf32_Addr r_offset; /* Address */ - Elf32_Word r_info; /* Relocation type and symbol index */ -} Elf32_Rel; - -/* I have seen two different definitions of the Elf64_Rel and - Elf64_Rela structures, so we'll leave them out until Novell (or - whoever) gets their act together. */ -/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */ - -typedef struct -{ - Elf64_Addr r_offset; /* Address */ - Elf64_Xword r_info; /* Relocation type and symbol index */ -} Elf64_Rel; - -/* Relocation table entry with addend (in section of type SHT_RELA). */ - -typedef struct -{ - Elf32_Addr r_offset; /* Address */ - Elf32_Word r_info; /* Relocation type and symbol index */ - Elf32_Sword r_addend; /* Addend */ -} Elf32_Rela; - -typedef struct -{ - Elf64_Addr r_offset; /* Address */ - Elf64_Xword r_info; /* Relocation type and symbol index */ - Elf64_Sxword r_addend; /* Addend */ -} Elf64_Rela; - -/* How to extract and insert information held in the r_info field. */ - -#define ELF32_R_SYM(val) ((val) >> 8) -#define ELF32_R_TYPE(val) ((val) & 0xff) -#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) - -#define ELF64_R_SYM(i) ((i) >> 32) -#define ELF64_R_TYPE(i) ((i) & 0xffffffff) -#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) - -/* Program segment header. */ - -typedef struct -{ - Elf32_Word p_type; /* Segment type */ - Elf32_Off p_offset; /* Segment file offset */ - Elf32_Addr p_vaddr; /* Segment virtual address */ - Elf32_Addr p_paddr; /* Segment physical address */ - Elf32_Word p_filesz; /* Segment size in file */ - Elf32_Word p_memsz; /* Segment size in memory */ - Elf32_Word p_flags; /* Segment flags */ - Elf32_Word p_align; /* Segment alignment */ -} Elf32_Phdr; - -typedef struct -{ - Elf64_Word p_type; /* Segment type */ - Elf64_Word p_flags; /* Segment flags */ - Elf64_Off p_offset; /* Segment file offset */ - Elf64_Addr p_vaddr; /* Segment virtual address */ - Elf64_Addr p_paddr; /* Segment physical address */ - Elf64_Xword p_filesz; /* Segment size in file */ - Elf64_Xword p_memsz; /* Segment size in memory */ - Elf64_Xword p_align; /* Segment alignment */ -} Elf64_Phdr; - -/* Legal values for p_type (segment type). */ - -#define PT_NULL 0 /* Program header table entry unused */ -#define PT_LOAD 1 /* Loadable program segment */ -#define PT_DYNAMIC 2 /* Dynamic linking information */ -#define PT_INTERP 3 /* Program interpreter */ -#define PT_NOTE 4 /* Auxiliary information */ -#define PT_SHLIB 5 /* Reserved */ -#define PT_PHDR 6 /* Entry for header table itself */ -#define PT_NUM 7 /* Number of defined types */ -#define PT_LOOS 0x60000000 /* Start of OS-specific */ -#define PT_HIOS 0x6fffffff /* End of OS-specific */ -#define PT_LOPROC 0x70000000 /* Start of processor-specific */ -#define PT_HIPROC 0x7fffffff /* End of processor-specific */ - -/* Legal values for p_flags (segment flags). */ - -#define PF_X (1 << 0) /* Segment is executable */ -#define PF_W (1 << 1) /* Segment is writable */ -#define PF_R (1 << 2) /* Segment is readable */ -#define PF_MASKOS 0x0ff00000 /* OS-specific */ -#define PF_MASKPROC 0xf0000000 /* Processor-specific */ - -/* Legal values for note segment descriptor types for core files. */ - -#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ -#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ -#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ -#define NT_PRXREG 4 /* Contains copy of prxregset struct */ -#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ -#define NT_AUXV 6 /* Contains copy of auxv array */ -#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ -#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ -#define NT_PSINFO 13 /* Contains copy of psinfo struct */ -#define NT_PRCRED 14 /* Contains copy of prcred struct */ -#define NT_UTSNAME 15 /* Contains copy of utsname struct */ -#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ -#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ -#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/ - -/* Legal values for the note segment descriptor types for object files. */ - -#define NT_VERSION 1 /* Contains a version string. */ - - -/* Dynamic section entry. */ - -typedef struct -{ - Elf32_Sword d_tag; /* Dynamic entry type */ - union - { - Elf32_Word d_val; /* Integer value */ - Elf32_Addr d_ptr; /* Address value */ - } d_un; -} Elf32_Dyn; - -typedef struct -{ - Elf64_Sxword d_tag; /* Dynamic entry type */ - union - { - Elf64_Xword d_val; /* Integer value */ - Elf64_Addr d_ptr; /* Address value */ - } d_un; -} Elf64_Dyn; - -/* Legal values for d_tag (dynamic entry type). */ - -#define DT_NULL 0 /* Marks end of dynamic section */ -#define DT_NEEDED 1 /* Name of needed library */ -#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ -#define DT_PLTGOT 3 /* Processor defined value */ -#define DT_HASH 4 /* Address of symbol hash table */ -#define DT_STRTAB 5 /* Address of string table */ -#define DT_SYMTAB 6 /* Address of symbol table */ -#define DT_RELA 7 /* Address of Rela relocs */ -#define DT_RELASZ 8 /* Total size of Rela relocs */ -#define DT_RELAENT 9 /* Size of one Rela reloc */ -#define DT_STRSZ 10 /* Size of string table */ -#define DT_SYMENT 11 /* Size of one symbol table entry */ -#define DT_INIT 12 /* Address of init function */ -#define DT_FINI 13 /* Address of termination function */ -#define DT_SONAME 14 /* Name of shared object */ -#define DT_RPATH 15 /* Library search path (deprecated) */ -#define DT_SYMBOLIC 16 /* Start symbol search here */ -#define DT_REL 17 /* Address of Rel relocs */ -#define DT_RELSZ 18 /* Total size of Rel relocs */ -#define DT_RELENT 19 /* Size of one Rel reloc */ -#define DT_PLTREL 20 /* Type of reloc in PLT */ -#define DT_DEBUG 21 /* For debugging; unspecified */ -#define DT_TEXTREL 22 /* Reloc might modify .text */ -#define DT_JMPREL 23 /* Address of PLT relocs */ -#define DT_BIND_NOW 24 /* Process relocations of object */ -#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ -#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ -#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ -#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ -#define DT_RUNPATH 29 /* Library search path */ -#define DT_FLAGS 30 /* Flags for the object being loaded */ -#define DT_ENCODING 32 /* Start of encoded range */ -#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ -#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ -#define DT_NUM 34 /* Number used */ -#define DT_LOOS 0x60000000 /* Start of OS-specific */ -#define DT_HIOS 0x6fffffff /* End of OS-specific */ -#define DT_LOPROC 0x70000000 /* Start of processor-specific */ -#define DT_HIPROC 0x7fffffff /* End of processor-specific */ -#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */ - -/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the - Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's - approach. */ -#define DT_VALRNGLO 0x6ffffd00 -#define DT_PLTPADSZ 0x6ffffdf9 -#define DT_MOVEENT 0x6ffffdfa -#define DT_MOVESZ 0x6ffffdfb -#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */ -#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting - the following DT_* entry. */ -#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */ -#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */ -#define DT_VALRNGHI 0x6ffffdff - -/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the - Dyn.d_un.d_ptr field of the Elf*_Dyn structure. - - If any adjustment is made to the ELF object after it has been - built these entries will need to be adjusted. */ -#define DT_ADDRRNGLO 0x6ffffe00 -#define DT_SYMINFO 0x6ffffeff /* syminfo table */ -#define DT_ADDRRNGHI 0x6ffffeff - -/* The versioning entry types. The next are defined as part of the - GNU extension. */ -#define DT_VERSYM 0x6ffffff0 - -#define DT_RELACOUNT 0x6ffffff9 -#define DT_RELCOUNT 0x6ffffffa - -/* These were chosen by Sun. */ -#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ -#define DT_VERDEF 0x6ffffffc /* Address of version definition - table */ -#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ -#define DT_VERNEED 0x6ffffffe /* Address of table with needed - versions */ -#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ -#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ -#define DT_VERSIONTAGNUM 16 - -/* Sun added these machine-independent extensions in the "processor-specific" - range. Be compatible. */ -#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ -#define DT_FILTER 0x7fffffff /* Shared object to get values from */ -#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) -#define DT_EXTRANUM 3 - -/* Values of `d_un.d_val' in the DT_FLAGS entry. */ -#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */ -#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ -#define DF_TEXTREL 0x00000004 /* Object contains text relocations */ -#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ - -/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 - entry in the dynamic section. */ -#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ -#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ -#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ -#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ -#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ -#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ -#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ -#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ -#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ -#define DF_1_TRANS 0x00000200 -#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ -#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ -#define DF_1_NODUMP 0x00001000 -#define DF_1_CONFALT 0x00002000 -#define DF_1_ENDFILTEE 0x00004000 - -/* Flags for the feature selection in DT_FEATURE_1. */ -#define DTF_1_PARINIT 0x00000001 -#define DTF_1_CONFEXP 0x00000002 - -/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ -#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ -#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not - generally available. */ - -/* Version definition sections. */ - -typedef struct -{ - Elf32_Half vd_version; /* Version revision */ - Elf32_Half vd_flags; /* Version information */ - Elf32_Half vd_ndx; /* Version Index */ - Elf32_Half vd_cnt; /* Number of associated aux entries */ - Elf32_Word vd_hash; /* Version name hash value */ - Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf32_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf32_Verdef; - -typedef struct -{ - Elf64_Half vd_version; /* Version revision */ - Elf64_Half vd_flags; /* Version information */ - Elf64_Half vd_ndx; /* Version Index */ - Elf64_Half vd_cnt; /* Number of associated aux entries */ - Elf64_Word vd_hash; /* Version name hash value */ - Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf64_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf64_Verdef; - - -/* Legal values for vd_version (version revision). */ -#define VER_DEF_NONE 0 /* No version */ -#define VER_DEF_CURRENT 1 /* Current version */ -#define VER_DEF_NUM 2 /* Given version number */ - -/* Legal values for vd_flags (version information flags). */ -#define VER_FLG_BASE 0x1 /* Version definition of file itself */ -#define VER_FLG_WEAK 0x2 /* Weak version identifier */ - -/* Auxialiary version information. */ - -typedef struct -{ - Elf32_Word vda_name; /* Version or dependency names */ - Elf32_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf32_Verdaux; - -typedef struct -{ - Elf64_Word vda_name; /* Version or dependency names */ - Elf64_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf64_Verdaux; - - -/* Version dependency section. */ - -typedef struct -{ - Elf32_Half vn_version; /* Version of structure */ - Elf32_Half vn_cnt; /* Number of associated aux entries */ - Elf32_Word vn_file; /* Offset of filename for this - dependency */ - Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf32_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf32_Verneed; - -typedef struct -{ - Elf64_Half vn_version; /* Version of structure */ - Elf64_Half vn_cnt; /* Number of associated aux entries */ - Elf64_Word vn_file; /* Offset of filename for this - dependency */ - Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf64_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf64_Verneed; - - -/* Legal values for vn_version (version revision). */ -#define VER_NEED_NONE 0 /* No version */ -#define VER_NEED_CURRENT 1 /* Current version */ -#define VER_NEED_NUM 2 /* Given version number */ - -/* Auxiliary needed version information. */ - -typedef struct -{ - Elf32_Word vna_hash; /* Hash value of dependency name */ - Elf32_Half vna_flags; /* Dependency specific information */ - Elf32_Half vna_other; /* Unused */ - Elf32_Word vna_name; /* Dependency name string offset */ - Elf32_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf32_Vernaux; - -typedef struct -{ - Elf64_Word vna_hash; /* Hash value of dependency name */ - Elf64_Half vna_flags; /* Dependency specific information */ - Elf64_Half vna_other; /* Unused */ - Elf64_Word vna_name; /* Dependency name string offset */ - Elf64_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf64_Vernaux; - - -/* Legal values for vna_flags. */ -#define VER_FLG_WEAK 0x2 /* Weak version identifier */ - - -/* Auxiliary vector. */ - -/* This vector is normally only used by the program interpreter. The - usual definition in an ABI supplement uses the name auxv_t. The - vector is not usually defined in a standard <elf.h> file, but it - can't hurt. We rename it to avoid conflicts. The sizes of these - types are an arrangement between the exec server and the program - interpreter, so we don't fully specify them here. */ - -typedef struct -{ - int a_type; /* Entry type */ - union - { - long int a_val; /* Integer value */ - void *a_ptr; /* Pointer value */ - void (*a_fcn) (void); /* Function pointer value */ - } a_un; -} Elf32_auxv_t; - -typedef struct -{ - long int a_type; /* Entry type */ - union - { - long int a_val; /* Integer value */ - void *a_ptr; /* Pointer value */ - void (*a_fcn) (void); /* Function pointer value */ - } a_un; -} Elf64_auxv_t; - -/* Legal values for a_type (entry type). */ - -#define AT_NULL 0 /* End of vector */ -#define AT_IGNORE 1 /* Entry should be ignored */ -#define AT_EXECFD 2 /* File descriptor of program */ -#define AT_PHDR 3 /* Program headers for program */ -#define AT_PHENT 4 /* Size of program header entry */ -#define AT_PHNUM 5 /* Number of program headers */ -#define AT_PAGESZ 6 /* System page size */ -#define AT_BASE 7 /* Base address of interpreter */ -#define AT_FLAGS 8 /* Flags */ -#define AT_ENTRY 9 /* Entry point of program */ -#define AT_NOTELF 10 /* Program is not ELF */ -#define AT_UID 11 /* Real uid */ -#define AT_EUID 12 /* Effective uid */ -#define AT_GID 13 /* Real gid */ -#define AT_EGID 14 /* Effective gid */ -#define AT_CLKTCK 17 /* Frequency of times() */ - -/* Some more special a_type values describing the hardware. */ -#define AT_PLATFORM 15 /* String identifying platform. */ -#define AT_HWCAP 16 /* Machine dependent hints about - processor capabilities. */ - -/* This entry gives some information about the FPU initialization - performed by the kernel. */ -#define AT_FPUCW 18 /* Used FPU control word. */ - - -/* Note section contents. Each entry in the note section begins with - a header of a fixed form. */ - -typedef struct -{ - Elf32_Word n_namesz; /* Length of the note's name. */ - Elf32_Word n_descsz; /* Length of the note's descriptor. */ - Elf32_Word n_type; /* Type of the note. */ -} Elf32_Nhdr; - -typedef struct -{ - Elf64_Word n_namesz; /* Length of the note's name. */ - Elf64_Word n_descsz; /* Length of the note's descriptor. */ - Elf64_Word n_type; /* Type of the note. */ -} Elf64_Nhdr; - -/* Known names of notes. */ - -/* Solaris entries in the note section have this name. */ -#define ELF_NOTE_SOLARIS "SUNW Solaris" - -/* Note entries for GNU systems have this name. */ -#define ELF_NOTE_GNU "GNU" - - -/* Defined types of notes for Solaris. */ - -/* Value of descriptor (one word) is desired pagesize for the binary. */ -#define ELF_NOTE_PAGESIZE_HINT 1 - - -/* Defined note types for GNU systems. */ - -/* ABI information. The descriptor consists of words: - word 0: OS descriptor - word 1: major version of the ABI - word 2: minor version of the ABI - word 3: subminor version of the ABI -*/ -#define ELF_NOTE_ABI 1 - -/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI - note section entry. */ -#define ELF_NOTE_OS_LINUX 0 -#define ELF_NOTE_OS_GNU 1 -#define ELF_NOTE_OS_SOLARIS2 2 - - -/* Move records. */ -typedef struct -{ - Elf32_Xword m_value; /* Symbol value. */ - Elf32_Word m_info; /* Size and index. */ - Elf32_Word m_poffset; /* Symbol offset. */ - Elf32_Half m_repeat; /* Repeat count. */ - Elf32_Half m_stride; /* Stride info. */ -} Elf32_Move; - -typedef struct -{ - Elf64_Xword m_value; /* Symbol value. */ - Elf64_Xword m_info; /* Size and index. */ - Elf64_Xword m_poffset; /* Symbol offset. */ - Elf64_Half m_repeat; /* Repeat count. */ - Elf64_Half m_stride; /* Stride info. */ -} Elf64_Move; - -/* Macro to construct move records. */ -#define ELF32_M_SYM(info) ((info) >> 8) -#define ELF32_M_SIZE(info) ((unsigned char) (info)) -#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) - -#define ELF64_M_SYM(info) ELF32_M_SYM (info) -#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) -#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) - - -/* Motorola 68k specific definitions. */ - -/* Values for Elf32_Ehdr.e_flags. */ -#define EF_CPU32 0x00810000 - -/* m68k relocs. */ - -#define R_68K_NONE 0 /* No reloc */ -#define R_68K_32 1 /* Direct 32 bit */ -#define R_68K_16 2 /* Direct 16 bit */ -#define R_68K_8 3 /* Direct 8 bit */ -#define R_68K_PC32 4 /* PC relative 32 bit */ -#define R_68K_PC16 5 /* PC relative 16 bit */ -#define R_68K_PC8 6 /* PC relative 8 bit */ -#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */ -#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */ -#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */ -#define R_68K_GOT32O 10 /* 32 bit GOT offset */ -#define R_68K_GOT16O 11 /* 16 bit GOT offset */ -#define R_68K_GOT8O 12 /* 8 bit GOT offset */ -#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */ -#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */ -#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */ -#define R_68K_PLT32O 16 /* 32 bit PLT offset */ -#define R_68K_PLT16O 17 /* 16 bit PLT offset */ -#define R_68K_PLT8O 18 /* 8 bit PLT offset */ -#define R_68K_COPY 19 /* Copy symbol at runtime */ -#define R_68K_GLOB_DAT 20 /* Create GOT entry */ -#define R_68K_JMP_SLOT 21 /* Create PLT entry */ -#define R_68K_RELATIVE 22 /* Adjust by program base */ -/* Keep this the last entry. */ -#define R_68K_NUM 23 - -/* Intel 80386 specific definitions. */ - -/* i386 relocs. */ - -#define R_386_NONE 0 /* No reloc */ -#define R_386_32 1 /* Direct 32 bit */ -#define R_386_PC32 2 /* PC relative 32 bit */ -#define R_386_GOT32 3 /* 32 bit GOT entry */ -#define R_386_PLT32 4 /* 32 bit PLT address */ -#define R_386_COPY 5 /* Copy symbol at runtime */ -#define R_386_GLOB_DAT 6 /* Create GOT entry */ -#define R_386_JMP_SLOT 7 /* Create PLT entry */ -#define R_386_RELATIVE 8 /* Adjust by program base */ -#define R_386_GOTOFF 9 /* 32 bit offset to GOT */ -#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ -/* Keep this the last entry. */ -#define R_386_NUM 11 - -/* SUN SPARC specific definitions. */ - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ - -#define STT_REGISTER 13 /* Global register reserved to app. */ - -/* Values for Elf64_Ehdr.e_flags. */ - -#define EF_SPARCV9_MM 3 -#define EF_SPARCV9_TSO 0 -#define EF_SPARCV9_PSO 1 -#define EF_SPARCV9_RMO 2 -#define EF_SPARC_LEDATA 0x800000 /* little endian data */ -#define EF_SPARC_EXT_MASK 0xFFFF00 -#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ -#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */ -#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ -#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */ - -/* SPARC relocs. */ - -#define R_SPARC_NONE 0 /* No reloc */ -#define R_SPARC_8 1 /* Direct 8 bit */ -#define R_SPARC_16 2 /* Direct 16 bit */ -#define R_SPARC_32 3 /* Direct 32 bit */ -#define R_SPARC_DISP8 4 /* PC relative 8 bit */ -#define R_SPARC_DISP16 5 /* PC relative 16 bit */ -#define R_SPARC_DISP32 6 /* PC relative 32 bit */ -#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */ -#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */ -#define R_SPARC_HI22 9 /* High 22 bit */ -#define R_SPARC_22 10 /* Direct 22 bit */ -#define R_SPARC_13 11 /* Direct 13 bit */ -#define R_SPARC_LO10 12 /* Truncated 10 bit */ -#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */ -#define R_SPARC_GOT13 14 /* 13 bit GOT entry */ -#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */ -#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */ -#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */ -#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */ -#define R_SPARC_COPY 19 /* Copy symbol at runtime */ -#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */ -#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */ -#define R_SPARC_RELATIVE 22 /* Adjust by program base */ -#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */ - -/* Additional Sparc64 relocs. */ - -#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */ -#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */ -#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */ -#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */ -#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */ -#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */ -#define R_SPARC_10 30 /* Direct 10 bit */ -#define R_SPARC_11 31 /* Direct 11 bit */ -#define R_SPARC_64 32 /* Direct 64 bit */ -#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */ -#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */ -#define R_SPARC_HM10 35 /* High middle 10 bits of ... */ -#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */ -#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */ -#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */ -#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */ -#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */ -#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */ -#define R_SPARC_7 43 /* Direct 7 bit */ -#define R_SPARC_5 44 /* Direct 5 bit */ -#define R_SPARC_6 45 /* Direct 6 bit */ -#define R_SPARC_DISP64 46 /* PC relative 64 bit */ -#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */ -#define R_SPARC_HIX22 48 /* High 22 bit complemented */ -#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */ -#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */ -#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */ -#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */ -#define R_SPARC_REGISTER 53 /* Global register usage */ -#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */ -#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */ -/* Keep this the last entry. */ -#define R_SPARC_NUM 56 - -/* For Sparc64, legal values for d_tag of Elf64_Dyn. */ - -#define DT_SPARC_REGISTER 0x70000001 -#define DT_SPARC_NUM 2 - -/* Bits present in AT_HWCAP, primarily for Sparc32. */ - -#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */ -#define HWCAP_SPARC_STBAR 2 -#define HWCAP_SPARC_SWAP 4 -#define HWCAP_SPARC_MULDIV 8 -#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */ - -/* MIPS R3000 specific definitions. */ - -/* Legal values for e_flags field of Elf32_Ehdr. */ - -#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */ -#define EF_MIPS_PIC 2 /* Contains PIC code */ -#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */ -#define EF_MIPS_XGOT 8 -#define EF_MIPS_64BIT_WHIRL 16 -#define EF_MIPS_ABI2 32 -#define EF_MIPS_ABI_ON32 64 -#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */ - -/* Legal values for MIPS architecture level. */ - -#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ -#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ -#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ -#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ -#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ - -/* The following are non-official names and should not be used. */ - -#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ -#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ -#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ -#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ -#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ - -/* Special section indices. */ - -#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */ -#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ -#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ -#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */ -#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */ - -/* Legal values for sh_type field of Elf32_Shdr. */ - -#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */ -#define SHT_MIPS_MSYM 0x70000001 -#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */ -#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */ -#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ -#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/ -#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */ -#define SHT_MIPS_PACKAGE 0x70000007 -#define SHT_MIPS_PACKSYM 0x70000008 -#define SHT_MIPS_RELD 0x70000009 -#define SHT_MIPS_IFACE 0x7000000b -#define SHT_MIPS_CONTENT 0x7000000c -#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */ -#define SHT_MIPS_SHDR 0x70000010 -#define SHT_MIPS_FDESC 0x70000011 -#define SHT_MIPS_EXTSYM 0x70000012 -#define SHT_MIPS_DENSE 0x70000013 -#define SHT_MIPS_PDESC 0x70000014 -#define SHT_MIPS_LOCSYM 0x70000015 -#define SHT_MIPS_AUXSYM 0x70000016 -#define SHT_MIPS_OPTSYM 0x70000017 -#define SHT_MIPS_LOCSTR 0x70000018 -#define SHT_MIPS_LINE 0x70000019 -#define SHT_MIPS_RFDESC 0x7000001a -#define SHT_MIPS_DELTASYM 0x7000001b -#define SHT_MIPS_DELTAINST 0x7000001c -#define SHT_MIPS_DELTACLASS 0x7000001d -#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */ -#define SHT_MIPS_DELTADECL 0x7000001f -#define SHT_MIPS_SYMBOL_LIB 0x70000020 -#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */ -#define SHT_MIPS_TRANSLATE 0x70000022 -#define SHT_MIPS_PIXIE 0x70000023 -#define SHT_MIPS_XLATE 0x70000024 -#define SHT_MIPS_XLATE_DEBUG 0x70000025 -#define SHT_MIPS_WHIRL 0x70000026 -#define SHT_MIPS_EH_REGION 0x70000027 -#define SHT_MIPS_XLATE_OLD 0x70000028 -#define SHT_MIPS_PDR_EXCEPTION 0x70000029 - -/* Legal values for sh_flags field of Elf32_Shdr. */ - -#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */ -#define SHF_MIPS_MERGE 0x20000000 -#define SHF_MIPS_ADDR 0x40000000 -#define SHF_MIPS_STRINGS 0x80000000 -#define SHF_MIPS_NOSTRIP 0x08000000 -#define SHF_MIPS_LOCAL 0x04000000 -#define SHF_MIPS_NAMES 0x02000000 -#define SHF_MIPS_NODUPE 0x01000000 - - -/* Symbol tables. */ - -/* MIPS specific values for `st_other'. */ -#define STO_MIPS_DEFAULT 0x0 -#define STO_MIPS_INTERNAL 0x1 -#define STO_MIPS_HIDDEN 0x2 -#define STO_MIPS_PROTECTED 0x3 -#define STO_MIPS_SC_ALIGN_UNUSED 0xff - -/* MIPS specific values for `st_info'. */ -#define STB_MIPS_SPLIT_COMMON 13 - -/* Entries found in sections of type SHT_MIPS_GPTAB. */ - -typedef union -{ - struct - { - Elf32_Word gt_current_g_value; /* -G value used for compilation */ - Elf32_Word gt_unused; /* Not used */ - } gt_header; /* First entry in section */ - struct - { - Elf32_Word gt_g_value; /* If this value were used for -G */ - Elf32_Word gt_bytes; /* This many bytes would be used */ - } gt_entry; /* Subsequent entries in section */ -} Elf32_gptab; - -/* Entry found in sections of type SHT_MIPS_REGINFO. */ - -typedef struct -{ - Elf32_Word ri_gprmask; /* General registers used */ - Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */ - Elf32_Sword ri_gp_value; /* $gp register value */ -} Elf32_RegInfo; - -/* Entries found in sections of type SHT_MIPS_OPTIONS. */ - -typedef struct -{ - unsigned char kind; /* Determines interpretation of the - variable part of descriptor. */ - unsigned char size; /* Size of descriptor, including header. */ - Elf32_Section section; /* Section header index of section affected, - 0 for global options. */ - Elf32_Word info; /* Kind-specific information. */ -} Elf_Options; - -/* Values for `kind' field in Elf_Options. */ - -#define ODK_NULL 0 /* Undefined. */ -#define ODK_REGINFO 1 /* Register usage information. */ -#define ODK_EXCEPTIONS 2 /* Exception processing options. */ -#define ODK_PAD 3 /* Section padding options. */ -#define ODK_HWPATCH 4 /* Hardware workarounds performed */ -#define ODK_FILL 5 /* record the fill value used by the linker. */ -#define ODK_TAGS 6 /* reserve space for desktop tools to write. */ -#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */ -#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */ - -/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */ - -#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */ -#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */ -#define OEX_PAGE0 0x10000 /* page zero must be mapped. */ -#define OEX_SMM 0x20000 /* Force sequential memory mode? */ -#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */ -#define OEX_PRECISEFP OEX_FPDBUG -#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */ - -#define OEX_FPU_INVAL 0x10 -#define OEX_FPU_DIV0 0x08 -#define OEX_FPU_OFLO 0x04 -#define OEX_FPU_UFLO 0x02 -#define OEX_FPU_INEX 0x01 - -/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */ - -#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */ -#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */ -#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */ -#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */ - -#define OPAD_PREFIX 0x1 -#define OPAD_POSTFIX 0x2 -#define OPAD_SYMBOL 0x4 - -/* Entry found in `.options' section. */ - -typedef struct -{ - Elf32_Word hwp_flags1; /* Extra flags. */ - Elf32_Word hwp_flags2; /* Extra flags. */ -} Elf_Options_Hw; - -/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */ - -#define OHWA0_R4KEOP_CHECKED 0x00000001 -#define OHWA1_R4KEOP_CLEAN 0x00000002 - -/* MIPS relocs. */ - -#define R_MIPS_NONE 0 /* No reloc */ -#define R_MIPS_16 1 /* Direct 16 bit */ -#define R_MIPS_32 2 /* Direct 32 bit */ -#define R_MIPS_REL32 3 /* PC relative 32 bit */ -#define R_MIPS_26 4 /* Direct 26 bit shifted */ -#define R_MIPS_HI16 5 /* High 16 bit */ -#define R_MIPS_LO16 6 /* Low 16 bit */ -#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ -#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ -#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ -#define R_MIPS_PC16 10 /* PC relative 16 bit */ -#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ -#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ - -#define R_MIPS_SHIFT5 16 -#define R_MIPS_SHIFT6 17 -#define R_MIPS_64 18 -#define R_MIPS_GOT_DISP 19 -#define R_MIPS_GOT_PAGE 20 -#define R_MIPS_GOT_OFST 21 -#define R_MIPS_GOT_HI16 22 -#define R_MIPS_GOT_LO16 23 -#define R_MIPS_SUB 24 -#define R_MIPS_INSERT_A 25 -#define R_MIPS_INSERT_B 26 -#define R_MIPS_DELETE 27 -#define R_MIPS_HIGHER 28 -#define R_MIPS_HIGHEST 29 -#define R_MIPS_CALL_HI16 30 -#define R_MIPS_CALL_LO16 31 -#define R_MIPS_SCN_DISP 32 -#define R_MIPS_REL16 33 -#define R_MIPS_ADD_IMMEDIATE 34 -#define R_MIPS_PJUMP 35 -#define R_MIPS_RELGOT 36 -#define R_MIPS_JALR 37 -/* Keep this the last entry. */ -#define R_MIPS_NUM 38 - -/* Legal values for p_type field of Elf32_Phdr. */ - -#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */ -#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */ -#define PT_MIPS_OPTIONS 0x70000002 - -/* Special program header types. */ - -#define PF_MIPS_LOCAL 0x10000000 - -/* Legal values for d_tag field of Elf32_Dyn. */ - -#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */ -#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ -#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */ -#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ -#define DT_MIPS_FLAGS 0x70000005 /* Flags */ -#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */ -#define DT_MIPS_MSYM 0x70000007 -#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */ -#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */ -#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */ -#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */ -#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */ -#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */ -#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ -#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */ -#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ -#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */ -#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */ -#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in - DT_MIPS_DELTA_CLASS. */ -#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */ -#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in - DT_MIPS_DELTA_INSTANCE. */ -#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */ -#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in - DT_MIPS_DELTA_RELOC. */ -#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta - relocations refer to. */ -#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in - DT_MIPS_DELTA_SYM. */ -#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the - class declaration. */ -#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in - DT_MIPS_DELTA_CLASSSYM. */ -#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */ -#define DT_MIPS_PIXIE_INIT 0x70000023 -#define DT_MIPS_SYMBOL_LIB 0x70000024 -#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 -#define DT_MIPS_LOCAL_GOTIDX 0x70000026 -#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 -#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 -#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */ -#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */ -#define DT_MIPS_DYNSTR_ALIGN 0x7000002b -#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */ -#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve - function stored in GOT. */ -#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added - by rld on dlopen() calls. */ -#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */ -#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */ -#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */ -#define DT_MIPS_NUM 0x32 - -/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */ - -#define RHF_NONE 0 /* No flags */ -#define RHF_QUICKSTART (1 << 0) /* Use quickstart */ -#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */ -#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */ -#define RHF_NO_MOVE (1 << 3) -#define RHF_SGI_ONLY (1 << 4) -#define RHF_GUARANTEE_INIT (1 << 5) -#define RHF_DELTA_C_PLUS_PLUS (1 << 6) -#define RHF_GUARANTEE_START_INIT (1 << 7) -#define RHF_PIXIE (1 << 8) -#define RHF_DEFAULT_DELAY_LOAD (1 << 9) -#define RHF_REQUICKSTART (1 << 10) -#define RHF_REQUICKSTARTED (1 << 11) -#define RHF_CORD (1 << 12) -#define RHF_NO_UNRES_UNDEF (1 << 13) -#define RHF_RLD_ORDER_SAFE (1 << 14) - -/* Entries found in sections of type SHT_MIPS_LIBLIST. */ - -typedef struct -{ - Elf32_Word l_name; /* Name (string table index) */ - Elf32_Word l_time_stamp; /* Timestamp */ - Elf32_Word l_checksum; /* Checksum */ - Elf32_Word l_version; /* Interface version */ - Elf32_Word l_flags; /* Flags */ -} Elf32_Lib; - -typedef struct -{ - Elf64_Word l_name; /* Name (string table index) */ - Elf64_Word l_time_stamp; /* Timestamp */ - Elf64_Word l_checksum; /* Checksum */ - Elf64_Word l_version; /* Interface version */ - Elf64_Word l_flags; /* Flags */ -} Elf64_Lib; - - -/* Legal values for l_flags. */ - -#define LL_NONE 0 -#define LL_EXACT_MATCH (1 << 0) /* Require exact match */ -#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */ -#define LL_REQUIRE_MINOR (1 << 2) -#define LL_EXPORTS (1 << 3) -#define LL_DELAY_LOAD (1 << 4) -#define LL_DELTA (1 << 5) - -/* Entries found in sections of type SHT_MIPS_CONFLICT. */ - -typedef Elf32_Addr Elf32_Conflict; - - -/* HPPA specific definitions. */ - -/* Legal values for e_flags field of Elf32_Ehdr. */ - -#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */ -#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */ -#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */ -#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */ -#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch - prediction. */ -#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */ -#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */ - -/* Defined values for `e_flags & EF_PARISC_ARCH' are: */ - -#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */ -#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */ -#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */ - -/* Additional section indeces. */ - -#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared - symbols in ANSI C. */ -#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */ - -/* Legal values for sh_type field of Elf32_Shdr. */ - -#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */ -#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */ -#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */ - -/* Legal values for sh_flags field of Elf32_Shdr. */ - -#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */ -#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */ -#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */ - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ - -#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */ - -#define STT_HP_OPAQUE (STT_LOOS + 0x1) -#define STT_HP_STUB (STT_LOOS + 0x2) - -/* HPPA relocs. */ - -#define R_PARISC_NONE 0 /* No reloc. */ -#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */ -#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */ -#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */ -#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */ -#define R_PARISC_DIR14R 5 /* Right 14 bits of eff. address. */ -#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */ -#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */ -#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */ -#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ -#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ -#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ -#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ -#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ -#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ -#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ -#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ -#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ -#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ -#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ -#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ -#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ -#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ -#define R_PARISC_FPTR64 64 /* 64 bits function address. */ -#define R_PARISC_PLABEL32 65 /* 32 bits function address. */ -#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ -#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ -#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ -#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ -#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */ -#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */ -#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */ -#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */ -#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */ -#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */ -#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */ -#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */ -#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */ -#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */ -#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */ -#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */ -#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */ -#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */ -#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */ -#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */ -#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */ -#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */ -#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */ -#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ -#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ -#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ -#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ -#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ -#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ -#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */ -#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */ -#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */ -#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */ -#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */ -#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */ -#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */ -#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */ -#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */ -#define R_PARISC_LORESERVE 128 -#define R_PARISC_COPY 128 /* Copy relocation. */ -#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */ -#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */ -#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */ -#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */ -#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */ -#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */ -#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/ -#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */ -#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */ -#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */ -#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */ -#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */ -#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */ -#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */ -#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */ -#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/ -#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/ -#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */ -#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */ -#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */ -#define R_PARISC_HIRESERVE 255 - -/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */ - -#define PT_HP_TLS (PT_LOOS + 0x0) -#define PT_HP_CORE_NONE (PT_LOOS + 0x1) -#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) -#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) -#define PT_HP_CORE_COMM (PT_LOOS + 0x4) -#define PT_HP_CORE_PROC (PT_LOOS + 0x5) -#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) -#define PT_HP_CORE_STACK (PT_LOOS + 0x7) -#define PT_HP_CORE_SHM (PT_LOOS + 0x8) -#define PT_HP_CORE_MMF (PT_LOOS + 0x9) -#define PT_HP_PARALLEL (PT_LOOS + 0x10) -#define PT_HP_FASTBIND (PT_LOOS + 0x11) -#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) -#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) -#define PT_HP_STACK (PT_LOOS + 0x14) - -#define PT_PARISC_ARCHEXT 0x70000000 -#define PT_PARISC_UNWIND 0x70000001 - -/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */ - -#define PF_PARISC_SBP 0x08000000 - -#define PF_HP_PAGE_SIZE 0x00100000 -#define PF_HP_FAR_SHARED 0x00200000 -#define PF_HP_NEAR_SHARED 0x00400000 -#define PF_HP_CODE 0x01000000 -#define PF_HP_MODIFY 0x02000000 -#define PF_HP_LAZYSWAP 0x04000000 -#define PF_HP_SBP 0x08000000 - - -/* Alpha specific definitions. */ - -/* Legal values for e_flags field of Elf64_Ehdr. */ - -#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */ -#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */ - -/* Legal values for sh_type field of Elf64_Shdr. */ - -/* These two are primerily concerned with ECOFF debugging info. */ -#define SHT_ALPHA_DEBUG 0x70000001 -#define SHT_ALPHA_REGINFO 0x70000002 - -/* Legal values for sh_flags field of Elf64_Shdr. */ - -#define SHF_ALPHA_GPREL 0x10000000 - -/* Legal values for st_other field of Elf64_Sym. */ -#define STO_ALPHA_NOPV 0x80 /* No PV required. */ -#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */ - -/* Alpha relocs. */ - -#define R_ALPHA_NONE 0 /* No reloc */ -#define R_ALPHA_REFLONG 1 /* Direct 32 bit */ -#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */ -#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */ -#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */ -#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */ -#define R_ALPHA_GPDISP 6 /* Add displacement to GP */ -#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */ -#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */ -#define R_ALPHA_SREL16 9 /* PC relative 16 bit */ -#define R_ALPHA_SREL32 10 /* PC relative 32 bit */ -#define R_ALPHA_SREL64 11 /* PC relative 64 bit */ -#define R_ALPHA_OP_PUSH 12 /* OP stack push */ -#define R_ALPHA_OP_STORE 13 /* OP stack pop and store */ -#define R_ALPHA_OP_PSUB 14 /* OP stack subtract */ -#define R_ALPHA_OP_PRSHIFT 15 /* OP stack right shift */ -#define R_ALPHA_GPVALUE 16 -#define R_ALPHA_GPRELHIGH 17 -#define R_ALPHA_GPRELLOW 18 -#define R_ALPHA_IMMED_GP_16 19 -#define R_ALPHA_IMMED_GP_HI32 20 -#define R_ALPHA_IMMED_SCN_HI32 21 -#define R_ALPHA_IMMED_BR_HI32 22 -#define R_ALPHA_IMMED_LO32 23 -#define R_ALPHA_COPY 24 /* Copy symbol at runtime */ -#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */ -#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ -#define R_ALPHA_RELATIVE 27 /* Adjust by program base */ -/* Keep this the last entry. */ -#define R_ALPHA_NUM 28 - - -/* PowerPC specific declarations */ - -/* Values for Elf32/64_Ehdr.e_flags. */ -#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ - -/* Cygnus local bits below */ -#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ -#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib - flag */ - -/* PowerPC relocations defined by the ABIs */ -#define R_PPC_NONE 0 -#define R_PPC_ADDR32 1 /* 32bit absolute address */ -#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ -#define R_PPC_ADDR16 3 /* 16bit absolute address */ -#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ -#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ -#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ -#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ -#define R_PPC_ADDR14_BRTAKEN 8 -#define R_PPC_ADDR14_BRNTAKEN 9 -#define R_PPC_REL24 10 /* PC relative 26 bit */ -#define R_PPC_REL14 11 /* PC relative 16 bit */ -#define R_PPC_REL14_BRTAKEN 12 -#define R_PPC_REL14_BRNTAKEN 13 -#define R_PPC_GOT16 14 -#define R_PPC_GOT16_LO 15 -#define R_PPC_GOT16_HI 16 -#define R_PPC_GOT16_HA 17 -#define R_PPC_PLTREL24 18 -#define R_PPC_COPY 19 -#define R_PPC_GLOB_DAT 20 -#define R_PPC_JMP_SLOT 21 -#define R_PPC_RELATIVE 22 -#define R_PPC_LOCAL24PC 23 -#define R_PPC_UADDR32 24 -#define R_PPC_UADDR16 25 -#define R_PPC_REL32 26 -#define R_PPC_PLT32 27 -#define R_PPC_PLTREL32 28 -#define R_PPC_PLT16_LO 29 -#define R_PPC_PLT16_HI 30 -#define R_PPC_PLT16_HA 31 -#define R_PPC_SDAREL16 32 -#define R_PPC_SECTOFF 33 -#define R_PPC_SECTOFF_LO 34 -#define R_PPC_SECTOFF_HI 35 -#define R_PPC_SECTOFF_HA 36 -/* Keep this the last entry. */ -#define R_PPC_NUM 37 - -/* The remaining relocs are from the Embedded ELF ABI, and are not - in the SVR4 ELF ABI. */ -#define R_PPC_EMB_NADDR32 101 -#define R_PPC_EMB_NADDR16 102 -#define R_PPC_EMB_NADDR16_LO 103 -#define R_PPC_EMB_NADDR16_HI 104 -#define R_PPC_EMB_NADDR16_HA 105 -#define R_PPC_EMB_SDAI16 106 -#define R_PPC_EMB_SDA2I16 107 -#define R_PPC_EMB_SDA2REL 108 -#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */ -#define R_PPC_EMB_MRKREF 110 -#define R_PPC_EMB_RELSEC16 111 -#define R_PPC_EMB_RELST_LO 112 -#define R_PPC_EMB_RELST_HI 113 -#define R_PPC_EMB_RELST_HA 114 -#define R_PPC_EMB_BIT_FLD 115 -#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */ - -/* Diab tool relocations. */ -#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */ -#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */ -#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */ -#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */ -#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ -#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ - -/* This is a phony reloc to handle any old fashioned TOC16 references - that may still be in object files. */ -#define R_PPC_TOC16 255 - - -/* ARM specific declarations */ - -/* Processor specific flags for the ELF header e_flags field. */ -#define EF_ARM_RELEXEC 0x01 -#define EF_ARM_HASENTRY 0x02 -#define EF_ARM_INTERWORK 0x04 -#define EF_ARM_APCS_26 0x08 -#define EF_ARM_APCS_FLOAT 0x10 -#define EF_ARM_PIC 0x20 -#define EF_ALIGN8 0x40 /* 8-bit structure alignment is in use */ -#define EF_NEW_ABI 0x80 -#define EF_OLD_ABI 0x100 - -/* Additional symbol types for Thumb */ -#define STT_ARM_TFUNC 0xd - -/* ARM-specific values for sh_flags */ -#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */ -#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined - in the input to a link step */ - -/* ARM-specific program header flags */ -#define PF_ARM_SB 0x10000000 /* Segment contains the location - addressed by the static base */ - -/* ARM relocs. */ -#define R_ARM_NONE 0 /* No reloc */ -#define R_ARM_PC24 1 /* PC relative 26 bit branch */ -#define R_ARM_ABS32 2 /* Direct 32 bit */ -#define R_ARM_REL32 3 /* PC relative 32 bit */ -#define R_ARM_PC13 4 -#define R_ARM_ABS16 5 /* Direct 16 bit */ -#define R_ARM_ABS12 6 /* Direct 12 bit */ -#define R_ARM_THM_ABS5 7 -#define R_ARM_ABS8 8 /* Direct 8 bit */ -#define R_ARM_SBREL32 9 -#define R_ARM_THM_PC22 10 -#define R_ARM_THM_PC8 11 -#define R_ARM_AMP_VCALL9 12 -#define R_ARM_SWI24 13 -#define R_ARM_THM_SWI8 14 -#define R_ARM_XPC25 15 -#define R_ARM_THM_XPC22 16 -#define R_ARM_COPY 20 /* Copy symbol at runtime */ -#define R_ARM_GLOB_DAT 21 /* Create GOT entry */ -#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */ -#define R_ARM_RELATIVE 23 /* Adjust by program base */ -#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */ -#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */ -#define R_ARM_GOT32 26 /* 32 bit GOT entry */ -#define R_ARM_PLT32 27 /* 32 bit PLT address */ -#define R_ARM_GNU_VTENTRY 100 -#define R_ARM_GNU_VTINHERIT 101 -#define R_ARM_THM_PC11 102 /* thumb unconditional branch */ -#define R_ARM_THM_PC9 103 /* thumb conditional branch */ -#define R_ARM_RXPC25 249 -#define R_ARM_RSBREL32 250 -#define R_ARM_THM_RPC22 251 -#define R_ARM_RREL32 252 -#define R_ARM_RABS22 253 -#define R_ARM_RPC24 254 -#define R_ARM_RBASE 255 -/* Keep this the last entry. */ -#define R_ARM_NUM 256 - -/* IA-64 specific declarations. */ - -/* Processor specific flags for the Ehdr e_flags field. */ -#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */ -#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */ -#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */ - -/* Processor specific values for the Phdr p_type field. */ -#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */ -#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */ - -/* Processor specific flags for the Phdr p_flags field. */ -#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */ - -/* Processor specific values for the Shdr sh_type field. */ -#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */ -#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ - -/* Processor specific flags for the Shdr sh_flags field. */ -#define SHF_IA_64_SHORT 0x10000000 /* section near gp */ -#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */ - -/* Processor specific values for the Dyn d_tag field. */ -#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) -#define DT_IA_64_NUM 1 - -/* IA-64 relocations. */ -#define R_IA64_NONE 0x00 /* none */ -#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */ -#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */ -#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */ -#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */ -#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */ -#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */ -#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */ -#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */ -#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */ -#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */ -#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */ -#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */ -#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */ -#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */ -#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */ -#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */ -#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */ -#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */ -#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */ -#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */ -#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */ -#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */ -#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */ -#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */ -#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */ -#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */ -#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */ -#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */ -#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */ -#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */ -#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */ -#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */ -#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */ -#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */ -#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */ -#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */ -#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */ -#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */ -#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */ -#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */ -#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */ -#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */ -#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */ -#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */ -#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */ -#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */ -#define R_IA64_REL32MSB 0x6c /* data 4 + REL */ -#define R_IA64_REL32LSB 0x6d /* data 4 + REL */ -#define R_IA64_REL64MSB 0x6e /* data 8 + REL */ -#define R_IA64_REL64LSB 0x6f /* data 8 + REL */ -#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */ -#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */ -#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */ -#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */ -#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */ -#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */ -#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */ -#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */ -#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */ -#define R_IA64_COPY 0x84 /* copy relocation */ -#define R_IA64_SUB 0x85 /* Addend and symbol difference */ -#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */ -#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */ -#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */ -#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */ -#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */ -#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */ -#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */ -#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */ -#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */ -#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */ -#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */ -#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */ -#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */ -#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */ -#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */ -#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */ -#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */ -#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ -#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ - -/* SH specific declarations */ - -/* SH relocs. */ -#define R_SH_NONE 0 -#define R_SH_DIR32 1 -#define R_SH_REL32 2 -#define R_SH_DIR8WPN 3 -#define R_SH_IND12W 4 -#define R_SH_DIR8WPL 5 -#define R_SH_DIR8WPZ 6 -#define R_SH_DIR8BP 7 -#define R_SH_DIR8W 8 -#define R_SH_DIR8L 9 -#define R_SH_SWITCH16 25 -#define R_SH_SWITCH32 26 -#define R_SH_USES 27 -#define R_SH_COUNT 28 -#define R_SH_ALIGN 29 -#define R_SH_CODE 30 -#define R_SH_DATA 31 -#define R_SH_LABEL 32 -#define R_SH_SWITCH8 33 -#define R_SH_GNU_VTINHERIT 34 -#define R_SH_GNU_VTENTRY 35 -#define R_SH_GOT32 160 -#define R_SH_PLT32 161 -#define R_SH_COPY 162 -#define R_SH_GLOB_DAT 163 -#define R_SH_JMP_SLOT 164 -#define R_SH_RELATIVE 165 -#define R_SH_GOTOFF 166 -#define R_SH_GOTPC 167 -/* Keep this the last entry. */ -#define R_SH_NUM 256 - -/* Additional s390 relocs */ - -#define R_390_NONE 0 /* No reloc. */ -#define R_390_8 1 /* Direct 8 bit. */ -#define R_390_12 2 /* Direct 12 bit. */ -#define R_390_16 3 /* Direct 16 bit. */ -#define R_390_32 4 /* Direct 32 bit. */ -#define R_390_PC32 5 /* PC relative 32 bit. */ -#define R_390_GOT12 6 /* 12 bit GOT offset. */ -#define R_390_GOT32 7 /* 32 bit GOT offset. */ -#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */ -#define R_390_COPY 9 /* Copy symbol at runtime. */ -#define R_390_GLOB_DAT 10 /* Create GOT entry. */ -#define R_390_JMP_SLOT 11 /* Create PLT entry. */ -#define R_390_RELATIVE 12 /* Adjust by program base. */ -#define R_390_GOTOFF 13 /* 32 bit offset to GOT. */ -#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */ -#define R_390_GOT16 15 /* 16 bit GOT offset. */ -#define R_390_PC16 16 /* PC relative 16 bit. */ -#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */ -#define R_390_PLT16DBL 18 /* 32 bit PC rel. PLT shifted by 1. */ -/* Keep this the last entry. */ -#define R_390_NUM 19 - -#endif /* elf.h */ +#include <linux/elf.h> diff --git a/mdk-stage1/dietlibc/include/errno.h b/mdk-stage1/dietlibc/include/errno.h index f4ba482b5..d1c68f39c 100644 --- a/mdk-stage1/dietlibc/include/errno.h +++ b/mdk-stage1/dietlibc/include/errno.h @@ -5,6 +5,7 @@ extern int errno; #include <linux/errno.h> +extern int *__errno_location(void); extern void __set_errno(int error); #endif diff --git a/mdk-stage1/dietlibc/include/features.h b/mdk-stage1/dietlibc/include/features.h index 02f081006..5b0283f20 100644 --- a/mdk-stage1/dietlibc/include/features.h +++ b/mdk-stage1/dietlibc/include/features.h @@ -1 +1,3 @@ #warning "someone included features.h, apparently someone is including glibc headers!" + +#define __dietlibc__ diff --git a/mdk-stage1/dietlibc/include/fnmatch.h b/mdk-stage1/dietlibc/include/fnmatch.h new file mode 100644 index 000000000..762b43ff7 --- /dev/null +++ b/mdk-stage1/dietlibc/include/fnmatch.h @@ -0,0 +1,15 @@ +#ifndef _FNMATCH_H +#define _FNMATCH_H + +#include <sys/cdefs.h> + +int fnmatch(const char *pattern, const char *string, int flags) __THROW; + +#define FNM_NOESCAPE 1 +#define FNM_PATHNAME 2 +#define FNM_FILE_NAME 2 +#define FNM_PERIOD 4 +#define FNM_LEADING_DIR 8 +#define FNM_CASEFOLD 16 + +#endif diff --git a/mdk-stage1/dietlibc/include/getopt.h b/mdk-stage1/dietlibc/include/getopt.h new file mode 100644 index 000000000..ebfc5522d --- /dev/null +++ b/mdk-stage1/dietlibc/include/getopt.h @@ -0,0 +1,32 @@ +#ifndef __GETOPT_H__ +#define __GETOPT_H__ + +extern int optind,opterr; +extern char *optarg; +int getopt(int argc, char *argv[], char *options); + +/* the following was taken from GNU getopt, it's not actually supported + * by the diet libc! */ +extern int optopt; + +struct option { + const char* name; + int has_arg; + int* flag; + int val; +}; + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +extern int getopt_long(int argc, char *const *argv, + const char *shortopts, const struct option *longopts, + int *longind); + +extern int getopt_long_only(int argc, char *const *argv, + const char *shortopts, const struct option *longopts, + int *longind); + + +#endif diff --git a/mdk-stage1/dietlibc/include/glob.h b/mdk-stage1/dietlibc/include/glob.h new file mode 100644 index 000000000..80febbccf --- /dev/null +++ b/mdk-stage1/dietlibc/include/glob.h @@ -0,0 +1,55 @@ +#ifndef _GLOB_H +#define _GLOB_H + + +typedef struct { + size_t gl_pathc; /* Count of paths matched so far */ + char **gl_pathv; /* List of matched pathnames. */ + size_t gl_offs; /* Slots to reserve in `gl_pathv'. */ + int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */ +} glob_t; + + +int glob(const char *pattern, int flags, + int errfunc(const char * epath, int eerrno), + glob_t *pglob) __THROW; + +void globfree(glob_t *pglob) __THROW; + + + +/* Bits set in the FLAGS argument to `glob'. */ +#define GLOB_ERR (1 << 0)/* Return on read errors. */ +#define GLOB_MARK (1 << 1)/* Append a slash to each name. */ +#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */ +#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */ +#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */ +#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */ +#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */ +#define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */ + +#define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */ +#define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */ +#define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */ +#define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */ +#define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */ +#define GLOB_ONLYDIR (1 << 13)/* Match only directories. */ +#define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error + if the user name is not available. */ +#define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \ + GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \ + GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \ + GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK) + + +/* Error returns from `glob'. */ +#define GLOB_NOSPACE 1 /* Ran out of memory. */ +#define GLOB_ABORTED 2 /* Read error. */ +#define GLOB_NOMATCH 3 /* No matches found. */ +#define GLOB_NOSYS 4 /* Not implemented. */ +/* Previous versions of this file defined GLOB_ABEND instead of + GLOB_ABORTED. Provide a compatibility definition here. */ +#define GLOB_ABEND GLOB_ABORTED + + +#endif diff --git a/mdk-stage1/dietlibc/include/grp.h b/mdk-stage1/dietlibc/include/grp.h index 2acd0f208..32bf49afc 100644 --- a/mdk-stage1/dietlibc/include/grp.h +++ b/mdk-stage1/dietlibc/include/grp.h @@ -12,7 +12,14 @@ struct group char **gr_mem; /* Member list. */ }; -extern struct passwd *getgrgid (uid_t __uid) __THROW; -extern struct passwd *getgrnam (const char *__name) __THROW; +extern struct group *getgrgid (gid_t uid) __THROW; +extern struct group *getgrnam (const char *name) __THROW; + +extern struct group *getgrent(void) __THROW; +extern void setgrent(void) __THROW; +extern void endgrent(void) __THROW; + +extern int setgroups(size_t n, const gid_t *groups) __THROW; +extern int initgroups(const char *user, gid_t group) __THROW; #endif diff --git a/mdk-stage1/dietlibc/include/inttypes.h b/mdk-stage1/dietlibc/include/inttypes.h new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/mdk-stage1/dietlibc/include/inttypes.h diff --git a/mdk-stage1/dietlibc/include/limits.h b/mdk-stage1/dietlibc/include/limits.h index ccc02150d..a333debfd 100644 --- a/mdk-stage1/dietlibc/include/limits.h +++ b/mdk-stage1/dietlibc/include/limits.h @@ -3,8 +3,46 @@ #include <linux/limits.h> +#define __WORDSIZE 32 + +#ifdef __alpha__ +#undef __WORDSIZE +#define __WORDSIZE 64 +#endif + #ifndef PATH_MAX #define PATH_MAX 4096 #endif +#define CHAR_BIT 8 + +#define SCHAR_MIN (-128) +#define SCHAR_MAX 0x7f +#define UCHAR_MAX 0xff + +#define SHRT_MIN (-SHRT_MAX-1) +#define SHRT_MAX 0x7fff +#define USHRT_MAX 0xffff + +#define INT_MIN (-INT_MAX-1) +#define INT_MAX 0x7fffffff +#define UINT_MAX 0xffffffff + +#if __WORDSIZE == 64 +#define LONG_MAX 9223372036854775807L +#define ULONG_MAX 18446744073709551615UL +#else +#define LONG_MAX 2147483647L +#define ULONG_MAX 4294967295UL +#endif +#define LONG_MIN (-LONG_MAX - 1L) + +#define LLONG_MAX 9223372036854775807LL +#define LLONG_MIN (-LLONG_MAX - 1LL) + +/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ +#define ULLONG_MAX 18446744073709551615ULL + +#define PASS_MAX 256 + #endif diff --git a/mdk-stage1/dietlibc/include/locale.h b/mdk-stage1/dietlibc/include/locale.h new file mode 100644 index 000000000..acbeec8c1 --- /dev/null +++ b/mdk-stage1/dietlibc/include/locale.h @@ -0,0 +1,6 @@ +#warning "there is no locale support for diet libc yet" + +#define setlocale(a,b) 0 +#define bindtextdomain +#define textdomain + diff --git a/mdk-stage1/dietlibc/include/math.h b/mdk-stage1/dietlibc/include/math.h new file mode 100644 index 000000000..716bc8e19 --- /dev/null +++ b/mdk-stage1/dietlibc/include/math.h @@ -0,0 +1,56 @@ +#ifndef _MATH_H +#define _MATH_H + +#include <sys/cdefs.h> + +#define M_E 2.7182818284590452354 /* e */ +#define M_LOG2E 1.4426950408889634074 /* log_2 e */ +#define M_LOG10E 0.43429448190325182765 /* log_10 e */ +#define M_LN2 0.69314718055994530942 /* log_e 2 */ +#define M_LN10 2.30258509299404568402 /* log_e 10 */ +#define M_PI 3.14159265358979323846 /* pi */ +#define M_PI_2 1.57079632679489661923 /* pi/2 */ +#define M_PI_4 0.78539816339744830962 /* pi/4 */ +#define M_1_PI 0.31830988618379067154 /* 1/pi */ +#define M_2_PI 0.63661977236758134308 /* 2/pi */ +#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ + +#define M_El 2.7182818284590452353602874713526625L /* e */ +#define M_LOG2El 1.4426950408889634073599246810018922L /* log_2 e */ +#define M_LOG10El 0.4342944819032518276511289189166051L /* log_10 e */ +#define M_LN2l 0.6931471805599453094172321214581766L /* log_e 2 */ +#define M_LN10l 2.3025850929940456840179914546843642L /* log_e 10 */ +#define M_PIl 3.1415926535897932384626433832795029L /* pi */ +#define M_PI_2l 1.5707963267948966192313216916397514L /* pi/2 */ +#define M_PI_4l 0.7853981633974483096156608458198757L /* pi/4 */ +#define M_1_PIl 0.3183098861837906715377675267450287L /* 1/pi */ +#define M_2_PIl 0.6366197723675813430755350534900574L /* 2/pi */ +#define M_2_SQRTPIl 1.1283791670955125738961589031215452L /* 2/sqrt(pi) */ +#define M_SQRT2l 1.4142135623730950488016887242096981L /* sqrt(2) */ +#define M_SQRT1_2l 0.7071067811865475244008443621048490L /* 1/sqrt(2) */ + +double sin(double d) __THROW __attribute__((__const__)); +double cos(double d) __THROW __attribute__((__const__)); +double tan(double d) __THROW __attribute__((__const__)); + +double sinh(double d) __THROW __attribute__((__const__)); +double cosh(double d) __THROW __attribute__((__const__)); +double tanh(double d) __THROW __attribute__((__const__)); + +double asin(double d) __THROW __attribute__((__const__)); +double acos(double d) __THROW __attribute__((__const__)); +double atan(double d) __THROW __attribute__((__const__)); + +double asinh(double d) __THROW __attribute__((__const__)); +double acosh(double d) __THROW __attribute__((__const__)); +double atanh(double d) __THROW __attribute__((__const__)); + +double exp(double d) __THROW __attribute__((__const__)); +double log(double d) __THROW __attribute__((__const__)); +double log10(double d) __THROW __attribute__((__const__)); + +double pow(double x, double y) __THROW __attribute__((__const__)); + +#endif diff --git a/mdk-stage1/dietlibc/include/memory.h b/mdk-stage1/dietlibc/include/memory.h new file mode 100644 index 000000000..39adee705 --- /dev/null +++ b/mdk-stage1/dietlibc/include/memory.h @@ -0,0 +1,6 @@ +#ifndef _MEMORY_H +#define _MEMORY_H + +#include <string.h> + +#endif diff --git a/mdk-stage1/dietlibc/include/mntent.h b/mdk-stage1/dietlibc/include/mntent.h new file mode 100644 index 000000000..301403224 --- /dev/null +++ b/mdk-stage1/dietlibc/include/mntent.h @@ -0,0 +1,72 @@ +#ifndef _MNTENT_H +#define _MNTENT_H + +#include <sys/cdefs.h> +#include <stdio.h> +#include <paths.h> + +#define MNTTAB _PATH_MNTTAB /* Deprecated alias. */ +#define MOUNTED _PATH_MOUNTED /* Deprecated alias. */ + +/* General filesystem types. */ +#define MNTTYPE_IGNORE "ignore" /* Ignore this entry. */ +#define MNTTYPE_NFS "nfs" /* Network file system. */ +#define MNTTYPE_SWAP "swap" /* Swap device. */ + + +/* Generic mount options. */ +#define MNTOPT_DEFAULTS "defaults" /* Use all default options. */ +#define MNTOPT_RO "ro" /* Read only. */ +#define MNTOPT_RW "rw" /* Read/write. */ +#define MNTOPT_SUID "suid" /* Set uid allowed. */ +#define MNTOPT_NOSUID "nosuid" /* No set uid allowed. */ +#define MNTOPT_NOAUTO "noauto" /* Do not auto mount. */ + +__BEGIN_DECLS + +/* Structure describing a mount table entry. */ +struct mntent + { + char *mnt_fsname; /* Device or server for filesystem. */ + char *mnt_dir; /* Directory mounted on. */ + char *mnt_type; /* Type of filesystem: ufs, nfs, etc. */ + char *mnt_opts; /* Comma-separated options for fs. */ + int mnt_freq; /* Dump frequency (in days). */ + int mnt_passno; /* Pass number for `fsck'. */ + }; + + +/* Prepare to begin reading and/or writing mount table entries from the + beginning of FILE. MODE is as for `fopen'. */ +extern FILE *setmntent (const char *file, const char *mode) __THROW; + +/* Read one mount table entry from STREAM. Returns a pointer to storage + reused on the next call, or null for EOF or error (use feof/ferror to + check). */ +extern struct mntent *getmntent (FILE* stream) __THROW; + +#ifdef __USE_MISC +/* Reentrant version of the above function. */ +extern struct mntent *getmntent_r (FILE* stream, + struct mntent* result, + char* buffer, + int bufsize) __THROW; +#endif + +/* Write the mount table entry described by MNT to STREAM. + Return zero on success, nonzero on failure. */ +extern int addmntent (FILE* stream, + const struct mntent* mnt) __THROW; + +/* Close a stream opened with `setmntent'. */ +extern int endmntent (FILE *stream) __THROW; + +/* Search MNT->mnt_opts for an option matching OPT. + Returns the address of the substring, or null if none found. */ +extern char *hasmntopt (const struct mntent *__mnt, + const char *opt) __THROW; + + +__END_DECLS + +#endif /* mntent.h */ diff --git a/mdk-stage1/dietlibc/include/net/if.h b/mdk-stage1/dietlibc/include/net/if.h index e6e7be441..88f386f46 100644 --- a/mdk-stage1/dietlibc/include/net/if.h +++ b/mdk-stage1/dietlibc/include/net/if.h @@ -3,6 +3,8 @@ #include <sys/cdefs.h> +#include <linux/if.h> + unsigned int if_nametoindex (const char *ifname) __THROW; char *if_indextoname (unsigned int ifindex, char *ifname) __THROW; diff --git a/mdk-stage1/dietlibc/include/net/if_arp.h b/mdk-stage1/dietlibc/include/net/if_arp.h new file mode 100644 index 000000000..fe37a22dc --- /dev/null +++ b/mdk-stage1/dietlibc/include/net/if_arp.h @@ -0,0 +1,6 @@ +#ifndef _NET_IF_ARP_H +#define _NET_IF_ARP_H + +#include <linux/if_arp.h> + +#endif diff --git a/mdk-stage1/dietlibc/include/net/route.h b/mdk-stage1/dietlibc/include/net/route.h new file mode 100644 index 000000000..5e5db7b1a --- /dev/null +++ b/mdk-stage1/dietlibc/include/net/route.h @@ -0,0 +1,6 @@ +#ifndef _NET_IF_ROUTE_H +#define _NET_IF_ROUTE_H + +#include <linux/route.h> + +#endif diff --git a/mdk-stage1/dietlibc/include/netdb.h b/mdk-stage1/dietlibc/include/netdb.h index 29f452ee9..887faa999 100644 --- a/mdk-stage1/dietlibc/include/netdb.h +++ b/mdk-stage1/dietlibc/include/netdb.h @@ -23,9 +23,9 @@ struct servent extern void endservent (void) __THROW; extern struct servent *getservent (void) __THROW; -extern struct servent *getservbyname (__const char *__name, - __const char *__proto) __THROW; -extern struct servent *getservbyport (int __port, __const char *__proto) +extern struct servent *getservbyname (const char *__name, + const char *__proto) __THROW; +extern struct servent *getservbyport (int __port, const char *__proto) __THROW; struct hostent @@ -45,4 +45,31 @@ extern struct hostent *gethostbyaddr (const void *__addr, socklen_t __len, extern struct hostent *gethostbyname (const char *__name) __THROW; extern struct hostent *gethostbyname2 (const char *__name, int __af) __THROW; +/* this glibc "invention" is so ugly, I'm going to throw up any minute + * now */ +extern int gethostbyname_r(const char* NAME, struct hostent* RESULT_BUF,char* BUF, + size_t BUFLEN, struct hostent** RESULT, + int* H_ERRNOP) __THROW; + +#define HOST_NOT_FOUND 1 +#define TRY_AGAIN 2 +#define NO_RECOVERY 3 +#define NO_ADDRESS 4 + +extern int gethostbyaddr_r(const char* addr, size_t length, int format, + struct hostent* result, char *buf, size_t buflen, + struct hostent **RESULT, int *h_errnop) __THROW; + +struct protoent { + char *p_name; /* official protocol name */ + char **p_aliases; /* alias list */ + int p_proto; /* protocol number */ +}; + +struct protoent *getprotoent(void) __THROW; +struct protoent *getprotobyname(const char *name) __THROW; +struct protoent *getprotobynumber(int proto) __THROW; +void setprotoent(int stayopen) __THROW; +void endprotoent(void) __THROW; + #endif diff --git a/mdk-stage1/dietlibc/include/netinet/in.h b/mdk-stage1/dietlibc/include/netinet/in.h index d83498a76..0569c8289 100644 --- a/mdk-stage1/dietlibc/include/netinet/in.h +++ b/mdk-stage1/dietlibc/include/netinet/in.h @@ -2,5 +2,8 @@ #define _NETINET_IN_H #include <linux/in.h> +#include <linux/in6.h> + +#define IPPORT_RESERVED 1024 #endif diff --git a/mdk-stage1/dietlibc/include/paths.h b/mdk-stage1/dietlibc/include/paths.h index aac47e870..0e36bb10e 100644 --- a/mdk-stage1/dietlibc/include/paths.h +++ b/mdk-stage1/dietlibc/include/paths.h @@ -4,4 +4,13 @@ #define _PATH_BSHELL "/bin/sh" #define _PATH_DEFPATH "/bin:/usr/bin:" +#define _PATH_DEVNULL "/dev/null" + +#define _PATH_CONSOLE "/dev/console" +#define _PATH_MOUNTED "/etc/mtab" + +#define _PATH_PASSWD "/etc/passwd" +#define _PATH_GROUP "/etc/group" +#define _PATH_SHADOW "/etc/shadow" + #endif diff --git a/mdk-stage1/dietlibc/include/pthread.h b/mdk-stage1/dietlibc/include/pthread.h new file mode 100644 index 000000000..e922ab28b --- /dev/null +++ b/mdk-stage1/dietlibc/include/pthread.h @@ -0,0 +1,227 @@ +#ifndef _PTHREAD_H +#define _PTHREAD_H 1 + +#include <sched.h> +#include <signal.h> +#include <setjmp.h> + +/* arg... kernel haeder... */ +#define ENOTSUP 524 /* Operation is not supported */ + +#define PTHREAD_STACK_SIZE 16384 + +#define PTHREAD_THREADS_MAX 128 + +#define MAX_SPIN_COUNT 50 +#define SPIN_SLEEP_DURATION 2000001 + +#define PTHREAD_KEYS_MAX 7 +#define PTHREAD_DESTRUCTOR_ITERATIONS 10 + +typedef struct _pthread_descr_struct *_pthread_descr; +typedef unsigned long int pthread_t; + +/* Fast locks */ +struct _pthread_fastlock { + int __spinlock; +}; + +/* Mutexes */ +typedef struct { + struct _pthread_fastlock lock; + _pthread_descr owner; + int kind; + unsigned int count; +} pthread_mutex_t; + +enum { + PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK_NP, +}; + +enum +{ + PTHREAD_PROCESS_PRIVATE, +#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE + PTHREAD_PROCESS_SHARED +#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED +}; + +#define PTHREAD_MUTEX_INITIALIZER \ +{{0}, 0, PTHREAD_MUTEX_FAST_NP, 0} + +#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ +{{0}, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0} + +#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \ +{{0}, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0} + +typedef struct { + int __mutexkind; +} pthread_mutexattr_t; + +int pthread_mutex_init(pthread_mutex_t *mutex, + const pthread_mutexattr_t *mutexattr); +int pthread_mutex_lock(pthread_mutex_t *mutex); +int pthread_mutex_unlock(pthread_mutex_t *mutex); +int pthread_mutex_trylock(pthread_mutex_t *mutex); +int pthread_mutex_destroy(pthread_mutex_t *mutex); + +/* Conditions */ +typedef void* pthread_condattr_t; + +typedef struct { + struct _pthread_fastlock lock; + _pthread_descr wait_chain; +} pthread_cond_t; + +#define PTHREAD_COND_INITIALIZER \ +{{0},0} + +int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *cond_attr); +int pthread_cond_destroy(pthread_cond_t *cond); +int pthread_cond_signal(pthread_cond_t *cond); +int pthread_cond_broadcast(pthread_cond_t *cond); +int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime); +int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); + +/* only for completeness (always return NULL) */ +int pthread_condattr_init(pthread_condattr_t *attr); +int pthread_condattr_destroy(pthread_condattr_t *attr); +int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared); +int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared); + +/* thread specific variables */ +typedef unsigned int pthread_key_t; + +int pthread_key_create(pthread_key_t *key, void (*destructor)(const void*)); +int pthread_key_delete(pthread_key_t key); +int pthread_setspecific(pthread_key_t key, const void *value); +const void *pthread_getspecific(pthread_key_t key); + + +/* Attributes for threads. */ +typedef struct +{ + int __detachstate; + int __schedpolicy; + struct sched_param __schedparam; + int __inheritsched; + int __scope; + void * __stackaddr; + unsigned long __stacksize; +} pthread_attr_t; + +enum +{ + PTHREAD_CREATE_JOINABLE, +#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE + PTHREAD_CREATE_DETACHED +#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED +}; + +enum +{ + PTHREAD_EXPLICIT_SCHED, +#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED + PTHREAD_INHERIT_SCHED +#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED +}; + +enum /* for completeness */ +{ + PTHREAD_SCOPE_SYSTEM, +#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM + PTHREAD_SCOPE_PROCESS +#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS +}; + +int pthread_attr_init(pthread_attr_t *attr); +int pthread_attr_destroy(pthread_attr_t *attr); + +int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); +int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate); + +int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy); +int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy); + +int pthread_attr_setschedparam(pthread_attr_t *attr, + const struct sched_param *param); +int pthread_attr_getschedparam(const pthread_attr_t *attr, + struct sched_param *param); + +int pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit); +int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit); + +int pthread_attr_setscope(pthread_attr_t *attr, int scope); +int pthread_attr_getscope(const pthread_attr_t *attr, int *scope); + +int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stack); +int pthread_attr_getstackaddr(pthread_attr_t *attr, void **stack); + +int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize); +int pthread_attr_getstacksize(pthread_attr_t *attr, size_t *stacksize); + +/* ONCE */ +typedef int pthread_once_t; +#define PTHREAD_ONCE_INIT 0 + +int __pthread_once(pthread_once_t* once_control, void (*init_routine)(void)); +int pthread_once(pthread_once_t* once_control, void (*init_routine)(void)); + +/* CANCEL */ + +enum { + PTHREAD_CANCEL_ENABLE, +#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE + PTHREAD_CANCEL_DISABLE, +#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE +}; + +enum { + PTHREAD_CANCEL_ASYNCHRONOUS, +#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS + PTHREAD_CANCEL_DEFERRED, +#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED +}; + +#define PTHREAD_CANCELED ((void *) -1) + +int pthread_cancel(pthread_t thread); +int pthread_setcancelstate(int state, int *oldstate); + +int pthread_setcanceltype(int type, int *oldtype); + +void pthread_testcancel(void); + +/* CLEANUP */ + +void pthread_cleanup_push(void (*routine)(void*), void *arg); +void pthread_cleanup_pop (int execute); + +void pthread_cleanup_push_defer_np(void (*routine)(void *), void *arg); +void pthread_cleanup_pop_restore_np(int execute); + +/* FORK */ + +pid_t pthread_atfork(void (*prepare)(void), void (*parent)(void), + void (*child)(void)); + +/* THREADS */ +int pthread_create (pthread_t *__thread, + const pthread_attr_t *__attr, + void *(*__start_routine) (void *), + void *__arg); + +void pthread_exit (void *__retval) __attribute__ ((__noreturn__)); + +int pthread_join (pthread_t __th, void **__thread_return); + +int pthread_detach (pthread_t __th); + +pthread_t pthread_self (void); +int pthread_equal (pthread_t __thread1, pthread_t __thread2); + +#endif diff --git a/mdk-stage1/dietlibc/include/pwd.h b/mdk-stage1/dietlibc/include/pwd.h index c7120917c..e6fb5d0be 100644 --- a/mdk-stage1/dietlibc/include/pwd.h +++ b/mdk-stage1/dietlibc/include/pwd.h @@ -17,4 +17,8 @@ struct passwd { extern struct passwd *getpwuid (uid_t __uid) __THROW; extern struct passwd *getpwnam (const char *__name) __THROW; +extern struct passwd *getpwent(void) __THROW; +extern void setpwent(void) __THROW; +extern void endpwent(void) __THROW; + #endif diff --git a/mdk-stage1/dietlibc/include/regex.h b/mdk-stage1/dietlibc/include/regex.h new file mode 100644 index 000000000..be609d9db --- /dev/null +++ b/mdk-stage1/dietlibc/include/regex.h @@ -0,0 +1,67 @@ +#ifndef _REGEX_H +#define _REGEX_H + +#include <sys/cdefs.h> +#include <sys/types.h> + +typedef ptrdiff_t regoff_t; + +typedef struct { + regoff_t rm_so; + regoff_t rm_eo; +} regmatch_t; + +#define REG_EXTENDED 1 +#define REG_ICASE 2 +#define REG_NOSUB 4 +#define REG_NEWLINE 8 + +#define REG_NOTBOL 1 +#define REG_NOTEOL 2 + +#define REG_NOMATCH -1 + +#define RE_DUP_MAX 255 + +struct __regex_t; + +typedef int (*matcher)(void*,const char*,int ofs,struct __regex_t *t,int plus,int eflags); + +typedef struct __regex_t { + struct regex { + matcher m; + void* next; + int pieces; + int num; + struct branch *b; + } r; + int brackets,cflags; + regmatch_t *l; +} regex_t; + +int regcomp(regex_t *preg, const char *regex, int cflags) __THROW; +int regexec(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags) __THROW; +size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) __THROW; +void regfree(regex_t *preg) __THROW; + +enum __regex_errors { + REG_NOERROR, + REG_BADRPT, /* Invalid use of repetition operators such as using `*' as the first character. */ + REG_BADBR, /* Invalid use of back reference operator. */ + REG_EBRACE, /* Un-matched brace interval operators. */ + REG_EBRACK, /* Un-matched bracket list operators. */ + REG_ERANGE, /* Invalid use of the range operator, eg. the ending point of the + range occurs prior to the starting point. */ + REG_ECTYPE, /* Unknown character class name. */ + REG_ECOLLATE, /* Invalid collating element. */ + REG_EPAREN, /* Un-matched parenthesis group operators. */ + REG_ESUBREG, /* Invalid back reference to a subexpression. */ + REG_EEND, /* Non specific error. This is not defined by POSIX.2. */ + REG_EESCAPE, /* Trailing backslash. */ + REG_BADPAT, /* Invalid use of pattern operators such as group or list. */ + REG_ESIZE, /* Compiled regular expression requires a pattern buffer + larger than 64Kb. This is not defined by POSIX.2. */ + REG_ESPACE, /* regcomp ran out of space */ +}; + +#endif diff --git a/mdk-stage1/dietlibc/include/resolv.h b/mdk-stage1/dietlibc/include/resolv.h new file mode 100644 index 000000000..4e90799c2 --- /dev/null +++ b/mdk-stage1/dietlibc/include/resolv.h @@ -0,0 +1 @@ +void res_init(void); diff --git a/mdk-stage1/dietlibc/include/rpc/auth.h b/mdk-stage1/dietlibc/include/rpc/auth.h new file mode 100644 index 000000000..4aa7d21ce --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/auth.h @@ -0,0 +1,213 @@ +/* @(#)auth.h 2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * auth.h, Authentication interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The data structures are completely opaque to the client. The client + * is required to pass a AUTH * to routines that create rpc + * "sessions". + */ + +#ifndef _RPC_AUTH_H + +#define _RPC_AUTH_H 1 +#include <sys/cdefs.h> +#include <rpc/xdr.h> + +__BEGIN_DECLS + +#define MAX_AUTH_BYTES 400 +#define MAXNETNAMELEN 255 /* maximum length of network user's name */ + +/* + * Status returned from authentication check + */ +enum auth_stat { + AUTH_OK=0, + /* + * failed at remote end + */ + AUTH_BADCRED=1, /* bogus credentials (seal broken) */ + AUTH_REJECTEDCRED=2, /* client should begin new session */ + AUTH_BADVERF=3, /* bogus verifier (seal broken) */ + AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ + AUTH_TOOWEAK=5, /* rejected due to security reasons */ + /* + * failed locally + */ + AUTH_INVALIDRESP=6, /* bogus response verifier */ + AUTH_FAILED=7 /* some unknown reason */ +}; + +union des_block { + struct { + u_int32_t high; + u_int32_t low; + } key; + char c[8]; +}; +typedef union des_block des_block; +extern bool_t xdr_des_block (XDR *__xdrs, des_block *__blkp) __THROW; + +/* + * Authentication info. Opaque to client. + */ +struct opaque_auth { + enum_t oa_flavor; /* flavor of auth */ + caddr_t oa_base; /* address of more auth stuff */ + u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ +}; + +/* + * Auth handle, interface to client side authenticators. + */ +typedef struct AUTH AUTH; +struct AUTH { + struct opaque_auth ah_cred; + struct opaque_auth ah_verf; + union des_block ah_key; + struct auth_ops { + void (*ah_nextverf) (AUTH *); + int (*ah_marshal) (AUTH *, XDR *); /* nextverf & serialize */ + int (*ah_validate) (AUTH *, struct opaque_auth *); + /* validate verifier */ + int (*ah_refresh) (AUTH *); /* refresh credentials */ + void (*ah_destroy) (AUTH *); /* destroy this structure */ + } *ah_ops; + caddr_t ah_private; +}; + + +/* + * Authentication ops. + * The ops and the auth handle provide the interface to the authenticators. + * + * AUTH *auth; + * XDR *xdrs; + * struct opaque_auth verf; + */ +#define AUTH_NEXTVERF(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) +#define auth_nextverf(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) + +#define AUTH_MARSHALL(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) +#define auth_marshall(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) + +#define AUTH_VALIDATE(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) +#define auth_validate(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) + +#define AUTH_REFRESH(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) +#define auth_refresh(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) + +#define AUTH_DESTROY(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) +#define auth_destroy(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) + + +extern struct opaque_auth _null_auth; + + +/* + * These are the various implementations of client side authenticators. + */ + +/* + * Unix style authentication + * AUTH *authunix_create(machname, uid, gid, len, aup_gids) + * char *machname; + * int uid; + * int gid; + * int len; + * int *aup_gids; + */ +extern AUTH *authunix_create (char *__machname,uid_t __uid, gid_t __gid, + int __len, gid_t *__aup_gids) __THROW; +extern AUTH *authunix_create_default (void) __THROW; +extern AUTH *authnone_create (void) __THROW; +extern AUTH *authdes_create (const char *__servername, u_int __window, + struct sockaddr *__syncaddr, des_block *__ckey) + __THROW; +extern AUTH *authdes_pk_create (const char *, netobj *, u_int, + struct sockaddr *, des_block *) __THROW; + + +#define AUTH_NONE 0 /* no authentication */ +#define AUTH_NULL 0 /* backward compatibility */ +#define AUTH_SYS 1 /* unix style (uid, gids) */ +#define AUTH_UNIX AUTH_SYS +#define AUTH_SHORT 2 /* short hand unix style */ +#define AUTH_DES 3 /* des style (encrypted timestamps) */ +#define AUTH_DH AUTH_DES /* Diffie-Hellman (this is DES) */ +#define AUTH_KERB 4 /* kerberos style */ + +/* + * Netname manipulating functions + * + */ +extern int getnetname (char *) __THROW; +extern int host2netname (char *, __const char *, __const char *) __THROW; +extern int user2netname (char *, __const uid_t, __const char *) __THROW; +extern int netname2user (__const char *, uid_t *, gid_t *, int *, gid_t *) + __THROW; +extern int netname2host (__const char *, char *, __const int) __THROW; + +/* + * + * These routines interface to the keyserv daemon + * + */ +extern int key_decryptsession (char *, des_block *) __THROW; +extern int key_decryptsession_pk (char *, netobj *, des_block *) __THROW; +extern int key_encryptsession (char *, des_block *) __THROW; +extern int key_encryptsession_pk (char *, netobj *, des_block *) __THROW; +extern int key_gendes (des_block *) __THROW; +extern int key_setsecret (char *) __THROW; +extern int key_secretkey_is_set (void) __THROW; +extern int key_get_conv (char *, des_block *) __THROW; + +/* + * XDR an opaque authentication struct. + */ +extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *) __THROW; + +__END_DECLS + +#endif /* rpc/auth.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/auth_des.h b/mdk-stage1/dietlibc/include/rpc/auth_des.h new file mode 100644 index 000000000..198b299e7 --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/auth_des.h @@ -0,0 +1,112 @@ +/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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 Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _RPC_AUTH_DES_H +#define _RPC_AUTH_DES_H 1 + +#include <sys/cdefs.h> +#include <rpc/auth.h> + +__BEGIN_DECLS + +/* There are two kinds of "names": fullnames and nicknames */ +enum authdes_namekind + { + ADN_FULLNAME, + ADN_NICKNAME + }; + +/* A fullname contains the network name of the client, + a conversation key and the window */ +struct authdes_fullname + { + char *name; /* network name of client, up to MAXNETNAMELEN */ + des_block key; /* conversation key */ + uint32_t window; /* associated window */ + }; + +/* A credential */ +struct authdes_cred + { + enum authdes_namekind adc_namekind; + struct authdes_fullname adc_fullname; + uint32_t adc_nickname; + }; + +/* A timeval replacement for !32bit platforms */ +struct rpc_timeval + { + uint32_t tv_sec; /* Seconds. */ + uint32_t tv_usec; /* Microseconds. */ + }; + +/* A des authentication verifier */ +struct authdes_verf + { + union + { + struct rpc_timeval adv_ctime; /* clear time */ + des_block adv_xtime; /* crypt time */ + } + adv_time_u; + uint32_t adv_int_u; + }; + +/* des authentication verifier: client variety + + adv_timestamp is the current time. + adv_winverf is the credential window + 1. + Both are encrypted using the conversation key. */ +#define adv_timestamp adv_time_u.adv_ctime +#define adv_xtimestamp adv_time_u.adv_xtime +#define adv_winverf adv_int_u + +/* des authentication verifier: server variety + + adv_timeverf is the client's timestamp + client's window + adv_nickname is the server's nickname for the client. + adv_timeverf is encrypted using the conversation key. */ +#define adv_timeverf adv_time_u.adv_ctime +#define adv_xtimeverf adv_time_u.adv_xtime +#define adv_nickname adv_int_u + +/* Map a des credential into a unix cred. */ +extern int authdes_getucred (__const struct authdes_cred * __adc, + uid_t * __uid, gid_t * __gid, + short *__grouplen, gid_t * __groups) __THROW; + +/* Get the public key for NAME and place it in KEY. NAME can only be + up to MAXNETNAMELEN bytes long and the destination buffer KEY should + have HEXKEYBYTES + 1 bytes long to fit all characters from the key. */ +extern int getpublickey (__const char *__name, char *__key) __THROW; + +/* Get the secret key for NAME and place it in KEY. PASSWD is used to + decrypt the encrypted key stored in the database. NAME can only be + up to MAXNETNAMELEN bytes long and the destination buffer KEY + should have HEXKEYBYTES + 1 bytes long to fit all characters from + the key. */ +extern int getsecretkey (__const char *__name, char *__key, + __const char *__passwd) __THROW; + +extern int rtime (struct sockaddr_in *__addrp, struct rpc_timeval *__timep, + struct rpc_timeval *__timeout) __THROW; + +__END_DECLS + + +#endif /* rpc/auth_des.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/auth_unix.h b/mdk-stage1/dietlibc/include/rpc/auth_unix.h new file mode 100644 index 000000000..7a1bfa9f0 --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/auth_unix.h @@ -0,0 +1,90 @@ +/* @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC; from 1.8 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)auth_unix.h 1.5 86/07/16 SMI */ + +/* + * auth_unix.h, Protocol for UNIX style authentication parameters for RPC + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +/* + * The system is very weak. The client uses no encryption for it + * credentials and only sends null verifiers. The server sends backs + * null verifiers or optionally a verifier that suggests a new short hand + * for the credentials. + */ + +#ifndef _RPC_AUTH_UNIX_H +#define _RPC_AUTH_UNIX_H 1 + +#include <sys/cdefs.h> +#include <sys/types.h> +#include <rpc/types.h> +#include <rpc/auth.h> +#include <rpc/xdr.h> + +__BEGIN_DECLS + +/* The machine name is part of a credential; it may not exceed 255 bytes */ +#define MAX_MACHINE_NAME 255 + +/* gids compose part of a credential; there may not be more than 16 of them */ +#define NGRPS 16 + +/* + * Unix style credentials. + */ +struct authunix_parms + { + u_long aup_time; + char *aup_machname; + uid_t aup_uid; + gid_t aup_gid; + u_int aup_len; + gid_t *aup_gids; + }; + +extern bool_t xdr_authunix_parms (XDR *__xdrs, struct authunix_parms *__p) + __THROW; + +/* + * If a response verifier has flavor AUTH_SHORT, + * then the body of the response verifier encapsulates the following structure; + * again it is serialized in the obvious fashion. + */ +struct short_hand_verf + { + struct opaque_auth new_cred; + }; + +__END_DECLS + +#endif /* rpc/auth_unix.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/clnt.h b/mdk-stage1/dietlibc/include/rpc/clnt.h new file mode 100644 index 000000000..60b0fafdf --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/clnt.h @@ -0,0 +1,421 @@ +/* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * clnt.h - Client side remote procedure call interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_CLNT_H +#define _RPC_CLNT_H 1 + +#include <sys/cdefs.h> +#include <sys/types.h> +#include <rpc/types.h> +#include <rpc/auth.h> +#include <sys/un.h> + +__BEGIN_DECLS + +/* + * Rpc calls return an enum clnt_stat. This should be looked at more, + * since each implementation is required to live with this (implementation + * independent) list of errors. + */ +enum clnt_stat { + RPC_SUCCESS=0, /* call succeeded */ + /* + * local errors + */ + RPC_CANTENCODEARGS=1, /* can't encode arguments */ + RPC_CANTDECODERES=2, /* can't decode results */ + RPC_CANTSEND=3, /* failure in sending call */ + RPC_CANTRECV=4, /* failure in receiving result */ + RPC_TIMEDOUT=5, /* call timed out */ + /* + * remote errors + */ + RPC_VERSMISMATCH=6, /* rpc versions not compatible */ + RPC_AUTHERROR=7, /* authentication error */ + RPC_PROGUNAVAIL=8, /* program not available */ + RPC_PROGVERSMISMATCH=9, /* program version mismatched */ + RPC_PROCUNAVAIL=10, /* procedure unavailable */ + RPC_CANTDECODEARGS=11, /* decode arguments error */ + RPC_SYSTEMERROR=12, /* generic "other problem" */ + RPC_NOBROADCAST = 21, /* Broadcasting not supported */ + /* + * callrpc & clnt_create errors + */ + RPC_UNKNOWNHOST=13, /* unknown host name */ + RPC_UNKNOWNPROTO=17, /* unknown protocol */ + RPC_UNKNOWNADDR = 19, /* Remote address unknown */ + + /* + * rpcbind errors + */ + RPC_RPCBFAILURE=14, /* portmapper failed in its call */ +#define RPC_PMAPFAILURE RPC_RPCBFAILURE + RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ + RPC_N2AXLATEFAILURE = 22, /* Name to addr translation failed */ + /* + * unspecified error + */ + RPC_FAILED=16, + RPC_INTR=18, + RPC_TLIERROR=20, + RPC_UDERROR=23, + /* + * asynchronous errors + */ + RPC_INPROGRESS = 24, + RPC_STALERACHANDLE = 25 +}; + + +/* + * Error info. + */ +struct rpc_err { + enum clnt_stat re_status; + union { + int RE_errno; /* related system error */ + enum auth_stat RE_why; /* why the auth error occurred */ + struct { + u_long low; /* lowest verion supported */ + u_long high; /* highest verion supported */ + } RE_vers; + struct { /* maybe meaningful if RPC_FAILED */ + long s1; + long s2; + } RE_lb; /* life boot & debugging only */ + } ru; +#define re_errno ru.RE_errno +#define re_why ru.RE_why +#define re_vers ru.RE_vers +#define re_lb ru.RE_lb +}; + + +/* + * Client rpc handle. + * Created by individual implementations, see e.g. rpc_udp.c. + * Client is responsible for initializing auth, see e.g. auth_none.c. + */ +typedef struct CLIENT CLIENT; +struct CLIENT { + AUTH *cl_auth; /* authenticator */ + struct clnt_ops { + enum clnt_stat (*cl_call) (CLIENT *, u_long, xdrproc_t, caddr_t, xdrproc_t, + caddr_t, struct timeval); + /* call remote procedure */ + void (*cl_abort) (void); /* abort a call */ + void (*cl_geterr) (CLIENT *, struct rpc_err *); + /* get specific error code */ + bool_t (*cl_freeres) (CLIENT *, xdrproc_t, caddr_t); + /* frees results */ + void (*cl_destroy) (CLIENT *); /* destroy this structure */ + bool_t (*cl_control) (CLIENT *, int, char *); + /* the ioctl() of rpc */ + } *cl_ops; + caddr_t cl_private; /* private stuff */ +}; + + +/* + * client side rpc interface ops + * + * Parameter types are: + * + */ + +/* + * enum clnt_stat + * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) + * CLIENT *rh; + * u_long proc; + * xdrproc_t xargs; + * caddr_t argsp; + * xdrproc_t xres; + * caddr_t resp; + * struct timeval timeout; + */ +#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) +#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) + +/* + * void + * CLNT_ABORT(rh); + * CLIENT *rh; + */ +#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) +#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) + +/* + * struct rpc_err + * CLNT_GETERR(rh); + * CLIENT *rh; + */ +#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) +#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) + + +/* + * bool_t + * CLNT_FREERES(rh, xres, resp); + * CLIENT *rh; + * xdrproc_t xres; + * caddr_t resp; + */ +#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) +#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) + +/* + * bool_t + * CLNT_CONTROL(cl, request, info) + * CLIENT *cl; + * u_int request; + * char *info; + */ +#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) +#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) + +/* + * control operations that apply to all transports + * + * Note: options marked XXX are no-ops in this implementation of RPC. + * The are present in TI-RPC but can't be implemented here since they + * depend on the presence of STREAMS/TLI, which we don't have. + */ +#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ +#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ +#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ +#define CLGET_FD 6 /* get connections file descriptor */ +#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) XXX */ +#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ +#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy*/ +#define CLGET_XID 10 /* Get xid */ +#define CLSET_XID 11 /* Set xid */ +#define CLGET_VERS 12 /* Get version number */ +#define CLSET_VERS 13 /* Set version number */ +#define CLGET_PROG 14 /* Get program number */ +#define CLSET_PROG 15 /* Set program number */ +#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) XXX */ +#define CLSET_PUSH_TIMOD 17 /* push timod if not already present XXX */ +#define CLSET_POP_TIMOD 18 /* pop timod XXX */ +/* + * Connectionless only control operations + */ +#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ +#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ + +/* + * void + * CLNT_DESTROY(rh); + * CLIENT *rh; + */ +#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) +#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) + + +/* + * RPCTEST is a test program which is accessible on every rpc + * transport/port. It is used for testing, performance evaluation, + * and network administration. + */ + +#define RPCTEST_PROGRAM ((u_long)1) +#define RPCTEST_VERSION ((u_long)1) +#define RPCTEST_NULL_PROC ((u_long)2) +#define RPCTEST_NULL_BATCH_PROC ((u_long)3) + +/* + * By convention, procedure 0 takes null arguments and returns them + */ + +#define NULLPROC ((u_long)0) + +/* + * Below are the client handle creation routines for the various + * implementations of client side rpc. They can return NULL if a + * creation failure occurs. + */ + +/* + * Memory based rpc (for speed check and testing) + * CLIENT * + * clntraw_create(prog, vers) + * u_long prog; + * u_long vers; + */ +extern CLIENT *clntraw_create (__const u_long __prog, __const u_long __vers) + __THROW; + + +/* + * Generic client creation routine. Supported protocols are "udp", "tcp" and + * "unix" + * CLIENT * + * clnt_create(host, prog, vers, prot) + * char *host; -- hostname + * u_long prog; -- program number + * u_ong vers; -- version number + * char *prot; -- protocol + */ +extern CLIENT *clnt_create (__const char *__host, __const u_long __prog, + __const u_long __vers, __const char *__prot) + __THROW; + + +/* + * TCP based rpc + * CLIENT * + * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * u_long prog; + * u_long version; + * register int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +extern CLIENT *clnttcp_create (struct sockaddr_in *__raddr, u_long __prog, + u_long __version, int *__sockp, u_int __sendsz, + u_int __recvsz) __THROW; + +/* + * UDP based rpc. + * CLIENT * + * clntudp_create(raddr, program, version, wait, sockp) + * struct sockaddr_in *raddr; + * u_long program; + * u_long version; + * struct timeval wait_resend; + * int *sockp; + * + * Same as above, but you specify max packet sizes. + * CLIENT * + * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * u_long program; + * u_long version; + * struct timeval wait_resend; + * int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +extern CLIENT *clntudp_create (struct sockaddr_in *__raddr, u_long __program, + u_long __version, struct timeval __wait_resend, + int *__sockp) __THROW; +extern CLIENT *clntudp_bufcreate (struct sockaddr_in *__raddr, + u_long __program, u_long __version, + struct timeval __wait_resend, int *__sockp, + u_int __sendsz, u_int __recvsz) __THROW; + + + + +/* + * AF_UNIX based rpc + * CLIENT * + * clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) + * struct sockaddr_un *raddr; + * u_long prog; + * u_long version; + * register int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +extern CLIENT *clntunix_create (struct sockaddr_un *__raddr, u_long __program, + u_long __version, int *__sockp, + u_int __sendsz, u_int __recvsz) __THROW; + + +extern int callrpc (__const char *__host, __const u_long __prognum, + __const u_long __versnum, __const u_long __procnum, + __const xdrproc_t __inproc, __const char *__in, + __const xdrproc_t __outproc, char *__out) __THROW; +extern int _rpc_dtablesize (void) __THROW; + +/* + * Print why creation failed + */ +extern void clnt_pcreateerror (__const char *__msg) __THROW; /* stderr */ +extern char *clnt_spcreateerror(__const char *__msg) __THROW; /* string */ + +/* + * Like clnt_perror(), but is more verbose in its output + */ +extern void clnt_perrno (enum clnt_stat __num) __THROW; /* stderr */ + +/* + * Print an English error message, given the client error code + */ +extern void clnt_perror (CLIENT *__clnt, __const char *__msg) __THROW; + /* stderr */ +extern char *clnt_sperror (CLIENT *__clnt, __const char *__msg) __THROW; + /* string */ + +/* + * If a creation fails, the following allows the user to figure out why. + */ +struct rpc_createerr { + enum clnt_stat cf_stat; + struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ +}; + +extern struct rpc_createerr rpc_createerr; + + + +/* + * Copy error message to buffer. + */ +extern char *clnt_sperrno (enum clnt_stat __num) __THROW; /* string */ + +/* + * get the port number on the host for the rpc program,version and proto + */ +extern int getrpcport (__const char * __host, u_long __prognum, + u_long __versnum, u_int proto) __THROW; + +/* + * get the local host's IP address without consulting + * name service library functions + */ +extern void get_myaddress (struct sockaddr_in *) __THROW; + +#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ +#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ + +__END_DECLS + +#endif /* rpc/clnt.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/des_crypt.h b/mdk-stage1/dietlibc/include/rpc/des_crypt.h new file mode 100644 index 000000000..6a65887d3 --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/des_crypt.h @@ -0,0 +1,97 @@ +/* + * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI + * + * des_crypt.h, des library routine interface + * Copyright (C) 1986, Sun Microsystems, Inc. + */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +#ifndef __DES_CRYPT_H__ +#define __DES_CRYPT_H__ 1 + +#include <features.h> + +__BEGIN_DECLS + +#define DES_MAXDATA 8192 /* max bytes encrypted in one call */ +#define DES_DIRMASK (1 << 0) +#define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */ +#define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */ + + +#define DES_DEVMASK (1 << 1) +#define DES_HW (0*DES_DEVMASK) /* Use hardware device */ +#define DES_SW (1*DES_DEVMASK) /* Use software device */ + + +#define DESERR_NONE 0 /* succeeded */ +#define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */ +#define DESERR_HWERROR 2 /* failed, hardware/driver error */ +#define DESERR_BADPARAM 3 /* failed, bad parameter to call */ + +#define DES_FAILED(err) \ + ((err) > DESERR_NOHWDEVICE) + +/* + * cbc_crypt() + * ecb_crypt() + * + * Encrypt (or decrypt) len bytes of a buffer buf. + * The length must be a multiple of eight. + * The key should have odd parity in the low bit of each byte. + * ivec is the input vector, and is updated to the new one (cbc only). + * The mode is created by oring together the appropriate parameters. + * DESERR_NOHWDEVICE is returned if DES_HW was specified but + * there was no hardware to do it on (the data will still be + * encrypted though, in software). + */ + + +/* + * Cipher Block Chaining mode + */ +extern int cbc_crypt (char *__key, char *__buf, unsigned __len, + unsigned __mode, char *__ivec) __THROW; + +/* + * Electronic Code Book mode + */ +extern int ecb_crypt (char *__key, char *__buf, unsigned __len, + unsigned __mode) __THROW; + +/* + * Set des parity for a key. + * DES parity is odd and in the low bit of each byte + */ +extern void des_setparity (char *__key) __THROW; + +__END_DECLS + +#endif diff --git a/mdk-stage1/dietlibc/include/rpc/key_prot.h b/mdk-stage1/dietlibc/include/rpc/key_prot.h new file mode 100644 index 000000000..3e2eb7208 --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/key_prot.h @@ -0,0 +1,346 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _KEY_PROT_H_RPCGEN +#define _KEY_PROT_H_RPCGEN + +#include <rpc/rpc.h> + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if 0 +#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" +#endif +/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ + +/* + * Compiled from key_prot.x using rpcgen. + * DO NOT EDIT THIS FILE! + * This is NOT source code! + */ +#define PROOT 3 +#define HEXMODULUS "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b" +#define HEXKEYBYTES 48 +#define KEYSIZE 192 +#define KEYBYTES 24 +#define KEYCHECKSUMSIZE 16 + +enum keystatus { + KEY_SUCCESS = 0, + KEY_NOSECRET = 1, + KEY_UNKNOWN = 2, + KEY_SYSTEMERR = 3, +}; +typedef enum keystatus keystatus; +#ifdef __cplusplus +extern "C" bool_t xdr_keystatus(XDR *, keystatus*); +#elif __STDC__ +extern bool_t xdr_keystatus(XDR *, keystatus*); +#else /* Old Style C */ +bool_t xdr_keystatus(); +#endif /* Old Style C */ + + +typedef char keybuf[HEXKEYBYTES]; +#ifdef __cplusplus +extern "C" bool_t xdr_keybuf(XDR *, keybuf); +#elif __STDC__ +extern bool_t xdr_keybuf(XDR *, keybuf); +#else /* Old Style C */ +bool_t xdr_keybuf(); +#endif /* Old Style C */ + + +typedef char *netnamestr; +#ifdef __cplusplus +extern "C" bool_t xdr_netnamestr(XDR *, netnamestr*); +#elif __STDC__ +extern bool_t xdr_netnamestr(XDR *, netnamestr*); +#else /* Old Style C */ +bool_t xdr_netnamestr(); +#endif /* Old Style C */ + + +struct cryptkeyarg { + netnamestr remotename; + des_block deskey; +}; +typedef struct cryptkeyarg cryptkeyarg; +#ifdef __cplusplus +extern "C" bool_t xdr_cryptkeyarg(XDR *, cryptkeyarg*); +#elif __STDC__ +extern bool_t xdr_cryptkeyarg(XDR *, cryptkeyarg*); +#else /* Old Style C */ +bool_t xdr_cryptkeyarg(); +#endif /* Old Style C */ + + +struct cryptkeyarg2 { + netnamestr remotename; + netobj remotekey; + des_block deskey; +}; +typedef struct cryptkeyarg2 cryptkeyarg2; +#ifdef __cplusplus +extern "C" bool_t xdr_cryptkeyarg2(XDR *, cryptkeyarg2*); +#elif __STDC__ +extern bool_t xdr_cryptkeyarg2(XDR *, cryptkeyarg2*); +#else /* Old Style C */ +bool_t xdr_cryptkeyarg2(); +#endif /* Old Style C */ + + +struct cryptkeyres { + keystatus status; + union { + des_block deskey; + } cryptkeyres_u; +}; +typedef struct cryptkeyres cryptkeyres; +#ifdef __cplusplus +extern "C" bool_t xdr_cryptkeyres(XDR *, cryptkeyres*); +#elif __STDC__ +extern bool_t xdr_cryptkeyres(XDR *, cryptkeyres*); +#else /* Old Style C */ +bool_t xdr_cryptkeyres(); +#endif /* Old Style C */ + +#define MAXGIDS 16 + +struct unixcred { + u_int uid; + u_int gid; + struct { + u_int gids_len; + u_int *gids_val; + } gids; +}; +typedef struct unixcred unixcred; +#ifdef __cplusplus +extern "C" bool_t xdr_unixcred(XDR *, unixcred*); +#elif __STDC__ +extern bool_t xdr_unixcred(XDR *, unixcred*); +#else /* Old Style C */ +bool_t xdr_unixcred(); +#endif /* Old Style C */ + + +struct getcredres { + keystatus status; + union { + unixcred cred; + } getcredres_u; +}; +typedef struct getcredres getcredres; +#ifdef __cplusplus +extern "C" bool_t xdr_getcredres(XDR *, getcredres*); +#elif __STDC__ +extern bool_t xdr_getcredres(XDR *, getcredres*); +#else /* Old Style C */ +bool_t xdr_getcredres(); +#endif /* Old Style C */ + + +struct key_netstarg { + keybuf st_priv_key; + keybuf st_pub_key; + netnamestr st_netname; +}; +typedef struct key_netstarg key_netstarg; +#ifdef __cplusplus +extern "C" bool_t xdr_key_netstarg(XDR *, key_netstarg*); +#elif __STDC__ +extern bool_t xdr_key_netstarg(XDR *, key_netstarg*); +#else /* Old Style C */ +bool_t xdr_key_netstarg(); +#endif /* Old Style C */ + + +struct key_netstres { + keystatus status; + union { + key_netstarg knet; + } key_netstres_u; +}; +typedef struct key_netstres key_netstres; +#ifdef __cplusplus +extern "C" bool_t xdr_key_netstres(XDR *, key_netstres*); +#elif __STDC__ +extern bool_t xdr_key_netstres(XDR *, key_netstres*); +#else /* Old Style C */ +bool_t xdr_key_netstres(); +#endif /* Old Style C */ + + +#ifndef opaque +#define opaque char +#endif + + +#define KEY_PROG ((u_long)100029) +#define KEY_VERS ((u_long)1) + +#ifdef __cplusplus +#define KEY_SET ((u_long)1) +extern "C" keystatus * key_set_1(opaque *, CLIENT *); +extern "C" keystatus * key_set_1_svc(opaque *, struct svc_req *); +#define KEY_ENCRYPT ((u_long)2) +extern "C" cryptkeyres * key_encrypt_1(cryptkeyarg *, CLIENT *); +extern "C" cryptkeyres * key_encrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_DECRYPT ((u_long)3) +extern "C" cryptkeyres * key_decrypt_1(cryptkeyarg *, CLIENT *); +extern "C" cryptkeyres * key_decrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_GEN ((u_long)4) +extern "C" des_block * key_gen_1(void *, CLIENT *); +extern "C" des_block * key_gen_1_svc(void *, struct svc_req *); +#define KEY_GETCRED ((u_long)5) +extern "C" getcredres * key_getcred_1(netnamestr *, CLIENT *); +extern "C" getcredres * key_getcred_1_svc(netnamestr *, struct svc_req *); + +#elif __STDC__ +#define KEY_SET ((u_long)1) +extern keystatus * key_set_1(opaque *, CLIENT *); +extern keystatus * key_set_1_svc(opaque *, struct svc_req *); +#define KEY_ENCRYPT ((u_long)2) +extern cryptkeyres * key_encrypt_1(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_encrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_DECRYPT ((u_long)3) +extern cryptkeyres * key_decrypt_1(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_decrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_GEN ((u_long)4) +extern des_block * key_gen_1(void *, CLIENT *); +extern des_block * key_gen_1_svc(void *, struct svc_req *); +#define KEY_GETCRED ((u_long)5) +extern getcredres * key_getcred_1(netnamestr *, CLIENT *); +extern getcredres * key_getcred_1_svc(netnamestr *, struct svc_req *); + +#else /* Old Style C */ +#define KEY_SET ((u_long)1) +extern keystatus * key_set_1(); +extern keystatus * key_set_1_svc(); +#define KEY_ENCRYPT ((u_long)2) +extern cryptkeyres * key_encrypt_1(); +extern cryptkeyres * key_encrypt_1_svc(); +#define KEY_DECRYPT ((u_long)3) +extern cryptkeyres * key_decrypt_1(); +extern cryptkeyres * key_decrypt_1_svc(); +#define KEY_GEN ((u_long)4) +extern des_block * key_gen_1(); +extern des_block * key_gen_1_svc(); +#define KEY_GETCRED ((u_long)5) +extern getcredres * key_getcred_1(); +extern getcredres * key_getcred_1_svc(); +#endif /* Old Style C */ +#define KEY_VERS2 ((u_long)2) + +#ifdef __cplusplus +extern "C" keystatus * key_set_2(opaque *, CLIENT *); +extern "C" keystatus * key_set_2_svc(opaque *, struct svc_req *); +extern "C" cryptkeyres * key_encrypt_2(cryptkeyarg *, CLIENT *); +extern "C" cryptkeyres * key_encrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern "C" cryptkeyres * key_decrypt_2(cryptkeyarg *, CLIENT *); +extern "C" cryptkeyres * key_decrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern "C" des_block * key_gen_2(void *, CLIENT *); +extern "C" des_block * key_gen_2_svc(void *, struct svc_req *); +extern "C" getcredres * key_getcred_2(netnamestr *, CLIENT *); +extern "C" getcredres * key_getcred_2_svc(netnamestr *, struct svc_req *); +#define KEY_ENCRYPT_PK ((u_long)6) +extern "C" cryptkeyres * key_encrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern "C" cryptkeyres * key_encrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_DECRYPT_PK ((u_long)7) +extern "C" cryptkeyres * key_decrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern "C" cryptkeyres * key_decrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_NET_PUT ((u_long)8) +extern "C" keystatus * key_net_put_2(key_netstarg *, CLIENT *); +extern "C" keystatus * key_net_put_2_svc(key_netstarg *, struct svc_req *); +#define KEY_NET_GET ((u_long)9) +extern "C" key_netstres * key_net_get_2(void *, CLIENT *); +extern "C" key_netstres * key_net_get_2_svc(void *, struct svc_req *); +#define KEY_GET_CONV ((u_long)10) +extern "C" cryptkeyres * key_get_conv_2(opaque *, CLIENT *); +extern "C" cryptkeyres * key_get_conv_2_svc(opaque *, struct svc_req *); + +#elif __STDC__ +extern keystatus * key_set_2(opaque *, CLIENT *); +extern keystatus * key_set_2_svc(opaque *, struct svc_req *); +extern cryptkeyres * key_encrypt_2(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_encrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern cryptkeyres * key_decrypt_2(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_decrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern des_block * key_gen_2(void *, CLIENT *); +extern des_block * key_gen_2_svc(void *, struct svc_req *); +extern getcredres * key_getcred_2(netnamestr *, CLIENT *); +extern getcredres * key_getcred_2_svc(netnamestr *, struct svc_req *); +#define KEY_ENCRYPT_PK ((u_long)6) +extern cryptkeyres * key_encrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern cryptkeyres * key_encrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_DECRYPT_PK ((u_long)7) +extern cryptkeyres * key_decrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern cryptkeyres * key_decrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_NET_PUT ((u_long)8) +extern keystatus * key_net_put_2(key_netstarg *, CLIENT *); +extern keystatus * key_net_put_2_svc(key_netstarg *, struct svc_req *); +#define KEY_NET_GET ((u_long)9) +extern key_netstres * key_net_get_2(void *, CLIENT *); +extern key_netstres * key_net_get_2_svc(void *, struct svc_req *); +#define KEY_GET_CONV ((u_long)10) +extern cryptkeyres * key_get_conv_2(opaque *, CLIENT *); +extern cryptkeyres * key_get_conv_2_svc(opaque *, struct svc_req *); + +#else /* Old Style C */ +extern keystatus * key_set_2(); +extern keystatus * key_set_2_svc(); +extern cryptkeyres * key_encrypt_2(); +extern cryptkeyres * key_encrypt_2_svc(); +extern cryptkeyres * key_decrypt_2(); +extern cryptkeyres * key_decrypt_2_svc(); +extern des_block * key_gen_2(); +extern des_block * key_gen_2_svc(); +extern getcredres * key_getcred_2(); +extern getcredres * key_getcred_2_svc(); +#define KEY_ENCRYPT_PK ((u_long)6) +extern cryptkeyres * key_encrypt_pk_2(); +extern cryptkeyres * key_encrypt_pk_2_svc(); +#define KEY_DECRYPT_PK ((u_long)7) +extern cryptkeyres * key_decrypt_pk_2(); +extern cryptkeyres * key_decrypt_pk_2_svc(); +#define KEY_NET_PUT ((u_long)8) +extern keystatus * key_net_put_2(); +extern keystatus * key_net_put_2_svc(); +#define KEY_NET_GET ((u_long)9) +extern key_netstres * key_net_get_2(); +extern key_netstres * key_net_get_2_svc(); +#define KEY_GET_CONV ((u_long)10) +extern cryptkeyres * key_get_conv_2(); +extern cryptkeyres * key_get_conv_2_svc(); +#endif /* Old Style C */ + +#endif /* !_KEY_PROT_H_RPCGEN */ diff --git a/mdk-stage1/dietlibc/include/rpc/netdb.h b/mdk-stage1/dietlibc/include/rpc/netdb.h new file mode 100644 index 000000000..da4bddfc4 --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/netdb.h @@ -0,0 +1,74 @@ +/* @(#)netdb.h 2.1 88/07/29 3.9 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)rpc.h 1.8 87/07/24 SMI */ + +/* Cleaned up for GNU C library roland@gnu.ai.mit.edu: + added multiple inclusion protection and use of <sys/cdefs.h>. + In GNU this file is #include'd by <netdb.h>. */ + +#ifndef _RPC_NETDB_H +#define _RPC_NETDB_H 1 + +#include <sys/cdefs.h> + +#define __need_size_t +#include <stddef.h> + +__BEGIN_DECLS + +struct rpcent +{ + char *r_name; /* Name of server for this rpc program. */ + char **r_aliases; /* Alias list. */ + int r_number; /* RPC program number. */ +}; + +extern void setrpcent (int __stayopen) __THROW; +extern void endrpcent (void) __THROW; +extern struct rpcent *getrpcbyname (__const char *__name) __THROW; +extern struct rpcent *getrpcbynumber (int __number) __THROW; +extern struct rpcent *getrpcent (void) __THROW; + +#ifdef __USE_MISC +extern int getrpcbyname_r (__const char *__name, struct rpcent *__result_buf, + char *__buffer, size_t __buflen, + struct rpcent **__result) __THROW; + +extern int getrpcbynumber_r (int __number, struct rpcent *__result_buf, + char *__buffer, size_t __buflen, + struct rpcent **__result) __THROW; + +extern int getrpcent_r (struct rpcent *__result_buf, char *__buffer, + size_t __buflen, struct rpcent **__result) __THROW; +#endif + +__END_DECLS + +#endif /* rpc/netdb.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/pmap_clnt.h b/mdk-stage1/dietlibc/include/rpc/pmap_clnt.h new file mode 100644 index 000000000..68bc8d8ec --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/pmap_clnt.h @@ -0,0 +1,98 @@ +/* @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.11 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * pmap_clnt.h + * Supplies C routines to get to portmap services. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_PMAP_CLNT_H +#define _RPC_PMAP_CLNT_H 1 + +#include <sys/cdefs.h> +#include <rpc/types.h> +#include <rpc/xdr.h> +#include <rpc/clnt.h> + +__BEGIN_DECLS + +typedef bool_t (*resultproc_t) (caddr_t resp, struct sockaddr_in *raddr); + +/* + * Usage: + * success = pmap_set(program, version, protocol, port); + * success = pmap_unset(program, version); + * port = pmap_getport(address, program, version, protocol); + * head = pmap_getmaps(address); + * clnt_stat = pmap_rmtcall(address, program, version, procedure, + * xdrargs, argsp, xdrres, resp, tout, port_ptr) + * (works for udp only.) + * clnt_stat = clnt_broadcast(program, version, procedure, + * xdrargs, argsp, xdrres, resp, eachresult) + * (like pmap_rmtcall, except the call is broadcasted to all + * locally connected nets. For each valid response received, + * the procedure eachresult is called. Its form is: + * done = eachresult(resp, raddr) + * bool_t done; + * caddr_t resp; + * struct sockaddr_in raddr; + * where resp points to the results of the call and raddr is the + * address if the responder to the broadcast. + */ + +extern bool_t pmap_set (__const u_long __program, __const u_long __vers, + int __protocol, u_short __port) __THROW; +extern bool_t pmap_unset (__const u_long __program, __const u_long __vers) + __THROW; +extern struct pmaplist *pmap_getmaps (struct sockaddr_in *__address) __THROW; +extern enum clnt_stat pmap_rmtcall (struct sockaddr_in *__addr, + __const u_long __prog, + __const u_long __vers, + __const u_long __proc, + xdrproc_t __xdrargs, + caddr_t __argsp, xdrproc_t __xdrres, + caddr_t __resp, struct timeval __tout, + u_long *__port_ptr) __THROW; +extern enum clnt_stat clnt_broadcast (__const u_long __prog, + __const u_long __vers, + __const u_long __proc, xdrproc_t __xargs, + caddr_t __argsp, xdrproc_t __xresults, + caddr_t __resultsp, + resultproc_t __eachresult) __THROW; +extern u_short pmap_getport (struct sockaddr_in *__address, + __const u_long __program, + __const u_long __version, u_int __protocol) + __THROW; + +__END_DECLS + +#endif /* rpc/pmap_clnt.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/pmap_prot.h b/mdk-stage1/dietlibc/include/rpc/pmap_prot.h new file mode 100644 index 000000000..fd7fb8e7e --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/pmap_prot.h @@ -0,0 +1,108 @@ +/* @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC; from 1.14 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * pmap_prot.h + * Protocol for the local binder service, or pmap. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_PMAP_PROT_H +#define _RPC_PMAP_PROT_H 1 + +#include <sys/cdefs.h> + +#include <rpc/xdr.h> + +__BEGIN_DECLS + +/* The following procedures are supported by the protocol: + * + * PMAPPROC_NULL() returns () + * takes nothing, returns nothing + * + * PMAPPROC_SET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Registers the tuple + * [prog, vers, prot, port]. + * + * PMAPPROC_UNSET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Un-registers pair + * [prog, vers]. prot and port are ignored. + * + * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). + * 0 is failure. Otherwise returns the port number where the pair + * [prog, vers] is registered. It may lie! + * + * PMAPPROC_DUMP() RETURNS (struct pmaplist *) + * + * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) + * RETURNS (port, string<>); + * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); + * Calls the procedure on the local machine. If it is not registered, + * this procedure is quite; ie it does not return error information!!! + * This procedure only is supported on rpc/udp and calls via + * rpc/udp. This routine only passes null authentication parameters. + * This file has no interface to xdr routines for PMAPPROC_CALLIT. + * + * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. + */ + +#define PMAPPORT ((u_short)111) +#define PMAPPROG ((u_long)100000) +#define PMAPVERS ((u_long)2) +#define PMAPVERS_PROTO ((u_long)2) +#define PMAPVERS_ORIG ((u_long)1) +#define PMAPPROC_NULL ((u_long)0) +#define PMAPPROC_SET ((u_long)1) +#define PMAPPROC_UNSET ((u_long)2) +#define PMAPPROC_GETPORT ((u_long)3) +#define PMAPPROC_DUMP ((u_long)4) +#define PMAPPROC_CALLIT ((u_long)5) + +struct pmap { + long unsigned pm_prog; + long unsigned pm_vers; + long unsigned pm_prot; + long unsigned pm_port; +}; + +extern bool_t xdr_pmap (XDR *__xdrs, struct pmap *__regs) __THROW; + +struct pmaplist { + struct pmap pml_map; + struct pmaplist *pml_next; +}; + +extern bool_t xdr_pmaplist (XDR *__xdrs, struct pmaplist **__rp) __THROW; + +__END_DECLS + +#endif /* rpc/pmap_prot.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/pmap_rmt.h b/mdk-stage1/dietlibc/include/rpc/pmap_rmt.h new file mode 100644 index 000000000..160f998ca --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/pmap_rmt.h @@ -0,0 +1,68 @@ +/* @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC; from 1.2 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Structures and XDR routines for parameters to and replies from + * the portmapper remote-call-service. + * + * Copyright (C) 1986, Sun Microsystems, Inc. + */ + +#ifndef _RPC_PMAP_RMT_H +#define _RPC_PMAP_RMT_H 1 + +#include <sys/cdefs.h> +#include <sys/types.h> +#include <rpc/types.h> +#include <rpc/xdr.h> + +__BEGIN_DECLS + +struct rmtcallargs { + u_long prog, vers, proc, arglen; + caddr_t args_ptr; + xdrproc_t xdr_args; +}; + +extern bool_t xdr_rmtcall_args (XDR *__xdrs, struct rmtcallargs *__crp) + __THROW; + +struct rmtcallres { + u_long *port_ptr; + u_long resultslen; + caddr_t results_ptr; + xdrproc_t xdr_results; +}; + +extern bool_t xdr_rmtcallres (XDR *__xdrs, struct rmtcallres *__crp) __THROW; + +__END_DECLS + +#endif /* rpc/pmap_rmt.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/rpc.h b/mdk-stage1/dietlibc/include/rpc/rpc.h new file mode 100644 index 000000000..20b341d74 --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/rpc.h @@ -0,0 +1,72 @@ +/* @(#)rpc.h 2.3 88/08/10 4.0 RPCSRC; from 1.9 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * rpc.h, Just includes the billions of rpc header files necessary to + * do remote procedure calling. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_RPC_H +#define _RPC_RPC_H 1 + +#include <rpc/types.h> /* some typedefs */ +#include <netinet/in.h> + +/* external data representation interfaces */ +#include <rpc/xdr.h> /* generic (de)serializer */ + +/* Client side only authentication */ +#include <rpc/auth.h> /* generic authenticator (client side) */ + +/* Client side (mostly) remote procedure call */ +#include <rpc/clnt.h> /* generic rpc stuff */ + +/* semi-private protocol headers */ +#include <rpc/rpc_msg.h> /* protocol for rpc messages */ +#include <rpc/auth_unix.h> /* protocol for unix style cred */ +#include <rpc/auth_des.h> /* protocol for des style cred */ + +/* Server side only remote procedure callee */ +#include <rpc/svc.h> /* service manager and multiplexer */ +#include <rpc/svc_auth.h> /* service side authenticator */ + +/* + * COMMENT OUT THE NEXT INCLUDE IF RUNNING ON SUN OS OR ON A VERSION + * OF UNIX BASED ON NFSSRC. These systems will already have the structures + * defined by <rpc/netdb.h> included in <netdb.h>. + */ +/* routines for parsing /etc/rpc */ +#include <rpc/netdb.h> /* structures and routines to parse /etc/rpc */ + +int bindresvport(int sd, struct sockaddr_in* sin) __THROW; + +#endif /* rpc/rpc.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/rpc_des.h b/mdk-stage1/dietlibc/include/rpc/rpc_des.h new file mode 100644 index 000000000..0f36d1697 --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/rpc_des.h @@ -0,0 +1,72 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Generic DES driver interface + * Keep this file hardware independent! + * Copyright (c) 1986 by Sun Microsystems, Inc. + */ + +#ifndef _DES_H +#define _DES_H + +#include <sys/types.h> + +#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */ +#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */ + +enum desdir + { + ENCRYPT, DECRYPT + }; +enum desmode + { + CBC, ECB + }; + +/* + * parameters to ioctl call + */ +struct desparams + { + u_char des_key[8]; /* key (with low bit parity) */ + enum desdir des_dir; /* direction */ + enum desmode des_mode; /* mode */ + u_char des_ivec[8]; /* input vector */ + unsigned des_len; /* number of bytes to crypt */ + union + { + u_char UDES_data[DES_QUICKLEN]; + u_char *UDES_buf; + } + UDES; +#define des_data UDES.UDES_data /* direct data here if quick */ +#define des_buf UDES.UDES_buf /* otherwise, pointer to data */ + }; + +#endif diff --git a/mdk-stage1/dietlibc/include/rpc/rpc_msg.h b/mdk-stage1/dietlibc/include/rpc/rpc_msg.h new file mode 100644 index 000000000..636d60ea9 --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/rpc_msg.h @@ -0,0 +1,202 @@ +/* @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)rpc_msg.h 1.7 86/07/16 SMI */ + +#ifndef _RPC_MSG_H +#define _RPC_MSG_H 1 + +#include <sys/cdefs.h> + +#include <rpc/xdr.h> +#include <rpc/clnt.h> + +/* + * rpc_msg.h + * rpc message definition + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#define RPC_MSG_VERSION ((u_long) 2) +#define RPC_SERVICE_PORT ((u_short) 2048) + +__BEGIN_DECLS + +/* + * Bottom up definition of an rpc message. + * NOTE: call and reply use the same overall struct but + * different parts of unions within it. + */ + +enum msg_type { + CALL=0, + REPLY=1 +}; + +enum reply_stat { + MSG_ACCEPTED=0, + MSG_DENIED=1 +}; + +enum accept_stat { + SUCCESS=0, + PROG_UNAVAIL=1, + PROG_MISMATCH=2, + PROC_UNAVAIL=3, + GARBAGE_ARGS=4, + SYSTEM_ERR=5 +}; + +enum reject_stat { + RPC_MISMATCH=0, + AUTH_ERROR=1 +}; + +/* + * Reply part of an rpc exchange + */ + +/* + * Reply to an rpc request that was accepted by the server. + * Note: there could be an error even though the request was + * accepted. + */ +struct accepted_reply { + struct opaque_auth ar_verf; + enum accept_stat ar_stat; + union { + struct { + u_long low; + u_long high; + } AR_versions; + struct { + caddr_t where; + xdrproc_t proc; + } AR_results; + /* and many other null cases */ + } ru; +#define ar_results ru.AR_results +#define ar_vers ru.AR_versions +}; + +/* + * Reply to an rpc request that was rejected by the server. + */ +struct rejected_reply { + enum reject_stat rj_stat; + union { + struct { + u_long low; + u_long high; + } RJ_versions; + enum auth_stat RJ_why; /* why authentication did not work */ + } ru; +#define rj_vers ru.RJ_versions +#define rj_why ru.RJ_why +}; + +/* + * Body of a reply to an rpc request. + */ +struct reply_body { + enum reply_stat rp_stat; + union { + struct accepted_reply RP_ar; + struct rejected_reply RP_dr; + } ru; +#define rp_acpt ru.RP_ar +#define rp_rjct ru.RP_dr +}; + +/* + * Body of an rpc request call. + */ +struct call_body { + u_long cb_rpcvers; /* must be equal to two */ + u_long cb_prog; + u_long cb_vers; + u_long cb_proc; + struct opaque_auth cb_cred; + struct opaque_auth cb_verf; /* protocol specific - provided by client */ +}; + +/* + * The rpc message + */ +struct rpc_msg { + u_long rm_xid; + enum msg_type rm_direction; + union { + struct call_body RM_cmb; + struct reply_body RM_rmb; + } ru; +#define rm_call ru.RM_cmb +#define rm_reply ru.RM_rmb +}; +#define acpted_rply ru.RM_rmb.ru.RP_ar +#define rjcted_rply ru.RM_rmb.ru.RP_dr + + +/* + * XDR routine to handle a rpc message. + * xdr_callmsg(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW; + +/* + * XDR routine to pre-serialize the static part of a rpc message. + * xdr_callhdr(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW; + +/* + * XDR routine to handle a rpc reply. + * xdr_replymsg(xdrs, rmsg) + * XDR *xdrs; + * struct rpc_msg *rmsg; + */ +extern bool_t xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg) __THROW; + +/* + * Fills in the error part of a reply message. + * _seterr_reply(msg, error) + * struct rpc_msg *msg; + * struct rpc_err *error; + */ +extern void _seterr_reply (struct rpc_msg *__msg, struct rpc_err *__error) + __THROW; + +__END_DECLS + +#endif /* rpc/rpc_msg.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/svc.h b/mdk-stage1/dietlibc/include/rpc/svc.h new file mode 100644 index 000000000..27c997dde --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/svc.h @@ -0,0 +1,316 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * svc.h, Server-side remote procedure call interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_SVC_H +#define _RPC_SVC_H 1 + +#include <sys/cdefs.h> +#include <rpc/rpc_msg.h> + +__BEGIN_DECLS + +/* + * This interface must manage two items concerning remote procedure calling: + * + * 1) An arbitrary number of transport connections upon which rpc requests + * are received. The two most notable transports are TCP and UDP; they are + * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; + * they in turn call xprt_register and xprt_unregister. + * + * 2) An arbitrary number of locally registered services. Services are + * described by the following four data: program number, version number, + * "service dispatch" function, a transport handle, and a boolean that + * indicates whether or not the exported program should be registered with a + * local binder service; if true the program's number and version and the + * port number from the transport handle are registered with the binder. + * These data are registered with the rpc svc system via svc_register. + * + * A service's dispatch function is called whenever an rpc request comes in + * on a transport. The request's program and version numbers must match + * those of the registered service. The dispatch function is passed two + * parameters, struct svc_req * and SVCXPRT *, defined below. + */ + +enum xprt_stat { + XPRT_DIED, + XPRT_MOREREQS, + XPRT_IDLE +}; + +/* + * Server side transport handle + */ +typedef struct SVCXPRT SVCXPRT; +struct SVCXPRT { + int xp_sock; + u_short xp_port; /* associated port number */ + const struct xp_ops { + bool_t (*xp_recv) (SVCXPRT *__xprt, struct rpc_msg *__msg); + /* receive incoming requests */ + enum xprt_stat (*xp_stat) (SVCXPRT *__xprt); + /* get transport status */ + bool_t (*xp_getargs) (SVCXPRT *__xprt, xdrproc_t __xdr_args, + caddr_t args_ptr); /* get arguments */ + bool_t (*xp_reply) (SVCXPRT *__xprt, struct rpc_msg *__msg); + /* send reply */ + bool_t (*xp_freeargs) (SVCXPRT *__xprt, xdrproc_t __xdr_args, + caddr_t args_ptr); + /* free mem allocated for args */ + void (*xp_destroy) (SVCXPRT *__xprt); + /* destroy this struct */ + } *xp_ops; + int xp_addrlen; /* length of remote address */ + struct sockaddr_in xp_raddr; /* remote address */ + struct opaque_auth xp_verf; /* raw response verifier */ + caddr_t xp_p1; /* private */ + caddr_t xp_p2; /* private */ + char xp_pad [256]; /* padding, internal use */ +}; + +/* + * Approved way of getting address of caller + */ +#define svc_getcaller(x) (&(x)->xp_raddr) + +/* + * Operations defined on an SVCXPRT handle + * + * SVCXPRT *xprt; + * struct rpc_msg *msg; + * xdrproc_t xargs; + * caddr_t argsp; + */ +#define SVC_RECV(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) +#define svc_recv(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) + +#define SVC_STAT(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) +#define svc_stat(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) + +#define SVC_GETARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) +#define svc_getargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) + +#define SVC_REPLY(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) +#define svc_reply(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) + +#define SVC_FREEARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) +#define svc_freeargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) + +#define SVC_DESTROY(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) +#define svc_destroy(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) + + +/* + * Service request + */ +struct svc_req { + rpcprog_t rq_prog; /* service program number */ + rpcvers_t rq_vers; /* service protocol version */ + rpcproc_t rq_proc; /* the desired procedure */ + struct opaque_auth rq_cred; /* raw creds from the wire */ + caddr_t rq_clntcred; /* read only cooked cred */ + SVCXPRT *rq_xprt; /* associated transport */ +}; + +#ifndef __DISPATCH_FN_T +#define __DISPATCH_FN_T +typedef void (*__dispatch_fn_t) (struct svc_req*, SVCXPRT*); +#endif + +/* + * Service registration + * + * svc_register(xprt, prog, vers, dispatch, protocol) + * SVCXPRT *xprt; + * rpcprog_t prog; + * rpcvers_t vers; + * void (*dispatch)(struct svc_req*, SVCXPRT*); + * rpcprot_t protocol; like TCP or UDP, zero means do not register + */ +extern bool_t svc_register (SVCXPRT *__xprt, rpcprog_t __prog, + rpcvers_t __vers, __dispatch_fn_t __dispatch, + rpcprot_t __protocol) __THROW; + +/* + * Service un-registration + * + * svc_unregister(prog, vers) + * rpcprog_t prog; + * rpcvers_t vers; + */ +extern void svc_unregister (rpcprog_t __prog, rpcvers_t __vers) __THROW; + +/* + * Transport registration. + * + * xprt_register(xprt) + * SVCXPRT *xprt; + */ +extern void xprt_register (SVCXPRT *__xprt) __THROW; + +/* + * Transport un-register + * + * xprt_unregister(xprt) + * SVCXPRT *xprt; + */ +extern void xprt_unregister (SVCXPRT *__xprt) __THROW; + + +/* + * When the service routine is called, it must first check to see if it + * knows about the procedure; if not, it should call svcerr_noproc + * and return. If so, it should deserialize its arguments via + * SVC_GETARGS (defined above). If the deserialization does not work, + * svcerr_decode should be called followed by a return. Successful + * decoding of the arguments should be followed the execution of the + * procedure's code and a call to svc_sendreply. + * + * Also, if the service refuses to execute the procedure due to too- + * weak authentication parameters, svcerr_weakauth should be called. + * Note: do not confuse access-control failure with weak authentication! + * + * NB: In pure implementations of rpc, the caller always waits for a reply + * msg. This message is sent when svc_sendreply is called. + * Therefore pure service implementations should always call + * svc_sendreply even if the function logically returns void; use + * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows + * for the abuse of pure rpc via batched calling or pipelining. In the + * case of a batched call, svc_sendreply should NOT be called since + * this would send a return message, which is what batching tries to avoid. + * It is the service/protocol writer's responsibility to know which calls are + * batched and which are not. Warning: responding to batch calls may + * deadlock the caller and server processes! + */ + +extern bool_t svc_sendreply (SVCXPRT *xprt, xdrproc_t __xdr_results, + caddr_t __xdr_location) __THROW; + +extern void svcerr_decode (SVCXPRT *__xprt) __THROW; + +extern void svcerr_weakauth (SVCXPRT *__xprt) __THROW; + +extern void svcerr_noproc (SVCXPRT *__xprt) __THROW; + +extern void svcerr_progvers (SVCXPRT *__xprt, rpcvers_t __low_vers, + rpcvers_t __high_vers) __THROW; + +extern void svcerr_auth (SVCXPRT *__xprt, enum auth_stat __why) __THROW; + +extern void svcerr_noprog (SVCXPRT *__xprt) __THROW; + +extern void svcerr_systemerr (SVCXPRT *__xprt) __THROW; + +/* + * Lowest level dispatching -OR- who owns this process anyway. + * Somebody has to wait for incoming requests and then call the correct + * service routine. The routine svc_run does infinite waiting; i.e., + * svc_run never returns. + * Since another (coexistent) package may wish to selectively wait for + * incoming calls or other events outside of the rpc architecture, the + * routine svc_getreq is provided. It must be passed readfds, the + * "in-place" results of a select system call (see select, section 2). + */ + +/* + * Global keeper of rpc service descriptors in use + * dynamic; must be inspected before each call to select + */ + +extern struct pollfd *svc_pollfd; +extern int svc_max_pollfd; +extern fd_set svc_fdset; +#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ + +/* + * a small program implemented by the svc_rpc implementation itself; + * also see clnt.h for protocol numbers. + */ +extern void svc_getreq (int __rdfds) __THROW; +extern void svc_getreq_common (const int __fd) __THROW; +extern void svc_getreqset (fd_set *__readfds) __THROW; +extern void svc_getreq_poll (struct pollfd *, const int) __THROW; +extern void svc_exit (void) __THROW; +extern void svc_run (void) __THROW; + +/* + * Socket to use on svcxxx_create call to get default socket + */ +#define RPC_ANYSOCK -1 + +/* + * These are the existing service side transport implementations + */ + +/* + * Memory based rpc for testing and timing. + */ +extern SVCXPRT *svcraw_create (void) __THROW; + +/* + * Udp based rpc. + */ +extern SVCXPRT *svcudp_create (int __sock) __THROW; +extern SVCXPRT *svcudp_bufcreate (int __sock, u_int __sendsz, u_int __recvsz) + __THROW; + +/* + * Tcp based rpc. + */ +extern SVCXPRT *svctcp_create (int __sock, u_int __sendsize, u_int __recvsize) + __THROW; + + +/* + * Unix based rpc. + */ +extern SVCXPRT *svcunix_create (int __sock, u_int __sendsize, u_int __recvsize, + char *__path) __THROW; + + +__END_DECLS + +#endif /* rpc/svc.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/svc_auth.h b/mdk-stage1/dietlibc/include/rpc/svc_auth.h new file mode 100644 index 000000000..cd4b8da29 --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/svc_auth.h @@ -0,0 +1,54 @@ +/* @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)svc_auth.h 1.6 86/07/16 SMI */ + +/* + * svc_auth.h, Service side of rpc authentication. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_SVC_AUTH_H +#define _RPC_SVC_AUTH_H 1 + +#include <sys/cdefs.h> +#include <rpc/svc.h> + +__BEGIN_DECLS + +/* + * Server side authenticator + */ +extern enum auth_stat _authenticate (struct svc_req *__rqst, + struct rpc_msg *__msg) __THROW; + +__END_DECLS + +#endif /* rpc/svc_auth.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/types.h b/mdk-stage1/dietlibc/include/rpc/types.h new file mode 100644 index 000000000..e2e8402be --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/types.h @@ -0,0 +1,78 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* fixincludes should not add extern "C" to this file */ +/* + * Rpc additions to <sys/types.h> + */ +#ifndef _RPC_TYPES_H +#define _RPC_TYPES_H 1 + +typedef int bool_t; +typedef int enum_t; +/* This needs to be changed to uint32_t in the future */ +typedef unsigned long rpcprog_t; +typedef unsigned long rpcvers_t; +typedef unsigned long rpcproc_t; +typedef unsigned long rpcprot_t; +typedef unsigned long rpcport_t; + +#define __dontcare__ -1 + +#ifndef FALSE +# define FALSE (0) +#endif + +#ifndef TRUE +# define TRUE (1) +#endif + +#ifndef NULL +# define NULL 0 +#endif + +#include <stdlib.h> /* For malloc decl. */ +#define mem_alloc(bsize) malloc(bsize) +#define mem_free(ptr, bsize) free(ptr) + +#ifndef makedev /* ie, we haven't already included it */ +#include <sys/types.h> +#endif +#include <sys/time.h> +#include <sys/param.h> + +#include <netinet/in.h> + +#ifndef INADDR_LOOPBACK +#define INADDR_LOOPBACK (u_long)0x7F000001 +#endif +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 64 +#endif + +#endif /* rpc/types.h */ diff --git a/mdk-stage1/dietlibc/include/rpc/xdr.h b/mdk-stage1/dietlibc/include/rpc/xdr.h new file mode 100644 index 000000000..ce092f085 --- /dev/null +++ b/mdk-stage1/dietlibc/include/rpc/xdr.h @@ -0,0 +1,379 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * xdr.h, External Data Representation Serialization Routines. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_XDR_H +#define _RPC_XDR_H 1 + +#include <sys/cdefs.h> +#include <sys/types.h> +#include <rpc/types.h> + +/* We need FILE. */ +#include <stdio.h> + +__BEGIN_DECLS + +/* + * XDR provides a conventional way for converting between C data + * types and an external bit-string representation. Library supplied + * routines provide for the conversion on built-in C data types. These + * routines and utility routines defined here are used to help implement + * a type encode/decode routine for each user-defined type. + * + * Each data type provides a single procedure which takes two arguments: + * + * bool_t + * xdrproc(xdrs, argresp) + * XDR *xdrs; + * <type> *argresp; + * + * xdrs is an instance of a XDR handle, to which or from which the data + * type is to be converted. argresp is a pointer to the structure to be + * converted. The XDR handle contains an operation field which indicates + * which of the operations (ENCODE, DECODE * or FREE) is to be performed. + * + * XDR_DECODE may allocate space if the pointer argresp is null. This + * data can be freed with the XDR_FREE operation. + * + * We write only one procedure per data type to make it easy + * to keep the encode and decode procedures for a data type consistent. + * In many cases the same code performs all operations on a user defined type, + * because all the hard work is done in the component type routines. + * decode as a series of calls on the nested data types. + */ + +/* + * Xdr operations. XDR_ENCODE causes the type to be encoded into the + * stream. XDR_DECODE causes the type to be extracted from the stream. + * XDR_FREE can be used to release the space allocated by an XDR_DECODE + * request. + */ +enum xdr_op { + XDR_ENCODE = 0, + XDR_DECODE = 1, + XDR_FREE = 2 +}; + +/* + * This is the number of bytes per unit of external data. + */ +#define BYTES_PER_XDR_UNIT (4) +/* + * This only works if the above is a power of 2. But it's defined to be + * 4 by the appropriate RFCs. So it will work. And it's normally quicker + * than the old routine. + */ +#if 1 +#define RNDUP(x) (((x) + BYTES_PER_XDR_UNIT - 1) & ~(BYTES_PER_XDR_UNIT - 1)) +#else /* this is the old routine */ +#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ + * BYTES_PER_XDR_UNIT) +#endif + +/* + * The XDR handle. + * Contains operation which is being applied to the stream, + * an operations vector for the particular implementation (e.g. see xdr_mem.c), + * and two private fields for the use of the particular implementation. + */ +typedef struct XDR XDR; +struct XDR + { + enum xdr_op x_op; /* operation; fast additional param */ + struct xdr_ops + { + bool_t (*x_getlong) (XDR *__xdrs, long *__lp); + /* get a long from underlying stream */ + bool_t (*x_putlong) (XDR *__xdrs, const long *__lp); + /* put a long to " */ + bool_t (*x_getbytes) (XDR *__xdrs, caddr_t __addr, u_int __len); + /* get some bytes from " */ + bool_t (*x_putbytes) (XDR *__xdrs, const char *__addr, u_int __len); + /* put some bytes to " */ + u_int (*x_getpostn) (const XDR *__xdrs); + /* returns bytes off from beginning */ + bool_t (*x_setpostn) (XDR *__xdrs, u_int __pos); + /* lets you reposition the stream */ + int32_t *(*x_inline) (XDR *__xdrs, int __len); + /* buf quick ptr to buffered data */ + void (*x_destroy) (XDR *__xdrs); + /* free privates of this xdr_stream */ + bool_t (*x_getint32) (XDR *__xdrs, int32_t *__ip); + /* get a int from underlying stream */ + bool_t (*x_putint32) (XDR *__xdrs, const int32_t *__ip); + /* put a int to " */ + } + *x_ops; + caddr_t x_public; /* users' data */ + caddr_t x_private; /* pointer to private data */ + caddr_t x_base; /* private used for position info */ + int x_handy; /* extra private word */ + }; + +/* + * A xdrproc_t exists for each data type which is to be encoded or decoded. + * + * The second argument to the xdrproc_t is a pointer to an opaque pointer. + * The opaque pointer generally points to a structure of the data type + * to be decoded. If this pointer is 0, then the type routines should + * allocate dynamic storage of the appropriate size and return it. + * bool_t (*xdrproc_t)(XDR *, caddr_t *); + */ +typedef bool_t (*xdrproc_t) (XDR *, void *,...); + + +/* + * Operations defined on a XDR handle + * + * XDR *xdrs; + * int32_t *int32p; + * long *longp; + * caddr_t addr; + * u_int len; + * u_int pos; + */ +#define XDR_GETINT32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) +#define xdr_getint32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) + +#define XDR_PUTINT32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) +#define xdr_putint32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) + +#define XDR_GETLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) +#define xdr_getlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) + +#define XDR_PUTLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) +#define xdr_putlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) + +#define XDR_GETBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) +#define xdr_getbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) + +#define XDR_PUTBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) +#define xdr_putbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) + +#define XDR_GETPOS(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) +#define xdr_getpos(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) + +#define XDR_SETPOS(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) +#define xdr_setpos(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) + +#define XDR_INLINE(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) +#define xdr_inline(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) + +#define XDR_DESTROY(xdrs) \ + do { \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs); \ + } while (0) +#define xdr_destroy(xdrs) \ + do { \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs); \ + } while (0) + +/* + * Support struct for discriminated unions. + * You create an array of xdrdiscrim structures, terminated with + * a entry with a null procedure pointer. The xdr_union routine gets + * the discriminant value and then searches the array of structures + * for a matching value. If a match is found the associated xdr routine + * is called to handle that part of the union. If there is + * no match, then a default routine may be called. + * If there is no match and no default routine it is an error. + */ +#define NULL_xdrproc_t ((xdrproc_t)0) +struct xdr_discrim +{ + int value; + xdrproc_t proc; +}; + +/* + * Inline routines for fast encode/decode of primitive data types. + * Caveat emptor: these use single memory cycles to get the + * data from the underlying buffer, and will fail to operate + * properly if the data is not aligned. The standard way to use these + * is to say: + * if ((buf = XDR_INLINE(xdrs, count)) == NULL) + * return (FALSE); + * <<< macro calls >>> + * where ``count'' is the number of bytes of data occupied + * by the primitive data types. + * + * N.B. and frozen for all time: each data type here uses 4 bytes + * of external representation. + */ + +#define IXDR_GET_INT32(buf) ((int32_t)ntohl((uint32_t)*(buf)++)) +#define IXDR_PUT_INT32(buf, v) (*(buf)++ = (int32_t)htonl((uint32_t)(v))) +#define IXDR_GET_U_INT32(buf) ((uint32_t)IXDR_GET_INT32(buf)) +#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32(buf, (int32_t)(v)) + +/* WARNING: The IXDR_*_LONG defines are removed by Sun for new platforms + * and shouldn't be used any longer. Code which use this defines or longs + * in the RPC code will not work on 64bit Solaris platforms ! + */ +#define IXDR_GET_LONG(buf) \ + ((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++)) +#define IXDR_PUT_LONG(buf, v) \ + (*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v))) +#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) +#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG(buf, (long)(v)) + + +#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) +#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) +#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) +#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) + +#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG(buf, (long)(v)) +#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG(buf, (long)(v)) +#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG(buf, (long)(v)) +#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG(buf, (long)(v)) + +/* + * These are the "generic" xdr routines. + * None of these can have const applied because it's not possible to + * know whether the call is a read or a write to the passed parameter + * also, the XDR structure is always updated by some of these calls. + */ +extern bool_t xdr_void (void) __THROW; +extern bool_t xdr_short (XDR *__xdrs, short *__sp) __THROW; +extern bool_t xdr_u_short (XDR *__xdrs, u_short *__usp) __THROW; +extern bool_t xdr_int (XDR *__xdrs, int *__ip) __THROW; +extern bool_t xdr_u_int (XDR *__xdrs, u_int *__up) __THROW; +extern bool_t xdr_long (XDR *__xdrs, long *__lp) __THROW; +extern bool_t xdr_u_long (XDR *__xdrs, u_long *__ulp) __THROW; +extern bool_t xdr_hyper (XDR *__xdrs, __quad_t *__llp) __THROW; +extern bool_t xdr_u_hyper (XDR *__xdrs, __u_quad_t *__ullp) __THROW; +extern bool_t xdr_longlong_t (XDR *__xdrs, __quad_t *__llp) __THROW; +extern bool_t xdr_u_longlong_t (XDR *__xdrs, __u_quad_t *__ullp) __THROW; +extern bool_t xdr_int8_t (XDR *__xdrs, int8_t *__ip) __THROW; +extern bool_t xdr_uint8_t (XDR *__xdrs, uint8_t *__up) __THROW; +extern bool_t xdr_int16_t (XDR *__xdrs, int16_t *__ip) __THROW; +extern bool_t xdr_uint16_t (XDR *__xdrs, uint16_t *__up) __THROW; +extern bool_t xdr_int32_t (XDR *__xdrs, int32_t *__ip) __THROW; +extern bool_t xdr_uint32_t (XDR *__xdrs, uint32_t *__up) __THROW; +extern bool_t xdr_int64_t (XDR *__xdrs, int64_t *__ip) __THROW; +extern bool_t xdr_uint64_t (XDR *__xdrs, uint64_t *__up) __THROW; +extern bool_t xdr_bool (XDR *__xdrs, bool_t *__bp) __THROW; +extern bool_t xdr_enum (XDR *__xdrs, enum_t *__ep) __THROW; +extern bool_t xdr_array (XDR * _xdrs, caddr_t *__addrp, u_int *__sizep, + u_int __maxsize, u_int __elsize, xdrproc_t __elproc) + __THROW; +extern bool_t xdr_bytes (XDR *__xdrs, char **__cpp, u_int *__sizep, + u_int __maxsize) __THROW; +extern bool_t xdr_opaque (XDR *__xdrs, caddr_t __cp, u_int __cnt) __THROW; +extern bool_t xdr_string (XDR *__xdrs, char **__cpp, u_int __maxsize) __THROW; +extern bool_t xdr_union (XDR *__xdrs, enum_t *__dscmp, char *__unp, + const struct xdr_discrim *__choices, + xdrproc_t dfault) __THROW; +extern bool_t xdr_char (XDR *__xdrs, char *__cp) __THROW; +extern bool_t xdr_u_char (XDR *__xdrs, u_char *__cp) __THROW; +extern bool_t xdr_vector (XDR *__xdrs, char *__basep, u_int __nelem, + u_int __elemsize, xdrproc_t __xdr_elem) __THROW; +extern bool_t xdr_float (XDR *__xdrs, float *__fp) __THROW; +extern bool_t xdr_double (XDR *__xdrs, double *__dp) __THROW; +extern bool_t xdr_reference (XDR *__xdrs, caddr_t *__xpp, u_int __size, + xdrproc_t __proc) __THROW; +extern bool_t xdr_pointer (XDR *__xdrs, char **__objpp, + u_int __obj_size, xdrproc_t __xdr_obj) __THROW; +extern bool_t xdr_wrapstring (XDR *__xdrs, char **__cpp) __THROW; +extern u_long xdr_sizeof (xdrproc_t, void *) __THROW; + +/* + * Common opaque bytes objects used by many rpc protocols; + * declared here due to commonality. + */ +#define MAX_NETOBJ_SZ 1024 +struct netobj +{ + u_int n_len; + char *n_bytes; +}; +typedef struct netobj netobj; +extern bool_t xdr_netobj (XDR *__xdrs, struct netobj *__np) __THROW; + +/* + * These are the public routines for the various implementations of + * xdr streams. + */ + +/* XDR using memory buffers */ +extern void xdrmem_create (XDR *__xdrs, const caddr_t __addr, + u_int __size, enum xdr_op __xop) __THROW; + +/* XDR using stdio library */ +extern void xdrstdio_create (XDR *__xdrs, FILE *__file, enum xdr_op __xop) + __THROW; + +/* XDR pseudo records for tcp */ +extern void xdrrec_create (XDR *__xdrs, u_int __sendsize, + u_int __recvsize, caddr_t __tcp_handle, + int (*__readit) (char *, char *, int), + int (*__writeit) (char *, char *, int)) __THROW; + +/* make end of xdr record */ +extern bool_t xdrrec_endofrecord (XDR *__xdrs, bool_t __sendnow) __THROW; + +/* move to beginning of next record */ +extern bool_t xdrrec_skiprecord (XDR *__xdrs) __THROW; + +/* true if no more input */ +extern bool_t xdrrec_eof (XDR *__xdrs) __THROW; + +/* free memory buffers for xdr */ +extern void xdr_free (xdrproc_t __proc, char *__objp) __THROW; + +__END_DECLS + +#endif /* rpc/xdr.h */ diff --git a/mdk-stage1/dietlibc/include/sched.h b/mdk-stage1/dietlibc/include/sched.h new file mode 100644 index 000000000..5e4430d29 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sched.h @@ -0,0 +1,74 @@ +#ifndef _SCHED_H +#define _SCHED_H 1 + +#include <time.h> + +#include <sys/types.h> +#ifndef u16 +#define u16 __u16 +#endif + +/* till those F**KIN' kernel headers are sane: A COPY ! + * #include <linux/sched.h> + * A COPY OF THE STUFF WE NEED.... *GRUMBLE* */ + +/* + * cloning flags: + */ +#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ +#define CLONE_VM 0x00000100 /* set if VM shared between processes */ +#define CLONE_FS 0x00000200 /* set if fs info shared between processes */ +#define CLONE_FILES 0x00000400 /* set if open files shared between processes */ +#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */ +#define CLONE_PID 0x00001000 /* set if pid shared */ +#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */ +#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ +#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */ +#define CLONE_THREAD 0x00010000 /* Same thread group? */ + +#define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREA) + +/* + * Scheduling policies + */ +#define SCHED_OTHER 0 +#define SCHED_FIFO 1 +#define SCHED_RR 2 + +/* + * This is an additional bit set when we want to + * yield the CPU for one re-schedule.. + */ +#define SCHED_YIELD 0x10 + +struct sched_param { + int sched_priority; +}; + +/* END OF COPY form kernel-header */ + +int __sched_setparam(pid_t pid, const struct sched_param *p); +int sched_setparam(pid_t pid, const struct sched_param *p); + +int __sched_getparam(pid_t pid, struct sched_param *p); +int sched_getparam(pid_t pid, struct sched_param *p); + +int __sched_getscheduler(pid_t pid); +int sched_getscheduler(pid_t pid); + +int __sched_setscheduler(pid_t pid, int policy, const struct sched_param *p); +int sched_setscheduler(pid_t pid, int policy, const struct sched_param *p); + +int __sched_yield(void); +int sched_yield(void); + +int __sched_get_priority_max(int policy); +int sched_get_priority_max(int policy); + +int __sched_get_priority_min(int policy); +int sched_get_priority_min(int policy); + +int __sched_rr_get_interval(pid_t pid, struct timespec *tp); +int sched_rr_get_interval(pid_t pid, struct timespec *tp); + +#endif diff --git a/mdk-stage1/dietlibc/include/scsi/scsi.h b/mdk-stage1/dietlibc/include/scsi/scsi.h new file mode 100644 index 000000000..652e44ee9 --- /dev/null +++ b/mdk-stage1/dietlibc/include/scsi/scsi.h @@ -0,0 +1,224 @@ +/* Copyright (C) 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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 Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* + * This header file contains public constants and structures used by + * the scsi code for linux. + */ + +#ifndef _SCSI_SCSI_H +#define _SCSI_SCSI_H 1 + +/* + * SCSI opcodes + */ + +#define TEST_UNIT_READY 0x00 +#define REZERO_UNIT 0x01 +#define REQUEST_SENSE 0x03 +#define FORMAT_UNIT 0x04 +#define READ_BLOCK_LIMITS 0x05 +#define REASSIGN_BLOCKS 0x07 +#define READ_6 0x08 +#define WRITE_6 0x0a +#define SEEK_6 0x0b +#define READ_REVERSE 0x0f +#define WRITE_FILEMARKS 0x10 +#define SPACE 0x11 +#define INQUIRY 0x12 +#define RECOVER_BUFFERED_DATA 0x14 +#define MODE_SELECT 0x15 +#define RESERVE 0x16 +#define RELEASE 0x17 +#define COPY 0x18 +#define ERASE 0x19 +#define MODE_SENSE 0x1a +#define START_STOP 0x1b +#define RECEIVE_DIAGNOSTIC 0x1c +#define SEND_DIAGNOSTIC 0x1d +#define ALLOW_MEDIUM_REMOVAL 0x1e + +#define SET_WINDOW 0x24 +#define READ_CAPACITY 0x25 +#define READ_10 0x28 +#define WRITE_10 0x2a +#define SEEK_10 0x2b +#define WRITE_VERIFY 0x2e +#define VERIFY 0x2f +#define SEARCH_HIGH 0x30 +#define SEARCH_EQUAL 0x31 +#define SEARCH_LOW 0x32 +#define SET_LIMITS 0x33 +#define PRE_FETCH 0x34 +#define READ_POSITION 0x34 +#define SYNCHRONIZE_CACHE 0x35 +#define LOCK_UNLOCK_CACHE 0x36 +#define READ_DEFECT_DATA 0x37 +#define MEDIUM_SCAN 0x38 +#define COMPARE 0x39 +#define COPY_VERIFY 0x3a +#define WRITE_BUFFER 0x3b +#define READ_BUFFER 0x3c +#define UPDATE_BLOCK 0x3d +#define READ_LONG 0x3e +#define WRITE_LONG 0x3f +#define CHANGE_DEFINITION 0x40 +#define WRITE_SAME 0x41 +#define READ_TOC 0x43 +#define LOG_SELECT 0x4c +#define LOG_SENSE 0x4d +#define MODE_SELECT_10 0x55 +#define RESERVE_10 0x56 +#define RELEASE_10 0x57 +#define MODE_SENSE_10 0x5a +#define PERSISTENT_RESERVE_IN 0x5e +#define PERSISTENT_RESERVE_OUT 0x5f +#define MOVE_MEDIUM 0xa5 +#define READ_12 0xa8 +#define WRITE_12 0xaa +#define WRITE_VERIFY_12 0xae +#define SEARCH_HIGH_12 0xb0 +#define SEARCH_EQUAL_12 0xb1 +#define SEARCH_LOW_12 0xb2 +#define READ_ELEMENT_STATUS 0xb8 +#define SEND_VOLUME_TAG 0xb6 +#define WRITE_LONG_2 0xea + +/* + * Status codes + */ + +#define GOOD 0x00 +#define CHECK_CONDITION 0x01 +#define CONDITION_GOOD 0x02 +#define BUSY 0x04 +#define INTERMEDIATE_GOOD 0x08 +#define INTERMEDIATE_C_GOOD 0x0a +#define RESERVATION_CONFLICT 0x0c +#define COMMAND_TERMINATED 0x11 +#define QUEUE_FULL 0x14 + +#define STATUS_MASK 0x3e + +/* + * SENSE KEYS + */ + +#define NO_SENSE 0x00 +#define RECOVERED_ERROR 0x01 +#define NOT_READY 0x02 +#define MEDIUM_ERROR 0x03 +#define HARDWARE_ERROR 0x04 +#define ILLEGAL_REQUEST 0x05 +#define UNIT_ATTENTION 0x06 +#define DATA_PROTECT 0x07 +#define BLANK_CHECK 0x08 +#define COPY_ABORTED 0x0a +#define ABORTED_COMMAND 0x0b +#define VOLUME_OVERFLOW 0x0d +#define MISCOMPARE 0x0e + + +/* + * DEVICE TYPES + */ + +#define TYPE_DISK 0x00 +#define TYPE_TAPE 0x01 +#define TYPE_PROCESSOR 0x03 /* HP scanners use this */ +#define TYPE_WORM 0x04 /* Treated as ROM by our system */ +#define TYPE_ROM 0x05 +#define TYPE_SCANNER 0x06 +#define TYPE_MOD 0x07 /* Magneto-optical disk - + * - treated as TYPE_DISK */ +#define TYPE_MEDIUM_CHANGER 0x08 +#define TYPE_ENCLOSURE 0x0d /* Enclosure Services Device */ +#define TYPE_NO_LUN 0x7f + +/* + * standard mode-select header prepended to all mode-select commands + * + * moved here from cdrom.h -- kraxel + */ + +struct ccs_modesel_head + { + unsigned char _r1; /* reserved. */ + unsigned char medium; /* device-specific medium type. */ + unsigned char _r2; /* reserved. */ + unsigned char block_desc_length; /* block descriptor length. */ + unsigned char density; /* device-specific density code. */ + unsigned char number_blocks_hi; /* number of blocks in this block + desc. */ + unsigned char number_blocks_med; + unsigned char number_blocks_lo; + unsigned char _r3; + unsigned char block_length_hi; /* block length for blocks in this + desc. */ + unsigned char block_length_med; + unsigned char block_length_lo; + }; + +/* + * MESSAGE CODES + */ + +#define COMMAND_COMPLETE 0x00 +#define EXTENDED_MESSAGE 0x01 +#define EXTENDED_MODIFY_DATA_POINTER 0x00 +#define EXTENDED_SDTR 0x01 +#define EXTENDED_EXTENDED_IDENTIFY 0x02 /* SCSI-I only */ +#define EXTENDED_WDTR 0x03 +#define SAVE_POINTERS 0x02 +#define RESTORE_POINTERS 0x03 +#define DISCONNECT 0x04 +#define INITIATOR_ERROR 0x05 +#define ABORT 0x06 +#define MESSAGE_REJECT 0x07 +#define NOP 0x08 +#define MSG_PARITY_ERROR 0x09 +#define LINKED_CMD_COMPLETE 0x0a +#define LINKED_FLG_CMD_COMPLETE 0x0b +#define BUS_DEVICE_RESET 0x0c + +#define INITIATE_RECOVERY 0x0f /* SCSI-II only */ +#define RELEASE_RECOVERY 0x10 /* SCSI-II only */ + +#define SIMPLE_QUEUE_TAG 0x20 +#define HEAD_OF_QUEUE_TAG 0x21 +#define ORDERED_QUEUE_TAG 0x22 + +/* + * Here are some scsi specific ioctl commands which are sometimes useful. + */ +/* These are a few other constants only used by scsi devices. */ + +#define SCSI_IOCTL_GET_IDLUN 0x5382 + +/* Used to turn on and off tagged queuing for scsi devices. */ + +#define SCSI_IOCTL_TAGGED_ENABLE 0x5383 +#define SCSI_IOCTL_TAGGED_DISABLE 0x5384 + +/* Used to obtain the host number of a device. */ +#define SCSI_IOCTL_PROBE_HOST 0x5385 + +/* Used to get the bus number for a device. */ +#define SCSI_IOCTL_GET_BUS_NUMBER 0x5386 + +#endif /* scsi/scsi.h */ diff --git a/mdk-stage1/dietlibc/include/scsi/scsi_ioctl.h b/mdk-stage1/dietlibc/include/scsi/scsi_ioctl.h new file mode 100644 index 000000000..bc9931838 --- /dev/null +++ b/mdk-stage1/dietlibc/include/scsi/scsi_ioctl.h @@ -0,0 +1,34 @@ +/* Copyright (C) 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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 Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _SCSI_IOCTL_H +#define _SCSI_IOCTL_H + +/* IOCTLs for SCSI. */ +#define SCSI_IOCTL_SEND_COMMAND 1 /* Send a command to the SCSI host. */ +#define SCSI_IOCTL_TEST_UNIT_READY 2 /* Test if unit is ready. */ +#define SCSI_IOCTL_BENCHMARK_COMMAND 3 +#define SCSI_IOCTL_SYNC 4 /* Request synchronous parameters. */ +#define SCSI_IOCTL_START_UNIT 5 +#define SCSI_IOCTL_STOP_UNIT 6 +#define SCSI_IOCTL_DOORLOCK 0x5380 /* Lock the eject mechanism. */ +#define SCSI_IOCTL_DOORUNLOCK 0x5381 /* Unlock the mechanism. */ + +#endif + + diff --git a/mdk-stage1/dietlibc/include/scsi/sg.h b/mdk-stage1/dietlibc/include/scsi/sg.h new file mode 100644 index 000000000..00334654e --- /dev/null +++ b/mdk-stage1/dietlibc/include/scsi/sg.h @@ -0,0 +1,274 @@ +/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library 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 Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* + History: + Started: Aug 9 by Lawrence Foard (entropy@world.std.com), to allow user + process control of SCSI devices. + Development Sponsored by Killy Corp. NY NY +*/ + +#ifndef _SCSI_SG_H +#define _SCSI_SG_H 1 + +#include <sys/types.h> + +/* New interface introduced in the 3.x SG drivers follows */ + +/* Same structure as used by readv() Linux system call. It defines one + scatter-gather element. */ +typedef struct sg_iovec +{ + void * iov_base; /* Starting address */ + size_t iov_len; /* Length in bytes */ +} sg_iovec_t; + + +typedef struct sg_io_hdr +{ + int interface_id; /* [i] 'S' for SCSI generic (required) */ + int dxfer_direction; /* [i] data transfer direction */ + unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */ + unsigned char mx_sb_len; /* [i] max length to write to sbp */ + unsigned short int iovec_count; /* [i] 0 implies no scatter gather */ + unsigned int dxfer_len; /* [i] byte count of data transfer */ + void * dxferp; /* [i], [*io] points to data transfer memory + or scatter gather list */ + unsigned char * cmdp; /* [i], [*i] points to command to perform */ + unsigned char * sbp; /* [i], [*o] points to sense_buffer memory */ + unsigned int timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */ + unsigned int flags; /* [i] 0 -> default, see SG_FLAG... */ + int pack_id; /* [i->o] unused internally (normally) */ + void * usr_ptr; /* [i->o] unused internally */ + unsigned char status; /* [o] scsi status */ + unsigned char masked_status;/* [o] shifted, masked scsi status */ + unsigned char msg_status; /* [o] messaging level data (optional) */ + unsigned char sb_len_wr; /* [o] byte count actually written to sbp */ + unsigned short int host_status; /* [o] errors from host adapter */ + unsigned short int driver_status;/* [o] errors from software driver */ + int resid; /* [o] dxfer_len - actual_transferred */ + unsigned int duration; /* [o] time taken by cmd (unit: millisec) */ + unsigned int info; /* [o] auxiliary information */ +} sg_io_hdr_t; + + +/* Use negative values to flag difference from original sg_header structure. */ +#define SG_DXFER_NONE -1 /* e.g. a SCSI Test Unit Ready command */ +#define SG_DXFER_TO_DEV -2 /* e.g. a SCSI WRITE command */ +#define SG_DXFER_FROM_DEV -3 /* e.g. a SCSI READ command */ +#define SG_DXFER_TO_FROM_DEV -4 /* treated like SG_DXFER_FROM_DEV with the + additional property than during indirect + IO the user buffer is copied into the + kernel buffers before the transfer */ + + +/* following flag values can be "or"-ed together */ +#define SG_FLAG_DIRECT_IO 1 /* default is indirect IO */ +#define SG_FLAG_LUN_INHIBIT 2 /* default is to put device's lun into */ + /* the 2nd byte of SCSI command */ +#define SG_FLAG_NO_DXFER 0x10000 /* no transfer of kernel buffers to/from */ + /* user space (debug indirect IO) */ + +/* The following 'info' values are "or"-ed together. */ +#define SG_INFO_OK_MASK 0x1 +#define SG_INFO_OK 0x0 /* no sense, host nor driver "noise" */ +#define SG_INFO_CHECK 0x1 /* something abnormal happened */ + +#define SG_INFO_DIRECT_IO_MASK 0x6 +#define SG_INFO_INDIRECT_IO 0x0 /* data xfer via kernel buffers (or no xfer) */ +#define SG_INFO_DIRECT_IO 0x2 /* direct IO requested and performed */ +#define SG_INFO_MIXED_IO 0x4 /* part direct, part indirect IO */ + + +/* Request information about a specific SG device, used by + SG_GET_SCSI_ID ioctl (). */ +struct sg_scsi_id { + /* Host number as in "scsi<n>" where 'n' is one of 0, 1, 2 etc. */ + int host_no; + int channel; + /* SCSI id of target device. */ + int scsi_id; + int lun; + /* TYPE_... defined in <scsi/scsi.h>. */ + int scsi_type; + /* Host (adapter) maximum commands per lun. */ + short int h_cmd_per_lun; + /* Device (or adapter) maximum queue length. */ + short int d_queue_depth; + /* Unused, set to 0 for now. */ + int unused[2]; +}; + +/* Used by SG_GET_REQUEST_TABLE ioctl(). */ +typedef struct sg_req_info { + char req_state; /* 0 -> not used, 1 -> written, 2 -> ready to read */ + char orphan; /* 0 -> normal request, 1 -> from interruped SG_IO */ + char sg_io_owned; /* 0 -> complete with read(), 1 -> owned by SG_IO */ + char problem; /* 0 -> no problem detected, 1 -> error to report */ + int pack_id; /* pack_id associated with request */ + void * usr_ptr; /* user provided pointer (in new interface) */ + unsigned int duration; /* millisecs elapsed since written (req_state==1) + or request duration (req_state==2) */ + int unused; +} sg_req_info_t; + + +/* IOCTLs: Those ioctls that are relevant to the SG 3.x drivers follow. + [Those that only apply to the SG 2.x drivers are at the end of the file.] + (_GET_s yield result via 'int *' 3rd argument unless otherwise indicated) */ + +#define SG_EMULATED_HOST 0x2203 /* true for emulated host adapter (ATAPI) */ + +/* Used to configure SCSI command transformation layer for ATAPI devices */ +/* Only supported by the ide-scsi driver */ +#define SG_SET_TRANSFORM 0x2204 /* N.B. 3rd arg is not pointer but value: */ + /* 3rd arg = 0 to disable transform, 1 to enable it */ +#define SG_GET_TRANSFORM 0x2205 + +#define SG_SET_RESERVED_SIZE 0x2275 /* request a new reserved buffer size */ +#define SG_GET_RESERVED_SIZE 0x2272 /* actual size of reserved buffer */ + +/* The following ioctl has a 'sg_scsi_id_t *' object as its 3rd argument. */ +#define SG_GET_SCSI_ID 0x2276 /* Yields fd's bus, chan, dev, lun + type */ +/* SCSI id information can also be obtained from SCSI_IOCTL_GET_IDLUN */ + +/* Override host setting and always DMA using low memory ( <16MB on i386) */ +#define SG_SET_FORCE_LOW_DMA 0x2279 /* 0-> use adapter setting, 1-> force */ +#define SG_GET_LOW_DMA 0x227a /* 0-> use all ram for dma; 1-> low dma ram */ + +/* When SG_SET_FORCE_PACK_ID set to 1, pack_id is input to read() which + tries to fetch a packet with a matching pack_id, waits, or returns EAGAIN. + If pack_id is -1 then read oldest waiting. When ...FORCE_PACK_ID set to 0 + then pack_id ignored by read() and oldest readable fetched. */ +#define SG_SET_FORCE_PACK_ID 0x227b +#define SG_GET_PACK_ID 0x227c /* Yields oldest readable pack_id (or -1) */ + +#define SG_GET_NUM_WAITING 0x227d /* Number of commands awaiting read() */ + +/* Yields max scatter gather tablesize allowed by current host adapter */ +#define SG_GET_SG_TABLESIZE 0x227F /* 0 implies can't do scatter gather */ + +#define SG_GET_VERSION_NUM 0x2282 /* Example: version 2.1.34 yields 20134 */ + +/* Returns -EBUSY if occupied. 3rd argument pointer to int (see next) */ +#define SG_SCSI_RESET 0x2284 +/* Associated values that can be given to SG_SCSI_RESET follow */ +#define SG_SCSI_RESET_NOTHING 0 +#define SG_SCSI_RESET_DEVICE 1 +#define SG_SCSI_RESET_BUS 2 +#define SG_SCSI_RESET_HOST 3 + +/* synchronous SCSI command ioctl, (only in version 3 interface) */ +#define SG_IO 0x2285 /* similar effect as write() followed by read() */ + +#define SG_GET_REQUEST_TABLE 0x2286 /* yields table of active requests */ + +/* How to treat EINTR during SG_IO ioctl(), only in SG 3.x series */ +#define SG_SET_KEEP_ORPHAN 0x2287 /* 1 -> hold for read(), 0 -> drop (def) */ +#define SG_GET_KEEP_ORPHAN 0x2288 + + +#define SG_SCATTER_SZ (8 * 4096) /* PAGE_SIZE not available to user */ +/* Largest size (in bytes) a single scatter-gather list element can have. + The value must be a power of 2 and <= (PAGE_SIZE * 32) [131072 bytes on + i386]. The minimum value is PAGE_SIZE. If scatter-gather not supported + by adapter then this value is the largest data block that can be + read/written by a single scsi command. The user can find the value of + PAGE_SIZE by calling getpagesize() defined in unistd.h . */ + +#define SG_DEFAULT_RETRIES 1 + +/* Defaults, commented if they differ from original sg driver */ +#define SG_DEF_FORCE_LOW_DMA 0 /* was 1 -> memory below 16MB on i386 */ +#define SG_DEF_FORCE_PACK_ID 0 +#define SG_DEF_KEEP_ORPHAN 0 +#define SG_DEF_RESERVED_SIZE SG_SCATTER_SZ /* load time option */ + +/* maximum outstanding requests, write() yields EDOM if exceeded */ +#define SG_MAX_QUEUE 16 + +#define SG_BIG_BUFF SG_DEF_RESERVED_SIZE /* for backward compatibility */ + +/* Alternate style type names, "..._t" variants preferred */ +typedef struct sg_io_hdr Sg_io_hdr; +typedef struct sg_io_vec Sg_io_vec; +typedef struct sg_scsi_id Sg_scsi_id; +typedef struct sg_req_info Sg_req_info; + + +/* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ +/* The older SG interface based on the 'sg_header' structure follows. */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */ + +#define SG_MAX_SENSE 16 /* this only applies to the sg_header interface */ + +struct sg_header + { + /* Length of incoming packet (including header). */ + int pack_len; + /* Maximal length of expected reply. */ + int reply_len; + /* Id number of packet. */ + int pack_id; + /* 0==ok, otherwise error number. */ + int result; + /* Force 12 byte command length for group 6 & 7 commands. */ + unsigned int twelve_byte:1; + /* SCSI status from target. */ + unsigned int target_status:5; + /* Host status (see "DID" codes). */ + unsigned int host_status:8; + /* Driver status+suggestion. */ + unsigned int driver_status:8; + /* Unused. */ + unsigned int other_flags:10; + /* Output in 3 cases: + when target_status is CHECK_CONDITION or + when target_status is COMMAND_TERMINATED or + when (driver_status & DRIVER_SENSE) is true. */ + unsigned char sense_buffer[SG_MAX_SENSE]; + }; + + +/* IOCTLs: The following are not required (or ignored) when the sg_io_hdr_t + interface is used. They are kept for backward compatibility with + the original and version 2 drivers. */ + +#define SG_SET_TIMEOUT 0x2201 /* Set timeout; *(int *)arg==timeout. */ +#define SG_GET_TIMEOUT 0x2202 /* Get timeout; return timeout. */ + +/* Get/set command queuing state per fd (default is SG_DEF_COMMAND_Q). */ +#define SG_GET_COMMAND_Q 0x2270 /* Yields 0 (queuing off) or 1 (on). */ +#define SG_SET_COMMAND_Q 0x2271 /* Change queuing state with 0 or 1. */ + +/* Turn on error sense trace (1..8), dump this device to log/console (9) + or dump all sg device states ( >9 ) to log/console. */ +#define SG_SET_DEBUG 0x227e /* 0 -> turn off debug */ + +#define SG_NEXT_CMD_LEN 0x2283 /* Override SCSI command length with given + number on the next write() on this file + descriptor. */ + +/* Defaults, commented if they differ from original sg driver */ +#define SG_DEFAULT_TIMEOUT (60*HZ) /* HZ == 'jiffies in 1 second' */ +#define SG_DEF_COMMAND_Q 0 /* command queuing is always on when + the new interface is used */ +#define SG_DEF_UNDERRUN_FLAG 0 + + +#endif /* scsi/sg.h */ diff --git a/mdk-stage1/dietlibc/include/setjmp.h b/mdk-stage1/dietlibc/include/setjmp.h index a49b450ac..66fc288f4 100644 --- a/mdk-stage1/dietlibc/include/setjmp.h +++ b/mdk-stage1/dietlibc/include/setjmp.h @@ -85,7 +85,8 @@ typedef long int __jmp_buf[58]; #ifndef __ASSEMBLER__ -typedef int __sig_atomic_t; +typedef int sig_atomic_t; +#define __sig_atomic_t sig_atomic_t # define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int))) typedef struct @@ -115,6 +116,7 @@ extern void siglongjmp (sigjmp_buf __env, int __val) __THROW __attribute__ ((__noreturn__)); #define setjmp(env) __sigsetjmp(env,0) +#define sigsetjmp(a,b) __sigsetjmp(a,b) #endif diff --git a/mdk-stage1/dietlibc/include/shadow.h b/mdk-stage1/dietlibc/include/shadow.h new file mode 100644 index 000000000..4d6341af1 --- /dev/null +++ b/mdk-stage1/dietlibc/include/shadow.h @@ -0,0 +1,24 @@ +#ifndef _SHADOW_H +#define _SHADOW_H + +#include <sys/cdefs.h> +#include <sys/types.h> + +struct spwd { + char *sp_namp; /* user login name */ + char *sp_pwdp; /* encrypted password */ + long sp_lstchg; /* last password change */ + int sp_min; /* days until change allowed. */ + int sp_max; /* days before change required */ + int sp_warn; /* days warning for expiration */ + int sp_inact; /* days before account inactive */ + int sp_expire; /* date when account expires */ + int sp_flag; /* reserved for future use */ +}; + +extern struct spwd *getspent(void) __THROW; +extern void setspent(void) __THROW; +extern void endspent(void) __THROW; +extern struct spwd *getspnam (__const char *__name) __THROW; + +#endif /* _SHADOW_H */ diff --git a/mdk-stage1/dietlibc/include/signal.h b/mdk-stage1/dietlibc/include/signal.h index 9214d176d..9ed93fe83 100644 --- a/mdk-stage1/dietlibc/include/signal.h +++ b/mdk-stage1/dietlibc/include/signal.h @@ -3,13 +3,33 @@ #include <sys/cdefs.h> +#define __WANT_POSIX1B_SIGNALS__ + #include <linux/types.h> #include <linux/signal.h> +typedef void (*sighandler_t)(int); + int sigemptyset(sigset_t *set) __THROW; +int sigfillset(sigset_t *set) __THROW; int sigaddset(sigset_t *set, int signum) __THROW; +int sigdelset(sigset_t *set, int signum) __THROW; int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) __THROW; +sighandler_t signal(int signum, sighandler_t action); int raise (int sig) __THROW; -void (*signal(int signum, void (*sighandler)(int)))(int) __THROW; +int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) __THROW; +int sigaltstack(const struct sigaltstack *newstack, struct sigaltstack *oldstack) __THROW; + +#ifndef SIGCLD +#define SIGCLD SIGCHLD +#endif + +extern const char *const sys_siglist[]; + +typedef __sighandler_t sig_t; + +#ifndef NSIG +#define NSIG _NSIG +#endif #endif diff --git a/mdk-stage1/dietlibc/include/stdio.h b/mdk-stage1/dietlibc/include/stdio.h index 65974668d..7c7c698eb 100644 --- a/mdk-stage1/dietlibc/include/stdio.h +++ b/mdk-stage1/dietlibc/include/stdio.h @@ -1,69 +1,96 @@ #ifndef _STDIO_H #define _STDIO_H +#include <sys/cdefs.h> #include <sys/types.h> typedef struct __stdio_file FILE; -FILE *fopen (const char *path, const char *mode); -FILE *fdopen (int fildes, const char *mode); -FILE *freopen (const char *path, const char *mode, FILE *stream); +FILE *fopen (const char *path, const char *mode) __THROW; +FILE *fdopen (int fildes, const char *mode) __THROW; +FILE *freopen (const char *path, const char *mode, FILE *stream) __THROW; -int printf(const char *format, ...); -int fprintf(FILE *stream, const char *format, ...); -int sprintf(char *str, const char *format, ...); -int snprintf(char *str, size_t size, const char *format, ...); +int printf(const char *format, ...) __THROW; +int fprintf(FILE *stream, const char *format, ...) __THROW; +int sprintf(char *str, const char *format, ...) __THROW; +int snprintf(char *str, size_t size, const char *format, ...) __THROW; +int asprintf(char **ptr, const char* format, ...) __THROW; -int scanf( const char *format, ...); -int fscanf( FILE *stream, const char *format, ...); -int sscanf( const char *str, const char *format, ...); +int scanf( const char *format, ...) __THROW; +int fscanf( FILE *stream, const char *format, ...) __THROW; +int sscanf( const char *str, const char *format, ...) __THROW; #include <stdarg.h> -int vprintf(const char *format, va_list ap); -int vfprintf(FILE *stream, const char *format, va_list ap); -int vsprintf(char *str, const char *format, va_list ap); -int vsnprintf(char *str, size_t size, const char *format, va_list ap); +int vprintf(const char *format, va_list ap) __THROW; +int vfprintf(FILE *stream, const char *format, va_list ap) __THROW; +int vsprintf(char *str, const char *format, va_list ap) __THROW; +int vsnprintf(char *str, size_t size, const char *format, va_list ap) __THROW; -int vscanf( const char *format, va_list ap); -int vsscanf( const char *str, const char *format, va_list ap); -int vfscanf( FILE *stream, const char *format, va_list ap); +int vscanf( const char *format, va_list ap) __THROW; +int vsscanf( const char *str, const char *format, va_list ap) __THROW; +int vfscanf( FILE *stream, const char *format, va_list ap) __THROW; -int ferror(FILE *stream); -int feof(FILE *stream); +int fgetc(FILE *stream) __THROW; +char *fgets(char *s, int size, FILE *stream) __THROW; +int getc(FILE *stream) __THROW; +int getchar(void) __THROW; +char *gets(char *s) __THROW; +int ungetc(int c, FILE *stream) __THROW; -int fgetc(FILE *stream); -char *fgets(char *s, int size, FILE *stream); -int getc(FILE *stream); -int getchar(void); -char *gets(char *s); +int fputc(int c, FILE *stream) __THROW; +int fputs(const char *s, FILE *stream) __THROW; -int fputc(int c, FILE *stream); -int fputs(const char *s, FILE *stream); -int putc(int c, FILE *stream); -int putchar(int c); -int puts(const char *s); +#define putc(c,stream) fputc(c,stream) +#define putchar(c) fputc(c,stdout) -int fseek( FILE *stream, long offset, int whence); -long ftell( FILE *stream); -void rewind( FILE *stream); -int fgetpos( FILE *stream, fpos_t *pos); -int fsetpos( FILE *stream, fpos_t *pos); +#define getchar() fgetc(stdin) +#define getc(stream) fgetc(stream) -size_t fread( void *ptr, size_t size, size_t nmemb, FILE *stream); +int puts(const char *s) __THROW; -size_t fwrite( const void *ptr, size_t size, size_t nmemb, FILE *stream); +long fseek( FILE *stream, long offset, int whence) __THROW; +long ftell( FILE *stream) __THROW; +void rewind( FILE *stream) __THROW; +int fgetpos( FILE *stream, fpos_t *pos) __THROW; +int fsetpos( FILE *stream, fpos_t *pos) __THROW; -int fflush(FILE *stream); +size_t fread( void *ptr, size_t size, size_t nmemb, FILE *stream) __THROW; -int fclose(FILE *stream); +size_t fwrite( const void *ptr, size_t size, size_t nmemb, FILE *stream) __THROW; + +int fflush(FILE *stream) __THROW; + +int fclose(FILE *stream) __THROW; + +int feof (FILE *stream) __THROW; +int ferror( FILE *stream) __THROW; +int fileno( FILE *stream) __THROW; + +int remove(const char *pathname) __THROW; + +void perror(const char *s) __THROW; extern FILE *stdin, *stdout, *stderr; #define EOF (int)(-1) -void perror (const char *__s); - #define BUFSIZ 128 +#define _IONBF 0 +#define _IOLBF 1 +#define _IOFBF 2 + +int setvbuf(FILE *stream, char *buf, int mode , size_t size) __THROW; + +#define setbuf(stream,buf) setvbuf(stream,buf,buf?_IOFBF:_IONBF,BUFSIZ) +#define setbuffer(stream,buf,size) setvbuf(stream,buf,buf?_IOFBF:_IONBF,size) +#define setlinebuf(stream) setvbuf(stream,0,_IOLBF,BUFSIZ) + +FILE *popen(const char *command, const char *type) __THROW; +int pclose(FILE *stream) __THROW; + +#define getc_unlocked(stream) getc(stream) +#define putc_unlocked(c,stream) putc(c,stream) + #endif diff --git a/mdk-stage1/dietlibc/include/stdlib.h b/mdk-stage1/dietlibc/include/stdlib.h index c5fea2608..b85425426 100644 --- a/mdk-stage1/dietlibc/include/stdlib.h +++ b/mdk-stage1/dietlibc/include/stdlib.h @@ -9,36 +9,52 @@ void *malloc(size_t size) __THROW; void free(void *ptr) __THROW; void *realloc(void *ptr, size_t size) __THROW; -void *alloca(size_t size); - -char *getenv(const char *name) __pure__; +char *getenv(const char *name) __THROW __pure__; +int putenv(const char *string) __THROW; +int setenv(const char *name, const char *value, int overwrite) __THROW; +void unsetenv(const char *name) __THROW; int atexit(void (*function)(void)) __THROW; double strtod(const char *nptr, char **endptr) __THROW; -long int strtol(const char *nptr, char **endptr, int base); -unsigned long int strtoul(const char *nptr, char **endptr, int base); +long int strtol(const char *nptr, char **endptr, int base) __THROW; +unsigned long int strtoul(const char *nptr, char **endptr, int base) __THROW; -int __ltostr(char *s, int size, unsigned long i, int base, char UpCase); +int __ltostr(char *s, int size, unsigned long i, int base, char UpCase) __THROW; #ifdef __GNUC__ -long long int strtoll(const char *nptr, char **endptr, int base); -unsigned long long int strtoull(const char *nptr, char **endptr, int base); -int __lltostr(char *s, int size, unsigned long long i, int base, char UpCase); +long long int strtoll(const char *nptr, char **endptr, int base) __THROW; +unsigned long long int strtoull(const char *nptr, char **endptr, int base) __THROW; +int __lltostr(char *s, int size, unsigned long long i, int base, char UpCase) __THROW; #endif -int atoi(const char *nptr); +int atoi(const char *nptr) __THROW; +long int atol(const char *nptr) __THROW; +double atof(const char *nptr) __THROW; + +void exit(int status) __THROW __attribute__((noreturn)); +void abort(void) __THROW; + +/* warning: the rand() implementation of the diet libc really sucks. */ +#define RAND_MAX 32767 -void abort(void); -void exit(int); +extern int rand(void) __THROW; +extern void srand(unsigned int seed) __THROW; + +void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) __THROW; +void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) __THROW; extern char **environ; -#define WIFSTOPPED(status) (((status) & 0xff) == 0x7f) -#define WIFSIGNALED(status) (!WIFSTOPPED(status) && !WIFEXITED(status)) -#define WEXITSTATUS(status) (((status) & 0xff00) >> 8) -#define WTERMSIG(status) ((status) & 0x7f) -#define WSTOPSIG(status) WEXITSTATUS(status) -#define WIFEXITED(status) (WTERMSIG(status) == 0) +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 1 + +/* now this function is the greatest bullshit I have ever seen. + * The ISO people must be out of their minds. */ +typedef struct { int quot,rem; } div_t; +div_t div(int numer, int denom) __THROW __attribute__((const)); + +void *alloca(size_t size) __THROW; /* gcc built-in */ +char *realpath(const char *path, char *resolved_path) __THROW; #endif diff --git a/mdk-stage1/dietlibc/include/string.h b/mdk-stage1/dietlibc/include/string.h index 133ac3b61..1ef78ae54 100644 --- a/mdk-stage1/dietlibc/include/string.h +++ b/mdk-stage1/dietlibc/include/string.h @@ -15,19 +15,27 @@ int memccmp(const void *s1, const void *s2, int c, size_t n) __THROW __pure__; int memcmp(const void *s1, const void *s2, size_t n) __THROW __pure__; int strcmp(const char *s1, const char *s2) __THROW __pure__; int strncmp(const char *s1, const char *s2, size_t n) __THROW __pure__; -char *strstr (const char *__haystack, const char *__needle) __THROW __pure__; + +int strcasecmp(const char *s1, const char *s2) __THROW __pure__; +int strncasecmp(const char *s1, const char *s2, size_t n) __THROW __pure__; size_t strlen(const char *s) __THROW __pure__; +char *strstr(const char *haystack, const char *needle) __THROW __pure__; + char *strdup(const char *s) __THROW; -char *strchr(const char *s, int c) __THROW; -char *strrchr(const char *s, int c) __THROW; +char *strchr(const char *s, int c) __THROW __pure__; +char *strrchr(const char *s, int c) __THROW __pure__; char *strcat(char *dest, const char *src) __THROW; char *strncat(char *dest, const char *src, size_t n) __THROW; -size_t strcspn(const char *s, const char *reject); +size_t strspn(const char *s, const char *accept) __THROW; +size_t strcspn(const char *s, const char *reject) __THROW; + +char *strpbrk(const char *s, const char *accept) __THROW; +char *strsep(char **stringp, const char *delim) __THROW; void* memset(void *s, int c, size_t n) __THROW; @@ -35,8 +43,15 @@ void* memset(void *s, int c, size_t n) __THROW; #define NULL (void*)0 #define bzero(s,n) memset(s,0,n) -#define bcmp(s1,s2,n) memcmp(s1,s2,n) +#define bcopy(src,dest,n) memmove(dest,src,n) +#define bcmp(a,b,n) memcmp(a,b,n) + +char *strerror(int errnum) __THROW; +char *strsignal(int signum) __THROW; + +char *strtok(char *s, const char *delim) __THROW; +char *strtok_r(char *s, const char *delim, char **ptrptr) __THROW; -char *strerror (int __errnum) __THROW; +int ffs(int i) __THROW __attribute__((__const__)); #endif diff --git a/mdk-stage1/dietlibc/include/strings.h b/mdk-stage1/dietlibc/include/strings.h new file mode 100644 index 000000000..ec947a9b9 --- /dev/null +++ b/mdk-stage1/dietlibc/include/strings.h @@ -0,0 +1,2 @@ +#warning "your code included obsolescent <strings.h>. Please change that to <string.h>!" +#include <string.h> diff --git a/mdk-stage1/dietlibc/include/sys/cdefs.h b/mdk-stage1/dietlibc/include/sys/cdefs.h index 9f256f59f..895bb74b8 100644 --- a/mdk-stage1/dietlibc/include/sys/cdefs.h +++ b/mdk-stage1/dietlibc/include/sys/cdefs.h @@ -1,11 +1,17 @@ #ifndef _SYS_CDEFS_H #define _SYS_CDEFS_H +#define __dietlibc__ + #ifndef __cplusplus #define throw () #define __THROW +#define __BEGIN_DECLS +#define __END_DECLS #else #define __THROW throw () +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS } #endif #ifndef __GNUC__ @@ -19,6 +25,12 @@ #define __pure__ __attribute__ ((__pure__)) #endif +#if (__GNUC__ == 2) && (__GNUC_MINOR__ < 95) +#define __restrict__ +#endif + #endif +#define __P(x) x + #endif diff --git a/mdk-stage1/dietlibc/include/sys/file.h b/mdk-stage1/dietlibc/include/sys/file.h new file mode 100644 index 000000000..91b6b547e --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/file.h @@ -0,0 +1,8 @@ +#ifndef _SYS_FILE_H +#define _SYS_FILE_H + +#include <sys/cdefs.h> + +extern int fcntl(int fd, int cmd, ...) __THROW; + +#endif /* _SYS_FILE_H */ diff --git a/mdk-stage1/dietlibc/include/sys/ipc.h b/mdk-stage1/dietlibc/include/sys/ipc.h new file mode 100644 index 000000000..9184a2a82 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/ipc.h @@ -0,0 +1,8 @@ +#ifndef _SYS_IPC_H +#define _SYS_IPC_H + +#include <sys/cdefs.h> +#include <linux/ipc.h> +#include <asm/page.h> + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/kd.h b/mdk-stage1/dietlibc/include/sys/kd.h new file mode 100644 index 000000000..9e9a5152b --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/kd.h @@ -0,0 +1,6 @@ +#ifndef _SYS_KD_H +#define _SYS_KD_H + +#include <linux/kd.h> + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/mman.h b/mdk-stage1/dietlibc/include/sys/mman.h index 03faa37ae..dc398ba90 100644 --- a/mdk-stage1/dietlibc/include/sys/mman.h +++ b/mdk-stage1/dietlibc/include/sys/mman.h @@ -4,6 +4,11 @@ #include <sys/cdefs.h> #include <sys/types.h> #include <linux/mman.h> +#include <asm/page.h> + +#ifndef PAGE_SIZE +#warning PAGE_SIZE undefined +#endif #define MAP_FAILED ((void *) -1) @@ -22,4 +27,7 @@ extern void *mmap64 (void *__addr, size_t __len, int __prot, int __flags, int __fd, off64_t __offset) __THROW; #endif +int mlockall(int flags) __THROW; +int munlockall(void) __THROW; + #endif diff --git a/mdk-stage1/dietlibc/include/sys/mount.h b/mdk-stage1/dietlibc/include/sys/mount.h index 1c4368a2f..2e9e86774 100644 --- a/mdk-stage1/dietlibc/include/sys/mount.h +++ b/mdk-stage1/dietlibc/include/sys/mount.h @@ -1,81 +1,19 @@ #ifndef _SYS_MOUNT_H -#define _SYS_MOUNT_H 1 +#define _SYS_MOUNT_H -#include <sys/ioctl.h> +#include <sys/cdefs.h> +#include <sys/types.h> +#include <linux/fs.h> -#define BLOCK_SIZE 1024 -#define BLOCK_SIZE_BITS 10 +int mount(const char* specialfile, const char* dir, const char* filesystemtype, + unsigned long rwflag, const void * data) __THROW; -/* These are the fs-independent mount-flags: up to 16 flags are - supported */ -enum -{ - MS_RDONLY = 1, /* Mount read-only. */ -#define MS_RDONLY MS_RDONLY - MS_NOSUID = 2, /* Ignore suid and sgid bits. */ -#define MS_NOSUID MS_NOSUID - MS_NODEV = 4, /* Disallow access to device special files. */ -#define MS_NODEV MS_NODEV - MS_NOEXEC = 8, /* Disallow program execution. */ -#define MS_NOEXEC MS_NOEXEC - MS_SYNCHRONOUS = 16, /* Writes are synced at once. */ -#define MS_SYNCHRONOUS MS_SYNCHRONOUS - MS_REMOUNT = 32, /* Alter flags of a mounted FS. */ -#define MS_REMOUNT MS_REMOUNT - MS_MANDLOCK = 64, /* Allow mandatory locks on an FS. */ -#define MS_MANDLOCK MS_MANDLOCK - S_WRITE = 128, /* Write on file/directory/symlink. */ -#define S_WRITE S_WRITE - S_APPEND = 256, /* Append-only file. */ -#define S_APPEND S_APPEND - S_IMMUTABLE = 512, /* Immutable file. */ -#define S_IMMUTABLE S_IMMUTABLE - MS_NOATIME = 1024, /* Do not update access times. */ -#define MS_NOATIME MS_NOATIME - MS_NODIRATIME = 2048, /* Do not update directory access times. */ -#define MS_NODIRATIME MS_NODIRATIME - MS_BIND = 4096, /* Bind directory at different place. */ -#define MS_BIND MS_BIND -}; +int umount(const char *specialfile) __THROW; -/* Flags that can be altered by MS_REMOUNT */ -#define MS_RMT_MASK (MS_RDONLY | MS_MANDLOCK) +int umount(const char *dir) __THROW; +int umount2(const char *specialfile, int mflag) __THROW; -/* Magic mount flag number. Has to be or-ed to the flag values. */ +int umount2(const char *dir, int mflag) __THROW; -#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number to indicate "new" flags */ -#define MS_MGC_MSK 0xffff0000 /* Magic flag number mask */ - - -/* The read-only stuff doesn't really belong here, but any other place - is probably as bad and I don't want to create yet another include - file. */ - -#define BLKROSET _IO(0x12, 93) /* Set device read-only (0 = read-write). */ -#define BLKROGET _IO(0x12, 94) /* Get read-only status (0 = read_write). */ -#define BLKRRPART _IO(0x12, 95) /* Re-read partition table. */ -#define BLKGETSIZE _IO(0x12, 96) /* Return device size. */ -#define BLKFLSBUF _IO(0x12, 97) /* Flush buffer cache. */ -#define BLKRASET _IO(0x12, 98) /* Set read ahead for block device. */ -#define BLKRAGET _IO(0x12, 99) /* Get current read ahead setting. */ - - -/* Possible value for FLAGS parameter of `umount2'. */ -enum -{ - MNT_FORCE = 1 /* Force unmounting. */ -#define MNT_FORCE MNT_FORCE -}; - - -/* Mount a filesystem. */ -int mount(const char *specialfile, const char *dir, const char *filesystemtype, unsigned long rwflag, const void *data) __THROW; - -/* Unmount a filesystem. */ -extern int umount (const char *__special_file) __THROW; - -/* Unmount a filesystem. Force unmounting if FLAGS is set to MNT_FORCE. */ -extern int umount2 (const char *__special_file, int __flags) __THROW; - -#endif /* _SYS_MOUNT_H */ +#endif diff --git a/mdk-stage1/dietlibc/include/sys/msg.h b/mdk-stage1/dietlibc/include/sys/msg.h new file mode 100644 index 000000000..ea1e470b6 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/msg.h @@ -0,0 +1,13 @@ +#ifndef _SYS_MSG_H +#define _SYS_MSG_H + +#include <linux/msg.h> +#include <sys/ipc.h> +#include <asm/page.h> + +extern int msgctl (int msqid, int cmd, struct msqid_ds *buf) __THROW; +extern int msgget (key_t key, int msgflg) __THROW; +extern int msgrcv (int msqid, void *msgp, size_t msgsz, long int msgtyp, int msgflg) __THROW; +extern int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg) __THROW; + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/mtio.h b/mdk-stage1/dietlibc/include/sys/mtio.h new file mode 100644 index 000000000..e70663407 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/mtio.h @@ -0,0 +1,6 @@ +#ifndef _SYS_MTIO_H +#define _SYS_MTIO_H + +#include <linux/mtio.h> + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/param.h b/mdk-stage1/dietlibc/include/sys/param.h new file mode 100644 index 000000000..05f4d40e2 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/param.h @@ -0,0 +1,8 @@ +#ifndef _SYS_PARAM_H +#define _SYS_PARAM_H + +#include <limits.h> + +#define MAXPATHLEN PATH_MAX + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/poll.h b/mdk-stage1/dietlibc/include/sys/poll.h new file mode 100644 index 000000000..adce26687 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/poll.h @@ -0,0 +1,11 @@ +#ifndef _SYS_POLL_H +#define _SYS_POLL_H + +#include <sys/cdefs.h> + +#include <linux/poll.h> + +extern int poll(struct pollfd *ufds, unsigned int nfds, int timeout) __THROW; + + +#endif /* _SYS_POLL_H */ diff --git a/mdk-stage1/dietlibc/include/sys/ptrace.h b/mdk-stage1/dietlibc/include/sys/ptrace.h new file mode 100644 index 000000000..9dd730bc6 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/ptrace.h @@ -0,0 +1,10 @@ +#ifndef _SYS_PTRACE_H +#define _SYS_PTRACE_H + +#include <sys/cdefs.h> + +#include <linux/ptrace.h> + +extern long int ptrace (int request, ...) __THROW; + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/reboot.h b/mdk-stage1/dietlibc/include/sys/reboot.h new file mode 100644 index 000000000..ba58d296a --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/reboot.h @@ -0,0 +1,9 @@ +#ifndef _SYS_REBOOT_H +#define _SYS_REBOOT_H + +#include <linux/reboot.h> + +/* Reboot or halt the system. */ +int reboot (int flag, void *arg); + +#endif /* _SYS_REBOOT_H */ diff --git a/mdk-stage1/dietlibc/include/sys/resource.h b/mdk-stage1/dietlibc/include/sys/resource.h index 953fc0eb2..442434cd1 100644 --- a/mdk-stage1/dietlibc/include/sys/resource.h +++ b/mdk-stage1/dietlibc/include/sys/resource.h @@ -4,4 +4,13 @@ #include <sys/cdefs.h> #include <linux/resource.h> +int getpriority(int which, int who) __THROW; +int setpriority(int which, int who, int prio) __THROW; + +int getrlimit (int resource, struct rlimit *rlim); +int getrusage (int who, struct rusage *usage); +int setrlimit (int resource, const struct rlimit *rlim); + +typedef unsigned long rlim_t; + #endif diff --git a/mdk-stage1/dietlibc/include/sys/select.h b/mdk-stage1/dietlibc/include/sys/select.h index fa166a530..e69de29bb 100644 --- a/mdk-stage1/dietlibc/include/sys/select.h +++ b/mdk-stage1/dietlibc/include/sys/select.h @@ -1,6 +0,0 @@ -#ifndef _SYS_SELECT_H -#define _SYS_SELECT_H 1 - -int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); - -#endif diff --git a/mdk-stage1/dietlibc/include/sys/sem.h b/mdk-stage1/dietlibc/include/sys/sem.h new file mode 100644 index 000000000..cc182649c --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/sem.h @@ -0,0 +1,11 @@ +#ifndef _SYS_SEM_H +#define _SYS_SEM_H + +#include <linux/sem.h> +#include <sys/ipc.h> + +extern int semget( key_t key, int nsems, int semflg) __THROW; +extern int semctl(int semid, int semnum, int cmd, union semun arg) __THROW; +extern int semop(int semid, struct sembuf *sops, unsigned nsops) __THROW; + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/sendfile.h b/mdk-stage1/dietlibc/include/sys/sendfile.h new file mode 100644 index 000000000..2e0c04add --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/sendfile.h @@ -0,0 +1,9 @@ +#ifndef _SYS_SENDFILE_H +#define _SYS_SENDFILE_H + +#include <sys/cdefs.h> + +extern ssize_t sendfile (int __out_fd, int __in_fd, off_t *offset, + size_t __count) __THROW; + +#endif /* sys/sendfile.h */ diff --git a/mdk-stage1/dietlibc/include/sys/shm.h b/mdk-stage1/dietlibc/include/sys/shm.h new file mode 100644 index 000000000..c27f5ddcf --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/shm.h @@ -0,0 +1,17 @@ +#ifndef _SYS_SHM_H +#define _SYS_SHM_H + +#include <linux/shm.h> +#include <sys/ipc.h> +#include <asm/page.h> + +#ifndef PAGE_SIZE +#define PAGE_SIZE getpagesize() +#endif + +extern int shmget(key_t key, int size, int shmflg) __THROW; +extern void *shmat(int shmid, const void *shmaddr, int shmflg) __THROW; +extern int shmdt (const void *shmaddr) __THROW; +extern int shmctl(int shmid, int cmd, struct shmid_ds *buf) __THROW; + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/signal.h b/mdk-stage1/dietlibc/include/sys/signal.h new file mode 100644 index 000000000..2e602dad8 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/signal.h @@ -0,0 +1 @@ +#include <signal.h> diff --git a/mdk-stage1/dietlibc/include/sys/socket.h b/mdk-stage1/dietlibc/include/sys/socket.h index f590c35c4..a1435501c 100644 --- a/mdk-stage1/dietlibc/include/sys/socket.h +++ b/mdk-stage1/dietlibc/include/sys/socket.h @@ -1,21 +1,46 @@ #ifndef _SYS_SOCKET_H #define _SYS_SOCKET_H +#include <sys/cdefs.h> #include <sys/types.h> #include <linux/socket.h> -int socket(int domain, int type, int protocol); -int listen (int fd, int n); -int accept(int s, struct sockaddr *addr, socklen_t *addrlen); -int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen); -int bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); -int recv(int s, void *buf, size_t len, int flags); -int recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); -int recvmsg(int s, struct msghdr *msg, int flags); -int send(int s, const void *msg, size_t len, int flags); -int sendto(int s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); -int sendmsg(int s, const struct msghdr *msg, int flags); -int getpeername(int s, struct sockaddr *name, socklen_t *namelen); -int getsockname(int s , struct sockaddr * name , socklen_t * namelen ); +#ifndef SOCK_DGRAM +/* the Linux kernel headers suck really badly on non-x86 */ +#define SOCK_STREAM 1 /* stream (connection) socket */ +#define SOCK_DGRAM 2 /* datagram (conn.less) socket */ +#define SOCK_RAW 3 /* raw socket */ +#define SOCK_RDM 4 /* reliably-delivered message */ +#define SOCK_SEQPACKET 5 /* sequential packet socket */ +#define SOCK_PACKET 10 /* linux specific way of */ +#endif + +struct sockaddr_storage { + char __tmp[sizeof(struct sockaddr)]; +}; + +int socket(int domain, int type, int protocol) __THROW; +int accept(int s, struct sockaddr *addr, socklen_t *addrlen) __THROW; +int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) __THROW; +int bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) __THROW; +int recv(int s, void *buf, size_t len, int flags) __THROW; +int recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen) __THROW; +int recvmsg(int s, struct msghdr *msg, int flags) __THROW; +int send(int s, const void *msg, size_t len, int flags) __THROW; +int sendto(int s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) __THROW; +int sendmsg(int s, const struct msghdr *msg, int flags) __THROW; + +int getpeername(int s, struct sockaddr *name, socklen_t *namelen) __THROW; +int getsockname(int s , struct sockaddr * name , socklen_t * namelen) __THROW; + +int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) __THROW; +int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) __THROW; + +int listen(int s, int backlog) __THROW; + +#define SHUT_RD 0 +#define SHUT_WR 1 +#define SHUT_RDWR 2 +int shutdown(int s, int how) __THROW; #endif diff --git a/mdk-stage1/dietlibc/include/sys/stat.h b/mdk-stage1/dietlibc/include/sys/stat.h index 7c3504218..10fddfa42 100644 --- a/mdk-stage1/dietlibc/include/sys/stat.h +++ b/mdk-stage1/dietlibc/include/sys/stat.h @@ -7,32 +7,32 @@ #include <linux/stat.h> #include <asm/stat.h> -#ifdef __alpha__ +#ifndef STAT64_HAS_BROKEN_ST_INO #define __NO_STAT64 #endif -#define stat(file,buf) __dietstat(file,buf) -#define fstat(file,buf) __dietfstat(file,buf) -#define lstat(file,buf) __dietlstat(file,buf) +extern int stat(const char *__file, struct stat *__buf) __THROW; +extern int fstat(int __fd, struct stat *__buf) __THROW; +extern int lstat(const char *__file, struct stat *__buf) __THROW; -#define stat64(file,buf) __dietstat64(file,buf) -#define fstat64(file,buf) __dietfstat64(file,buf) -#define lstat64(file,buf) __dietlstat64(file,buf) +#ifdef __NO_STAT64 +#undef _FILE_OFFSET_BITS +#else +extern int stat64(const char *__file, struct stat64 *__buf) __THROW; +extern int fstat64(int __fd, struct stat64 *__buf) __THROW; +extern int lstat64(const char *__file, struct stat64 *__buf) __THROW; +#endif + +#if _FILE_OFFSET_BITS == 64 +#define lstat(file,buf) lstat64(file,buf) +#define fstat(file,buf) fstat64(file,buf) +#define stat stat64 +#endif #define major(dev) (((dev)>>8) & 0xff) #define minor(dev) ((dev) & 0xff) #define makedev(major, minor) ((((unsigned int) (major)) << 8) | ((unsigned int) (minor))) -extern int __dietstat (const char *__file, struct stat *__buf) __THROW; -extern int __dietfstat (int __fd, struct stat *__buf) __THROW; -extern int __dietlstat (const char *__file, struct stat *__buf) __THROW; - -#ifndef __NO_STAT64 -extern int __dietstat64 (const char *__file, struct stat64 *__buf) __THROW; -extern int __dietfstat64 (int __fd, struct stat64 *__buf) __THROW; -extern int __dietlstat64 (const char *__file, struct stat64 *__buf) __THROW; -#endif - extern int chmod (const char *__file, mode_t __mode) __THROW; extern int fchmod (int __fd, mode_t __mode) __THROW; @@ -45,4 +45,8 @@ extern int mknod (const char *__path, mode_t __mode, dev_t __dev) __THROW; extern int mkfifo (const char *__path, mode_t __mode) __THROW; +#define S_IREAD S_IRUSR +#define S_IWRITE S_IWUSR +#define S_IEXEC S_IXUSR + #endif diff --git a/mdk-stage1/dietlibc/include/sys/syscall.h b/mdk-stage1/dietlibc/include/sys/syscall.h new file mode 100644 index 000000000..5d6b5a4ad --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/syscall.h @@ -0,0 +1,6 @@ +#ifndef _SYSCALL_H +#define _SYSCALL_H + +#include <asm/unistd.h> + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/sysinfo.h b/mdk-stage1/dietlibc/include/sys/sysinfo.h new file mode 100644 index 000000000..5f059d469 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/sysinfo.h @@ -0,0 +1,9 @@ +#ifndef _SYS_SYSINFO_H +#define _SYS_SYSINFO_H + +#include <sys/cdefs.h> +#include <linux/kernel.h> + +int sysinfo(struct sysinfo *info) __THROW; + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/syslog.h b/mdk-stage1/dietlibc/include/sys/syslog.h new file mode 100644 index 000000000..91bf0d1fa --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/syslog.h @@ -0,0 +1,102 @@ +#ifndef _SYS_SYSLOG_H +#define _SYS_SYSLOG_H 1 + +#include <sys/cdefs.h> +#include <stdarg.h> + +#define _PATH_LOG "/dev/log" + +/* + * priorities/facilities are encoded into a single 32-bit quantity, where the + * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility + * (0-big number). Both the priorities and the facilities map roughly + * one-to-one to strings in the syslogd(8) source code. This mapping is + * included in this file. + * + * priorities (these are ordered) + */ +#define LOG_EMERG 0 /* system is unusable */ +#define LOG_ALERT 1 /* action must be taken immediately */ +#define LOG_CRIT 2 /* critical conditions */ +#define LOG_ERR 3 /* error conditions */ +#define LOG_WARNING 4 /* warning conditions */ +#define LOG_NOTICE 5 /* normal but significant condition */ +#define LOG_INFO 6 /* informational */ +#define LOG_DEBUG 7 /* debug-level messages */ + +#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ + /* extract priority */ +#define LOG_PRI(p) ((p) & LOG_PRIMASK) +#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) + +/* facility codes */ +#define LOG_KERN (0<<3) /* kernel messages */ +#define LOG_USER (1<<3) /* random user-level messages */ +#define LOG_MAIL (2<<3) /* mail system */ +#define LOG_DAEMON (3<<3) /* system daemons */ +#define LOG_AUTH (4<<3) /* security/authorization messages */ +#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ +#define LOG_LPR (6<<3) /* line printer subsystem */ +#define LOG_NEWS (7<<3) /* network news subsystem */ +#define LOG_UUCP (8<<3) /* UUCP subsystem */ +#define LOG_CRON (9<<3) /* clock daemon */ +#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */ +#define LOG_FTP (11<<3) /* ftp daemon */ + + /* other codes through 15 reserved for system use */ +#define LOG_LOCAL0 (16<<3) /* reserved for local use */ +#define LOG_LOCAL1 (17<<3) /* reserved for local use */ +#define LOG_LOCAL2 (18<<3) /* reserved for local use */ +#define LOG_LOCAL3 (19<<3) /* reserved for local use */ +#define LOG_LOCAL4 (20<<3) /* reserved for local use */ +#define LOG_LOCAL5 (21<<3) /* reserved for local use */ +#define LOG_LOCAL6 (22<<3) /* reserved for local use */ +#define LOG_LOCAL7 (23<<3) /* reserved for local use */ + +#define LOG_NFACILITIES 24 /* current number of facilities */ +#define LOG_FACMASK 0x03f8 /* mask to extract facility part */ + /* facility of pri */ +#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) + +/* + * arguments to setlogmask. + */ +#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ +#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ + +/* + * Option flags for openlog. + * + * LOG_ODELAY no longer does anything. + * LOG_NDELAY is the inverse of what it used to be. + */ +#define LOG_PID 0x01 /* log the pid with each message */ +#define LOG_CONS 0x02 /* log on the console if errors in sending */ +#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ +#define LOG_NDELAY 0x08 /* don't delay open */ +#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ +#define LOG_PERROR 0x20 /* log to stderr as well */ + +/* Open connection to system logger. */ +/* against the glibc-routine ident has not to be const ! */ +/* instead ident is limited to 80 characters ! */ +void openlog (const char *ident, int option, int facility); + +void closelog (void) __THROW; + +int setlogmask (int mask) __THROW; + +void syslog (int priority, const char *format, ...) __THROW; + +void vsyslog (int priority, const char *format, va_list arg_ptr) __THROW; + +/* yuck yuck yuck, only needed for syslogd. */ +typedef struct _code { + char *c_name; + int c_val; +} CODE; + +extern CODE prioritynames[]; +extern CODE facilitynames[]; + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/time.h b/mdk-stage1/dietlibc/include/sys/time.h index 069d50a83..11144f57b 100644 --- a/mdk-stage1/dietlibc/include/sys/time.h +++ b/mdk-stage1/dietlibc/include/sys/time.h @@ -21,4 +21,26 @@ int settimeofday(const struct timeval *tv , const struct timezone *tz) __THROW; extern int adjtime (const struct timeval *__delta, struct timeval *__olddelta) __THROW; +struct tm +{ + int tm_sec; /* Seconds. [0-60] (1 leap second) */ + int tm_min; /* Minutes. [0-59] */ + int tm_hour; /* Hours. [0-23] */ + int tm_mday; /* Day. [1-31] */ + int tm_mon; /* Month. [0-11] */ + int tm_year; /* Year - 1900. */ + int tm_wday; /* Day of week. [0-6] */ + int tm_yday; /* Days in year.[0-365] */ + int tm_isdst; /* DST. [-1/0/1]*/ + + long int tm_gmtoff; /* Seconds east of UTC. */ + const char *tm_zone; /* Timezone abbreviation. */ +}; + +struct tm* gmtime(const time_t *t) __THROW; +struct tm* gmtime_r(const time_t *t, struct tm *r) __THROW; + +struct tm* localtime(const time_t *t) __THROW; +struct tm* localtime_r(const time_t *t, struct tm *r) __THROW; + #endif diff --git a/mdk-stage1/dietlibc/include/sys/times.h b/mdk-stage1/dietlibc/include/sys/times.h new file mode 100644 index 000000000..7a1db07fa --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/times.h @@ -0,0 +1,6 @@ +#ifndef _SYS_TIMES_H +#define _SYS_TIMES_H + +#include <linux/times.h> + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/uio.h b/mdk-stage1/dietlibc/include/sys/uio.h new file mode 100644 index 000000000..d64fd33c9 --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/uio.h @@ -0,0 +1,9 @@ +#ifndef _SYS_UIO +#define _SYS_UIO 1 + +#include <linux/uio.h> + +int readv(int filedes, const struct iovec *vector, size_t count); +int writev(int filedes, const struct iovec *vector, size_t count); + +#endif diff --git a/mdk-stage1/dietlibc/include/sys/un.h b/mdk-stage1/dietlibc/include/sys/un.h new file mode 100644 index 000000000..213d9290e --- /dev/null +++ b/mdk-stage1/dietlibc/include/sys/un.h @@ -0,0 +1,8 @@ +#ifndef _SYS_UN_H +#define _SYS_UN_H + +#include <sys/cdefs.h> + +#include <linux/un.h> + +#endif /* sys/un.h */ diff --git a/mdk-stage1/dietlibc/include/sys/wait.h b/mdk-stage1/dietlibc/include/sys/wait.h index 91b5da348..eb70112e2 100644 --- a/mdk-stage1/dietlibc/include/sys/wait.h +++ b/mdk-stage1/dietlibc/include/sys/wait.h @@ -3,6 +3,29 @@ #include <sys/cdefs.h> #include <sys/resource.h> +#include <linux/wait.h> + +/* If WIFEXITED(STATUS), the low-order 8 bits of the status. */ +#define __WEXITSTATUS(status) (((status) & 0xff00) >> 8) +#define WEXITSTATUS __WEXITSTATUS + +/* If WIFSIGNALED(STATUS), the terminating signal. */ +#define __WTERMSIG(status) ((status) & 0x7f) +#define WTERMSIG __WTERMSIG + +/* If WIFSTOPPED(STATUS), the signal that stopped the child. */ +#define __WSTOPSIG(status) __WEXITSTATUS(status) +#define WSTOPSIG __WSTOPSIG + +/* Nonzero if STATUS indicates normal termination. */ +#define WIFEXITED(status) (__WTERMSIG(status) == 0) + +/* Nonzero if STATUS indicates termination by a signal. */ +#define WIFSIGNALED(status) (!WIFSTOPPED(status) && !WIFEXITED(status)) + +/* Nonzero if STATUS indicates the child is stopped. */ +#define WIFSTOPPED(status) (((status) & 0xff) == 0x7f) + pid_t wait(int *status) __THROW; pid_t waitpid(pid_t pid, int *status, int options) __THROW; diff --git a/mdk-stage1/dietlibc/include/syslog.h b/mdk-stage1/dietlibc/include/syslog.h new file mode 100644 index 000000000..830b4928a --- /dev/null +++ b/mdk-stage1/dietlibc/include/syslog.h @@ -0,0 +1 @@ +#include <sys/syslog.h> diff --git a/mdk-stage1/dietlibc/include/termios.h b/mdk-stage1/dietlibc/include/termios.h index fc297ea19..4c4b8f4dc 100644 --- a/mdk-stage1/dietlibc/include/termios.h +++ b/mdk-stage1/dietlibc/include/termios.h @@ -1,178 +1,21 @@ #ifndef _TERMIOS_H #define _TERMIOS_H -typedef unsigned char cc_t; -typedef unsigned int speed_t; -typedef unsigned int tcflag_t; - -#define NCCS 32 -struct termios - { - tcflag_t c_iflag; /* input mode flags */ - tcflag_t c_oflag; /* output mode flags */ - tcflag_t c_cflag; /* control mode flags */ - tcflag_t c_lflag; /* local mode flags */ - cc_t c_line; /* line discipline */ - cc_t c_cc[NCCS]; /* control characters */ - speed_t c_ispeed; /* input speed */ - speed_t c_ospeed; /* output speed */ - }; - -/* c_cc characters */ -#define VINTR 0 -#define VQUIT 1 -#define VERASE 2 -#define VKILL 3 -#define VEOF 4 -#define VTIME 5 -#define VMIN 6 -#define VSWTC 7 -#define VSTART 8 -#define VSTOP 9 -#define VSUSP 10 -#define VEOL 11 -#define VREPRINT 12 -#define VDISCARD 13 -#define VWERASE 14 -#define VLNEXT 15 -#define VEOL2 16 - -/* c_iflag bits */ -#define IGNBRK 0000001 -#define BRKINT 0000002 -#define IGNPAR 0000004 -#define PARMRK 0000010 -#define INPCK 0000020 -#define ISTRIP 0000040 -#define INLCR 0000100 -#define IGNCR 0000200 -#define ICRNL 0000400 -#define IUCLC 0001000 -#define IXON 0002000 -#define IXANY 0004000 -#define IXOFF 0010000 -#define IMAXBEL 0020000 - -/* c_oflag bits */ -#define OPOST 0000001 -#define OLCUC 0000002 -#define ONLCR 0000004 -#define OCRNL 0000010 -#define ONOCR 0000020 -#define ONLRET 0000040 -#define OFILL 0000100 -#define OFDEL 0000200 -#define NLDLY 0000400 -#define NL0 0000000 -#define NL1 0000400 -#define CRDLY 0003000 -#define CR0 0000000 -#define CR1 0001000 -#define CR2 0002000 -#define CR3 0003000 -#define TABDLY 0014000 -#define TAB0 0000000 -#define TAB1 0004000 -#define TAB2 0010000 -#define TAB3 0014000 -#define BSDLY 0020000 -#define BS0 0000000 -#define BS1 0020000 -#define FFDLY 0100000 -#define FF0 0000000 -#define FF1 0100000 - -#define VTDLY 0040000 -#define VT0 0000000 -#define VT1 0040000 - -#define XTABS 0014000 - -/* c_cflag bit meaning */ -#define CBAUD 0010017 -#define B0 0000000 /* hang up */ -#define B50 0000001 -#define B75 0000002 -#define B110 0000003 -#define B134 0000004 -#define B150 0000005 -#define B200 0000006 -#define B300 0000007 -#define B600 0000010 -#define B1200 0000011 -#define B1800 0000012 -#define B2400 0000013 -#define B4800 0000014 -#define B9600 0000015 -#define B19200 0000016 -#define B38400 0000017 -#define EXTA B19200 -#define EXTB B38400 -#define CSIZE 0000060 -#define CS5 0000000 -#define CS6 0000020 -#define CS7 0000040 -#define CS8 0000060 -#define CSTOPB 0000100 -#define CREAD 0000200 -#define PARENB 0000400 -#define PARODD 0001000 -#define HUPCL 0002000 -#define CLOCAL 0004000 -#define CBAUDEX 0010000 -#define B57600 0010001 -#define B115200 0010002 -#define B230400 0010003 -#define B460800 0010004 -#define B500000 0010005 -#define B576000 0010006 -#define B921600 0010007 -#define B1000000 0010010 -#define B1152000 0010011 -#define B1500000 0010012 -#define B2000000 0010013 -#define B2500000 0010014 -#define B3000000 0010015 -#define B3500000 0010016 -#define B4000000 0010017 -#define CIBAUD 002003600000 /* input baud rate (not used) */ -#define CRTSCTS 020000000000 /* flow control */ - -/* c_lflag bits */ -#define ISIG 0000001 -#define ICANON 0000002 -#define XCASE 0000004 -#define ECHO 0000010 -#define ECHOE 0000020 -#define ECHOK 0000040 -#define ECHONL 0000100 -#define NOFLSH 0000200 -#define TOSTOP 0000400 -#define ECHOCTL 0001000 -#define ECHOPRT 0002000 -#define ECHOKE 0004000 -#define FLUSHO 0010000 -#define PENDIN 0040000 -#define IEXTEN 0100000 - -/* tcflow() and TCXONC use these */ -#define TCOOFF 0 -#define TCOON 1 -#define TCIOFF 2 -#define TCION 3 - -/* tcflush() and TCFLSH use these */ -#define TCIFLUSH 0 -#define TCOFLUSH 1 -#define TCIOFLUSH 2 - -/* tcsetattr uses these */ -#define TCSANOW 0 -#define TCSADRAIN 1 -#define TCSAFLUSH 2 - - -#define _IOT_termios /* Hurd ioctl type field. */ \ - _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2) +#include <sys/cdefs.h> +#include <sys/types.h> + +/* man, the Linux kernel headers suck */ +#define __USE_BSD +#include <linux/termios.h> +#undef __USE_BSD + +pid_t tcgetpgrp(int fd) __THROW; +int tcsetpgrp(int fd, pid_t pgrpid) __THROW; +int tcgetattr(int fd, struct termios *termios_p) __THROW; +int tcsetattr(int fd, int optional_actions, struct termios *termios_p) __THROW; +speed_t cfgetospeed(struct termios *termios_p) __THROW; +int cfsetospeed(struct termios *termios_p, speed_t speed) __THROW; +speed_t cfgetispeed(struct termios *termios_p) __THROW; +int cfsetispeed(struct termios *termios_p, speed_t speed) __THROW; #endif diff --git a/mdk-stage1/dietlibc/include/time.h b/mdk-stage1/dietlibc/include/time.h index adc3710a4..827c85b97 100644 --- a/mdk-stage1/dietlibc/include/time.h +++ b/mdk-stage1/dietlibc/include/time.h @@ -4,28 +4,21 @@ #include <sys/cdefs.h> #include <sys/time.h> -struct tm -{ - int tm_sec; /* Seconds. [0-60] (1 leap second) */ - int tm_min; /* Minutes. [0-59] */ - int tm_hour; /* Hours. [0-23] */ - int tm_mday; /* Day. [1-31] */ - int tm_mon; /* Month. [0-11] */ - int tm_year; /* Year - 1900. */ - int tm_wday; /* Day of week. [0-6] */ - int tm_yday; /* Days in year.[0-365] */ - int tm_isdst; /* DST. [-1/0/1]*/ - - long int tm_gmtoff; /* Seconds east of UTC. */ - const char *tm_zone; /* Timezone abbreviation. */ -}; - -# define __isleap(year) \ - ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) +extern int __isleap(int year); int nanosleep(const struct timespec *req, struct timespec *rem) __THROW; unsigned int sleep(unsigned int secs) __THROW; -struct tm *localtime(const time_t *timep) __THROW; +time_t mktime(struct tm *timeptr) __THROW __pure__; + +char *asctime(const struct tm *timeptr) __THROW; +char *asctime_r(const struct tm *timeptr, char *buf) __THROW; + +char *ctime(const time_t *timep) __THROW; + +size_t strftime(char *s, size_t max, const char *format, const struct tm *tm) __THROW; +time_t time(time_t *t) __THROW; + +int stime(time_t *t) __THROW; #endif diff --git a/mdk-stage1/dietlibc/include/unistd.h b/mdk-stage1/dietlibc/include/unistd.h index 5165ba286..1a528c0e4 100644 --- a/mdk-stage1/dietlibc/include/unistd.h +++ b/mdk-stage1/dietlibc/include/unistd.h @@ -1,17 +1,40 @@ #ifndef _UNISTD_H #define _UNISTD_H -#include <dirent.h> #include <sys/cdefs.h> +#include <dirent.h> #include <sys/types.h> +#include <sys/time.h> +#include <getopt.h> +#include <linux/sysctl.h> +#include <sys/stat.h> + +/* Values for the second argument to access. + These may be OR'd together. */ +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ -const enum { - SEEK_SET=0, - SEEK_CUR=1, - SEEK_END=2 -} __seek_types; +/* Test for access to NAME using the real UID and real GID. */ +extern int access (__const char *__name, int __type) __THROW; + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 off_t lseek(int fildes, off_t offset, int whence) __THROW; +int llseek(int fildes, unsigned long hi, unsigned long lo, loff_t* result,int whence) __THROW; +#ifndef __NO_STAT64 +loff_t lseek64(int fildes, loff_t offset, int whence) __THROW; +#endif +#if _FILE_OFFSET_BITS == 64 +#define lseek(fildes,offset,whence) lseek64(fildes,offset,whence) +#endif int chdir(const char *path) __THROW; int fchdir(int fd) __THROW; @@ -20,39 +43,56 @@ int rmdir(const char *pathname) __THROW; char *getcwd(char *buf, size_t size) __THROW; int open(const char* pathname,int flags, ...) __THROW; +int open64(const char* pathname,int flags, ...) __THROW; int creat(const char* pathname,mode_t mode) __THROW; +int creat64(const char* pathname,mode_t mode) __THROW; int write(int fd,const void* buf,size_t len) __THROW; -int read(int fd,const void* buf,size_t len) __THROW; +int read(int fd,void* buf,size_t len) __THROW; int close(int fd) __THROW; +int unlink(const char *pathname) __THROW; + int pread(int fd, void *buf, size_t count, off_t offset); int pwrite(int fd, const void *buf, size_t count, off_t offset); -int execve (const char *filename, char *const argv [], char *const envp[]) __THROW; -int execl( const char *path, ...); -int execv (const char *__path, char *const __argv[]) __THROW; +int execve(const char *filename, char *const argv [], char *const envp[]) __THROW; +int execlp(const char *file, const char *arg, ...) __THROW; +int execv(const char *path, char *const argv[]) __THROW; +int execvp(const char *file, char *const argv[]) __THROW; +int execl(const char *path, ...) __THROW; -pid_t getpid(void) __attribute__((const)) __THROW; +pid_t getpid(void) __attribute__((__const__)) __THROW; pid_t getppid(void) __THROW; int kill(pid_t pid, int sig) __THROW; +int setpgid (pid_t pid,pid_t pgid) __THROW; +pid_t getpgid (pid_t pid) __THROW; +int setpgrp (void) __THROW; +pid_t getpgrp (void) __THROW; +pid_t setsid (void) __THROW; +int dup (int oldfd) __THROW; +int dup2 (int oldfd,int newfd) __THROW; + int mknod(const char *pathname, mode_t mode, dev_t dev) __THROW; int getdents(unsigned int fd, struct dirent *dirp, unsigned int count) __THROW; int getdents64(unsigned int fd, struct dirent64 *dirp, unsigned int count) __THROW; -pid_t fork() __THROW; -pid_t vfork() __THROW; +pid_t fork(void) __THROW; +pid_t vfork(void) __THROW; int readlink(const char *path, char *buf, size_t bufsiz) __THROW; int symlink(const char *oldpath, const char *newpath) __THROW; int link(const char *oldpath, const char *newpath) __THROW; -int unlink (const char *__name) __THROW; int chown(const char *path, uid_t owner, gid_t group) __THROW; int fchown(int fd, uid_t owner, gid_t group) __THROW; int lchown(const char *path, uid_t owner, gid_t group) __THROW; +int fsync(int fd) __THROW; + +int pipe(int filedes[2]) __THROW; + char *ttyname (int desc) __THROW; int brk(void *end_data_segment) __THROW; @@ -61,23 +101,68 @@ void *sbrk(ptrdiff_t increment) __THROW; int gethostname(char *name, size_t len) __THROW; int sethostname(const char *name, size_t len) __THROW; -int setdomainname(const char *name, size_t len) __THROW; +void usleep(unsigned long usec) __THROW; +unsigned int sleep(unsigned int seconds) __THROW; -void sync(void) __THROW; +unsigned int alarm(unsigned int seconds) __THROW; +int sync(void) __THROW; -/* Values for the second argument to access. - These may be OR'd together. */ -#define R_OK 4 /* Test for read permission. */ -#define W_OK 2 /* Test for write permission. */ -#define X_OK 1 /* Test for execute permission. */ -#define F_OK 0 /* Test for existence. */ +int isatty(int desc) __THROW; -int access (char *__name, int __type) __THROW; +void _exit(int status) __THROW __attribute__((noreturn)); -int dup2 (int __fd, int __fd2) __THROW; +extern int daemon (int nochdir,int noclose) __THROW; -pid_t setsid (void) __THROW; +#if _FILE_OFFSET_BITS == 64 +#define open open64 +#define creat creat64 +#endif + +extern char* getlogin(void) __THROW; +/* warning: the diet libc getlogin() simply returns getenv("LOGNAME") */ + +int chroot(const char *path) __THROW; + +uid_t getuid(void) __THROW; +uid_t geteuid(void) __THROW; +gid_t getgid(void) __THROW; +gid_t getegid(void) __THROW; +int setuid(uid_t uid) __THROW; +/* int seteuid(uid_t uid) __THROW; */ +int setgid(gid_t gid) __THROW; +/* int setegid(gid_t gid) __THROW; */ +int setregid(gid_t rgid, gid_t egid) __THROW; +int setreuid(uid_t ruid, uid_t euid) __THROW; +#define seteuid(euid) setreuid(-1,euid) +#define setegid(egid) setregid(-1,egid) + +int rename(const char *oldpath, const char *newpath) __THROW; +int ftruncate(int fd, off_t length) __THROW; + +int mkstemp(char *Template) __THROW; + +int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) __THROW; + +int nice(int inc) __THROW; + +extern char *__environ[]; + +char *crypt(const char *key, const char *salt) __THROW; +void encrypt(char block[64], int edflag) __THROW; +void setkey(const char *key) __THROW; + +size_t getpagesize(void) __attribute__((__const__)) __THROW; + +int getdomainname(char *name, size_t len) __THROW; +int setdomainname(const char *name, size_t len) __THROW; + +int getgroups(int size, gid_t list[]) __THROW; + +/* warning: linux specific: */ +int _sysctl(struct __sysctl_args *args) __THROW; +int sendfile(int out_fd, int in_fd, off_t *offset, size_t count) __THROW; -unsigned int sleep (unsigned int __seconds) __THROW; +int getdtablesize(void) __THROW; +char *getpass(const char * prompt) __THROW; #endif diff --git a/mdk-stage1/dietlibc/include/utmp.h b/mdk-stage1/dietlibc/include/utmp.h index 2f598257c..2946be921 100644 --- a/mdk-stage1/dietlibc/include/utmp.h +++ b/mdk-stage1/dietlibc/include/utmp.h @@ -38,6 +38,7 @@ struct utmp char ut_id[4]; /* Inittab ID. */ char ut_user[UT_NAMESIZE]; /* Username. */ char ut_host[UT_HOSTSIZE]; /* Hostname for remote login. */ +#define ut_name ut_host struct exit_status ut_exit; /* Exit status of a process marked as DEAD_PROCESS. */ long int ut_session; /* Session ID, used for windowing. */ diff --git a/mdk-stage1/dietlibc/lib/__dtostr.c b/mdk-stage1/dietlibc/lib/__dtostr.c index def091f16..e9a8a83d3 100644 --- a/mdk-stage1/dietlibc/lib/__dtostr.c +++ b/mdk-stage1/dietlibc/lib/__dtostr.c @@ -1,3 +1,4 @@ +#include <stdio.h> /* convert double to string. Helper for sprintf. */ int __dtostr(double d,char *buf,int maxlen,int prec) { @@ -14,8 +15,14 @@ int __dtostr(double d,char *buf,int maxlen,int prec) { char *oldbuf=buf; int initial=1; + if (d==0.0) { + *buf='0'; ++buf; + goto done; + } if (s) { d=-d; *buf='-'; --maxlen; buf++; } - if ((i=e10)>=0) { +/* printf("e=%d e10=%d prec=%d\n",e,e10,prec); */ + if (e10>=0) { + i=e10; while (i>10) { tmp=tmp*1e10; i-=10; } while (i>1) { tmp=tmp*10; --i; } } else { @@ -52,6 +59,20 @@ int __dtostr(double d,char *buf,int maxlen,int prec) { } /* step 5: loop through the digits, inserting the decimal point when * appropriate */ + if (d<1.0) { + double x=1.0; + int first=1; + do { + if (--maxlen<0) return buf-oldbuf; + *buf='0'; ++buf; + if (first) { + first=0; + *buf='.'; ++buf; + if (--maxlen<0) return buf-oldbuf; + } + x/=10.0; + } while (x>d); + } for (; prec>0; ) { double tmp2=d/tmp; char c; @@ -77,6 +98,7 @@ int __dtostr(double d,char *buf,int maxlen,int prec) { } else tmp/=10.0; } +done: *buf=0; return buf-oldbuf; } diff --git a/mdk-stage1/dietlibc/lib/__fstat64.c b/mdk-stage1/dietlibc/lib/__fstat64.c new file mode 100644 index 000000000..6f9fcb2c5 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__fstat64.c @@ -0,0 +1,25 @@ +#include "dietfeatures.h" + +#ifdef WANT_LARGEFILE_BACKCOMPAT +#include <sys/stat.h> +#ifndef __NO_STAT64 +#include <errno.h> + +extern int __dietlibc_fstat64(int __fd, struct stat64 *__buf); +extern void __stat64_cvt(const struct stat *src,struct stat64 *dest); + +int fstat64(int __fd, struct stat64 *__buf) { + if (__dietlibc_fstat64(__fd,__buf)) { + struct stat temp; +#ifdef WANT_THREAD_SAFE + if (*__errno_location()!=ENOSYS) return -1; +#else + if (errno!=ENOSYS) return -1; +#endif + if (fstat(__fd,&temp)) return -1; + __stat64_cvt(&temp,__buf); + } + return 0; +} +#endif +#endif diff --git a/mdk-stage1/dietlibc/lib/__getcwd.c b/mdk-stage1/dietlibc/lib/__getcwd.c new file mode 100644 index 000000000..e97fc4520 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__getcwd.c @@ -0,0 +1,10 @@ +#include <stdlib.h> + +extern int __syscall_getcwd(char* buf, size_t size); + +char *getcwd(char *buf, size_t size) { + int tmp; + if ((tmp=__syscall_getcwd(buf,size))<0) return 0; + buf[tmp]=0; + return buf; +} diff --git a/mdk-stage1/dietlibc/lib/__isnan.c b/mdk-stage1/dietlibc/lib/__isnan.c new file mode 100644 index 000000000..9d21e9824 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__isnan.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +int __isnan(double d) { + unsigned long long *x=(unsigned long long *)&d; + return (*x==0x7FF8002000000000ll || *x==0x7FF0002000000000); +} + +#if 0 +TestFromIeeeExtended("7FFF0000000000000000"); /* +infinity */ +TestFromIeeeExtended("FFFF0000000000000000"); /* -infinity */ +TestFromIeeeExtended("7FFF8001000000000000"); /* Quiet NaN(1) */ +TestFromIeeeExtended("7FFF0001000000000000"); /* Signalling NaN(1) */ +TestFromIeeeExtended("3FFFFEDCBA9876543210"); /* accuracy test */ +#endif diff --git a/mdk-stage1/dietlibc/lib/__lltostr.c b/mdk-stage1/dietlibc/lib/__lltostr.c index f53dcfb80..eb4a27cef 100644 --- a/mdk-stage1/dietlibc/lib/__lltostr.c +++ b/mdk-stage1/dietlibc/lib/__lltostr.c @@ -1,7 +1,5 @@ #include <string.h> -static char *num="0123456789abcdefghijklmnopqrstuvwxyz"; - int __lltostr(char *s, int size, unsigned long long i, int base, char UpCase) { char *tmp; @@ -23,8 +21,7 @@ int __lltostr(char *s, int size, unsigned long long i, int base, char UpCase) while((tmp>s)&&(i)) { tmp--; - *tmp=num[i%base]; - if ((UpCase)&&(*tmp>96)) (*tmp)-=' '; + if ((*tmp=i%base+'0')>'9') *tmp+=(UpCase?'A':'a')-'9'-1; i=i/base; j++; } diff --git a/mdk-stage1/dietlibc/lib/__lstat64.c b/mdk-stage1/dietlibc/lib/__lstat64.c new file mode 100644 index 000000000..a871f3917 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__lstat64.c @@ -0,0 +1,25 @@ +#include "dietfeatures.h" + +#ifdef WANT_LARGEFILE_BACKCOMPAT +#include <sys/stat.h> +#ifndef __NO_STAT64 +#include <errno.h> + +extern int __dietlibc_lstat64(const char *__file, struct stat64 *__buf); +extern void __stat64_cvt(const struct stat *src,struct stat64 *dest); + +int lstat64(const char *__file, struct stat64 *__buf) { + if (__dietlibc_lstat64(__file,__buf)) { + struct stat temp; +#ifdef WANT_THREAD_SAFE + if (*__errno_location()!=ENOSYS) return -1; +#else + if (errno!=ENOSYS) return -1; +#endif + if (lstat(__file,&temp)) return -1; + __stat64_cvt(&temp,__buf); + } + return 0; +} +#endif +#endif diff --git a/mdk-stage1/dietlibc/lib/__ltostr.c b/mdk-stage1/dietlibc/lib/__ltostr.c index b2ebeb074..57e0690d2 100644 --- a/mdk-stage1/dietlibc/lib/__ltostr.c +++ b/mdk-stage1/dietlibc/lib/__ltostr.c @@ -1,7 +1,5 @@ #include <string.h> -static char *num="0123456789abcdefghijklmnopqrstuvwxyz"; - int __ltostr(char *s, int size, unsigned long i, int base, char UpCase) { char *tmp; @@ -23,8 +21,7 @@ int __ltostr(char *s, int size, unsigned long i, int base, char UpCase) while((tmp>s)&&(i)) { tmp--; - *tmp=num[i%base]; - if ((UpCase)&&(*tmp>96)) (*tmp)-=' '; + if ((*tmp=i%base+'0')>'9') *tmp+=(UpCase?'A':'a')-'9'-1; i=i/base; j++; } diff --git a/mdk-stage1/dietlibc/lib/__stat64.c b/mdk-stage1/dietlibc/lib/__stat64.c new file mode 100644 index 000000000..dfb0d4315 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__stat64.c @@ -0,0 +1,25 @@ +#include "dietfeatures.h" + +#ifdef WANT_LARGEFILE_BACKCOMPAT +#include <sys/stat.h> +#ifndef __NO_STAT64 +#include <errno.h> + +extern int __dietlibc_stat64(const char *__file, struct stat64 *__buf); +extern void __stat64_cvt(const struct stat *src,struct stat64 *dest); + +int stat64(const char *__file, struct stat64 *__buf) { + if (__dietlibc_stat64(__file,__buf)) { + struct stat temp; +#ifdef WANT_THREAD_SAFE + if (*__errno_location()!=ENOSYS) return -1; +#else + if (errno!=ENOSYS) return -1; +#endif + if (stat(__file,&temp)) return -1; + __stat64_cvt(&temp,__buf); + } + return 0; +} +#endif +#endif diff --git a/mdk-stage1/dietlibc/lib/__stat64_cvt.c b/mdk-stage1/dietlibc/lib/__stat64_cvt.c new file mode 100644 index 000000000..dced352a4 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/__stat64_cvt.c @@ -0,0 +1,18 @@ +#include <sys/stat.h> +#ifndef __NO_STAT64 + +void __stat64_cvt(const struct stat *src,struct stat64 *dest) { + dest->st_dev=src->st_dev; + dest->st_ino=src->st_ino; + dest->st_mode=src->st_mode; + dest->st_nlink=src->st_nlink; + dest->st_uid=src->st_gid; + dest->st_rdev=src->st_rdev; + dest->st_size=src->st_size; + dest->st_blksize=src->st_blksize; + dest->st_blocks=src->st_blocks; + dest->st_atime=src->st_atime; + dest->st_mtime=src->st_mtime; + dest->st_ctime=src->st_ctime; +} +#endif diff --git a/mdk-stage1/dietlibc/lib/abort.c b/mdk-stage1/dietlibc/lib/abort.c index e6374c5ac..55bfb8f0f 100644 --- a/mdk-stage1/dietlibc/lib/abort.c +++ b/mdk-stage1/dietlibc/lib/abort.c @@ -1,8 +1,7 @@ #include <linux/types.h> #include <linux/signal.h> #include <signal.h> - -extern int exit(int code) __attribute__ ((noreturn)); +#include <stdlib.h> void abort() { sigset_t t; diff --git a/mdk-stage1/dietlibc/lib/accept.c b/mdk-stage1/dietlibc/lib/accept.c index a7ae824eb..c7e8254ca 100644 --- a/mdk-stage1/dietlibc/lib/accept.c +++ b/mdk-stage1/dietlibc/lib/accept.c @@ -2,7 +2,7 @@ extern int socketcall(int callno,long* args); -int accept(int a, void * addr, void * addr2) { +int __libc_accept(int a, void * addr, void * addr2) { #ifdef __i386__ return socketcall(SYS_ACCEPT, (long*)&a); #else @@ -11,4 +11,4 @@ int accept(int a, void * addr, void * addr2) { #endif } -int __libc_accept(int a, void * addr, void * addr2) __attribute__((weak,alias("accept"))); +int accept(int a, void * addr, void * addr2) __attribute__((weak,alias("__libc_accept"))); diff --git a/mdk-stage1/dietlibc/lib/alloc.c b/mdk-stage1/dietlibc/lib/alloc.c index 27b6838df..8cb87a69b 100644 --- a/mdk-stage1/dietlibc/lib/alloc.c +++ b/mdk-stage1/dietlibc/lib/alloc.c @@ -5,6 +5,7 @@ #include <linux/unistd.h> #include <asm/mman.h> #include <linux/errno.h> +#include "dietfeatures.h" #if 0 #include <sys/mman.h> @@ -31,8 +32,10 @@ extern void *memset(void *s, int c, size_t n); extern void *memcpy(void *dest, const void *src, size_t n); typedef struct t_alloc_head { + unsigned int magic1; struct t_alloc_head *ptr; unsigned long size; + unsigned int magic2; } alloc_head; /* guess what ? the virtual block size */ @@ -49,22 +52,28 @@ typedef struct t_alloc_head { #define PAGE_ALIGN(s) (((s)+MEM_BLOCK_SIZE-1)&(~(MEM_BLOCK_SIZE-1))) #define PAGE_ALIGNP(p) ((char*)PAGE_ALIGN((size_t)(p))) -#define END_OF_BLOCK(p) ((alloc_head*)(((char*)(p))+((p)->size))) -#define START_BLOCK(p) ((alloc_head*)(((char*)(p))-sizeof(alloc_head))) -#define START_DATA(p) (((char*)(p))+sizeof(alloc_head)) -#define MIN_ALLOC(s) (((((s)+sizeof(alloc_head)-1)/MEM_ALLOC_MIN)+1)*MEM_ALLOC_MIN) +#define END_OF_BLOCK(p) ((alloc_head*)(((char*)(p))+((p)->size))) +#define START_BLOCK(p) ((alloc_head*)(((char*)(p))-sizeof(alloc_head))) +#define START_DATA(p) (((char*)(p))+sizeof(alloc_head)) +#define MIN_ALLOC(s) (((((s)+sizeof(alloc_head)-1)/MEM_ALLOC_MIN)+1)*MEM_ALLOC_MIN) + +#define ALLOC_MAGIC1 0xbad2f7ee +#define ALLOC_MAGIC2 0xf7ee2bad /* freelist handler */ -static alloc_head base = {&base,0}; +static alloc_head base = {ALLOC_MAGIC1,&base,0,ALLOC_MAGIC2}; static char *alloc_get_end = MEM_ALLOC_START; -void free(void *ptr) +void __libc_free(void *ptr) { alloc_head *prev,*p,*block; if (ptr==NULL) return; block=START_BLOCK(ptr); + if (block->magic1 != ALLOC_MAGIC1) return; + if (block->magic2 != ALLOC_MAGIC2) return; + prev=&base; for (p=prev->ptr ; ; prev=p, p=p->ptr) { @@ -91,6 +100,7 @@ void free(void *ptr) prev->ptr = block->ptr; } } +void free(void *ptr) __attribute__((weak,alias("__libc_free"))); static void *alloc_get_mem(unsigned long size) { @@ -119,16 +129,18 @@ static void *alloc_get_mem(unsigned long size) /* make a header */ ah=(alloc_head*)tmp; + ah->magic1=ALLOC_MAGIC1; + ah->magic2=ALLOC_MAGIC2; ah->ptr=ah; ah->size=size; /* link new free maped pages in freelist */ - free(START_DATA(tmp)); + __libc_free(START_DATA(tmp)); return &base; } -void *malloc(size_t size) +void *__libc_malloc(size_t size) { alloc_head *p, *prev; size_t need; @@ -157,6 +169,8 @@ void *malloc(size_t size) else { prev->ptr=tmp; + tmp->magic1=ALLOC_MAGIC1; + tmp->magic2=ALLOC_MAGIC2; tmp->ptr=p->ptr; tmp->size=p->size-need; /* remaining size */ } @@ -169,11 +183,13 @@ void *malloc(size_t size) } else if (p==&base) { - if ((p=alloc_get_mem(need))==NULL) return NULL; + if ((p=alloc_get_mem(need))==NULL) goto err_out; } } +err_out: return NULL; } +void *malloc(size_t size) __attribute__((weak,alias("__libc_malloc"))); void *calloc(size_t nmemb,size_t size) { @@ -206,10 +222,12 @@ void *realloc(void *ptr,size_t size) } return NULL; } - if (diff>0) + if (diff>=sizeof(alloc_head)) { tmp->size=need; tf=END_OF_BLOCK(tmp); + tf->magic1=ALLOC_MAGIC1; + tf->magic2=ALLOC_MAGIC2; tf->ptr=tf; tf->size=diff; free(START_DATA(tf)); diff --git a/mdk-stage1/dietlibc/lib/assert_fail.c b/mdk-stage1/dietlibc/lib/assert_fail.c index caa70ef5b..3d6ba65c1 100644 --- a/mdk-stage1/dietlibc/lib/assert_fail.c +++ b/mdk-stage1/dietlibc/lib/assert_fail.c @@ -1,6 +1,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include "dietwarning.h" extern int __ltostr(char *s, int size, unsigned long i, int base, char UpCase); @@ -25,3 +26,5 @@ void __assert_fail (const char *assertion, const char *file, unsigned int line, } abort(); } + +link_warning("__assert_fail","warning: your code still has assertions enabled!") diff --git a/mdk-stage1/dietlibc/lib/atexit.c b/mdk-stage1/dietlibc/lib/atexit.c index 2b644bf49..8204af06c 100644 --- a/mdk-stage1/dietlibc/lib/atexit.c +++ b/mdk-stage1/dietlibc/lib/atexit.c @@ -15,9 +15,9 @@ int atexit(function t) { extern void _exit(int code) __attribute__((noreturn)); void exit(int code) { - if (__atexitlist[0]) __atexitlist[0](); - if (__atexitlist[1]) __atexitlist[1](); - if (__atexitlist[2]) __atexitlist[2](); if (__atexitlist[3]) __atexitlist[3](); + if (__atexitlist[2]) __atexitlist[2](); + if (__atexitlist[1]) __atexitlist[1](); + if (__atexitlist[0]) __atexitlist[0](); _exit(code); } diff --git a/mdk-stage1/dietlibc/lib/atof.c b/mdk-stage1/dietlibc/lib/atof.c index 4839e5152..54221390e 100644 --- a/mdk-stage1/dietlibc/lib/atof.c +++ b/mdk-stage1/dietlibc/lib/atof.c @@ -1,5 +1,10 @@ #include <stdlib.h> double atof(const char *nptr) { +#if 0 return strtod(nptr,0); +#else + double tmp=strtod(nptr,0); + return tmp; +#endif } diff --git a/mdk-stage1/dietlibc/lib/bsearch.c b/mdk-stage1/dietlibc/lib/bsearch.c new file mode 100644 index 000000000..d2f5c74b2 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/bsearch.c @@ -0,0 +1,20 @@ +#include <stdlib.h> + +void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) { + const char *v, *r; + int res; + r=base+(nmemb-1)*size; + do { + register int num=nmemb/2; + v=base+num*size; + if ((res=compar(key,v))<0) { + r=v-size; + nmemb=num; + } else { + if (res==0) return (void*)v; + base=v+size; + nmemb-=num; + } + } while ((char*)base<=r); + return 0; +} diff --git a/mdk-stage1/dietlibc/lib/cfgetospeed.c b/mdk-stage1/dietlibc/lib/cfgetospeed.c index 4e392a239..4d70888f7 100644 --- a/mdk-stage1/dietlibc/lib/cfgetospeed.c +++ b/mdk-stage1/dietlibc/lib/cfgetospeed.c @@ -2,5 +2,5 @@ #include <sys/types.h> speed_t cfgetospeed(struct termios *termios_p) { - return termios_p->c_ospeed; + return ((termios_p->c_iflag & (CBAUD|CBAUDEX))); } diff --git a/mdk-stage1/dietlibc/lib/cfmakeraw.c b/mdk-stage1/dietlibc/lib/cfmakeraw.c new file mode 100644 index 000000000..7f6df9913 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/cfmakeraw.c @@ -0,0 +1,14 @@ +#include <termios.h> +#include <sys/ioctl.h> + +void cfmakeraw(struct termios *t) +{ + t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); + t->c_oflag &= ~OPOST; + t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + t->c_cflag &= ~(CSIZE|PARENB); + t->c_cflag |= CS8; + t->c_cc[VMIN] = 1; + t->c_cc[VTIME] = 0; +} + diff --git a/mdk-stage1/dietlibc/lib/closedir.c b/mdk-stage1/dietlibc/lib/closedir.c index c8d834f3b..e73025eb1 100644 --- a/mdk-stage1/dietlibc/lib/closedir.c +++ b/mdk-stage1/dietlibc/lib/closedir.c @@ -1,28 +1,10 @@ -#include <stdlib.h> +#include "dietdirent.h" #include <unistd.h> -#include <errno.h> -#undef _POSIX_PTHREADS -#include "dirstream.h" - -#undef closedir -int closedir(DIR * dir) -{ - int fd; - - if (!dir) { - errno = EBADF; - return -1; - } +#include <dirent.h> +#include <stdlib.h> - /* We need to check dd_fd. */ - if (dir->dd_fd == -1) - { - errno = EBADF; - return -1; - } - fd = dir->dd_fd; - dir->dd_fd = -1; - free(dir->dd_buf); - free(dir); - return close(fd); +int closedir (DIR* d) { + int res=close(d->fd); + free(d); + return res; } diff --git a/mdk-stage1/dietlibc/lib/connect.c b/mdk-stage1/dietlibc/lib/connect.c index f7f4f1ed7..01fd61a6c 100644 --- a/mdk-stage1/dietlibc/lib/connect.c +++ b/mdk-stage1/dietlibc/lib/connect.c @@ -2,7 +2,7 @@ extern int socketcall(int callno,long* args); -int connect(int a, void * b, int c) { +int __libc_connect(int a, void * b, int c) { #ifdef __i386__ return socketcall(SYS_CONNECT, (long*)&a); #else @@ -11,4 +11,4 @@ int connect(int a, void * b, int c) { #endif } -int __libc_connect(int a, void * b, int c) __attribute__((weak,alias("connect"))); +int connect(int a, void * b, int c) __attribute__((weak,alias("__libc_connect"))); diff --git a/mdk-stage1/dietlibc/lib/creat.c b/mdk-stage1/dietlibc/lib/creat.c new file mode 100644 index 000000000..82145b515 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/creat.c @@ -0,0 +1,5 @@ +#include <fcntl.h> + +int creat(const char *file,mode_t mode) { + return open(file,O_WRONLY|O_CREAT|O_TRUNC,mode); +} diff --git a/mdk-stage1/dietlibc/lib/creat64.c b/mdk-stage1/dietlibc/lib/creat64.c index 923c1baaa..8cf897b57 100644 --- a/mdk-stage1/dietlibc/lib/creat64.c +++ b/mdk-stage1/dietlibc/lib/creat64.c @@ -1,5 +1,9 @@ #include <fcntl.h> +#ifndef O_LARGEFILE +#define O_LARGEFILE 0 +#endif + int creat64(const char *file,mode_t mode) { - return open64(file,O_WRONLY|O_CREAT|O_TRUNC,mode); + return open(file,O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE,mode); } diff --git a/mdk-stage1/dietlibc/lib/exec_lib.c b/mdk-stage1/dietlibc/lib/exec_lib.c new file mode 100644 index 000000000..3129224a0 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/exec_lib.c @@ -0,0 +1,20 @@ +#include <unistd.h> +#include <paths.h> + +extern char **environ; + +int __exec_shell(const char *file, char *const argv[]) { + int i; + + for (i = 0; argv[i]; i++); + + { + char *shell_argv[i + 1]; + shell_argv[0] = _PATH_BSHELL; + shell_argv[1] = (char *) file; + for (; i > 1; i--) + shell_argv[i] = argv[i - 1]; + return execve(_PATH_BSHELL, shell_argv, environ); + } +} + diff --git a/mdk-stage1/dietlibc/lib/exec_lib.h b/mdk-stage1/dietlibc/lib/exec_lib.h new file mode 100644 index 000000000..0971bd1fb --- /dev/null +++ b/mdk-stage1/dietlibc/lib/exec_lib.h @@ -0,0 +1,9 @@ +#ifndef __EXEC_LIB_H +#define __EXEC_LIB_H + +#include <paths.h> + +extern int __exec_shell(const char *file, char *const argv[]); + +#endif /* __EXEC_LIB_H */ + diff --git a/mdk-stage1/dietlibc/lib/execl.c b/mdk-stage1/dietlibc/lib/execl.c index ae28fb850..71459e71f 100644 --- a/mdk-stage1/dietlibc/lib/execl.c +++ b/mdk-stage1/dietlibc/lib/execl.c @@ -3,7 +3,7 @@ #include <errno.h> #include <stdlib.h> -int execl( const char *path, ...) { +int execl( const char *path,...) { va_list ap; int n,i; char **argv,*tmp; diff --git a/mdk-stage1/dietlibc/lib/execlp.c b/mdk-stage1/dietlibc/lib/execlp.c new file mode 100644 index 000000000..3aea1e960 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/execlp.c @@ -0,0 +1,26 @@ +#include <stdarg.h> +#include <unistd.h> +#include <errno.h> +#include <stdlib.h> +#include "dietstdarg.h" + +int execlp(const char* file, const char *arg,...) { + va_list ap,bak; + int n,i; + char **argv,*tmp; + va_start(ap, arg); + va_copy(bak,ap); + n=2; + while ((tmp=va_arg(ap,char *))) + ++n; + va_end (ap); + if ((argv=(char **)alloca(n*sizeof(char*)))) { + argv[0]=arg; + for (i=0; i<n; ++i) + argv[i+1]=va_arg(bak,char *); + va_end (bak); + return execvp(file,argv); + } + __set_errno(ENOMEM); + return -1; +} diff --git a/mdk-stage1/dietlibc/lib/execv.c b/mdk-stage1/dietlibc/lib/execv.c new file mode 100644 index 000000000..efd760253 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/execv.c @@ -0,0 +1,13 @@ +#include <limits.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include "exec_lib.h" + +int execv(const char *file, char *const argv[]) { + if (execve(file,argv,environ)==-1) { + if (errno==ENOEXEC) __exec_shell(file,argv); + } + return -1; +} diff --git a/mdk-stage1/dietlibc/lib/execvp.c b/mdk-stage1/dietlibc/lib/execvp.c index 809252990..20521d69f 100644 --- a/mdk-stage1/dietlibc/lib/execvp.c +++ b/mdk-stage1/dietlibc/lib/execvp.c @@ -2,25 +2,8 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <paths.h> #include <errno.h> - -extern char **environ; - -static int exec_shell(const char *file, char *const argv[]) { - int i; - - for (i = 0; argv[i]; i++); - - if (1) { - char *shell_argv[i + 1]; - shell_argv[0] = _PATH_BSHELL; - shell_argv[1] = (char *) file; - for (; i > 1; i--) - shell_argv[i] = argv[i - 1]; - return execve(_PATH_BSHELL, shell_argv, environ); - } -} +#include "exec_lib.h" int execvp(const char *file, char *const argv[]) { char *path=getenv("PATH"); @@ -28,7 +11,7 @@ int execvp(const char *file, char *const argv[]) { char buf[PATH_MAX]; if (strchr((char*)file,'/')) { if (execve(file,argv,environ)==-1) { - if (errno==ENOEXEC) exec_shell(file,argv); + if (errno==ENOEXEC) __exec_shell(file,argv); return -1; } } @@ -45,7 +28,7 @@ int execvp(const char *file, char *const argv[]) { buf[next-cur]='/'; memmove(&buf[next-cur+1],file,strlen(file)+1); if (execve(buf,argv,environ)==-1) { - if (errno==ENOEXEC) return exec_shell(buf,argv); + if (errno==ENOEXEC) return __exec_shell(buf,argv); if ((errno!=EACCES) && (errno!=ENOENT)) return -1; } if (*next==0) break; diff --git a/mdk-stage1/dietlibc/lib/getopt.c b/mdk-stage1/dietlibc/lib/getopt.c new file mode 100644 index 000000000..93097122f --- /dev/null +++ b/mdk-stage1/dietlibc/lib/getopt.c @@ -0,0 +1,118 @@ +#include "getopt.h" +#include <string.h> + +/* + * by Olaf Dreesen + */ + +int opterr; + +int optind=1; +char *optarg; + +static int opt_unknown=1,opt_unknown_len; + +static int getopt_check(int c,char*o,int ol) +{ + int i; + if (c==':') return 2; + for (i=0;i<ol;i++) + { + if (o[i]==c) + { + if (o[i+1]==':') return 1; + return 0; + } + } + return 2; +} + +static void getopt_sort(char*v[],int oi) +{ + int i; + char *tmp, *tmp2=0; + + if (opt_unknown_len) + { + tmp=v[optind-(1+oi)]; + if (oi) tmp2=v[optind-1]; + + for (i=opt_unknown+opt_unknown_len;i>opt_unknown;i--) v[i+oi]=v[i-1]; + + v[opt_unknown++]=tmp; + if (oi) v[opt_unknown++]=tmp2; + } +} + +static char* nextchar; +int getopt(int c,char*v[],char*o) +{ + int ol=strlen(o); + int ret=0; + int oi=0; + + optarg=0; + + while (nextchar || (optind<c)) + { + if (nextchar) + { + if ((ret=(*(++nextchar)))) + { + switch (getopt_check(ret,o,ol)) + { + case 1: + if (*(++nextchar)) + optarg=nextchar; + else + { + if (optind<c) + { + oi=1; + optarg=v[optind++]; + } + else + ret='?'; + } + nextchar=0; + case 0: + if (!nextchar) + getopt_sort(v,oi); + else + if (!(*(nextchar+1))) + getopt_sort(v,oi); + return ret; + break; + default: + return '?'; + break; + } + } + else + nextchar=0; + } + else + { + if ((v[optind][0]=='-')&&((v[optind][1]!=0))) + { + if ((v[optind][1]=='-')&&(v[optind][2]==0)) + { + getopt_sort(v,oi); + optind=opt_unknown; + return -1; + } + else + { + nextchar=v[optind]; + } + } + else + { + ++opt_unknown_len; + } + ++optind; + } + } + optind=opt_unknown; + return -1; +} diff --git a/mdk-stage1/dietlibc/lib/getpgrp.c b/mdk-stage1/dietlibc/lib/getpgrp.c new file mode 100644 index 000000000..ee2ab0257 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/getpgrp.c @@ -0,0 +1,6 @@ +#include <unistd.h> + +int getpgrp() +{ + return getpgid(0); +} diff --git a/mdk-stage1/dietlibc/lib/getservent.c b/mdk-stage1/dietlibc/lib/getservent.c index ee6a77c21..bf25d046b 100644 --- a/mdk-stage1/dietlibc/lib/getservent.c +++ b/mdk-stage1/dietlibc/lib/getservent.c @@ -5,6 +5,7 @@ #include <errno.h> #include <netinet/in.h> #include <string.h> +#include <ctype.h> static int servicesfd=-1; static char* servicesmap; @@ -14,29 +15,13 @@ static char* aliases[10]; static char *cur; -static inline int isalpha(char c) { - return (c>='a' && c<='z') || (c>='A' && c<='Z'); -} - -static inline int isdigit(char c) { - return (c>='0' && c<='9'); -} - -static inline int isalnum(char c) { - return isalpha(c) || isdigit(c); -} - -static inline int isblank(char c) { - return (c==' ' || c=='\t'); -} - /* nameserver 42/tcp name # IEN 116 */ struct servent *getservent(void) { static struct servent se; char *last; int aliasidx; if (servicesfd<0) { - servicesfd=open("/etc/services",O_RDONLY); + servicesfd=open(_PATH_SERVICES,O_RDONLY); if (servicesfd<0) return 0; serviceslen=lseek(servicesfd,0,SEEK_END); servicesmap=mmap(0,serviceslen,PROT_READ|PROT_WRITE,MAP_PRIVATE,servicesfd,0); @@ -71,17 +56,17 @@ again: if (*cur!='/') goto parseerror; cur++; se.s_proto=cur; - while (cur<last && isalpha(*cur)) cur++; + while (cur<last && isalpha(*cur)) ++cur; if (cur>=last) return 0; if (*cur=='\n') { *cur++=0; return &se; } *cur=0; cur++; /* now the aliases */ - for (aliasidx=0;aliasidx<10;aliasidx++) { - while (cur<last && isblank(*cur)) cur++; + for (aliasidx=0;aliasidx<10;++aliasidx) { + while (cur<last && isblank(*cur)) ++cur; aliases[aliasidx]=cur; - while (cur<last && isalpha(*cur)) cur++; + while (cur<last && isalpha(*cur)) ++cur; + if (*cur=='\n') { *cur++=0; ++aliasidx; break; } if (cur>=last || !isblank(*cur)) break; - if (*cur=='\n') { *cur++=0; break; } *cur++=0; } aliases[aliasidx]=0; @@ -99,8 +84,13 @@ error: return 0; } +void setservent(int stayopen) { + cur=servicesmap; +} + struct servent *getservbyname(const char *name, const char *proto) { struct servent *s; + setservent(0); for (s=getservent(); s; s=getservent()) { char **tmp; #if 0 @@ -109,6 +99,16 @@ struct servent *getservbyname(const char *name, const char *proto) { write(1,"/",1); write(1,s->s_proto,strlen(s->s_proto)); write(1,"\n",1); + if (!strcmp(name,"auth")) { + tmp=s->s_aliases; + write(1," aka ",5); + while (*tmp) { + write(1,*tmp,strlen(*tmp)); + write(1,", ",2); + ++tmp; + } + write(1,"\n",1); + } #endif if (!strcmp(name,s->s_name) && !strcmp(proto,s->s_proto)) return s; @@ -128,10 +128,6 @@ struct servent *getservbyport(int port, const char *proto) { return 0; } -void setservent(int stayopen) { - cur=servicesmap; -} - void endservent(void) { if (servicesmap!=(char*)-1) munmap(servicesmap,serviceslen); if (servicesfd!=-1) close(servicesfd); diff --git a/mdk-stage1/dietlibc/lib/htonl.c b/mdk-stage1/dietlibc/lib/htonl.c new file mode 100644 index 000000000..490de42c4 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/htonl.c @@ -0,0 +1,12 @@ +#include <endian.h> + +unsigned long int htonl(unsigned long int hostlong) { +#if __BYTE_ORDER==__LITTLE_ENDIAN + return (hostlong>>24) | ((hostlong&0xff0000)>>8) | + ((hostlong&0xff00)<<8) | (hostlong<<24); +#else + return hostlong; +#endif +} + +unsigned long int ntohl(unsigned long int hostlong) __attribute__((weak,alias("htonl"))); diff --git a/mdk-stage1/dietlibc/lib/htons.c b/mdk-stage1/dietlibc/lib/htons.c index 92a43f937..765d3bbc5 100644 --- a/mdk-stage1/dietlibc/lib/htons.c +++ b/mdk-stage1/dietlibc/lib/htons.c @@ -1,12 +1,11 @@ -#include <asm/byteorder.h> +#include <endian.h> -#undef htons -#ifdef __i386__ -unsigned short int htons(unsigned short int netshort) { - return ___arch__swab16(netshort); -} +unsigned short int htons(unsigned short int hostshort) { +#if __BYTE_ORDER==__LITTLE_ENDIAN + return ((hostshort>>8)&0xff) | (hostshort<<8); #else -unsigned short int htons(unsigned short int netshort) { - return netshort; -} + return hostshort; #endif +} + +unsigned short int ntohs(unsigned short int hostshort) __attribute__((weak,alias("htons"))); diff --git a/mdk-stage1/dietlibc/lib/isalnum.c b/mdk-stage1/dietlibc/lib/isalnum.c index 19e5151d5..4d363fab9 100644 --- a/mdk-stage1/dietlibc/lib/isalnum.c +++ b/mdk-stage1/dietlibc/lib/isalnum.c @@ -1,6 +1,7 @@ #include <ctype.h> -int isalnum(int c) { +int __isalnum_ascii(int c) { return isalpha(c) || isdigit(c); } +int isalnum(int c) __attribute__((weak,alias("__isalnum_ascii"))); diff --git a/mdk-stage1/dietlibc/lib/isalpha.c b/mdk-stage1/dietlibc/lib/isalpha.c index db04c3fae..07ea69696 100644 --- a/mdk-stage1/dietlibc/lib/isalpha.c +++ b/mdk-stage1/dietlibc/lib/isalpha.c @@ -1,6 +1,7 @@ #include <ctype.h> -inline int isalpha(int c) { +int __isalpha_ascii(int c) { return (c>='a' && c<='z') || (c>='A' && c<='Z'); } +int isalpha(int c) __attribute__((weak,alias("__isalpha_ascii"))); diff --git a/mdk-stage1/dietlibc/lib/isascii.c b/mdk-stage1/dietlibc/lib/isascii.c index e627efb41..e06994783 100644 --- a/mdk-stage1/dietlibc/lib/isascii.c +++ b/mdk-stage1/dietlibc/lib/isascii.c @@ -1,6 +1,6 @@ #include <ctype.h> -inline int isascii(int c) { +int isascii(int c) { return (c & 0x80) == 0; } diff --git a/mdk-stage1/dietlibc/lib/iscntrl.c b/mdk-stage1/dietlibc/lib/iscntrl.c new file mode 100644 index 000000000..a183a54f1 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/iscntrl.c @@ -0,0 +1,7 @@ +#include <ctype.h> + +int __iscntrl_ascii(int c) { + return (c<32) || (c==127); +} + +int iscntrl(int c) __attribute__((weak,alias("__iscntrl_ascii"))); diff --git a/mdk-stage1/dietlibc/lib/isdigit.c b/mdk-stage1/dietlibc/lib/isdigit.c index 734eb5197..8a7c3e801 100644 --- a/mdk-stage1/dietlibc/lib/isdigit.c +++ b/mdk-stage1/dietlibc/lib/isdigit.c @@ -1,6 +1,7 @@ #include <ctype.h> -inline int isdigit(int c) { +int __isdigit_ascii(int c) { return (c>='0' && c<='9'); } +int isdigit(int c) __attribute__((weak,alias("__isdigit_ascii"))); diff --git a/mdk-stage1/dietlibc/lib/isgraph.c b/mdk-stage1/dietlibc/lib/isgraph.c new file mode 100644 index 000000000..807f90ff0 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/isgraph.c @@ -0,0 +1,5 @@ +int __isgraph_ascii(int c) { + return (c>=33 && c<=126); +} + +int isgraph(int c) __attribute__((weak,alias("__isgraph_ascii"))); diff --git a/mdk-stage1/dietlibc/lib/islower.c b/mdk-stage1/dietlibc/lib/islower.c new file mode 100644 index 000000000..6a9afa519 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/islower.c @@ -0,0 +1,7 @@ +#include <ctype.h> + +int __islower_ascii(int c) { + return (c>='a' && c<='z'); +} + +int islower(int c) __attribute__((weak,alias("__islower_ascii"))); diff --git a/mdk-stage1/dietlibc/lib/isprint.c b/mdk-stage1/dietlibc/lib/isprint.c new file mode 100644 index 000000000..e980658a5 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/isprint.c @@ -0,0 +1,6 @@ + +int __isprint_ascii(int c) { + return (c>=32 && c<=126); +} + +int isprint(int c) __attribute__((weak,alias("__isprint_ascii"))); diff --git a/mdk-stage1/dietlibc/lib/ispunct.c b/mdk-stage1/dietlibc/lib/ispunct.c new file mode 100644 index 000000000..2fd1183b1 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/ispunct.c @@ -0,0 +1,7 @@ +#include <ctype.h> + +int __ispunct_ascii(int c) { + return isprint(c) && !( isalnum(c) || isspace(c) ); +} + +int ispunct(int c) __attribute__((weak,alias("__ispunct_ascii"))); diff --git a/mdk-stage1/dietlibc/lib/isspace.c b/mdk-stage1/dietlibc/lib/isspace.c index ab39e81bc..916f784ab 100644 --- a/mdk-stage1/dietlibc/lib/isspace.c +++ b/mdk-stage1/dietlibc/lib/isspace.c @@ -1,6 +1,8 @@ #include <ctype.h> -int isspace(int ch) +int __isspace_ascii(int ch) { return ((ch==' ')||(ch=='\f')||(ch=='\t')||(ch=='\v')||(ch=='\r')||(ch=='\n')); } + +int isspace(int c) __attribute__((weak,alias("__isspace_ascii"))); diff --git a/mdk-stage1/dietlibc/lib/isupper.c b/mdk-stage1/dietlibc/lib/isupper.c new file mode 100644 index 000000000..933dfc169 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/isupper.c @@ -0,0 +1,7 @@ +#include <ctype.h> + +int __isupper_ascii(int c) { + return (c>='A' && c<='Z'); +} + +int isupper(int c) __attribute__((weak,alias("__isupper_ascii"))); diff --git a/mdk-stage1/dietlibc/lib/isxdigit.c b/mdk-stage1/dietlibc/lib/isxdigit.c new file mode 100644 index 000000000..22a711f2d --- /dev/null +++ b/mdk-stage1/dietlibc/lib/isxdigit.c @@ -0,0 +1,5 @@ +int __isxdigit_ascii(int c) { + return ((c>='0'&&c<='9') || (c>='A'&&c<='F') || (c>='a'&&c<='f')); +} + +int isxdigit(int c) __attribute__((weak,alias("__isxdigit_ascii"))); diff --git a/mdk-stage1/dietlibc/lib/lseek64.c b/mdk-stage1/dietlibc/lib/lseek64.c new file mode 100644 index 000000000..f39e779f9 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/lseek64.c @@ -0,0 +1,22 @@ +#include "dietfeatures.h" + +#ifdef WANT_LARGEFILE_BACKCOMPAT +#include <sys/stat.h> +#ifndef __NO_STAT64 +#include <errno.h> +#include <unistd.h> + +loff_t lseek64(int fildes, loff_t offset, int whence) { + loff_t tmp; + if (llseek(fildes,offset>>32,offset&0xffffffff,&tmp,whence)) { +#ifdef WANT_THREAD_SAFE + if (*__errno_location()!=ENOSYS) return -1; +#else + if (errno!=ENOSYS) return -1; +#endif + return (loff_t)lseek(fildes,(off_t)offset,whence); + } + return tmp; +} +#endif +#endif diff --git a/mdk-stage1/dietlibc/lib/memcmp.c b/mdk-stage1/dietlibc/lib/memcmp.c index 8bce6c975..c05a46863 100644 --- a/mdk-stage1/dietlibc/lib/memcmp.c +++ b/mdk-stage1/dietlibc/lib/memcmp.c @@ -12,3 +12,5 @@ int memcmp(const void *dst, const void *src, size_t count) { } return 0; } + +int bcmp(const char *a,const char *b,size_t c) __attribute__((weak,alias("memcmp"))); diff --git a/mdk-stage1/dietlibc/lib/mkfifo.c b/mdk-stage1/dietlibc/lib/mkfifo.c index 97659490c..596efbe27 100644 --- a/mdk-stage1/dietlibc/lib/mkfifo.c +++ b/mdk-stage1/dietlibc/lib/mkfifo.c @@ -1,6 +1,6 @@ #include <linux/stat.h> #include <unistd.h> -int mkfifo(char *fn,int mode) { +int mkfifo(const char *fn,mode_t mode) { return mknod(fn,S_IFIFO|mode,0); } diff --git a/mdk-stage1/dietlibc/lib/msgctl.c b/mdk-stage1/dietlibc/lib/msgctl.c new file mode 100644 index 000000000..19ea6d8cf --- /dev/null +++ b/mdk-stage1/dietlibc/lib/msgctl.c @@ -0,0 +1,10 @@ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/msg.h> +#include <asm/ipc.h> + +extern int __ipc(); + +int msgctl(int msqid, int cmd, struct msqid_ds *buf) { + return __ipc(MSGCTL,msqid,cmd,0,buf); +} diff --git a/mdk-stage1/dietlibc/lib/msgget.c b/mdk-stage1/dietlibc/lib/msgget.c new file mode 100644 index 000000000..9bca09ebe --- /dev/null +++ b/mdk-stage1/dietlibc/lib/msgget.c @@ -0,0 +1,10 @@ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/msg.h> +#include <asm/ipc.h> + +extern int __ipc(); + +int msgget(key_t key,int flag) { + return __ipc(MSGGET,key,flag,0,0); +} diff --git a/mdk-stage1/dietlibc/lib/msgrcv.c b/mdk-stage1/dietlibc/lib/msgrcv.c new file mode 100644 index 000000000..b4ae9cc6c --- /dev/null +++ b/mdk-stage1/dietlibc/lib/msgrcv.c @@ -0,0 +1,13 @@ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/msg.h> +#include <asm/ipc.h> + +extern int __ipc(); + +int msgrcv(int msqid, void *msgp, size_t msgsz, long int msgtyp, int msgflg) { + struct ipc_kludge tmp; + tmp.msgp = msgp; + tmp.msgtyp = msgtyp; + return __ipc(MSGRCV,msqid, msgsz, msgflg, &tmp); +} diff --git a/mdk-stage1/dietlibc/lib/msgsnd.c b/mdk-stage1/dietlibc/lib/msgsnd.c new file mode 100644 index 000000000..6203053f0 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/msgsnd.c @@ -0,0 +1,10 @@ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/msg.h> +#include <asm/ipc.h> + +extern int __ipc(); + +int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg) { + return __ipc(MSGSND,msqid, msgsz, msgflg, msgp); +} diff --git a/mdk-stage1/dietlibc/lib/nop.c b/mdk-stage1/dietlibc/lib/nop.c index 623278dee..c05bea813 100644 --- a/mdk-stage1/dietlibc/lib/nop.c +++ b/mdk-stage1/dietlibc/lib/nop.c @@ -1,7 +1,7 @@ -int __fflush_stdin() __attribute__((weak,alias("__nop"))); -int __fflush_stdout() __attribute__((weak,alias("__nop"))); -int __fflush_stderr() __attribute__((weak,alias("__nop"))); +int __fflush_stdin() __attribute__((weak,alias("__return0"))); +int __fflush_stdout() __attribute__((weak,alias("__return0"))); +int __fflush_stderr() __attribute__((weak,alias("__return0"))); /* used for weak aliases */ -int __nop() { return 0; } +int __return0() { return 0; } diff --git a/mdk-stage1/dietlibc/lib/open64.c b/mdk-stage1/dietlibc/lib/open64.c index cab7e992e..f1499d017 100644 --- a/mdk-stage1/dietlibc/lib/open64.c +++ b/mdk-stage1/dietlibc/lib/open64.c @@ -1,11 +1,14 @@ #include <linux/types.h> #include <linux/fcntl.h> -#include <unistd.h> -#ifdef O_LARGEFILE -int open64(const char* file,int oflag,int mode) { +#ifndef O_LARGEFILE +#define O_LARGEFILE 0 +#endif + +extern int open(const char* file,int oflag,int mode); + +int __libc_open64(const char* file,int oflag,int mode) { return open(file,oflag|O_LARGEFILE,mode); } -int __libc_open64(const char* file,int oflag,int mode) __attribute__((weak,alias("open64"))); -#endif +int open64(const char* file,int oflag,int mode) __attribute__((weak,alias("__libc_open64"))); diff --git a/mdk-stage1/dietlibc/lib/opendir.c b/mdk-stage1/dietlibc/lib/opendir.c index 05c0b9bc8..5c0c4a305 100644 --- a/mdk-stage1/dietlibc/lib/opendir.c +++ b/mdk-stage1/dietlibc/lib/opendir.c @@ -1,63 +1,18 @@ -#include <sys/stat.h> +#include "dietdirent.h" +#include <unistd.h> +#include <dirent.h> #include <stdlib.h> -#include <string.h> #include <fcntl.h> -#include <unistd.h> -#undef _POSIX_PTHREADS -#include <errno.h> - -#include "dirstream.h" - -#ifndef O_DIRECTORY -#define O_DIRECTORY 0200000 /* must be a directory */ -#endif - -/* - * opendir just makes an open() call - it return NULL if it fails - * (open sets errno), otherwise it returns a DIR * pointer. - */ -#undef opendir -DIR * -opendir(const char * name) -{ - int fd; - struct stat statbuf; - struct dirent *buf; - DIR *ptr; - - /* - if (stat(name,&statbuf)) return NULL; - if (!S_ISDIR(statbuf.st_mode)) { - errno = ENOTDIR; - return NULL; - } - */ - if ((fd = open(name,O_RDONLY|O_DIRECTORY)) < 0) - return NULL; - /* According to POSIX, directory streams should be closed when - * exec. From "Anna Pluzhnikov" <besp@midway.uchicago.edu>. - */ - if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) - return NULL; - if (!(ptr=malloc(sizeof(*ptr)))) { - close(fd); - errno = ENOMEM; - return NULL; - } - - ptr->dd_max = statbuf.st_blksize; - if (ptr->dd_max < 512) - ptr->dd_max = 512; - if (!(buf=malloc(ptr->dd_max))) { - close(fd); - free(ptr); - errno = ENOMEM; - return NULL; +DIR *opendir (const char *name) { + DIR *t=(DIR*)malloc(sizeof(DIR)); + if (t) { + if ((t->fd=open(name,O_RDONLY|O_DIRECTORY))>=0) { + t->num=t->cur=0; + } else { + free(t); + t=0; + } } - ptr->dd_fd = fd; - ptr->dd_nextoff = ptr->dd_nextloc = ptr->dd_size = 0; - ptr->dd_buf = buf; - ptr->dd_getdents = unknown; - return ptr; + return t; } diff --git a/mdk-stage1/dietlibc/lib/perror.c b/mdk-stage1/dietlibc/lib/perror.c index 5476d76a1..ecab7250b 100644 --- a/mdk-stage1/dietlibc/lib/perror.c +++ b/mdk-stage1/dietlibc/lib/perror.c @@ -1,5 +1,7 @@ +#include "dietfeatures.h" #include <unistd.h> #include <string.h> +#include <errno.h> extern char *sys_errlist[]; extern int sys_nerr; @@ -10,7 +12,11 @@ void perror(const char *s) { write(2,s,strlen(s)); write(2,": ",2); if (errno>=0 && errno<sys_nerr) +#ifdef WANT_THREAD_SAFE + message=sys_errlist[*__errno_location()]; +#else message=sys_errlist[errno]; +#endif write(2,message,strlen(message)); write(2,"\n",1); } diff --git a/mdk-stage1/dietlibc/lib/puts.c b/mdk-stage1/dietlibc/lib/puts.c index 01f6e50c4..54415151d 100644 --- a/mdk-stage1/dietlibc/lib/puts.c +++ b/mdk-stage1/dietlibc/lib/puts.c @@ -1,6 +1,12 @@ #include <unistd.h> #include <string.h> +#include "dietstdio.h" +#include "dietfeatures.h" int puts(const char *s) { +#ifdef WANT_BUFFERED_STDIO + return fwrite(s,1,strlen(s),stdout) && fputc('\n',stdout); +#else return write(1,s,strlen(s)) && write(1,"\n",1); +#endif } diff --git a/mdk-stage1/dietlibc/lib/qsort.c b/mdk-stage1/dietlibc/lib/qsort.c new file mode 100644 index 000000000..2a8824bf3 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/qsort.c @@ -0,0 +1,125 @@ +#include <stdlib.h> +#include <assert.h> + +/* comments: + 1. insertion sort sofort, nicht nachträglich + 2. threshold = 16 + */ + +static inline void iswap(void *a,void *b,size_t size) { + register char *x=a; + register char *y=b; + register char *z=x+size; + while (x<z) { + register char tmp=*x; + *x=*y; + *y=tmp; + ++x; ++y; + } +} + +static inline void swap(void *base,size_t size,size_t a,size_t b) { + iswap(base+a*size,base+b*size,size); +} + +#if 0 +extern int array[]; + +void dumparray() { + printf("array now {%d,%d,%d,%d,%d}\n",array[0],array[1],array[2],array[3],array[4]); +} +#endif + +void isort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) { + int i; + while (nmemb>1) { + char *min=base; + char *tmp=min+size; + for (i=1; i<nmemb; ++i) { + if (compar(tmp,min)<0) + min=tmp; + tmp+=size; + } + iswap(min,base,size); + base+=size; + nmemb-=1; + } +} + +void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) { +#ifdef DEBUG + char *dbase=base; + char *dmax=base+(nmemb-1)*size; + char dmemb=nmemb; +#endif + static int level=0; + char* v; /* pivot */ + char* mid, *max, *min; + int lmemb; + +#if 0 + int left,right; + left=(int*)base-array; + right=left+nmemb-1; + ++level; + { int i; for (i=0; i<level; ++i) printf(" "); } + printf("qsort: level %d; base=%p, %dx%d; array[%d..%d]\n",level,base,nmemb,size,left,right); + assert(left>=0 && right<=1000); +#endif + if (nmemb<=8) { + --level; + return isort(base,nmemb,size,compar); + } + { + mid=base+(nmemb/2)*size; + max=base+(nmemb-1)*size; + + if (compar(base,max)<0) /* a[left] < a[right] */ + if (compar(base,mid)<0) /* a[left] < a[med] */ + if (compar(max,mid)<0) /* a[left] < a[right] < a[med] */ + v=max; + else /* a[left] < a[med] < a[right] */ + v=mid; + else /* a[med] < a[left] < a[right] */ + v=base; + else /* a[right] < a[left] */ + if (compar(base,mid)<0) /* a[right] < a[left] < a[med] */ + v=base; + else /* a[right] < a[left] && a[med] < a[left] */ + if (compar(max,mid)<0) /* a[right] < a[med] < a[left] */ + v=mid; + else + v=max; +// printf("%d %d %d -> median %d\n",*(int*)base,*(int*)mid,*(int*)max,*(int*)v); + } + if (v != max) + iswap(v,max,size); + v=max; + min=base; lmemb=0; + for (;;) { + while (compar(min,v)<0) { min+=size; ++lmemb; } + while (compar(max-=size,v)>0) ; + if (min>=max) break; + iswap(min,max,size); + } + iswap(min,v,size); +#ifdef DEBUG +// { int i; for (i=0; i<level; ++i) printf(" "); } +// printf("-=< base=%p, min=%p, nmemb=%d, lmemb=%d (%d)\n",base,min,nmemb,lmemb,(min-(char*)base)/size); + assert(lmemb==((min-(char*)base)/size)); +#endif + if (min>(char*)base+size) { +#ifdef DEBUG + assert(base==dbase); +#endif +// { int i; for (i=0; i<level; ++i) printf(" "); } +// printf("+-left %d [%d..%d] of [%d..%d]\n",level+1,left,left+lmemb,left,right); + qsort(base,lmemb,size,compar); + } + if (nmemb>lmemb+1) { +// { int i; for (i=0; i<level; ++i) printf(" "); } +// printf("+-right %d [%d..%d] of [%d..%d]\n",level+1,left+lmemb,right,left,right); + qsort(min+size,nmemb-lmemb-1,size,compar); + } + --level; +} diff --git a/mdk-stage1/dietlibc/lib/rand.c b/mdk-stage1/dietlibc/lib/rand.c new file mode 100644 index 000000000..10bfaf94d --- /dev/null +++ b/mdk-stage1/dietlibc/lib/rand.c @@ -0,0 +1,9 @@ +#include <stdlib.h> + +static unsigned int seed=1; + +int rand() { + return ((seed = seed * 1103515245 + 12345) % ((unsigned int)RAND_MAX + 1)); +} + +void srand(unsigned int i) { seed=i; } diff --git a/mdk-stage1/dietlibc/lib/random.c b/mdk-stage1/dietlibc/lib/random.c new file mode 100644 index 000000000..02d1e1004 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/random.c @@ -0,0 +1,9 @@ +#include <stdlib.h> + +static unsigned int seed=1; + +int random() { + return ((seed = seed * 1103515245 + 12345) % ((unsigned int)RAND_MAX + 1)); +} + +void srandom(unsigned int i) { seed=i; } diff --git a/mdk-stage1/dietlibc/lib/readdir.c b/mdk-stage1/dietlibc/lib/readdir.c index 5accd32a1..689f5d08b 100644 --- a/mdk-stage1/dietlibc/lib/readdir.c +++ b/mdk-stage1/dietlibc/lib/readdir.c @@ -1,83 +1,13 @@ -#if 0 - -Sorry, currently broken - -#include <dirent.h> -#include <errno.h> +#include "dietdirent.h" #include <unistd.h> +#include <dirent.h> #include <stdlib.h> -#include <string.h> - -#include "dirstream.h" - -#ifdef __ELF__ -#pragma weak readdir = __libc_readdir -#endif - -struct dirent * -__libc_readdir(DIR * dir) -{ - int result; - struct dirent *de; - - if (!dir) { - errno = EBADF; - return NULL; - } - - /* Are we running an old kernel? */ - if (dir->dd_getdents == no_getdents) - { - abort(); - } - - if (dir->dd_size <= dir->dd_nextloc) - { - /* read dir->dd_max bytes of directory entries. */ - result=getdents(dir->dd_fd,dir->dd_buf,dir->dd_max); - - /* We assume we have getdents (). */ - dir->dd_getdents = have_getdents; - if (result <= 0) - { - result = -result; - if (result > 0) - { - /* Are we right? */ - if (result == ENOSYS) - { - dir->dd_getdents = no_getdents; - abort(); - } - errno = result; - } - return NULL; - } - - dir->dd_size = result; - dir->dd_nextloc = 0; +struct dirent* readdir(DIR *d) { + if (!d->num || (d->cur += ((struct dirent*)(d->buf+d->cur))->d_reclen)>=d->num) { + int res=getdents(d->fd,(struct dirent*)d->buf,1023); + if (res<=0) return 0; + d->num=res; d->cur=0; } - - de = (struct dirent *) (((char *)dir->dd_buf) + dir->dd_nextloc); - - /* Am I right? H.J. */ - dir->dd_nextloc += de->d_reclen; - - /* We have to save the next offset here. */ - dir->dd_nextoff = de->d_off; - - /* convert */ - dir->convbuf.d_ino=de->d_ino; - dir->convbuf.d_off=de->d_off; - dir->convbuf.d_reclen=de->d_reclen; - dir->convbuf.d_type=0; - if (strlen((char*)&de->d_type)>10) - de->d_name[10]=0; - strcpy(dir->convbuf.d_name,(char*)&de->d_type); - errno=0; - - return &dir->convbuf; + return (struct dirent*)(d->buf+d->cur); } - -#endif diff --git a/mdk-stage1/dietlibc/lib/reboot.c b/mdk-stage1/dietlibc/lib/reboot.c new file mode 100644 index 000000000..7f47a95dd --- /dev/null +++ b/mdk-stage1/dietlibc/lib/reboot.c @@ -0,0 +1,8 @@ +#include <sys/reboot.h> + +int __reboot(int magic1, int magic2, int cmd, void * arg); + +int reboot(int cmd, void *arg) +{ + return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, arg); +} diff --git a/mdk-stage1/dietlibc/lib/recv.c b/mdk-stage1/dietlibc/lib/recv.c index cc778712c..bc6b1e5d7 100644 --- a/mdk-stage1/dietlibc/lib/recv.c +++ b/mdk-stage1/dietlibc/lib/recv.c @@ -2,7 +2,7 @@ extern int socketcall(int callno,long* args); -int recv(int a, const void * b, size_t c, int flags) { +int __libc_recv(int a, const void * b, size_t c, int flags) { #ifdef __i386__ return socketcall(SYS_RECV,(long*)&a); #else @@ -11,3 +11,5 @@ int recv(int a, const void * b, size_t c, int flags) { #endif } +int recv(int a, const void * b, size_t c, int flags) + __attribute__ ((weak, alias("__libc_recv"))); diff --git a/mdk-stage1/dietlibc/lib/recvfrom.c b/mdk-stage1/dietlibc/lib/recvfrom.c index a07afe7ad..802ad665f 100644 --- a/mdk-stage1/dietlibc/lib/recvfrom.c +++ b/mdk-stage1/dietlibc/lib/recvfrom.c @@ -2,7 +2,7 @@ extern int socketcall(int callno,long* args); -int recvfrom(int a, const void * b, size_t c, int flags, void *to, void *tolen) { +int __libc_recvfrom(int a, const void * b, size_t c, int flags, void *to, void *tolen) { #ifdef __i386__ return socketcall(SYS_RECVFROM, (long*)&a); #else @@ -10,3 +10,6 @@ int recvfrom(int a, const void * b, size_t c, int flags, void *to, void *tolen) return socketcall(SYS_RECVFROM, args); #endif } + +int recvfrom(int a, const void * b, size_t c, int flags, void *to, void *tolen) + __attribute__ ((weak,alias("__libc_recvfrom"))) ; diff --git a/mdk-stage1/dietlibc/lib/recvmsg.c b/mdk-stage1/dietlibc/lib/recvmsg.c new file mode 100644 index 000000000..c14c58c78 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/recvmsg.c @@ -0,0 +1,15 @@ +#include <linux/net.h> + +extern int socketcall(int callno,long* args); + +int __libc_recvmsg(int a, struct msghdr* msg, int flags) { +#ifdef __i386__ + return socketcall(SYS_RECVMSG, (long*)&a); +#else + unsigned long args[] = { a, (long) msg, flags }; + return socketcall(SYS_RECVMSG, args); +#endif +} + +int recvmsg(int a, struct msghdr *msg, int flags) + __attribute__ ((weak,alias("__libc_recvmsg"))) ; diff --git a/mdk-stage1/dietlibc/lib/remove.c b/mdk-stage1/dietlibc/lib/remove.c new file mode 100644 index 000000000..d5125bfed --- /dev/null +++ b/mdk-stage1/dietlibc/lib/remove.c @@ -0,0 +1,11 @@ +#include <unistd.h> +#include <errno.h> + +int remove(const char* filename) { + if (unlink(filename)) { + if (errno==EISDIR) + return rmdir(filename); + return -1; + } + return 0; +} diff --git a/mdk-stage1/dietlibc/lib/rewinddir.c b/mdk-stage1/dietlibc/lib/rewinddir.c index 138936527..addc7bde9 100644 --- a/mdk-stage1/dietlibc/lib/rewinddir.c +++ b/mdk-stage1/dietlibc/lib/rewinddir.c @@ -1,17 +1,8 @@ +#include "dietdirent.h" #include <unistd.h> -#include <errno.h> +#include <dirent.h> -#include "dirstream.h" - -/* - * rewinddir() just does an lseek(fd,0,0) - see close for comments - */ -void rewinddir(DIR * dir) -{ - if (!dir) { - errno = EBADF; - return; - } - lseek(dir->dd_fd,0,SEEK_SET); - dir->dd_nextoff = dir->dd_nextloc = dir->dd_size = 0; +void rewinddir(DIR *d) { + if (lseek(d->fd,0,SEEK_SET) != (off_t)-1) + d->num=d->cur=0; } diff --git a/mdk-stage1/dietlibc/lib/seekdir.c b/mdk-stage1/dietlibc/lib/seekdir.c index f83052250..cf111fbc8 100644 --- a/mdk-stage1/dietlibc/lib/seekdir.c +++ b/mdk-stage1/dietlibc/lib/seekdir.c @@ -1,15 +1,8 @@ +#include "dietdirent.h" #include <unistd.h> -#include <errno.h> +#include <dirent.h> -#include "dirstream.h" - -#undef seekdir -void seekdir(DIR * dir, off_t offset) -{ - if (!dir) { - errno = EBADF; - return; - } - dir->dd_nextoff = lseek(dir->dd_fd, offset, SEEK_SET); - dir->dd_size = dir->dd_nextloc = 0; +void seekdir(DIR *d,off_t offset) { + if (lseek(d->fd,offset,SEEK_SET) != (off_t)-1) + d->num=d->cur=0; } diff --git a/mdk-stage1/dietlibc/lib/semctl.c b/mdk-stage1/dietlibc/lib/semctl.c new file mode 100644 index 000000000..ddc0aae95 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/semctl.c @@ -0,0 +1,10 @@ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/sem.h> +#include <asm/ipc.h> + +extern int __ipc(); + +int semctl(int semid, int semnum, int cmd, union semun arg) { + return __ipc(SEMCTL,semid,semnum,cmd,&arg); +} diff --git a/mdk-stage1/dietlibc/lib/semget.c b/mdk-stage1/dietlibc/lib/semget.c new file mode 100644 index 000000000..056aeae04 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/semget.c @@ -0,0 +1,10 @@ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/sem.h> +#include <asm/ipc.h> + +extern int __ipc(); + +int semget(key_t key, int nsems, int semflg) { + return __ipc(SEMGET,key,nsems,semflg,0); +} diff --git a/mdk-stage1/dietlibc/lib/semop.c b/mdk-stage1/dietlibc/lib/semop.c new file mode 100644 index 000000000..abfde73a7 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/semop.c @@ -0,0 +1,10 @@ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/sem.h> +#include <asm/ipc.h> + +extern int __ipc(); + +int semop(int semid,struct sembuf *sops,unsigned nsops) { + return __ipc(SEMOP,semid,nsops,0,sops); +} diff --git a/mdk-stage1/dietlibc/lib/send.c b/mdk-stage1/dietlibc/lib/send.c index be43b4e63..c1adf1b5d 100644 --- a/mdk-stage1/dietlibc/lib/send.c +++ b/mdk-stage1/dietlibc/lib/send.c @@ -2,7 +2,7 @@ extern int socketcall(int callno,long* args); -int send(int a, const void * b, size_t c, int flags) { +int __libc_send(int a, const void * b, size_t c, int flags) { #ifdef __i386__ return socketcall(SYS_SEND, (long*)&a); #else @@ -11,3 +11,5 @@ int send(int a, const void * b, size_t c, int flags) { #endif } +int send(int a, const void * b, size_t c, int flags) + __attribute__ ((weak, alias("__libc_send"))); diff --git a/mdk-stage1/dietlibc/lib/sendmsg.c b/mdk-stage1/dietlibc/lib/sendmsg.c new file mode 100644 index 000000000..277265985 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/sendmsg.c @@ -0,0 +1,15 @@ +#include <linux/net.h> + +extern int socketcall(int callno,long* args); + +int __libc_sendmsg(int a, const struct msghdr* msg, int flags) { +#ifdef __i386__ + return socketcall(SYS_SENDMSG, (long*)&a); +#else + unsigned long args[] = { a, (long) msg, flags }; + return socketcall(SYS_SENDMSG, args); +#endif +} + +int sendmsg(int a, const struct msghdr *msg, int flags) + __attribute__ ((weak,alias("__libc_sendmsg"))) ; diff --git a/mdk-stage1/dietlibc/lib/sendto.c b/mdk-stage1/dietlibc/lib/sendto.c index e6c2560f3..078c010ea 100644 --- a/mdk-stage1/dietlibc/lib/sendto.c +++ b/mdk-stage1/dietlibc/lib/sendto.c @@ -2,7 +2,7 @@ extern int socketcall(int callno,long* args); -int sendto(int a, const void * b, size_t c, int flags, void *to, int tolen) { +int __libc_sendto(int a, const void * b, size_t c, int flags, void *to, int tolen) { #ifdef __i386__ return socketcall(SYS_SENDTO, (long*)&a); #else @@ -11,3 +11,5 @@ int sendto(int a, const void * b, size_t c, int flags, void *to, int tolen) { #endif } +int sendto(int a, const void * b, size_t c, int flags, void *to, int tolen) + __attribute__ ((weak, alias("__libc_sendto"))); diff --git a/mdk-stage1/dietlibc/lib/setpgrp.c b/mdk-stage1/dietlibc/lib/setpgrp.c new file mode 100644 index 000000000..825ca3725 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/setpgrp.c @@ -0,0 +1,6 @@ +#include <unistd.h> + +int setpgrp() +{ + return setpgid(0,0); +} diff --git a/mdk-stage1/dietlibc/lib/shmat.c b/mdk-stage1/dietlibc/lib/shmat.c new file mode 100644 index 000000000..63284b1ea --- /dev/null +++ b/mdk-stage1/dietlibc/lib/shmat.c @@ -0,0 +1,15 @@ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <asm/ipc.h> + +extern void* __ipc(); + +void* shmat(int shmid,const void* shmaddr,int shmflg) { + void* raddr; + register void* result; + result=__ipc(SHMAT,shmid,shmflg,&raddr,shmaddr); + if ((unsigned long)result <= -(unsigned long)SHMLBA) + result=raddr; + return result; +} diff --git a/mdk-stage1/dietlibc/lib/shmctl.c b/mdk-stage1/dietlibc/lib/shmctl.c new file mode 100644 index 000000000..8f942f2a4 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/shmctl.c @@ -0,0 +1,10 @@ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <asm/ipc.h> + +extern int __ipc(); + +int shmctl(int shmid, int cmd, struct shmid_ds *buf) { + return __ipc(SHMCTL,shmid,cmd,0,buf); +} diff --git a/mdk-stage1/dietlibc/lib/shmdt.c b/mdk-stage1/dietlibc/lib/shmdt.c new file mode 100644 index 000000000..36db10f08 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/shmdt.c @@ -0,0 +1,10 @@ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <asm/ipc.h> + +extern int __ipc(); + +int shmdt(const void* shmaddr) { + return __ipc(SHMDT,0,0,0,shmaddr); +} diff --git a/mdk-stage1/dietlibc/lib/shmget.c b/mdk-stage1/dietlibc/lib/shmget.c new file mode 100644 index 000000000..9b03f5deb --- /dev/null +++ b/mdk-stage1/dietlibc/lib/shmget.c @@ -0,0 +1,10 @@ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <asm/ipc.h> + +extern int __ipc(); + +int shmget(key_t key, int size, int shmflg) { + return __ipc(SHMGET,key,size,shmflg,0); +} diff --git a/mdk-stage1/dietlibc/lib/shutdown.c b/mdk-stage1/dietlibc/lib/shutdown.c new file mode 100644 index 000000000..0a6be6c37 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/shutdown.c @@ -0,0 +1,14 @@ +#include <linux/net.h> + +extern int socketcall(int callno,long* args); + +int __libc_shutdown(int s, int how) { +#ifdef __i386__ + return socketcall(SYS_SHUTDOWN, (long*)&s); +#else + unsigned long args[] = { s, (long) how, 0 }; + return socketcall(SYS_SHUTDOWN, args); +#endif +} + +int shutdown(int s, int how) __attribute__((weak,alias("__libc_shutdown"))); diff --git a/mdk-stage1/dietlibc/lib/sigaddset.c b/mdk-stage1/dietlibc/lib/sigaddset.c index 0c9d95c28..8ce69ea77 100644 --- a/mdk-stage1/dietlibc/lib/sigaddset.c +++ b/mdk-stage1/dietlibc/lib/sigaddset.c @@ -1,21 +1,15 @@ -#define __USE_EXTERN_INLINES 1 -#include <signal.h> - -# define __sigmask(sig) \ - (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int)))) - -# define __sigword(sig) (((sig) - 1) / (8 * sizeof (unsigned long int))) - -# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int))) -typedef struct - { - unsigned long int __val[_SIGSET_NWORDS]; - } __sigset_t; - -int __sigaddset(__sigset_t *set, int signo) { - unsigned long int __mask = __sigmask (signo); - unsigned long int __word = __sigword (signo); - return ((set->__val[__word] |= __mask), 0); +#define __KERNEL__ +#define sigaddset foobar +#include <asm/signal.h> +#undef sigaddset + +int __sigaddset(sigset_t *set, int signo) { + unsigned long sig = signo - 1; + if (_NSIG_WORDS == 1) + set->sig[0] |= 1UL << sig; + else + set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW); + return 0; } int sigaddset (sigset_t *env, int signo) __attribute__((weak,alias("__sigaddset"))); diff --git a/mdk-stage1/dietlibc/lib/sigdelset.c b/mdk-stage1/dietlibc/lib/sigdelset.c new file mode 100644 index 000000000..2c3385ea8 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/sigdelset.c @@ -0,0 +1,15 @@ +#define __KERNEL__ +#define sigdelset foobar +#include <asm/signal.h> +#undef sigdelset + +int __sigdelset(sigset_t *set, int signo) { + unsigned long sig = signo - 1; + if (_NSIG_WORDS == 1) + set->sig[0] &= ~(1UL << sig); + else + set->sig[sig / _NSIG_BPW] &= ~(1UL << (sig % _NSIG_BPW)); + return 0; +} + +int sigdelset (sigset_t *env, int signo) __attribute__((weak,alias("__sigdelset"))); diff --git a/mdk-stage1/dietlibc/lib/sigfillset.c b/mdk-stage1/dietlibc/lib/sigfillset.c new file mode 100644 index 000000000..ddac6e391 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/sigfillset.c @@ -0,0 +1,11 @@ +#define __KERNEL__ +#include <asm/signal.h> + +int __sigfillset (sigset_t *set) { + int i; + for (i=0; i<_NSIG_WORDS; i++) + set->sig[i]=~0; + return 0; +} + +int sigfillset(sigset_t *env) __attribute__((weak,alias("__sigfillset"))); diff --git a/mdk-stage1/dietlibc/lib/sigismember.c b/mdk-stage1/dietlibc/lib/sigismember.c new file mode 100644 index 000000000..67a258884 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/sigismember.c @@ -0,0 +1,21 @@ +#define __USE_EXTERN_INLINES 1 +#include <signal.h> + +# define __sigmask(sig) \ + (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int)))) + +# define __sigword(sig) (((sig) - 1) / (8 * sizeof (unsigned long int))) + +# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int))) +typedef struct + { + unsigned long int __val[_SIGSET_NWORDS]; + } __sigset_t; + +int __sigismember(const __sigset_t *set, int signo) { + unsigned long int __mask = __sigmask (signo); + unsigned long int __word = __sigword (signo); + return (set->__val[__word] & __mask); +} + +int sigismember(const sigset_t *env, int signo) __attribute__((weak,alias("__sigismember"))); diff --git a/mdk-stage1/dietlibc/lib/sigjmp.c b/mdk-stage1/dietlibc/lib/sigjmp.c index d7db58fd2..be97c62cc 100644 --- a/mdk-stage1/dietlibc/lib/sigjmp.c +++ b/mdk-stage1/dietlibc/lib/sigjmp.c @@ -16,7 +16,6 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <stddef.h> #include <setjmp.h> #include <signal.h> #include <string.h> diff --git a/mdk-stage1/dietlibc/lib/sprintf.c b/mdk-stage1/dietlibc/lib/sprintf.c index f1b554ce2..b355d01f9 100644 --- a/mdk-stage1/dietlibc/lib/sprintf.c +++ b/mdk-stage1/dietlibc/lib/sprintf.c @@ -1,6 +1,7 @@ #include <stdarg.h> #include <linux/types.h> #include <stdlib.h> +#include "dietwarning.h" int vsnprintf (char *str,size_t size,const char *format, va_list arg_ptr); @@ -13,3 +14,5 @@ int sprintf(char *dest,const char *format,...) va_end (arg_ptr); return n; } + +link_warning("sprintf","warning: Avoid sprintf; use snprintf. It is more secure and faster.") diff --git a/mdk-stage1/dietlibc/lib/strcasecmp.c b/mdk-stage1/dietlibc/lib/strcasecmp.c new file mode 100644 index 000000000..d978488a4 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/strcasecmp.c @@ -0,0 +1,17 @@ +#include <ctype.h> +#include "dietfeatures.h" + +int strcasecmp(register const char *s,register const char *t) { + register char x; + + for (;;) { + x = tolower(*s); if (x != tolower(*t)) break; if (!x) break; ++s; ++t; +#ifndef WANT_SMALL_STRING_ROUTINES + x = tolower(*s); if (x != tolower(*t)) break; if (!x) break; ++s; ++t; + x = tolower(*s); if (x != tolower(*t)) break; if (!x) break; ++s; ++t; + x = tolower(*s); if (x != tolower(*t)) break; if (!x) break; ++s; ++t; +#endif + } + return ((int)(unsigned int)(unsigned char) x) + - ((int)(unsigned int)(unsigned char) *t); +} diff --git a/mdk-stage1/dietlibc/lib/strchr.c b/mdk-stage1/dietlibc/lib/strchr.c index b908853f8..0c2050da6 100644 --- a/mdk-stage1/dietlibc/lib/strchr.c +++ b/mdk-stage1/dietlibc/lib/strchr.c @@ -14,3 +14,5 @@ char *strchr(register const char *t, int c) { } return (char*)t; } + +char *index(char *t,int c) __attribute__((weak,alias("strchr"))); diff --git a/mdk-stage1/dietlibc/lib/strlcpy.3 b/mdk-stage1/dietlibc/lib/strlcpy.3 new file mode 100644 index 000000000..e00af8d6b --- /dev/null +++ b/mdk-stage1/dietlibc/lib/strlcpy.3 @@ -0,0 +1,169 @@ +.\" $OpenBSD: strlcpy.3,v 1.10 2000/11/06 01:03:25 aaron Exp $ +.\" +.\" Copyright (c) 1998, 2000 Todd C. Miller <Todd.Miller@courtesan.com> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd June 22, 1998 +.Dt STRLCPY 3 +.Os +.Sh NAME +.Nm strlcpy , +.Nm strlcat +.Nd size-bounded string copying and concatenation +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft size_t +.Fn strlcpy "char *dst" "const char *src" "size_t size" +.Ft size_t +.Fn strlcat "char *dst" "const char *src" "size_t size" +.Sh DESCRIPTION +The +.Fn strlcpy +and +.Fn strlcat +functions copy and concatenate strings respectively. +They are designed +to be safer, more consistent, and less error prone replacements for +.Xr strncpy 3 +and +.Xr strncat 3 . +Unlike those functions, +.Fn strlcpy +and +.Fn strlcat +take the full size of the buffer (not just the length) and guarantee to +NUL-terminate the result (as long as +.Fa size +is larger than 0 or, in the case of +.Fn strlcat , +as long as there is at least one byte free in +.Fa dst ) . +Note that you should include a byte for the NUL in +.Fa size . +Also note that +.Fn strlcpy +and +.Fn strlcat +only operate on true +.Dq C +strings. +This means that for +.Fn strlcpy +.Fa src +must be NUL-terminated and for +.Fn strlcat +both +.Fa src +and +.Fa dst +must be NUL-terminated. +.Pp +The +.Fn strlcpy +function copies up to +.Fa size +- 1 characters from the NUL-terminated string +.Fa src +to +.Fa dst , +NUL-terminating the result. +.Pp +The +.Fn strlcat +function appends the NUL-terminated string +.Fa src +to the end of +.Fa dst . +It will append at most +.Fa size +- strlen(dst) - 1 bytes, NUL-terminating the result. +.Sh RETURN VALUES +The +.Fn strlcpy +and +.Fn strlcat +functions return the total length of the string they tried to create. +For +.Fn strlcpy +that means the length of +.Fa src . +For +.Fn strlcat +that means the initial length of +.Fa dst +plus +the length of +.Fa src . +While this may seem somewhat confusing it was done to make +truncation detection simple. +.Sh EXAMPLES +The following code fragment illustrates the simple case: +.Bd -literal -offset indent +char *s, *p, buf[BUFSIZ]; + +\&... + +(void)strlcpy(buf, s, sizeof(buf)); +(void)strlcat(buf, p, sizeof(buf)); +.Ed +.Pp +To detect truncation, perhaps while building a pathname, something +like the following might be used: +.Bd -literal -offset indent +char *dir, *file, pname[MAXPATHLEN]; + +\&... + +if (strlcpy(pname, dir, sizeof(pname)) >= sizeof(pname)) + goto toolong; +if (strlcat(pname, file, sizeof(pname)) >= sizeof(pname)) + goto toolong; +.Ed +.Pp +Since we know how many characters we copied the first time, we can +speed things up a bit by using a copy instead of an append: +.Bd -literal -offset indent +char *dir, *file, pname[MAXPATHLEN]; +size_t n; + +\&... + +n = strlcpy(pname, dir, sizeof(pname)); +if (n >= sizeof(pname)) + goto toolong; +if (strlcpy(pname + n, file, sizeof(pname) - n) >= sizeof(pname) - n) + goto toolong; +.Ed +.Pp +However, one may question the validity of such optimizations, as they +defeat the whole purpose of +.Fn strlcpy +and +.Fn strlcat . +As a matter of fact, the first version of this manual page got it wrong. +.Sh SEE ALSO +.Xr snprintf 3 , +.Xr strncat 3 , +.Xr strncpy 3 diff --git a/mdk-stage1/dietlibc/lib/strncasecmp.c b/mdk-stage1/dietlibc/lib/strncasecmp.c new file mode 100644 index 000000000..8a5445e53 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/strncasecmp.c @@ -0,0 +1,18 @@ +#include <ctype.h> +#include <sys/types.h> +#include <string.h> + +int strncasecmp(const char *s, const char *t, size_t n) { + register char x; + register const char* u=s+n; + for (;;) { + x = tolower(*s); if (x!=tolower(*t)) break; if (!x) break; if (++s>=u) return 0; ++t; +#ifndef WANT_SMALL_STRING_ROUTINES + x = tolower(*s); if (x!=tolower(*t)) break; if (!x) break; if (++s>=u) return 0; ++t; + x = tolower(*s); if (x!=tolower(*t)) break; if (!x) break; if (++s>=u) return 0; ++t; + x = tolower(*s); if (x!=tolower(*t)) break; if (!x) break; if (++s>=u) return 0; ++t; +#endif + } + return ((int)(unsigned int)(unsigned char) x) + - ((int)(unsigned int)(unsigned char) *t); +} diff --git a/mdk-stage1/dietlibc/lib/strncat.c b/mdk-stage1/dietlibc/lib/strncat.c index 1d3b94ca5..21e2be326 100644 --- a/mdk-stage1/dietlibc/lib/strncat.c +++ b/mdk-stage1/dietlibc/lib/strncat.c @@ -1,10 +1,17 @@ #include "dietfeatures.h" #include <string.h> +/* this implementation is not standards compliant. + * the standard says that strncat(dest,"foobar",3) should write 'f', 'o' + * and 'o'. The programmer is then expected to overwrite the last byte + * with '\0', which is often forgotten. This implementation makes sure + * the last written bytes is always '\0'. */ + char *strncat(char *s, const char *t, size_t n) { char *dest=s; - register char *max=s+n-1; + register char *max; s+=strlen(s); + max=s+n-1; for (;;) { if (!(*s = *t)) break; if (++s==max) break; ++t; #ifndef WANT_SMALL_STRING_ROUTINES diff --git a/mdk-stage1/dietlibc/lib/strrchr.c b/mdk-stage1/dietlibc/lib/strrchr.c index 3c91e9bc8..1abb655e2 100644 --- a/mdk-stage1/dietlibc/lib/strrchr.c +++ b/mdk-stage1/dietlibc/lib/strrchr.c @@ -16,3 +16,5 @@ char *strrchr(const char *t, int c) { } return (char*)l; } + +char *rindex(const char *t,int c) __attribute__((weak,alias("strrchr"))); diff --git a/mdk-stage1/dietlibc/lib/strsep.c b/mdk-stage1/dietlibc/lib/strsep.c new file mode 100644 index 000000000..a1bf1872a --- /dev/null +++ b/mdk-stage1/dietlibc/lib/strsep.c @@ -0,0 +1,16 @@ +#include <string.h> + +char *strsep(char **stringp, const char *delim) { + register char *tmp=*stringp; + register char *tmp2=tmp; + register const char *tmp3; + for (tmp2=tmp; *tmp2; ++tmp2) { + for (tmp3=delim; *tmp3; ++tmp3) + if (*tmp2==*tmp3) { /* delimiter found */ + *tmp2=0; + *stringp=tmp2+1; + return tmp; + } + } + return 0; +} diff --git a/mdk-stage1/dietlibc/lib/strtod.c b/mdk-stage1/dietlibc/lib/strtod.c index 767be679f..cbe983d84 100644 --- a/mdk-stage1/dietlibc/lib/strtod.c +++ b/mdk-stage1/dietlibc/lib/strtod.c @@ -29,10 +29,10 @@ double strtod(const char *nptr, char **endptr) { } if ((*c|32)=='e') { int exp=0; - char neg=0; + double factor=10; if (c[1]<'0') { - switch (*c) { - case '-': neg=1; + switch (c[1]) { + case '-': factor=0.1; case '+': c++; break; default: d=0; @@ -43,7 +43,7 @@ double strtod(const char *nptr, char **endptr) { while (isdigit(*++c)) exp=exp*10+(*c-'0'); while (exp) { /* XXX: this introduces rounding errors */ - d*=10; --exp; + d*=factor; --exp; } } done: diff --git a/mdk-stage1/dietlibc/lib/strtok.c b/mdk-stage1/dietlibc/lib/strtok.c index 525665e59..86337da7b 100644 --- a/mdk-stage1/dietlibc/lib/strtok.c +++ b/mdk-stage1/dietlibc/lib/strtok.c @@ -1,5 +1,7 @@ char *strtok_r(char *s, const char *delim, char **ptrptr); + static char *strtok_pos; + char *strtok(char *s, const char *delim) { return strtok_r(s,delim,&strtok_pos); diff --git a/mdk-stage1/dietlibc/lib/strtoul.c b/mdk-stage1/dietlibc/lib/strtoul.c index bee849685..3f93962a9 100644 --- a/mdk-stage1/dietlibc/lib/strtoul.c +++ b/mdk-stage1/dietlibc/lib/strtoul.c @@ -1,38 +1,31 @@ #include <ctype.h> -static char *num="0123456789abcdefghijklmnopqrstuvwxyz"; +/* static char *num="0123456789abcdefghijklmnopqrstuvwxyz"; */ unsigned long int strtoul(const char *nptr, char **endptr, int base) { long int v=0; - int a=1,i; - while(isspace(*nptr)) nptr++; + while(isspace(*nptr)) ++nptr; - if (*nptr == '+') { nptr++; } - if (!base) - { - if (*nptr=='0') - { + if (*nptr == '+') ++nptr; + if (!base) { + if (*nptr=='0') { base=8; - if ((*(nptr+1)=='x')||(*(nptr+1)=='X')) base=16; + if ((*(nptr+1)=='x')||(*(nptr+1)=='X')) { + nptr+=2; + base=16; + } } else base=10; } - while((a)&&(*nptr)) - { - a=0; - for (i=0;(!a)&&(i<base);i++) - { - if ((*nptr == num[i]) || (*nptr == (num[i]-' '))) - { - a=1; - v=(v*base)+(&num[i]-num); - } - } - if ((!a)&&(base==16)&&((*nptr=='x')||(*nptr=='X'))) a=1; - if (a) nptr++; + while(*nptr) { + register unsigned char c=*nptr; + c=(c>='a'?c-'a'+10:c>='A'?c-'A'+10:c-'0'); + if (c>=base) break; + v=v*base+c; + ++nptr; } if (endptr) *endptr=(char *)nptr; return v; diff --git a/mdk-stage1/dietlibc/lib/strtoull.c b/mdk-stage1/dietlibc/lib/strtoull.c index 64f095f60..40818958d 100644 --- a/mdk-stage1/dietlibc/lib/strtoull.c +++ b/mdk-stage1/dietlibc/lib/strtoull.c @@ -1,38 +1,29 @@ #include <ctype.h> -static char *num="0123456789abcdefghijklmnopqrstuvwxyz"; - unsigned long long int strtoull(const char *nptr, char **endptr, int base) { long long int v=0; - int a=1,i; - while(isspace(*nptr)) nptr++; + while(isspace(*nptr)) ++nptr; - if (*nptr == '+') { nptr++; } - if (!base) - { - if (*nptr=='0') - { + if (*nptr == '+') ++nptr; + if (!base) { + if (*nptr=='0') { base=8; - if ((*(nptr+1)=='x')||(*(nptr+1)=='X')) base=16; + if ((*(nptr+1)=='x')||(*(nptr+1)=='X')) { + nptr+=2; + base=16; + } } else base=10; } - while((a)&&(*nptr)) - { - a=0; - for (i=0;(!a)&&(i<base);i++) - { - if ((*nptr == num[i]) || (*nptr == (num[i]-' '))) - { - a=1; - v=(v*base)+(&num[i]-num); - } - } - if ((!a)&&(base==16)&&((*nptr=='x')||(*nptr=='X'))) a=1; - if (a) nptr++; + while(*nptr) { + register unsigned char c=*nptr; + c=(c>='a'?c-'a'+10:c>='A'?c-'A'+10:c-'0'); + if (c>=base) break; + v=v*base+c; + ++nptr; } if (endptr) *endptr=(char *)nptr; return v; diff --git a/mdk-stage1/dietlibc/lib/tcdrain.c b/mdk-stage1/dietlibc/lib/tcdrain.c new file mode 100644 index 000000000..7a760f643 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/tcdrain.c @@ -0,0 +1,8 @@ +#include <sys/ioctl.h> + +int __libc_tcdrain(int fd) +{ + return ioctl(fd, TCSBRK, 1); +} + +int tcdrain(int fd) __attribute__((weak,alias("__libc_tcdrain"))); diff --git a/mdk-stage1/dietlibc/lib/tcgetpgrp.c b/mdk-stage1/dietlibc/lib/tcgetpgrp.c new file mode 100644 index 000000000..f2a290651 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/tcgetpgrp.c @@ -0,0 +1,7 @@ +#include <termios.h> +#include <sys/ioctl.h> + +int tcgetpgrp(int fildes) +{ + return ioctl(fildes, TIOCGPGRP); +} diff --git a/mdk-stage1/dietlibc/lib/tcsetpgrp.c b/mdk-stage1/dietlibc/lib/tcsetpgrp.c new file mode 100644 index 000000000..6c40b5c79 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/tcsetpgrp.c @@ -0,0 +1,7 @@ +#include <termios.h> +#include <sys/ioctl.h> + +int tcsetpgrp(int fildes, pid_t pgrpid) +{ + return ioctl(fildes, TIOCSPGRP, &pgrpid); +} diff --git a/mdk-stage1/dietlibc/lib/telldir.c b/mdk-stage1/dietlibc/lib/telldir.c index eca175381..58be5d034 100644 --- a/mdk-stage1/dietlibc/lib/telldir.c +++ b/mdk-stage1/dietlibc/lib/telldir.c @@ -1,38 +1,7 @@ +#include "dietdirent.h" #include <unistd.h> -#include <errno.h> +#include <dirent.h> -#include "dirstream.h" - -#undef telldir -off_t -telldir(DIR * dir) -{ - off_t offset; - - if (!dir) { - errno = EBADF; - return -1; - } - - switch (dir->dd_getdents) - { - case no_getdents: - /* We are running the old kernel. This is the starting offset - of the next readdir(). */ - offset = lseek(dir->dd_fd, 0, SEEK_CUR); - break; - - case unknown: - /* readdir () is not called yet. but seekdir () may be called. */ - case have_getdents: - /* The next entry. */ - offset = dir->dd_nextoff; - break; - - default: - errno = EBADF; - offset = -1; - } - - return offset; +off_t telldir(DIR *d) { + return lseek(d->fd,0,SEEK_CUR)-d->num+d->cur; } diff --git a/mdk-stage1/dietlibc/lib/tolower.c b/mdk-stage1/dietlibc/lib/tolower.c new file mode 100644 index 000000000..4b7c7cf2d --- /dev/null +++ b/mdk-stage1/dietlibc/lib/tolower.c @@ -0,0 +1,6 @@ +#include <ctype.h> + +inline int tolower(int c) { + return (c>='A' && c<='Z')?c-'A'+'a':c; +} + diff --git a/mdk-stage1/dietlibc/lib/toupper.c b/mdk-stage1/dietlibc/lib/toupper.c new file mode 100644 index 000000000..c048e60bb --- /dev/null +++ b/mdk-stage1/dietlibc/lib/toupper.c @@ -0,0 +1,6 @@ +#include <ctype.h> + +inline int toupper(int c) { + return (c>='a' && c<='z')?c-'a'+'A':c; +} + diff --git a/mdk-stage1/dietlibc/lib/ttyname.c b/mdk-stage1/dietlibc/lib/ttyname.c index 81a0cbc66..a6b479088 100644 --- a/mdk-stage1/dietlibc/lib/ttyname.c +++ b/mdk-stage1/dietlibc/lib/ttyname.c @@ -1,7 +1,6 @@ #include "dietfeatures.h" #include <unistd.h> #include <sys/stat.h> -#include <string.h> #ifdef __linux__ diff --git a/mdk-stage1/dietlibc/lib/usleep.c b/mdk-stage1/dietlibc/lib/usleep.c new file mode 100644 index 000000000..494f99233 --- /dev/null +++ b/mdk-stage1/dietlibc/lib/usleep.c @@ -0,0 +1,12 @@ +#include <linux/time.h> +#include <time.h> + +/* nano * 1000 == usecs + * usecs * 1000 == msecs + * msecs * 1000 = secs */ +void usleep(unsigned int usecs) { + struct timespec t; + t.tv_sec=usecs/1000000; + t.tv_nsec=(usecs%1000000)*1000; + nanosleep(&t,&t); +} diff --git a/mdk-stage1/dietlibc/lib/vfprintf.c b/mdk-stage1/dietlibc/lib/vfprintf.c index 03dfe87a9..c33a2404b 100644 --- a/mdk-stage1/dietlibc/lib/vfprintf.c +++ b/mdk-stage1/dietlibc/lib/vfprintf.c @@ -1,11 +1,19 @@ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> +#include "dietstdarg.h" int vfprintf(FILE *fstream, const char *format, va_list ap) { - char tmp[1000000]; - size_t n = vsnprintf(tmp, sizeof(tmp), format, ap); - fwrite(tmp, n, 1, fstream); + char *tmp; + va_list cp_ap; + size_t n = 0; + + va_copy(cp_ap, ap); + n=vsnprintf(0, 1000000, format, cp_ap); + tmp=alloca(n+2); + vsnprintf(tmp, n+1, format, ap); + fwrite(tmp, n,1, fstream); return n; } + diff --git a/mdk-stage1/dietlibc/lib/vsnprintf.c b/mdk-stage1/dietlibc/lib/vsnprintf.c index 5bbc51620..f425066e3 100644 --- a/mdk-stage1/dietlibc/lib/vsnprintf.c +++ b/mdk-stage1/dietlibc/lib/vsnprintf.c @@ -3,33 +3,11 @@ #include <sys/types.h> #include <stdlib.h> #include <string.h> +#include "dietwarning.h" extern int __ltostr(char *s, int size, unsigned long i, int base, char UpCase); extern int __dtostr(double d,char *buf,int maxlen,int prec); -#include <unistd.h> -void print_int(int fd, int i) -{ - char buf[10]; - char * chptr = buf + 9; - int j = 0; - - if (i < 0) - { - write(1, "-", 1); - i = -1 * i; - } - - while (i) - { - *chptr-- = '0' + (i % 10); - j++; - i = i / 10; - } - - write(fd, chptr + 1, j); -} - int vsnprintf (char *str, size_t size, const char *format, va_list arg_ptr) { size_t apos,i; @@ -78,7 +56,7 @@ inn_vsnprintf: goto inn_vsnprintf; case 'l': - flag_long=1; + ++flag_long; goto inn_vsnprintf; case '0': @@ -111,10 +89,19 @@ inn_vsnprintf: format=pb; goto inn_vsnprintf; + case '*': + width=va_arg(arg_ptr,int); + goto inn_vsnprintf; + case '.': flag_dot=1; - preci=strtol(format,&pb,10); - format=pb; + if (*format=='*') { + preci=va_arg(arg_ptr,int); + ++format; + } else { + preci=strtol(format,&pb,10); + format=pb; + } goto inn_vsnprintf; /* Format conversion chars */ @@ -130,6 +117,8 @@ inn_vsnprintf: if (!pb) pb="(null)"; #endif buf_len=strlen(pb); + if (flag_dot && buf_len>preci) buf_len=preci; + if (buf_len>size-apos) buf_len=size-apos; print_out: if (str) { @@ -137,17 +126,16 @@ print_out: { for (pad=width-buf_len; pad>0; --pad) str[apos++]=padwith; } - for(i=0;(pb[i])&&(apos<size);i++) { str[apos++]=pb[i]; } /* strncpy */ + for(i=0;i<buf_len;++i) { str[apos++]=pb[i]; } /* strncpy */ if (width && (flag_left)) { for (pad=width-buf_len; pad>0; --pad) str[apos++]=padwith; } } else { - if (width) - apos+=width; - else { - int a=strlen(pb); - if (a>size) apos+=size; else apos+=a; + if (width) { + apos+=width>buf_len?width:buf_len; + } else { + apos+=size>buf_len?buf_len:size; } } @@ -214,10 +202,18 @@ num_vsnprintf: goto print_out; #ifdef WANT_FLOATING_POINT_IN_PRINTF + case 'f': case 'g': { double d=va_arg(arg_ptr,double); - buf_len=__dtostr(d,buf,sizeof(buf),6); + buf_len=__dtostr(d,buf,sizeof(buf),width?width:6); + if (flag_dot) { + char *tmp; + if ((tmp=strchr(buf,'.'))) { + while (preci>-1 && *++tmp) --preci; + *tmp=0; + } + } pb=buf; goto print_out; } @@ -237,3 +233,6 @@ num_vsnprintf: if (str) str[apos]=0; return apos; } + +link_warning("vsnprintf","warning: the printf functions add several kilobytes of bloat.") + diff --git a/mdk-stage1/dietlibc/lib/vsprintf.c b/mdk-stage1/dietlibc/lib/vsprintf.c index af4eea852..10ff04bd7 100644 --- a/mdk-stage1/dietlibc/lib/vsprintf.c +++ b/mdk-stage1/dietlibc/lib/vsprintf.c @@ -1,11 +1,10 @@ #include <stdarg.h> #include <linux/types.h> -#include <unistd.h> #include <stdlib.h> int vsnprintf (char *str,size_t size,const char *format, va_list arg_ptr); -int vsprintf(char *str, const char *format, va_list ap) +int vsprintf(char *dest,const char *format, va_list arg_ptr) { - return vsnprintf(str, 1000000, format, ap); + return vsnprintf(dest,1000000,format,arg_ptr); } diff --git a/mdk-stage1/dietlibc/lib/vsscanf.c b/mdk-stage1/dietlibc/lib/vsscanf.c index a646ad92d..108555b33 100644 --- a/mdk-stage1/dietlibc/lib/vsscanf.c +++ b/mdk-stage1/dietlibc/lib/vsscanf.c @@ -3,6 +3,7 @@ #include <sys/types.h> #include <ctype.h> #include <stdlib.h> +#include <string.h> const char *skip_ws(const char *str) { @@ -15,15 +16,15 @@ extern double strtod(const char *s,char **f); int vsscanf(const char *str, const char *format, va_list arg_ptr) { int n=0,div; - char ch; + unsigned char ch; char flag_discard, flag_malloc, flag_half, flag_long, flag_longlong; char flag_width; unsigned long width; -#ifdef WANT_FLOATING_POINT_IN_SCANF /* arg_ptr tmps */ +#ifdef WANT_FLOATING_POINT_IN_SCANF double d,*pd; float *pf; #endif @@ -216,15 +217,74 @@ inn_vsscanf: } if (*(str=skip_ws(str))) { - while (width && *str && (!isspace(*str))) + while (width && (!isspace(*str))) { if (!flag_discard) *(s++)=*(str); + if (!*str) break; ++str; --width; } - *s = '\0'; } break; + +#ifdef WANT_CHARACTER_CLASSES_IN_SCANF + case '[': + { + char cset[256]; + int flag_not=0; + int flag_dash=0; + memset(cset,0,sizeof(cset)); + ch=*format++; + + /* first char specials */ + if (ch=='^') + { + flag_not=1; + ch=*format++; + } + if ((ch=='-')||(ch==']')) + { + cset[ch]=1; + ch=*format++; + } + + /* almost all non special chars */ + for (;(*format) && (*format!=']');++format) { + if (flag_dash) + { + register unsigned char tmp=*format; + for (;ch<=tmp;++ch) cset[ch]=1; + flag_dash=0; + ch=*(++format); + } + else if (*format=='-') flag_dash=1; + else + { + cset[ch]=1; + ch=*format; + } + } + + /* last char specials */ + if (flag_dash) cset['-']=1; + else cset[ch]=1; + + /* like %c or %s */ + if (!flag_discard) + { + s=(char *)va_arg(arg_ptr,char*); + ++n; + } + while (width && (cset[(unsigned char)(*str)]-flag_not)) + { + if (!flag_discard) *(s++)=*(str); + if (!*str) break; + ++str; + --width; + } + } + break; +#endif } break; diff --git a/mdk-stage1/dietlibc/ppc/Makefile.add b/mdk-stage1/dietlibc/ppc/Makefile.add index b71031e05..641cf1ade 100644 --- a/mdk-stage1/dietlibc/ppc/Makefile.add +++ b/mdk-stage1/dietlibc/ppc/Makefile.add @@ -1,3 +1,3 @@ CFLAGS+=-mpowerpc-gpopt -mpowerpc-gfxopt -Os -override VPATH=ppc:syscalls.s:lib +VPATH:=ppc:syscalls.s:$(VPATH) diff --git a/mdk-stage1/dietlibc/ppc/__longjmp.S b/mdk-stage1/dietlibc/ppc/__longjmp.S index deada115e..8113eeeea 100644 --- a/mdk-stage1/dietlibc/ppc/__longjmp.S +++ b/mdk-stage1/dietlibc/ppc/__longjmp.S @@ -1,6 +1,4 @@ -#define _ASM -#define _SETJMP_H -#include <bits/setjmp.h> +#include <setjmp.h> #ifdef PIC diff --git a/mdk-stage1/dietlibc/ppc/__testandset.S b/mdk-stage1/dietlibc/ppc/__testandset.S new file mode 100644 index 000000000..a6063fbb2 --- /dev/null +++ b/mdk-stage1/dietlibc/ppc/__testandset.S @@ -0,0 +1,11 @@ +.global __testandset +.type __testandset,@function +.align 2 +__testandset: + lwarx 5,0,3 + add 0,4,5 + stwcx 0,0,3 + bne __testandset + blr +.size __testandset,.-__testandset + diff --git a/mdk-stage1/dietlibc/sparc/Makefile.add b/mdk-stage1/dietlibc/sparc/Makefile.add index a12a0446a..0de05b1db 100644 --- a/mdk-stage1/dietlibc/sparc/Makefile.add +++ b/mdk-stage1/dietlibc/sparc/Makefile.add @@ -1,3 +1,3 @@ CFLAGS+=-mcpu=supersparc -Os -override VPATH=sparc:syscalls.s:lib +VPATH:=sparc:syscalls.s:$(VPATH) diff --git a/mdk-stage1/dietlibc/sparc/__longjmp.S b/mdk-stage1/dietlibc/sparc/__longjmp.S index 81dd24af2..72e001a2f 100644 --- a/mdk-stage1/dietlibc/sparc/__longjmp.S +++ b/mdk-stage1/dietlibc/sparc/__longjmp.S @@ -1,7 +1,8 @@ -#define _ASM -#define _SETJMP_H -#include <bits/setjmp.h> +#include <setjmp.h> +#define JB_SP 0 +#define JB_FP 1 +#define JB_PC 2 #define ENV(base,reg) [%base + (reg * 4)] #define ST_FLUSH_WINDOWS 3 diff --git a/mdk-stage1/dietlibc/sparc/__testandset.S b/mdk-stage1/dietlibc/sparc/__testandset.S new file mode 100644 index 000000000..84f6cf597 --- /dev/null +++ b/mdk-stage1/dietlibc/sparc/__testandset.S @@ -0,0 +1,6 @@ +.text +.align 4 +.global __testandset +__testandset: + retl + ldstub [%o0], %o0 diff --git a/mdk-stage1/dietlibc/sparc/clone.S b/mdk-stage1/dietlibc/sparc/clone.S new file mode 100644 index 000000000..58b438249 --- /dev/null +++ b/mdk-stage1/dietlibc/sparc/clone.S @@ -0,0 +1,45 @@ +#include <asm/errno.h> +#include <asm/unistd.h> + +.text +.align 4 +.weak clone +clone: +.global __clone +__clone: + save %sp, -96, %sp + + tst %i0 /* check for function pointer */ + be .Lerror + tst %i1 /* check for stack pointer */ + be .Lerror + nop + + mov %i1, %o1 /* child-stack */ + mov %i2, %o0 /* clone-flags */ + mov __NR_clone, %g1 + ta 0x10 /* syscall: clone */ + bcs .Lerror + + tst %o1 + bne .Lstart /* we are the child :) */ + nop + mov %o0, %i0 /* return child pid */ + ret + restore + +.Lerror: + call __errno_location + nop + mov EINVAL, %l0 + st %l0, [%o0] + ret + restore %g0, -1, %o0 + +.Lstart: + call %i0 /* call child-function */ + mov %i3, %o0 /* put arg in the right place for the child */ + + call _exit /* child returned */ + nop + diff --git a/mdk-stage1/dietlibc/sparc/fork.S b/mdk-stage1/dietlibc/sparc/fork.S index 150839971..869c9b30c 100644 --- a/mdk-stage1/dietlibc/sparc/fork.S +++ b/mdk-stage1/dietlibc/sparc/fork.S @@ -1,19 +1,25 @@ #include "syscalls.h" .text -.global fork +.weak fork fork: +.global __libc_fork +__libc_fork: mov 2, %g1 ta 0x10 bcc,a 1f nop - - sethi %hi(errno), %o3 - or %o3, %lo(errno), %o3 - st %i0, [%o3] - + save %sp, -96, %sp +#ifdef WANT_THREAD_SAVE + call __errno_location + nop +#else + sethi %hi(errno), %o0 + or %o0, %lo(errno), %o0 +#endif + st %i0, [ %o0 ] retl - mov -1, %o0 + restore %g0, -1, %o0 1: dec %o1 retl and %o0, %o1, %o0 diff --git a/mdk-stage1/dietlibc/sparc/pipe.S b/mdk-stage1/dietlibc/sparc/pipe.S index b8ad1d251..820da2570 100644 --- a/mdk-stage1/dietlibc/sparc/pipe.S +++ b/mdk-stage1/dietlibc/sparc/pipe.S @@ -3,18 +3,24 @@ .text .global pipe pipe: + mov %o0, %o2 mov __NR_pipe, %g1 ta 0x10 - bcc,a .Lnoerror + bcc,a 1f nop save %sp, -96, %sp +#ifdef WANT_THREAD_SAVE call __errno_location nop +#else + sethi %hi(errno), %o0 + or %o0, %lo(errno), %o0 +#endif st %i0, [ %o0 ] ret restore %g0, -1, %o0 -.Lnoerror: - st %o0, [ %o2 ] + +1: st %o0, [ %o2 ] st %o1, [ %o2 + 4 ] retl mov %g0, %o0 diff --git a/mdk-stage1/dietlibc/sparc/setjmp.S b/mdk-stage1/dietlibc/sparc/setjmp.S index be77af3c4..efc5a7013 100644 --- a/mdk-stage1/dietlibc/sparc/setjmp.S +++ b/mdk-stage1/dietlibc/sparc/setjmp.S @@ -1,6 +1,8 @@ -#define _ASM -#define _SETJMP_H -#include <bits/setjmp.h> +#include <setjmp.h> + +#define JB_SP 0 +#define JB_FP 1 +#define JB_PC 2 #define ST_FLUSH_WINDOWS 0x03 diff --git a/mdk-stage1/dietlibc/sparc/shmat.c b/mdk-stage1/dietlibc/sparc/shmat.c new file mode 100644 index 000000000..73b2d89a9 --- /dev/null +++ b/mdk-stage1/dietlibc/sparc/shmat.c @@ -0,0 +1,19 @@ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/shm.h> +#include <asm/ipc.h> + +extern void* __ipc(); + +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif + +void* shmat(int shmid,const void* shmaddr,int shmflg) { + void* raddr; + register void* result; + result=__ipc(SHMAT,shmid,shmflg,&raddr,shmaddr); + if ((unsigned long)result <= -(unsigned long)PAGE_SIZE) + result=raddr; + return result; +} diff --git a/mdk-stage1/dietlibc/sparc/unified.S b/mdk-stage1/dietlibc/sparc/unified.S index 53b1612a9..3cd609da5 100644 --- a/mdk-stage1/dietlibc/sparc/unified.S +++ b/mdk-stage1/dietlibc/sparc/unified.S @@ -22,7 +22,7 @@ __unified_syscall: or %o0, %lo(errno), %o0 #endif st %l3, [ %o0 ] - mov -1, %o0 + mov -1, %i0 2: ret restore diff --git a/mdk-stage1/dietlibc/start.h b/mdk-stage1/dietlibc/start.h index 5983b0462..7f9e6be28 100644 --- a/mdk-stage1/dietlibc/start.h +++ b/mdk-stage1/dietlibc/start.h @@ -1,10 +1,14 @@ .section ".bss" - .align 8 +.align 8 - .weak errno +.weak errno errno: +.global __errno +__errno: .long 0 - .weak environ +.weak environ environ: +.global __environ +__environ: .long 0 diff --git a/mdk-stage1/dietlibc/syscalls.h b/mdk-stage1/dietlibc/syscalls.h index 5e9782ee9..eba7a3c00 100644 --- a/mdk-stage1/dietlibc/syscalls.h +++ b/mdk-stage1/dietlibc/syscalls.h @@ -10,6 +10,15 @@ #ifdef __i386__ +#define syscall_weak(name,wsym,sym) \ +.text; \ +.weak wsym; \ +wsym: ; \ +.global sym; \ +sym: \ + movb $__NR_##name,%al; \ + jmp __unified_syscall + #define syscall(name,sym) \ .text; \ .global sym; \ @@ -21,6 +30,15 @@ sym: \ #ifdef __sparc__ +#define syscall_weak(name,wsym,sym) \ +.text; \ +.weak wsym; \ +wsym: ; \ +.global sym; \ +sym: \ + b __unified_syscall; \ + mov __NR_##name, %g1 + #define syscall(name,sym) \ .text; \ .global sym; \ @@ -32,6 +50,15 @@ sym: \ #ifdef __powerpc__ +#define syscall_weak(name,wsym,sym) \ +.text; \ +.weak wsym; \ +wsym: ; \ +.global sym; \ +sym: \ + li 0,__NR_##name; \ + b __unified_syscall + #define syscall(name,sym) \ .text; \ .global sym; \ @@ -44,6 +71,18 @@ sym: \ #ifdef __mips__ +#define syscall_weak(name,wsym,sym) \ +.text; \ +.weak wsym; \ +wsym: ; \ +.global sym; \ +.ent sym; \ +sym: \ + li $2,__NR_##name; \ + la $25,__unified_syscall; \ + jr $25; \ +.end sym + #define syscall(name,sym) \ .text; \ .global sym; \ @@ -58,6 +97,15 @@ sym: \ #ifdef __arm__ +#define syscall_weak(name,wsym,sym) \ +.text; \ +.weak wsym; \ +wsym: ; \ +.global sym; \ +sym: \ + swi __NR_##name; \ + b __unified_syscall + #define syscall(name,sym) \ .text; \ .global sym; \ @@ -70,6 +118,18 @@ sym: \ #ifdef __alpha__ +#define syscall_weak(name,wsym,sym) \ +.text ; \ +.align 2 ; \ +.weak wsym; \ +.type wsym,@function ; \ +wsym: ; \ +.global sym ; \ +.type sym,@function ; \ +sym: ; \ + lda $0, __NR_##name($31) ; \ + br __unified_syscall + #define syscall(name,sym) \ .text ; \ .align 2 ; \ diff --git a/mdk-stage1/dietlibc/syscalls.s/__getpagesize.S b/mdk-stage1/dietlibc/syscalls.s/__getpagesize.S new file mode 100644 index 000000000..c9fd97898 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/__getpagesize.S @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_getpagesize +syscall(getpagesize,getpagesize) +#endif diff --git a/mdk-stage1/dietlibc/syscalls.s/__pread.S b/mdk-stage1/dietlibc/syscalls.s/__pread.S index 4603a1009..ad47c7873 100644 --- a/mdk-stage1/dietlibc/syscalls.s/__pread.S +++ b/mdk-stage1/dietlibc/syscalls.s/__pread.S @@ -1,4 +1,3 @@ #include "syscalls.h" -.weak __libc_pread -syscall(pread,__pread) +syscall_weak(pread,__pread,__libc__pread) diff --git a/mdk-stage1/dietlibc/syscalls.s/__reboot.S b/mdk-stage1/dietlibc/syscalls.s/__reboot.S new file mode 100644 index 000000000..0de4f25b2 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/__reboot.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(reboot,__reboot) diff --git a/mdk-stage1/dietlibc/syscalls.s/close.S b/mdk-stage1/dietlibc/syscalls.s/close.S index 0f72ca1ae..361ca5272 100644 --- a/mdk-stage1/dietlibc/syscalls.s/close.S +++ b/mdk-stage1/dietlibc/syscalls.s/close.S @@ -1,5 +1,3 @@ #include "syscalls.h" -.weak __libc_close -__libc_close: -syscall(close,close) +syscall_weak(close,close,__libc_close) diff --git a/mdk-stage1/dietlibc/syscalls.s/exit.S b/mdk-stage1/dietlibc/syscalls.s/exit.S index 89d3145e9..11c989529 100644 --- a/mdk-stage1/dietlibc/syscalls.s/exit.S +++ b/mdk-stage1/dietlibc/syscalls.s/exit.S @@ -1,6 +1,3 @@ #include "syscalls.h" -.text -.weak exit -exit: -syscall(exit,_exit) +syscall_weak(exit,exit,_exit) diff --git a/mdk-stage1/dietlibc/syscalls.s/fcntl.S b/mdk-stage1/dietlibc/syscalls.s/fcntl.S index 8516bc232..2285929a0 100644 --- a/mdk-stage1/dietlibc/syscalls.s/fcntl.S +++ b/mdk-stage1/dietlibc/syscalls.s/fcntl.S @@ -1,5 +1,3 @@ #include "syscalls.h" -.weak __libc_fcntl -__libc_fcntl: -syscall(fcntl,fcntl) +syscall_weak(fcntl,fcntl,__libc_fcntl) diff --git a/mdk-stage1/dietlibc/syscalls.s/fork.S b/mdk-stage1/dietlibc/syscalls.s/fork.S index 66732d27e..b40c3f708 100644 --- a/mdk-stage1/dietlibc/syscalls.s/fork.S +++ b/mdk-stage1/dietlibc/syscalls.s/fork.S @@ -1,5 +1,3 @@ #include "syscalls.h" -.weak __libc_fork -__libc_fork: -syscall(fork,fork) +syscall_weak(fork,fork,__libc_fork) diff --git a/mdk-stage1/dietlibc/syscalls.s/fstat.S b/mdk-stage1/dietlibc/syscalls.s/fstat.S new file mode 100644 index 000000000..9dd465cda --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/fstat.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(fstat,fstat) diff --git a/mdk-stage1/dietlibc/syscalls.s/fstat64.S b/mdk-stage1/dietlibc/syscalls.s/fstat64.S new file mode 100644 index 000000000..0c7a41609 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/fstat64.S @@ -0,0 +1,8 @@ +#include "dietfeatures.h" +#include "syscalls.h" + +#ifdef WANT_LARGEFILE_BACKCOMPAT +syscall(fstat64,__dietlibc_fstat64) +#else +syscall(fstat64,fstat64) +#endif diff --git a/mdk-stage1/dietlibc/syscalls.s/fsync.S b/mdk-stage1/dietlibc/syscalls.s/fsync.S index 624cbaf97..66af59ef9 100644 --- a/mdk-stage1/dietlibc/syscalls.s/fsync.S +++ b/mdk-stage1/dietlibc/syscalls.s/fsync.S @@ -1,3 +1,3 @@ #include "syscalls.h" -syscall(fsync,fsync) +syscall_weak(fsync,fsync,__libc_fsync) diff --git a/mdk-stage1/dietlibc/syscalls.s/getcwd.S b/mdk-stage1/dietlibc/syscalls.s/getcwd.S index 8ff0a026e..e13262f20 100644 --- a/mdk-stage1/dietlibc/syscalls.s/getcwd.S +++ b/mdk-stage1/dietlibc/syscalls.s/getcwd.S @@ -1,3 +1,3 @@ #include "syscalls.h" -syscall(getcwd,getcwd) +syscall(getcwd,__syscall_getcwd) diff --git a/mdk-stage1/dietlibc/syscalls.s/getitimer.S b/mdk-stage1/dietlibc/syscalls.s/getitimer.S new file mode 100644 index 000000000..9a2084080 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/getitimer.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(getitimer,getitimer) diff --git a/mdk-stage1/dietlibc/syscalls.s/getpriority.S b/mdk-stage1/dietlibc/syscalls.s/getpriority.S new file mode 100644 index 000000000..848b27ed7 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/getpriority.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(getpriority,getpriority) diff --git a/mdk-stage1/dietlibc/syscalls.s/iopl.S b/mdk-stage1/dietlibc/syscalls.s/iopl.S new file mode 100644 index 000000000..06a6c53fb --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/iopl.S @@ -0,0 +1,6 @@ + +#include "syscalls.h" + +#ifdef __NR_iopl +syscall(iopl,iopl) +#endif diff --git a/mdk-stage1/dietlibc/syscalls.s/ipc.S b/mdk-stage1/dietlibc/syscalls.s/ipc.S new file mode 100644 index 000000000..40479400d --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/ipc.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(ipc,__ipc) diff --git a/mdk-stage1/dietlibc/syscalls.s/llseek.S b/mdk-stage1/dietlibc/syscalls.s/llseek.S new file mode 100644 index 000000000..0318b492e --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/llseek.S @@ -0,0 +1,6 @@ +#include "dietfeatures.h" +#include "syscalls.h" + +#ifdef __NR__llseek +syscall(_llseek,llseek) +#endif diff --git a/mdk-stage1/dietlibc/syscalls.s/lseek.S b/mdk-stage1/dietlibc/syscalls.s/lseek.S index 454827483..93707a22a 100644 --- a/mdk-stage1/dietlibc/syscalls.s/lseek.S +++ b/mdk-stage1/dietlibc/syscalls.s/lseek.S @@ -1,3 +1,3 @@ #include "syscalls.h" -syscall(lseek,lseek) +syscall_weak(lseek,lseek,__libc_lseek) diff --git a/mdk-stage1/dietlibc/syscalls.s/lstat.S b/mdk-stage1/dietlibc/syscalls.s/lstat.S new file mode 100644 index 000000000..5720161c0 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/lstat.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(lstat,lstat) diff --git a/mdk-stage1/dietlibc/syscalls.s/lstat64.S b/mdk-stage1/dietlibc/syscalls.s/lstat64.S new file mode 100644 index 000000000..33fd5ab94 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/lstat64.S @@ -0,0 +1,8 @@ +#include "dietfeatures.h" +#include "syscalls.h" + +#ifdef WANT_LARGEFILE_BACKCOMPAT +syscall(lstat64,__dietlibc_lstat64) +#else +syscall(lstat64,lstat64) +#endif diff --git a/mdk-stage1/dietlibc/syscalls.s/mlockall.S b/mdk-stage1/dietlibc/syscalls.s/mlockall.S new file mode 100644 index 000000000..6ad0eef9d --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/mlockall.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(mlockall,mlockall) diff --git a/mdk-stage1/dietlibc/syscalls.s/munlockall.S b/mdk-stage1/dietlibc/syscalls.s/munlockall.S new file mode 100644 index 000000000..776811dea --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/munlockall.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(munlockall,munlockall) diff --git a/mdk-stage1/dietlibc/syscalls.s/nanosleep.S b/mdk-stage1/dietlibc/syscalls.s/nanosleep.S index 7dce9956d..279a52604 100644 --- a/mdk-stage1/dietlibc/syscalls.s/nanosleep.S +++ b/mdk-stage1/dietlibc/syscalls.s/nanosleep.S @@ -1,3 +1,3 @@ #include "syscalls.h" -syscall(nanosleep,nanosleep) +syscall_weak(nanosleep,nanosleep,__libc_nanosleep) diff --git a/mdk-stage1/dietlibc/syscalls.s/nice.S b/mdk-stage1/dietlibc/syscalls.s/nice.S new file mode 100644 index 000000000..7d3f740b2 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/nice.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(nice,nice) diff --git a/mdk-stage1/dietlibc/syscalls.s/open.S b/mdk-stage1/dietlibc/syscalls.s/open.S index 11cfecd4a..280efd0d9 100644 --- a/mdk-stage1/dietlibc/syscalls.s/open.S +++ b/mdk-stage1/dietlibc/syscalls.s/open.S @@ -1,3 +1,3 @@ #include "syscalls.h" -syscall(open,open) +syscall_weak(open,open,__libc_open) diff --git a/mdk-stage1/dietlibc/syscalls.s/pause.S b/mdk-stage1/dietlibc/syscalls.s/pause.S new file mode 100644 index 000000000..cdf42cabd --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/pause.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall_weak(pause,pause,__libc_pause) diff --git a/mdk-stage1/dietlibc/syscalls.s/personality.S b/mdk-stage1/dietlibc/syscalls.s/personality.S new file mode 100644 index 000000000..34b467084 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/personality.S @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_personality +syscall(personality,personality) +#endif diff --git a/mdk-stage1/dietlibc/syscalls.s/ptrace.s b/mdk-stage1/dietlibc/syscalls.s/ptrace.s new file mode 100644 index 000000000..392e6a4ed --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/ptrace.s @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(ptrace,ptrace) diff --git a/mdk-stage1/dietlibc/syscalls.s/query_module.S b/mdk-stage1/dietlibc/syscalls.s/query_module.S new file mode 100644 index 000000000..cb2f1d852 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/query_module.S @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_query_module +syscall(query_module,query_module) +#endif diff --git a/mdk-stage1/dietlibc/syscalls.s/read.S b/mdk-stage1/dietlibc/syscalls.s/read.S index 98ad98c17..33fdb7531 100644 --- a/mdk-stage1/dietlibc/syscalls.s/read.S +++ b/mdk-stage1/dietlibc/syscalls.s/read.S @@ -1,5 +1,3 @@ #include "syscalls.h" -.weak __libc_read -__libc_read: -syscall(read,read) +syscall_weak(read,read,__libc_read) diff --git a/mdk-stage1/dietlibc/syscalls.s/readv.S b/mdk-stage1/dietlibc/syscalls.s/readv.S new file mode 100644 index 000000000..757c26bfb --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/readv.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(readv,readv) diff --git a/mdk-stage1/dietlibc/syscalls.s/sched_get_priority_max.S b/mdk-stage1/dietlibc/syscalls.s/sched_get_priority_max.S new file mode 100644 index 000000000..caf403672 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/sched_get_priority_max.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sched_get_priority_max,sched_get_priority_max) diff --git a/mdk-stage1/dietlibc/syscalls.s/sched_get_priority_min.S b/mdk-stage1/dietlibc/syscalls.s/sched_get_priority_min.S new file mode 100644 index 000000000..a0c3337dc --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/sched_get_priority_min.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sched_get_priority_min,sched_get_priority_min) diff --git a/mdk-stage1/dietlibc/syscalls.s/sched_getparam.S b/mdk-stage1/dietlibc/syscalls.s/sched_getparam.S new file mode 100644 index 000000000..7190a40ae --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/sched_getparam.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sched_getparam,sched_getparam) diff --git a/mdk-stage1/dietlibc/syscalls.s/sched_getscheduler.S b/mdk-stage1/dietlibc/syscalls.s/sched_getscheduler.S new file mode 100644 index 000000000..08709b65e --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/sched_getscheduler.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sched_getscheduler,sched_getscheduler) diff --git a/mdk-stage1/dietlibc/syscalls.s/sched_rr_get_interval.S b/mdk-stage1/dietlibc/syscalls.s/sched_rr_get_interval.S new file mode 100644 index 000000000..150b9a98d --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/sched_rr_get_interval.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sched_rr_get_interval,sched_rr_get_interval) diff --git a/mdk-stage1/dietlibc/syscalls.s/sched_setparam.S b/mdk-stage1/dietlibc/syscalls.s/sched_setparam.S new file mode 100644 index 000000000..3a6dd1dcc --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/sched_setparam.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sched_setparam,sched_setparam) diff --git a/mdk-stage1/dietlibc/syscalls.s/sched_setscheduler.S b/mdk-stage1/dietlibc/syscalls.s/sched_setscheduler.S new file mode 100644 index 000000000..27869d6ce --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/sched_setscheduler.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sched_setscheduler,sched_setscheduler) diff --git a/mdk-stage1/dietlibc/syscalls.s/sched_yield.S b/mdk-stage1/dietlibc/syscalls.s/sched_yield.S new file mode 100644 index 000000000..ccb9ac1d0 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/sched_yield.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sched_yield,sched_yield) diff --git a/mdk-stage1/dietlibc/syscalls.s/select.S b/mdk-stage1/dietlibc/syscalls.s/select.S index 3353848ff..f585d0449 100644 --- a/mdk-stage1/dietlibc/syscalls.s/select.S +++ b/mdk-stage1/dietlibc/syscalls.s/select.S @@ -1,4 +1,3 @@ #include "syscalls.h" -.text syscall(select,select) diff --git a/mdk-stage1/dietlibc/syscalls.s/sendfile.S b/mdk-stage1/dietlibc/syscalls.s/sendfile.S index d56219dc6..12d6195dd 100644 --- a/mdk-stage1/dietlibc/syscalls.s/sendfile.S +++ b/mdk-stage1/dietlibc/syscalls.s/sendfile.S @@ -1,5 +1,6 @@ #include "syscalls.h" +#include "dietwarning.h" -.weak __libc_sendfile -__libc_sendfile: -syscall(sendfile,sendfile) +syscall_weak(sendfile,sendfile,__libc_sendfile) + +link_warning(sendfile,"sendfile is not portable and does not support large files") diff --git a/mdk-stage1/dietlibc/syscalls.s/setpriority.S b/mdk-stage1/dietlibc/syscalls.s/setpriority.S new file mode 100644 index 000000000..57d7bc388 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/setpriority.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(setpriority,setpriority) diff --git a/mdk-stage1/dietlibc/syscalls.s/sigaltstack.S b/mdk-stage1/dietlibc/syscalls.s/sigaltstack.S new file mode 100644 index 000000000..b07d90f40 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/sigaltstack.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall_weak(sigaltstack,sigaltstack,__sigaltstack) diff --git a/mdk-stage1/dietlibc/syscalls.s/sigprocmask.S b/mdk-stage1/dietlibc/syscalls.s/sigprocmask.S index 8d6563b8f..07f5b9d26 100644 --- a/mdk-stage1/dietlibc/syscalls.s/sigprocmask.S +++ b/mdk-stage1/dietlibc/syscalls.s/sigprocmask.S @@ -1,6 +1,3 @@ #include "syscalls.h" -.text -.weak sigprocmask -sigprocmask: -syscall(sigprocmask,__sigprocmask) +syscall_weak(sigprocmask,sigprocmask,__sigprocmask) diff --git a/mdk-stage1/dietlibc/syscalls.s/sigsuspend.S b/mdk-stage1/dietlibc/syscalls.s/sigsuspend.S index c832c2b5d..062264ab6 100644 --- a/mdk-stage1/dietlibc/syscalls.s/sigsuspend.S +++ b/mdk-stage1/dietlibc/syscalls.s/sigsuspend.S @@ -1,3 +1,3 @@ #include "syscalls.h" -syscall(sigsuspend,sigsuspend) +syscall_weak(sigsuspend,sigsuspend,__libc_sigsuspend) diff --git a/mdk-stage1/dietlibc/syscalls.s/stat.S b/mdk-stage1/dietlibc/syscalls.s/stat.S new file mode 100644 index 000000000..2aa3bc088 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/stat.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(stat,stat) diff --git a/mdk-stage1/dietlibc/syscalls.s/stat64.S b/mdk-stage1/dietlibc/syscalls.s/stat64.S new file mode 100644 index 000000000..734fcab20 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/stat64.S @@ -0,0 +1,8 @@ +#include "dietfeatures.h" +#include "syscalls.h" + +#ifdef WANT_LARGEFILE_BACKCOMPAT +syscall(stat64,__dietlibc_stat64) +#else +syscall(stat64,stat64) +#endif diff --git a/mdk-stage1/dietlibc/syscalls.s/stime.S b/mdk-stage1/dietlibc/syscalls.s/stime.S new file mode 100644 index 000000000..9d9f5bf0a --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/stime.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(stime,stime) diff --git a/mdk-stage1/dietlibc/syscalls.s/sysctl.S b/mdk-stage1/dietlibc/syscalls.s/sysctl.S new file mode 100644 index 000000000..536e62b3d --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/sysctl.S @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_sysctl +syscall(sysctl,_sysctl) +#endif diff --git a/mdk-stage1/dietlibc/syscalls.s/sysinfo.S b/mdk-stage1/dietlibc/syscalls.s/sysinfo.S new file mode 100644 index 000000000..eaec7941e --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/sysinfo.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(sysinfo,sysinfo) diff --git a/mdk-stage1/dietlibc/syscalls.s/syslog.S b/mdk-stage1/dietlibc/syscalls.s/syslog.S index 55df87d53..6af3c4eac 100644 --- a/mdk-stage1/dietlibc/syscalls.s/syslog.S +++ b/mdk-stage1/dietlibc/syscalls.s/syslog.S @@ -1,3 +1,3 @@ #include "syscalls.h" -syscall(syslog,syslog) +syscall(syslog,__syscall_syslog) diff --git a/mdk-stage1/dietlibc/syscalls.s/times.S b/mdk-stage1/dietlibc/syscalls.s/times.S new file mode 100644 index 000000000..dcc8a6dd0 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/times.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(times,times) diff --git a/mdk-stage1/dietlibc/syscalls.s/umount2.S b/mdk-stage1/dietlibc/syscalls.s/umount2.S new file mode 100644 index 000000000..4cdd6a200 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/umount2.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(umount2,umount2) diff --git a/mdk-stage1/dietlibc/syscalls.s/waitpid.S b/mdk-stage1/dietlibc/syscalls.s/waitpid.S index 569d8f68d..5cdc18afb 100644 --- a/mdk-stage1/dietlibc/syscalls.s/waitpid.S +++ b/mdk-stage1/dietlibc/syscalls.s/waitpid.S @@ -1,3 +1,3 @@ #include "syscalls.h" -syscall(waitpid,waitpid) +syscall_weak(waitpid,waitpid,__libc_waitpid) diff --git a/mdk-stage1/dietlibc/syscalls.s/write.S b/mdk-stage1/dietlibc/syscalls.s/write.S index 409575be0..ba20395df 100644 --- a/mdk-stage1/dietlibc/syscalls.s/write.S +++ b/mdk-stage1/dietlibc/syscalls.s/write.S @@ -1,5 +1,3 @@ #include "syscalls.h" -.weak __libc_write -__libc_write: -syscall(write,write) +syscall_weak(write,write,__libc_write) diff --git a/mdk-stage1/dietlibc/syscalls.s/writev.S b/mdk-stage1/dietlibc/syscalls.s/writev.S new file mode 100644 index 000000000..8ec7aa6b0 --- /dev/null +++ b/mdk-stage1/dietlibc/syscalls.s/writev.S @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(writev,writev) |