This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: RFC: Add getcpu wrapper
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 5 Dec 2018 07:40:12 -0800
- Subject: Re: RFC: Add getcpu wrapper
- References: <CAMe9rOpcy16tREX8Gb0qYPXXc__Vzykj2c=M20aBOn4p0gUBGw@mail.gmail.com> <87pnuggf5z.fsf@oldenburg2.str.redhat.com>
On Wed, Dec 5, 2018 at 7:35 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > returns such info. But syscall () is too slow. I'd like to add a wrapper to
> > glibc. Any comments?
>
> We already have it as sched_getcpu, I think.
>
We have
int
sched_getcpu (void)
{
#ifdef __NR_getcpu
unsigned int cpu;
int r = INLINE_VSYSCALL (getcpu, 3, &cpu, NULL, NULL);
^^^^^ I need the node info.
return r == -1 ? r : cpu;
#else
__set_errno (ENOSYS);
return -1;
#endif
}
--
H.J.