chiark / gitweb /
[PATCH] update klibc to version 0.98
authorgreg@kroah.com <greg@kroah.com>
Tue, 27 Jan 2004 04:17:10 +0000 (20:17 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:13:19 +0000 (21:13 -0700)
klibc/klibc/SYSCALLS
klibc/klibc/arch/i386/include/sys/io.h [new file with mode: 0644]
klibc/klibc/arch/i386/include/sys/vm86.h [new file with mode: 0644]
klibc/klibc/arch/x86_64/include/sys/io.h [new file with mode: 0644]
klibc/klibc/fopen.c
klibc/klibc/include/stdio.h
klibc/klibc/include/unistd.h
klibc/klibc/makeerrlist.pl
klibc/klibc/syscommon.h
klibc/version

index 0be1b4425abfb6d80c302a502a0dff3927226564..00883cc0987223bc1884ce3726a5bc77fac0c573 100644 (file)
@@ -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 (file)
index 0000000..b051464
--- /dev/null
@@ -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 (file)
index 0000000..d327239
--- /dev/null
@@ -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 (file)
index 0000000..4a0ae44
--- /dev/null
@@ -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 */
index 5c84184809af4118a9f9ed9310aa04d8b2c05c67..ee62c68bd75200a3ac62607a4bba4b6957eaa5af 100644 (file)
@@ -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));
 }
index f57439f018a58f88b9f77cab7938d2242c39c69a..31a1fe40af29647a85d10af76695f151f3f4d736 100644 (file)
@@ -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 *);
index 36c486f49d15a5fe4be1d836c720cdebb8b0926a..ad129138341657d38dd3f25b18b69316eb8a76be 100644 (file)
@@ -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 *);
index 121ed1f46b97ebdaf8e16e8eb64679086c5bfbfe..00acb8a3d5bbf00a586930a7c1eec52096096ee8 100644 (file)
@@ -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) = @_;
index 916d4eb0c02af3a2b05486077a47dcb37fdf5e85..30939207391073174b295d391d2641cd8ecca82a 100644 (file)
@@ -26,3 +26,7 @@
 #include <sys/vfs.h>
 #include <sys/wait.h>
 #include <unistd.h>
+
+#ifdef __i386__
+#include <sys/vm86.h>
+#endif
index fd6d73e4a0554be7673f39086280788941fefc24..0f6db3dda2ebf786351bbc6a94ca68edeaec496a 100644 (file)
@@ -1 +1 @@
-0.95
+0.98