aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2002-08-10 02:56:35 +0000
committerH. Peter Anvin <hpa@zytor.com>2002-08-10 02:56:35 +0000
commitcc1819cfb2df0055a0156025f648f74500bd5f15 (patch)
tree002b65e8d1da600a32694699c80cf4024df2cd33
parentaafcf61aac69be7e38344c934b4f2c6d25774572 (diff)
downloadklibc-cc1819cfb2df0055a0156025f648f74500bd5f15.tar.gz
Various bug fixes. minips now seems to work!klibc-0.8
-rw-r--r--include/stdlib.h11
-rw-r--r--klibc/Makefile14
-rw-r--r--klibc/README2
-rw-r--r--klibc/include/stdlib.h11
-rw-r--r--klibc/minips.c4
-rw-r--r--klibc/vsscanf.c4
-rw-r--r--minips.c4
-rw-r--r--vsscanf.c4
8 files changed, 38 insertions, 16 deletions
diff --git a/include/stdlib.h b/include/stdlib.h
index b78ada0b2f4ef..0f8b0f531e814 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -30,10 +30,17 @@ static __inline__ long labs(long __n) {
return (__n < 0L) ? -__n : __n;
}
-static __inline__ long llabs(long __n) {
+static __inline__ long long llabs(long long __n) {
return (__n < 0LL) ? -__n : __n;
}
-__extern void *malloc(size_t);
+
+#if defined(__GNUC__) && __GNUC_MAJOR__ >= 3
+# define __attribute_malloc __attribute__((malloc))
+#else
+# define __attribute_malloc
+#endif
+
+__extern __attribute_malloc void *malloc(size_t);
__extern void *realloc(void *, size_t);
__extern long strtol(const char *, char **, int);
__extern long long strtoll(const char *, char **, int);
diff --git a/klibc/Makefile b/klibc/Makefile
index c14bdf1312cac..664ef09c583cb 100644
--- a/klibc/Makefile
+++ b/klibc/Makefile
@@ -12,7 +12,7 @@ RANLIB = $(CROSS)ranlib
PERL = perl
TESTS = testvsnp hello minihello microhello getenvtest \
- getopttest malloctest
+ getopttest malloctest minips
LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \
vsscanf.o sscanf.o ctypes.o \
strntoumax.o strntoimax.o \
@@ -67,10 +67,7 @@ all: $(TESTS) $(CRT0) $(LIB) $(SOLIB)
.c.ls:
$(CC) $(CFLAGS) $(SOFLAGS) -S -o $@ $<
-# Kill implicit rule
-.o:
-
-% : %.o $(LIB) $(CRT0)
+% : %.o
$(LD) -o $@ $(CRT0) $< $(LIB) $(LIBGCC)
cp $@ $@.stripped
$(STRIP) $@.stripped
@@ -89,6 +86,8 @@ getopttest: getopttest.o $(LIB) $(CRT0)
malloctest: malloctest.o $(LIB) $(CRT0)
+minips: minips.o $(LIB) $(CRT0)
+
$(LIB): $(LIBOBJS) syscalls.dir socketcalls.dir
rm -f $(LIB)
$(AR) cq $(LIB) $(LIBOBJS) syscalls/*.o socketcalls/*.o
@@ -99,6 +98,11 @@ $(SOLIB): $(SOOBJS) syscalls.dir
$(SOOBJS) syscalls/*.lo socketcalls/*.lo \
$(LIBGCC)
+# This one *HAS* to be compiled without a frame pointer, regardless of
+# OPTFLAGS!
+crt0.o: crt0.c
+ $(CC) $(CFLAGS) -fomit-frame-pointer -c -o $@ $<
+
syscalls.dir: SYSCALLS syscalls.pl syscommon.h
rm -rf syscalls
mkdir syscalls
diff --git a/klibc/README b/klibc/README
index 2e260317774c3..8d5c7e51822f6 100644
--- a/klibc/README
+++ b/klibc/README
@@ -10,7 +10,7 @@ this:
a) Create a symlink called "linux" pointing to a reasonably recent
Linux kernel tree (2.4 or 2.5 should be OK.) This tree must have
the include/asm symlink set up for the architecture you're
- compiling for.
+ compiling for, and include/linux/autoconf.h must exist.
b) Create a symlink in the include directory called "bitsize" pointing
either to the "bits32" or the "bits64" directory, depending on the
diff --git a/klibc/include/stdlib.h b/klibc/include/stdlib.h
index b78ada0b2f4ef..0f8b0f531e814 100644
--- a/klibc/include/stdlib.h
+++ b/klibc/include/stdlib.h
@@ -30,10 +30,17 @@ static __inline__ long labs(long __n) {
return (__n < 0L) ? -__n : __n;
}
-static __inline__ long llabs(long __n) {
+static __inline__ long long llabs(long long __n) {
return (__n < 0LL) ? -__n : __n;
}
-__extern void *malloc(size_t);
+
+#if defined(__GNUC__) && __GNUC_MAJOR__ >= 3
+# define __attribute_malloc __attribute__((malloc))
+#else
+# define __attribute_malloc
+#endif
+
+__extern __attribute_malloc void *malloc(size_t);
__extern void *realloc(void *, size_t);
__extern long strtol(const char *, char **, int);
__extern long long strtoll(const char *, char **, int);
diff --git a/klibc/minips.c b/klibc/minips.c
index fd031f55321b5..c599150858d59 100644
--- a/klibc/minips.c
+++ b/klibc/minips.c
@@ -369,7 +369,7 @@ static void print_proc(void){
break;
case 'u'|0x80:
printf(
- "%5d %5d - - %5ld %4ld %s %c - %s",
+ "%5d %5d - - %5ld %5ld %s %c - %s",
P_euid, P_pid, P_vsize, P_rss, tty, P_state,
do_time(P_utime+P_stime)
);
@@ -415,7 +415,7 @@ int main(int argc, char *argv[]){
case 'l': head = " F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD"; break;
case 'f': head = " UID PID PPID C STIME TTY TIME CMD"; break;
case 'j': head = " PID PGID SID TTY TIME CMD"; break;
- case 'u'|0x80: head = " UID PID %CPU %MEM VSZ RSS TTY S START TIME COMMAND"; break;
+ case 'u'|0x80: head = " UID PID %CPU %MEM VSZ RSS TTY S START TIME COMMAND"; break;
case 'v'|0x80: head = " PID TTY S TIME MAJFL TRS DRS RSS %MEM COMMAND"; break;
case 'j'|0x80: head = " PPID PID PGID SID TTY TPGID S UID TIME COMMAND"; break;
case 'l'|0x80: head = " F UID PID PPID PRI NI VSZ RSS WCHAN S TTY TIME COMMAND"; break;
diff --git a/klibc/vsscanf.c b/klibc/vsscanf.c
index be9f4da2fa6de..7410556f88044 100644
--- a/klibc/vsscanf.c
+++ b/klibc/vsscanf.c
@@ -64,7 +64,7 @@ test_bit(unsigned long *bitmap, unsigned int bit)
return (int)(bitmap[bit/LONG_BIT] >> (bit%LONG_BIT)) & 1;
}
-int vsscanf(const char *buffer, size_t n, const char *format, va_list ap)
+int vsscanf(const char *buffer, const char *format, va_list ap)
{
const char *p = format;
char ch;
@@ -228,6 +228,7 @@ int vsscanf(const char *buffer, size_t n, const char *format, va_list ap)
bail = bail_err;
break;
}
+ q = qq;
converted++;
/* fall through */
@@ -305,6 +306,7 @@ int vsscanf(const char *buffer, size_t n, const char *format, va_list ap)
break;
}
}
+ break;
case st_match_init: /* Initial state for %[ match */
if ( ch == '^' && !(flags & FL_INV) ) {
diff --git a/minips.c b/minips.c
index fd031f55321b5..c599150858d59 100644
--- a/minips.c
+++ b/minips.c
@@ -369,7 +369,7 @@ static void print_proc(void){
break;
case 'u'|0x80:
printf(
- "%5d %5d - - %5ld %4ld %s %c - %s",
+ "%5d %5d - - %5ld %5ld %s %c - %s",
P_euid, P_pid, P_vsize, P_rss, tty, P_state,
do_time(P_utime+P_stime)
);
@@ -415,7 +415,7 @@ int main(int argc, char *argv[]){
case 'l': head = " F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD"; break;
case 'f': head = " UID PID PPID C STIME TTY TIME CMD"; break;
case 'j': head = " PID PGID SID TTY TIME CMD"; break;
- case 'u'|0x80: head = " UID PID %CPU %MEM VSZ RSS TTY S START TIME COMMAND"; break;
+ case 'u'|0x80: head = " UID PID %CPU %MEM VSZ RSS TTY S START TIME COMMAND"; break;
case 'v'|0x80: head = " PID TTY S TIME MAJFL TRS DRS RSS %MEM COMMAND"; break;
case 'j'|0x80: head = " PPID PID PGID SID TTY TPGID S UID TIME COMMAND"; break;
case 'l'|0x80: head = " F UID PID PPID PRI NI VSZ RSS WCHAN S TTY TIME COMMAND"; break;
diff --git a/vsscanf.c b/vsscanf.c
index be9f4da2fa6de..7410556f88044 100644
--- a/vsscanf.c
+++ b/vsscanf.c
@@ -64,7 +64,7 @@ test_bit(unsigned long *bitmap, unsigned int bit)
return (int)(bitmap[bit/LONG_BIT] >> (bit%LONG_BIT)) & 1;
}
-int vsscanf(const char *buffer, size_t n, const char *format, va_list ap)
+int vsscanf(const char *buffer, const char *format, va_list ap)
{
const char *p = format;
char ch;
@@ -228,6 +228,7 @@ int vsscanf(const char *buffer, size_t n, const char *format, va_list ap)
bail = bail_err;
break;
}
+ q = qq;
converted++;
/* fall through */
@@ -305,6 +306,7 @@ int vsscanf(const char *buffer, size_t n, const char *format, va_list ap)
break;
}
}
+ break;
case st_match_init: /* Initial state for %[ match */
if ( ch == '^' && !(flags & FL_INV) ) {