how sys_select, sys_fork, ... are defined for thread libraries?

Jin Guojun jin at george.lbl.gov
Thu Aug 2 14:26:50 PDT 2007


I am trying to understand how these __sys_xxx functions are defined for 
thread libraries.
Following string search tells that all thread libraries are using these 
__sys_xxx functions,
for example, __sys_select(). However, the search also shows that these 
functions are not defined anywhere in the entire source tree.

 /usr/src: findstring sys_select "*.[hcS]"
total files= 21687 : pattern= sys_select rootdir= /usr/src
regular mode: Thu Aug 2 13:31:40 PDT 2007
./lib/libc_r/uthread/uthread_fork.c
91:              * __sys_select:

./lib/libpthread/thread/thr_private.h
1264:int     __sys_select(int, fd_set *, fd_set *, fd_set *, struct 
timeval *);

./lib/libpthread/thread/thr_select.c
61:             ret = __sys_select(numfds, readfds, writefds, exceptfds, 
timeout);

./lib/libthr/thread/thr_private.h
805:int     __sys_select(int, fd_set *, fd_set *, fd_set *, struct 
timeval *);

./lib/libthr/thread/thr_syscalls.c
435:    ret = __sys_select(numfds, readfds, writefds, exceptfds, timeout);


By searching the usr/lib objects, I found them in libc, but they are not 
in libc source tree.
Can someone shed some light on how these system calls are built into 
libc and what is the
different between standard syscall APIs and these __sys_syscall APIs,
e.g., __sys_read() vs. read(), etc.

Thanks,

-Jin


 nm /usr/lib/libc.a | grep __sys_
00000008 T __sys_sigreturn
00000008 T __sys_setlogin
00000008 T __sys_reboot
... snapped
00000008 T __sys_kse_release
00000008 T __sys_kse_thr_interrupt
00000008 T __sys_kse_create
00000008 T __sys_kse_wakeup
... skipped
00000008 T __sys_getdtablesize
00000008 T __sys_select
00000008 T __sys_ioctl
00000008 T __sys_close
00000008 T __sys_write
00000008 T __sys_read
00000008 T __sys___syscall



More information about the freebsd-questions mailing list