From 068a8240c67cb1dff6237c475828123dae0889c3 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 30 Apr 2010 08:55:41 +0000 Subject: 2010-04-30 Sebastian Huber * libcsupport/include/rtems/libio_.h, libcsupport/src/envlock.c, libcsupport/src/libio.c: Added and use rtems_libio_lock() and rtems_libio_unlock(). Cleaned up includes and declarations. Do not use RTEMS_NO_PRIORITY for unused ceiling priority in rtems_semaphore_create(). --- cpukit/libcsupport/include/rtems/libio_.h | 10 +++++++ cpukit/libcsupport/src/envlock.c | 4 +-- cpukit/libcsupport/src/libio.c | 49 +++++++++++-------------------- 3 files changed, 29 insertions(+), 34 deletions(-) (limited to 'cpukit/libcsupport') diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h index 7aada77622..27609023b5 100644 --- a/cpukit/libcsupport/include/rtems/libio_.h +++ b/cpukit/libcsupport/include/rtems/libio_.h @@ -204,6 +204,16 @@ extern rtems_user_env_t rtems_global_user_env; rtems_status_code rtems_libio_set_private_env(void); rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ; +static inline void rtems_libio_lock( void ) +{ + rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); +} + +static inline void rtems_libio_unlock( void ) +{ + rtems_semaphore_release( rtems_libio_semaphore ); +} + /* * File Descriptor Routine Prototypes */ diff --git a/cpukit/libcsupport/src/envlock.c b/cpukit/libcsupport/src/envlock.c index 32fb78f0d5..9594e0abe3 100644 --- a/cpukit/libcsupport/src/envlock.c +++ b/cpukit/libcsupport/src/envlock.c @@ -97,12 +97,12 @@ __env_unlock(struct _reent *r) void __env_lock(struct _reent *r __attribute__((unused))) { - rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); + rtems_libio_lock(); } void __env_unlock(struct _reent *r __attribute__((unused))) { - rtems_semaphore_release( rtems_libio_semaphore ); + rtems_libio_unlock(); } #endif diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c index 6ae05e18a6..d080d01596 100644 --- a/cpukit/libcsupport/src/libio.c +++ b/cpukit/libcsupport/src/libio.c @@ -17,14 +17,15 @@ #include "config.h" #endif -#include /* libio_.h pulls in rtems */ -#include -#include /* assoc.h not included by rtems.h */ +#include +#include +#include +#include +#include -#include /* O_RDONLY, et.al. */ -#include /* O_RDONLY, et.al. */ -#include -#include +#include +#include +#include /* define this to alias O_NDELAY to O_NONBLOCK, i.e., * O_NDELAY is accepted on input but fcntl(F_GETFL) returns @@ -40,22 +41,6 @@ */ #undef ACCEPT_O_NDELAY_ALIAS -#include -#include /* strcmp */ -#include -#include /* calloc() */ - -#include /* libio.h not pulled in by rtems */ - -/* - * File descriptor Table Information - */ - -extern uint32_t rtems_libio_number_iops; -extern rtems_id rtems_libio_semaphore; -extern rtems_libio_t *rtems_libio_iops; -extern rtems_libio_t *rtems_libio_iop_freelist; - /* * rtems_libio_fcntl_flags * @@ -151,14 +136,14 @@ rtems_libio_t *rtems_libio_allocate( void ) rtems_status_code rc; rtems_id sema; - rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); + rtems_libio_lock(); if (rtems_libio_iop_freelist) { rc = rtems_semaphore_create( RTEMS_LIBIO_IOP_SEM(rtems_libio_iop_freelist - rtems_libio_iops), 1, RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, - RTEMS_NO_PRIORITY, + 0, &sema ); if (rc != RTEMS_SUCCESSFUL) @@ -176,7 +161,7 @@ failed: iop = 0; done: - rtems_semaphore_release( rtems_libio_semaphore ); + rtems_libio_unlock(); return iop; } @@ -191,7 +176,7 @@ void rtems_libio_free( rtems_libio_t *iop ) { - rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); + rtems_libio_lock(); if (iop->sem) rtems_semaphore_delete(iop->sem); @@ -200,7 +185,7 @@ void rtems_libio_free( iop->data1 = rtems_libio_iop_freelist; rtems_libio_iop_freelist = iop; - rtems_semaphore_release(rtems_libio_semaphore); + rtems_libio_unlock(); } /* @@ -222,7 +207,7 @@ int rtems_libio_is_open_files_in_fs( int result = 0; uint32_t i; - rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); + rtems_libio_lock(); /* * Look for any active file descriptor entry. @@ -244,7 +229,7 @@ int rtems_libio_is_open_files_in_fs( } } - rtems_semaphore_release( rtems_libio_semaphore ); + rtems_libio_unlock(); return result; } @@ -266,7 +251,7 @@ int rtems_libio_is_file_open( int result=0; uint32_t i; - rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); + rtems_libio_lock(); /* * Look for any active file descriptor entry. @@ -287,7 +272,7 @@ int rtems_libio_is_file_open( } } - rtems_semaphore_release( rtems_libio_semaphore ); + rtems_libio_unlock(); return result; } -- cgit v1.2.3