summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgreg@kroah.com <greg@kroah.com>2003-12-17 00:22:55 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:08 -0700
commit3555a14bae9f372385e4bc01368027cdbc29384c (patch)
tree581893cb67b1788f38b51fbbabd2c7deadd0e810
parentc63a27273bffd268dfedc492399f3be71bad5dd4 (diff)
[PATCH] sync klibc with release 0.95
-rw-r--r--klibc/Makefile17
-rw-r--r--klibc/klibc/Makefile9
-rw-r--r--klibc/klibc/SYSCALLS7
-rw-r--r--klibc/klibc/arch/i386/include/klibc/archsignal.h2
-rw-r--r--klibc/klibc/arch/ia64/Makefile.inc11
-rw-r--r--klibc/klibc/arch/ia64/include/klibc/archsignal.h2
-rw-r--r--klibc/klibc/arch/ia64/pipe.c42
-rw-r--r--klibc/klibc/arch/ppc/Makefile.inc8
-rw-r--r--klibc/klibc/arch/ppc/crt0.S27
-rw-r--r--klibc/klibc/arch/ppc64/Makefile.inc5
-rw-r--r--klibc/klibc/arch/ppc64/crt0.S14
-rw-r--r--klibc/klibc/arch/ppc64/include/klibc/archsetjmp.h36
-rw-r--r--klibc/klibc/arch/ppc64/setjmp.S46
-rw-r--r--klibc/klibc/arch/s390/Makefile.inc7
-rw-r--r--klibc/klibc/include/klibc/compiler.h7
-rw-r--r--klibc/klibc/include/signal.h6
-rw-r--r--klibc/klibc/include/stdio.h5
-rw-r--r--klibc/klibc/include/sys/module.h158
-rw-r--r--klibc/klibc/inet/bindresvport.c2
-rw-r--r--klibc/klibc/mmap.c2
-rw-r--r--klibc/klibc/strcasecmp.c24
-rw-r--r--klibc/klibc/strerror.c1
-rw-r--r--klibc/klibc/strncasecmp.c23
-rw-r--r--klibc/klibc/strncmp.c2
-rw-r--r--klibc/klibc/syscommon.h1
-rw-r--r--klibc/klibc/tests/memstrtest.c4
-rw-r--r--klibc/klibc/tests/minips.c1
-rw-r--r--klibc/version2
28 files changed, 240 insertions, 231 deletions
diff --git a/klibc/Makefile b/klibc/Makefile
index 5f9a7d6a6e..ef5fbabff8 100644
--- a/klibc/Makefile
+++ b/klibc/Makefile
@@ -1,6 +1,23 @@
+VERSION := $(shell cat version)
SUBDIRS = klibc
all:
+rpmbuild = $(shell which rpmbuild 2>/dev/null || which rpm)
+
+klibc.spec: klibc.spec.in version
+ sed -e 's/@@VERSION@@/$(VERSION)/g' < $< > $@
+
+.PHONY: rpm
+rpm: klibc.spec
+ +$(rpmbuild) -bb klibc.spec
+
%:
@set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
+
+clean:
+ @set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
+
+spotless:
+ @set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
+ rm -f klibc.spec *~ tags
diff --git a/klibc/klibc/Makefile b/klibc/klibc/Makefile
index e1d63381c1..5fc481aa8a 100644
--- a/klibc/klibc/Makefile
+++ b/klibc/klibc/Makefile
@@ -57,6 +57,12 @@ tests: $(TESTS)
tests/%.o : tests/%.c
$(CC) $(CFLAGS) -c -o $@ $<
+# This particular file uses a bunch of formats gcc don't know of, in order
+# to test the full range of our vsnprintf() function. This outputs a bunch
+# of useless warnings unless we tell it not to.
+tests/testvsnp.o : tests/testvsnp.c
+ $(CC) $(CFLAGS) -Wno-format -c -o $@ $<
+
tests/% : tests/%.o $(LIB) $(CRT0)
$(LD) $(LDFLAGS) -o $@ $(CRT0) $< $(LIB) $(LIBGCC)
cp $@ $@.stripped
@@ -131,6 +137,9 @@ spotless: clean
find . \( -name \*~ -o -name '.*.d' \) -not -type d -print0 | \
xargs -0rt rm -f
+bitsize:
+ @echo $(BITSIZE)
+
ifneq ($(wildcard $(DIR)/.*.d),)
include $(wildcard $(DIR)/.*.d)
endif
diff --git a/klibc/klibc/SYSCALLS b/klibc/klibc/SYSCALLS
index 92dff963b3..0be1b4425a 100644
--- a/klibc/klibc/SYSCALLS
+++ b/klibc/klibc/SYSCALLS
@@ -73,7 +73,7 @@ int mknod(const char *, mode_t, dev_t)
int chmod(const char *, mode_t)
int mkdir(const char *, mode_t)
int rmdir(const char *)
-<!alpha,mips,mips64> int pipe(int *)
+<!alpha,ia64,mips,mips64> int pipe(int *)
mode_t umask(mode_t)
int chroot(const char *)
int symlink(const char *, const char *)
@@ -139,9 +139,8 @@ int mprotect(const void *, size_t, int)
int uname(struct utsname *)
int setdomainname(const char *, size_t)
int sethostname(const char *, size_t)
-int init_module(const char *, struct module *)
-<!ia64> void * create_module(const char *, size_t)
-int delete_module(const char *)
+long init_module(void *, unsigned long, const char *)
+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)
diff --git a/klibc/klibc/arch/i386/include/klibc/archsignal.h b/klibc/klibc/arch/i386/include/klibc/archsignal.h
index caea8d8b3d..b092ba6d3a 100644
--- a/klibc/klibc/arch/i386/include/klibc/archsignal.h
+++ b/klibc/klibc/arch/i386/include/klibc/archsignal.h
@@ -8,6 +8,6 @@
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
-typedef int sig_atomic_t;
+/* No special stuff for this architecture */
#endif
diff --git a/klibc/klibc/arch/ia64/Makefile.inc b/klibc/klibc/arch/ia64/Makefile.inc
index edf43459f8..781448770e 100644
--- a/klibc/klibc/arch/ia64/Makefile.inc
+++ b/klibc/klibc/arch/ia64/Makefile.inc
@@ -9,7 +9,16 @@
ARCHOBJS = \
arch/$(ARCH)/vfork.o \
- arch/$(ARCH)/setjmp.o
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/pipe.o \
+ libgcc/__divdi3.o \
+ libgcc/__divsi3.o \
+ libgcc/__udivdi3.o \
+ libgcc/__udivsi3.o \
+ libgcc/__umodsi3.o \
+ libgcc/__umoddi3.o \
+ libgcc/__udivmodsi4.o \
+ libgcc/__udivmoddi4.o
ARCHSOOBJS = $(patsubst %o,%.lo,%(ARCHOBJS))
diff --git a/klibc/klibc/arch/ia64/include/klibc/archsignal.h b/klibc/klibc/arch/ia64/include/klibc/archsignal.h
index 9ab0ed744c..5b01f19bc2 100644
--- a/klibc/klibc/arch/ia64/include/klibc/archsignal.h
+++ b/klibc/klibc/arch/ia64/include/klibc/archsignal.h
@@ -28,6 +28,4 @@ struct sigaction {
#define sa_handler _u._sa_handler
#define sa_sigaction _u._sa_sigaction
-typedef int sig_atomic_t;
-
#endif
diff --git a/klibc/klibc/arch/ia64/pipe.c b/klibc/klibc/arch/ia64/pipe.c
new file mode 100644
index 0000000000..5f5dd05727
--- /dev/null
+++ b/klibc/klibc/arch/ia64/pipe.c
@@ -0,0 +1,42 @@
+/*
+ * pipe.c
+ */
+
+#include "syscommon.h"
+#include <klibc/archsys.h>
+
+#define ASM_CLOBBERS ,"out2", "out3", "out4", "out5", "out6", "out7", \
+ /* Non-stacked integer registers, minus r8, r9, r10, r15. */ \
+ "r2", "r3", "r11", "r12", "r13", "r14", "r16", "r17", "r18", \
+ "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", \
+ "r28", "r29", "r30", "r31", \
+ /* Predicate registers. */ \
+ "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
+ /* Non-rotating fp registers. */ \
+ "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
+ /* Branch registers. */ \
+ "b6", "b7"
+
+int pipe(int *filedes)
+{
+ register long _r8 asm("r8");
+ register long _r9 asm("r9");
+ register long _r10 asm("r10");
+ register long _r15 asm("r15") = __NR_pipe;
+ register long _out0 asm ("out0") = (long)filedes;
+ long _retval;
+ __asm __volatile (__IA64_BREAK
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15),
+ "=r" (_out0)
+ : "2" (_r15), "3" (_out0)
+ : "memory" ASM_CLOBBERS);
+ if (_r10 == -1) {
+ errno = _r8;
+ _retval = -1;
+ } else {
+ filedes[0] = _r8;
+ filedes[1] = _r9;
+ _retval = 0;
+ }
+ return _retval;
+}
diff --git a/klibc/klibc/arch/ppc/Makefile.inc b/klibc/klibc/arch/ppc/Makefile.inc
index 6e87a48d6b..3bd2c0643c 100644
--- a/klibc/klibc/arch/ppc/Makefile.inc
+++ b/klibc/klibc/arch/ppc/Makefile.inc
@@ -8,7 +8,13 @@
#
ARCHOBJS = \
- arch/$(ARCH)/setjmp.o
+ arch/$(ARCH)/setjmp.o \
+ libgcc/__divdi3.o \
+ libgcc/__moddi3.o \
+ libgcc/__udivdi3.o \
+ libgcc/__umoddi3.o \
+ libgcc/__udivmoddi4.o
+
ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
diff --git a/klibc/klibc/arch/ppc/crt0.S b/klibc/klibc/arch/ppc/crt0.S
index f7274b07dd..282f8411e4 100644
--- a/klibc/klibc/arch/ppc/crt0.S
+++ b/klibc/klibc/arch/ppc/crt0.S
@@ -1,29 +1,20 @@
#
# arch/ppc/crt0.S
#
-# void _start(void)
-# {
-# /* Divine up argc, argv, and envp */
-# environ = envp;
-# exit(main(argc, argv, envp));
-# }
-#
.text
.align 4
.type _start,@function
.globl _start
_start:
- lwz 3,0(1)
- addi 4,1,4
- addi 5,1,8
- slwi 0,3,2
- add 5,5,0
- li 0,0
- stwu 0,-16(1)
- lis 9,environ@ha
- stw 5,environ@l(9)
- bl main
- bl exit
+ stwu 1,-16(1)
+ addi 3,1,16
+ /*
+ * the SVR4abippc.pdf specifies r7 as a pointer to
+ * a termination function pointer.
+ * It is unused on Linux.
+ */
+ mr 4,7
+ bl __libc_init
.size _start,.-_start
diff --git a/klibc/klibc/arch/ppc64/Makefile.inc b/klibc/klibc/arch/ppc64/Makefile.inc
index 434d0aad96..3ab3a8c8e6 100644
--- a/klibc/klibc/arch/ppc64/Makefile.inc
+++ b/klibc/klibc/arch/ppc64/Makefile.inc
@@ -7,4 +7,9 @@
# accordingly.
#
+ARCHOBJS = \
+ arch/$(ARCH)/setjmp.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
archclean:
diff --git a/klibc/klibc/arch/ppc64/crt0.S b/klibc/klibc/arch/ppc64/crt0.S
index 2f352e8045..872d2a0791 100644
--- a/klibc/klibc/arch/ppc64/crt0.S
+++ b/klibc/klibc/arch/ppc64/crt0.S
@@ -23,16 +23,10 @@ _start:
.globl ._start
.type ._start,@function
._start:
- ld 3,0(1)
- ld 4,8(1)
- ld 5,16(1)
- li 0,0
- stdu 0,-64(1)
- ld 9,.LC0@toc(2)
- std 5,0(9)
- bl .main
- nop
- bl .exit
+ stdu %r1,-32(%r1)
+ addi %r3,%r1,32
+ mr %r4,%r7 /* fini */
+ b .__libc_init
nop
.size _start,.-_start
diff --git a/klibc/klibc/arch/ppc64/include/klibc/archsetjmp.h b/klibc/klibc/arch/ppc64/include/klibc/archsetjmp.h
new file mode 100644
index 0000000000..006a2e27be
--- /dev/null
+++ b/klibc/klibc/arch/ppc64/include/klibc/archsetjmp.h
@@ -0,0 +1,36 @@
+/*
+ * arch/ppc64/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __r2;
+ unsigned long __sp;
+ unsigned long __lr;
+ unsigned long __cr;
+ unsigned long __r13;
+ unsigned long __r14;
+ unsigned long __r15;
+ unsigned long __r16;
+ unsigned long __r17;
+ unsigned long __r18;
+ unsigned long __r19;
+ unsigned long __r20;
+ unsigned long __r21;
+ unsigned long __r22;
+ unsigned long __r23;
+ unsigned long __r24;
+ unsigned long __r25;
+ unsigned long __r26;
+ unsigned long __r27;
+ unsigned long __r28;
+ unsigned long __r29;
+ unsigned long __r30;
+ unsigned long __r31;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
diff --git a/klibc/klibc/arch/ppc64/setjmp.S b/klibc/klibc/arch/ppc64/setjmp.S
new file mode 100644
index 0000000000..1dcc67035e
--- /dev/null
+++ b/klibc/klibc/arch/ppc64/setjmp.S
@@ -0,0 +1,46 @@
+#
+# arch/ppc64/setjmp.S
+#
+# Basic setjmp/longjmp implementation
+# This file was derived from the equivalent file in NetBSD
+#
+
+ .text
+ .align 4
+
+ .section ".opd","aw"
+setjmp:
+ .quad .setjmp,.TOC.@tocbase,0
+ .previous
+ .size setjmp,24
+ .type .setjmp,@function
+ .globl setjmp
+ .globl .setjmp
+.setjmp:
+ mflr %r11 /* save return address */
+ mfcr %r12 /* save condition register */
+ mr %r10,%r1 /* save stack pointer */
+ mr %r9,%r2 /* save GPR2 (not needed) */
+ stmw %r9,0(%r3) /* save r9..r31 */
+ li %r3,0 /* indicate success */
+ blr /* return */
+
+ .size .setjmp,.-.setjmp
+ .section ".opd","aw"
+longjmp:
+ .quad .longjmp,.TOC.@tocbase,0
+ .previous
+ .size longjmp,24
+ .type .longjmp,@function
+ .globl longjmp
+ .globl .longjmp
+.longjmp:
+ lmw %r9,0(%r3) /* save r9..r31 */
+ mtlr %r11 /* restore LR */
+ mtcr %r12 /* restore CR */
+ mr %r2,%r9 /* restore GPR2 (not needed) */
+ mr %r1,%r10 /* restore stack */
+ mr %r3,%r4 /* get return value */
+ blr /* return */
+
+ .size .longjmp,.-.longjmp
diff --git a/klibc/klibc/arch/s390/Makefile.inc b/klibc/klibc/arch/s390/Makefile.inc
index 45aa551695..c50f4f2886 100644
--- a/klibc/klibc/arch/s390/Makefile.inc
+++ b/klibc/klibc/arch/s390/Makefile.inc
@@ -8,7 +8,12 @@
#
ARCHOBJS = \
- arch/$(ARCH)/setjmp.o
+ arch/$(ARCH)/setjmp.o \
+ libgcc/__divdi3.o \
+ libgcc/__moddi3.o \
+ libgcc/__udivdi3.o \
+ libgcc/__umoddi3.o \
+ libgcc/__udivmoddi4.o
ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
diff --git a/klibc/klibc/include/klibc/compiler.h b/klibc/klibc/include/klibc/compiler.h
index 5c284b206c..64b8c54158 100644
--- a/klibc/klibc/include/klibc/compiler.h
+++ b/klibc/klibc/include/klibc/compiler.h
@@ -58,4 +58,11 @@
# define __unlikely(x) (x)
#endif
+/* Possibly unused function */
+#ifdef __GNUC__
+# define __unusedfunc __attribute__((unused))
+#else
+# define __unusedfunc
+#endif
+
#endif
diff --git a/klibc/klibc/include/signal.h b/klibc/klibc/include/signal.h
index 62c5083dc0..f9eebb2a29 100644
--- a/klibc/klibc/include/signal.h
+++ b/klibc/klibc/include/signal.h
@@ -13,6 +13,12 @@
#include <klibc/archsignal.h>
+/* glibc seems to use sig_atomic_t as "int" pretty much on all architectures.
+ Do the same, but allow the architecture to override. */
+#ifdef _KLIBC_HAS_ARCH_SIG_ATOMIC_T
+typedef int sig_atomic_t;
+#endif
+
/* Some architectures don't define these */
#ifndef SA_RESETHAND
# define SA_RESETHAND SA_ONESHOT
diff --git a/klibc/klibc/include/stdio.h b/klibc/klibc/include/stdio.h
index 5e621af5f1..f57439f018 100644
--- a/klibc/klibc/include/stdio.h
+++ b/klibc/klibc/include/stdio.h
@@ -78,12 +78,13 @@ __extern size_t _fread(void *, size_t, FILE *);
__extern size_t _fwrite(const void *, size_t, FILE *);
#ifndef __NO_FREAD_FWRITE_INLINES
-static __inline__ size_t
+extern __inline__ size_t
fread(void *__p, size_t __s, size_t __n, FILE *__f)
{
return _fread(__p, __s*__n, __f)/__s;
}
-static __inline__ size_t
+
+extern __inline__ size_t
fwrite(void *__p, size_t __s, size_t __n, FILE *__f)
{
return _fwrite(__p, __s*__n, __f)/__s;
diff --git a/klibc/klibc/include/sys/module.h b/klibc/klibc/include/sys/module.h
deleted file mode 100644
index 96b3b59945..0000000000
--- a/klibc/klibc/include/sys/module.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * sys/module.h
- *
- * This is a bastardized version of linux/module.h, since the latter
- * doesn't have __KERNEL__ guards where it needs them...
- */
-
-#ifndef _SYS_MODULE_H
-#define _SYS_MODULE_H
-
-/*
- * Dynamic loading of modules into the kernel.
- *
- * Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996
- */
-
-#include <asm/atomic.h>
-
-/* Don't need to bring in all of uaccess.h just for this decl. */
-struct exception_table_entry;
-
-/* Used by get_kernel_syms, which is obsolete. */
-struct kernel_sym
-{
- unsigned long value;
- char name[60]; /* should have been 64-sizeof(long); oh well */
-};
-
-struct module_symbol
-{
- unsigned long value;
- const char *name;
-};
-
-struct module_ref
-{
- struct module *dep; /* "parent" pointer */
- struct module *ref; /* "child" pointer */
- struct module_ref *next_ref;
-};
-
-/* TBD */
-struct module_persist;
-
-struct module
-{
- unsigned long size_of_struct; /* == sizeof(module) */
- struct module *next;
- const char *name;
- unsigned long size;
-
- union
- {
- atomic_t usecount;
- long pad;
- } uc; /* Needs to keep its size - so says rth */
-
- unsigned long flags; /* AUTOCLEAN et al */
-
- unsigned nsyms;
- unsigned ndeps;
-
- struct module_symbol *syms;
- struct module_ref *deps;
- struct module_ref *refs;
- int (*init)(void);
- void (*cleanup)(void);
- const struct exception_table_entry *ex_table_start;
- const struct exception_table_entry *ex_table_end;
-#ifdef __alpha__
- unsigned long gp;
-#endif
- /* Members past this point are extensions to the basic
- module support and are optional. Use mod_member_present()
- to examine them. */
- const struct module_persist *persist_start;
- const struct module_persist *persist_end;
- int (*can_unload)(void);
- int runsize; /* In modutils, not currently used */
- const char *kallsyms_start; /* All symbols for kernel debugging */
- const char *kallsyms_end;
- const char *archdata_start; /* arch specific data for module */
- const char *archdata_end;
- const char *kernel_data; /* Reserved for kernel internal use */
-};
-
-struct module_info
-{
- unsigned long addr;
- unsigned long size;
- unsigned long flags;
- long usecount;
-};
-
-/* Bits of module.flags. */
-
-#define MOD_UNINITIALIZED 0
-#define MOD_RUNNING 1
-#define MOD_DELETED 2
-#define MOD_AUTOCLEAN 4
-#define MOD_VISITED 8
-#define MOD_USED_ONCE 16
-#define MOD_JUST_FREED 32
-#define MOD_INITIALIZING 64
-
-/* Values for query_module's which. */
-
-#define QM_MODULES 1
-#define QM_DEPS 2
-#define QM_REFS 3
-#define QM_SYMBOLS 4
-#define QM_INFO 5
-
-/* Can the module be queried? */
-#define MOD_CAN_QUERY(mod) (((mod)->flags & (MOD_RUNNING | MOD_INITIALIZING)) && !((mod)->flags & MOD_DELETED))
-
-/* When struct module is extended, we must test whether the new member
- is present in the header received from insmod before we can use it.
- This function returns true if the member is present. */
-
-#define mod_member_present(mod,member) \
- ((unsigned long)(&((struct module *)0L)->member + 1) \
- <= (mod)->size_of_struct)
-
-/*
- * Ditto for archdata. Assumes mod->archdata_start and mod->archdata_end
- * are validated elsewhere.
- */
-#define mod_archdata_member_present(mod, type, member) \
- (((unsigned long)(&((type *)0L)->member) + \
- sizeof(((type *)0L)->member)) <= \
- ((mod)->archdata_end - (mod)->archdata_start))
-
-
-/* Check if an address p with number of entries n is within the body of module m */
-#define mod_bound(p, n, m) ((unsigned long)(p) >= ((unsigned long)(m) + ((m)->size_of_struct)) && \
- (unsigned long)((p)+(n)) <= (unsigned long)(m) + (m)->size)
-
-/* Backwards compatibility definition. */
-
-#define GET_USE_COUNT(module) (atomic_read(&(module)->uc.usecount))
-
-/* Poke the use count of a module. */
-
-#define __MOD_INC_USE_COUNT(mod) \
- (atomic_inc(&(mod)->uc.usecount), (mod)->flags |= MOD_VISITED|MOD_USED_ONCE)
-#define __MOD_DEC_USE_COUNT(mod) \
- (atomic_dec(&(mod)->uc.usecount), (mod)->flags |= MOD_VISITED)
-#define __MOD_IN_USE(mod) \
- (mod_member_present((mod), can_unload) && (mod)->can_unload \
- ? (mod)->can_unload() : atomic_read(&(mod)->uc.usecount))
-
-/* Indirect stringification. */
-
-#define __MODULE_STRING_1(x) #x
-#define __MODULE_STRING(x) __MODULE_STRING_1(x)
-
-#endif /* _SYS_MODULE_H */
diff --git a/klibc/klibc/inet/bindresvport.c b/klibc/klibc/inet/bindresvport.c
index b5f327bb33..c30054edfd 100644
--- a/klibc/klibc/inet/bindresvport.c
+++ b/klibc/klibc/inet/bindresvport.c
@@ -37,7 +37,7 @@ int bindresvport(int sd, struct sockaddr_in *sin)
for (i = 0; i < NUM_PORTS; i++, port++) {
sin->sin_port = htons(port);
- if ((ret = bind(sd, sin, sizeof(*sin))) != -1)
+ if ((ret = bind(sd, (struct sockaddr *)&sin, sizeof(*sin))) != -1)
break;
if (port == END_PORT)
port = START_PORT;
diff --git a/klibc/klibc/mmap.c b/klibc/klibc/mmap.c
index 3d28cba601..aedf4dceb5 100644
--- a/klibc/klibc/mmap.c
+++ b/klibc/klibc/mmap.c
@@ -19,7 +19,7 @@
* Prefer mmap2() over mmap(), except on the architectures listed
*/
-#if defined(__NR_mmap2) && !defined(__sparc__) && !defined(__ia64__)
+#if defined(__NR_mmap2) && !defined(__sparc__) && !defined(__ia64__) && !defined(__powerpc64__)
/* This architecture uses mmap2() */
diff --git a/klibc/klibc/strcasecmp.c b/klibc/klibc/strcasecmp.c
index e583491b35..12aef40d93 100644
--- a/klibc/klibc/strcasecmp.c
+++ b/klibc/klibc/strcasecmp.c
@@ -1,6 +1,5 @@
/*
* strcasecmp.c
- *
*/
#include <string.h>
@@ -8,18 +7,17 @@
int strcasecmp(const char *s1, const char *s2)
{
- char *n1, *n2;
- int i, retval;
+ const unsigned char *c1 = s1, *c2 = s2;
+ unsigned char ch;
+ int d = 0;
- n1 = strdup(s1);
- n2 = strdup(s2);
+ while ( 1 ) {
+ /* toupper() expects an unsigned char (implicitly cast to int)
+ as input, and returns an int, which is exactly what we want. */
+ d = toupper(ch = *c1++) - toupper(*c2++);
+ if ( d || !ch )
+ break;
+ }
- for (i = 0; i < strlen(n1); i++)
- n1[i] = toupper(n1[i]);
- for (i = 0; i < strlen(n2); i++)
- n2[i] = toupper(n2[i]);
- retval = strcmp(n1, n2);
- free(n1);
- free(n2);
- return retval;
+ return d;
}
diff --git a/klibc/klibc/strerror.c b/klibc/klibc/strerror.c
index 754a30693c..62705553a6 100644
--- a/klibc/klibc/strerror.c
+++ b/klibc/klibc/strerror.c
@@ -10,7 +10,6 @@ char *strerror(int errnum)
char numbuf[32];
char *p;
- int len;
p = numbuf+sizeof numbuf;
*--p = '\0';
diff --git a/klibc/klibc/strncasecmp.c b/klibc/klibc/strncasecmp.c
index 542493de0f..3309d1a7fe 100644
--- a/klibc/klibc/strncasecmp.c
+++ b/klibc/klibc/strncasecmp.c
@@ -7,18 +7,17 @@
int strncasecmp(const char *s1, const char *s2, size_t n)
{
- char *n1, *n2;
- int i, retval;
+ const unsigned char *c1 = s1, *c2 = s2;
+ unsigned char ch;
+ int d = 0;
- n1 = strndup(s1, n);
- n2 = strndup(s2, n);
+ while ( n-- ) {
+ /* toupper() expects an unsigned char (implicitly cast to int)
+ as input, and returns an int, which is exactly what we want. */
+ d = toupper(ch = *c1++) - toupper(*c2++);
+ if ( d || !ch )
+ break;
+ }
- for (i = 0; i < strlen(n1); i++)
- n1[i] = toupper(n1[i]);
- for (i = 0; i < strlen(n2); i++)
- n2[i] = toupper(n2[i]);
- retval = strcmp(n1, n2);
- free(n1);
- free(n2);
- return retval;
+ return d;
}
diff --git a/klibc/klibc/strncmp.c b/klibc/klibc/strncmp.c
index 98a41c3773..4dbde1389f 100644
--- a/klibc/klibc/strncmp.c
+++ b/klibc/klibc/strncmp.c
@@ -11,7 +11,7 @@ int strncmp(const char *s1, const char *s2, size_t n)
int d = 0;
while ( n-- ) {
- d = (int)*c2++ - (int)(ch = *c1++);
+ d = (int)(ch = *c1++) - (int)*c2++;
if ( d || !ch )
break;
}
diff --git a/klibc/klibc/syscommon.h b/klibc/klibc/syscommon.h
index 224e240e38..916d4eb0c0 100644
--- a/klibc/klibc/syscommon.h
+++ b/klibc/klibc/syscommon.h
@@ -15,7 +15,6 @@
#include <sys/dirent.h>
#include <sys/klog.h>
#include <sys/mman.h>
-#include <sys/module.h>
#include <sys/resource.h>
#include <sys/select.h>
#include <sys/stat.h>
diff --git a/klibc/klibc/tests/memstrtest.c b/klibc/klibc/tests/memstrtest.c
index 14d5173cb2..70c642c067 100644
--- a/klibc/klibc/tests/memstrtest.c
+++ b/klibc/klibc/tests/memstrtest.c
@@ -8,7 +8,7 @@ int main(void)
int i;
int r;
- for(i = 0; i < sizeof(t1); i++)
+ for(i = 0; i < (int)sizeof(t1); i++)
t1[i] = t2[i] = (unsigned char)i;
r = memcmp(t1, t2, sizeof(t1));
@@ -19,7 +19,7 @@ int main(void)
r = memcmp(t1, t2, sizeof(t1));
printf("memcmp r = %d\n", r);
- for (i = 0; i < sizeof(t1); i++)
+ for (i = 0; i < (int)sizeof(t1); i++)
t1[i] = 0xaa;
memset(t2, 0xaa, sizeof(t2));
r = memcmp(t1, t2, sizeof(t1));
diff --git a/klibc/klibc/tests/minips.c b/klibc/klibc/tests/minips.c
index c599150858..20898270f4 100644
--- a/klibc/klibc/tests/minips.c
+++ b/klibc/klibc/tests/minips.c
@@ -396,6 +396,7 @@ static void print_proc(void){
);
break;
default:
+ break;
}
if(show_args) printf(" [%s]\n", P_cmd);
else printf(" %s\n", P_cmd);
diff --git a/klibc/version b/klibc/version
index e6e9cf41cc..fd6d73e4a0 100644
--- a/klibc/version
+++ b/klibc/version
@@ -1 +1 @@
-0.82
+0.95