Mercurial > ecos-v3_0-branch
changeset 2085:96df14bb938f
* src/time.cxx: add gettimeofday() implementation
* cdl/posix.cdl: make some descriptions a bit more verbose. move
mutex.cxx into its own component (CYGPKG_POSIX_PTHREAD_MUTEX).
move compilation of mqueue.cxx into the CYGPKG_POSIX_MQUEUES
component. Fixed the tests so that only the ones which stand a
chance of compling are compiled.
* include/sys/time.h (new): Header file which implements sys/time.h
* include/pthread.h: Include time.h for struct timespec
* include/mutex.h: Include time.h for struct timespec
line wrap: on
line diff
--- a/packages/compat/posix/current/ChangeLog +++ b/packages/compat/posix/current/ChangeLog @@ -1,3 +1,16 @@ +2005-10-23 Andrew Lunn <andrew.lunn@ascom.ch> +2005-10-18 Alexander Neundorf <neundorf@kde.org> + + * src/time.cxx: add gettimeofday() implementation + * cdl/posix.cdl: make some descriptions a bit more verbose. move + mutex.cxx into its own component (CYGPKG_POSIX_PTHREAD_MUTEX). + move compilation of mqueue.cxx into the CYGPKG_POSIX_MQUEUES + component. Fixed the tests so that only the ones which stand a + chance of compling are compiled. + * include/sys/time.h (new): Header file which implements sys/time.h + * include/pthread.h: Include time.h for struct timespec + * include/mutex.h: Include time.h for struct timespec + 2004-10-01 Oyvind Harboe <oyvind.harboe@zylin.com> * src/signal.cxx: place the CYGBLD_ATTRIB_INIT_PRI such that it
--- a/packages/compat/posix/current/cdl/posix.cdl +++ b/packages/compat/posix/current/cdl/posix.cdl @@ -52,6 +52,7 @@ cdl_package CYGPKG_POSIX { display "POSIX compatibility layer" description "This package enables the POSIX compatibility layer that implements IEEE 1003.1." + doc ref/posix-compatibility.html include_dir cyg/posix @@ -62,10 +63,7 @@ cdl_package CYGPKG_POSIX { requires CYGINT_ISO_ERRNO_CODES requires CYGIMP_KERNEL_SCHED_SORTED_QUEUES - implements CYGINT_ISO_SCHED_IMPL implements CYGINT_ISO_POSIX_LIMITS - implements CYGINT_ISO_PMUTEXTYPES - implements CYGINT_ISO_PTHREAD_MUTEX requires { CYGBLD_ISO_POSIX_LIMITS_HEADER == \ "<cyg/posix/limits.h>" } requires { CYGBLD_ISO_PMUTEXTYPES_HEADER == \ @@ -73,26 +71,41 @@ cdl_package CYGPKG_POSIX { requires { CYGBLD_ISO_PTHREAD_MUTEX_HEADER == \ "<cyg/posix/mutex.h>" } - compile mqueue.cxx mutex.cxx misc.cxx + compile misc.cxx compile -library=libextras.a startup.cxx - cdl_option _POSIX_THREAD_PRIO_INHERIT { - display "POSIX mutex priority inheritance feature test macro" - flavor bool - default_value 1 - requires CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT - description "This option defines the POSIX feature test macro - for supporting priority inheritance protocol in - mutexes." - } + cdl_component CYGPKG_POSIX_PTHREAD_MUTEX { + + display "POSIX pthread mutexes" + flavor bool + default_value 1 + implements CYGINT_ISO_PMUTEXTYPES + implements CYGINT_ISO_PTHREAD_MUTEX + description " + This component provides support for POSIX pthreads + mutexes." + + compile mutex.cxx + + cdl_option _POSIX_THREAD_PRIO_INHERIT { + display "POSIX mutex priority inheritance feature test macro" + flavor bool + default_value 1 + requires CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT + description " + This option defines the POSIX feature test macro for + supporting priority inheritance protocol in mutexes." + } - cdl_option _POSIX_THREAD_PRIO_PROTECT { - display "POSIX mutex priority ceiling feature test macro" - flavor bool - default_value 1 - requires CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING - description "This option defines the POSIX feature test macro - for supporting priority ceiling protocol in mutexes." + cdl_option _POSIX_THREAD_PRIO_PROTECT { + display "POSIX mutex priority ceiling feature test macro" + flavor bool + default_value 1 + requires CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + description " + This option defines the POSIX feature test macro for + supporting priority ceiling protocol in mutexes." + } } # ---------------------------------------------------------------- @@ -102,9 +115,12 @@ cdl_package CYGPKG_POSIX { display "POSIX scheduling configuration" flavor bool default_value 1 - description "This component provides controls over scheduling - in POSIX." + implements CYGINT_ISO_SCHED_IMPL requires CYGPKG_POSIX_CLOCKS + + description " + This component provides controls over scheduling in POSIX." + compile sched.cxx cdl_option _POSIX_PRIORITY_SCHEDULING { @@ -112,9 +128,10 @@ cdl_package CYGPKG_POSIX { flavor bool calculated 1 requires CYGSEM_KERNEL_SCHED_MLQUEUE - description "This option defines the POSIX feature test macro - that indicates that priority scheduling is present. - This should not be undefined." + description " + This option defines the POSIX feature test macro that + indicates that priority scheduling is present. This + should not be undefined." } } @@ -125,14 +142,17 @@ cdl_package CYGPKG_POSIX { display "POSIX pthread configuration" flavor bool default_value 1 - description "This component provides configuration controls for - the POSIX pthreads package." + description " + This component provides configuration controls for the + POSIX pthreads package." + + script pthread.cdl compile pthread.cxx - script pthread.cdl + } # ---------------------------------------------------------------- - # Timers component + # Clock component cdl_option CYGPKG_POSIX_CLOCKS { display "POSIX clocks" @@ -145,11 +165,18 @@ cdl_package CYGPKG_POSIX { "<cyg/posix/time.h>" } requires { CYGBLD_ISO_POSIX_CLOCKS_HEADER == \ "<cyg/posix/time.h>" } + requires { CYGBLD_ISO_STRUCTTIMEVAL_HEADER == \ + "<cyg/posix/sys/time.h>" } requires CYGPKG_KERNEL requires CYGVAR_KERNEL_COUNTERS_CLOCK + + description " + This component provides configuration controls for + the POSIX clocks and the sleep(), nanosleep() and + gettimeofday() functions." + compile time.cxx - description "This component provides configuration controls for - the POSIX clocks." + } # ---------------------------------------------------------------- @@ -169,10 +196,11 @@ cdl_package CYGPKG_POSIX { requires CYGPKG_KERNEL requires CYGVAR_KERNEL_COUNTERS_CLOCK requires CYGPKG_POSIX_PTHREAD - requires CYGPKG_POSIX_CLOCKS requires CYGPKG_POSIX_SIGNALS - description "This component provides configuration controls for - the POSIX timers." + requires CYGINT_ISO_POSIX_CLOCKS + description " + This component provides configuration controls for + the POSIX timers." } # ---------------------------------------------------------------- @@ -198,11 +226,14 @@ cdl_package CYGPKG_POSIX { display "POSIX message queues" flavor bool default_value 1 + compile mqueue.cxx implements CYGINT_ISO_MQUEUE requires CYGPKG_KERNEL requires CYGINT_ISO_MALLOC requires CYGINT_ISO_ERRNO requires CYGINT_ISO_STRING_STRFUNCS + requires CYGINT_ISO_PTHREAD_MUTEX + requires CYGPKG_POSIX_CLOCKS description "This component provides configuration controls for POSIX message queues." @@ -261,8 +292,10 @@ cdl_package CYGPKG_POSIX { "<cyg/posix/signal.h>" } requires { CYGBLD_ISO_SIGNAL_IMPL_HEADER == \ "<cyg/posix/signal.h>" } - description "This component provides configuration controls for - the POSIX signals." + description " + This component provides configuration controls for + the POSIX signals." + compile signal.cxx except.cxx } @@ -275,8 +308,9 @@ cdl_package CYGPKG_POSIX { default_value 1 requires { CYGBLD_ISO_UTSNAME_HEADER == \ "<cyg/posix/utsname.h>" } - description "This component provides configuration controls for - the POSIX utsname structure and the uname() function." + description " + This component provides configuration controls for + the POSIX utsname structure and the uname() function." cdl_option CYG_POSIX_UTSNAME_LENGTH { display "Length of name strings in utsname structure" @@ -297,13 +331,24 @@ cdl_package CYGPKG_POSIX { # ---------------------------------------------------------------- # Tests - cdl_option CYGPKG_POSIX_TESTS { - display "POSIX tests" - flavor data - no_define - calculated { - "tests/pthread1 tests/pthread2 tests/pthread3 tests/mutex3 tests/mqueue2" - . ((CYGPKG_POSIX_SIGNALS) ? " tests/mqueue1 tests/signal1 tests/signal2 tests/signal3 tests/sigsetjmp tests/timer1 tests/tm_basic" : "") + cdl_option CYGPKG_POSIX_TESTS { + display "POSIX tests" + flavor data + no_define + calculated { + (CYGPKG_POSIX_PTHREAD ? "tests/pthread1 tests/pthread2 tests/pthread3 " + : "") . + (CYGPKG_POSIX_PTHREAD_MUTEX ? "tests/mutex3 " : "") . + (CYGPKG_POSIX_MQUEUES ? "tests/mqueue1 tests/mqueue2 " : "") . + (CYGPKG_POSIX_SIGNALS ? "tests/signal1 tests/signal2 tests/signal3 \ + tests/sigsetjmp " : "") . + ((CYGPKG_POSIX_SIGNALS && + CYGPKG_POSIX_TIMERS && + CYGPKG_POSIX_SEMAPHORES) ? "tests/timer1 " : "") . + ((CYGPKG_POSIX_SIGNALS && + CYGPKG_POSIX_TIMERS && + CYGPKG_POSIX_PTHREAD && + CYGPKG_POSIX_SEMAPHORES) ? "tests/tm_basic " : "") } description " This option specifies the set of tests for the POSIX package."
--- a/packages/compat/posix/current/cdl/pthread.cdl +++ b/packages/compat/posix/current/cdl/pthread.cdl @@ -50,14 +50,14 @@ cdl_option CYGPKG_POSIX_PTHREAD_REQUIREMENTS { display "Generic requirements of pthread package" - flavor bool - calculated 1 + flavor bool + calculated 1 implements CYGINT_ISO_PTHREADTYPES implements CYGINT_ISO_PTHREAD_IMPL - requires CYGPKG_POSIX_SCHED - requires CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE - requires CYGSEM_KERNEL_SCHED_ASR_SUPPORT - requires CYGSEM_KERNEL_SCHED_ASR_GLOBAL + requires CYGPKG_POSIX_SCHED + requires CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE + requires CYGSEM_KERNEL_SCHED_ASR_SUPPORT + requires CYGSEM_KERNEL_SCHED_ASR_GLOBAL requires !CYGSEM_KERNEL_SCHED_ASR_DATA_GLOBAL requires CYGFUN_KERNEL_THREADS_STACK_LIMIT requires { CYGBLD_ISO_PTHREADTYPES_HEADER == \
--- a/packages/compat/posix/current/doc/posix.sgml +++ b/packages/compat/posix/current/doc/posix.sgml @@ -1046,6 +1046,7 @@ int timer_settime( timer_t int timer_gettime( timer_t timerid, struct itimerspec *value ); int timer_getoverrun( timer_t timerid ); int nanosleep( const struct timespec *rqtp, struct timespec *rmtp); +int gettimeofday(struct timeval *tv, struct timezone* tz); </screen> </sect2>
--- a/packages/compat/posix/current/include/mutex.h +++ b/packages/compat/posix/current/include/mutex.h @@ -59,7 +59,7 @@ #include <pkgconf/posix.h> #include <sys/types.h> // pthread_* types - +#include <time.h> //============================================================================= // Mutexes
--- a/packages/compat/posix/current/include/pthread.h +++ b/packages/compat/posix/current/include/pthread.h @@ -75,7 +75,7 @@ #include <sys/types.h> #include <sched.h> // SCHED_* - +#include <time.h> //============================================================================= // General thread operations
new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/include/sys/time.h @@ -0,0 +1,173 @@ +//========================================================================== +// +// include/sys/time.h +// +// +// +//========================================================================== +//####BSDCOPYRIGHTBEGIN#### +// +// ------------------------------------------- +// +// Portions of this software may have been derived from OpenBSD or other sources, +// and are covered by the appropriate copyright disclaimers included herein. +// +// ------------------------------------------- +// +//####BSDCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +/* $OpenBSD: time.h,v 1.9 1999/12/06 19:36:42 aaron Exp $ */ +/* $NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)time.h 8.2 (Berkeley) 7/10/94 + */ + +#ifndef _SYS_TIME_H_ +#define _SYS_TIME_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <sys/types.h> +#include <time.h> + +/* + * Structure returned by gettimeofday(2) system call, + * and used in other calls. + */ +struct timeval { + long tv_sec; /* seconds */ + long tv_usec; /* and microseconds */ +}; + + +#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; \ +} +#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; \ +} + +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +#define DST_NONE 0 /* not on dst */ +#define DST_USA 1 /* USA style dst */ +#define DST_AUST 2 /* Australian style dst */ +#define DST_WET 3 /* Western European dst */ +#define DST_MET 4 /* Middle European dst */ +#define DST_EET 5 /* Eastern European dst */ +#define DST_CAN 6 /* Canada */ + +/* Operations on timevals. */ +#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 +#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#define timercmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec == (uvp)->tv_sec) ? \ + ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ + ((tvp)->tv_sec cmp (uvp)->tv_sec)) +#define timeradd(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ + if ((vvp)->tv_usec >= 1000000) { \ + (vvp)->tv_sec++; \ + (vvp)->tv_usec -= 1000000; \ + } \ + } while (0) +#define timersub(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ + if ((vvp)->tv_usec < 0) { \ + (vvp)->tv_sec--; \ + (vvp)->tv_usec += 1000000; \ + } \ + } while (0) + +/* Operations on timespecs. */ +#define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0 +#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec) +#define timespeccmp(tsp, usp, cmp) \ + (((tsp)->tv_sec == (usp)->tv_sec) ? \ + ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ + ((tsp)->tv_sec cmp (usp)->tv_sec)) +#define timespecadd(tsp, usp, vsp) \ + do { \ + (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ + if ((vsp)->tv_nsec >= 1000000000L) { \ + (vsp)->tv_sec++; \ + (vsp)->tv_nsec -= 1000000000L; \ + } \ + } while (0) +#define timespecsub(tsp, usp, vsp) \ + do { \ + (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ + if ((vsp)->tv_nsec < 0) { \ + (vsp)->tv_sec--; \ + (vsp)->tv_nsec += 1000000000L; \ + } \ + } while (0) + + +int gettimeofday(struct timeval *, struct timezone *); + +#ifdef __cplusplus +} +#endif + + +#endif
--- a/packages/compat/posix/current/src/misc.cxx +++ b/packages/compat/posix/current/src/misc.cxx @@ -32,9 +32,6 @@ // // This exception does not invalidate any other reasons why a work based on // this file might be covered by the GNU General Public License. -// -// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. -// at http://sources.redhat.com/ecos/ecos-license/ // ------------------------------------------- //####ECOSGPLCOPYRIGHTEND#### //========================================================================== @@ -65,7 +62,9 @@ #include "pprivate.h" // POSIX private header #include <unistd.h> +#ifdef CYGPKG_POSIX_UTSNAME #include <sys/utsname.h> // My header +#endif #include <string.h> // strcpy #include <limits.h> #include <time.h> @@ -93,6 +92,7 @@ // ------------------------------------------------------------------------- // uname() +#ifdef CYGPKG_POSIX_UTSNAME __externC int uname( struct utsname *name ) { CYG_REPORT_FUNCTYPE( "returning %d" ); @@ -106,6 +106,7 @@ CYG_REPORT_RETVAL(0); return 0; } +#endif // ------------------------------------------------------------------------- // sysconf() @@ -126,14 +127,18 @@ SC_CASE( _SC_GETGR_R_SIZE_MAX, 0 ); SC_CASE( _SC_GETPW_R_SIZE_MAX, 0 ); SC_CASE( _SC_LOGIN_NAME_MAX, LOGIN_NAME_MAX ); +#ifdef CYGPKG_POSIX_MQUEUES SC_CASE( _SC_MQ_OPEN_MAX, MQ_OPEN_MAX ); SC_CASE( _SC_MQ_PRIO_MAX, MQ_PRIO_MAX ); +#endif SC_CASE( _SC_NGROUPS_MAX, NGROUPS_MAX ); SC_CASE( _SC_OPEN_MAX, OPEN_MAX ); SC_CASE( _SC_PAGESIZE, PAGESIZE ); SC_CASE( _SC_RTSIG_MAX, RTSIG_MAX ); +#ifdef CYGPKG_POSIX_SEMAPHORES SC_CASE( _SC_SEM_NSEMS_MAX, SEM_NSEMS_MAX ); SC_CASE( _SC_SEM_VALUE_MAX, SEM_VALUE_MAX ); +#endif SC_CASE( _SC_SIGQUEUE_MAX, SIGQUEUE_MAX ); SC_CASE( _SC_STREAM_MAX, STREAM_MAX ); #ifdef CYGPKG_POSIX_PTHREAD
--- a/packages/compat/posix/current/src/mqueue.cxx +++ b/packages/compat/posix/current/src/mqueue.cxx @@ -58,8 +58,6 @@ #include <pkgconf/posix.h> -#ifdef CYGPKG_POSIX_MQUEUES - #include <pkgconf/kernel.h> /* INCLUDES */ @@ -1000,6 +998,4 @@ mq_getattr( mqd_t mqdes, struct mq_attr //------------------------------------------------------------------------ -#endif // ifdef CYGPKG_POSIX_MQUEUES - /* EOF mqueue.cxx */
--- a/packages/compat/posix/current/src/time.cxx +++ b/packages/compat/posix/current/src/time.cxx @@ -55,8 +55,6 @@ #include <pkgconf/posix.h> -#ifdef CYGPKG_POSIX_CLOCKS - #include <pkgconf/hal.h> #include <pkgconf/kernel.h> @@ -67,9 +65,11 @@ #include "pprivate.h" // POSIX private header #include <time.h> // our header +#include <sys/time.h> #include <cyg/kernel/thread.hxx> #include <cyg/kernel/clock.hxx> +#include <cyg/kernel/kapi.h> #include <cyg/kernel/thread.inl> #include <cyg/kernel/clock.inl> @@ -694,7 +694,20 @@ externC unsigned int sleep( unsigned int TIME_RETURN(0); } -#endif // ifdef CYGPKG_POSIX_CLOCKS +// ------------------------------------------------------------------------- +// gettimeofday() +// Get the current time in a struct timeval +externC int gettimeofday(struct timeval* tv, struct timezone* tz) +{ + int ticks_per_second = 1000000000/ + (CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR); + cyg_tick_count_t cur_time = cyg_current_time(); + int tix = cur_time % ticks_per_second; + tv->tv_sec = cur_time / ticks_per_second; + tv->tv_usec = (tix * 1000000)/ticks_per_second; + return 0; +} + // ------------------------------------------------------------------------- // EOF time.cxx
--- a/packages/compat/posix/current/tests/signal1.c +++ b/packages/compat/posix/current/tests/signal1.c @@ -55,6 +55,8 @@ #define NA_MSG "POSIX signals not enabled" #elif !defined(CYGPKG_POSIX_PTHREAD) #define NA_MSG "POSIX threads not enabled" +#elif !defined(CYGPKG_POSIX_SEMAPHORES) +#define NA_MSG "POSIX semaphores not enabled" #endif #ifdef NA_MSG
--- a/packages/compat/posix/current/tests/sigsetjmp.c +++ b/packages/compat/posix/current/tests/sigsetjmp.c @@ -55,6 +55,8 @@ #define NA_MSG "POSIX signals not enabled" #elif !defined(CYGPKG_POSIX_PTHREAD) #define NA_MSG "POSIX threads not enabled" +#elif !defined(CYGPKG_POSIX_SEMAPHORES) +#define NA_MSG "POSIX semaphores not enabled" #endif #ifdef NA_MSG
--- a/packages/compat/posix/current/tests/timer1.c +++ b/packages/compat/posix/current/tests/timer1.c @@ -55,6 +55,8 @@ #define NA_MSG "No POSIX signals" #elif !defined(CYGPKG_POSIX_TIMERS) #define NA_MSG "No POSIX timers" +#elif !defined(CYGPKG_POSIX_SEMAPHORES) +#define NA_MSG "POSIX semaphores not enabled" #endif #ifdef NA_MSG
--- a/packages/compat/posix/current/tests/tm_basic.cxx +++ b/packages/compat/posix/current/tests/tm_basic.cxx @@ -71,6 +71,8 @@ #define NA_MSG "Kernel clock not enabled" #elif CYGNUM_KERNEL_SCHED_PRIORITIES <= 12 #define NA_MSG "Kernel scheduler properties <= 12" +#elif !defined(CYGPKG_POSIX_SEMAPHORES) +#define NA_MSG "POSIX semaphores not enabled" #endif //========================================================================== @@ -156,7 +158,9 @@ typedef struct fun_times { static int nsamples; static int ntest_threads; static int nthread_switches; +#ifdef CYGPKG_POSIX_PTHREAD_MUTEX static int nmutexes; +#endif static int nmboxes; static int nsemaphores; static int nscheds; @@ -169,11 +173,11 @@ static sem_t synchro; static fun_times thread_ft[NTEST_THREADS]; static fun_times test2_ft[NTHREAD_SWITCHES]; - +#ifdef CYGPKG_POSIX_PTHREAD_MUTEX static pthread_mutex_t test_mutexes[NMUTEXES]; static fun_times mutex_ft[NMUTEXES]; static pthread_t mutex_test_thread_handle; - +#endif #if 0 static cyg_mbox test_mboxes[NMBOXES]; static cyg_handle_t test_mbox_handles[NMBOXES]; @@ -212,8 +216,10 @@ extern bool measure_clock_latency; void run_sched_tests(void); void run_thread_tests(void); void run_thread_switch_test(void); +#ifdef CYGPKG_POSIX_PTHREAD_MUTEX void run_mutex_tests(void); void run_mutex_circuit_test(void); +#endif void run_mbox_tests(void); void run_mbox_circuit_test(void); void run_semaphore_tests(void); @@ -413,7 +419,9 @@ show_test_parameters(void) diag_printf(" Clock samples: %5d\n", nsamples); diag_printf(" Threads: %5d\n", ntest_threads); diag_printf(" Thread switches: %5d\n", nthread_switches); +#ifdef CYGPKG_POSIX_PTHREAD_MUTEX diag_printf(" Mutexes: %5d\n", nmutexes); +#endif diag_printf(" Mailboxes: %5d\n", nmboxes); diag_printf(" Semaphores: %5d\n", nsemaphores); diag_printf(" Scheduler operations: %5d\n", nscheds); @@ -495,7 +503,7 @@ test2(void *indx) return indx; } - +#ifdef CYGPKG_POSIX_PTHREAD_MUTEX //-------------------------------------------------------------------------- // Full-circuit mutex unlock/lock test @@ -531,7 +539,7 @@ mbox_test(cyg_uint32 indx) cyg_thread_exit(0); } #endif - +#endif //-------------------------------------------------------------------------- // Full-circuit semaphore post/wait test @@ -767,7 +775,7 @@ run_thread_switch_test(void) //-------------------------------------------------------------------------- - +#ifdef CYGPKG_POSIX_PTHREAD_MUTEX void run_mutex_tests(void) { @@ -889,7 +897,7 @@ run_mutex_circuit_test(void) } - +#endif //-------------------------------------------------------------------------- // Message queue tests @@ -1576,8 +1584,10 @@ run_all_tests() reset_clock_latency_measurement(); run_thread_tests(); +#ifdef CYGPKG_POSIX_PTHREAD_MUTEX run_mutex_tests(); // run_mbox_tests(); +#endif run_semaphore_tests(); run_timer_tests(); @@ -1655,7 +1665,9 @@ int main( int argc, char **argv ) nsamples = NSAMPLES_SIM; ntest_threads = NTEST_THREADS_SIM; nthread_switches = NTHREAD_SWITCHES_SIM; +#ifdef CYGPKG_POSIX_PTHREAD_MUTEX nmutexes = NMUTEXES_SIM; +#endif nmboxes = NMBOXES_SIM; nsemaphores = NSEMAPHORES_SIM; nscheds = NSCHEDS_SIM; @@ -1664,7 +1676,9 @@ int main( int argc, char **argv ) nsamples = NSAMPLES; ntest_threads = NTEST_THREADS; nthread_switches = NTHREAD_SWITCHES; +#ifdef CYGPKG_POSIX_PTHREAD_MUTEX nmutexes = NMUTEXES; +#endif nmboxes = NMBOXES; nsemaphores = NSEMAPHORES; nscheds = NSCHEDS; @@ -1674,14 +1688,18 @@ int main( int argc, char **argv ) // Sanity #ifdef WORKHORSE_TEST ntest_threads = max(512, ntest_threads); +#ifdef CYGPKG_POSIX_PTHREAD_MUTEX nmutexes = max(1024, nmutexes); +#endif nsemaphores = max(1024, nsemaphores); nmboxes = max(1024, nmboxes); ncounters = max(1024, ncounters); ntimers = max(1024, ntimers); #else ntest_threads = max(64, ntest_threads); +#ifdef CYGPKG_POSIX_PTHREAD_MUTEX nmutexes = max(32, nmutexes); +#endif nsemaphores = max(32, nsemaphores); nmboxes = max(32, nmboxes); ntimers = max(32, ntimers);
