Clean up syscall generation in libc by removing HIDDEN_SYSCALLS

and treating (almost) all system calls the same way:

	__sys_foo - actual syscall
	foo, _foo - weak definitions to __sys_foo

Change PSEUDO syscalls (currently only _exit and _getlogin) to
be __sys_foo (T) and _foo (W).

Add $FreeBSD$ to a few files to satisfy commitprep.

Suggested by:	bde
This commit is contained in:
deischen 2001-01-29 03:23:46 +00:00
parent 99d951b840
commit ca55abf319
24 changed files with 80 additions and 255 deletions

View File

@ -15,24 +15,6 @@ CLEANFILES+=tags
INSTALL_PIC_ARCHIVE= yes
PRECIOUSLIB= yes
#
# This is a list of syscalls that are renamed as __sys_{syscall}
# so that libpthread and libc_r can override and/or replace them.
# In the case of libc_r replacement functions are provided, whereas
# libpthread can both override and provide replacement functions.
#
HIDDEN_SYSCALLS= _exit.o accept.o aio_suspend.o bind.o close.o connect.o \
dup.o dup2.o execve.o fchflags.o fchmod.o fchown.o fcntl.o \
flock.o fpathconf.o fstat.o fstatfs.o fsync.o getdirentries.o \
getpeername.o getsockname.o getsockopt.o ioctl.o \
kevent.o listen.o \
msync.o nanosleep.o nfssvc.o open.o poll.o read.o readv.o recvfrom.o \
recvmsg.o sched_yield.o select.o sendfile.o sendmsg.o sendto.o \
setsockopt.o shutdown.o sigaction.o sigaltstack.o \
sigpending.o sigprocmask.o sigreturn.o \
sigsuspend.o socket.o \
socketpair.o wait4.o write.o writev.o
#
# Include make rules that are shared with libc_r.
#

View File

@ -46,78 +46,32 @@ LLABEL(name,1):
#define SYSCALL(name) \
LEAF(__CONCAT(_,name),0); /* XXX # of args? */ \
WEAK_ALIAS(name, __CONCAT(_,name)); \
LEAF(__CONCAT(__sys_,name),0); /* XXX # of args? */ \
WEAK_ALIAS(name, __CONCAT(__sys_,name)); \
WEAK_ALIAS(__CONCAT(_,name), __CONCAT(__sys_,name)); \
CALLSYS_ERROR(name)
#define SYSCALL_NOERROR(name) \
LEAF(name,0); /* XXX # of args? */ \
LEAF(__CONCAT(__sys_,name),0); /* XXX # of args? */ \
WEAK_ALIAS(name, __CONCAT(__sys_,name)); \
WEAK_ALIAS(__CONCAT(_,name), __CONCAT(__sys_,name)); \
CALLSYS_NOERROR(name)
#define RSYSCALL(name) \
SYSCALL(name); \
RET; \
END(__CONCAT(_,name))
END(__CONCAT(__sys_,name))
#define RSYSCALL_NOERROR(name) \
SYSCALL_NOERROR(name); \
RET; \
END(name)
END(__CONCAT(__sys_,name))
#define PSEUDO(label,name) \
LEAF(__CONCAT(_,label),0); /* XXX # of args? */ \
WEAK_ALIAS(label, __CONCAT(_,label)); \
#define PSEUDO(name) \
LEAF(__CONCAT(__sys_,name),0); /* XXX # of args? */ \
WEAK_ALIAS(__CONCAT(_,name), __CONCAT(__sys_, name)); \
CALLSYS_ERROR(name); \
RET; \
END(__CONCAT(_,label));
#define PSEUDO_NOERROR(label,name) \
LEAF(label,0); /* XXX # of args? */ \
CALLSYS_NOERROR(name); \
RET; \
END(label);
/*
* Design note:
*
* The macros PSYSCALL() and PRSYSCALL() are intended for use where a
* syscall needs to be renamed in the threaded library.
*/
/*
* For the thread_safe versions, we prepend __sys_ to the function
* name so that the 'C' wrapper can go around the real name.
*/
#define PNAME(name) __CONCAT(__sys_,name)
#define PCALL(name) \
CALL(PNAME(name))
#define PLEAF(name, args) \
LEAF(PNAME(name),args)
#define PEND(name) \
END(PNAME(name))
#define PSYSCALL(name) \
PLEAF(name,0); /* XXX # of args? */ \
WEAK_ALIAS(name, PNAME(name)); \
WEAK_ALIAS(__CONCAT(_,name), PNAME(name)); \
CALLSYS_ERROR(name)
#define PRSYSCALL(name) \
PLEAF(name,0); /* XXX # of args? */ \
WEAK_ALIAS(name, PNAME(name)); \
WEAK_ALIAS(__CONCAT(_,name), PNAME(name)); \
CALLSYS_ERROR(name) \
RET; \
PEND(name)
#define PPSEUDO(label,name) \
PLEAF(label,0); /* XXX # of args? */ \
WEAK_ALIAS(label, PNAME(label)); \
WEAK_ALIAS(__CONCAT(_,label), PNAME(label)); \
CALLSYS_ERROR(name); \
RET; \
PEND(label)
END(__CONCAT(__sys_,name))

