mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-22 12:29:17 +08:00
2010-07-01 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac: Add test for GCC C++ library helpers. * gxx01/.cvsignore, gxx01/Makefile.am, gxx01/gxx01.doc, gxx01/gxx01.scn, gxx01/gxx_wrappers.h, gxx01/init.c: New files.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2010-07-01 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* Makefile.am, configure.ac: Add test for GCC C++ library helpers.
|
||||
* gxx01/.cvsignore, gxx01/Makefile.am, gxx01/gxx01.doc,
|
||||
gxx01/gxx01.scn, gxx01/gxx_wrappers.h, gxx01/init.c: New files.
|
||||
|
||||
2010-07-01 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||
|
||||
* termios04/termios_testdriver_intr.c: Task driven IO now works.
|
||||
|
||||
@@ -6,7 +6,7 @@ ACLOCAL_AMFLAGS = -I ../aclocal
|
||||
|
||||
SUBDIRS = POSIX
|
||||
|
||||
SUBDIRS += bspcmdline01 cpuuse malloctest malloc02 malloc03 heapwalk \
|
||||
SUBDIRS += bspcmdline01 cpuuse gxx01 malloctest malloc02 malloc03 heapwalk \
|
||||
putenvtest monitor monitor02 rtmonuse stackchk stackchk01 \
|
||||
termios termios01 termios02 termios03 termios04 termios05 \
|
||||
rtems++ tztest block01 block02 block03 block04 block05 block06 block07 \
|
||||
|
||||
@@ -45,6 +45,7 @@ block09/Makefile
|
||||
block10/Makefile
|
||||
bspcmdline01/Makefile
|
||||
cpuuse/Makefile
|
||||
gxx01/Makefile
|
||||
heapwalk/Makefile
|
||||
malloctest/Makefile
|
||||
malloc02/Makefile
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -0,0 +1,26 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
MANAGERS = all
|
||||
|
||||
rtems_tests_PROGRAMS = gxx01
|
||||
gxx01_SOURCES = init.c
|
||||
|
||||
dist_rtems_tests_DATA = gxx01.scn
|
||||
dist_rtems_tests_DATA += gxx01.doc
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../automake/compile.am
|
||||
include $(top_srcdir)/../automake/leaf.am
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
|
||||
LINK_OBJS = $(gxx01_OBJECTS) $(gxx01_LDADD)
|
||||
LINK_LIBS = $(gxx01_LDLIBS)
|
||||
|
||||
gxx01$(EXEEXT): $(gxx01_OBJECTS) $(gxx01_DEPENDENCIES)
|
||||
@rm -f gxx01$(EXEEXT)
|
||||
$(make-exe)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
@@ -0,0 +1,37 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# COPYRIGHT (c) 1989-2010.
|
||||
# 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.
|
||||
#
|
||||
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: gxx01
|
||||
|
||||
directives:
|
||||
|
||||
rtems_gxx_once
|
||||
rtems_gxx_key_create
|
||||
rtems_gxx_key_dtor
|
||||
rtems_gxx_key_delete
|
||||
rtems_gxx_getspecific
|
||||
rtems_gxx_setspecific
|
||||
rtems_gxx_mutex_init
|
||||
rtems_gxx_mutex_lock
|
||||
rtems_gxx_mutex_destroy
|
||||
rtems_gxx_mutex_trylock
|
||||
rtems_gxx_mutex_unlock
|
||||
rtems_gxx_recursive_mutex_init
|
||||
rtems_gxx_recursive_mutex_lock
|
||||
rtems_gxx_recursive_mutex_trylock
|
||||
rtems_gxx_recursive_mutex_unlock
|
||||
|
||||
concepts:
|
||||
|
||||
+ Fully exercise wrappers provided by RTEMS for GCC's C++ library's
|
||||
mutual exclusion implementation.
|
||||
@@ -0,0 +1,26 @@
|
||||
*** TEST GXX 01 ***
|
||||
rtems_gxx_mutex_init() - OK
|
||||
rtems_gxx_mutex_trylock() - OK
|
||||
rtems_gxx_mutex_unlock() - OK
|
||||
rtems_gxx_mutex_lock() - OK
|
||||
rtems_gxx_mutex_unlock() - OK
|
||||
|
||||
rtems_gxx_recursive_mutex_init() - OK
|
||||
rtems_gxx_recursive_mutex_trylock() - OK
|
||||
rtems_gxx_recursive_mutex_trylock() - Nest
|
||||
rtems_gxx_recursive_mutex_unlock() - Unnest
|
||||
rtems_gxx_recursive_mutex_unlock() - OK
|
||||
rtems_gxx_recursive_mutex_lock() - OK
|
||||
rtems_gxx_recursive_mutex_unlock() - OK
|
||||
|
||||
Call once method the first time
|
||||
Running once method
|
||||
Call once method the second time
|
||||
|
||||
rtems_gxx_key_create(&key, NULL) - OK
|
||||
rtems_gxx_key_delete(key) - OK
|
||||
rtems_gxx_key_create(&key, key_dtor) - OK
|
||||
rtems_gxx_setspecific() - OK
|
||||
rtems_gxx_petspecific() - OK
|
||||
rtems_gxx_key_delete(key) - OK
|
||||
*** END OF TEST GXX 01 ***
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* RTEMS threads compatibily routines for libgcc2.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __GCC_WRAPPERS_h
|
||||
#define __GCC_WRAPPERS_h
|
||||
|
||||
/*
|
||||
* These typedefs should match with the ones defined in the file
|
||||
* gcc/gthr-rtems.h in the gcc distribution.
|
||||
* FIXME: T.S, 2007/01/31: -> gcc/gthr-rtems.h still declares
|
||||
* void * __gthread_key_t;
|
||||
*/
|
||||
typedef struct __gthread_key_ {
|
||||
void *val; /* this is switched with the task */
|
||||
void (*dtor)(void*); /* this remains in place for all tasks */
|
||||
} __gthread_key, *__gthread_key_t;
|
||||
|
||||
typedef int __gthread_once_t;
|
||||
typedef void *__gthread_mutex_t;
|
||||
typedef void *__gthread_recursive_mutex_t;
|
||||
|
||||
int rtems_gxx_once(__gthread_once_t *once, void (*func) (void));
|
||||
|
||||
int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *));
|
||||
|
||||
int rtems_gxx_key_dtor (__gthread_key_t key, void *ptr);
|
||||
|
||||
int rtems_gxx_key_delete (__gthread_key_t key);
|
||||
|
||||
void *rtems_gxx_getspecific(__gthread_key_t key);
|
||||
|
||||
int rtems_gxx_setspecific(__gthread_key_t key, const void *ptr);
|
||||
|
||||
/*
|
||||
* MUTEX support
|
||||
*/
|
||||
void rtems_gxx_mutex_init (__gthread_mutex_t *mutex);
|
||||
|
||||
int rtems_gxx_mutex_lock (__gthread_mutex_t *mutex);
|
||||
|
||||
int rtems_gxx_mutex_destroy (__gthread_mutex_t *mutex);
|
||||
|
||||
int rtems_gxx_mutex_trylock (__gthread_mutex_t *mutex);
|
||||
|
||||
int rtems_gxx_mutex_unlock (__gthread_mutex_t *mutex);
|
||||
|
||||
void rtems_gxx_recursive_mutex_init(__gthread_recursive_mutex_t *mutex);
|
||||
|
||||
int rtems_gxx_recursive_mutex_lock(__gthread_recursive_mutex_t *mutex);
|
||||
|
||||
int rtems_gxx_recursive_mutex_trylock(__gthread_recursive_mutex_t *mutex);
|
||||
|
||||
int rtems_gxx_recursive_mutex_unlock(__gthread_recursive_mutex_t *mutex);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2010.
|
||||
* 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$
|
||||
*/
|
||||
|
||||
#include <tmacros.h>
|
||||
#include "test_support.h"
|
||||
#include "gxx_wrappers.h"
|
||||
|
||||
void test_recursive_mutex(void)
|
||||
{
|
||||
int sc;
|
||||
__gthread_mutex_t mutex;
|
||||
|
||||
mutex = 0;
|
||||
puts( "rtems_gxx_recursive_mutex_init() - OK" );
|
||||
rtems_gxx_recursive_mutex_init(&mutex);
|
||||
rtems_test_assert( mutex != 0 );
|
||||
|
||||
puts( "rtems_gxx_recursive_mutex_trylock() - OK" );
|
||||
sc = rtems_gxx_recursive_mutex_trylock(&mutex);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_recursive_mutex_trylock() - Nest" );
|
||||
sc = rtems_gxx_recursive_mutex_trylock(&mutex);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_recursive_mutex_unlock() - Unnest" );
|
||||
sc = rtems_gxx_recursive_mutex_unlock(&mutex);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_recursive_mutex_unlock() - OK" );
|
||||
sc = rtems_gxx_recursive_mutex_unlock(&mutex);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_recursive_mutex_lock() - OK" );
|
||||
sc = rtems_gxx_recursive_mutex_lock(&mutex);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_recursive_mutex_unlock() - OK" );
|
||||
sc = rtems_gxx_recursive_mutex_unlock(&mutex);
|
||||
rtems_test_assert( sc == 0 );
|
||||
}
|
||||
|
||||
void test_mutex(void)
|
||||
{
|
||||
int sc;
|
||||
__gthread_mutex_t mutex;
|
||||
|
||||
mutex = 0;
|
||||
puts( "rtems_gxx_mutex_init() - OK" );
|
||||
rtems_gxx_mutex_init(&mutex);
|
||||
rtems_test_assert( mutex != 0 );
|
||||
|
||||
puts( "rtems_gxx_mutex_trylock() - OK" );
|
||||
sc = rtems_gxx_mutex_trylock(&mutex);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_mutex_unlock() - OK" );
|
||||
sc = rtems_gxx_mutex_unlock(&mutex);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_mutex_lock() - OK" );
|
||||
sc = rtems_gxx_mutex_lock(&mutex);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_mutex_unlock() - OK" );
|
||||
sc = rtems_gxx_mutex_unlock(&mutex);
|
||||
rtems_test_assert( sc == 0 );
|
||||
}
|
||||
|
||||
void once_function(void)
|
||||
{
|
||||
puts( "Running once method" );
|
||||
}
|
||||
|
||||
void test_once(void)
|
||||
{
|
||||
__gthread_once_t once;
|
||||
int sc;
|
||||
|
||||
once = 0;
|
||||
|
||||
puts( "Call once method the first time" );
|
||||
sc = rtems_gxx_once(&once, once_function);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "Call once method the second time" );
|
||||
sc = rtems_gxx_once(&once, once_function);
|
||||
rtems_test_assert( sc == 0 );
|
||||
}
|
||||
|
||||
volatile bool key_dtor_ran;
|
||||
|
||||
void key_dtor(void *ptr)
|
||||
{
|
||||
key_dtor_ran = true;
|
||||
}
|
||||
|
||||
void test_key(void)
|
||||
{
|
||||
int sc;
|
||||
__gthread_key_t key;
|
||||
void *p;
|
||||
|
||||
puts( "rtems_gxx_key_create(&key, NULL) - OK" );
|
||||
sc = rtems_gxx_key_create(&key, NULL);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_key_delete(key) - OK" );
|
||||
sc = rtems_gxx_key_delete(key);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_key_create(&key, key_dtor) - OK" );
|
||||
sc = rtems_gxx_key_create(&key, key_dtor);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_setspecific() - OK" );
|
||||
sc = rtems_gxx_setspecific(key, (void *)0x1234);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_petspecific() - OK" );
|
||||
p = rtems_gxx_getspecific(key);
|
||||
rtems_test_assert( p == (void *)0x1234 );
|
||||
|
||||
puts( "rtems_gxx_key_delete(key) - OK" );
|
||||
sc = rtems_gxx_key_delete(key);
|
||||
rtems_test_assert( sc == 0 );
|
||||
rtems_test_assert( key_dtor_ran == true );
|
||||
|
||||
#if 0
|
||||
|
||||
void *rtems_gxx_getspecific(__gthread_key_t key);
|
||||
|
||||
int rtems_gxx_setspecific(__gthread_key_t key, const void *ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
{
|
||||
puts( "\n\n*** TEST GXX 01 ***" );
|
||||
|
||||
test_mutex();
|
||||
puts( "" );
|
||||
|
||||
test_recursive_mutex();
|
||||
puts( "" );
|
||||
|
||||
test_once();
|
||||
puts( "" );
|
||||
|
||||
test_key();
|
||||
|
||||
puts( "*** END OF TEST GXX 01 ***" );
|
||||
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 2
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
/* end of file */
|
||||
Reference in New Issue
Block a user