public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 4/6] RTEMS: Make pthread_rwlock_t self-contained
  2017-10-05 12:56 [PATCH 1/6] RTEMS: Optimize pthread_once_t Sebastian Huber
  2017-10-05 12:56 ` [PATCH 5/6] RTEMS: Make pthread_cond_t self-contained Sebastian Huber
  2017-10-05 12:56 ` [PATCH 6/6] RTEMS: Make pthread_mutex_t self-contained Sebastian Huber
@ 2017-10-05 12:56 ` Sebastian Huber
  2017-10-05 12:56 ` [PATCH 2/6] RTEMS: Make sem_t self-contained Sebastian Huber
  2017-10-05 13:53 ` [PATCH 3/6] RTEMS: Make pthread_barrier_t self-contained Sebastian Huber
  4 siblings, 0 replies; 6+ messages in thread
From: Sebastian Huber @ 2017-10-05 12:56 UTC (permalink / raw)
  To: newlib

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libc/sys/rtems/include/sys/_pthreadtypes.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h b/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
index 4cb15d14b..5638f1569 100644
--- a/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
+++ b/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
@@ -206,9 +206,14 @@ typedef struct {
 /* POSIX Reader/Writer Lock Types */
 
 #if defined(_POSIX_READER_WRITER_LOCKS)
-typedef __uint32_t pthread_rwlock_t;         /* POSIX RWLock Object */
+typedef struct {
+  unsigned long _flags;
+  struct _Thread_queue_Queue _Queue;
+  unsigned int _current_state;
+  unsigned int _number_of_readers;
+} pthread_rwlock_t;
 
-#define _PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) 0xFFFFFFFF)
+#define _PTHREAD_RWLOCK_INITIALIZER { 0, _THREAD_QUEUE_INITIALIZER, 0, 0 }
 
 typedef struct {
   int   is_initialized;       /* is this structure initialized? */
-- 
2.12.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 6/6] RTEMS: Make pthread_mutex_t self-contained
  2017-10-05 12:56 [PATCH 1/6] RTEMS: Optimize pthread_once_t Sebastian Huber
  2017-10-05 12:56 ` [PATCH 5/6] RTEMS: Make pthread_cond_t self-contained Sebastian Huber