View File

@ -10,8 +10,5 @@ NOASM= __semctl.o break.o exit.o ftruncate.o getdomainname.o getlogin.o \
semop.o setdomainname.o shmat.o shmctl.o shmdt.o shmget.o sstk.o \
truncate.o uname.o vfork.o yield.o
PSEUDO= _getlogin.o
PSEUDO= _getlogin.o _exit.o
# Pseudo syscalls that are renamed as __sys_{pseudo} so that libc_r
# can override them with replacements.
PSEUDOR= _exit.o

View File

@ -25,11 +25,13 @@
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
* $FreeBSD$
*/
#include "SYS.h"
PSYSCALL(vfork)
SYSCALL(vfork)
cmovne a4, zero, v0 /* a4 (rv[1]) != 0, child */
RET
PEND(vfork)
END(vfork)

View File

@ -25,11 +25,13 @@
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
* $FreeBSD$
*/
#include "SYS.h"
PSYSCALL(fork)
SYSCALL(fork)
cmovne a4, zero, v0 /* a4 (rv[1]) != 0, child */
RET
PEND(fork)
END(fork)

View File

@ -25,13 +25,15 @@
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
* $FreeBSD$
*/
#include "SYS.h"
PSYSCALL(pipe)
SYSCALL(pipe)
stl v0, 0(a0)
stl a4, 4(a0)
mov zero, v0
RET
PEND(pipe)
END(pipe)

View File

@ -25,6 +25,8 @@
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
* $FreeBSD$
*/
#include "SYS.h"
@ -35,4 +37,4 @@
* (XXX PROFILING)
*/
PRSYSCALL(sigreturn)
RSYSCALL(sigreturn)

View File

