From df49c60c9671e4a28e636964d744c1f59fb6cb68 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 12 Jun 2000 15:00:15 +0000 Subject: Merged from 4.5.0-beta3a --- cpukit/libcsupport/Makefile.am | 3 +- cpukit/libcsupport/include/console.h | 4 - cpukit/libcsupport/include/rtems/error.h | 9 + cpukit/libcsupport/include/sys/termios.h | 10 +- cpukit/libcsupport/src/gxx_wrappers.c | 219 +++++++++++++++++++++++ cpukit/libcsupport/src/libio.c | 4 +- cpukit/libcsupport/src/malloc.c | 2 +- cpukit/libcsupport/src/scandir.c | 2 +- cpukit/libcsupport/src/termios.c | 15 +- cpukit/libcsupport/src/termiosreserveresources.c | 5 + cpukit/libcsupport/src/unmount.c | 12 +- 11 files changed, 260 insertions(+), 25 deletions(-) (limited to 'cpukit/libcsupport') diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am index f65729290b..2d2f16cd26 100644 --- a/cpukit/libcsupport/Makefile.am +++ b/cpukit/libcsupport/Makefile.am @@ -5,8 +5,7 @@ AUTOMAKE_OPTIONS = foreign 1.4 ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal -SUBDIRS = include libc libcpu libbsp \ - $(LIBHWAPI) +SUBDIRS = include libc libcpu libbsp include $(top_srcdir)/../../../automake/subdirs.am include $(top_srcdir)/../../../automake/local.am diff --git a/cpukit/libcsupport/include/console.h b/cpukit/libcsupport/include/console.h index 7bc6b5e3d4..2d2f380012 100644 --- a/cpukit/libcsupport/include/console.h +++ b/cpukit/libcsupport/include/console.h @@ -24,10 +24,6 @@ extern "C" { { console_initialize, console_open, console_close, \ console_read, console_write, console_control } -void console_reserve_resources( - rtems_configuration_table *configuration -); - rtems_device_driver console_initialize( rtems_device_major_number, rtems_device_minor_number, diff --git a/cpukit/libcsupport/include/rtems/error.h b/cpukit/libcsupport/include/rtems/error.h index a0698afb5d..de6e1715db 100644 --- a/cpukit/libcsupport/include/rtems/error.h +++ b/cpukit/libcsupport/include/rtems/error.h @@ -7,6 +7,10 @@ #ifndef __RTEMS_ERROR_h #define __RTEMS_ERROR_h +#ifdef __cplusplus +extern "C" { +#endif + /* * rtems_error() and rtems_panic() support */ @@ -34,5 +38,10 @@ void rtems_panic(const char *printf_format, ...); extern int rtems_panic_in_progress; +#ifdef __cplusplus +} +#endif + + #endif /* end of include file */ diff --git a/cpukit/libcsupport/include/sys/termios.h b/cpukit/libcsupport/include/sys/termios.h index bb64d55433..7cc28d7d38 100644 --- a/cpukit/libcsupport/include/sys/termios.h +++ b/cpukit/libcsupport/include/sys/termios.h @@ -14,6 +14,8 @@ #ifndef TERMIOS_H #define TERMIOS_H +#include + #ifdef __cplusplus extern "C" { #endif @@ -174,9 +176,15 @@ struct termios { #define TCSADRAIN 1 #define TCSAFLUSH 2 +int tcdrain(int); +int tcflow(int, int); +int tcflush(int, int); int tcgetattr(int, struct termios *); int tcsetattr(int, int, struct termios *); -int tcdrain(int); +pid_t tcgetprgrp(int); +int tcsetprgrp(int, pid_t); +int tcsendbreak(int, int); + speed_t cfgetospeed(const struct termios *tp); int cfsetospeed(struct termios *tp, speed_t speed); speed_t cfgetispeed(const struct termios *tp); diff --git a/cpukit/libcsupport/src/gxx_wrappers.c b/cpukit/libcsupport/src/gxx_wrappers.c index e69de29bb2..323da73e7f 100644 --- a/cpukit/libcsupport/src/gxx_wrappers.c +++ b/cpukit/libcsupport/src/gxx_wrappers.c @@ -0,0 +1,219 @@ +/* + * RTEMS threads compatibily routines for libgcc2. + * + * by: Rosimildo da Silva ( rdasilva@connecttel.com + * + * Used ideas from: + * W. Eric Norum + * Canadian Light Source + * University of Saskatchewan + * Saskatoon, Saskatchewan, CANADA + * eric@cls.usask.ca + * + * Eric sent some e-mail in the rtems-list as a start point for this + * module implementation. + * + * + */ + +/* We might not need, defined just in case */ +#define __RTEMS_INSIDE__ 1 + + +#include +#include + +#include +#include +#include + +/* + * These typedefs should match with the ones defined in the file + * gcc/gthr-rtems.h in the gcc distribution. + */ +typedef void *__gthread_key_t; +typedef int __gthread_once_t; +typedef void *__gthread_mutex_t; + + +/* uncomment this if you need to debug this interface */ + +/* +#define DEBUG_GXX_WRAPPERS 1 +*/ + + +/* prototype for the terminate() */ +extern void __terminate( void ); + + +#ifdef DEBUG_GXX_WRAPPERS +/* local function to return the ID of the calling thread */ +static rtems_id get_tid( void ) +{ + rtems_id id = 0; + rtems_task_ident( RTEMS_SELF, 0, &id ); + return id; +} +#endif + + +int rtems_gxx_once(__gthread_once_t *once, void (*func) ()) +{ +#ifdef DEBUG_GXX_WRAPPERS + printk( "gxx_wrappers: once=%x, func=%x\n", *once, func ); +#endif + if( *once == 0 ) + { + /* + * NOTE: could not use the call to disable "preemption", it causes + * one exception. Somebody might want to investiage it further + * sometime later. + */ + _Thread_Disable_dispatch(); + *once = 1; + (*func)(); + _Thread_Enable_dispatch(); + } + return 0; +} + + +int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *)) +{ + /* Ok, this can be a bit tricky. We are going to return a "key" as a + * pointer to the buffer that will hold the value of the key itself. + * We have to to this, becuase the others functions on this interface + * deal with the value of the key, as used with the POSIX API. + */ + /* Do not pull your hair, trust me this works. :-) */ + __gthread_key_t *new_key = ( __gthread_key_t * )malloc( sizeof( __gthread_key_t ) ); + *key = ( __gthread_key_t )new_key; + *new_key = NULL; + +#ifdef DEBUG_GXX_WRAPPERS + printk( "gxx_wrappers: create key=%x, dtor=%x, new_key=%x\n", key, dtor, new_key ); +#endif + /* register with RTEMS the buffer that will hold the key values */ + if( rtems_task_variable_add( RTEMS_SELF, (void **)new_key, NULL ) == RTEMS_SUCCESSFUL ) + return 0; + return -1; +} + +int rtems_gxx_key_dtor (__gthread_key_t key, void *ptr) +{ +#ifdef DEBUG_GXX_WRAPPERS + printk( "gxx_wrappers: dtor key=%x, ptr=%x\n", key, ptr ); +#endif + *(void **)key = 0; + return 0; +} + +int rtems_gxx_key_delete (__gthread_key_t key) +{ +#ifdef DEBUG_GXX_WRAPPERS + printk( "gxx_wrappers: delete key=%x\n", key ); +#endif + /* register with RTEMS the buffer that will hold the key values */ + if( rtems_task_variable_delete( RTEMS_SELF, (void **)key ) == RTEMS_SUCCESSFUL ) + { + if( key ) free( (void *)key ); + return 0; + } + return 0; +} + + +void *rtems_gxx_getspecific(__gthread_key_t key) +{ + void *p= 0; + + /* register with RTEMS the buffer that will hold the key values */ + if( rtems_task_variable_get( RTEMS_SELF, (void **)key, &p ) == RTEMS_SUCCESSFUL ) + { + /* We do not have to do this, but what the heck ! */ + p= *( void **)key; + } + else + { + /* fisrt time, always set to zero, it is unknown the value that the others + * threads are using at the moment of this call + */ + if( rtems_task_variable_add( RTEMS_SELF, (void **)key, NULL ) != RTEMS_SUCCESSFUL ) + { + __terminate (); + } + *( void ** )key = (void *)0; + } + +#ifdef DEBUG_GXX_WRAPPERS + printk( "gxx_wrappers: getspecific key=%x, ptr=%x, id=%x\n", key, p, get_tid() ); +#endif + return p; +} + + +int rtems_gxx_setspecific(__gthread_key_t key, const void *ptr) +{ +#ifdef DEBUG_GXX_WRAPPERS + printk( "gxx_wrappers: setspecific key=%x, ptr=%x, id=%x\n", key, ptr, get_tid() ); +#endif + /* register with RTEMS the buffer that will hold the key values */ + if( rtems_task_variable_add( RTEMS_SELF, (void **)key, NULL ) == RTEMS_SUCCESSFUL ) + { + /* now let's set the proper value */ + *( void ** )key = (void *)ptr; + return 0; + } + return -1; +} + + +/* + * MUTEX support + */ +void rtems_gxx_mutex_init (__gthread_mutex_t *mutex) +{ +#ifdef DEBUG_GXX_WRAPPERS + printk( "gxx_wrappers: mutex init =%X\n", *mutex ); +#endif + if( rtems_semaphore_create( rtems_build_name ('G', 'C', 'C', '2'), + 1, + RTEMS_PRIORITY|RTEMS_BINARY_SEMAPHORE + |RTEMS_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING|RTEMS_LOCAL, + 0, + (rtems_id *)mutex ) != RTEMS_SUCCESSFUL ) + { + __terminate (); + } +#ifdef DEBUG_GXX_WRAPPERS + printk( "gxx_wrappers: mutex init complete =%X\n", *mutex ); +#endif +} + +int rtems_gxx_mutex_lock (__gthread_mutex_t *mutex) +{ +#ifdef DEBUG_GXX_WRAPPERS + printk( "gxx_wrappers: lock mutex=%X\n", *mutex ); +#endif + return ( rtems_semaphore_obtain( (rtems_id)*mutex, + RTEMS_WAIT, RTEMS_NO_TIMEOUT ) == RTEMS_SUCCESSFUL) ? 0 : -1; +} + +int rtems_gxx_mutex_trylock (__gthread_mutex_t *mutex) +{ +#ifdef DEBUG_GXX_WRAPPERS + printk( "gxx_wrappers: trylock mutex=%X\n", *mutex ); +#endif + return (rtems_semaphore_obtain ((rtems_id)*mutex, + RTEMS_NO_WAIT, 0) == RTEMS_SUCCESSFUL) ? 0 : -1; +} + +int rtems_gxx_mutex_unlock (__gthread_mutex_t *mutex) +{ +#ifdef DEBUG_GXX_WRAPPERS + printk( "gxx_wrappers: unlock mutex=%X\n", *mutex ); +#endif + return (rtems_semaphore_release( (rtems_id)*mutex ) == RTEMS_SUCCESSFUL) ? 0 :-1; +} + diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c index 9e075c9f0b..c878db6247 100644 --- a/cpukit/libcsupport/src/libio.c +++ b/cpukit/libcsupport/src/libio.c @@ -260,7 +260,7 @@ int rtems_libio_is_open_files_in_fs( * Look for any active file descriptor entry. */ - for (iop=rtems_libio_iops,i=0; i <= rtems_libio_number_iops; iop++, i++){ + for (iop=rtems_libio_iops,i=0; i < rtems_libio_number_iops; iop++, i++){ if ((iop->flags & LIBIO_FLAGS_OPEN) != 0) { @@ -304,7 +304,7 @@ int rtems_libio_is_file_open( * Look for any active file descriptor entry. */ - for (iop=rtems_libio_iops,i=0; i <= rtems_libio_number_iops; iop++, i++){ + for (iop=rtems_libio_iops,i=0; i < rtems_libio_number_iops; iop++, i++){ if ((iop->flags & LIBIO_FLAGS_OPEN) != 0) { /* diff --git a/cpukit/libcsupport/src/malloc.c b/cpukit/libcsupport/src/malloc.c index cc63b6c7d0..08660d75cc 100644 --- a/cpukit/libcsupport/src/malloc.c +++ b/cpukit/libcsupport/src/malloc.c @@ -120,7 +120,7 @@ void RTEMS_Malloc_Initialize( rtems_build_name( 'H', 'E', 'A', 'P' ), starting_address, length, - CPU_ALIGNMENT, + CPU_HEAP_ALIGNMENT, RTEMS_DEFAULT_ATTRIBUTES, &RTEMS_Malloc_Heap ); diff --git a/cpukit/libcsupport/src/scandir.c b/cpukit/libcsupport/src/scandir.c index 43c7c51747..25f3263187 100644 --- a/cpukit/libcsupport/src/scandir.c +++ b/cpukit/libcsupport/src/scandir.c @@ -112,7 +112,7 @@ scandir(dirname, namelist, select, dcomp) p->d_ino = d->d_ino; p->d_reclen = d->d_reclen; p->d_namlen = d->d_namlen; - strncpy(p->d_name, d->d_name, p->d_namlen + 1); + strncpy(d->d_name, p->d_name, p->d_namlen + 1); /* * Check to make sure the array has space left and * realloc the maximum size. diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c index 6d334ecd23..7883e94b63 100644 --- a/cpukit/libcsupport/src/termios.c +++ b/cpukit/libcsupport/src/termios.c @@ -28,7 +28,6 @@ * FreeBSD does not support a full POSIX termios so we have to help it out */ - #if defined(__FreeBSD__) #define XTABS 0 #define ONLRET 0 @@ -40,6 +39,14 @@ #define IUCLC 0 #endif +/* + * Cygwin does not define these + */ + +#if defined(__CYGWIN__) +#define ECHOPRT 0 +#endif + /* * The size of the cooked buffer */ @@ -238,7 +245,7 @@ rtems_termios_open ( */ tty->termios.c_iflag = BRKINT | ICRNL | IMAXBEL; tty->termios.c_oflag = OPOST | ONLCR | XTABS; - tty->termios.c_cflag = B9600 | CS8 | CREAD; + tty->termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL; tty->termios.c_lflag = ISIG | ICANON | IEXTEN | ECHO | ECHOK | ECHOE | ECHOCTL; tty->termios.c_cc[VINTR] = '\003'; @@ -256,8 +263,8 @@ rtems_termios_open ( tty->termios.c_cc[VWERASE] = '\027'; tty->termios.c_cc[VLNEXT] = '\026'; - /* setup flow control mode, clear flow control flags */ - tty->flow_ctrl = FL_MDXON; + /* start with no flow control, clear flow control flags */ + tty->flow_ctrl = 0; /* * set low/highwater mark for XON/XOFF support */ diff --git a/cpukit/libcsupport/src/termiosreserveresources.c b/cpukit/libcsupport/src/termiosreserveresources.c index 2d9c05c988..664bdd1f62 100644 --- a/cpukit/libcsupport/src/termiosreserveresources.c +++ b/cpukit/libcsupport/src/termiosreserveresources.c @@ -6,15 +6,19 @@ #include +#if 0 static int first_time; /* assumed to be zeroed by BSS initialization */ +#endif void rtems_termios_reserve_resources ( rtems_configuration_table *configuration, rtems_unsigned32 number_of_devices ) { +#if 0 rtems_api_configuration_table *rtems_config; + if (!configuration) rtems_fatal_error_occurred (0xFFF0F001); rtems_config = configuration->RTEMS_api_configuration; @@ -24,5 +28,6 @@ void rtems_termios_reserve_resources ( rtems_config->maximum_semaphores += 1; first_time = 1; rtems_config->maximum_semaphores += (4 * number_of_devices); +#endif } diff --git a/cpukit/libcsupport/src/unmount.c b/cpukit/libcsupport/src/unmount.c index c4b6bdae7d..46b11d1848 100644 --- a/cpukit/libcsupport/src/unmount.c +++ b/cpukit/libcsupport/src/unmount.c @@ -62,7 +62,6 @@ int unmount( int status; rtems_filesystem_location_info_t temp_loc; rtems_filesystem_mount_table_entry_t temp_mt_entry; - int result; /* * Are there any file systems below the mount_path specified @@ -101,7 +100,7 @@ int unmount( /* * Allow the file system being mounted on to do its cleanup. * XXX - Did I change these correctly ??? It looks like either I did - * XXX this backwards or the IMFS_unmount and IMFS_fsumount are swaped. + * XXX this backwards or the IMFS_unmount and IMFS_fsumount are swapped. * XXX Add to the mt_point_node unmount to set the mt_entry back to null * XXX I will step off in space when evaluating past the end of the node. */ @@ -120,12 +119,6 @@ int unmount( return -1; } - /* - * Allow the file system to clean up. - */ - - result = (*temp_loc.ops->fsunmount_me)( temp_loc.mt_entry ); - /* * Extract the mount table entry from the chain */ @@ -140,8 +133,7 @@ int unmount( free( temp_loc.mt_entry ); rtems_filesystem_freenode( &temp_loc ); - return result; - + return 0; } -- cgit v1.2.3