[PATCH] Add getcpu

H.J. Lu hjl.tools@gmail.com
Wed Dec 5 19:51:00 GMT 2018


On Wed, Dec 5, 2018 at 10:48 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > +extern int __getcpu (unsigned *, unsigned *) __THROW;
>
> “unsigned int”; perhaps  use __typeof__ (getcpu)?

Fixed.

> > diff --git a/sysdeps/unix/sysv/linux/bits/sched.h b/sysdeps/unix/sysv/linux/bits/sched.h
> > index 34f27a7d9b..ea5d51a80d 100644
> > --- a/sysdeps/unix/sysv/linux/bits/sched.h
> > +++ b/sysdeps/unix/sysv/linux/bits/sched.h
> > @@ -86,6 +86,9 @@ extern int unshare (int __flags) __THROW;
> >  /* Get index of currently used CPU.  */
> >  extern int sched_getcpu (void) __THROW;
> >
> > +/* Get currently used CPU and NUMA node.  */
> > +extern int getcpu (unsigned int *, unsigned int *) __THROW;
>
> Can either pointer be NULL?

Yes.  Either pointer can be NULL.

> > +__getcpu (unsigned *cpu, unsigned *node)
>
> “unsigned int”.

Fixed.

> > --- /dev/null
> > +++ b/sysdeps/unix/sysv/linux/tst-affinity-getcpu.c
> > @@ -0,0 +1,292 @@
> > +/* Test case for CPU affinity functions with getcpu.
> > +   Copyright (C) 2018 Free Software Foundation, Inc.
>
> I think this is a copy of another test, right?
>
> Maybe we should move bits of it to support/?

I updated the patch with a very simple test.

> We have a parallel discussion about a new requirement that all new
> functions must have documentation in the manual.  I don't know what will
> come out of that.

Here is the updated patch.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-getcpu.patch
Type: text/x-patch
Size: 23430 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20181205/c62a7a0a/attachment.bin>


More information about the Libc-alpha mailing list