chiark / gitweb /
klibc: version 1.0.14
authorKay Sievers <kay.sievers@suse.de>
Sun, 5 Jun 2005 15:11:09 +0000 (17:11 +0200)
committerKay Sievers <kay.sievers@suse.de>
Sun, 5 Jun 2005 15:11:09 +0000 (17:11 +0200)
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
19 files changed:
klibc/Makefile
klibc/include/netinet/if_ether.h [moved from klibc/include/net/if_ether.h with 100% similarity]
klibc/include/netpacket/packet.h [new file with mode: 0644]
klibc/include/signal.h
klibc/klcc.1
klibc/klcc.in
klibc/klibc/SYSCALLS.def
klibc/klibc/arch/i386/Makefile.inc
klibc/klibc/arch/x86_64/MCONFIG
klibc/klibc/arch/x86_64/Makefile.inc
klibc/klibc/arch/x86_64/syscall.S
klibc/klibc/fgets.c
klibc/klibc/sigaction.c
klibc/klibc/sigpending.c
klibc/klibc/sigprocmask.c
klibc/klibc/sigsuspend.c
klibc/klibc/strntoumax.c
klibc/makeklcc.pl [changed mode: 0644->0755]
klibc/version

index 5071e60da40ef6b3f8f7eef0d01273a5ffaccacb..e634aaccb58ad5a734a3939aaa0fdf2db1946df4 100644 (file)
@@ -69,4 +69,9 @@ local-install: $(CROSS)klcc
        $(INSTALL_DATA) klcc.1 $(INSTALLROOT)$(mandir)/man1/$(KCROSS)klcc.1
        $(INSTALL_EXEC) $(KCROSS)klcc $(INSTALLROOT)$(bindir)
 
+# This does all the prep work needed to turn a freshly exported git repository
+# into a release tarball tree
+release: klibc.spec
+       rm -f maketar.sh
+
 -include MCONFIG
diff --git a/klibc/include/netpacket/packet.h b/klibc/include/netpacket/packet.h
new file mode 100644 (file)
index 0000000..b5e8e0e
--- /dev/null
@@ -0,0 +1 @@
+#include <linux/if_packet.h>
index ab3c98d6e4cfa7f27369b0ed035cf0acf26394e8..05930bdea16d753a1b67e8e9604f7cca02969c39 100644 (file)
@@ -82,10 +82,6 @@ __extern int sigaction(int, const struct sigaction *, struct sigaction *);
 __extern int sigprocmask(int, const sigset_t *, sigset_t *);
 __extern int sigpending(sigset_t *);
 __extern int sigsuspend(const sigset_t *);
-__extern int rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t);
-__extern int rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t);
-__extern int rt_sigpending(sigset_t *, size_t);
-__extern int rt_sigsuspend(const sigset_t *, size_t);
 __extern int raise(int);
 __extern int kill(pid_t, int);
 
index a6f979c6c4ac4e3d8f1dee02a2e69b92476c2d74..76334a3a54fe781854783c6fcb3091b41c5c5581 100644 (file)
@@ -1,4 +1,4 @@
-.\" $Id: klcc.1,v 1.2 2005/03/02 02:24:17 hpa Exp $
+.\" $Id: klcc.1,v 1.3 2005/04/19 23:27:46 hpa Exp $
 .\" -----------------------------------------------------------------------
 .\"   
 .\"   Copyright 2005 H. Peter Anvin - All Rights Reserved
@@ -39,7 +39,9 @@ klcc \- compile a program against klibc
 .B klcc
 is a wrapper around
 .BR gcc (1)
-to compile a program against the
+and
+.BR ld (1)
+which compiles and links a program against the
 .B klibc
 tiny C library.  It supports most
 .B gcc
@@ -63,7 +65,12 @@ or
 option to use the default optimization level; this will generally
 result in the smallest binaries.  You may want to use
 .B \-s
