From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-apps@cygwin.com
Subject: Re: can't compile coreutils-9.3 any more after upgrade to cygwin-3.4.8
Date: Wed, 30 Aug 2023 14:17:22 +0200 [thread overview]
Message-ID: <ZO8zUvZ2TAzWy5ZR@calimero.vinschen.de> (raw)
In-Reply-To: <ZO8Se08piQ5TE+bA@calimero.vinschen.de>
[-- Attachment #1: Type: text/plain, Size: 664 bytes --]
On Aug 30 11:57, Corinna Vinschen via Cygwin-apps wrote:
> On Aug 30 11:34, Corinna Vinschen via Cygwin-apps wrote:
> > #define CPU_ZERO_S(siz, set) __cpuset_zero_s (siz, set)
> > -static __inline void
> > -__cpuset_zero_s (size_t siz, cpu_set_t *set)
> > -{
> > - (void) memset (set, 0, siz);
> > -}
> > +void __cpuset_zero_s (size_t, cpu_set_t *);
> > [...]
> > +__cpuset_zero_s (size_t siz, cpu_set_t *set)
> > +{
> > + (void) memset (set, 0, siz);
> > +}
> > +
> > } /* extern C */
>
> Also, we can avoid an external __cpuset_zero_s function by just using a
> loop, kind of like this:
I attached a matching patch. Please give it a try.
Thanks,
Corinna
[-- Attachment #2: 0001-Cygwin-sys-cpuset.h-add-cpuset-specific-external-fun.patch --]
[-- Type: text/plain, Size: 3203 bytes --]
From a8b26a78ae600f471f54769c28b6d3542aabab06 Mon Sep 17 00:00:00 2001
From: Corinna Vinschen <corinna@vinschen.de>
Date: Wed, 30 Aug 2023 11:32:02 +0200
Subject: [PATCH] Cygwin: sys/cpuset.h: add cpuset-specific external functions
The latest incarnation of sys/cpuset.h broke building coreutils.
The reason is the inclusion of stdlib.h and string.h and hence
premature requests for datatypes not yet defined in the include
chain.
Avoid this by defining __cpuset_alloc and __cpuset_free as external
functions, now defined in sched.cc. Linux is doing this too, just
using different names for the functions. Redefine __cpuset_zero_s
to use __builtin_memset only on compilers supporting it, otherwise
using a simple loop. Drop the stdlib.h and string.h includes.
Fixes: 3f2790e04439 ("Cygwin: Make gcc-specific code in <sys/cpuset.h> compiler-agnostic")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
---
winsup/cygwin/cygwin.din | 2 ++
winsup/cygwin/include/sys/cpuset.h | 25 +++++++++++--------------
winsup/cygwin/sched.cc | 12 ++++++++++++
3 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index ee646fddc862..3afadb7f3a77 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -49,6 +49,8 @@ __b64_ntop NOSIGFE
__b64_pton NOSIGFE
__bsd_qsort_r NOSIGFE
__chk_fail SIGFE
+__cpuset_alloc SIGFE
+__cpuset_free SIGFE
__cxa_atexit = cygwin__cxa_atexit SIGFE
__cxa_finalize SIGFE
__dn_comp SIGFE
diff --git a/winsup/cygwin/include/sys/cpuset.h b/winsup/cygwin/include/sys/cpuset.h
index 95c777cfbc6d..2ab2b95f0d65 100644
--- a/winsup/cygwin/include/sys/cpuset.h
+++ b/winsup/cygwin/include/sys/cpuset.h
@@ -9,8 +9,7 @@ details. */
#ifndef _SYS_CPUSET_H_
#define _SYS_CPUSET_H_
-#include <stdlib.h>
-#include <string.h>
+#include <sys/features.h>
#ifdef __cplusplus
extern "C" {
@@ -42,25 +41,23 @@ __cpuset_alloc_size (int num)
}
#define CPU_ALLOC(num) __cpuset_alloc (num)
-static __inline cpu_set_t *
-__cpuset_alloc (int num)
-{
- return (cpu_set_t *) malloc (CPU_ALLOC_SIZE(num));
-}
+extern cpu_set_t * __cpuset_alloc (int);
#define CPU_FREE(set) __cpuset_free (set)
-static __inline void
-__cpuset_free (cpu_set_t *set)
-{
- free (set);
-}
+void __cpuset_free (cpu_set_t *);
/* These _S macros operate on dynamically-sized cpu sets of size 'siz' bytes */
#define CPU_ZERO_S(siz, set) __cpuset_zero_s (siz, set)
-static __inline void
+static __inline
__cpuset_zero_s (size_t siz, cpu_set_t *set)
{
- (void) memset (set, 0, siz);
+#if __GNUC_PREREQ (2, 91)
+ __builtin_memset (set, 0, siz);
+#else
+ siz /= sizeof (__cpu_mask);
+ while (siz > 0)
+ set->_bits[--siz] = 0;
+#endif
}
#define CPU_SET_S(cpu, siz, set) __cpuset_set_s (cpu, siz, set)
diff --git a/winsup/cygwin/sched.cc b/winsup/cygwin/sched.cc
index d7bad852765c..845fcef5702c 100644
--- a/winsup/cygwin/sched.cc
+++ b/winsup/cygwin/sched.cc
@@ -684,4 +684,16 @@ done:
return 0;
}
+cpu_set_t *
+__cpuset_alloc (int num)
+{
+ return (cpu_set_t *) malloc (CPU_ALLOC_SIZE(num));
+}
+
+void
+__cpuset_free (cpu_set_t *set)
+{
+ free (set);
+}
+
} /* extern C */
--
2.41.0
next prev parent reply other threads:[~2023-08-30 12:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <83C27059-CB24-48F5-AC91-AB0622DF82CD@Denis-Excoffier.org>
[not found] ` <aa38a12e-875a-bfaf-6427-2f8d05c0bc47@maxrnd.com>
[not found] ` <ZOh2lNSnYAJmZqUh@calimero.vinschen.de>
[not found] ` <ff004ecd-0bd7-1886-bf81-88daa6b48f2a@maxrnd.com>
[not found] ` <ZOoFxp0yvqK3ZWxX@calimero.vinschen.de>
2023-08-30 7:29 ` Mark Geisert
2023-08-30 9:34 ` Corinna Vinschen
2023-08-30 9:57 ` Corinna Vinschen
2023-08-30 12:17 ` Corinna Vinschen [this message]
2023-08-30 18:04 ` Brian Inglis
2023-08-30 18:10 ` Corinna Vinschen
2023-08-31 8:24 ` Corinna Vinschen
2023-09-01 10:28 ` Mark Geisert
2023-09-01 10:38 ` Corinna Vinschen
2023-09-02 6:51 ` Mark Geisert
2023-08-31 6:54 ` Mark Geisert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZO8zUvZ2TAzWy5ZR@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin-apps@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).