[PATCH] Update to version 117 of klibc (from version 108)

This commit is contained in:
greg@kroah.com 2004-05-20 23:14:08 -07:00 committed by Greg KH
parent 3c60abb55a
commit 73028bc332
22 changed files with 233 additions and 28 deletions

View File

@ -25,9 +25,14 @@ HOST_CFLAGS = -g -O
HOST_LDFLAGS =
HOST_LIBS =
CRT0 = $(KLIBSRC)/crt0.o
KLIBC = $(KLIBSRC)/libc.a
LIBGCC = $(shell $(CC) --print-libgcc)
# Static library paths
CRT0 = $(KLIBSRC)/crt0.o
KLIBC = $(KLIBSRC)/libc.a
LIBGCC = $(shell $(CC) --print-libgcc)
# Shared library paths
CRTSHARED = $(KLIBSRC)/interp.o
LIBSHARED = $(KLIBSRC)/libc.so
#
# This indicates the location of the final version of the shared library.

View File

@ -5,6 +5,10 @@
.SUFFIXES: .c .o .a .so .lo .i .S .s .ls .ss .lss
% : %.c # Cancel default rule
% : %.S
.c.o:
$(CC) $(CFLAGS) -c -o $@ $<

View File

@ -17,7 +17,8 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \
strtoimax.o strtoumax.o \
globals.o exitc.o atexit.o onexit.o \
execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o \
fork.o wait.o wait3.o waitpid.o system.o setpgrp.o \
fork.o wait.o wait3.o waitpid.o system.o setpgrp.o getpgrp.o \
open.o \
printf.o vprintf.o fprintf.o vfprintf.o perror.o \
fopen.o fread.o fread2.o fgetc.o fgets.o \
fwrite.o fwrite2.o fputc.o fputs.o puts.o \
@ -35,7 +36,7 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \
seteuid.o setegid.o setresuid.o setresgid.o \
getenv.o setenv.o putenv.o __put_env.o unsetenv.o \
getopt.o readdir.o \
syslog.o closelog.o pty.o isatty.o reboot.o \
syslog.o closelog.o pty.o getpt.o isatty.o reboot.o \
time.o utime.o fdatasync.o llseek.o select.o nice.o getpriority.o \
qsort.o lrand48.o srand48.o seed48.o \
inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \

View File

@ -36,9 +36,9 @@ b) If you're cross-compiling, change ARCH in the main MCONFIG file to
Known to work: alpha arm ia64 i386 ppc s390 s390x sparc
sparc64 x86_64*
Works static, not shared: mips* arm-thumb sh*
Works static, not shared: mips* arm-thumb sh* parisc
Might work: ppc64
Need porting work: cris m68k mips64 parisc
Need porting work: cris m68k mips64 v850
x86_64: requires a kernel header patch (to be created)
mips, sh: linker problem; might work with fixed linker

View File

@ -19,7 +19,6 @@ int setpgid(pid_t, pid_t)
pid_t getpgid(pid_t)
<!alpha> pid_t getppid()
<alpha> pid_t getxpid@dual1::getppid()
<!ia64> pid_t getpgrp()
pid_t setsid()
pid_t getsid(pid_t)
pid_t wait4(pid_t, int *, int, struct rusage *)
@ -92,7 +91,6 @@ int lchown(const char *, uid_t, gid_t)
#
ssize_t read(int, void *, size_t)
ssize_t write(int, const void *, size_t)
int open(const char *, int, mode_t)
int close(int)
off_t lseek(int, off_t, int)
int dup(int)
@ -145,6 +143,7 @@ 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)
int sysinfo(struct sysinfo *)
#
# Low-level I/O (generally architecture-specific)

View File

@ -36,5 +36,3 @@ __noreturn __libc_init(uintptr_t *elfdata, void (*onexit)(void))
environ = envp;
exit(main(argc, argv, envp));
}

View File