-when linking, however.
+when linking, however.  Use
+.B \-O0
+to compile without any optimization whatsoever; this may not work depending
+on the version of
+.B gcc
+used.
 .PP
 Use the
 .B \-shared
@@ -72,10 +79,38 @@ or
 option to compile for and link against shared or static klibc.  Note
 that shared klibc only supports running against the exact same klibc
 binary as the binary was linked with.
+.PP
+In addition to standard
+.B gcc
+options,
+.B klcc
+supports options of the form \fB\-print-klibc-\fP\fIoption\fP,
+which prints the corresponding klibc configuration option.
 .SH AUTHOR
 Written by H. Peter Anvin <hpa@zytor.com>.
 .SH COPYRIGHT
-Copyright \(co 2005 H. Peter Anvin.
+Copyright \(co 2005 H. Peter Anvin \- All Rights Reserved
+.PP
+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:
+.PP
+The above copyright notice and this permission notice shall
+be included in all copies or substantial portions of the Software.
+.PP
+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.
 .SH "SEE ALSO"
 .BR gcc (1)
 
index 36c4d9b3eeeb6332b5a9d9fc369529a6db033e5f..5629f24f1c02e7a15c8bd3f504f58d008f6fcbe8 100644 (file)
@@ -1,5 +1,7 @@
 # -*- perl -*-
 
+use IPC::Open3;
+
 # Standard includes
 @includes = ("-I${prefix}/${KCROSS}include/arch/${ARCH}",
             "-I${prefix}/${KCROSS}include/bits${BITSIZE}",
@@ -57,7 +59,7 @@ sub files_with_lang($$) {
 
        # Skip object files
        if ( $need ne 'obj' ) {
-           unless ( $xopt eq $need ) {
+           unless ( $xopt eq $need || $need eq 'stdin') {
                push(@as, '-x', $need);
                $xopt = $need;
            }
@@ -79,7 +81,11 @@ sub syserr($) {
 # Run a program; printing out the command line if $verbose is set
 sub mysystem(@) {
     print STDERR join(' ', @_), "\n" if ( $verbose );
-    return system(@_);
+    my $cmd = shift;
+    open(INPUT, "<&STDIN");    # dup STDIN filehandle to INPUT
+    my $childpid = open3("<&INPUT", ">&STDOUT", ">&STDERR", $cmd, @_);
+    waitpid ($childpid, 0);
+    return $?;
 }
 
 #
@@ -117,6 +123,11 @@ while ( defined($a = shift(@ARGV)) ) {
        # Not an option.  Must be a filename then.
        push(@files, $a);
        $flang{$a} = $lang || filename2lang($a);
+    } elsif ( $a eq '-' ) {
+       # gcc gets its input from stdin
+       push(@files, $a);
+       # prevent setting -x
+       $flang{$a} = 'stdin'
     } elsif ( $a =~ /^-print-klibc-(.*)$/ ) {
        # This test must precede -print
        if ( defined($conf{$1}) ) {
index e8b9a7f176670b5f67d965de19621422fa32588a..11d8c9a47e8b206116e351e0fa0665e0a5eb4756 100644 (file)
@@ -145,17 +145,29 @@ ssize_t pwrite64,pwrite::pwrite(int, void *, size_t, off_t)
 ;
 ; Signal operations
 ;
-int kill(pid_t, int)
 ; We really should get rid of the non-rt_* of these, but that takes
-; sanitizing <signal.h> for all architectures, sigh...
-<?> int sigaction(int, const struct sigaction *, struct sigaction *)
-<?> int sigsuspend(const sigset_t *)
-<?> int sigpending(sigset_t *)
-<?> int sigprocmask(int, const sigset_t *, sigset_t *)
-int rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t)
-int rt_sigsuspend(const sigset_t *, size_t)
-int rt_sigpending(sigset_t *, size_t)
-int rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t)
+; sanitizing <signal.h> for all architectures, sigh.
+#ifdef __NR_sigaction
+int sigaction::__sigaction(int, const struct sigaction *, struct sigaction *)
+#else
+int rt_sigaction::__rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t)
+#endif
+#ifdef __NR_sigsuspend
+int sigsuspend(const sigset_t *)
+#else
+int rt_sigsuspend::__rt_sigsuspend(const sigset_t *, size_t)
+#endif
+#ifdef __NR_sigpending
+int sigpending(sigset_t *)
+#else
+int rt_sigpending::__rt_sigpending(sigset_t *, size_t)
+#endif
+#ifdef __NR_sigprocmask
+int sigprocmask(int, const sigset_t *, sigset_t *)
+#else
+int rt_sigprocmask::__rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t)
+#endif
+int kill(pid_t, int)
 <?> unsigned int alarm(unsigned int)
 int getitimer(int, struct itimerval *)
 int setitimer(int, const struct itimerval *, struct itimerval *)
index 5c320cb45322ababc07563a1383407836d12f45a..80344bd0a573253996b388a243d082d04b16cb5f 100644 (file)
@@ -13,6 +13,7 @@ ARCHOBJS = \
        arch/$(ARCH)/setjmp.o \
        arch/$(ARCH)/syscall.o \
        arch/$(ARCH)/open.o \
+       arch/$(ARCH)/sigreturn.o \
        arch/$(ARCH)/libgcc/__ashldi3.o \
        arch/$(ARCH)/libgcc/__ashrdi3.o \
        arch/$(ARCH)/libgcc/__lshrdi3.o \
index 13b6e391f9910e5b9df3ad275c84ecfad8fb7340..c9b5da8bd6a01248391a227333823e8558f92203 100644 (file)
 # debugging using gdb.
 #
 ARCHREQFLAGS = -m64
+ifeq ($(DEBUG),y)
+OPTFLAGS     = -Os -fomit-frame-pointer \
+               -falign-functions=0 -falign-jumps=0 -falign-loops=0
+else
 OPTFLAGS     = -Os -fno-asynchronous-unwind-tables -fomit-frame-pointer \
                -falign-functions=0 -falign-jumps=0 -falign-loops=0
+endif
 BITSIZE      = 64
 LDFLAGS      = -m elf_x86_64
 
index d6cc1204e488ff8cac8acda9989c07bdea011a9d..26d880d7c725a51756bb985c2076fbbb0a1c90e5 100644 (file)
@@ -10,7 +10,8 @@
 ARCHOBJS = \
        arch/$(ARCH)/exits.o \
        arch/$(ARCH)/setjmp.o \
-       arch/$(ARCH)/syscall.o
+       arch/$(ARCH)/syscall.o \
+       arch/$(ARCH)/sigreturn.o
 
 ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
 
index f2c74ae974d8c5a9ef4726d4f55a1d190b88a158..17977978b9efce573462e7169cb7a728be540d6f 100644 (file)
@@ -15,14 +15,14 @@ __syscall_common:
        syscall
 
        cmpq    $-4095,%rax
-       jb      1f
+       jnb     1f
+       ret
 
        # Error return, must set errno
+1:
        negl    %eax
        movl    %eax,errno(%rip)        # errno is type int, so 32 bits
        orq     $-1,%rax                # orq $-1 smaller than movq $-1
-
-1:
        ret
 
        .size   __syscall_common,.-__syscall_common
index 88a145a63f065b84d88b8fe081eda67723986ffd..72f8a13cf1d7f3c192c902f8287bc6d783a07a68 100644 (file)
@@ -20,6 +20,7 @@ char *fgets(char *s, int n, FILE *f)
       return NULL;
     }
     *p++ = ch;
+    n--;
     if ( ch == '\n' )
       break;
   }
index 819ffd4fe82efbc812d14d300fcdb95b2b4d54a5..85f42a244cc65ff7d65f6bde9a21a8c1e146aadb 100644 (file)
@@ -5,11 +5,40 @@
 #include <signal.h>
 #include <sys/syscall.h>
 
-#ifndef __NR_sigaction
+__extern void __sigreturn(void);
+__extern int __sigaction(int, const struct sigaction *, struct sigaction *);
+__extern int __rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t);
 
 int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
 {
-  return rt_sigaction(sig, act, oact, sizeof(sigset_t));
-}
+  int rv;
+
+#if defined(__i386__) || defined(__x86_64__)
+  /* x86-64, and the Fedora i386 kernel, are broken without SA_RESTORER */
+  struct sigaction sa;
+
+  if ( act && !(act->sa_flags & SA_RESTORER) ) {
+    sa = *act;
+    act = &sa;
+
+    /* The kernel can't be trusted to have a valid default restorer */
+    sa.sa_flags |= SA_RESTORER;
+    sa.sa_restorer = &__sigreturn;
+  }
+#endif
 
+#ifdef __NR_sigaction
+  rv = __sigaction(sig, act, oact);
+#else
+  rv = __rt_sigaction(sig, act, oact, sizeof(sigset_t));
 #endif
+
+
+#if defined(__i386__) || defined(__x86_64__)
+  if ( oact && (oact->sa_restorer == &__sigreturn) ) {
+    oact->sa_flags &= ~SA_RESTORER;
+  }
+#endif
+
+  return rv;
+}
index 76d2b1a7f6c939230d28483eb7c61fae5a5b9169..decfe32b1bd809543b2b8875806d9e0629bd3edf 100644 (file)
@@ -7,9 +7,11 @@
 
 #ifndef __NR_sigpending
 
+__extern __rt_sigpending(sigset_t *, size_t);
+
 int sigpending(sigset_t *set)
 {
-  return rt_sigpending(set, sizeof(sigset_t));
+  return __rt_sigpending(set, sizeof(sigset_t));
 }
 
 #endif
index b5e58b28b8489f77c627b18b09eb747560827cd1..372e0fd90d5c40a48aa8543ca21c791b5f7c43d4 100644 (file)
@@ -7,9 +7,11 @@
 
 #ifndef __NR_sigprocmask
 
+__extern __rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t);
+
 int sigprocmask(int how, const sigset_t *set, sigset_t *oset)
 {
-  return rt_sigprocmask(how, set, oset, sizeof(sigset_t));
+  return __rt_sigprocmask(how, set, oset, sizeof(sigset_t));
 }
 
 #endif
