This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: RFC: Add getcpu wrapper
- From: Florian Weimer <fweimer at redhat dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 05 Dec 2018 16:48:43 +0100
- Subject: Re: RFC: Add getcpu wrapper
- References: <CAMe9rOpcy16tREX8Gb0qYPXXc__Vzykj2c=M20aBOn4p0gUBGw@mail.gmail.com> <87pnuggf5z.fsf@oldenburg2.str.redhat.com> <CAMe9rOqEeSY7H-MQybk=wuR4aK4juTNj5dGK1CvjYkxExYOAuw@mail.gmail.com>
* H. J. Lu:
> 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
> }
Ah, so you want to pass a non-null second argument to getcpu?
I think we can expose getcpu (with two arguments), under that name. Add
it to <sched.h> or <unistd.h>; I do not have a strong preference.
Thanks,
Florian