@ 2017-10-05 12:56 ` Sebastian Huber
  2017-10-05 12:56 ` [PATCH 4/6] RTEMS: Make pthread_rwlock_t self-contained Sebastian Huber
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sebastian Huber @ 2017-10-05 12:56 UTC (permalink / raw)
  To: newlib

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libc/sys/rtems/include/sys/_pthreadtypes.h | 30 +++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h b/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
index 0b607f7f2..b091ebbaf 100644
--- a/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
+++ b/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
@@ -131,9 +131,35 @@ typedef struct {
 
 #endif /* !defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) */
 
-typedef __uint32_t pthread_mutex_t;      /* identify a mutex */
+struct _Chain_Node {
+  struct _Chain_Node *_next;
+  struct _Chain_Node *_previous;
+};
+
+struct _RBTree_Node {
+  struct _RBTree_Node *_left;
+  struct _RBTree_Node *_right;
+  struct _RBTree_Node *_parent;
+  int _color;
+};
+
+struct _Priority_Node {
+  union {
+    struct _RBTree_Node _RBTree;
+    struct _Chain_Node _Chain;
+  } _Node;
+  __uint64_t _priority;
+};
 
-#define _PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF)
+typedef struct {
+  unsigned long _flags;
+  struct _Mutex_recursive_Control _Recursive;
+  struct _Priority_Node _Priority_ceiling;
+  const struct _Scheduler_Control *_scheduler;
+} pthread_mutex_t;
+
+#define _PTHREAD_MUTEX_INITIALIZER \
+  { 0, _MUTEX_RECURSIVE_INITIALIZER, { { 0, 0, 0, 0 }, 0 }, 0 }
 
 typedef struct {
   int   is_initialized;
-- 
2.12.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/6] RTEMS: Optimize pthread_once_t
@ 2017-10-05 12:56 Sebastian Huber
  2017-10-05 12:56 ` [PATCH 5/6] RTEMS: Make pthread_cond_t self-contained Sebastian Huber
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Sebastian Huber @ 2017-10-05 12:56 UTC (permalink / raw)
  To: newlib

Reduce size of pthread_once_t and make it zero-initialized.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libc/sys/rtems/include/machine/_threads.h  | 5 ++---
 newlib/libc/sys/rtems/include/sys/_pthreadtypes.h | 8 ++++----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/newlib/libc/sys/rtems/include/machine/_threads.h b/newlib/libc/sys/rtems/include/machine/_threads.h
index 24db21c0e..5faa78f46 100644
--- a/newlib/libc/sys/rtems/include/machine/_threads.h
+++ b/newlib/libc/sys/rtems/include/machine/_threads.h
@@ -41,12 +41,11 @@ typedef __uint32_t tss_t;
 
 /* pthread_once_t */
 typedef struct {
-	int	_is_initialized;
-	int	_init_executed;
+	unsigned char _flags;
 } once_flag;
 
 /* PTHREAD_ONCE_INIT */
-#define	ONCE_FLAG_INIT { 1, 0 }
+#define	ONCE_FLAG_INIT { 0 }
 
 /* PTHREAD_DESTRUCTOR_ITERATIONS */
 #define	TSS_DTOR_ITERATIONS 4
diff --git a/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h b/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
index bd66c689e..9db50fe44 100644
--- a/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
+++ b/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
@@ -169,11 +169,11 @@ typedef struct {
 typedef __uint32_t pthread_key_t;        /* thread-specific data keys */
 
 typedef struct {
-  int   is_initialized;  /* is this structure initialized? */
-  int   init_executed;   /* has the initialization routine been run? */
-} pthread_once_t;       /* dynamic package initialization */
+  unsigned char _flags;
+} pthread_once_t;
+
+#define _PTHREAD_ONCE_INIT { 0 }
 
-#define _PTHREAD_ONCE_INIT  { 1, 0 }  /* is initialized and not run */
 #endif /* defined(_POSIX_THREADS) */
 
 /* POSIX Barrier Types */
-- 
2.12.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 5/6] RTEMS: Make pthread_cond_t self-contained
  2017-10-05 12:56 [PATCH 1/6] RTEMS: Optimize pthread_once_t Sebastian Huber
@ 2017-10-05 12:56 ` Sebastian Huber
  2017-10-05 12:56 ` [PATCH 6/6] RTEMS: Make pthread_mutex_t self-contained Sebastian Huber
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sebastian Huber @ 2017-10-05 12:56 UTC (permalink / raw)
  To: newlib

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libc/sys/rtems/include/sys/_pthreadtypes.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h b/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
index 5638f1569..0b607f7f2 100644
--- a/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
+++ b/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
@@ -152,9 +152,13 @@ typedef struct {
 
 /* Condition Variables */
 
-typedef __uint32_t pthread_cond_t;       /* identify a condition variable */
+typedef struct {
+  unsigned long _flags;
+  struct _Thread_queue_Queue _Queue;
+  pthread_mutex_t *_mutex;
+} pthread_cond_t;
 
-#define _PTHREAD_COND_INITIALIZER ((pthread_cond_t) 0xFFFFFFFF)
+#define _PTHREAD_COND_INITIALIZER { 0, _THREAD_QUEUE_INITIALIZER, 0 }
 
 typedef struct {
   int      is_initialized;
-- 
2.12.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/6] RTEMS: Make sem_t self-contained
  2017-10-05 12:56 [PATCH 1/6] RTEMS: Optimize pthread_once_t Sebastian Huber
                   ` (2 preceding siblings ...)
  2017-10-05 12:56 ` [PATCH 4/6] RTEMS: Make pthread_rwlock_t self-contained Sebastian Huber
@ 2017-10-05 12:56 ` Sebastian Huber
  2017-10-05 13:53 ` [PATCH 3/6] RTEMS: Make pthread_barrier_t self-contained Sebastian Huber
  4 siblings, 0 replies; 6+ messages in thread
From: Sebastian Huber @ 2017-10-05 12:56 UTC (permalink / raw)
  To: newlib

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libc/sys/rtems/include/semaphore.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/sys/rtems/include/semaphore.h b/newlib/libc/sys/rtems/include/semaphore.h
index e3c61da04..44ecc58f4 100644
--- a/newlib/libc/sys/rtems/include/semaphore.h
+++ b/newlib/libc/sys/rtems/include/semaphore.h
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: head/include/semaphore.h 314424 2017-02-28 21:47:00Z vangyzen $
  */
 
 /* semaphore.h: POSIX 1003.1b semaphores */
@@ -33,10 +33,14 @@
 #define _SEMAPHORE_H_
 
 #include <sys/cdefs.h>
+#include <sys/lock.h>
 #include <sys/_types.h>
 #include <sys/_timespec.h>
 
-typedef	__uint32_t	sem_t;
+typedef struct {
+	unsigned long _flags;
+	struct _Semaphore_Control _Semaphore;
+} sem_t;
 
 #define	SEM_FAILED	((sem_t *)0)
 
-- 
2.12.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/6] RTEMS: Make pthread_barrier_t self-contained
  2017-10-05 12:56 [PATCH 1/6] RTEMS: Optimize pthread_once_t Sebastian Huber
                   ` (3 preceding siblings ...)
  2017-10-05 12:56 ` [PATCH 2/6] RTEMS: Make sem_t self-contained Sebastian Huber
@ 2017-10-05 13:53 ` Sebastian Huber
  4 siblings, 0 replies; 6+ messages in thread
From: Sebastian Huber @ 2017-10-05 13:53 UTC (permalink / raw)
  To: newlib

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libc/sys/rtems/include/sys/_pthreadtypes.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h b/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
index 9db50fe44..4cb15d14b 100644
--- a/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
+++ b/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
@@ -179,7 +179,13 @@ typedef struct {
 /* POSIX Barrier Types */
 
 #if defined(_POSIX_BARRIERS)
-typedef __uint32_t pthread_barrier_t;        /* POSIX Barrier Object */
+typedef struct {
+  unsigned long _flags;
+  struct _Thread_queue_Queue _Queue;
+  unsigned int _count;
+  unsigned int _waiting_threads;
+} pthread_barrier_t;
+
 typedef struct {
   int   is_initialized;  /* is this structure initialized? */
 #if defined(_POSIX_THREAD_PROCESS_SHARED)
-- 
2.12.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-05 12:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05 12:56 [PATCH 1/6] RTEMS: Optimize pthread_once_t Sebastian Huber
2017-10-05 12:56 ` [PATCH 5/6] RTEMS: Make pthread_cond_t self-contained Sebastian Huber
2017-10-05 12:56 ` [PATCH 6/6] RTEMS: Make pthread_mutex_t self-contained Sebastian Huber
2017-10-05 12:56 ` [PATCH 4/6] RTEMS: Make pthread_rwlock_t self-contained Sebastian Huber
2017-10-05 12:56 ` [PATCH 2/6] RTEMS: Make sem_t self-contained Sebastian Huber
2017-10-05 13:53 ` [PATCH 3/6] RTEMS: Make pthread_barrier_t self-contained Sebastian Huber

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