* 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().
This commit is contained in:
Sebastian Huber
2010-04-30 08:55:41 +00:00
parent ebf2bc6cbc
commit 068a8240c6
4 changed files with 37 additions and 34 deletions

View File

@@ -1,3 +1,11 @@
2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
* 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().
2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de> 2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libnetworking/lib/ftpfs.c: Format changes. Fixed pathname * libnetworking/lib/ftpfs.c: Format changes. Fixed pathname

View File

@@ -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_set_private_env(void);
rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ; 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 * File Descriptor Routine Prototypes
*/ */

View File

@@ -97,12 +97,12 @@ __env_unlock(struct _reent *r)
void void
__env_lock(struct _reent *r __attribute__((unused))) __env_lock(struct _reent *r __attribute__((unused)))
{ {
rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); rtems_libio_lock();
} }
void void
__env_unlock(struct _reent *r __attribute__((unused))) __env_unlock(struct _reent *r __attribute__((unused)))
{ {
rtems_semaphore_release( rtems_libio_semaphore ); rtems_libio_unlock();
} }
#endif #endif

View File

@@ -17,14 +17,15 @@
#include "config.h" #include "config.h"
#endif #endif
#include <rtems/libio_.h> /* libio_.h pulls in rtems */ #include <fcntl.h>
#include <rtems.h> #include <stdio.h>
#include <rtems/assoc.h> /* assoc.h not included by rtems.h */ #include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h> /* O_RDONLY, et.al. */ #include <rtems.h>
#include <fcntl.h> /* O_RDONLY, et.al. */ #include <rtems/libio_.h>
#include <assert.h> #include <rtems/assoc.h>
#include <errno.h>
/* define this to alias O_NDELAY to O_NONBLOCK, i.e., /* define this to alias O_NDELAY to O_NONBLOCK, i.e.,
* O_NDELAY is accepted on input but fcntl(F_GETFL) returns * O_NDELAY is accepted on input but fcntl(F_GETFL) returns
@@ -40,22 +41,6 @@
*/ */
#undef ACCEPT_O_NDELAY_ALIAS #undef ACCEPT_O_NDELAY_ALIAS
#include <errno.h>
#include <string.h> /* strcmp */
#include <unistd.h>
#include <stdlib.h> /* calloc() */
#include <rtems/libio.h> /* 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 * rtems_libio_fcntl_flags
* *
@@ -151,14 +136,14 @@ rtems_libio_t *rtems_libio_allocate( void )
rtems_status_code rc; rtems_status_code rc;
rtems_id sema; rtems_id sema;
rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); rtems_libio_lock();
if (rtems_libio_iop_freelist) { if (rtems_libio_iop_freelist) {
rc = rtems_semaphore_create( rc = rtems_semaphore_create(
RTEMS_LIBIO_IOP_SEM(rtems_libio_iop_freelist - rtems_libio_iops), RTEMS_LIBIO_IOP_SEM(rtems_libio_iop_freelist - rtems_libio_iops),
1, 1,
RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
RTEMS_NO_PRIORITY, 0,
&sema &sema
); );
if (rc != RTEMS_SUCCESSFUL) if (rc != RTEMS_SUCCESSFUL)
@@ -176,7 +161,7 @@ failed:
iop = 0; iop = 0;
done: done:
rtems_semaphore_release( rtems_libio_semaphore ); rtems_libio_unlock();
return iop; return iop;
} }
@@ -191,7 +176,7 @@ void rtems_libio_free(
rtems_libio_t *iop rtems_libio_t *iop
) )
{ {
rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); rtems_libio_lock();
if (iop->sem) if (iop->sem)
rtems_semaphore_delete(iop->sem); rtems_semaphore_delete(iop->sem);
@@ -200,7 +185,7 @@ void rtems_libio_free(
iop->data1 = rtems_libio_iop_freelist; iop->data1 = rtems_libio_iop_freelist;
rtems_libio_iop_freelist = iop; 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; int result = 0;
uint32_t i; uint32_t i;
rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); rtems_libio_lock();
/* /*
* Look for any active file descriptor entry. * 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; return result;
} }
@@ -266,7 +251,7 @@ int rtems_libio_is_file_open(
int result=0; int result=0;
uint32_t i; uint32_t i;
rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); rtems_libio_lock();
/* /*
* Look for any active file descriptor entry. * 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; return result;
} }