source: rtems-tools/tools/4.12/newlib/RTEMS-Add-user-defined-name-to-thread-queues.patch @ 516f931

Last change on this file since 516f931 was 516f931, checked in by Sebastian Huber <sebastian.huber@…>, on Dec 23, 2016 at 8:06:01 AM

Add Newlib patch for RTEMS 4.12

  • Property mode set to 100644
File size: 4.4 KB
  • newlib/libc/sys/rtems/include/sys/lock.h

    From 932cfc4da3a2737e0077164b7d4a6c3e4252ebb2 Mon Sep 17 00:00:00 2001
    From: Sebastian Huber <sebastian.huber@embedded-brains.de>
    Date: Tue, 20 Dec 2016 09:26:54 +0100
    Subject: [PATCH] RTEMS: Add user-defined name to thread queues
    
    Add a user-defined name to the self-contained synchronization objects in
    order to make system diagnostics, tracing and debugging more user
    friendly.
    
    Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
    ---
     newlib/libc/sys/rtems/include/sys/lock.h | 66 +++++++++++++++++++++++++++++++-
     1 file changed, 65 insertions(+), 1 deletion(-)
    
    diff --git a/newlib/libc/sys/rtems/include/sys/lock.h b/newlib/libc/sys/rtems/include/sys/lock.h
    index c0549db..ec3415a 100644
    a b struct _Thread_queue_Queue { 
    4646        struct _Ticket_lock_Control _Lock;
    4747        struct _Thread_queue_Heads *_heads;
    4848        struct _Thread_Control *_owner;
     49        const char *_name;
    4950};
    5051
    5152struct _Mutex_Control {
    struct _Futex_Control { 
    7273
    7374#define _TICKET_LOCK_INITIALIZER { 0, 0 }
    7475
    75 #define _THREAD_QUEUE_INITIALIZER { _TICKET_LOCK_INITIALIZER, 0, 0 }
     76#define _THREAD_QUEUE_INITIALIZER { _TICKET_LOCK_INITIALIZER, 0, 0, 0 }
     77
     78#define _THREAD_QUEUE_NAMED_INITIALIZER(_name) \
     79    { _TICKET_LOCK_INITIALIZER, 0, 0, _name }
    7680
    7781#define _MUTEX_INITIALIZER { _THREAD_QUEUE_INITIALIZER }
    7882
     83#define _MUTEX_NAMED_INITIALIZER(_name) \
     84    { _THREAD_QUEUE_NAMED_INITIALIZER(_name) }
     85
    7986#define _MUTEX_RECURSIVE_INITIALIZER { _MUTEX_INITIALIZER, 0 }
    8087
     88#define _MUTEX_RECURSIVE_NAMED_INITIALIZER(_name) \
     89    { _MUTEX_NAMED_INITIALIZER(_name), 0 }
     90
    8191#define _CONDITION_INITIALIZER { _THREAD_QUEUE_INITIALIZER }
    8292
     93#define _CONDITION_NAMED_INITIALIZER(_name) \
     94    { _THREAD_QUEUE_NAMED_INITIALIZER(_name) }
     95
    8396#define _SEMAPHORE_INITIALIZER(_count) { _THREAD_QUEUE_INITIALIZER, _count }
    8497
     98#define _SEMAPHORE_NAMED_INITIALIZER(_name, _count) \
     99    { _THREAD_QUEUE_NAMED_INITIALIZER(_name), _count }
     100
    85101#define _FUTEX_INITIALIZER { _THREAD_QUEUE_INITIALIZER }
    86102
     103#define _FUTEX_NAMED_INITIALIZER(_name) \
     104    { _THREAD_QUEUE_NAMED_INITIALIZER(_name) }
     105
    87106static __inline void
    88107_Mutex_Initialize(struct _Mutex_Control *_mutex)
    89108{
    _Mutex_Initialize(struct _Mutex_Control *_mutex) 
    92111        *_mutex = _init;
    93112}
    94113
     114static __inline void
     115_Mutex_Initialize_named(struct _Mutex_Control *_mutex, const char *_name)
     116{
     117        struct _Mutex_Control _init = _MUTEX_NAMED_INITIALIZER(_name);
     118
     119        *_mutex = _init;
     120}
     121
    95122void _Mutex_Acquire(struct _Mutex_Control *);
    96123
    97124int _Mutex_Acquire_timed(struct _Mutex_Control *, const struct timespec *);
    _Mutex_recursive_Initialize(struct _Mutex_recursive_Control *_mutex) 
    115142        *_mutex = _init;
    116143}
    117144
     145static __inline void
     146_Mutex_recursive_Initialize_named(struct _Mutex_recursive_Control *_mutex,
     147    const char *_name)
     148{
     149        struct _Mutex_recursive_Control _init =
     150            _MUTEX_RECURSIVE_NAMED_INITIALIZER(_name);
     151
     152        *_mutex = _init;
     153}
     154
    118155void _Mutex_recursive_Acquire(struct _Mutex_recursive_Control *);
    119156
    120157int _Mutex_recursive_Acquire_timed(struct _Mutex_recursive_Control *,
    _Condition_Initialize(struct _Condition_Control *_cond) 
    139176        *_cond = _init;
    140177}
    141178
     179static __inline void
     180_Condition_Initialize_named(struct _Condition_Control *_cond,
     181    const char *_name)
     182{
     183        struct _Condition_Control _init = _CONDITION_NAMED_INITIALIZER(_name);
     184
     185        *_cond = _init;
     186}
     187
    142188void _Condition_Wait(struct _Condition_Control *, struct _Mutex_Control *);
    143189
    144190int _Condition_Wait_timed(struct _Condition_Control *,
    _Semaphore_Initialize(struct _Semaphore_Control *_semaphore, 
    170216        *_semaphore = _init;
    171217}
    172218
     219static __inline void
     220_Semaphore_Initialize_named(struct _Semaphore_Control *_semaphore,
     221    const char *_name, unsigned int _count)
     222{
     223        struct _Semaphore_Control _init =
     224            _SEMAPHORE_NAMED_INITIALIZER(_name, _count);
     225
     226        *_semaphore = _init;
     227}
     228
    173229void _Semaphore_Wait(struct _Semaphore_Control *);
    174230
    175231void _Semaphore_Post(struct _Semaphore_Control *);
    _Futex_Initialize(struct _Futex_Control *_futex) 
    189245        *_futex = _init;
    190246}
    191247
     248static __inline void
     249_Futex_Initialize_named(struct _Futex_Control *_futex, const char *_name)
     250{
     251        struct _Futex_Control _init = _FUTEX_NAMED_INITIALIZER(_name);
     252
     253        *_futex = _init;
     254}
     255
    192256int _Futex_Wait(struct _Futex_Control *, int *, int);
    193257
    194258int _Futex_Wake(struct _Futex_Control *, int);
Note: See TracBrowser for help on using the repository browser.