[PATCH] Cygwin: Implement CPU_SET(3) macros
Corinna Vinschen
corinna-cygwin@cygwin.com
Mon Jul 1 07:34:00 GMT 2019
Hi Mark,
On Jun 30 15:59, Mark Geisert wrote:
> This patch supplies an implementation of the CPU_SET(3) processor
> affinity macros as documented on the relevant Linux man page.
> ---
> winsup/cygwin/include/sys/cpuset.h | 62 +++++++++++++++++++++++++++---
> winsup/cygwin/sched.cc | 8 ++--
> 2 files changed, 60 insertions(+), 10 deletions(-)
>
> diff --git a/winsup/cygwin/include/sys/cpuset.h b/winsup/cygwin/include/sys/cpuset.h
> index 4857b879d..9c8417b73 100644
> --- a/winsup/cygwin/include/sys/cpuset.h
> +++ b/winsup/cygwin/include/sys/cpuset.h
> @@ -14,20 +14,70 @@ extern "C" {
> #endif
>
> typedef __SIZE_TYPE__ __cpu_mask;
> -#define __CPU_SETSIZE 1024 // maximum number of logical processors tracked
> -#define __NCPUBITS (8 * sizeof (__cpu_mask)) // max size of processor group
> -#define __CPU_GROUPMAX (__CPU_SETSIZE / __NCPUBITS) // maximum group number
> +#define CPU_SETSIZE 1024 // maximum number of logical processors tracked
> +#define NCPUBITS (8 * sizeof (__cpu_mask)) // max size of processor group
> +#define CPU_GROUPMAX (CPU_SETSIZE / NCPUBITS) // maximum group number
>
> -#define __CPUELT(cpu) ((cpu) / __NCPUBITS)
> -#define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS))
> +#define CPU_WORD(cpu) ((cpu) / NCPUBITS)
> +#define CPU_MASK(cpu) ((__cpu_mask) 1 << ((cpu) % NCPUBITS))
I wouldn't do that. Three problems:
- The non-underscored definitions should only be exposed #if __GNU_VISIBLE
because otherwise they clutter the application namespace.
- CPU_WORD and CPU_MASK don't exist at all in glibc, so I don't see
why you rename __CPUELT and __CPUMASK at all.
- CPU_GROUPMAX does not exist in glibc either. As a non-standard
macro it should be kept underscored.
Keep (and use) the underscored variations throughout, and only expose
the non-underscored macro set #if __GNU_VISIBLE.
There's also the request from Sebastian on the newlib list to
consolidate the cpuset stuff from RTEMS and Cygwin into a single
definition. It's not exactly straightforward given the different
definition of cpuset_t from FreeBSD, but it's probably not very
complicated either. Maybe something for after your vaca?
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20190701/3ff106d8/attachment.sig>
More information about the Cygwin-patches
mailing list