This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH] headers: avoid bareword attributes
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: Eric Blake <eblake at redhat dot com>, newlib at sourceware dot org
- Date: Thu, 24 Aug 2017 07:44:18 +0200
- Subject: Re: [PATCH] headers: avoid bareword attributes
- Authentication-results: sourceware.org; auth=none
- References: <20170817015011.9345-1-eblake@redhat.com>
Hello Eric,
On 17/08/17 03:50, Eric Blake wrote:
Always use the __-decorated form of an attribute name in public
headers, as the bareword form is in the user's namespace, and we
don't want compilation to break just because the user defines the
bareword to mean something else.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
newlib/libc/include/sys/cdefs.h | 28 ++++++++++++++--------------
newlib/libc/sys/phoenix/sys/unistd.h | 2 +-
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
index 2e63a07a2..9e58ee980 100644
--- a/newlib/libc/include/sys/cdefs.h
+++ b/newlib/libc/include/sys/cdefs.h
@@ -681,42 +681,42 @@
#endif
/* Structure implements a lock. */
-#define __lockable __lock_annotate(lockable)
+#define __lockable __lock_annotate(__lockable__)
/* Function acquires an exclusive or shared lock. */
#define __locks_exclusive(...) \
- __lock_annotate(exclusive_lock_function(__VA_ARGS__))
+ __lock_annotate(__exclusive_lock_function__(__VA_ARGS__))
#define __locks_shared(...) \
- __lock_annotate(shared_lock_function(__VA_ARGS__))
+ __lock_annotate(__shared_lock_function__(__VA_ARGS__))
/* Function attempts to acquire an exclusive or shared lock. */
#define __trylocks_exclusive(...) \
- __lock_annotate(exclusive_trylock_function(__VA_ARGS__))
+ __lock_annotate(__exclusive_trylock_function__(__VA_ARGS__))
#define __trylocks_shared(...) \
- __lock_annotate(shared_trylock_function(__VA_ARGS__))
+ __lock_annotate(__shared_trylock_function__(__VA_ARGS__))
/* Function releases a lock. */
-#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__))
+#define __unlocks(...) __lock_annotate(__unlock_function__(__VA_ARGS__))
/* Function asserts that an exclusive or shared lock is held. */
#define __asserts_exclusive(...) \
- __lock_annotate(assert_exclusive_lock(__VA_ARGS__))
+ __lock_annotate(__assert_exclusive_lock__(__VA_ARGS__))
#define __asserts_shared(...) \
- __lock_annotate(assert_shared_lock(__VA_ARGS__))
+ __lock_annotate(__assert_shared_lock__(__VA_ARGS__))
/* Function requires that an exclusive or shared lock is or is not held. */
#define __requires_exclusive(...) \
- __lock_annotate(exclusive_locks_required(__VA_ARGS__))
+ __lock_annotate(__exclusive_locks_required__(__VA_ARGS__))
#define __requires_shared(...) \
- __lock_annotate(shared_locks_required(__VA_ARGS__))
+ __lock_annotate(__shared_locks_required__(__VA_ARGS__))
#define __requires_unlocked(...) \
- __lock_annotate(locks_excluded(__VA_ARGS__))
+ __lock_annotate(__locks_excluded__(__VA_ARGS__))
/* Function should not be analyzed. */
-#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)
+#define __no_lock_analysis __lock_annotate(__no_thread_safety_analysis__)
/* Guard variables and structure members by lock. */
-#define __guarded_by(x) __lock_annotate(guarded_by(x))
-#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x))
+#define __guarded_by(x) __lock_annotate(__guarded_by__(x))
+#define __pt_guarded_by(x) __lock_annotate(__pt_guarded_by__(x))
#endif /* !_SYS_CDEFS_H_ */
did you test the clang thread safety analysis after this patch? It not
longer works using clang 3.8. I get now errors like this:
error: use of undeclared identifier '__mutex'
__locks_exclusive(*__mutex);
If I revert this change it works.
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.