This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: RTEMS Patches Pending and Our Activity
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- Cc: "newlib at sourceware dot org" <newlib at sourceware dot org>
- Date: Tue, 26 Nov 2013 15:16:34 +0100
- Subject: Re: RTEMS Patches Pending and Our Activity
- Authentication-results: sourceware.org; auth=none
- References: <5294A92E dot 4000909 at oarcorp dot com>
Hello Joel,
On 2013-11-26 14:59, Joel Sherrill wrote:
Hi
In case it hasn't been obvious from the patches, RTEMS is
in the middle of some major SMP work. We are trying to also
address C99 and POSIX 2013 but this is a slower ongoing
effort. We have just taken advantage of Google Code-In to
get some movement there.
With that in mind, I still think RTEMS has a few patches
to push hard on before the traditional newlib December
release:
+ Sebastian's variable size cpuset patch
+ add pthread affinity patch
+ pthread push/pop patch
- Sebastian .. If you sent me the corresponding RTEMS
patch, I missed it.
its attached.
+ I want to make a double pass that restrict didn't end up in
the traditional prototype section of documentation.
+ Sebastian.. anything else?
I hope that I have time to fix the stdint.h vs. _default_types.h issue.
[...]
--
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.
>From dd45b36fa839df249b23c48f2862b21e6d97ed86 Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Fri, 5 Jul 2013 15:49:13 +0200
Subject: [PATCH] Pthreads cleanup push/pop changes
Implementation according to POSIX:
http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_cleanup_push.html
This change is not conditional to RTEMS since I don't think the previous
approach is useful at all. To provide binary compatibility systems can
still provide the previous pthread_cleanup_push() and pthread_cleanup_pop()
functions.
newlib/ChangeLog
2013-11-26 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/include/pthread.h (pthread_cleanup_push): Delete prototype
and add macro of the same name.
(pthread_cleanup_pop): Likewise.
(_pthread_cleanup_context): Define.
(_pthread_cleanup_push): Likewise.
(_pthread_cleanup_pop): Likewise.
(pthread_cleanup_push_defer_np): Define if _GNU_SOURCE is defined.
(pthread_cleanup_pop_restore_np): Likewise.
(_pthread_cleanup_push_defer): Likewise.
(_pthread_cleanup_pop_restore): Likewise.
---
newlib/libc/include/pthread.h | 47 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/newlib/libc/include/pthread.h b/newlib/libc/include/pthread.h
index ff7f354..9641114 100644
--- a/newlib/libc/include/pthread.h
+++ b/newlib/libc/include/pthread.h
@@ -33,6 +33,13 @@ extern "C" {
#include <time.h>
#include <sys/sched.h>
+struct _pthread_cleanup_context {
+ void (*_routine)(void *);
+ void *_arg;
+ int _canceltype;
+ struct _pthread_cleanup_context *_previous;
+};
+
/* Register Fork Handlers */
int _EXFUN(pthread_atfork,(void (*prepare)(void), void (*parent)(void),
void (*child)(void)));
@@ -280,9 +287,43 @@ void _EXFUN(pthread_testcancel, (void));
/* Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184 */
-void _EXFUN(pthread_cleanup_push,
- (void (*__routine)( void * ), void *__arg));
-void _EXFUN(pthread_cleanup_pop, (int __execute));
+void _EXFUN(_pthread_cleanup_push,
+ (struct _pthread_cleanup_context *_context,
+ void (*_routine)(void *), void *_arg));
+
+void _EXFUN(_pthread_cleanup_pop,
+ (struct _pthread_cleanup_context *_context,
+ int _execute));
+
+/* It is intentional to open and close the scope in two different macros */
+#define pthread_cleanup_push(_routine, _arg) \
+ do { \
+ struct _pthread_cleanup_context _pthread_clup_ctx; \
+ _pthread_cleanup_push(&_pthread_clup_ctx, (_routine), (_arg))
+
+#define pthread_cleanup_pop(_execute) \
+ _pthread_cleanup_pop(&_pthread_clup_ctx, (_execute)); \
+ } while (0)
+
+#if defined(_GNU_SOURCE)
+void _EXFUN(_pthread_cleanup_push_defer,
+ (struct _pthread_cleanup_context *_context,
+ void (*_routine)(void *), void *_arg));
+
+void _EXFUN(_pthread_cleanup_pop_restore,
+ (struct _pthread_cleanup_context *_context,
+ int _execute));
+
+/* It is intentional to open and close the scope in two different macros */
+#define pthread_cleanup_push_defer_np(_routine, _arg) \
+ do { \
+ struct _pthread_cleanup_context _pthread_clup_ctx; \
+ _pthread_cleanup_push_defer(&_pthread_clup_ctx, (_routine), (_arg))
+
+#define pthread_cleanup_pop_restore_np(_execute) \
+ _pthread_cleanup_pop_restore(&_pthread_clup_ctx, (_execute)); \
+ } while (0)
+#endif /* defined(_GNU_SOURCE) */
#if defined(_POSIX_THREAD_CPUTIME)
--
1.7.7