@ -7,17 +7,16 @@
# accordingly.
#
# Comment this out to compile with register parameter passing
# This doesn't work right now because gcc 3.2 (at least) calls
# libgcc with the default calling convention instead of forcing
# them to be cdecl
# REGPARM = -mregparm=3 -DREGPARM
# Enable this to compile with register parameters; only safe for
# gcc > 3
REGPARM_OPT := -mregparm=3 -DREGPARM
gcc_major := $(shell $(CC) -v 2>&1 | awk '/gcc version/{print int($$3)}')
OPTFLAGS = $(REGPARM) -march=i386 -Os
ifeq ($(gcc_major),3)
REGPARM := $(REGPARM_OPT)
OPTFLAGS += -falign-functions=0 -falign-jumps=0 -falign-loops=0
else
OPTFLAGS += -malign-functions=0 -malign-jumps=0 -malign-loops=0

View File

@ -26,7 +26,6 @@ _start:
#endif
call __libc_init
# If __libc_init returns, problem...
ud2
hlt
.size _start, .-_start

View File

@ -7,4 +7,9 @@
# accordingly.
#
ARCHOBJS = \
arch/$(ARCH)/setjmp.o
ARCHOOBJS = $(patsubst %o,%.lo,%(ARCHOBJS))
archclean:

View File

@ -0,0 +1,34 @@
.align 4
.import $global$, data
.import __libc_init, code
.global _start
.export _start, ENTRY
.type _start,@function
.proc
.callinfo
_start:
/* extend the stack by 64-bytes */
ldo 64(%sp), %sp
/* %r25 = argc
* %r24 = argv
* envp = argv + (argc + 1)
* elfdata = (argv - 4)
*/
ldo -4(%r24), %r26
/* load global data */
ldil L%$global$, %dp
ldo R%$global$(%dp), %dp
/* branch to __libc_init */
bl __libc_init,%r2
nop
/* break miserably if we ever return */
iitlbp %r0,(%r0) /* illegal instruction */
nop
.procend

View File

@ -8,6 +8,17 @@
#ifndef _KLIBC_ARCHSIGNAL_H
#define _KLIBC_ARCHSIGNAL_H
/* No special stuff for this architecture */
#define _NSIG 64
#define _NSIG_SZ (_NSIG / LONG_BIT)
typedef struct {
unsigned long sig[_NSIG_SZ];
} sigset_t;
struct sigaction {
__sighandler_t sa_handler;
unsigned long sa_flags;
sigset_t sa_mask;
};
#endif

View File

@ -0,0 +1,88 @@
/*
* parisc specific setjmp/longjmp routines
*
*/
.text
.align 4
.global setjmp
.export setjmp, code
.proc
.callinfo
setjmp:
stw %r3,0(%r26)
stw %r4,8(%r26)
stw %r5,12(%r26)
stw %r6,16(%r26)
stw %r7,20(%r26)
stw %r8,24(%r26)
stw %r9,28(%r26)
stw %r10,32(%r26)
stw %r11,36(%r26)
stw %r12,40(%r26)
stw %r13,44(%r26)
stw %r14,48(%r26)
stw %r15,52(%r26)
stw %r16,56(%r26)
stw %r17,60(%r26)
stw %r18,64(%r26)
stw %r19,68(%r26)
stw %dp,72(%r26)
stw %r30,76(%r26)
stw %rp,80(%r26)
ldo 88(%r26),%r19
fstd,ma %fr12,8(%r19)
fstd,ma %fr13,8(%r19)
fstd,ma %fr14,8(%r19)
fstd,ma %fr15,8(%r19)
fstd,ma %fr16,8(%r19)
fstd,ma %fr17,8(%r19)
fstd,ma %fr18,8(%r19)
fstd,ma %fr19,8(%r19)
fstd,ma %fr20,8(%r19)
fstd %fr21,0(%r19)
bv %r0(%rp)
copy %r0,%r28
.procend
.text
.align 4
.global longjmp
.export longjmp, code
.proc
.callinfo
longjmp:
ldw 0(%r26),%r3
ldw 8(%r26),%r4
ldw 12(%r26),%r5
ldw 16(%r26),%r6
ldw 20(%r26),%r7
ldw 24(%r26),%r8
ldw 28(%r26),%r9
ldw 32(%r26),%r10
ldw 36(%r26),%r11
ldw 40(%r26),%r12
ldw 44(%r26),%r13
ldw 48(%r26),%r14
ldw 52(%r26),%r15
ldw 56(%r26),%r16
ldw 60(%r26),%r17
ldw 64(%r26),%r18
ldw 68(%r26),%r19
ldw 72(%r26),%r27
ldw 76(%r26),%r30
ldw 80(%r26),%rp
ldo 88(%r26),%r20
fldd,ma 8(%r20),%fr12
fldd,ma 8(%r20),%fr13
fldd,ma 8(%r20),%fr14
fldd,ma 8(%r20),%fr15
fldd,ma 8(%r20),%fr16
fldd,ma 8(%r20),%fr17
fldd,ma 8(%r20),%fr18
fldd,ma 8(%r20),%fr19
fldd,ma 8(%r20),%fr20
fldd 0(%r20),%fr21
bv %r0(%rp)
copy %r25,%r28
.procend

