The HyperNews Linux KHG Discussion Pages
Next-in-Thread Next Message Previous Message Next Thread

Feedback: the solution to the problem

Forum: How System Calls Work on Linux/i86
Re: Feedback the directory /usr/src/libc/syscall/ (vijay gupta)
Re: Note ...no longer exists. (Michael K. Johnson)
Keywords: system call libc
Date: Tue, 21 May 1996 23:05:39 GMT
From: Vijay Gupta <vijay@crhc.uiuc.edu>

Hi everybody,

       Thanks to the two people who replied to me on 
this. The solution to the problem is as follows :

the khg seems to be wrong in assuming there was a directory syscall in the C library. Instead, there is a directory sysdeps/linux, which contains, among others, socketpair.c, which defines the function

int
socketpair(int family, int type, int protocol, int sockvec[2])
{
    unsigned long args[4];

    args[0] = family;
    args[1] = type;
    args[2] = protocol;
    args[3] = (unsigned long)sockvec;
    return socketcall(SYS_SOCKETPAIR, args);
}

If you look at /usr/src/linux/net/socket.c, you will find a good match with that code. The socketcall function then is not defined by a C macro, but by an assembler macro in __socketcall.S:

SYSCALL__ (socketcall, 2)
    ret
Please note that the socket system calls are special because of that level
of indirection. The wait(2) function is declared as

#ifdef __SVR4_I386_ABI_L1__
#define wait4   __wait4
#else
static inline
_syscall4(__pid_t,wait4,__pid_t,pid,__WAIT_STATUS_DEFN,status,int,options,struc
t
 rusage *,ru)
#endif

__pid_t
__wait(__WAIT_STATUS_DEFN wait_stat)
{
    return wait4(WAIT_ANY, wait_stat, 0, NULL);
}

(so it is actually wait(3) in Linux, with wait4(2) being the system call).

------------------------

Thanks again,
       Vijay

Next-in-Thread Next Message Previous Message Next Thread

to: "the solution to the problem "

Subscribe Membership Move/Remove Admin Mode Show Frames Help for HyperNews 1.9.4