Where is the glibc socket implementation?

In glibc 2.22, the directory /socketcontains the socket library implementation.
However, when opening any of these files, all I see is the error setting function with some macros under it.
Here is an example file ( /socket/send.c):

#include <errno.h>
#include <sys/socket.h>

/* Send N bytes of BUF to socket FD.  Returns the number sent or -1.  */
ssize_t
__send (fd, buf, n, flags)
     int fd;
     const __ptr_t buf;
     size_t n;
     int flags;
{
  __set_errno (ENOSYS);
  return -1;
}
libc_hidden_def (__send)
weak_alias (__send, send)

stub_warning (send)

(Comment with remote license.)

Where does this sendmacro weak_aliashave an argument? Where are these macros defined?
I think this is due to compatibility with some kind of crappy old compiler, but why do they still use the K & R syntax?
And most importantly, why is it __send defined like this?

+4
source share
2 answers

.

-, , glibc , C , C . , , , __send(). send() , - .

-, glibc, glibc , - . , , , "", errno ENOSYS ( ) . , . send() , , - , . , (t2) , , /sysdeps/unix/sysv/linux/x86_64/send.c glibc.

, send() - , , glibc, - , . , , .

+5

, send, bind socket, , , . unix, man 2 socket man 3 fopen. - , - . glibc , glibc.

__send weak_alias, , glibc send __send, , send , glibc __send. ENOSYS , . , .

sysdeps . , sysdeps/unix/sysv/linux/x86_64/syscalls.list, C OS . syscall.S , , syscalls. , , syscalls, libc , syscall , syscall. .

+3

Source: https://habr.com/ru/post/1622030/


All Articles