9
klibc/klibc/getpgrp.c Normal file
View File

@ -0,0 +1,9 @@
/*
* getpgrp.c
*/
#include <unistd.h>
pid_t getpgrp(void) {
return getpgid(0);
}

17
klibc/klibc/getpt.c Normal file
View File

@ -0,0 +1,17 @@
/*
* getpt.c
*
* GNU extension to the standard Unix98 pty suite
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
#include <sys/ioctl.h>
int getpt(void)
{
return open("/dev/ptmx", O_RDWR|O_NOCTTY);
}

View File

@ -8,12 +8,16 @@
#define _KLIBC_COMPILER_H
/* Specific calling conventions */
/* __cdecl is used when we want varadic and non-varadic functions to have
the same binary calling convention. */
#ifdef __i386__
# ifdef __GNUC__
# define __cdecl __attribute__((cdecl,regparm(0)))
# else
/* Most other C compilers have __cdecl as a keyword */
# endif
#else
# define __cdecl /* Meaningless on non-i386 */
#endif
/* How to declare a function that *must* be inlined */

View File

@ -83,12 +83,14 @@ static __inline__ void srandom(unsigned int __s)
/* Basic PTY functions. These only work if devpts is mounted! */
__extern int unlockpt(int);
__extern char *ptsname(int);
__extern int getpt(void);
static __inline__ int grantpt(int __fd)
{
(void)__fd;
return 0; /* devpts does this all for us! */
}
__extern int unlockpt(int);
__extern char *ptsname(int);
#endif /* _STDLIB_H */

View File

@ -0,0 +1,12 @@
/*
* sys/sysinfo.h
*/
#ifndef _SYS_SYSINFO_H
#define _SYS_SYSINFO_H
#include <linux/kernel.h>
extern int sysinfo (struct sysinfo *info);
#endif /* _SYS_SYSINFO_H */

View File

@ -1,10 +1,10 @@
/*
* sys/un.h
* <sys/un.h>
*/
#ifndef _UN_H
#define _UN_H
#ifndef _SYS_UN_H
#define _SYS_UN_H
#include <linux/un.h>
#endif /* _UN_H */
#endif /* _SYS_UN_H */

View File

@ -17,6 +17,7 @@ __extern __noreturn _exit(int);
__extern pid_t fork(void);
__extern pid_t vfork(void);
__extern pid_t getpid(void);
__extern pid_t getpgid(pid_t);
__extern int setpgid(pid_t, pid_t);
__extern pid_t getppid(void);
__extern pid_t getpgrp(void);
@ -76,8 +77,8 @@ __extern int sync(void);
__extern ssize_t read(int, void *, size_t);
__extern ssize_t write(int, const void *, size_t);
#ifndef __IN_SYS_COMMON
__extern int open(const char *, int, ...);
#ifndef __IN_OPEN_C
__extern __cdecl int open(const char *, int, ...);
#endif
__extern int close(int);
__extern off_t lseek(int, off_t, int);

17
klibc/klibc/open.c Normal file
View File

@ -0,0 +1,17 @@
/*
* open.c
*
* The open syscall is weird, because it's defined as a varadic
* function, but implementing it as such generally sucks for
* performance. Thus we generate it as a 3-argument function,
* but with explicit __cdecl assuming the __cdecl convention is
* independent of being varadic.
*/
#define __IN_OPEN_C
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/syscall.h>
__cdecl _syscall3(int,open,const char *,file,int,flags,mode_t,mode)

View File

@ -1,7 +1,7 @@
/*
* pty.c
*
* Basic Unix98 PTY functionality; assumes devpts
* Basic Unix98 PTY functionality; assumes devpts mounted on /dev/pts
*/
#include <stdio.h>

View File

@ -1 +1 @@
0.108
0.117