Cygwin: Implement sched_[gs]etaffinity() commit breaks RTEMS port

Corinna Vinschen vinschen@redhat.com
Wed Jun 26 13:12:00 GMT 2019


On Jun 26 13:05, Sebastian Huber wrote:
> On 26/06/2019 11:37, Corinna Vinschen wrote:
> > On Jun 26 10:24, Sebastian Huber wrote:
> > > Hello,
> > > 
> > > the following commit:
> > > 
> > > commit 641ecb07533e85211b6abce334c85967f3f90209
> > > Author: Mark Geisert<mark@maxrnd.com>
> > > Date:   Sun Jun 23 14:51:06 2019 -0700
> > > 
> > >      Cygwin: Implement sched_[gs]etaffinity()
> > > [...]
> > > breaks the RTEMS port:
> > > [...]
> > Looks like Cygwin has to define its own sys/cpuset.h included via
> > sys/_pthreadtypes.h.
> 
> Yes, something like this. The RTEMS <sys/cpuset.h> is based on the FreeBSD
> implementation and should be compatible to the Linux API. Maybe it can move
> out of the RTEMS area into the global Newlib area.

I'm not so sure, given the different names of macros and types used
inside cpu_set_t.  The new functions inside Cygwin rely on that.

I prep'ed a patch to move the Cygwin-specific definitions out of the
way, can you please test it on RTEMS?  It's attached to this mail.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
From cb828e0679ba06a6e7e57ae51a6e63ebc96d5987 Mon Sep 17 00:00:00 2001
From: Corinna Vinschen <corinna@vinschen.de>
Date: Wed, 26 Jun 2019 15:08:57 +0200
Subject: [PATCH] sched: Move Cygwin cpuset definitions into Cygwin-specific
 header

This avoids build breakage on RTEMS.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
---
 newlib/libc/include/sched.h               | 18 ----------------
 winsup/cygwin/include/sys/_pthreadtypes.h |  5 +++--
 winsup/cygwin/include/sys/cpuset.h        | 25 +++++++++++++++++++++++
 3 files changed, 28 insertions(+), 20 deletions(-)
 create mode 100644 winsup/cygwin/include/sys/cpuset.h

diff --git a/newlib/libc/include/sched.h b/newlib/libc/include/sched.h
index fc44209d60dc..79b775e220c7 100644
--- a/newlib/libc/include/sched.h
+++ b/newlib/libc/include/sched.h
@@ -93,24 +93,6 @@ int sched_yield( void );
 #if __GNU_VISIBLE
 int sched_getcpu(void);
 
-/* Affinity-related definitions, here until numerous enough to separate out */
-#ifdef __x86_64__
-typedef uint64_t __cpu_mask;
-#else
-typedef uint32_t __cpu_mask;
-#endif
-#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))
-
-typedef struct
-{
-  __cpu_mask __bits[__CPU_GROUPMAX];
-} cpu_set_t;
-
 int sched_getaffinity (pid_t, size_t, cpu_set_t *);
 int sched_get_thread_affinity (void *, size_t, cpu_set_t *);
 int sched_setaffinity (pid_t, size_t, const cpu_set_t *);
diff --git a/winsup/cygwin/include/sys/_pthreadtypes.h b/winsup/cygwin/include/sys/_pthreadtypes.h
index 3063e833462e..e951fee6313b 100644
--- a/winsup/cygwin/include/sys/_pthreadtypes.h
+++ b/winsup/cygwin/include/sys/_pthreadtypes.h
@@ -1,5 +1,4 @@
-/* machine/types.h
-   Written by Robert Collins <rbtcollins@hotmail.com>
+/* sys/_pthreadtypes.h
 
 This file is part of Cygwin.
 
@@ -10,6 +9,8 @@ details. */
 #ifndef _SYS__PTHREADTYPES_H_
 #define	_SYS__PTHREADTYPES_H_
 
+#include <sys/cpuset.h>
+
 #if !defined(__INSIDE_CYGWIN__) || !defined(__cplusplus)
 
 typedef struct __pthread_t {char __dummy;} *pthread_t;
diff --git a/winsup/cygwin/include/sys/cpuset.h b/winsup/cygwin/include/sys/cpuset.h
new file mode 100644
index 000000000000..a83163d01635
--- /dev/null
+++ b/winsup/cygwin/include/sys/cpuset.h
@@ -0,0 +1,25 @@
+/* sys/cpuset.h
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#ifndef _SYS_CPUSET_H_
+#define _SYS_CPUSET_H_
+
+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 __CPUELT(cpu)   ((cpu) / __NCPUBITS)
+#define __CPUMASK(cpu)  ((__cpu_mask) 1 << ((cpu) % __NCPUBITS))
+
+typedef struct
+{
+  __cpu_mask __bits[__CPU_GROUPMAX];
+} cpu_set_t;
+
+#endif /* _SYS_CPUSET_H_ */
-- 
2.20.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20190626/76e2524c/attachment.sig>


More information about the Newlib mailing list