index a927999ae68ac68c396775b8b7a4db86f768f207..22f9a46681a0c11859599d514f0c8f27b83eb162 100644 (file)
@@ -7,9 +7,11 @@
 
 #ifndef __NR_sigsuspend
 
+__extern int __rt_sigsuspend(const sigset_t *, size_t);
+
 int sigsuspend(const sigset_t *mask)
 {
-  return rt_sigsuspend(mask, sizeof *mask);
+  return __rt_sigsuspend(mask, sizeof *mask);
 }
 
 #endif
index 4e30637d2c3bd5ebf8a219693693852da3ba9d3b..4c47fe8662f9524d8e782b326da315550be77073 100644 (file)
@@ -33,12 +33,13 @@ uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n)
   }
 
   /* Single optional + or - */
-  if ( n && *nptr == '-' ) {
-    minus = 1;
-    nptr++;
-    n--;
-  } else if ( n && *nptr == '+' ) {
-    nptr++;
+  if ( n ) {
+    char c = *nptr;
+    if ( c == '-' || c == '+' ) {
+      minus = (c == '-');
+      nptr++;
+      n--;
+    }
   }
 
   if ( base == 0 ) {
old mode 100644 (file)
new mode 100755 (executable)
index 238d6e882a08cec91c9bf37bd210147a0c968798..5b09c67c2066cc1cf4b56a66f4f9875115b9f4ad 100644 (file)
@@ -1 +1 @@
-1.0.7
+1.0.14