cpukit/posix: reformat include with clang-format

Updates #3860.
Closes #5356.
This commit is contained in:
Gedare Bloom
2026-02-02 14:32:33 -06:00
committed by Kinsey Moore
parent 90327627ef
commit b88fbdb4c0
26 changed files with 382 additions and 410 deletions
+32 -42
View File
@@ -42,7 +42,7 @@
#define _AIO_MISC_H #define _AIO_MISC_H
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <aio.h> #include <aio.h>
#include <pthread.h> #include <pthread.h>
#include <stdatomic.h> #include <stdatomic.h>
@@ -61,23 +61,23 @@ extern "C" {
/** Constants to identify op type */ /** Constants to identify op type */
/** Needed by aio_fsync() */ /** Needed by aio_fsync() */
#define AIO_OP_READ 0 #define AIO_OP_READ 0
/** Needed by aio_fsync() */ /** Needed by aio_fsync() */
#define AIO_OP_WRITE 1 #define AIO_OP_WRITE 1
/** Needed by aio_fsync() */ /** Needed by aio_fsync() */
#define AIO_OP_SYNC 2 #define AIO_OP_SYNC 2
/** Needed by aio_fsync() */ /** Needed by aio_fsync() */
#define AIO_OP_DSYNC 3 #define AIO_OP_DSYNC 3
/* /*
* Constants to track return status * Constants to track return status
*/ */
/** The aio operation return value has been retrieved */ /** The aio operation return value has been retrieved */
#define AIO_RETURNED 0 #define AIO_RETURNED 0
/** The aio operation return value has not been retrieved */ /** The aio operation return value has not been retrieved */
#define AIO_NOTRETURNED 1 #define AIO_NOTRETURNED 1
@@ -85,25 +85,24 @@ extern "C" {
/** Constants to identify list completion notification */ /** Constants to identify list completion notification */
/** No notification required */ /** No notification required */
#define AIO_LIO_NO_NOTIFY 0 #define AIO_LIO_NO_NOTIFY 0
/** Notification via sigevent */ /** Notification via sigevent */
#define AIO_LIO_SIGEV 1 #define AIO_LIO_SIGEV 1
/** Notification via event delivery */ /** Notification via event delivery */
#define AIO_LIO_EVENT 2 #define AIO_LIO_EVENT 2
/* Constants needed by aio_suspend() */ /* Constants needed by aio_suspend() */
/** Signal generated for suspend call */ /** Signal generated for suspend call */
#define AIO_SIGNALED 1 #define AIO_SIGNALED 1
/** /**
* @brief holds a pointer to a sigevent struct or a thread id * @brief holds a pointer to a sigevent struct or a thread id
* *
*/ */
typedef union typedef union {
{
/** @brief pointer to the sigevent for notification */ /** @brief pointer to the sigevent for notification */
struct sigevent *sigp; struct sigevent *sigp;
@@ -115,8 +114,7 @@ typedef union
/** /**
* @brief Control block for every list enqueued with lio_listio() * @brief Control block for every list enqueued with lio_listio()
*/ */
typedef struct typedef struct {
{
pthread_mutex_t mutex; pthread_mutex_t mutex;
/** @brief number of requests left to complete the list */ /** @brief number of requests left to complete the list */
@@ -133,8 +131,7 @@ typedef struct
/** /**
* @brief Control block for every list involved in a aio_suspend() call. * @brief Control block for every list involved in a aio_suspend() call.
*/ */
typedef struct typedef struct {
{
pthread_mutex_t mutex; pthread_mutex_t mutex;
/** @brief number of requests left to complete the list */ /** @brief number of requests left to complete the list */
@@ -151,12 +148,11 @@ typedef struct
/** /**
* @brief The request being processed * @brief The request being processed
*/ */
typedef struct typedef struct {
{
/** @brief Chain requests in order of priority */ /** @brief Chain requests in order of priority */
rtems_chain_node next_prio; rtems_chain_node next_prio;
/** @brief If _POSIX_PRIORITIZED_IO and _POSIX_PRIORITY_SCHEDULING are defined */ /** @brief If _POSIX_PRIORITIZED_IO and _POSIX_PRIORITY_SCHEDULING are defined */
int policy; int policy;
/** @brief see above */ /** @brief see above */
@@ -182,8 +178,7 @@ typedef struct
/** /**
* @brief A chain of requests for the same FD * @brief A chain of requests for the same FD
*/ */
typedef struct typedef struct {
{
/** @brief Order fd chains in queue */ /** @brief Order fd chains in queue */
rtems_chain_node next_fd; rtems_chain_node next_fd;
@@ -197,25 +192,24 @@ typedef struct
int new_fd; int new_fd;
pthread_mutex_t mutex; pthread_mutex_t mutex;
pthread_cond_t cond; pthread_cond_t cond;
} rtems_aio_request_chain; } rtems_aio_request_chain;
/** /**
* @brief The queue of all the requests in progress and waiting to be processed * @brief The queue of all the requests in progress and waiting to be processed
*/ */
typedef struct typedef struct {
{
pthread_mutex_t mutex; pthread_mutex_t mutex;
pthread_cond_t new_req; pthread_cond_t new_req;
pthread_attr_t attr; pthread_attr_t attr;
/** @brief Chains being worked by active threads */ /** @brief Chains being worked by active threads */
rtems_chain_control work_req; rtems_chain_control work_req;
/** @brief Chains waiting to be processed */ /** @brief Chains waiting to be processed */
rtems_chain_control idle_req; rtems_chain_control idle_req;
/** @brief Specific value if queue is initialized */ /** @brief Specific value if queue is initialized */
unsigned int initialized; unsigned int initialized;
@@ -278,8 +272,8 @@ int rtems_aio_enqueue( rtems_aio_request *req );
*/ */
rtems_aio_request_chain *rtems_aio_search_fd( rtems_aio_request_chain *rtems_aio_search_fd(
rtems_chain_control *chain, rtems_chain_control *chain,
int fildes, int fildes,
int create int create
); );
/** /**
@@ -298,10 +292,7 @@ void rtems_aio_remove_fd( rtems_aio_request_chain *r_chain );
* @retval AIO_CANCELED The request was canceled. * @retval AIO_CANCELED The request was canceled.
* @retval AIO_NOTCANCELED The request was not canceled. * @retval AIO_NOTCANCELED The request was not canceled.
*/ */
int rtems_aio_remove_req( int rtems_aio_remove_req( rtems_chain_control *chain, struct aiocb *aiocbp );
rtems_chain_control *chain,
struct aiocb *aiocbp
);
/** /**
* @brief Checks the validity of a sigevent struct * @brief Checks the validity of a sigevent struct
@@ -322,7 +313,7 @@ int rtems_aio_check_sigevent( struct sigevent *sigp );
* - * -
* @return rtems_aio_request* a pointer to the newly created request. * @return rtems_aio_request* a pointer to the newly created request.
*/ */
rtems_aio_request *init_write_req( struct aiocb* aiocbp ); rtems_aio_request *init_write_req( struct aiocb *aiocbp );
/** /**
* @brief initializes a write rtems_aio_request * @brief initializes a write rtems_aio_request
@@ -332,7 +323,7 @@ rtems_aio_request *init_write_req( struct aiocb* aiocbp );
* - * -
* @return rtems_aio_request* a pointer to the newly created request. * @return rtems_aio_request* a pointer to the newly created request.
*/ */
rtems_aio_request *init_read_req( struct aiocb* aiocbp ); rtems_aio_request *init_read_req( struct aiocb *aiocbp );
/** /**
* @brief updates listcb after op completion * @brief updates listcb after op completion
@@ -355,19 +346,19 @@ void rtems_aio_update_suspendcbp( rtems_aio_suspendcb *suspendcbp );
* @retval NULL The request identified by aiocbp is not present in fd_chain. * @retval NULL The request identified by aiocbp is not present in fd_chain.
* @return A pointer to the rtems_aio_request referenced by aiocbp. * @return A pointer to the rtems_aio_request referenced by aiocbp.
*/ */
rtems_aio_request * rtems_aio_search_in_chain( rtems_aio_request *rtems_aio_search_in_chain(
const struct aiocb* aiocbp, const struct aiocb *aiocbp,
rtems_chain_control *fd_chain rtems_chain_control *fd_chain
); );
#ifdef RTEMS_DEBUG #ifdef RTEMS_DEBUG
#include <assert.h> #include <assert.h>
#define AIO_assert(_x) assert(_x) #define AIO_assert( _x ) assert( _x )
#define AIO_printf(_x) printf(_x) #define AIO_printf( _x ) printf( _x )
#else #else
#define AIO_assert(_x) #define AIO_assert( _x )
#define AIO_printf(_x) #define AIO_printf( _x )
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
@@ -375,4 +366,3 @@ rtems_aio_request * rtems_aio_search_in_chain(
#endif #endif
#endif #endif
+11 -11
View File
@@ -55,10 +55,10 @@ extern "C" {
#define POSIX_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO #define POSIX_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
typedef struct { typedef struct {
unsigned long flags; unsigned long flags;
Thread_queue_Syslock_queue Queue; Thread_queue_Syslock_queue Queue;
unsigned int count; unsigned int count;
unsigned int waiting_threads; unsigned int waiting_threads;
} POSIX_Barrier_Control; } POSIX_Barrier_Control;
static inline POSIX_Barrier_Control *_POSIX_Barrier_Get( static inline POSIX_Barrier_Control *_POSIX_Barrier_Get(
@@ -100,14 +100,14 @@ static inline void _POSIX_Barrier_Queue_release(
); );
} }
#define POSIX_BARRIER_VALIDATE_OBJECT( bar ) \ #define POSIX_BARRIER_VALIDATE_OBJECT( bar ) \
do { \ do { \
if ( \ if ( \
( bar ) == NULL \ ( bar ) == NULL || \
|| ( (uintptr_t) ( bar ) ^ POSIX_BARRIER_MAGIC ) != ( bar )->_flags \ ( (uintptr_t) ( bar ) ^ POSIX_BARRIER_MAGIC ) != ( bar )->_flags \
) { \ ) { \
return EINVAL; \ return EINVAL; \
} \ } \
} while ( 0 ) } while ( 0 )
#ifdef __cplusplus #ifdef __cplusplus
+25 -27
View File
@@ -47,9 +47,9 @@ extern "C" {
#endif #endif
typedef struct { typedef struct {
unsigned long flags; unsigned long flags;
Thread_queue_Syslock_queue Queue; Thread_queue_Syslock_queue Queue;
pthread_mutex_t *mutex; pthread_mutex_t *mutex;
} POSIX_Condition_variables_Control; } POSIX_Condition_variables_Control;
#define POSIX_CONDITION_VARIABLES_CLOCK_MONOTONIC 0x1UL #define POSIX_CONDITION_VARIABLES_CLOCK_MONOTONIC 0x1UL
@@ -67,17 +67,15 @@ typedef struct {
#define POSIX_CONDITION_VARIABLES_TQ_OPERATIONS &_Thread_queue_Operations_FIFO #define POSIX_CONDITION_VARIABLES_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
#define POSIX_CONDITION_VARIABLE_OF_THREAD_QUEUE_QUEUE( queue ) \ #define POSIX_CONDITION_VARIABLE_OF_THREAD_QUEUE_QUEUE( queue ) \
RTEMS_CONTAINER_OF( \ RTEMS_CONTAINER_OF( queue, POSIX_Condition_variables_Control, Queue.Queue )
queue, POSIX_Condition_variables_Control, Queue.Queue )
/** /**
* The default condition variable attributes structure. * The default condition variable attributes structure.
*/ */
extern const pthread_condattr_t _POSIX_Condition_variables_Default_attributes; extern const pthread_condattr_t _POSIX_Condition_variables_Default_attributes;
static inline POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get( static inline POSIX_Condition_variables_Control *
pthread_cond_t *cond _POSIX_Condition_variables_Get( pthread_cond_t *cond )
)
{ {
return (POSIX_Condition_variables_Control *) cond; return (POSIX_Condition_variables_Control *) cond;
} }
@@ -158,8 +156,8 @@ static inline void _POSIX_Condition_variables_Release(
* wake up version of the "signal" operation. * wake up version of the "signal" operation.
*/ */
int _POSIX_Condition_variables_Signal_support( int _POSIX_Condition_variables_Signal_support(
pthread_cond_t *cond, pthread_cond_t *cond,
bool is_broadcast bool is_broadcast
); );
/** /**
@@ -169,31 +167,31 @@ int _POSIX_Condition_variables_Signal_support(
* timed wait version of condition variable wait routines. * timed wait version of condition variable wait routines.
*/ */
int _POSIX_Condition_variables_Wait_support( int _POSIX_Condition_variables_Wait_support(
pthread_cond_t *cond, pthread_cond_t *cond,
pthread_mutex_t *mutex, pthread_mutex_t *mutex,
const struct timespec *abstime, const struct timespec *abstime,
clockid_t clock_id clockid_t clock_id
); );
bool _POSIX_Condition_variables_Auto_initialization( bool _POSIX_Condition_variables_Auto_initialization(
POSIX_Condition_variables_Control *the_cond POSIX_Condition_variables_Control *the_cond
); );
#define POSIX_CONDITION_VARIABLES_VALIDATE_OBJECT( the_cond, flags ) \ #define POSIX_CONDITION_VARIABLES_VALIDATE_OBJECT( the_cond, flags ) \
do { \ do { \
if ( ( the_cond ) == NULL ) { \ if ( ( the_cond ) == NULL ) { \
return EINVAL; \ return EINVAL; \
} \ } \
flags = ( the_cond )->flags; \ flags = ( the_cond )->flags; \
if ( \ if ( \
( ( (uintptr_t) ( the_cond ) ^ POSIX_CONDITION_VARIABLES_MAGIC ) \ ( ( (uintptr_t) ( the_cond ) ^ POSIX_CONDITION_VARIABLES_MAGIC ) & \
& ~POSIX_CONDITION_VARIABLES_FLAGS_MASK ) \ ~POSIX_CONDITION_VARIABLES_FLAGS_MASK ) != \
!= ( flags & ~POSIX_CONDITION_VARIABLES_FLAGS_MASK ) \ ( flags & ~POSIX_CONDITION_VARIABLES_FLAGS_MASK ) \
) { \ ) { \
if ( !_POSIX_Condition_variables_Auto_initialization( the_cond ) ) { \ if ( !_POSIX_Condition_variables_Auto_initialization( the_cond ) ) { \
return EINVAL; \ return EINVAL; \
} \ } \
} \ } \
} while ( 0 ) } while ( 0 )
#ifdef __cplusplus #ifdef __cplusplus
+15 -15
View File
@@ -111,16 +111,16 @@ extern const uint32_t _POSIX_Keys_Key_value_pair_maximum;
* @brief The data structure used to manage a POSIX key. * @brief The data structure used to manage a POSIX key.
*/ */
typedef struct { typedef struct {
/** This field is the Object control structure. */ /** This field is the Object control structure. */
Objects_Control Object; Objects_Control Object;
/** This field is the data destructor. */ /** This field is the data destructor. */
void (*destructor) (void *); void ( *destructor )( void * );
/** /**
* @brief Key value pairs of this key. * @brief Key value pairs of this key.
*/ */
Chain_Control Key_value_pairs; Chain_Control Key_value_pairs;
} POSIX_Keys_Control; } POSIX_Keys_Control;
/** /**
* @brief The POSIX Key objects information. * @brief The POSIX Key objects information.
@@ -136,14 +136,14 @@ extern Objects_Information _POSIX_Keys_Information;
* may be set). * may be set).
*/ */
#define POSIX_KEYS_INFORMATION_DEFINE( max ) \ #define POSIX_KEYS_INFORMATION_DEFINE( max ) \
OBJECTS_INFORMATION_DEFINE( \ OBJECTS_INFORMATION_DEFINE( \
_POSIX_Keys, \ _POSIX_Keys, \
OBJECTS_POSIX_API, \ OBJECTS_POSIX_API, \
OBJECTS_POSIX_KEYS, \ OBJECTS_POSIX_KEYS, \
POSIX_Keys_Control, \ POSIX_Keys_Control, \
max, \ max, \
OBJECTS_NO_STRING_NAME, \ OBJECTS_NO_STRING_NAME, \
NULL \ NULL \
) )
/** @} */ /** @} */
+7 -8
View File
@@ -81,17 +81,16 @@ static inline POSIX_Keys_Control *_POSIX_Keys_Allocate( void )
* This routine frees a keys control block to the * This routine frees a keys control block to the
* inactive chain of free keys control blocks. * inactive chain of free keys control blocks.
*/ */
static inline void _POSIX_Keys_Free( static inline void _POSIX_Keys_Free( POSIX_Keys_Control *the_key )
POSIX_Keys_Control *the_key
)
{ {
_Objects_Free( &_POSIX_Keys_Information, &the_key->Object ); _Objects_Free( &_POSIX_Keys_Information, &the_key->Object );
} }
static inline POSIX_Keys_Control *_POSIX_Keys_Get( pthread_key_t key ) static inline POSIX_Keys_Control *_POSIX_Keys_Get( pthread_key_t key )
{ {
return (POSIX_Keys_Control *) return (
_Objects_Get_no_protection( (Objects_Id) key, &_POSIX_Keys_Information ); POSIX_Keys_Control *
) _Objects_Get_no_protection( (Objects_Id) key, &_POSIX_Keys_Information );
} }
static inline void _POSIX_Keys_Key_value_acquire( static inline void _POSIX_Keys_Key_value_acquire(
@@ -101,7 +100,7 @@ static inline void _POSIX_Keys_Key_value_acquire(
{ {
_ISR_lock_ISR_disable_and_acquire( &the_thread->Keys.Lock, lock_context ); _ISR_lock_ISR_disable_and_acquire( &the_thread->Keys.Lock, lock_context );
#ifndef RTEMS_SMP #ifndef RTEMS_SMP
(void) the_thread; (void) the_thread;
#endif #endif
} }
@@ -112,11 +111,11 @@ static inline void _POSIX_Keys_Key_value_release(
{ {
_ISR_lock_Release_and_ISR_enable( &the_thread->Keys.Lock, lock_context ); _ISR_lock_Release_and_ISR_enable( &the_thread->Keys.Lock, lock_context );
#ifndef RTEMS_SMP #ifndef RTEMS_SMP
(void) the_thread; (void) the_thread;
#endif #endif
} }
POSIX_Keys_Key_value_pair * _POSIX_Keys_Key_value_allocate( void ); POSIX_Keys_Key_value_pair *_POSIX_Keys_Key_value_allocate( void );
static inline void _POSIX_Keys_Key_value_free( static inline void _POSIX_Keys_Key_value_free(
POSIX_Keys_Key_value_pair *key_value_pair POSIX_Keys_Key_value_pair *key_value_pair
+1 -1
View File
@@ -50,7 +50,7 @@ extern "C" {
*/ */
typedef struct mmap_mappings_s { typedef struct mmap_mappings_s {
rtems_chain_node node; /**< The mapping chain's node */ rtems_chain_node node; /**< The mapping chain's node */
void* addr; /**< The address of the mapped memory */ void *addr; /**< The address of the mapped memory */
size_t len; /**< The length of memory mapped */ size_t len; /**< The length of memory mapped */
int flags; /**< The mapping flags */ int flags; /**< The mapping flags */
POSIX_Shm_Control *shm; /**< The shared memory object or NULL */ POSIX_Shm_Control *shm; /**< The shared memory object or NULL */
+15 -15
View File
@@ -74,13 +74,13 @@ extern "C" {
*/ */
typedef struct { typedef struct {
Objects_Control Object; Objects_Control Object;
CORE_message_queue_Control Message_queue; CORE_message_queue_Control Message_queue;
bool linked; bool linked;
uint32_t open_count; uint32_t open_count;
struct sigevent notification; struct sigevent notification;
int oflag; int oflag;
} POSIX_Message_queue_Control; } POSIX_Message_queue_Control;
/** /**
* @brief The POSIX Message Queue objects information. * @brief The POSIX Message Queue objects information.
@@ -97,14 +97,14 @@ extern Objects_Information _POSIX_Message_queue_Information;
* may be set). * may be set).
*/ */
#define POSIX_MESSAGE_QUEUE_INFORMATION_DEFINE( max ) \ #define POSIX_MESSAGE_QUEUE_INFORMATION_DEFINE( max ) \
OBJECTS_INFORMATION_DEFINE( \ OBJECTS_INFORMATION_DEFINE( \
_POSIX_Message_queue, \ _POSIX_Message_queue, \
OBJECTS_POSIX_API, \ OBJECTS_POSIX_API, \
OBJECTS_POSIX_MESSAGE_QUEUES, \ OBJECTS_POSIX_MESSAGE_QUEUES, \
POSIX_Message_queue_Control, \ POSIX_Message_queue_Control, \
max, \ max, \
_POSIX_PATH_MAX, \ _POSIX_PATH_MAX, \
NULL \ NULL \
) )
/** @} */ /** @} */
+20 -24
View File
@@ -77,12 +77,12 @@ void _POSIX_Message_queue_Delete(
* @note This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open time. * @note This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open time.
*/ */
ssize_t _POSIX_Message_queue_Receive_support( ssize_t _POSIX_Message_queue_Receive_support(
mqd_t mqdes, mqd_t mqdes,
char *msg_ptr, char *msg_ptr,
size_t msg_len, size_t msg_len,
unsigned int *msg_prio, unsigned int *msg_prio,
const struct timespec *abstime, const struct timespec *abstime,
Thread_queue_Enqueue_callout enqueue_callout Thread_queue_Enqueue_callout enqueue_callout
); );
/** /**
@@ -91,19 +91,20 @@ ssize_t _POSIX_Message_queue_Receive_support(
* This routine posts a message to a specified message queue. * This routine posts a message to a specified message queue.
*/ */
int _POSIX_Message_queue_Send_support( int _POSIX_Message_queue_Send_support(
mqd_t mqdes, mqd_t mqdes,
const char *msg_ptr, const char *msg_ptr,
size_t msg_len, size_t msg_len,
unsigned int msg_prio, unsigned int msg_prio,
const struct timespec *abstime, const struct timespec *abstime,
Thread_queue_Enqueue_callout enqueue_callout Thread_queue_Enqueue_callout enqueue_callout
); );
static inline POSIX_Message_queue_Control * static inline POSIX_Message_queue_Control *
_POSIX_Message_queue_Allocate_unprotected( void ) _POSIX_Message_queue_Allocate_unprotected( void )
{ {
return (POSIX_Message_queue_Control *) return (POSIX_Message_queue_Control *) _Objects_Allocate_unprotected(
_Objects_Allocate_unprotected( &_POSIX_Message_queue_Information ); &_POSIX_Message_queue_Information
);
} }
/** /**
@@ -119,7 +120,6 @@ static inline void _POSIX_Message_queue_Free(
_Objects_Free( &_POSIX_Message_queue_Information, &the_mq->Object ); _Objects_Free( &_POSIX_Message_queue_Information, &the_mq->Object );
} }
static inline POSIX_Message_queue_Control *_POSIX_Message_queue_Get( static inline POSIX_Message_queue_Control *_POSIX_Message_queue_Get(
Objects_Id id, Objects_Id id,
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
@@ -140,14 +140,11 @@ static inline POSIX_Message_queue_Control *_POSIX_Message_queue_Get(
* by the Score. * by the Score.
*/ */
static inline CORE_message_queue_Submit_types static inline CORE_message_queue_Submit_types
_POSIX_Message_queue_Priority_to_core( _POSIX_Message_queue_Priority_to_core( unsigned int priority )
unsigned int priority
)
{ {
return (CORE_message_queue_Submit_types) priority * -1; return (CORE_message_queue_Submit_types) priority * -1;
} }
/* /*
* @brief POSIX Message Queue Convert Message Priority from Score * @brief POSIX Message Queue Convert Message Priority from Score
* *
@@ -159,13 +156,13 @@ static inline unsigned int _POSIX_Message_queue_Priority_from_core(
) )
{ {
/* absolute value without a library dependency */ /* absolute value without a library dependency */
return (unsigned int) ((priority >= 0) ? priority : -priority); return (unsigned int) ( ( priority >= 0 ) ? priority : -priority );
} }
/** /**
* @brief POSIX Message Queue Remove from Namespace * @brief POSIX Message Queue Remove from Namespace
*/ */
static inline void _POSIX_Message_queue_Namespace_remove ( static inline void _POSIX_Message_queue_Namespace_remove(
POSIX_Message_queue_Control *the_mq POSIX_Message_queue_Control *the_mq
) )
{ {
@@ -175,8 +172,7 @@ static inline void _POSIX_Message_queue_Namespace_remove (
); );
} }
static inline POSIX_Message_queue_Control * static inline POSIX_Message_queue_Control *_POSIX_Message_queue_Get_by_name(
_POSIX_Message_queue_Get_by_name(
const char *name, const char *name,
size_t *name_length_p, size_t *name_length_p,
Objects_Get_by_name_error *error Objects_Get_by_name_error *error
+35 -45
View File
@@ -49,9 +49,9 @@ extern "C" {
#endif #endif
typedef struct { typedef struct {
unsigned long flags; unsigned long flags;
Mutex_recursive_Control Recursive; Mutex_recursive_Control Recursive;
Priority_Node Priority_ceiling; Priority_Node Priority_ceiling;
const Scheduler_Control *scheduler; const Scheduler_Control *scheduler;
} POSIX_Mutex_Control; } POSIX_Mutex_Control;
@@ -123,12 +123,10 @@ static inline POSIX_Mutex_Protocol _POSIX_Mutex_Get_protocol(
unsigned long flags unsigned long flags
) )
{ {
return (POSIX_Mutex_Protocol) (flags & POSIX_MUTEX_PROTOCOL_MASK); return (POSIX_Mutex_Protocol) ( flags & POSIX_MUTEX_PROTOCOL_MASK );
} }
static inline bool _POSIX_Mutex_Is_recursive( static inline bool _POSIX_Mutex_Is_recursive( unsigned long flags )
unsigned long flags
)
{ {
return ( flags & POSIX_MUTEX_RECURSIVE ) != 0; return ( flags & POSIX_MUTEX_RECURSIVE ) != 0;
} }
@@ -176,7 +174,6 @@ static Status_Control _POSIX_Mutex_Lock_nested(
unsigned long flags unsigned long flags
) )
{ {
if ( _POSIX_Mutex_Is_recursive( flags ) ) { if ( _POSIX_Mutex_Is_recursive( flags ) ) {
++the_mutex->Recursive.nest_level; ++the_mutex->Recursive.nest_level;
return STATUS_SUCCESSFUL; return STATUS_SUCCESSFUL;
@@ -269,10 +266,10 @@ static inline const Scheduler_Control *_POSIX_Mutex_Get_scheduler(
const POSIX_Mutex_Control *the_mutex const POSIX_Mutex_Control *the_mutex
) )
{ {
#if defined(RTEMS_SMP) #if defined( RTEMS_SMP )
return the_mutex->scheduler; return the_mutex->scheduler;
#else #else
(void) the_mutex; (void) the_mutex;
return &_Scheduler_Table[ 0 ]; return &_Scheduler_Table[ 0 ];
#endif #endif
} }
@@ -315,17 +312,17 @@ static inline Status_Control _POSIX_Mutex_Ceiling_set_owner(
Thread_queue_Context *queue_context Thread_queue_Context *queue_context
) )
{ {
ISR_lock_Context lock_context; ISR_lock_Context lock_context;
Scheduler_Node *scheduler_node; Scheduler_Node *scheduler_node;
Per_CPU_Control *cpu_self; Per_CPU_Control *cpu_self;
_Thread_Wait_acquire_default_critical( owner, &lock_context ); _Thread_Wait_acquire_default_critical( owner, &lock_context );
scheduler_node = _Thread_Scheduler_get_home_node( owner ); scheduler_node = _Thread_Scheduler_get_home_node( owner );
if ( if (
_Priority_Get_priority( &scheduler_node->Wait.Priority ) _Priority_Get_priority( &scheduler_node->Wait.Priority ) <
< the_mutex->Priority_ceiling.priority the_mutex->Priority_ceiling.priority
) { ) {
_Thread_Wait_release_default_critical( owner, &lock_context ); _Thread_Wait_release_default_critical( owner, &lock_context );
_POSIX_Mutex_Release( the_mutex, queue_context ); _POSIX_Mutex_Release( the_mutex, queue_context );
@@ -334,11 +331,7 @@ static inline Status_Control _POSIX_Mutex_Ceiling_set_owner(
_POSIX_Mutex_Set_owner( the_mutex, owner ); _POSIX_Mutex_Set_owner( the_mutex, owner );
_Thread_Resource_count_increment( owner ); _Thread_Resource_count_increment( owner );
_Thread_Priority_add( _Thread_Priority_add( owner, &the_mutex->Priority_ceiling, queue_context );
owner,
&the_mutex->Priority_ceiling,
queue_context
);
_Thread_Wait_release_default_critical( owner, &lock_context ); _Thread_Wait_release_default_critical( owner, &lock_context );
cpu_self = _Thread_queue_Dispatch_disable( queue_context ); cpu_self = _Thread_queue_Dispatch_disable( queue_context );
@@ -361,10 +354,10 @@ static inline Status_Control _POSIX_Mutex_Ceiling_seize(
owner = _POSIX_Mutex_Get_owner( the_mutex ); owner = _POSIX_Mutex_Get_owner( the_mutex );
if ( owner == NULL ) { if ( owner == NULL ) {
#if defined(RTEMS_SMP) #if defined( RTEMS_SMP )
if ( if (
_Thread_Scheduler_get_home( executing ) _Thread_Scheduler_get_home( executing ) !=
!= _POSIX_Mutex_Get_scheduler( the_mutex ) _POSIX_Mutex_Get_scheduler( the_mutex )
) { ) {
_POSIX_Mutex_Release( the_mutex, queue_context ); _POSIX_Mutex_Release( the_mutex, queue_context );
return STATUS_NOT_DEFINED; return STATUS_NOT_DEFINED;
@@ -426,38 +419,35 @@ static inline Status_Control _POSIX_Mutex_Ceiling_surrender(
); );
} }
#define POSIX_MUTEX_ABSTIME_TRY_LOCK ((uintptr_t) 1) #define POSIX_MUTEX_ABSTIME_TRY_LOCK ( (uintptr_t) 1 )
int _POSIX_Mutex_Lock_support( int _POSIX_Mutex_Lock_support(
pthread_mutex_t *mutex, pthread_mutex_t *mutex,
const struct timespec *abstime, const struct timespec *abstime,
Thread_queue_Enqueue_callout enqueue_callout Thread_queue_Enqueue_callout enqueue_callout
); );
static inline POSIX_Mutex_Control *_POSIX_Mutex_Get( static inline POSIX_Mutex_Control *_POSIX_Mutex_Get( pthread_mutex_t *mutex )
pthread_mutex_t *mutex
)
{ {
return (POSIX_Mutex_Control *) mutex; return (POSIX_Mutex_Control *) mutex;
} }
bool _POSIX_Mutex_Auto_initialization( POSIX_Mutex_Control *the_mutex ); bool _POSIX_Mutex_Auto_initialization( POSIX_Mutex_Control *the_mutex );
#define POSIX_MUTEX_VALIDATE_OBJECT( the_mutex, flags ) \ #define POSIX_MUTEX_VALIDATE_OBJECT( the_mutex, flags ) \
do { \ do { \
if ( ( the_mutex ) == NULL ) { \ if ( ( the_mutex ) == NULL ) { \
return EINVAL; \ return EINVAL; \
} \ } \
flags = ( the_mutex )->flags; \ flags = ( the_mutex )->flags; \
if ( \ if ( \
( ( (uintptr_t) ( the_mutex ) ^ POSIX_MUTEX_MAGIC ) \ ( ( (uintptr_t) ( the_mutex ) ^ POSIX_MUTEX_MAGIC ) & \
& ~POSIX_MUTEX_FLAGS_MASK ) \ ~POSIX_MUTEX_FLAGS_MASK ) != ( flags & ~POSIX_MUTEX_FLAGS_MASK ) \
!= ( flags & ~POSIX_MUTEX_FLAGS_MASK ) \ ) { \
) { \ if ( !_POSIX_Mutex_Auto_initialization( the_mutex ) ) { \
if ( !_POSIX_Mutex_Auto_initialization( the_mutex ) ) { \ return EINVAL; \
return EINVAL; \ } \
} \ } \
} \
} while ( 0 ) } while ( 0 )
#ifdef __cplusplus #ifdef __cplusplus
+6 -8
View File
@@ -59,11 +59,11 @@
extern const int _POSIX_Get_by_name_error_table[ 3 ]; extern const int _POSIX_Get_by_name_error_table[ 3 ];
static inline int _POSIX_Get_by_name_error( static inline int _POSIX_Get_by_name_error( Objects_Get_by_name_error error )
Objects_Get_by_name_error error
)
{ {
_Assert( (size_t) error < RTEMS_ARRAY_SIZE( _POSIX_Get_by_name_error_table ) ); _Assert(
(size_t) error < RTEMS_ARRAY_SIZE( _POSIX_Get_by_name_error_table )
);
return _POSIX_Get_by_name_error_table[ error ]; return _POSIX_Get_by_name_error_table[ error ];
} }
@@ -79,9 +79,7 @@ static inline int _POSIX_Get_error_after_wait(
return _POSIX_Get_error( _Thread_Wait_get_status( executing ) ); return _POSIX_Get_error( _Thread_Wait_get_status( executing ) );
} }
static inline int _POSIX_Zero_or_minus_one_plus_errno( static inline int _POSIX_Zero_or_minus_one_plus_errno( Status_Control status )
Status_Control status
)
{ {
if ( status == STATUS_SUCCESSFUL ) { if ( status == STATUS_SUCCESSFUL ) {
return 0; return 0;
@@ -100,7 +98,7 @@ static inline int _POSIX_Zero_or_minus_one_plus_errno(
static inline bool _POSIX_Is_valid_pshared( int pshared ) static inline bool _POSIX_Is_valid_pshared( int pshared )
{ {
return pshared == PTHREAD_PROCESS_PRIVATE || return pshared == PTHREAD_PROCESS_PRIVATE ||
pshared == PTHREAD_PROCESS_SHARED; pshared == PTHREAD_PROCESS_SHARED;
} }
/** /**
+1 -1
View File
@@ -58,7 +58,7 @@ extern "C" {
/** /**
* This is the numerically least important POSIX priority. * This is the numerically least important POSIX priority.
*/ */
#define POSIX_SCHEDULER_MINIMUM_PRIORITY (1) #define POSIX_SCHEDULER_MINIMUM_PRIORITY ( 1 )
/** /**
* @brief Gets the maximum POSIX API priority for this scheduler instance. * @brief Gets the maximum POSIX API priority for this scheduler instance.
+3 -3
View File
@@ -46,9 +46,9 @@
*/ */
typedef struct { typedef struct {
Chain_Node Node; Chain_Node Node;
siginfo_t Info; siginfo_t Info;
} POSIX_signals_Siginfo_node; } POSIX_signals_Siginfo_node;
extern const uint32_t _POSIX_signals_Maximum_queued_signals; extern const uint32_t _POSIX_signals_Maximum_queued_signals;
+46 -34
View File
@@ -56,27 +56,47 @@
#define POSIX_SIGNALS_TQ_OPERATIONS &_Thread_queue_Operations_FIFO #define POSIX_SIGNALS_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
#define _States_Is_interruptible_signal( _states ) \ #define _States_Is_interruptible_signal( _states ) \
( ((_states) & \ ( ( ( _states ) & \
(STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL)) == \ ( STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL ) ) == \
(STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL)) ( STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL ) )
#define SIGACTION_TERMINATE \ #define SIGACTION_TERMINATE \
{ 0, SIGNAL_ALL_MASK, {_POSIX_signals_Abnormal_termination_handler} } { \
0, SIGNAL_ALL_MASK, \
{ \
_POSIX_signals_Abnormal_termination_handler \
} \
}
#define SIGACTION_IGNORE \ #define SIGACTION_IGNORE \
{ 0, SIGNAL_ALL_MASK, {SIG_IGN} } { \
#define SIGACTION_STOP \ 0, SIGNAL_ALL_MASK, \
{ 0, SIGNAL_ALL_MASK, {_POSIX_signals_Stop_handler} } { \
#define SIGACTION_CONTINUE \ SIG_IGN \
{ 0, SIGNAL_ALL_MASK, {_POSIX_signals_Continue_handler} } } \
}
#define SIGACTION_STOP \
{ \
0, SIGNAL_ALL_MASK, \
{ \
_POSIX_signals_Stop_handler \
} \
}
#define SIGACTION_CONTINUE \
{ \
0, SIGNAL_ALL_MASK, \
{ \
_POSIX_signals_Continue_handler \
} \
}
#define SIG_ARRAY_MAX (SIGRTMAX + 1) #define SIG_ARRAY_MAX ( SIGRTMAX + 1 )
/* /*
* Variables * Variables
*/ */
extern sigset_t _POSIX_signals_Pending; extern sigset_t _POSIX_signals_Pending;
extern const struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ]; extern const struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ];
@@ -110,45 +130,37 @@ static inline void _POSIX_signals_Release(
* @brief Unlock POSIX signals thread. * @brief Unlock POSIX signals thread.
*/ */
bool _POSIX_signals_Unblock_thread( bool _POSIX_signals_Unblock_thread(
Thread_Control *the_thread, Thread_Control *the_thread,
int signo, int signo,
siginfo_t *info siginfo_t *info
); );
/** /**
* @brief Clear POSIX signals. * @brief Clear POSIX signals.
*/ */
bool _POSIX_signals_Clear_signals( bool _POSIX_signals_Clear_signals(
POSIX_API_Control *api, POSIX_API_Control *api,
int signo, int signo,
siginfo_t *info, siginfo_t *info,
bool is_global, bool is_global,
bool check_blocked, bool check_blocked,
bool do_signals_acquire_release bool do_signals_acquire_release
); );
int _POSIX_signals_Send( int _POSIX_signals_Send( pid_t pid, int sig, const union sigval *value );
pid_t pid,
int sig,
const union sigval *value
);
/** /**
* @brief Set POSIX process signals. * @brief Set POSIX process signals.
*/ */
void _POSIX_signals_Set_process_signals( void _POSIX_signals_Set_process_signals( sigset_t mask );
sigset_t mask
);
void _POSIX_signals_Clear_process_signals( void _POSIX_signals_Clear_process_signals( int signo );
int signo
);
/* /*
* Default signal handlers * Default signal handlers
*/ */
#define _POSIX_signals_Stop_handler NULL #define _POSIX_signals_Stop_handler NULL
#define _POSIX_signals_Continue_handler NULL #define _POSIX_signals_Continue_handler NULL
void _POSIX_signals_Abnormal_termination_handler( int signo ); void _POSIX_signals_Abnormal_termination_handler( int signo );
+2 -2
View File
@@ -61,9 +61,9 @@ extern "C" {
*/ */
typedef struct { typedef struct {
/** This is the entry point for a POSIX initialization thread. */ /** This is the entry point for a POSIX initialization thread. */
void *(*thread_entry)(void *); void *( *thread_entry )( void * );
/** This is the stack size for a POSIX initialization thread. */ /** This is the stack size for a POSIX initialization thread. */
int stack_size; int stack_size;
} posix_initialization_threads_table; } posix_initialization_threads_table;
extern const size_t _POSIX_Threads_Minimum_stack_size; extern const size_t _POSIX_Threads_Minimum_stack_size;
+8 -12
View File
@@ -61,25 +61,20 @@ extern "C" {
extern const pthread_attr_t _POSIX_Threads_Default_attributes; extern const pthread_attr_t _POSIX_Threads_Default_attributes;
static inline void _POSIX_Threads_Copy_attributes( static inline void _POSIX_Threads_Copy_attributes(
pthread_attr_t *dst_attr, pthread_attr_t *dst_attr,
const pthread_attr_t *src_attr const pthread_attr_t *src_attr
) )
{ {
*dst_attr = *src_attr; *dst_attr = *src_attr;
_Assert( _Assert(
dst_attr->affinitysetsize == sizeof(dst_attr->affinitysetpreallocated) dst_attr->affinitysetsize == sizeof( dst_attr->affinitysetpreallocated )
); );
dst_attr->affinityset = &dst_attr->affinitysetpreallocated; dst_attr->affinityset = &dst_attr->affinitysetpreallocated;
} }
static inline void _POSIX_Threads_Initialize_attributes( static inline void _POSIX_Threads_Initialize_attributes( pthread_attr_t *attr )
pthread_attr_t *attr
)
{ {
_POSIX_Threads_Copy_attributes( _POSIX_Threads_Copy_attributes( attr, &_POSIX_Threads_Default_attributes );
attr,
&_POSIX_Threads_Default_attributes
);
} }
static inline void _POSIX_Threads_Get_sched_param_sporadic( static inline void _POSIX_Threads_Get_sched_param_sporadic(
@@ -88,10 +83,11 @@ static inline void _POSIX_Threads_Get_sched_param_sporadic(
struct sched_param *param struct sched_param *param
) )
{ {
#if defined(RTEMS_POSIX_API) #if defined( RTEMS_POSIX_API )
const POSIX_API_Control *api; const POSIX_API_Control *api;
api = (const POSIX_API_Control*) the_thread->API_Extensions[ THREAD_API_POSIX ]; api = (const POSIX_API_Control *)
the_thread->API_Extensions[ THREAD_API_POSIX ];
param->sched_ss_low_priority = _POSIX_Priority_From_core( param->sched_ss_low_priority = _POSIX_Priority_From_core(
scheduler, scheduler,
api->Sporadic.Low_priority.priority api->Sporadic.Low_priority.priority
+8 -6
View File
@@ -60,14 +60,15 @@ extern "C" {
*/ */
#define PTHREAD_MINIMUM_STACK_SIZE _POSIX_Threads_Minimum_stack_size #define PTHREAD_MINIMUM_STACK_SIZE _POSIX_Threads_Minimum_stack_size
#if defined(RTEMS_POSIX_API) #if defined( RTEMS_POSIX_API )
static inline void _POSIX_Threads_Sporadic_timer_insert( static inline void _POSIX_Threads_Sporadic_timer_insert(
Thread_Control *the_thread, Thread_Control *the_thread,
POSIX_API_Control *api POSIX_API_Control *api
) )
{ {
the_thread->CPU_budget.available = the_thread->CPU_budget.available = _Timespec_To_ticks(
_Timespec_To_ticks( &api->Sporadic.sched_ss_init_budget ); &api->Sporadic.sched_ss_init_budget
);
_Watchdog_Per_CPU_insert_ticks( _Watchdog_Per_CPU_insert_ticks(
&api->Sporadic.Timer, &api->Sporadic.Timer,
@@ -109,14 +110,15 @@ int _POSIX_Thread_Translate_sched_param(
Thread_Configuration *config Thread_Configuration *config
); );
static inline Thread_Control *_POSIX_Threads_Allocate(void) static inline Thread_Control *_POSIX_Threads_Allocate( void )
{ {
_Objects_Allocator_lock(); _Objects_Allocator_lock();
_Thread_Kill_zombies(); _Thread_Kill_zombies();
return (Thread_Control *) return (Thread_Control *) _Objects_Allocate_unprotected(
_Objects_Allocate_unprotected( &_POSIX_Threads_Information.Objects ); &_POSIX_Threads_Information.Objects
);
} }
/** @} */ /** @} */
+10 -10
View File
@@ -50,7 +50,7 @@ extern "C" {
#define POSIX_RWLOCK_MAGIC 0x9621dabdUL #define POSIX_RWLOCK_MAGIC 0x9621dabdUL
typedef struct { typedef struct {
unsigned long flags; unsigned long flags;
CORE_RWLock_Control RWLock; CORE_RWLock_Control RWLock;
} POSIX_RWLock_Control; } POSIX_RWLock_Control;
@@ -63,16 +63,16 @@ static inline POSIX_RWLock_Control *_POSIX_RWLock_Get(
bool _POSIX_RWLock_Auto_initialization( POSIX_RWLock_Control *the_rwlock ); bool _POSIX_RWLock_Auto_initialization( POSIX_RWLock_Control *the_rwlock );
#define POSIX_RWLOCK_VALIDATE_OBJECT( rw ) \ #define POSIX_RWLOCK_VALIDATE_OBJECT( rw ) \
do { \ do { \
if ( ( rw ) == NULL ) { \ if ( ( rw ) == NULL ) { \
return EINVAL; \ return EINVAL; \
} \ } \
if ( ( (uintptr_t) ( rw ) ^ POSIX_RWLOCK_MAGIC ) != ( rw )->flags ) { \ if ( ( (uintptr_t) ( rw ) ^ POSIX_RWLOCK_MAGIC ) != ( rw )->flags ) { \
if ( !_POSIX_RWLock_Auto_initialization( rw ) ) { \ if ( !_POSIX_RWLock_Auto_initialization( rw ) ) { \
return EINVAL; \ return EINVAL; \
} \ } \
} \ } \
} while ( 0 ) } while ( 0 )
#ifdef __cplusplus #ifdef __cplusplus
+13 -13
View File
@@ -61,11 +61,11 @@ extern "C" {
*/ */
typedef struct { typedef struct {
Objects_Control Object; Objects_Control Object;
sem_t Semaphore; sem_t Semaphore;
bool linked; bool linked;
uint32_t open_count; uint32_t open_count;
} POSIX_Semaphore_Control; } POSIX_Semaphore_Control;
/** /**
* @brief The POSIX Semaphore objects information. * @brief The POSIX Semaphore objects information.
@@ -82,14 +82,14 @@ extern Objects_Information _POSIX_Semaphore_Information;
* may be set). * may be set).
*/ */
#define POSIX_SEMAPHORE_INFORMATION_DEFINE( max ) \ #define POSIX_SEMAPHORE_INFORMATION_DEFINE( max ) \
OBJECTS_INFORMATION_DEFINE( \ OBJECTS_INFORMATION_DEFINE( \
_POSIX_Semaphore, \ _POSIX_Semaphore, \
OBJECTS_POSIX_API, \ OBJECTS_POSIX_API, \
OBJECTS_POSIX_SEMAPHORES, \ OBJECTS_POSIX_SEMAPHORES, \
POSIX_Semaphore_Control, \ POSIX_Semaphore_Control, \
max, \ max, \
_POSIX_PATH_MAX, \ _POSIX_PATH_MAX, \
NULL \ NULL \
) )
/** @} */ /** @} */
+20 -20
View File
@@ -53,11 +53,13 @@ extern "C" {
*/ */
#define POSIX_SEMAPHORE_MAGIC 0x5d367fe7UL #define POSIX_SEMAPHORE_MAGIC 0x5d367fe7UL
static inline POSIX_Semaphore_Control * static inline POSIX_Semaphore_Control *_POSIX_Semaphore_Allocate_unprotected(
_POSIX_Semaphore_Allocate_unprotected( void ) void
)
{ {
return (POSIX_Semaphore_Control *) return (POSIX_Semaphore_Control *) _Objects_Allocate_unprotected(
_Objects_Allocate_unprotected( &_POSIX_Semaphore_Information ); &_POSIX_Semaphore_Information
);
} }
/** /**
@@ -66,16 +68,14 @@ static inline POSIX_Semaphore_Control *
* This routine frees a semaphore control block to the * This routine frees a semaphore control block to the
* inactive chain of free semaphore control blocks. * inactive chain of free semaphore control blocks.
*/ */
static inline void _POSIX_Semaphore_Free ( static inline void _POSIX_Semaphore_Free(
POSIX_Semaphore_Control *the_semaphore POSIX_Semaphore_Control *the_semaphore
) )
{ {
_Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object ); _Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object );
} }
static inline POSIX_Semaphore_Control *_POSIX_Semaphore_Get( static inline POSIX_Semaphore_Control *_POSIX_Semaphore_Get( sem_t *sem )
sem_t *sem
)
{ {
return RTEMS_CONTAINER_OF( sem, POSIX_Semaphore_Control, Semaphore ); return RTEMS_CONTAINER_OF( sem, POSIX_Semaphore_Control, Semaphore );
} }
@@ -91,9 +91,9 @@ static inline bool _POSIX_Semaphore_Is_busy( const sem_t *sem )
} }
static inline void _POSIX_Semaphore_Initialize( static inline void _POSIX_Semaphore_Initialize(
sem_t *sem, sem_t *sem,
const char *name, const char *name,
unsigned int value unsigned int value
) )
{ {
sem->_flags = (uintptr_t) sem ^ POSIX_SEMAPHORE_MAGIC; sem->_flags = (uintptr_t) sem ^ POSIX_SEMAPHORE_MAGIC;
@@ -116,7 +116,7 @@ void _POSIX_Semaphore_Delete( POSIX_Semaphore_Control *the_semaphore );
/** /**
* @brief POSIX Semaphore Namespace Remove * @brief POSIX Semaphore Namespace Remove
*/ */
static inline void _POSIX_Semaphore_Namespace_remove ( static inline void _POSIX_Semaphore_Namespace_remove(
POSIX_Semaphore_Control *the_semaphore POSIX_Semaphore_Control *the_semaphore
) )
{ {
@@ -140,14 +140,14 @@ static inline POSIX_Semaphore_Control *_POSIX_Semaphore_Get_by_name(
); );
} }
#define POSIX_SEMAPHORE_VALIDATE_OBJECT( sem ) \ #define POSIX_SEMAPHORE_VALIDATE_OBJECT( sem ) \
do { \ do { \
if ( \ if ( \
( sem ) == NULL \ ( sem ) == NULL || \
|| ( (uintptr_t) ( sem ) ^ POSIX_SEMAPHORE_MAGIC ) != ( sem )->_flags \ ( (uintptr_t) ( sem ) ^ POSIX_SEMAPHORE_MAGIC ) != ( sem )->_flags \
) { \ ) { \
rtems_set_errno_and_return_minus_one( EINVAL ); \ rtems_set_errno_and_return_minus_one( EINVAL ); \
} \ } \
} while ( 0 ) } while ( 0 )
#ifdef __cplusplus #ifdef __cplusplus
+52 -45
View File
@@ -52,7 +52,7 @@ extern "C" {
* @{ * @{
*/ */
typedef struct POSIX_Shm_Object_operations POSIX_Shm_Object_operations; typedef struct POSIX_Shm_Object_operations POSIX_Shm_Object_operations;
extern const POSIX_Shm_Object_operations _POSIX_Shm_Object_operations; extern const POSIX_Shm_Object_operations _POSIX_Shm_Object_operations;
/** /**
* @brief Encapsulation for the storage and manipulation of shm objects. * @brief Encapsulation for the storage and manipulation of shm objects.
@@ -61,18 +61,18 @@ typedef struct {
/** /**
* @brief The handle is private for finding object storage. * @brief The handle is private for finding object storage.
*/ */
void *handle; void *handle;
/** /**
* @brief The number of bytes allocated to the object. A size of 0 with * @brief The number of bytes allocated to the object. A size of 0 with
* a handle of NULL means no object is allocated. * a handle of NULL means no object is allocated.
*/ */
size_t size; size_t size;
/** /**
* @brief Implementation-specific operations on shm objects. * @brief Implementation-specific operations on shm objects.
*/ */
const POSIX_Shm_Object_operations *ops; const POSIX_Shm_Object_operations *ops;
} POSIX_Shm_Object; } POSIX_Shm_Object;
/** /**
@@ -86,7 +86,7 @@ struct POSIX_Shm_Object_operations {
* *
* Returns 0 for success. * Returns 0 for success.
*/ */
int ( *object_create ) ( POSIX_Shm_Object *shm_obj, size_t size ); int ( *object_create )( POSIX_Shm_Object *shm_obj, size_t size );
/** /**
* @brief Changes the @a shm_obj size to @a size. * @brief Changes the @a shm_obj size to @a size.
@@ -95,7 +95,7 @@ struct POSIX_Shm_Object_operations {
* *
* Returns 0 for success. * Returns 0 for success.
*/ */
int ( *object_resize ) ( POSIX_Shm_Object *shm_obj, size_t size ); int ( *object_resize )( POSIX_Shm_Object *shm_obj, size_t size );
/** /**
* @brief Deletes the @a shm_obj. * @brief Deletes the @a shm_obj.
@@ -104,14 +104,14 @@ struct POSIX_Shm_Object_operations {
* *
* Returns 0 for success. * Returns 0 for success.
*/ */
int ( *object_delete ) ( POSIX_Shm_Object *shm_obj ); int ( *object_delete )( POSIX_Shm_Object *shm_obj );
/** /**
* @brief Copies up to @count bytes of the @a shm_obj data into @a buf. * @brief Copies up to @count bytes of the @a shm_obj data into @a buf.
* *
* Returns the number of bytes read (copied) into @a buf. * Returns the number of bytes read (copied) into @a buf.
*/ */
int ( *object_read ) ( POSIX_Shm_Object *shm_obj, void *buf, size_t count ); int ( *object_read )( POSIX_Shm_Object *shm_obj, void *buf, size_t count );
/** /**
* @brief Maps a shared memory object. * @brief Maps a shared memory object.
@@ -121,28 +121,33 @@ struct POSIX_Shm_Object_operations {
* *
* Returns the mapped address of the object. * Returns the mapped address of the object.
*/ */
void * ( *object_mmap ) ( POSIX_Shm_Object *shm_obj, size_t len, int prot, off_t off); void *( *object_mmap )(
POSIX_Shm_Object *shm_obj,
size_t len,
int prot,
off_t off
);
}; };
/** /**
* @brief Control for a POSIX Shared Memory Object * @brief Control for a POSIX Shared Memory Object
*/ */
typedef struct { typedef struct {
Objects_Control Object; Objects_Control Object;
Thread_queue_Control Wait_queue; Thread_queue_Control Wait_queue;
int reference_count; int reference_count;
POSIX_Shm_Object shm_object; POSIX_Shm_Object shm_object;
uid_t uid; uid_t uid;
gid_t gid; gid_t gid;
mode_t mode; mode_t mode;
int oflag; int oflag;
time_t atime; time_t atime;
time_t mtime; time_t mtime;
time_t ctime; time_t ctime;
} POSIX_Shm_Control; } POSIX_Shm_Control;
/** /**
@@ -160,14 +165,14 @@ extern Objects_Information _POSIX_Shm_Information;
* may be set). * may be set).
*/ */
#define POSIX_SHM_INFORMATION_DEFINE( max ) \ #define POSIX_SHM_INFORMATION_DEFINE( max ) \
OBJECTS_INFORMATION_DEFINE( \ OBJECTS_INFORMATION_DEFINE( \
_POSIX_Shm, \ _POSIX_Shm, \
OBJECTS_POSIX_API, \ OBJECTS_POSIX_API, \
OBJECTS_POSIX_SHMS, \ OBJECTS_POSIX_SHMS, \
POSIX_Shm_Control, \ POSIX_Shm_Control, \
max, \ max, \
_POSIX_PATH_MAX, \ _POSIX_PATH_MAX, \
NULL \ NULL \
) )
/** /**
@@ -175,20 +180,22 @@ extern Objects_Information _POSIX_Shm_Information;
*/ */
extern int _POSIX_Shm_Object_create_from_workspace( extern int _POSIX_Shm_Object_create_from_workspace(
POSIX_Shm_Object *shm_obj, POSIX_Shm_Object *shm_obj,
size_t size size_t size
); );
/** /**
* @brief object_delete operation for shm objects stored in RTEMS Workspace. * @brief object_delete operation for shm objects stored in RTEMS Workspace.
*/ */
extern int _POSIX_Shm_Object_delete_from_workspace( POSIX_Shm_Object *shm_obj ); extern int _POSIX_Shm_Object_delete_from_workspace(
POSIX_Shm_Object *shm_obj
);
/** /**
* @brief object_resize operation for shm objects stored in RTEMS Workspace. * @brief object_resize operation for shm objects stored in RTEMS Workspace.
*/ */
extern int _POSIX_Shm_Object_resize_from_workspace( extern int _POSIX_Shm_Object_resize_from_workspace(
POSIX_Shm_Object *shm_obj, POSIX_Shm_Object *shm_obj,
size_t size size_t size
); );
/** /**
@@ -196,18 +203,18 @@ extern int _POSIX_Shm_Object_resize_from_workspace(
*/ */
extern int _POSIX_Shm_Object_read_from_workspace( extern int _POSIX_Shm_Object_read_from_workspace(
POSIX_Shm_Object *shm_obj, POSIX_Shm_Object *shm_obj,
void *buf, void *buf,
size_t count size_t count
); );
/** /**
* @brief object_mmap operation for shm objects stored in RTEMS Workspace. * @brief object_mmap operation for shm objects stored in RTEMS Workspace.
*/ */
extern void * _POSIX_Shm_Object_mmap_from_workspace( extern void *_POSIX_Shm_Object_mmap_from_workspace(
POSIX_Shm_Object *shm_obj, POSIX_Shm_Object *shm_obj,
size_t len, size_t len,
int prot, int prot,
off_t off off_t off
); );
/** /**
@@ -215,7 +222,7 @@ extern void * _POSIX_Shm_Object_mmap_from_workspace(
*/ */
extern int _POSIX_Shm_Object_create_from_heap( extern int _POSIX_Shm_Object_create_from_heap(
POSIX_Shm_Object *shm_obj, POSIX_Shm_Object *shm_obj,
size_t size size_t size
); );
/** /**
@@ -228,7 +235,7 @@ extern int _POSIX_Shm_Object_delete_from_heap( POSIX_Shm_Object *shm_obj );
*/ */
extern int _POSIX_Shm_Object_resize_from_heap( extern int _POSIX_Shm_Object_resize_from_heap(
POSIX_Shm_Object *shm_obj, POSIX_Shm_Object *shm_obj,
size_t size size_t size
); );
/** /**
@@ -236,18 +243,18 @@ extern int _POSIX_Shm_Object_resize_from_heap(
*/ */
extern int _POSIX_Shm_Object_read_from_heap( extern int _POSIX_Shm_Object_read_from_heap(
POSIX_Shm_Object *shm_obj, POSIX_Shm_Object *shm_obj,
void *buf, void *buf,
size_t count size_t count
); );
/** /**
* @brief object_mmap operation for shm objects stored in C program heap. * @brief object_mmap operation for shm objects stored in C program heap.
*/ */
extern void * _POSIX_Shm_Object_mmap_from_heap( extern void *_POSIX_Shm_Object_mmap_from_heap(
POSIX_Shm_Object *shm_obj, POSIX_Shm_Object *shm_obj,
size_t len, size_t len,
int prot, int prot,
off_t off off_t off
); );
/** @} */ /** @} */
+16 -23
View File
@@ -52,8 +52,9 @@ extern "C" {
static inline POSIX_Shm_Control *_POSIX_Shm_Allocate_unprotected( void ) static inline POSIX_Shm_Control *_POSIX_Shm_Allocate_unprotected( void )
{ {
return (POSIX_Shm_Control *) return (POSIX_Shm_Control *) _Objects_Allocate_unprotected(
_Objects_Allocate_unprotected( &_POSIX_Shm_Information ); &_POSIX_Shm_Information
);
} }
/** /**
@@ -61,9 +62,7 @@ static inline POSIX_Shm_Control *_POSIX_Shm_Allocate_unprotected( void )
* *
* This routine frees a shm control block. * This routine frees a shm control block.
*/ */
static inline void _POSIX_Shm_Free ( static inline void _POSIX_Shm_Free( POSIX_Shm_Control *the_shm )
POSIX_Shm_Control *the_shm
)
{ {
_Objects_Free( &_POSIX_Shm_Information, &the_shm->Object ); _Objects_Free( &_POSIX_Shm_Information, &the_shm->Object );
} }
@@ -82,18 +81,14 @@ static inline POSIX_Shm_Control *_POSIX_Shm_Get_by_name(
); );
} }
static inline void _POSIX_Shm_Update_atime( static inline void _POSIX_Shm_Update_atime( POSIX_Shm_Control *shm )
POSIX_Shm_Control *shm
)
{ {
struct timeval now; struct timeval now;
gettimeofday( &now, 0 ); gettimeofday( &now, 0 );
shm->atime = now.tv_sec; shm->atime = now.tv_sec;
} }
static inline void _POSIX_Shm_Update_mtime_ctime( static inline void _POSIX_Shm_Update_mtime_ctime( POSIX_Shm_Control *shm )
POSIX_Shm_Control *shm
)
{ {
struct timeval now; struct timeval now;
gettimeofday( &now, 0 ); gettimeofday( &now, 0 );
@@ -101,32 +96,30 @@ static inline void _POSIX_Shm_Update_mtime_ctime(
shm->ctime = now.tv_sec; shm->ctime = now.tv_sec;
} }
static inline POSIX_Shm_Control* iop_to_shm( rtems_libio_t *iop ) static inline POSIX_Shm_Control *iop_to_shm( rtems_libio_t *iop )
{ {
return (POSIX_Shm_Control*) iop->data1; return (POSIX_Shm_Control *) iop->data1;
} }
static inline POSIX_Shm_Control* loc_to_shm( static inline POSIX_Shm_Control *loc_to_shm(
const rtems_filesystem_location_info_t *loc const rtems_filesystem_location_info_t *loc
) )
{ {
return (POSIX_Shm_Control*) loc->node_access; return (POSIX_Shm_Control *) loc->node_access;
} }
static inline int POSIX_Shm_Attempt_delete( static inline int POSIX_Shm_Attempt_delete( POSIX_Shm_Control *shm )
POSIX_Shm_Control* shm
)
{ {
Objects_Control *obj; Objects_Control *obj;
ISR_lock_Context lock_ctx; ISR_lock_Context lock_ctx;
int err; int err;
err = 0; err = 0;
_Objects_Allocator_lock(); _Objects_Allocator_lock();
--shm->reference_count; --shm->reference_count;
if ( shm->reference_count == 0 ) { if ( shm->reference_count == 0 ) {
if ( (*shm->shm_object.ops->object_delete)( &shm->shm_object ) != 0 ) { if ( ( *shm->shm_object.ops->object_delete )( &shm->shm_object ) != 0 ) {
err = EIO; err = EIO;
} }
} }
+6 -10
View File
@@ -45,21 +45,17 @@
* Currently 32 signals numbered 1-32 are defined * Currently 32 signals numbered 1-32 are defined
*/ */
#define SIGNAL_EMPTY_MASK 0x00000000L #define SIGNAL_EMPTY_MASK 0x00000000L
#define SIGNAL_ALL_MASK 0xffffffffL #define SIGNAL_ALL_MASK 0xffffffffL
static inline sigset_t signo_to_mask( static inline sigset_t signo_to_mask( uint32_t sig )
uint32_t sig
)
{ {
return 1u << (sig - 1); return 1u << ( sig - 1 );
} }
static inline bool is_valid_signo( static inline bool is_valid_signo( int signo )
int signo
)
{ {
return ((signo) >= 1 && (signo) <= 32 ); return ( ( signo ) >= 1 && ( signo ) <= 32 );
} }
#endif #endif
+2 -2
View File
@@ -44,7 +44,7 @@
#include <rtems/score/isrlevel.h> #include <rtems/score/isrlevel.h>
#if defined(RTEMS_SMP) #if defined( RTEMS_SMP )
#include <rtems/score/percpu.h> #include <rtems/score/percpu.h>
#include <rtems/score/smplockticket.h> #include <rtems/score/smplockticket.h>
#endif #endif
@@ -54,7 +54,7 @@ extern "C" {
#endif #endif
typedef struct { typedef struct {
#if defined(RTEMS_SMP) #if defined( RTEMS_SMP )
SMP_ticket_lock_Control Lock; SMP_ticket_lock_Control Lock;
#else #else
unsigned int reserved[ 2 ]; unsigned int reserved[ 2 ];
+4 -4
View File
@@ -54,7 +54,7 @@
extern "C" { extern "C" {
#endif #endif
#if defined(RTEMS_POSIX_API) #if defined( RTEMS_POSIX_API )
/** /**
* This defines the POSIX API support structure associated with * This defines the POSIX API support structure associated with
* each thread in a system with POSIX configured. * each thread in a system with POSIX configured.
@@ -98,14 +98,14 @@ typedef struct {
} Sporadic; } Sporadic;
/** This is the set of signals which are currently unblocked. */ /** This is the set of signals which are currently unblocked. */
sigset_t signals_unblocked; sigset_t signals_unblocked;
/** This is the set of signals which are currently pending. */ /** This is the set of signals which are currently pending. */
sigset_t signals_pending; sigset_t signals_pending;
/** /**
* @brief Signal post-switch action in case signals are pending. * @brief Signal post-switch action in case signals are pending.
*/ */
Thread_Action Signal_action; Thread_Action Signal_action;
} POSIX_API_Control; } POSIX_API_Control;
#endif #endif
+9 -12
View File
@@ -84,14 +84,14 @@ extern Objects_Information _POSIX_Timer_Information;
* may be set). * may be set).
*/ */
#define POSIX_TIMER_INFORMATION_DEFINE( max ) \ #define POSIX_TIMER_INFORMATION_DEFINE( max ) \
OBJECTS_INFORMATION_DEFINE( \ OBJECTS_INFORMATION_DEFINE( \
_POSIX_Timer, \ _POSIX_Timer, \
OBJECTS_POSIX_API, \ OBJECTS_POSIX_API, \
OBJECTS_POSIX_TIMERS, \ OBJECTS_POSIX_TIMERS, \
POSIX_Timer_Control, \ POSIX_Timer_Control, \
max, \ max, \
OBJECTS_NO_STRING_NAME, \ OBJECTS_NO_STRING_NAME, \
NULL \ NULL \
) )
/** /**
@@ -107,10 +107,7 @@ extern Objects_Information _POSIX_Timer_Information;
* *
* @return 0 if @a clock_id is allowed for use. Otherwise an errno value. * @return 0 if @a clock_id is allowed for use. Otherwise an errno value.
*/ */
int _POSIX_Timer_Is_allowed( int _POSIX_Timer_Is_allowed( clockid_t clock_id );
clockid_t clock_id
);
/** @} */ /** @} */
+15 -17
View File
@@ -47,26 +47,26 @@ extern "C" {
#endif #endif
/** Timer is free */ /** Timer is free */
#define POSIX_TIMER_STATE_FREE 0x01 #define POSIX_TIMER_STATE_FREE 0x01
/** Created timer but not running */ /** Created timer but not running */
#define POSIX_TIMER_STATE_CREATE_NEW 0x02 #define POSIX_TIMER_STATE_CREATE_NEW 0x02
/** Created timer and running */ /** Created timer and running */
#define POSIX_TIMER_STATE_CREATE_RUN 0x03 #define POSIX_TIMER_STATE_CREATE_RUN 0x03
/** Created, ran and stopped timer */ /** Created, ran and stopped timer */
#define POSIX_TIMER_STATE_CREATE_STOP 0x04 #define POSIX_TIMER_STATE_CREATE_STOP 0x04
/** Indicates that the fire time is relative to the current one */ /** Indicates that the fire time is relative to the current one */
#define POSIX_TIMER_RELATIVE 0 #define POSIX_TIMER_RELATIVE 0
/* /*
* POSIX defines TIMER_ABSTIME but no constant for relative. So * POSIX defines TIMER_ABSTIME but no constant for relative. So
* we have one internally but we need to be careful it has a different * we have one internally but we need to be careful it has a different
* value. * value.
*/ */
#if (POSIX_TIMER_RELATIVE == TIMER_ABSTIME) #if ( POSIX_TIMER_RELATIVE == TIMER_ABSTIME )
#error "POSIX_TIMER_RELATIVE == TIMER_ABSTIME" #error "POSIX_TIMER_RELATIVE == TIMER_ABSTIME"
#endif #endif
@@ -78,7 +78,9 @@ extern "C" {
*/ */
static inline POSIX_Timer_Control *_POSIX_Timer_Allocate( void ) static inline POSIX_Timer_Control *_POSIX_Timer_Allocate( void )
{ {
return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information ); return (POSIX_Timer_Control *) _Objects_Allocate(
&_POSIX_Timer_Information
);
} }
/** /**
@@ -87,9 +89,7 @@ static inline POSIX_Timer_Control *_POSIX_Timer_Allocate( void )
* This routine frees a timer control block to the * This routine frees a timer control block to the
* inactive chain of free timer control blocks. * inactive chain of free timer control blocks.
*/ */
static inline void _POSIX_Timer_Free ( static inline void _POSIX_Timer_Free( POSIX_Timer_Control *the_timer )
POSIX_Timer_Control *the_timer
)
{ {
_Objects_Free( &_POSIX_Timer_Information, &the_timer->Object ); _Objects_Free( &_POSIX_Timer_Information, &the_timer->Object );
} }
@@ -105,16 +105,14 @@ void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog );
* is set to OBJECTS_LOCAL. Otherwise, location is set * is set to OBJECTS_LOCAL. Otherwise, location is set
* to OBJECTS_ERROR and the returned value is undefined. * to OBJECTS_ERROR and the returned value is undefined.
*/ */
static inline POSIX_Timer_Control *_POSIX_Timer_Get ( static inline POSIX_Timer_Control *_POSIX_Timer_Get(
timer_t id, timer_t id,
ISR_lock_Context *lock_context ISR_lock_Context *lock_context
) )
{ {
return (POSIX_Timer_Control *) _Objects_Get( return (
(Objects_Id) id, POSIX_Timer_Control *
lock_context, ) _Objects_Get( (Objects_Id) id, lock_context, &_POSIX_Timer_Information );
&_POSIX_Timer_Information
);
} }
static inline Per_CPU_Control *_POSIX_Timer_Acquire_critical( static inline Per_CPU_Control *_POSIX_Timer_Acquire_critical(