public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/cygwin-3_4-branch] Cygwin: Make gcc-specific code in <sys/cpuset.h> compiler-agnostic
@ 2023-07-10  8:42 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-07-10  8:42 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=df0f296f59d24fbad1fbc3cd791bf3f362116c4f

commit df0f296f59d24fbad1fbc3cd791bf3f362116c4f
Author:     Mark Geisert <mark@maxrnd.com>
AuthorDate: Sun Jul 9 00:59:22 2023 -0700
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Mon Jul 10 10:29:41 2023 +0200

    Cygwin: Make gcc-specific code in <sys/cpuset.h> compiler-agnostic
    
    The current version of <sys/cpuset.h> cannot be compiled by Clang due to
    the use of builtin versions of malloc, free, and memset.  Their presence
    here was a dubious optimization anyway, so their usage has been
    converted to standard library functions.
    
    The use of __builtin_popcountl remains because Clang implements it just
    like gcc does.  If/when some other compiler (Rust? Go?) runs into this
    issue we can deal with specialized handling then.
    
    The "#include <sys/cdefs>" here to define __inline can be removed since
    both of the new includes sub-include it.
    
    Addresses: https://cygwin.com/pipermail/cygwin/2023-July/253927.html
    Fixes: 9cc910dd33a5 (Cygwin: Make <sys/cpuset.h> safe for c89 compilations)
    Signed-off-by: Mark Geisert <mark@maxrnd.com>

Diff:
---
 winsup/cygwin/include/sys/cpuset.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/winsup/cygwin/include/sys/cpuset.h b/winsup/cygwin/include/sys/cpuset.h
index 0c95134ff31a..95c777cfbc6d 100644
--- a/winsup/cygwin/include/sys/cpuset.h
+++ b/winsup/cygwin/include/sys/cpuset.h
@@ -9,7 +9,8 @@ details. */
 #ifndef _SYS_CPUSET_H_
 #define _SYS_CPUSET_H_
 
-#include <sys/cdefs.h>
+#include <stdlib.h>
+#include <string.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -44,14 +45,14 @@ __cpuset_alloc_size (int num)
 static __inline cpu_set_t *
 __cpuset_alloc (int num)
 {
-  return (cpu_set_t *) __builtin_malloc (CPU_ALLOC_SIZE(num));
+  return (cpu_set_t *) malloc (CPU_ALLOC_SIZE(num));
 }
 
 #define CPU_FREE(set) __cpuset_free (set)
 static __inline void
 __cpuset_free (cpu_set_t *set)
 {
-  __builtin_free (set);
+  free (set);
 }
 
 /* These _S macros operate on dynamically-sized cpu sets of size 'siz' bytes */
@@ -59,7 +60,7 @@ __cpuset_free (cpu_set_t *set)
 static __inline void
 __cpuset_zero_s (size_t siz, cpu_set_t *set)
 {
-  (void) __builtin_memset (set, 0, siz);
+  (void) memset (set, 0, siz);
 }
 
 #define CPU_SET_S(cpu, siz, set) __cpuset_set_s (cpu, siz, set)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-10  8:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-10  8:42 [newlib-cygwin/cygwin-3_4-branch] Cygwin: Make gcc-specific code in <sys/cpuset.h> compiler-agnostic Corinna Vinschen

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).