public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Konstantin Kharlamov <hi-angel@yandex.ru>
To: Peng Yu <pengyu.ut@gmail.com>, Florian Weimer <fweimer@redhat.com>
Cc: Peng Yu via Libc-help <libc-help@sourceware.org>
Subject: Re: Where is setsockopt() defined?
Date: Wed, 03 Mar 2021 09:40:15 +0300	[thread overview]
Message-ID: <b4aa778d3acb5c5e89ab136d4c30f343f3aec392.camel@yandex.ru> (raw)
In-Reply-To: <CABrM6wm3k8XRnWBCLvGNp8FfseF1QG=yEBkksDURRh4k8GiuHQ@mail.gmail.com>

On Wed, 2021-03-03 at 00:14 -0600, Peng Yu via Libc-help wrote:
> > It's in sysdeps/unix/sysv/linux/setsockopt.c.
> 
> https://github.com/bminor/glibc/blob/21c3f4b5368686ade28d90d8c7d79c4c95c72c1b/sysdeps/unix/sysv/linux/setsockopt.c
> 
> There is not much code in this file. Based on the manpage of
> setsockopt() (which refers to socket(7)), setsockopt() should be able
> to process many different cases. So I'd expect many branch statements.
> Where are they defined?
> 
> Things like INLINE_SYSCALL and SOCKETCALL are too complicated to
> comprehend. How to understand what they do?
> 
> https://github.com/bminor/glibc/blob/21c3f4b5368686ade28d90d8c7d79c4c95c72c1b/sysdeps/unix/sysv/linux/sysdep.h#L42
> https://github.com/bminor/glibc/blob/83908b3a1ea51e3aa7ff422275940e56dbba989f/sysdeps/unix/sysv/linux/socketcall.h#L85


(disclaimer: I'm not a glibc dev)

The INLINE_SYSCALL as it name says is apparently syscall. A syscall simply places its arguments into registers/stack as defined by the architecture and calls into kernel.

The SOCKETCALL version indeed looks involved, but as far I as see it just basically chooses between __SOCKETCALL1..__SOCKETCALL6 macroses based on the number of arguments. And all 6 of those, in turn, are a wrapper around INLINE_SYSCALL.

So, all roads lead to Rome aka kernel.


      reply	other threads:[~2021-03-03  6:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02 20:52 Peng Yu
2021-03-02 21:30 ` Florian Weimer
2021-03-03  6:14   ` Peng Yu
2021-03-03  6:40     ` Konstantin Kharlamov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4aa778d3acb5c5e89ab136d4c30f343f3aec392.camel@yandex.ru \
    --to=hi-angel@yandex.ru \
    --cc=fweimer@redhat.com \
    --cc=libc-help@sourceware.org \
    --cc=pengyu.ut@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).