diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-07-05 19:23:36 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-07-05 19:23:36 +0000 |
commit | 9281d180d13057917f618c35ef7433d2e4d4dd86 (patch) | |
tree | b497158acdc1a81b93b938a2f76376c88bc7799b /libc/sysdeps | |
parent | 775622914fa0a2814c705d25b1a3929002c5c785 (diff) | |
download | uClibc-alpine-9281d180d13057917f618c35ef7433d2e4d4dd86.tar.bz2 uClibc-alpine-9281d180d13057917f618c35ef7433d2e4d4dd86.tar.xz |
Completely rearchitected the sysdeps directory.
-Erik
Diffstat (limited to 'libc/sysdeps')
-rw-r--r-- | libc/sysdeps/Makefile | 10 | ||||
-rw-r--r-- | libc/sysdeps/README | 6 | ||||
-rw-r--r-- | libc/sysdeps/linux/Makefile | 20 | ||||
-rw-r--r-- | libc/sysdeps/linux/README | 7 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/Makefile | 24 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/getdnnm.c | 24 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/gethstnm.c | 24 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/getpagesize.c | 38 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/kernel_version.c | 95 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/mkfifo.c | 34 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/setegid.c | 6 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/seteuid.c | 22 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/setpgrp.c | 11 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/tell.c | 15 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/wait.c | 12 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/wait3.c | 12 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/waitpid.c | 13 | ||||
-rw-r--r-- | libc/sysdeps/linux/i386/Makefile | 29 | ||||
-rw-r--r-- | libc/sysdeps/linux/i386/setjmp.S | 88 |
19 files changed, 490 insertions, 0 deletions
diff --git a/libc/sysdeps/Makefile b/libc/sysdeps/Makefile new file mode 100644 index 000000000..cdd7e4e24 --- /dev/null +++ b/libc/sysdeps/Makefile @@ -0,0 +1,10 @@ +all: linux + +linux: dummy + make -C linux + +clean: + rm -f *.o + make -C linux clean + +.PHONY: dummy diff --git a/libc/sysdeps/README b/libc/sysdeps/README new file mode 100644 index 000000000..ca9cb29f0 --- /dev/null +++ b/libc/sysdeps/README @@ -0,0 +1,6 @@ +This directory level abstracts out the UN*X-like Operating System dependent +features of uC-Libc for all UN*X-like operating systems. If you wanted to port +uC-Libc to some other UN*X-like OS, this is the place to add that support. + +If you want to port uC-Libc to support some non-UN*X-like Operating System, you +should probably stop using crack. It is bad for you. ;-) diff --git a/libc/sysdeps/linux/Makefile b/libc/sysdeps/linux/Makefile new file mode 100644 index 000000000..a81bb9a21 --- /dev/null +++ b/libc/sysdeps/linux/Makefile @@ -0,0 +1,20 @@ +# Figure out what arch to build... + +ARCH = $(shell uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/') + +all: $(ARCH) common + +$(ARCH): dummy + echo Building for ARCH=$(ARCH) + make -C $(ARCH) + +common: dummy + echo Building common stuff + make -C common + +clean: + rm -f *.o + make -C common clean + make -C $(ARCH) clean + +.PHONY: dummy diff --git a/libc/sysdeps/linux/README b/libc/sysdeps/linux/README new file mode 100644 index 000000000..52eb09254 --- /dev/null +++ b/libc/sysdeps/linux/README @@ -0,0 +1,7 @@ +This directory level abstracts out the Linux Operating System dependent +features of uC-Libc for suported Linux architectures/CPUs. If you wanted to +port uC-Libc to some new Linux architecture (arm, mips, etc), this is the place +to add that support. + +All the common stuff that is not at all dependent on a particular Linux architecture +goes in the 'common' directory. diff --git a/libc/sysdeps/linux/common/Makefile b/libc/sysdeps/linux/common/Makefile new file mode 100644 index 000000000..eac2dc3b4 --- /dev/null +++ b/libc/sysdeps/linux/common/Makefile @@ -0,0 +1,24 @@ +# Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk> +# This file is part of the Linux-8086 C library and is distributed +# under the GNU Library General Public License. + +TOPDIR=../../../ +include $(TOPDIR)Rules.make + +CFLAGS+= -D_GCC_LIMITS_H_ + +LIBC=$(TOPDIR)libc.a + +include makefile.objs + +all: $(LIBC) + +$(LIBC): $(OBJ) + $(AR) $(ARFLAGS) $@ $(OBJ) + +transfer: + -@rm -f ../include/stdio.h + cp -p stdio.h ../include/. + +clean: + rm -f *.o diff --git a/libc/sysdeps/linux/common/getdnnm.c b/libc/sysdeps/linux/common/getdnnm.c new file mode 100644 index 000000000..fdcbb0f3a --- /dev/null +++ b/libc/sysdeps/linux/common/getdnnm.c @@ -0,0 +1,24 @@ +#include <string.h> +#include <unistd.h> +#include <sys/utsname.h> +#include <errno.h> + +int +getdomainname(char *name, size_t len) +{ + struct utsname uts; + + if (name == NULL) { + errno = EINVAL; + return -1; + } + + if (uname(&uts) == -1) return -1; + + if (strlen(uts.domainname)+1 > len) { + errno = EINVAL; + return -1; + } + strcpy(name, uts.domainname); + return 0; +} diff --git a/libc/sysdeps/linux/common/gethstnm.c b/libc/sysdeps/linux/common/gethstnm.c new file mode 100644 index 000000000..0728f65a4 --- /dev/null +++ b/libc/sysdeps/linux/common/gethstnm.c @@ -0,0 +1,24 @@ +#include <string.h> +#include <unistd.h> +#include <sys/utsname.h> +#include <errno.h> + +int +gethostname(char *name, size_t len) +{ + struct utsname uts; + + if (name == NULL) { + errno = EINVAL; + return -1; + } + + if (uname(&uts) == -1) return -1; + + if (strlen(uts.nodename)+1 > len) { + errno = EINVAL; + return -1; + } + strcpy(name, uts.nodename); + return 0; +} diff --git a/libc/sysdeps/linux/common/getpagesize.c b/libc/sysdeps/linux/common/getpagesize.c new file mode 100644 index 000000000..708fdd06e --- /dev/null +++ b/libc/sysdeps/linux/common/getpagesize.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1991, 1992, 1995, 1996, 1997 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. */ + +#include <unistd.h> +#include <sys/param.h> + +/* Return the system page size. */ +int getpagesize () +{ +#ifdef EXEC_PAGESIZE + return EXEC_PAGESIZE; +#else /* No EXEC_PAGESIZE. */ +#ifdef NBPG +#ifndef CLSIZE +#define CLSIZE 1 +#endif /* No CLSIZE. */ + return NBPG * CLSIZE; +#else /* No NBPG. */ + return NBPC; +#endif /* NBPG. */ +#endif /* EXEC_PAGESIZE. */ +} + diff --git a/libc/sysdeps/linux/common/kernel_version.c b/libc/sysdeps/linux/common/kernel_version.c new file mode 100644 index 000000000..dacc4f0f7 --- /dev/null +++ b/libc/sysdeps/linux/common/kernel_version.c @@ -0,0 +1,95 @@ +/* Copyright (C) 1996 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., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include <ansidecl.h> +#include <string.h> +#include <sys/utsname.h> +#include <sys/param.h> + +static int __linux_kernel_version = -1; + +static inline int +asc2int (const char *s) +{ + int result = 0; + + for (; *s >= '0' && *s <= '9'; s++) + { + result = result * 10 + (*s - '0'); + } + + return result; +} + +static int +set_linux_kernel_version (void) +{ + struct utsname uts; + char *version = NULL, *patchlevel = NULL, *sublevel = NULL; + + if (uname (&uts)) + { + __linux_kernel_version = 0; + return __linux_kernel_version; + } + + version = uts.release; + if (version != NULL) + { + patchlevel = strchr (version, '.'); + if (patchlevel != NULL) + { + *patchlevel = '\0'; + patchlevel++; + sublevel = strchr (patchlevel, '.'); + if (sublevel != NULL) + { + *sublevel = '\0'; + sublevel++; + } + } + + __linux_kernel_version = + GET_LINUX_KERNEL_VERSION (asc2int (version)); + if (patchlevel != NULL) + { + __linux_kernel_version |= + GET_LINUX_KERNEL_PATCHLEVEL (asc2int (patchlevel)); + } + if (sublevel != NULL) + { + __linux_kernel_version |= + GET_LINUX_KERNEL_SUBLEVEL (asc2int (sublevel)); + } + } + else + { + __linux_kernel_version = 0; + } + + return __linux_kernel_version; +} + +int +__get_linux_kernel_version (void) +{ + if (__linux_kernel_version != -1) + return __linux_kernel_version; + + return set_linux_kernel_version (); +} diff --git a/libc/sysdeps/linux/common/mkfifo.c b/libc/sysdeps/linux/common/mkfifo.c new file mode 100644 index 000000000..dbaa9aa3b --- /dev/null +++ b/libc/sysdeps/linux/common/mkfifo.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991, 1996, 1997 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. + + June 28, 2000 -- swiped from GNU libc 2.1.3 and adjusted for uC-Libc + by Erik Andersen <andersee@debian.org> + */ + +#include <errno.h> +#include <stddef.h> +#include <sys/stat.h> +#include <sys/types.h> + +/* Create a named pipe (FIFO) named PATH with protections MODE. */ +int +mkfifo (const char *path, mode_t mode) +{ + dev_t dev = 0; + return mknod (path, mode | S_IFIFO, &dev); +} diff --git a/libc/sysdeps/linux/common/setegid.c b/libc/sysdeps/linux/common/setegid.c new file mode 100644 index 000000000..3eebf60fb --- /dev/null +++ b/libc/sysdeps/linux/common/setegid.c @@ -0,0 +1,6 @@ +#include <unistd.h> + +int setegid(gid_t gid) +{ + return __setregid(-1, gid); +} diff --git a/libc/sysdeps/linux/common/seteuid.c b/libc/sysdeps/linux/common/seteuid.c new file mode 100644 index 000000000..179477a14 --- /dev/null +++ b/libc/sysdeps/linux/common/seteuid.c @@ -0,0 +1,22 @@ +#include <unistd.h> +#include <stdio.h> +#include <errno.h> + +int seteuid(uid_t uid) +{ + switch (sizeof (uid_t)) + { + case 2: + if (uid == 65535) + { + errno = EINVAL; + return -1; + } + break; + + default: + fprintf (stderr, "Uknown uid_t size and sign\n"); + } + + return setreuid(-1, uid); +} diff --git a/libc/sysdeps/linux/common/setpgrp.c b/libc/sysdeps/linux/common/setpgrp.c new file mode 100644 index 000000000..f1f27d18f --- /dev/null +++ b/libc/sysdeps/linux/common/setpgrp.c @@ -0,0 +1,11 @@ +#include <syscall.h> +#include <unistd.h> + +static inline +_syscall2(int,setpgid,pid_t,pid,pid_t,pgid); + +int +setpgrp(void) +{ + return setpgid(0,0); +} diff --git a/libc/sysdeps/linux/common/tell.c b/libc/sysdeps/linux/common/tell.c new file mode 100644 index 000000000..b58f3f944 --- /dev/null +++ b/libc/sysdeps/linux/common/tell.c @@ -0,0 +1,15 @@ +#define lseek __normal_lseek +#include <unistd.h> +#include <syscall.h> +#undef lseek + +static inline +_syscall3(off_t,lseek,int,fildes,off_t,offset,int,origin) + +off_t tell(int); + +off_t +tell (int fildes) +{ + return lseek (fildes, 0, SEEK_CUR); +} diff --git a/libc/sysdeps/linux/common/wait.c b/libc/sysdeps/linux/common/wait.c new file mode 100644 index 000000000..ffcb9d26f --- /dev/null +++ b/libc/sysdeps/linux/common/wait.c @@ -0,0 +1,12 @@ +#include <syscall.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <sys/resource.h> + +static inline +_syscall4(__pid_t,wait4,__pid_t,pid,__WAIT_STATUS,status,int,options,struct rusage *,ru) + +__pid_t wait(__WAIT_STATUS wait_stat) +{ + return wait4((-1) /* WAIT_ANY */, wait_stat, 0, NULL); +} diff --git a/libc/sysdeps/linux/common/wait3.c b/libc/sysdeps/linux/common/wait3.c new file mode 100644 index 000000000..df9ab5f3a --- /dev/null +++ b/libc/sysdeps/linux/common/wait3.c @@ -0,0 +1,12 @@ +#include <syscall.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <sys/resource.h> + +static inline +_syscall4(__pid_t,wait4,__pid_t,pid,__WAIT_STATUS,status,int,options,struct rusage *,ru) + +__pid_t wait3(__WAIT_STATUS wait_stat, int options, struct rusage *reserved) +{ + return wait4((-1) /* WAIT_ANY*/, wait_stat, options, reserved); +} diff --git a/libc/sysdeps/linux/common/waitpid.c b/libc/sysdeps/linux/common/waitpid.c new file mode 100644 index 000000000..1a7f7ecad --- /dev/null +++ b/libc/sysdeps/linux/common/waitpid.c @@ -0,0 +1,13 @@ +#include <syscall.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <sys/resource.h> + +static inline +_syscall4(__pid_t,wait4,__pid_t,pid,__WAIT_STATUS,status,int,options,struct rusage *,ru) + +__pid_t +waitpid(__pid_t pid, int *wait_stat, int options) +{ + return wait4(pid, (__WAIT_STATUS) wait_stat, options, NULL); +} diff --git a/libc/sysdeps/linux/i386/Makefile b/libc/sysdeps/linux/i386/Makefile new file mode 100644 index 000000000..bfb8d82ff --- /dev/null +++ b/libc/sysdeps/linux/i386/Makefile @@ -0,0 +1,29 @@ +# Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk> +# This file is part of the Linux-8086 C library and is distributed +# under the GNU Library General Public License. + +TOPDIR=../../../ +include $(TOPDIR)Rules.make + +CFLAGS+= -D_GCC_LIMITS_H_ + +LIBC=$(TOPDIR)libc.a + +.S.s: + $(CC) $(CFLAGS) -D__ASSEMBLY__ -traditional -E -o $*.s $< +.S.o: + $(CC) $(CFLAGS) -c -o $*.o $< + +include makefile.objs + +all: $(LIBC) + +$(LIBC): $(OBJ) + $(AR) $(ARFLAGS) $@ $(OBJ) + +transfer: + -@rm -f ../include/stdio.h + cp -p stdio.h ../include/. + +clean: + rm -f *.o diff --git a/libc/sysdeps/linux/i386/setjmp.S b/libc/sysdeps/linux/i386/setjmp.S new file mode 100644 index 000000000..3ff05425f --- /dev/null +++ b/libc/sysdeps/linux/i386/setjmp.S @@ -0,0 +1,88 @@ +/* These are predefined by new versions of GNU cpp. */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif + +/* ANSI concatenation macros. */ + +#define CONCAT1(a, b) CONCAT2(a, b) +#define CONCAT2(a, b) a ## b + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +#define d0 REG (d0) +#define d1 REG (d1) +#define d2 REG (d2) +#define d3 REG (d3) +#define d4 REG (d4) +#define d5 REG (d5) +#define d6 REG (d6) +#define d7 REG (d7) +#define a0 REG (a0) +#define a1 REG (a1) +#define a2 REG (a2) +#define a3 REG (a3) +#define a4 REG (a4) +#define a5 REG (a5) +#define a6 REG (a6) +#define fp REG (fp) +#define sp REG (sp) + +.global SYM (setjmp) +.global SYM (longjmp) + +SYM (setjmp): + moveal sp@(4),a0 + movel sp@(0),a0@(12) + movel sp,a0@(8) + moveml d2-d7/a2-a6,a0@(20) + clrl d0 + rts + +SYM (longjmp): + moveal sp@(4),a0 + movel sp@(8),d0 + bne 1f + movel #1,d0 +1: + moveml a0@(20),d2-d7/a2-a6 + moveal a0@(8),sp + movel a0@(12),sp@ + rts + +#ifdef M68881 +.global SYM (setjmp_68881) +.global SYM (longjmp_68881) + +SYM (setjmp_68881): + moveal sp@(4),a0 + movel sp@(0),a0@(12) + movel sp,a0@(8) + moveml d2-d7/a2-a6,a0@(20) + fmovemx fp2-fp7,a0@(64) + clrl d0 + rts + +SYM (longjmp_68881): + moveal sp@(4),a0 + fmovemx a0@(64),fp2-fp7 + movel sp@(8),d0 + bne 1f + movel #1,d0 +1: + moveml a0@(20),d2-d7/a2-a6 + moveal a0@(8),sp + movel a0@(12),sp@ + rts +#endif |