@ -42,32 +42,6 @@
#include "DEFS.h"
#define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
ENTRY(__CONCAT(_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(_,x)); \
lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
#define RSYSCALL(x) SYSCALL(x); ret
#define PSEUDO(x,y) ENTRY(__CONCAT(_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(_,x)); \
lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
/* gas messes up offset -- although we don't currently need it, do for BCS */
#define LCALL(x,y) .byte 0x9a ; .long y; .word x
/*
* Design note:
*
* The macros PSYSCALL() and PRSYSCALL() are intended for use where a
* syscall needs to be renamed in the threaded library.
*/
/*
* For the thread_safe versions, we prepend __sys_ to the function
* name so that the 'C' wrapper can go around the real name.
*/
#define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
ENTRY(__CONCAT(__sys_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(__sys_,x)); \
@ -75,14 +49,15 @@
.set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
#define PRSYSCALL(x) PSYSCALL(x); ret
#define RSYSCALL(x) SYSCALL(x); ret
#define PPSEUDO(x,y) ENTRY(__CONCAT(__sys_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(__sys_,x)); \
#define PSEUDO(x) ENTRY(__CONCAT(__sys_,x)); \
.weak CNAME(__CONCAT(_,x)); \
.set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
lea __CONCAT(SYS_,x), %eax; KERNCALL; ret
/* gas messes up offset -- although we don't currently need it, do for BCS */
#define LCALL(x,y) .byte 0x9a ; .long y; .word x
#ifdef __ELF__
#define KERNCALL int $0x80 /* Faster */

View File

@ -14,11 +14,7 @@ NOASM= __semctl.o break.o exit.o ftruncate.o getdomainname.o getlogin.o \
semop.o setdomainname.o shmat.o shmctl.o shmdt.o shmget.o sstk.o \
truncate.o uname.o vfork.o yield.o
PSEUDO= _getlogin.o
# Pseudo syscalls that are renamed as __sys_{pseudo} so that libc_r can
# override them with replacements.
PSEUDOR= _exit.o
PSEUDO= _getlogin.o _exit.o
.if ${LIB} == "c"
MAN2+= i386_get_ioperm.2 i386_get_ldt.2 i386_vm86.2

View File

@ -43,7 +43,7 @@
#include "SYS.h"
PSYSCALL(pipe)
SYSCALL(pipe)
movl 4(%esp),%ecx
movl %eax,(%ecx)
movl %edx,4(%ecx)

View File

@ -48,5 +48,5 @@
* must be saved. On FreeBSD, this is not the case.
*/
PSYSCALL(sigreturn)
SYSCALL(sigreturn)
ret

View File

@ -42,32 +42,6 @@
#include "DEFS.h"
#define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
ENTRY(__CONCAT(_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(_,x)); \
lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
#define RSYSCALL(x) SYSCALL(x); ret
#define PSEUDO(x,y) ENTRY(__CONCAT(_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(_,x)); \
lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
/* gas messes up offset -- although we don't currently need it, do for BCS */
#define LCALL(x,y) .byte 0x9a ; .long y; .word x
/*
* Design note:
*
* The macros PSYSCALL() and PRSYSCALL() are intended for use where a
* syscall needs to be renamed in the threaded library.
*/
/*
* For the thread_safe versions, we prepend __sys_ to the function
* name so that the 'C' wrapper can go around the real name.
*/
#define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
ENTRY(__CONCAT(__sys_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(__sys_,x)); \
@ -75,14 +49,15 @@
.set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
#define PRSYSCALL(x) PSYSCALL(x); ret
#define RSYSCALL(x) SYSCALL(x); ret
#define PPSEUDO(x,y) ENTRY(__CONCAT(__sys_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(__sys_,x)); \
#define PSEUDO(x) ENTRY(__CONCAT(__sys_,x)); \
.weak CNAME(__CONCAT(_,x)); \
.set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
lea __CONCAT(SYS_,x), %eax; KERNCALL; ret
/* gas messes up offset -- although we don't currently need it, do for BCS */
#define LCALL(x,y) .byte 0x9a ; .long y; .word x
#ifdef __ELF__
#define KERNCALL int $0x80 /* Faster */

View File

@ -14,11 +14,7 @@ NOASM= __semctl.o break.o exit.o ftruncate.o getdomainname.o getlogin.o \
semop.o setdomainname.o shmat.o shmctl.o shmdt.o shmget.o sstk.o \
truncate.o uname.o vfork.o yield.o
PSEUDO= _getlogin.o
# Pseudo syscalls that are renamed as __sys_{pseudo} so that libc_r can
# override them with replacements.
PSEUDOR= _exit.o
PSEUDO= _getlogin.o _exit.o
.if ${LIB} == "c"
MAN2+= i386_get_ioperm.2 i386_get_ldt.2 i386_vm86.2

View File

@ -43,7 +43,7 @@
#include "SYS.h"
PSYSCALL(fork)
SYSCALL(fork)
cmpl $0,%edx /* parent, since %edx == 0 in parent, 1 in child */
je 1f
movl $0,%eax

View File

@ -43,7 +43,7 @@
#include "SYS.h"
PSYSCALL(pipe)
SYSCALL(pipe)
movl 4(%esp),%ecx
movl %eax,(%ecx)
movl %edx,4(%ecx)

View File

@ -43,7 +43,7 @@
#include "SYS.h"
PSYSCALL(rfork)
SYSCALL(rfork)
cmpl $0,%edx /* parent, since %edx == 0 in parent, 1 in child */
je 1f
movl $0,%eax

View File

@ -48,5 +48,5 @@
* must be saved. On FreeBSD, this is not the case.
*/
PSYSCALL(sigreturn)
SYSCALL(sigreturn)
ret

View File

@ -38,72 +38,39 @@
#define SYSCALL(name) \
ENTRY(_ ## name,0); /* XXX # of args? */ \
WEAK_ALIAS(name, _ ## name); \
ENTRY(__sys_ ## name,0); /* XXX # of args? */ \
WEAK_ALIAS(name, __sys_ ## name); \
WEAK_ALIAS(_ ## name, __sys_ ## name); \
CALLSYS_ERROR(name)
#define SYSCALL_NOERROR(name) \
ENTRY(name,0); /* XXX # of args? */ \
ENTRY(__sys_ ## name,0); /* XXX # of args? */ \
WEAK_ALIAS(name, __sys_ ## name); \
WEAK_ALIAS(_ ## name, __sys_ ## name); \
CALLSYS_NOERROR(name)
#define RSYSCALL(name) \
SYSCALL(name); \
br.ret.sptk.few rp; \
END(_ ## name)
END(__sys_ ## name)
#define RSYSCALL_NOERROR(name) \
SYSCALL_NOERROR(name); \
br.ret.sptk.few rp; \
END(name)
#define PSEUDO(label,name) \
ENTRY(_ ## label,0); /* XXX # of args? */ \
WEAK_ALIAS(label, _ ## label); \
CALLSYS_ERROR(name); \
br.ret.sptk.few rp; \
END(_ ## label);
#define PSEUDO_NOERROR(label,name) \
ENTRY(label,0); /* XXX # of args? */ \
CALLSYS_NOERROR(name); \
br.ret.sptk.few rp; \
END(label);
/*
* Design note:
*
* The macros PSYSCALL() and PRSYSCALL() are intended for use where a
* syscall needs to be renamed in the threaded library.
*/
/*
* For the thread_safe versions, we prepend __sys_ to the function
* name so that the 'C' wrapper can go around the real name.
*/
#define PCALL(name) \
CALL(__sys_ ## name)
#define PENTRY(name, args) \
ENTRY(__sys_ ## name,args)
#define PEND(name) \
END(__sys_ ## name)
#define PSYSCALL(name) \
PENTRY(name,0); /* XXX # of args? */ \
CALLSYS_ERROR(name)
#define PRSYSCALL(name) \
PENTRY(_sys_ ## name,0); /* XXX # of args? */ \
WEAK_ALIAS(name, __sys_ ## name); \
#define PSEUDO(name) \
ENTRY(__sys_ ## name,0); /* XXX # of args? */ \
WEAK_ALIAS(_ ## name, __sys_ ## name); \
CALLSYS_ERROR(name) \
br.ret.sptk.few rp; \
PEND(name)
#define PPSEUDO(label,name) \
PENTRY(label,0); /* XXX # of args? */ \
CALLSYS_ERROR(name); \
br.ret.sptk.few rp; \
PEND(label)
END(__sys_ ## name);
#define PSEUDO_NOERROR(name) \
ENTRY(__sys_ ## name,0); /* XXX # of args? */ \
WEAK_ALIAS(_ ## name, __sys_ ## name); \
CALLSYS_NOERROR(name); \
br.ret.sptk.few rp; \
END(__sys_ ## name);

View File

@ -10,8 +10,4 @@ NOASM= __semctl.o break.o exit.o ftruncate.o getdomainname.o getlogin.o \
semop.o setdomainname.o shmat.o shmctl.o shmdt.o shmget.o sstk.o \
truncate.o uname.o vfork.o yield.o
PSEUDO= _getlogin.o
# Pseudo syscalls that are renamed as __sys_{pseudo} so that libc_r
# can override them with replacements.
PSEUDOR= _exit.o
PSEUDO= _getlogin.o _exit.o

View File

@ -27,9 +27,9 @@
*/
#include "SYS.h"
PSYSCALL(vfork)
SYSCALL(vfork)
cmp.ne p6,p0=ret1,r0 /* ret1!=0 for child */
;;
(p6) mov ret0=r0
br.ret.sptk.few rp
PEND(vfork)
END(vfork)

View File

@ -27,9 +27,9 @@
*/
#include "SYS.h"
PSYSCALL(fork)
SYSCALL(fork)
cmp.ne p6,p0=ret1,r0 /* ret1!=0 for child */
;;
(p6) mov ret0=r0
br.ret.sptk.few rp
PEND(fork)
END(fork)

View File

@ -30,10 +30,10 @@
#include "SYS.h"
PSYSCALL(pipe)
SYSCALL(pipe)
.regstk 1,0,0,0
st4 [in0]=ret0,4 ;;
st4 [in0]=ret1
mov ret0=0
br.ret.sptk.few rp
PEND(pipe)
END(pipe)

View File

@ -36,4 +36,4 @@
* (XXX PROFILING)
*/
PRSYSCALL(sigreturn)
RSYSCALL(sigreturn)

View File

@ -16,60 +16,39 @@
.include "${.CURDIR}/../libc/${MACHINE_ARCH}/sys/Makefile.inc"
# Sources common to both syscall interfaces:
SRCS+= ftruncate.c lseek.c mmap.c pread.c pwrite.c truncate.c
# Build __error() into libc, but not libc_r which has its own:
.if ${LIB} == "c"
SRCS+= __error.c
.endif
SRCS+= ftruncate.c lseek.c mmap.c pread.c pwrite.c truncate.c __error.c
# Add machine dependent asm sources:
SRCS+=${MDASM}
# Look though the complete list of syscalls (MIASM) for names that are
# not defined with machine dependent implementations (MDASM) and are
# not declared for no generation of default code (NOASM). If the
# syscall is not hidden, add it to the ASM list, otherwise add it
# to the ASMR list.
# not declared for no generation of default code (NOASM). Add each
# syscall that satisfies these conditions to the ASM list.
.for _asm in ${MIASM}
.if (${MDASM:R:M${_asm:R}} == "")
.if (${NOASM:R:M${_asm:R}} == "")
.if (${HIDDEN_SYSCALLS:R:M${_asm:R}} == "")
ASM+=$(_asm)
.else
ASMR+=$(_asm)
.endif
.endif
.endif
.endfor
OBJS+= ${ASM} ${ASMR} ${PSEUDO} ${PSEUDOR}
OBJS+= ${ASM} ${PSEUDO}
SASM= ${ASM:S/.o/.S/}
SASMR= ${ASMR:S/.o/.S/}
SPSEUDO= ${PSEUDO:S/.o/.S/}
SPSEUDOR= ${PSEUDOR:S/.o/.S/}
SRCS+= ${SASM} ${SASMR} ${SPSEUDO} ${SPSEUDOR}
SRCS+= ${SASM} ${SPSEUDO}
# Generated files
CLEANFILES+= ${SASM} ${SASMR} ${SPSEUDO} ${SPSEUDOR}
CLEANFILES+= ${SASM} ${SPSEUDO}
${SASM}:
printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' > ${.TARGET}
${SASMR}:
printf '#include "SYS.h"\nPRSYSCALL(${.PREFIX})\n' > ${.TARGET}
${SPSEUDO}:
printf '#include "SYS.h"\nPSEUDO(${.PREFIX},${.PREFIX:S/_//})\n' \
> ${.TARGET}
${SPSEUDOR}:
printf '#include "SYS.h"\nPPSEUDO(${.PREFIX},${.PREFIX:S/_//})\n' \
printf '#include "SYS.h"\nPSEUDO(${.PREFIX:S/_//})\n' \
> ${.TARGET}
.if ${LIB} == "c"