diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-03-26 22:31:31 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-03-26 22:31:31 +0000 |
commit | 55568af2e70d7026b57fe54ce14f6980a37c4e08 (patch) | |
tree | 9ecac1722450cf6b582450bd90e15e878d290fe5 /cpukit/libcsupport/src/assoc.c | |
parent | 2007-03-26 Chris Johns <chrisj@rtems.org> (diff) | |
download | rtems-55568af2e70d7026b57fe54ce14f6980a37c4e08.tar.bz2 |
2007-03-26 Joel Sherrill <joel@OARcorp.com>
* 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.
Diffstat (limited to 'cpukit/libcsupport/src/assoc.c')
-rw-r--r-- | cpukit/libcsupport/src/assoc.c | 245 |
1 files changed, 13 insertions, 232 deletions
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 <rtems.h> #include <rtems/assoc.h> #include <string.h> /* 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; } |