From 55568af2e70d7026b57fe54ce14f6980a37c4e08 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 26 Mar 2007 22:31:31 +0000 Subject: 2007-03-26 Joel Sherrill * libcsupport/src/assoc.c, libcsupport/src/libio.c, libcsupport/src/write.c: Split files to shrink minimum.exe. Hopefully this will not be deemed necessary to commit to the 4.7 branch. * libcsupport/src/assoclocalbyname.c, libcsupport/src/assoclocalbyremote.c, libcsupport/src/assoclocalbyremotebitfield.c, libcsupport/src/assocnamebylocal.c, libcsupport/src/assocnamebylocalbitfield.c, libcsupport/src/assocnamebyremote.c, libcsupport/src/assocnamebyremotebitfield.c, libcsupport/src/assocptrbylocal.c, libcsupport/src/assocptrbyname.c, libcsupport/src/assocptrbyremote.c, libcsupport/src/assocremotebylocal.c, libcsupport/src/assocremotebylocalbitfield.c, libcsupport/src/assocremotebyname.c, libcsupport/src/libio_init.c, libcsupport/src/write_r.c: New files. --- cpukit/ChangeLog | 19 ++ cpukit/libcsupport/src/assoc.c | 245 ++------------------- cpukit/libcsupport/src/assoclocalbyname.c | 31 +++ cpukit/libcsupport/src/assoclocalbyremote.c | 31 +++ .../libcsupport/src/assoclocalbyremotebitfield.c | 34 +++ cpukit/libcsupport/src/assocnamebylocal.c | 31 +++ cpukit/libcsupport/src/assocnamebylocalbitfield.c | 38 ++++ cpukit/libcsupport/src/assocnamebyremote.c | 33 +++ cpukit/libcsupport/src/assocnamebyremotebitfield.c | 39 ++++ cpukit/libcsupport/src/assocptrbylocal.c | 34 +++ cpukit/libcsupport/src/assocptrbyname.c | 35 +++ cpukit/libcsupport/src/assocptrbyremote.c | 34 +++ cpukit/libcsupport/src/assocremotebylocal.c | 31 +++ .../libcsupport/src/assocremotebylocalbitfield.c | 33 +++ cpukit/libcsupport/src/assocremotebyname.c | 31 +++ cpukit/libcsupport/src/libio.c | 55 +---- cpukit/libcsupport/src/libio_init.c | 90 ++++++++ cpukit/libcsupport/src/write.c | 23 +- cpukit/libcsupport/src/write_r.c | 40 ++++ 19 files changed, 602 insertions(+), 305 deletions(-) create mode 100644 cpukit/libcsupport/src/assoclocalbyname.c create mode 100644 cpukit/libcsupport/src/assoclocalbyremote.c create mode 100644 cpukit/libcsupport/src/assoclocalbyremotebitfield.c create mode 100644 cpukit/libcsupport/src/assocnamebylocal.c create mode 100644 cpukit/libcsupport/src/assocnamebylocalbitfield.c create mode 100644 cpukit/libcsupport/src/assocnamebyremote.c create mode 100644 cpukit/libcsupport/src/assocnamebyremotebitfield.c create mode 100644 cpukit/libcsupport/src/assocptrbylocal.c create mode 100644 cpukit/libcsupport/src/assocptrbyname.c create mode 100644 cpukit/libcsupport/src/assocptrbyremote.c create mode 100644 cpukit/libcsupport/src/assocremotebylocal.c create mode 100644 cpukit/libcsupport/src/assocremotebylocalbitfield.c create mode 100644 cpukit/libcsupport/src/assocremotebyname.c create mode 100644 cpukit/libcsupport/src/libio_init.c create mode 100644 cpukit/libcsupport/src/write_r.c diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index baa3cc3591..267af03af7 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,22 @@ +2007-03-26 Joel Sherrill + + * libcsupport/src/assoc.c, libcsupport/src/libio.c, + libcsupport/src/write.c: Split files to shrink minimum.exe. Hopefully + this will not be deemed necessary to commit to the 4.7 branch. + * libcsupport/src/assoclocalbyname.c, + libcsupport/src/assoclocalbyremote.c, + libcsupport/src/assoclocalbyremotebitfield.c, + libcsupport/src/assocnamebylocal.c, + libcsupport/src/assocnamebylocalbitfield.c, + libcsupport/src/assocnamebyremote.c, + libcsupport/src/assocnamebyremotebitfield.c, + libcsupport/src/assocptrbylocal.c, libcsupport/src/assocptrbyname.c, + libcsupport/src/assocptrbyremote.c, + libcsupport/src/assocremotebylocal.c, + libcsupport/src/assocremotebylocalbitfield.c, + libcsupport/src/assocremotebyname.c, libcsupport/src/libio_init.c, + libcsupport/src/write_r.c: New files. + 2007-03-26 Joel Sherrill * libcsupport/src/__gettod.c: Replace incorrect comment about timezone diff --git a/cpukit/libcsupport/src/assoc.c b/cpukit/libcsupport/src/assoc.c index 58c0b2e73f..457f57e434 100644 --- a/cpukit/libcsupport/src/assoc.c +++ b/cpukit/libcsupport/src/assoc.c @@ -9,246 +9,27 @@ #include "config.h" #endif +#define INSIDE_ASSOC + #include #include #include /* strcat, strcmp */ -#define STREQ(a,b) (strcmp((a), (b)) == 0) -#define rtems_assoc_is_default(ap) ((ap)->name && STREQ(ap->name, RTEMS_ASSOC_DEFAULT_NAME)) - -const rtems_assoc_t * -rtems_assoc_ptr_by_name( - const rtems_assoc_t *ap, - const char *name - ) -{ - const rtems_assoc_t *default_ap = 0; - - if (rtems_assoc_is_default(ap)) - default_ap = ap++; - - for ( ; ap->name; ap++) - if (strcmp(ap->name, name) == 0) - return ap; - - return default_ap; -} - -const rtems_assoc_t * -rtems_assoc_ptr_by_local( - const rtems_assoc_t *ap, - uint32_t local_value - ) -{ - const rtems_assoc_t *default_ap = 0; - - if (rtems_assoc_is_default(ap)) - default_ap = ap++; - - for ( ; ap->name; ap++) - if (ap->local_value == local_value) - return ap; - - return default_ap; -} - - -const rtems_assoc_t * -rtems_assoc_ptr_by_remote( - const rtems_assoc_t *ap, - uint32_t remote_value - ) -{ - const rtems_assoc_t *default_ap = 0; - - if (rtems_assoc_is_default(ap)) - default_ap = ap++; - - for ( ; ap->name; ap++) - if (ap->remote_value == remote_value) - return ap; - - return default_ap; -} - - -/* - * Get values - */ - -uint32_t -rtems_assoc_remote_by_local( - const rtems_assoc_t *ap, - uint32_t local_value - ) -{ - const rtems_assoc_t *nap; - nap = rtems_assoc_ptr_by_local(ap, local_value); - if (nap) - return nap->remote_value; - - return 0; -} - -uint32_t -rtems_assoc_local_by_remote( - const rtems_assoc_t *ap, - uint32_t remote_value - ) -{ - const rtems_assoc_t *nap; - nap = rtems_assoc_ptr_by_remote(ap, remote_value); - if (nap) - return nap->local_value; - - return 0; -} - -uint32_t -rtems_assoc_remote_by_name( - const rtems_assoc_t *ap, - const char *name - ) -{ - const rtems_assoc_t *nap; - nap = rtems_assoc_ptr_by_name(ap, name); - if (nap) - return nap->remote_value; - - return 0; -} - -uint32_t -rtems_assoc_local_by_name( - const rtems_assoc_t *ap, - const char *name - ) -{ - const rtems_assoc_t *nap; - nap = rtems_assoc_ptr_by_name(ap, name); - if (nap) - return nap->local_value; - - return 0; -} - -/* - * what to return if a value is not found - * this is not reentrant, but it really shouldn't be invoked anyway - */ - -const char *rtems_assoc_name_bad( - uint32_t bad_value -); - -/* body in separate file to reduce dependency on printf */ - - -const char * -rtems_assoc_name_by_local( - const rtems_assoc_t *ap, - uint32_t local_value - ) -{ - const rtems_assoc_t *nap; - nap = rtems_assoc_ptr_by_local(ap, local_value); - if (nap) - return nap->name; - - return rtems_assoc_name_bad(local_value); -} - -const char * -rtems_assoc_name_by_remote( - const rtems_assoc_t *ap, - uint32_t remote_value - ) -{ - const rtems_assoc_t *nap; - nap = rtems_assoc_ptr_by_remote(ap, remote_value); - if (nap) - return nap->name; - - return rtems_assoc_name_bad(remote_value); -} - -/* - * Bitfield functions assume just 1 bit set in each of remote and local - * entries; they do not check for this. - */ - -uint32_t rtems_assoc_remote_by_local_bitfield( - const rtems_assoc_t *ap, - uint32_t local_value - ) -{ - uint32_t b; - uint32_t remote_value = 0; - - for (b = 1; b; b <<= 1) - if (b & local_value) - remote_value |= rtems_assoc_remote_by_local(ap, b); - - return remote_value; -} - - -uint32_t rtems_assoc_local_by_remote_bitfield( - const rtems_assoc_t *ap, - uint32_t remote_value - ) -{ - uint32_t b; - uint32_t local_value = 0; - - for (b = 1; b; b <<= 1) - if (b & remote_value) - local_value |= rtems_assoc_local_by_remote(ap, b); - - return local_value; -} - -char * -rtems_assoc_name_by_remote_bitfield( - const rtems_assoc_t *ap, - uint32_t value, - char *buffer - ) -{ - uint32_t b; - - *buffer = 0; - - for (b = 1; b; b <<= 1) - if (b & value) - { - if (*buffer) - strcat(buffer, " "); - strcat(buffer, rtems_assoc_name_by_remote(ap, b)); - } - - return buffer; -} -char * -rtems_assoc_name_by_local_bitfield( - const rtems_assoc_t *ap, - uint32_t value, - char *buffer - ) +const rtems_assoc_t *rtems_assoc_ptr_by_name( + const rtems_assoc_t *ap, + const char *name +) { - uint32_t b; + const rtems_assoc_t *default_ap = 0; - *buffer = 0; + if (rtems_assoc_is_default(ap)) + default_ap = ap++; - for (b = 1; b; b <<= 1) - if (b & value) - { - if (*buffer) - strcat(buffer, " "); - strcat(buffer, rtems_assoc_name_by_local(ap, b)); - } + for ( ; ap->name; ap++) + if (strcmp(ap->name, name) == 0) + return ap; - return buffer; + return default_ap; } diff --git a/cpukit/libcsupport/src/assoclocalbyname.c b/cpukit/libcsupport/src/assoclocalbyname.c new file mode 100644 index 0000000000..28856afc46 --- /dev/null +++ b/cpukit/libcsupport/src/assoclocalbyname.c @@ -0,0 +1,31 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + +uint32_t rtems_assoc_local_by_name( + const rtems_assoc_t *ap, + const char *name +) +{ + const rtems_assoc_t *nap; + + nap = rtems_assoc_ptr_by_name(ap, name); + if (nap) + return nap->local_value; + + return 0; +} diff --git a/cpukit/libcsupport/src/assoclocalbyremote.c b/cpukit/libcsupport/src/assoclocalbyremote.c new file mode 100644 index 0000000000..545f31b6a8 --- /dev/null +++ b/cpukit/libcsupport/src/assoclocalbyremote.c @@ -0,0 +1,31 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + +uint32_t rtems_assoc_local_by_remote( + const rtems_assoc_t *ap, + uint32_t remote_value +) +{ + const rtems_assoc_t *nap; + + nap = rtems_assoc_ptr_by_remote(ap, remote_value); + if (nap) + return nap->local_value; + + return 0; +} diff --git a/cpukit/libcsupport/src/assoclocalbyremotebitfield.c b/cpukit/libcsupport/src/assoclocalbyremotebitfield.c new file mode 100644 index 0000000000..177ca62b49 --- /dev/null +++ b/cpukit/libcsupport/src/assoclocalbyremotebitfield.c @@ -0,0 +1,34 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + + +uint32_t rtems_assoc_local_by_remote_bitfield( + const rtems_assoc_t *ap, + uint32_t remote_value +) +{ + uint32_t b; + uint32_t local_value = 0; + + for (b = 1; b; b <<= 1) { + if (b & remote_value) + local_value |= rtems_assoc_local_by_remote(ap, b); + } + + return local_value; +} diff --git a/cpukit/libcsupport/src/assocnamebylocal.c b/cpukit/libcsupport/src/assocnamebylocal.c new file mode 100644 index 0000000000..3ba0b8c083 --- /dev/null +++ b/cpukit/libcsupport/src/assocnamebylocal.c @@ -0,0 +1,31 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + +const char *rtems_assoc_name_by_local( + const rtems_assoc_t *ap, + uint32_t local_value +) +{ + const rtems_assoc_t *nap; + + nap = rtems_assoc_ptr_by_local(ap, local_value); + if (nap) + return nap->name; + + return rtems_assoc_name_bad(local_value); +} diff --git a/cpukit/libcsupport/src/assocnamebylocalbitfield.c b/cpukit/libcsupport/src/assocnamebylocalbitfield.c new file mode 100644 index 0000000000..c9d1fa1256 --- /dev/null +++ b/cpukit/libcsupport/src/assocnamebylocalbitfield.c @@ -0,0 +1,38 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + +char *rtems_assoc_name_by_local_bitfield( + const rtems_assoc_t *ap, + uint32_t value, + char *buffer +) +{ + uint32_t b; + + *buffer = 0; + + for (b = 1; b; b <<= 1) { + if (b & value) { + if (*buffer) + strcat(buffer, " "); + strcat(buffer, rtems_assoc_name_by_local(ap, b)); + } + } + + return buffer; +} diff --git a/cpukit/libcsupport/src/assocnamebyremote.c b/cpukit/libcsupport/src/assocnamebyremote.c new file mode 100644 index 0000000000..281022c7bf --- /dev/null +++ b/cpukit/libcsupport/src/assocnamebyremote.c @@ -0,0 +1,33 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + + +const char *rtems_assoc_name_by_remote( + const rtems_assoc_t *ap, + uint32_t remote_value +) +{ + const rtems_assoc_t *nap; + nap = rtems_assoc_ptr_by_remote(ap, remote_value); + + if (nap) + return nap->name; + + return rtems_assoc_name_bad(remote_value); +} + diff --git a/cpukit/libcsupport/src/assocnamebyremotebitfield.c b/cpukit/libcsupport/src/assocnamebyremotebitfield.c new file mode 100644 index 0000000000..1293393e1e --- /dev/null +++ b/cpukit/libcsupport/src/assocnamebyremotebitfield.c @@ -0,0 +1,39 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + + +char *rtems_assoc_name_by_remote_bitfield( + const rtems_assoc_t *ap, + uint32_t value, + char *buffer +) +{ + uint32_t b; + + *buffer = 0; + + for (b = 1; b; b <<= 1) { + if (b & value) { + if (*buffer) + strcat(buffer, " "); + strcat(buffer, rtems_assoc_name_by_remote(ap, b)); + } + } + + return buffer; +} diff --git a/cpukit/libcsupport/src/assocptrbylocal.c b/cpukit/libcsupport/src/assocptrbylocal.c new file mode 100644 index 0000000000..cbf26b1bcb --- /dev/null +++ b/cpukit/libcsupport/src/assocptrbylocal.c @@ -0,0 +1,34 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + +const rtems_assoc_t *rtems_assoc_ptr_by_local( + const rtems_assoc_t *ap, + uint32_t local_value +) +{ + const rtems_assoc_t *default_ap = 0; + + if (rtems_assoc_is_default(ap)) + default_ap = ap++; + + for ( ; ap->name; ap++) + if (ap->local_value == local_value) + return ap; + + return default_ap; +} diff --git a/cpukit/libcsupport/src/assocptrbyname.c b/cpukit/libcsupport/src/assocptrbyname.c new file mode 100644 index 0000000000..457f57e434 --- /dev/null +++ b/cpukit/libcsupport/src/assocptrbyname.c @@ -0,0 +1,35 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + + +const rtems_assoc_t *rtems_assoc_ptr_by_name( + const rtems_assoc_t *ap, + const char *name +) +{ + const rtems_assoc_t *default_ap = 0; + + if (rtems_assoc_is_default(ap)) + default_ap = ap++; + + for ( ; ap->name; ap++) + if (strcmp(ap->name, name) == 0) + return ap; + + return default_ap; +} diff --git a/cpukit/libcsupport/src/assocptrbyremote.c b/cpukit/libcsupport/src/assocptrbyremote.c new file mode 100644 index 0000000000..4879c2d397 --- /dev/null +++ b/cpukit/libcsupport/src/assocptrbyremote.c @@ -0,0 +1,34 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + +const rtems_assoc_t *rtems_assoc_ptr_by_remote( + const rtems_assoc_t *ap, + uint32_t remote_value +) +{ + const rtems_assoc_t *default_ap = 0; + + if (rtems_assoc_is_default(ap)) + default_ap = ap++; + + for ( ; ap->name; ap++) + if (ap->remote_value == remote_value) + return ap; + + return default_ap; +} diff --git a/cpukit/libcsupport/src/assocremotebylocal.c b/cpukit/libcsupport/src/assocremotebylocal.c new file mode 100644 index 0000000000..23bbcc74fa --- /dev/null +++ b/cpukit/libcsupport/src/assocremotebylocal.c @@ -0,0 +1,31 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + +uint32_t rtems_assoc_remote_by_local( + const rtems_assoc_t *ap, + uint32_t local_value +) +{ + const rtems_assoc_t *nap; + + nap = rtems_assoc_ptr_by_local(ap, local_value); + if (nap) + return nap->remote_value; + + return 0; +} diff --git a/cpukit/libcsupport/src/assocremotebylocalbitfield.c b/cpukit/libcsupport/src/assocremotebylocalbitfield.c new file mode 100644 index 0000000000..3d28345847 --- /dev/null +++ b/cpukit/libcsupport/src/assocremotebylocalbitfield.c @@ -0,0 +1,33 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + + +uint32_t rtems_assoc_remote_by_local_bitfield( + const rtems_assoc_t *ap, + uint32_t local_value +) +{ + uint32_t b; + uint32_t remote_value = 0; + + for (b = 1; b; b <<= 1) + if (b & local_value) + remote_value |= rtems_assoc_remote_by_local(ap, b); + + return remote_value; +} diff --git a/cpukit/libcsupport/src/assocremotebyname.c b/cpukit/libcsupport/src/assocremotebyname.c new file mode 100644 index 0000000000..923c8d28ba --- /dev/null +++ b/cpukit/libcsupport/src/assocremotebyname.c @@ -0,0 +1,31 @@ +/* + * assoc.c + * rtems assoc routines + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#define INSIDE_ASSOC + +#include +#include + +#include /* strcat, strcmp */ + +uint32_t rtems_assoc_remote_by_name( + const rtems_assoc_t *ap, + const char *name +) +{ + const rtems_assoc_t *nap; + + nap = rtems_assoc_ptr_by_name(ap, name); + if (nap) + return nap->remote_value; + + return 0; +} diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c index 0c42b61854..879cd8134c 100644 --- a/cpukit/libcsupport/src/libio.c +++ b/cpukit/libcsupport/src/libio.c @@ -51,57 +51,10 @@ * File descriptor Table Information */ -extern uint32_t rtems_libio_number_iops; -rtems_id rtems_libio_semaphore; -rtems_libio_t *rtems_libio_iops; -rtems_libio_t *rtems_libio_iop_freelist; - -/* - * rtems_libio_init - * - * Called by BSP startup code to initialize the libio subsystem. - */ - -void rtems_libio_init( void ) -{ - rtems_status_code rc; - int i; - rtems_libio_t *iop; - - if (rtems_libio_number_iops > 0) - { - rtems_libio_iops = (rtems_libio_t *) calloc(rtems_libio_number_iops, - sizeof(rtems_libio_t)); - if (rtems_libio_iops == NULL) - rtems_fatal_error_occurred(RTEMS_NO_MEMORY); - - iop = rtems_libio_iop_freelist = rtems_libio_iops; - for (i = 0 ; i < (rtems_libio_number_iops - 1) ; i++, iop++) - iop->data1 = iop + 1; - iop->data1 = NULL; - } - - /* - * Create the binary semaphore used to provide mutual exclusion - * on the IOP Table. - */ - - rc = rtems_semaphore_create( - RTEMS_LIBIO_SEM, - 1, - RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, - RTEMS_NO_PRIORITY, - &rtems_libio_semaphore - ); - if ( rc != RTEMS_SUCCESSFUL ) - rtems_fatal_error_occurred( rc ); - - /* - * Initialize the base file system infrastructure. - */ - - rtems_filesystem_initialize(); -} +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 diff --git a/cpukit/libcsupport/src/libio_init.c b/cpukit/libcsupport/src/libio_init.c new file mode 100644 index 0000000000..4968058637 --- /dev/null +++ b/cpukit/libcsupport/src/libio_init.c @@ -0,0 +1,90 @@ +/* + * This file contains the support infrastructure used to manage the + * table of integer style file descriptors used by the low level + * POSIX system calls like open(), read, fstat(), etc. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include /* libio_.h pulls in rtems */ +#include +#include /* assoc.h not included by rtems.h */ + +#include /* O_RDONLY, et.al. */ +#include /* O_RDONLY, et.al. */ +#include +#include + +#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; +rtems_id rtems_libio_semaphore; +rtems_libio_t *rtems_libio_iops; +rtems_libio_t *rtems_libio_iop_freelist; + +/* + * rtems_libio_init + * + * Called by BSP startup code to initialize the libio subsystem. + */ + +void rtems_libio_init( void ) +{ + rtems_status_code rc; + int i; + rtems_libio_t *iop; + + if (rtems_libio_number_iops > 0) + { + rtems_libio_iops = (rtems_libio_t *) calloc(rtems_libio_number_iops, + sizeof(rtems_libio_t)); + if (rtems_libio_iops == NULL) + rtems_fatal_error_occurred(RTEMS_NO_MEMORY); + + iop = rtems_libio_iop_freelist = rtems_libio_iops; + for (i = 0 ; i < (rtems_libio_number_iops - 1) ; i++, iop++) + iop->data1 = iop + 1; + iop->data1 = NULL; + } + + /* + * Create the binary semaphore used to provide mutual exclusion + * on the IOP Table. + */ + + rc = rtems_semaphore_create( + RTEMS_LIBIO_SEM, + 1, + RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, + RTEMS_NO_PRIORITY, + &rtems_libio_semaphore + ); + if ( rc != RTEMS_SUCCESSFUL ) + rtems_fatal_error_occurred( rc ); + + /* + * Initialize the base file system infrastructure. + */ + + rtems_filesystem_initialize(); +} diff --git a/cpukit/libcsupport/src/write.c b/cpukit/libcsupport/src/write.c index 4e08918ffb..751aab33ed 100644 --- a/cpukit/libcsupport/src/write.c +++ b/cpukit/libcsupport/src/write.c @@ -1,7 +1,7 @@ /* * write() - POSIX 1003.1b 6.4.2 - Write to a File * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -55,24 +55,3 @@ ssize_t write( return rc; } - -/* - * _write_r - * - * This is the Newlib dependent reentrant version of write(). - */ - -#if defined(RTEMS_NEWLIB) - -#include - -_ssize_t _write_r( - struct _reent *ptr, - int fd, - const void *buf, - size_t nbytes -) -{ - return write( fd, buf, nbytes ); -} -#endif diff --git a/cpukit/libcsupport/src/write_r.c b/cpukit/libcsupport/src/write_r.c new file mode 100644 index 0000000000..504cb10a43 --- /dev/null +++ b/cpukit/libcsupport/src/write_r.c @@ -0,0 +1,40 @@ +/* + * write_r() - POSIX 1003.1b 6.4.2 - Write to a File + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +/* + * _write_r + * + * This is the Newlib dependent reentrant version of write(). + */ + +#if defined(RTEMS_NEWLIB) + +#include + +_ssize_t _write_r( + struct _reent *ptr, + int fd, + const void *buf, + size_t nbytes +) +{ + return write( fd, buf, nbytes ); +} +#endif -- cgit v1.2.3