From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 7F3943858D37; Fri, 1 Sep 2023 10:49:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F3943858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1693565392; bh=omyH852rei9eX/yftU/LN4SzK5C0iaZ15p94GaW7lls=; h=From:To:Subject:Date:From; b=nn7UMUjrxp1l/IOfFKeaQgAuGQ1zr3Qw8ucRiX2Vn6Js/jd0cLZwpMjLxGO95n/a1 1PZuOpTDlAdUKVQ19y4wYWno4dcLSM5kMJUi5H//1LxKsH+E61APKEHQQmjK/afpK9 JgNml6hpEqQB94fg87lKT9Hozvl44jy4BbWxVzm0= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_4-branch] Cygwin: sys/cpuset.h: add cpuset-specific external functions X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/cygwin-3_4-branch X-Git-Oldrev: 930f210b21c59298944f237002c36db0b990a4d9 X-Git-Newrev: 797d1bbd2e115872df10cf1c15ccc6cfc99648d6 Message-Id: <20230901104952.7F3943858D37@sourceware.org> Date: Fri, 1 Sep 2023 10:49:52 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D797d1bbd2e1= 15872df10cf1c15ccc6cfc99648d6 commit 797d1bbd2e115872df10cf1c15ccc6cfc99648d6 Author: Corinna Vinschen AuthorDate: Wed Aug 30 11:32:02 2023 +0200 Commit: Corinna Vinschen CommitDate: Fri Sep 1 12:43:36 2023 +0200 Cygwin: sys/cpuset.h: add cpuset-specific external functions =20 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. =20 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. =20 Fixes: 3f2790e04439 ("Cygwin: Make gcc-specific code in = compiler-agnostic") Reported-by: Denis Excoffier Signed-off-by: Corinna Vinschen Diff: --- 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 c6768e4fcec8..be404263e605 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 =3D 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_ =20 -#include -#include +#include =20 #ifdef __cplusplus extern "C" { @@ -42,25 +41,23 @@ __cpuset_alloc_size (int num) } =20 #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); =20 #define CPU_FREE(set) __cpuset_free (set) -static __inline void -__cpuset_free (cpu_set_t *set) -{ - free (set); -} +void __cpuset_free (cpu_set_t *); =20 /* These _S macros operate on dynamically-sized cpu sets of size 'siz' byt= es */ #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 /=3D sizeof (__cpu_mask); + while (siz > 0) + set->_bits[--siz] =3D 0; +#endif } =20 #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; } =20 +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 */