summaryrefslogtreecommitdiff
path: root/klibc
diff options
context:
space:
mode:
authorgreg@kroah.com <greg@kroah.com>2004-01-26 20:17:10 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:19 -0700
commit125611d9d47bd3a99ed6ce90ed327860de022e8a (patch)
tree75e4e7ebc37f5e0bdbafc370459f90bb36dffb8b /klibc
parent28706bd9a1110f00f40888251425eea6e4bc22e1 (diff)
[PATCH] update klibc to version 0.98
Diffstat (limited to 'klibc')
-rw-r--r--klibc/klibc/SYSCALLS8
-rw-r--r--klibc/klibc/arch/i386/include/sys/io.h126
-rw-r--r--klibc/klibc/arch/i386/include/sys/vm86.h41
-rw-r--r--klibc/klibc/arch/x86_64/include/sys/io.h126
-rw-r--r--klibc/klibc/fopen.c12
-rw-r--r--klibc/klibc/include/stdio.h11
-rw-r--r--klibc/klibc/include/unistd.h1
-rw-r--r--klibc/klibc/makeerrlist.pl2
-rw-r--r--klibc/klibc/syscommon.h4
-rw-r--r--klibc/version2
10 files changed, 320 insertions, 13 deletions
diff --git a/klibc/klibc/SYSCALLS b/klibc/klibc/SYSCALLS
index 0be1b4425a..00883cc098 100644
--- a/klibc/klibc/SYSCALLS
+++ b/klibc/klibc/SYSCALLS
@@ -71,6 +71,7 @@ int chdir(const char *)
int rename(const char *, const char *)
int mknod(const char *, mode_t, dev_t)
int chmod(const char *, mode_t)
+int fchmod(int, mode_t)
int mkdir(const char *, mode_t)
int rmdir(const char *)
<!alpha,ia64,mips,mips64> int pipe(int *)
@@ -144,3 +145,10 @@ long delete_module(const char *, unsigned int)
<!ia64> int query_module(const char *, int, void *, size_t, size_t)
int reboot::__reboot(int, int, int, void *)
int syslog::klogctl(int, char *, int)
+
+#
+# Low-level I/O (generally architecture-specific)
+#
+<i386,x86_64> int iopl(int)
+<i386,x86_64> int ioperm(unsigned long, unsigned long, int)
+<i386> int vm86(struct vm86_struct *)
diff --git a/klibc/klibc/arch/i386/include/sys/io.h b/klibc/klibc/arch/i386/include/sys/io.h
new file mode 100644
index 0000000000..b051464dfc
--- /dev/null
+++ b/klibc/klibc/arch/i386/include/sys/io.h
@@ -0,0 +1,126 @@
+#ident "$Id: io.h,v 1.2 2004/01/25 07:49:39 hpa Exp $"
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2004 H. Peter Anvin - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * sys/io.h for the i386 architecture
+ *
+ * Basic I/O macros
+ */
+
+#ifndef _SYS_IO_H
+#define _SYS_IO_H 1
+
+/* I/O-related system calls */
+
+int iopl(int);
+int ioperm(unsigned long, unsigned long, int);
+
+/* Basic I/O macros */
+
+static __inline__ void
+outb(unsigned char __v, unsigned short __p)
+{
+ asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ void
+outw(unsigned short __v, unsigned short __p)
+{
+ asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ void
+outl(unsigned int __v, unsigned short __p)
+{
+ asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ unsigned char
+inb(unsigned short __p)
+{
+ unsigned char __v;
+ asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
+ return __v;
+}
+
+static __inline__ unsigned short
+inw(unsigned short __p)
+{
+ unsigned short __v;
+ asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
+ return __v;
+}
+
+static __inline__ unsigned int
+inl(unsigned short __p)
+{
+ unsigned int __v;
+ asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
+ return __v;
+}
+
+/* String I/O macros */
+
+static __inline__ void
+outsb (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+outsw (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+outsl (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+
+static __inline__ void
+insb (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+insw (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+insl (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+#endif /* _SYS_IO_H */
diff --git a/klibc/klibc/arch/i386/include/sys/vm86.h b/klibc/klibc/arch/i386/include/sys/vm86.h
new file mode 100644
index 0000000000..d3272393dc
--- /dev/null
+++ b/klibc/klibc/arch/i386/include/sys/vm86.h
@@ -0,0 +1,41 @@
+#ident "$Id: vm86.h,v 1.1 2004/01/25 01:34:28 hpa Exp $"
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2004 H. Peter Anvin - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * sys/vm86.h for i386
+ */
+
+#ifndef _SYS_VM86_H
+#define _SYS_VM86_H 1
+
+#include <asm/vm86.h>
+
+/* Actual system call */
+int vm86(struct vm86_struct *);
+
+#endif
diff --git a/klibc/klibc/arch/x86_64/include/sys/io.h b/klibc/klibc/arch/x86_64/include/sys/io.h
new file mode 100644
index 0000000000..4a0ae44985
--- /dev/null
+++ b/klibc/klibc/arch/x86_64/include/sys/io.h
@@ -0,0 +1,126 @@
+#ident "$Id: io.h,v 1.1 2004/01/25 01:34:29 hpa Exp $"
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2004 H. Peter Anvin - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * sys/io.h for the i386 architecture
+ *
+ * Basic I/O macros
+ */
+
+#ifndef _SYS_IO_H
+#define _SYS_IO_H 1
+
+/* I/O-related system calls */
+
+int iopl(int);
+int ioperm(unsigned long, unsigned long, int);
+
+/* Basic I/O macros */
+
+static __inline__ void
+outb(unsigned char __v, unsigned short __p)
+{
+ asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ void
+outw(unsigned short __v, unsigned short __p)
+{
+ asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ void
+outl(unsigned int __v, unsigned short __p)
+{
+ asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ unsigned char
+inb(unsigned short __p)
+{
+ unsigned char __v;
+ asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
+ return v;
+}
+
+static __inline__ unsigned short
+inw(unsigned short __p)
+{
+ unsigned short __v;
+ asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
+ return v;
+}
+
+static __inline__ unsigned int
+inl(unsigned short __p)
+{
+ unsigned int __v;
+ asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
+ return v;
+}
+
+/* String I/O macros */
+
+static __inline__ void
+outsb (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+outsw (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+outsl (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+
+static __inline__ void
+insb (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+insw (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+insl (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+#endif /* _SYS_IO_H */
diff --git a/klibc/klibc/fopen.c b/klibc/klibc/fopen.c
index 5c84184809..ee62c68bd7 100644
--- a/klibc/klibc/fopen.c
+++ b/klibc/klibc/fopen.c
@@ -13,10 +13,9 @@ FILE *fopen(const char *file, const char *mode)
{
int flags = O_RDONLY;
int plus = 0;
- int fd;
while ( *mode ) {
- switch ( *mode ) {
+ switch ( *mode++ ) {
case 'r':
flags = O_RDONLY;
break;
@@ -30,17 +29,12 @@ FILE *fopen(const char *file, const char *mode)
plus = 1;
break;
}
- mode++;
}
if ( plus ) {
flags = (flags & ~(O_RDONLY|O_WRONLY)) | O_RDWR;
}
- fd = open(file, flags, 0666);
-
- if ( fd < 0 )
- return NULL;
- else
- return fdopen(fd, mode);
+ /* Note: __create_file(-1) == NULL, so this is safe */
+ return __create_file(open(file, flags, 0666));
}
diff --git a/klibc/klibc/include/stdio.h b/klibc/klibc/include/stdio.h
index f57439f018..31a1fe40af 100644
--- a/klibc/klibc/include/stdio.h
+++ b/klibc/klibc/include/stdio.h
@@ -31,15 +31,22 @@ typedef struct _IO_file FILE;
#define SEEK_CUR 1
#define SEEK_END 2
+/*
+ * Convert between a FILE * and a file descriptor. We don't actually
+ * have any in-memory data, so we just abuse the pointer itself to
+ * hold the data. Note, however, that for file descriptors, -1 is
+ * error and 0 is a valid value; for FILE *, NULL (0) is error and
+ * non-NULL are valid.
+ */
static __inline__ int fileno(FILE *__f)
{
/* This should really be intptr_t, but size_t should be the same size */
- return (int)(size_t)__f;
+ return (int)(size_t)__f - 1;
}
static __inline__ FILE * __create_file(int __fd)
{
- return (FILE *)(size_t)__fd;
+ return (FILE *)(size_t)(__fd + 1);
}
__extern FILE *fopen(const char *, const char *);
diff --git a/klibc/klibc/include/unistd.h b/klibc/klibc/include/unistd.h
index 36c486f49d..ad12913834 100644
--- a/klibc/klibc/include/unistd.h
+++ b/klibc/klibc/include/unistd.h
@@ -54,6 +54,7 @@ __extern int link(const char *, const char *);
__extern int unlink(const char *);
__extern int chdir(const char *);
__extern int chmod(const char *, mode_t);
+__extern int fchmod(int, mode_t);
__extern int mkdir(const char *, mode_t);
__extern int rmdir(const char *);
__extern int pipe(int *);
diff --git a/klibc/klibc/makeerrlist.pl b/klibc/klibc/makeerrlist.pl
index 121ed1f46b..00acb8a3d5 100644
--- a/klibc/klibc/makeerrlist.pl
+++ b/klibc/klibc/makeerrlist.pl
@@ -10,7 +10,7 @@ use FileHandle;
%errors = ();
%errmsg = ();
$maxerr = -1;
-$rootdir = 'linux/include/'; # Must have trailing /
+$rootdir = '../linux/include/'; # Must have trailing /
sub parse_file($) {
my($file) = @_;
diff --git a/klibc/klibc/syscommon.h b/klibc/klibc/syscommon.h
index 916d4eb0c0..3093920739 100644
--- a/klibc/klibc/syscommon.h
+++ b/klibc/klibc/syscommon.h
@@ -26,3 +26,7 @@
#include <sys/vfs.h>
#include <sys/wait.h>
#include <unistd.h>
+
+#ifdef __i386__
+#include <sys/vm86.h>
+#endif
diff --git a/klibc/version b/klibc/version
index fd6d73e4a0..0f6db3dda2 100644
--- a/klibc/version
+++ b/klibc/version
@@ -1 +1 @@
-0.95
+0.98