summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--include/features.h1
-rw-r--r--include/getopt.h3
-rw-r--r--include/stdio.h4
-rw-r--r--include/stdlib.h2
-rw-r--r--include/sys/stat.h46
-rw-r--r--include/sys/uio.h61
-rw-r--r--include/unistd.h74
-rw-r--r--libc/sysdeps/linux/common/glibcstat.h68
-rw-r--r--libc/sysdeps/linux/i386/Makefile2
-rw-r--r--libc/sysdeps/linux/i386/bits/uio.h46
-rw-r--r--libc/sysdeps/linux/i386/clone.S87
12 files changed, 329 insertions, 67 deletions
diff --git a/Makefile b/Makefile
index fcba9168a..1a143cfd0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
DIRS = headers error getent malloc-simple misc regex stdio2 \
- string sysdeps termios time #rpc
+ string termios time sysdeps #rpc
all: libc.a
diff --git a/include/features.h b/include/features.h
index e890edebe..b7dfd21c5 100644
--- a/include/features.h
+++ b/include/features.h
@@ -41,6 +41,7 @@
#define __USE_BSD
#define __USE_MISC
#define __USE_POSIX
+#define __USE_POSIX2
#define _POSIX_THREAD_SAFE_FUNCTIONS
#include <sys/cdefs.h>
diff --git a/include/getopt.h b/include/getopt.h
index 0d71ff6bd..a4cb95496 100644
--- a/include/getopt.h
+++ b/include/getopt.h
@@ -9,8 +9,9 @@
#include <features.h>
extern char *optarg;
-extern int opterr;
extern int optind;
+extern int opterr;
+extern int optopt;
extern int getopt __P((int argc, char *const *argv, const char *shortopts));
diff --git a/include/stdio.h b/include/stdio.h
index e807262f0..5f944f1f7 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -201,6 +201,10 @@ extern int vfscanf __P ((FILE *__restrict __s,
/* Print a message describing the meaning of the value of errno. */
extern void perror __P ((__const char *__s));
+/* Like `getdelim', but reads up to a newline. */
+extern int getline __P ((char **__restrict __lineptr,
+ size_t *__restrict __n,
+ FILE *__restrict __stream));
#endif /* __STDIO_H */
diff --git a/include/stdlib.h b/include/stdlib.h
index 51ce80ba2..fefaf447a 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -58,6 +58,7 @@ extern int putenv __P ((__const char *__string));
extern int setenv __P ((__const char *__name, __const char *__value,
int __replace));
+extern void unsetenv __P ((__const char *__name));
extern int system __P ((__const char *__command));
@@ -87,7 +88,6 @@ extern void qsort __P ((__ptr_t __base, size_t __nmemb, size_t __size,
#define atof(x) strtod((x),(char**)0)
#define atoi(x) (int)strtol((x),(char**)0,10)
#define atol(x) strtol((x),(char**)0,10)
-char* itoa(int i);
/* Returned by `div'. */
typedef struct
diff --git a/include/sys/stat.h b/include/sys/stat.h
index 13c50411d..b4e1620df 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -276,37 +276,37 @@ extern int mkfifo __P ((__const char *__path, __mode_t __mode));
/* Wrappers for stat and mknod system calls. */
#ifndef __USE_FILE_OFFSET64
-extern int __fxstat __P ((int __ver, int __fildes,
+extern int _fxstat __P ((int __ver, int __fildes,
struct stat *__stat_buf));
-extern int __xstat __P ((int __ver, __const char *__filename,
+extern int _xstat __P ((int __ver, __const char *__filename,
struct stat *__stat_buf));
-extern int __lxstat __P ((int __ver, __const char *__filename,
+extern int _lxstat __P ((int __ver, __const char *__filename,
struct stat *__stat_buf));
#else
# ifdef __REDIRECT
-extern int __REDIRECT (__fxstat, __P ((int __ver, int __fildes,
- struct stat *__stat_buf)), __fxstat64);
-extern int __REDIRECT (__xstat, __P ((int __ver, __const char *__filename,
- struct stat *__stat_buf)), __xstat64);
-extern int __REDIRECT (__lxstat, __P ((int __ver, __const char *__filename,
- struct stat *__stat_buf)), __lxstat64);
+extern int __REDIRECT (_fxstat, __P ((int __ver, int __fildes,
+ struct stat *__stat_buf)), _fxstat64);
+extern int __REDIRECT (_xstat, __P ((int __ver, __const char *__filename,
+ struct stat *__stat_buf)), _xstat64);
+extern int __REDIRECT (_lxstat, __P ((int __ver, __const char *__filename,
+ struct stat *__stat_buf)), _lxstat64);
# else
-# define __fxstat __fxstat64
-# define __xstat __xstat64
-# define __lxstat __lxstat64
+# define _fxstat _fxstat64
+# define _xstat _xstat64
+# define _lxstat _lxstat64
# endif
#endif
#ifdef __USE_LARGEFILE64
-extern int __fxstat64 __P ((int __ver, int __fildes,
+extern int _fxstat64 __P ((int __ver, int __fildes,
struct stat64 *__stat_buf));
-extern int __xstat64 __P ((int __ver, __const char *__filename,
+extern int _xstat64 __P ((int __ver, __const char *__filename,
struct stat64 *__stat_buf));
-extern int __lxstat64 __P ((int __ver, __const char *__filename,
+extern int _lxstat64 __P ((int __ver, __const char *__filename,
struct stat64 *__stat_buf));
#endif
-extern int __xmknod __P ((int __ver, __const char *__path,
+extern int _xmknod __P ((int __ver, __const char *__path,
__mode_t __mode, __dev_t *__dev));
#if defined __GNUC__ && __GNUC__ >= 2
@@ -315,27 +315,27 @@ extern int __xmknod __P ((int __ver, __const char *__path,
extern __inline__ int stat (__const char *__path,
struct stat *__statbuf)
{
- return __xstat (_STAT_VER, __path, __statbuf);
+ return _xstat (_STAT_VER, __path, __statbuf);
}
# if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
extern __inline__ int lstat (__const char *__path,
struct stat *__statbuf)
{
- return __lxstat (_STAT_VER, __path, __statbuf);
+ return _lxstat (_STAT_VER, __path, __statbuf);
}
# endif
extern __inline__ int fstat (int __fd, struct stat *__statbuf)
{
- return __fxstat (_STAT_VER, __fd, __statbuf);
+ return _fxstat (_STAT_VER, __fd, __statbuf);
}
# if defined __USE_MISC || defined __USE_BSD
extern __inline__ int mknod (__const char *__path, __mode_t __mode,
__dev_t __dev)
{
- return __xmknod (_MKNOD_VER, __path, __mode, &__dev);
+ return _xmknod (_MKNOD_VER, __path, __mode, &__dev);
}
# endif
@@ -343,20 +343,20 @@ extern __inline__ int mknod (__const char *__path, __mode_t __mode,
extern __inline__ int stat64 (__const char *__path,
struct stat64 *__statbuf)
{
- return __xstat64 (_STAT_VER, __path, __statbuf);
+ return _xstat64 (_STAT_VER, __path, __statbuf);
}
# if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
extern __inline__ int lstat64 (__const char *__path,
struct stat64 *__statbuf)
{
- return __lxstat64 (_STAT_VER, __path, __statbuf);
+ return _lxstat64 (_STAT_VER, __path, __statbuf);
}
# endif
extern __inline__ int fstat64 (int __fd, struct stat64 *__statbuf)
{
- return __fxstat64 (_STAT_VER, __fd, __statbuf);
+ return _fxstat64 (_STAT_VER, __fd, __statbuf);
}
# endif
diff --git a/include/sys/uio.h b/include/sys/uio.h
index 87120e6ff..0be33e9b4 100644
--- a/include/sys/uio.h
+++ b/include/sys/uio.h
@@ -1,64 +1,49 @@
-/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1991, 1992, 1996, 1997, 1998 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 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.
+ 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, 1992 Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+ 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 _SYS_UIO_H
-
#define _SYS_UIO_H 1
-#include <features.h>
-
-__BEGIN_DECLS
-#define __need_size_t
-#include <stddef.h>
-
-/* That is a klude for Linux. */
-#ifdef __linux__
-#include <linux/socket.h>
-#endif
+#include <features.h>
-#ifndef __LINUX_UIO_H
+#include <sys/types.h>
-/* Structure describing a section of memory. */
+__BEGIN_DECLS
-struct iovec
-{
- /* Starting address. */
- __ptr_t iov_base;
- /* Length in bytes. */
- size_t iov_len;
-};
+/* This file defines `struct iovec'. */
+#include <bits/uio.h>
-#endif
/* Read data from file descriptor FD, and put the result in the
buffers described by VECTOR, which is a vector of COUNT `struct iovec's.
The buffers are filled in the order specified.
Operates just like `read' (see <unistd.h>) except that data are
put in VECTOR instead of a contiguous buffer. */
-int readv __P ((int __fd, __const struct iovec * __vector, size_t __count));
+extern ssize_t readv __P ((int __fd, __const struct iovec *__vector,
+ int __count));
/* Write data pointed by the buffers described by VECTOR, which
is a vector of COUNT `struct iovec's, to file descriptor FD.
The data is written in the order specified.
Operates just like `write' (see <unistd.h>) except that the data
are taken from VECTOR instead of a contiguous buffer. */
-int writev __P ((int __fd, __const struct iovec * __vector, size_t __count));
-
+extern ssize_t writev __P ((int __fd, __const struct iovec *__vector,
+ int __count));
__END_DECLS
diff --git a/include/unistd.h b/include/unistd.h
index 57a203dfd..6c2d1cece 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -65,13 +65,71 @@ extern char * mktemp __P ((char * __template));
extern int _clone __P ((int (*fn)(void *arg), void *child_stack, int flags, void *arg));
+/* Return the current machine's Internet number. */
+extern long int gethostid __P ((void));
-/* Make PATH be the root directory (the starting point for absolute paths).
+/* Put the name of the current host in no more than LEN bytes of NAME.
+ The result is null-terminated if LEN is large enough for the full
+ name and the terminator. */
+extern int gethostname __P ((char *__name, size_t __len));
+
+/* Set the name of the current host to NAME, which is LEN bytes long.
This call is restricted to the super-user. */
-extern int chroot __P ((__const char *__path));
+extern int sethostname __P ((__const char *__name, size_t __len));
+
+
+/* Set the user ID of the calling process to UID.
+ If the calling process is the super-user, set the real
+ and effective user IDs, and the saved set-user-ID to UID;
+ if not, the effective user ID is set to UID. */
+extern int setuid __P ((__uid_t __uid));
+
+/* Create a new session with the calling process as its leader.
+ The process group IDs of the session and the calling process
+ are set to the process ID of the calling process, which is returned. */
+extern __pid_t setsid __P ((void));
+
+/* Get the real user ID of the calling process. */
+extern __uid_t getuid __P ((void));
+
+/* Get the effective user ID of the calling process. */
+extern __uid_t geteuid __P ((void));
+
+/* Get the real group ID of the calling process. */
+extern __gid_t getgid __P ((void));
+
+/* Get the effective group ID of the calling process. */
+extern __gid_t getegid __P ((void));
+
+/* If SIZE is zero, return the number of supplementary groups
+ the calling process is in. Otherwise, fill in the group IDs
+ of its supplementary groups in LIST and return the number written. */
+extern int getgroups __P ((int __size, __gid_t __list[]));
+
+/* Return the foreground process group ID of FD. */
+extern __pid_t tcgetpgrp __P ((int __fd));
+/* Set the foreground process group ID of FD set PGRP_ID. */
+extern int tcsetpgrp __P ((int __fd, __pid_t __pgrp_id));
+/* Get the process group ID of the calling process.
+ This function is different on old BSD. */
+extern __pid_t getpgrp __P ((void));
+/* Set the process group ID of the process matching PID to PGID.
+ If PID is zero, the current process's process group ID is set.
+ If PGID is zero, the process ID of the process is used. */
+extern int setpgid __P ((__pid_t __pid, __pid_t __pgid));
+
+/* Get the process ID of the calling process. */
+extern __pid_t getpid __P ((void));
+
+
+
+
+/* Make PATH be the root directory (the starting point for absolute paths).
+ This call is restricted to the super-user. */
+extern int chroot __P ((__const char *__path));
/* Execute PATH with all arguments after PATH until
a NULL pointer and environment from `environ'. */
@@ -113,6 +171,18 @@ extern __pid_t fork __P ((void));
* and the process ID of the new process to the old process. */
extern __pid_t vfork __P ((void));
+/* Return the number of bytes in a page. This is the system's page size,
+ which is not necessarily the same as the hardware page size. */
+extern int getpagesize __P ((void)) __attribute__ ((__const__));
+
+#ifdef __USE_POSIX2
+/* Get definitions and prototypes for functions to process the
+ arguments in ARGV (ARGC of them, minus the program name) for
+ options given in OPTS. */
+# define __need_getopt
+# include <getopt.h>
+#endif
+
#ifndef SEEK_SET
#define SEEK_SET 0
diff --git a/libc/sysdeps/linux/common/glibcstat.h b/libc/sysdeps/linux/common/glibcstat.h
new file mode 100644
index 000000000..f5a2e7c91
--- /dev/null
+++ b/libc/sysdeps/linux/common/glibcstat.h
@@ -0,0 +1,68 @@
+/* Copyright (C) 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. */
+
+#ifndef _GLIBCSTAT_H
+#define _GLIBCSTAT_H 1
+
+/* Versions of the `struct stat' data structure. */
+#define _STAT_VER_LINUX_OLD 1
+#define _STAT_VER_SVR4 2
+#define _STAT_VER_LINUX 3
+#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
+
+/* Versions of the `xmknod' interface. */
+#define _MKNOD_VER_LINUX 1
+#define _MKNOD_VER_SVR4 2
+#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
+
+typedef unsigned long long int __glibc_dev_t;
+typedef unsigned long int __glibc_ino_t;
+typedef unsigned int __glibc_mode_t;
+typedef unsigned int __glibc_nlink_t;
+typedef unsigned int __glibc_uid_t;
+typedef unsigned int __glibc_gid_t;
+typedef long int __glibc_off_t;
+typedef long int __glibc_time_t;
+
+struct glibcstat
+ {
+ __glibc_dev_t st_dev; /* Device. */
+ unsigned short int __pad1;
+ __glibc_ino_t st_ino; /* File serial number. */
+ __glibc_mode_t st_mode; /* File mode. */
+ __glibc_nlink_t st_nlink; /* Link count. */
+ __glibc_uid_t st_uid; /* User ID of the file's owner. */
+ __glibc_gid_t st_gid; /* Group ID of the file's group.*/
+ __glibc_dev_t st_rdev; /* Device number, if device. */
+ unsigned short int __pad2;
+ __glibc_off_t st_size; /* Size of file, in bytes. */
+ unsigned long int st_blksize; /* Optimal block size for I/O. */
+#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
+
+ unsigned long int st_blocks; /* Number of 512-byte blocks allocated. */
+ __glibc_time_t st_atime; /* Time of last access. */
+ unsigned long int __unused1;
+ __glibc_time_t st_mtime; /* Time of last modification. */
+ unsigned long int __unused2;
+ __glibc_time_t st_ctime; /* Time of last status change. */
+ unsigned long int __unused3;
+ unsigned long int __unused4;
+ unsigned long int __unused5;
+ };
+
+#endif /* glibcstat.h */
diff --git a/libc/sysdeps/linux/i386/Makefile b/libc/sysdeps/linux/i386/Makefile
index 4db2b57fc..57fed3bf4 100644
--- a/libc/sysdeps/linux/i386/Makefile
+++ b/libc/sysdeps/linux/i386/Makefile
@@ -15,7 +15,7 @@ LIBC=$(TOPDIR)libc.a
$(CC) $(CFLAGS) -c -o $*.o $<
SSRC=syscalls.S
-OBJ= setjmp.o longjmp.o readdir.o _start.o _exit.o #select.o
+OBJ= setjmp.o longjmp.o readdir.o _start.o _exit.o fork.o #select.o
include makefile.objs
all: $(LIBC)
diff --git a/libc/sysdeps/linux/i386/bits/uio.h b/libc/sysdeps/linux/i386/bits/uio.h
new file mode 100644
index 000000000..38ac17baa
--- /dev/null
+++ b/libc/sysdeps/linux/i386/bits/uio.h
@@ -0,0 +1,46 @@
+/* Copyright (C) 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. */
+
+#ifndef _SYS_UIO_H
+# error "Never include <bits/uio.h> directly; use <sys/uio.h> instead."
+#endif
+
+
+#include <sys/types.h>
+
+
+/* We should normally use the Linux kernel header file to define this
+ type and macros but this calls for trouble because of the header
+ includes other kernel headers. */
+
+/* Size of object which can be written atomically.
+
+ This macro has different values in different kernel versions. The
+ latest versions of ther kernel use 1024 and this is good choice. Since
+ the C library implementation of readv/writev is able to emulate the
+ functionality even if the currently running kernel does not support
+ this large value the readv/writev call will not fail because of this. */
+#define UIO_MAXIOV 1024
+
+
+/* Structure for scatter/gather I/O. */
+struct iovec
+ {
+ void *iov_base; /* Pointer to data. */
+ size_t iov_len; /* Length of data. */
+ };
diff --git a/libc/sysdeps/linux/i386/clone.S b/libc/sysdeps/linux/i386/clone.S
new file mode 100644
index 000000000..7a2025b53
--- /dev/null
+++ b/libc/sysdeps/linux/i386/clone.S
@@ -0,0 +1,87 @@
+/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@tamu.edu)
+
+ 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. */
+
+/* clone() is even more special than fork() as it mucks with stacks
+ and invokes a function in the right context after its all over. */
+
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <asm-syntax.h>
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
+
+ .text
+ENTRY(__clone)
+ /* Sanity check arguments. */
+ movl $-EINVAL,%eax
+ movl 4(%esp),%ecx /* no NULL function pointers */
+#ifdef PIC
+ jecxz SYSCALL_ERROR_LABEL
+#else
+ testl %ecx,%ecx
+ jz SYSCALL_ERROR_LABEL
+#endif
+ movl 8(%esp),%ecx /* no NULL stack pointers */
+#ifdef PIC
+ jecxz SYSCALL_ERROR_LABEL
+#else
+ testl %ecx,%ecx
+ jz SYSCALL_ERROR_LABEL
+#endif
+
+ /* Insert the argument onto the new stack. */
+ subl $8,%ecx
+ movl 16(%esp),%eax /* no negative argument counts */
+ movl %eax,4(%ecx)
+
+ /* Save the function pointer as the zeroth argument.
+ It will be popped off in the child in the ebx frobbing below. */
+ movl 4(%esp),%eax
+ movl %eax,0(%ecx)
+
+ /* Do the system call */
+ pushl %ebx
+ movl 16(%esp),%ebx
+ movl $SYS_ify(clone),%eax
+ int $0x80
+ popl %ebx
+
+ test %eax,%eax
+ jl SYSCALL_ERROR_LABEL
+ jz thread_start
+
+L(pseudo_end):
+ ret
+
+thread_start:
+ subl %ebp,%ebp /* terminate the stack frame */
+ call *%ebx
+#ifdef PIC
+ call L(here)
+L(here):
+ popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-L(here)], %ebx
+#endif
+ pushl %eax
+ call JUMPTARGET (_exit)
+
+PSEUDO_END (__clone)
+
+weak_alias (__clone, clone)