This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On Aug 12 11:05, Giacomo Tesio wrote:
> On Monday, 12 August 2019, Corinna Vinschen <vinschen@redhat.com> 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 <corinna@vinschen.de>
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

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]