summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1994-11-28 11:59:19 +0000
committer <ralf@linux-mips.org>1994-11-28 11:59:19 +0000
commit1513ff9b7899ab588401c89db0e99903dbf5f886 (patch)
treef69cc81a940a502ea23d664c3ffb2d215a479667 /lib
Import of Linus's Linux 1.1.68
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile32
-rw-r--r--lib/_exit.c18
-rw-r--r--lib/close.c11
-rw-r--r--lib/ctype.c35
-rw-r--r--lib/dup.c11
-rw-r--r--lib/errno.c7
-rw-r--r--lib/execve.c11
-rw-r--r--lib/open.c26
-rw-r--r--lib/setsid.c12
-rw-r--r--lib/string.c11
-rw-r--r--lib/wait.c17
-rw-r--r--lib/write.c12
12 files changed, 203 insertions, 0 deletions
diff --git a/lib/Makefile b/lib/Makefile
new file mode 100644
index 000000000..d6b77ea4f
--- /dev/null
+++ b/lib/Makefile
@@ -0,0 +1,32 @@
+#
+# Makefile for some libs needed in the kernel.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+
+.c.s:
+ $(CC) $(CFLAGS) -S $<
+.s.o:
+ $(AS) -c -o $*.o $<
+.c.o:
+ $(CC) $(CFLAGS) -c $<
+
+OBJS = ctype.o _exit.o open.o close.o errno.o write.o dup.o setsid.o \
+ execve.o wait.o string.o
+
+lib.a: $(OBJS)
+ $(AR) rcs lib.a $(OBJS)
+ sync
+
+dep:
+ $(CPP) -M *.c > .depend
+
+#
+# include a dependency file if one exists
+#
+ifeq (.depend,$(wildcard .depend))
+include .depend
+endif
+
diff --git a/lib/_exit.c b/lib/_exit.c
new file mode 100644
index 000000000..a46f1a2b6
--- /dev/null
+++ b/lib/_exit.c
@@ -0,0 +1,18 @@
+/*
+ * linux/lib/_exit.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#define __LIBRARY__
+#include <linux/unistd.h>
+
+volatile void _exit(int exit_code)
+{
+fake_volatile:
+ __asm__("movl %1,%%ebx\n\t"
+ "int $0x80"
+ : /* no outputs */
+ :"a" (__NR_exit),"g" (exit_code));
+ goto fake_volatile;
+}
diff --git a/lib/close.c b/lib/close.c
new file mode 100644
index 000000000..2c3f4363e
--- /dev/null
+++ b/lib/close.c
@@ -0,0 +1,11 @@
+/*
+ * linux/lib/close.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#define __LIBRARY__
+#include <linux/unistd.h>
+
+_syscall1(int,close,int,fd)
+
diff --git a/lib/ctype.c b/lib/ctype.c
new file mode 100644
index 000000000..d3613be6f
--- /dev/null
+++ b/lib/ctype.c
@@ -0,0 +1,35 @@
+/*
+ * linux/lib/ctype.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#include <linux/ctype.h>
+
+char _ctmp;
+unsigned char _ctype[] = {0x00, /* EOF */
+_C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */
+_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */
+_C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */
+_C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */
+_S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */
+_P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */
+_D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */
+_D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */
+_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */
+_U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */
+_U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */
+_U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */
+_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */
+_L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */
+_L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */
+_L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 160-175 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 176-191 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 192-207 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 208-223 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 224-239 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* 240-255 */
+
diff --git a/lib/dup.c b/lib/dup.c
new file mode 100644
index 000000000..6d5ed119e
--- /dev/null
+++ b/lib/dup.c
@@ -0,0 +1,11 @@
+/*
+ * linux/lib/dup.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#define __LIBRARY__
+#include <linux/unistd.h>
+
+_syscall1(int,dup,int,fd)
+
diff --git a/lib/errno.c b/lib/errno.c
new file mode 100644
index 000000000..41cb9d76c
--- /dev/null
+++ b/lib/errno.c
@@ -0,0 +1,7 @@
+/*
+ * linux/lib/errno.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+int errno;
diff --git a/lib/execve.c b/lib/execve.c
new file mode 100644
index 000000000..32a93f0f1
--- /dev/null
+++ b/lib/execve.c
@@ -0,0 +1,11 @@
+/*
+ * linux/lib/execve.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#define __LIBRARY__
+#include <linux/unistd.h>
+
+_syscall3(int,execve,const char *,file,char **,argv,char **,envp)
+
diff --git a/lib/open.c b/lib/open.c
new file mode 100644
index 000000000..b69d2b548
--- /dev/null
+++ b/lib/open.c
@@ -0,0 +1,26 @@
+/*
+ * linux/lib/open.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#define __LIBRARY__
+#include <linux/unistd.h>
+#include <stdarg.h>
+
+int open(const char * filename, int flag, ...)
+{
+ register int res;
+ va_list arg;
+
+ va_start(arg,flag);
+ __asm__("movl %2,%%ebx\n\t"
+ "int $0x80"
+ :"=a" (res)
+ :"0" (__NR_open),"g" ((long)(filename)),"c" (flag),
+ "d" (va_arg(arg,int)));
+ if (res>=0)
+ return res;
+ errno = -res;
+ return -1;
+}
diff --git a/lib/setsid.c b/lib/setsid.c
new file mode 100644
index 000000000..c157b7135
--- /dev/null
+++ b/lib/setsid.c
@@ -0,0 +1,12 @@
+/*
+ * linux/lib/setsid.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#define __LIBRARY__
+#include <linux/types.h>
+#include <linux/unistd.h>
+
+_syscall0(pid_t,setsid)
+
diff --git a/lib/string.c b/lib/string.c
new file mode 100644
index 000000000..8c69ff0c3
--- /dev/null
+++ b/lib/string.c
@@ -0,0 +1,11 @@
+/*
+ * linux/lib/string.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#include <linux/string.h>
+
+/* all the actual functions should be inline anyway, so.. */
+
+char * ___strtok = NULL;
diff --git a/lib/wait.c b/lib/wait.c
new file mode 100644
index 000000000..727a27162
--- /dev/null
+++ b/lib/wait.c
@@ -0,0 +1,17 @@
+/*
+ * linux/lib/wait.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#define __LIBRARY__
+#include <linux/unistd.h>
+#include <linux/types.h>
+
+_syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
+
+pid_t wait(int * wait_stat)
+{
+ return waitpid(-1,wait_stat,0);
+}
+
diff --git a/lib/write.c b/lib/write.c
new file mode 100644
index 000000000..9336ed9d8
--- /dev/null
+++ b/lib/write.c
@@ -0,0 +1,12 @@
+/*
+ * linux/lib/write.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#define __LIBRARY__
+#include <linux/unistd.h>
+#include <linux/types.h>
+
+_syscall3(int,write,int,fd,const char *,buf,off_t,count)
+