* improve clang support (22)
@ 2020-08-11 16:38 Bruno Haible
2020-08-16 16:40 ` Bruno Haible
0 siblings, 1 reply; 2+ messages in thread
From: Bruno Haible @ 2020-08-11 16:38 UTC (permalink / raw
To: bug-gnulib
clang supports expression statement syntax (a block inside parentheses) like
GCC. This patch makes use of it.
2020-08-11 Bruno Haible <bruno@clisp.org>
Use expression statements also on clang.
* lib/cdefs.h (__extension__): Don't define to empty on clang.
* lib/obstack.h (__extension__): Likewise.
(obstack_object_size, obstack_room, obstack_make_room, obstack_empty_p,
obstack_grow, obstack_grow0, obstack_1grow, obstack_ptr_grow,
obstack_int_grow, obstack_ptr_grow_fast, obstack_int_grow_fast,
obstack_blank, obstack_alloc, obstack_copy, obstack_copy0,
obstack_finish, obstack_free): Enable as optimized macros also on clang.
* lib/fpucw.h (fpucw_t etc.): Enable the definitions also on clang.
diff --git a/lib/cdefs.h b/lib/cdefs.h
index 170d9e6..0065254 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -395,7 +395,7 @@
run in pedantic mode if the uses are carefully marked using the
`__extension__' keyword. But this is not generally available before
version 2.8. */
-#if !__GNUC_PREREQ (2,8)
+#if !(__GNUC_PREREQ (2,8) || defined __clang__)
# define __extension__ /* Ignore */
#endif
diff --git a/lib/fpucw.h b/lib/fpucw.h
index 1c6edf6..8ef5420 100644
--- a/lib/fpucw.h
+++ b/lib/fpucw.h
@@ -61,8 +61,8 @@
'long double' safe operation precision
*/
-/* Inline assembler like this works only with GNU C. */
-#if (defined __i386__ || defined __x86_64__) && defined __GNUC__
+/* Inline assembler like this works only with GNU C and clang. */
+#if (defined __i386__ || defined __x86_64__) && (defined __GNUC__ || defined __clang__)
typedef unsigned short fpucw_t; /* glibc calls this fpu_control_t */
diff --git a/lib/obstack.h b/lib/obstack.h
index 987bd3b..9452408 100644
--- a/lib/obstack.h
+++ b/lib/obstack.h
@@ -283,8 +283,9 @@ extern int obstack_exit_failure;
#define obstack_memory_used(h) _obstack_memory_used (h)
-#if defined __GNUC__
-# if !defined __GNUC_MINOR__ || __GNUC__ * 1000 + __GNUC_MINOR__ < 2008
+#if defined __GNUC__ || defined __clang__
+# if !(defined __GNUC_MINOR__ && __GNUC__ * 1000 + __GNUC_MINOR__ >= 2008 \
+ || defined __clang__)
# define __extension__
# endif
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: improve clang support (22)
2020-08-11 16:38 improve clang support (22) Bruno Haible
@ 2020-08-16 16:40 ` Bruno Haible
0 siblings, 0 replies; 2+ messages in thread
From: Bruno Haible @ 2020-08-16 16:40 UTC (permalink / raw
To: bug-gnulib
[-- Attachment #1: Type: text/plain, Size: 521 bytes --]
> clang supports expression statement syntax (a block inside parentheses) like
> GCC. This patch makes use of it.
Two further places where expression statements can be enabled in clang, for
better optimization:
2020-08-16 Bruno Haible <bruno@clisp.org>
setenv: Use tree code also with clang.
* lib/setenv.c (USE_TSEARCH): Treat clang like GCC.
2020-08-16 Bruno Haible <bruno@clisp.org>
math: Optimize signbit also on clang.
* lib/math.in.h (gl_signbitf, gl_signbitd, gl_signbitl): Optimize also
on clang.
[-- Attachment #2: 0001-math-Optimize-signbit-also-on-clang.patch --]
[-- Type: text/x-patch, Size: 1518 bytes --]
From ad3f6af5cea05a6aa9d6bf8588ef024d24f3b6ef Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 16 Aug 2020 18:39:29 +0200
Subject: [PATCH 1/2] math: Optimize signbit also on clang.
* lib/math.in.h (gl_signbitf, gl_signbitd, gl_signbitl): Optimize also
on clang.
---
ChangeLog | 6 ++++++
lib/math.in.h | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 81ed349..2e78c4f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2020-08-16 Bruno Haible <bruno@clisp.org>
+ math: Optimize signbit also on clang.
+ * lib/math.in.h (gl_signbitf, gl_signbitd, gl_signbitl): Optimize also
+ on clang.
+
+2020-08-16 Bruno Haible <bruno@clisp.org>
+
avltreehash-list, rbtreehash-list: Optimize also on clang.
* lib/gl_anytreehash_list1.h (add_nodes_to_buckets): Use
__builtin_expect also on clang.
diff --git a/lib/math.in.h b/lib/math.in.h
index 99b7e32..0f67127 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -2536,7 +2536,7 @@ _GL_WARN_REAL_FLOATING_DECL (isnan);
_GL_EXTERN_C int gl_signbitf (float arg);
_GL_EXTERN_C int gl_signbitd (double arg);
_GL_EXTERN_C int gl_signbitl (long double arg);
-# if __GNUC__ >= 2 && !defined __STRICT_ANSI__
+# if (__GNUC__ >= 2 || defined __clang__) && !defined __STRICT_ANSI__
# define _GL_NUM_UINT_WORDS(type) \
((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf
--
2.7.4
[-- Attachment #3: 0002-setenv-Use-tree-code-also-with-clang.patch --]
[-- Type: text/x-patch, Size: 1363 bytes --]
From 5a459e1cf0deb13b90313da377fe6cb2d8ccff73 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 16 Aug 2020 18:39:33 +0200
Subject: [PATCH 2/2] setenv: Use tree code also with clang.
* lib/setenv.c (USE_TSEARCH): Treat clang like GCC.
---
ChangeLog | 5 +++++
lib/setenv.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 2e78c4f..b750f34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2020-08-16 Bruno Haible <bruno@clisp.org>
+ setenv: Use tree code also with clang.
+ * lib/setenv.c (USE_TSEARCH): Treat clang like GCC.
+
+2020-08-16 Bruno Haible <bruno@clisp.org>
+
math: Optimize signbit also on clang.
* lib/math.in.h (gl_signbitf, gl_signbitd, gl_signbitl): Optimize also
on clang.
diff --git a/lib/setenv.c b/lib/setenv.c
index d03bc5a..aede703 100644
--- a/lib/setenv.c
+++ b/lib/setenv.c
@@ -72,7 +72,7 @@ __libc_lock_define_initialized (static, envlock)
values are from a small set. Outside glibc this will eat up all
memory after a while. */
#if defined _LIBC || (defined HAVE_SEARCH_H && defined HAVE_TSEARCH \
- && defined __GNUC__)
+ && (defined __GNUC__ || defined __clang__))
# define USE_TSEARCH 1
# include <search.h>
typedef int (*compar_fn_t) (const void *, const void *);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-16 16:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-11 16:38 improve clang support (22) Bruno Haible
2020-08-16 16:40 ` Bruno Haible
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).