Re: unknown type name 'cpu_set_t' in newlib/libc/include/sched.h

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Aug 12 11:05, Giacomo Tesio wrote:
> On Monday, 12 August 2019, Corinna Vinschen <[email protected]> wrote:
> > On Aug 12 02:28, Giacomo Tesio wrote:
> >> Hello everybody,
> >>
> >> apparently commit 383e19ca552234fa9af47e80cb00d843a96de9e3 moved the
> >> cpu_set_t typedef from newlib/libc/include/sched.h to cygwin specific
> >> stuff, but left a few functions using such type behind and
> >> unprotected.
> >>
> >> Is it intended?
> >
> > Probably not, if it leads to build errors on non-Cygwin, non-RTEMS.
> >
> > Does it?
> 
> Yes it produce build errore in my os port because I don't have it defined
> anywhere.
> 
> You could either protect the functions with an ifdef or move back the
> typedef to sched.h

I'd propose this patch:

From d192727fee2f85fcc7eb78c7cb09963a7b663d5a Mon Sep 17 00:00:00 2001
From: Corinna Vinschen <[email protected]>
Date: Mon, 12 Aug 2019 12:13:20 +0200
Subject: [PATCH] sched.h: Declare affinity functions only on targets
 supporting them

---
 newlib/libc/include/sched.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/newlib/libc/include/sched.h b/newlib/libc/include/sched.h
index 79b775e220c7..31599aa7e6ca 100644
--- a/newlib/libc/include/sched.h
+++ b/newlib/libc/include/sched.h
@@ -93,10 +93,16 @@ int sched_yield( void );
 #if __GNU_VISIBLE
 int sched_getcpu(void);
 
+/* The following functions should only be declared if the type
+   cpu_set_t is defined through indirect inclusion of sys/cpuset.h,
+   only available on some targets. */
+#ifdef _SYS_CPUSET_H_
 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 *);
 int sched_set_thread_affinity (void *, size_t, const cpu_set_t *);
+#endif /* _SYS_CPUSET_H_ */
+
 #endif
 
 #ifdef __cplusplus
-- 
2.20.1


Please test or suggest an alternative.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl1RPGoACgkQ9TYGna5E
T6COpg//Q3+jeG/D/tBkmO7b/G6xANb/crmIipa0lOewULXvcq+QwaOFM7wt6MOI
PhIFLK65/MnfmUnOzkp//f7GfOiTw+YYrluLF3nDM/UH4Nt6KJByO5BWBhFfKgmC
71ksN2NvPqX9IBZ7pCcDN0q8L2tUHrL+w9aTfLwkh2u49typA9HG+ijv8I/S5PvN
Z516q0bU9FzopOiOxnJeZeRppPsbwZ3hcW7D0rdzRywx7xdyMjzBpmppyz/MH28D
JII1sLfocaz4DNi8GZYugyTRSxOkbzryCDMHcc70Ffmu415a83fGFeo9MirjqNS8
Yzoj/y28uDFco7q9h6UuZEs0kgxbwSAsqxHLVZSjOhCZawiBUBn1MajhwiO7kIac
AJf6nt0NQZJEq6emh/AH3cggzNW9GiT2uhhUi07YQSFoRDq70KRZwOR9XpLXSUcR
IwGSPaVz88gEepdT/KQVUmI18kvrlLHN11eR8zIPnI0bq2HJ5HI8unvp9jt+7Ehl
rFrW35hEICNwF/js8KsOIdRtIWzpqg4x1X2KLTmSekfTMOz0iAXxhkJLnwTb01rp
Afx0ul0ysYa070dvrZq6+GW5q9KAx4xXT5C8KfJbfXmWwdQ6fbt/u6uHIYjEH8nO
r2lcmSH/yTVuX/qWH9Fnj7d0Sn/IMwlsysxYRIPocvOubZJQEU0=
=ldx4
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.