mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-26 06:08:20 +00:00
Remove obsolete rtems_gxx_*() implementation
GCC versions prior to 6.1 used a RTEMS thread model based on rtems_gxx_*() functions. GCC version 6.1 or later uses the self-contained synchronization objects of Newlib <sys/lock.h> for the RTEMS thread model. Remove the obsolete implementation. Close #3143.
This commit is contained in:
@@ -1,80 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* RTEMS threads compatibility 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.
|
||||
*/
|
||||
|
||||
#ifndef __GCC_WRAPPERS_h
|
||||
#define __GCC_WRAPPERS_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* @defgroup GxxWrappersSupport Gxx Wrappers Support
|
||||
*
|
||||
* @ingroup libcsupport
|
||||
*
|
||||
* @brief RTEMS Threads Compatibility Routines for Libgcc2
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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;
|
||||
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_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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GCC_WRAPPERS_h */
|
||||
@@ -188,8 +188,8 @@ typedef enum {
|
||||
/* INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_FROM_BAD_STATE = 18, */
|
||||
/* INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0 = 19, */
|
||||
/* INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP = 20, */
|
||||
INTERNAL_ERROR_GXX_KEY_ADD_FAILED = 21,
|
||||
INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED = 22,
|
||||
/* INTERNAL_ERROR_GXX_KEY_ADD_FAILED = 21, */
|
||||
/* INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED = 22, */
|
||||
INTERNAL_ERROR_NO_MEMORY_FOR_HEAP = 23,
|
||||
INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR = 24,
|
||||
INTERNAL_ERROR_RESOURCE_IN_USE = 25,
|
||||
|
||||
@@ -1,261 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief RTEMS Threads Compatibility Routines for Libgcc2
|
||||
* @ingroup GxxWrappersSupport
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is only used if using gcc
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/gxx_wrappers.h>
|
||||
#include <rtems/score/onceimpl.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
/* uncomment this if you need to debug this interface */
|
||||
/*#define DEBUG_GXX_WRAPPERS 1*/
|
||||
|
||||
int rtems_gxx_once(__gthread_once_t *once, void (*func) (void))
|
||||
{
|
||||
#ifdef DEBUG_GXX_WRAPPERS
|
||||
printk( "gxx_wrappers: once=%x, func=%x\n", *once, func );
|
||||
#endif
|
||||
|
||||
return _Once( (unsigned char *) once, func );
|
||||
}
|
||||
|
||||
int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *))
|
||||
{
|
||||
int eno;
|
||||
pthread_key_t *pkey;
|
||||
|
||||
pkey = malloc( sizeof( *pkey ) );
|
||||
*key = pkey;
|
||||
if ( pkey == NULL )
|
||||
{
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_GXX_WRAPPERS
|
||||
printk(
|
||||
"gxx_wrappers: create key=%x, dtor=%x, pkey=%x\n", key, dtor, pkey
|
||||
);
|
||||
#endif
|
||||
|
||||
eno = pthread_key_create(pkey, dtor);
|
||||
if ( eno != 0 ) {
|
||||
free( pkey );
|
||||
*key = NULL;
|
||||
}
|
||||
|
||||
return eno;
|
||||
}
|
||||
|
||||
int rtems_gxx_key_delete (__gthread_key_t key)
|
||||
{
|
||||
int eno = 0;
|
||||
pthread_key_t *pkey = key;
|
||||
|
||||
#ifdef DEBUG_GXX_WRAPPERS
|
||||
printk( "gxx_wrappers: delete key=%x\n", pkey );
|
||||
#endif
|
||||
|
||||
if ( pkey == NULL ) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
eno = pthread_key_delete(*pkey);
|
||||
if ( eno == 0 ) {
|
||||
free( pkey );
|
||||
}
|
||||
return eno;
|
||||
}
|
||||
|
||||
void *rtems_gxx_getspecific(__gthread_key_t key)
|
||||
{
|
||||
pthread_key_t *pkey = key;
|
||||
void *p = NULL;
|
||||
|
||||
if ( pkey != NULL ) {
|
||||
p = pthread_getspecific( *pkey );
|
||||
}
|
||||
|
||||
#ifdef DEBUG_GXX_WRAPPERS
|
||||
printk(
|
||||
"gxx_wrappers: getspecific key=%x, ptr=%x, id=%x\n",
|
||||
pkey,
|
||||
p,
|
||||
rtems_task_self()
|
||||
);
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
int rtems_gxx_setspecific(__gthread_key_t key, const void *ptr)
|
||||
{
|
||||
pthread_key_t *pkey = key;
|
||||
int eno;
|
||||
|
||||
if ( pkey == NULL ) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
eno = pthread_setspecific( *pkey, ptr );
|
||||
|
||||
#ifdef DEBUG_GXX_WRAPPERS
|
||||
printk(
|
||||
"gxx_wrappers: setspecific key=%x, ptr=%x, id=%x\n",
|
||||
pkey,
|
||||
ptr,
|
||||
rtems_task_self()
|
||||
);
|
||||
#endif
|
||||
|
||||
if ( eno != 0 ) {
|
||||
_Internal_error( INTERNAL_ERROR_GXX_KEY_ADD_FAILED );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* MUTEX support
|
||||
*/
|
||||
void rtems_gxx_mutex_init (__gthread_mutex_t *mutex)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
#ifdef DEBUG_GXX_WRAPPERS
|
||||
printk( "gxx_wrappers: mutex init =%X\n", *mutex );
|
||||
#endif
|
||||
|
||||
status = 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
|
||||
);
|
||||
if ( status != RTEMS_SUCCESSFUL ) {
|
||||
#ifdef DEBUG_GXX_WRAPPERS
|
||||
printk(
|
||||
"gxx_wrappers: mutex init failed %s (%d)\n",
|
||||
rtems_status_text(status),
|
||||
status
|
||||
);
|
||||
#endif
|
||||
_Internal_error( INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED );
|
||||
}
|
||||
#ifdef DEBUG_GXX_WRAPPERS
|
||||
printk( "gxx_wrappers: mutex init complete =%X\n", *mutex );
|
||||
#endif
|
||||
}
|
||||
|
||||
int rtems_gxx_mutex_lock (__gthread_mutex_t *mutex)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
#ifdef DEBUG_GXX_WRAPPERS
|
||||
printk( "gxx_wrappers: lock mutex=%X\n", *mutex );
|
||||
#endif
|
||||
|
||||
status = rtems_semaphore_obtain(
|
||||
*(rtems_id *)mutex,
|
||||
RTEMS_WAIT,
|
||||
RTEMS_NO_TIMEOUT
|
||||
);
|
||||
if ( status == RTEMS_SUCCESSFUL )
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int rtems_gxx_mutex_destroy (__gthread_mutex_t *mutex)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
#ifdef DEBUG_GXX_WRAPPERS
|
||||
printk( "gxx_wrappers: destroy mutex=%X\n", *mutex );
|
||||
#endif
|
||||
|
||||
status = rtems_semaphore_delete(*(rtems_id *)mutex);
|
||||
if ( status == RTEMS_SUCCESSFUL )
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int rtems_gxx_mutex_trylock (__gthread_mutex_t *mutex)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
#ifdef DEBUG_GXX_WRAPPERS
|
||||
printk( "gxx_wrappers: trylock mutex=%X\n", *mutex );
|
||||
#endif
|
||||
|
||||
status = rtems_semaphore_obtain (*(rtems_id *)mutex, RTEMS_NO_WAIT, 0);
|
||||
if ( status == RTEMS_SUCCESSFUL )
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int rtems_gxx_mutex_unlock (__gthread_mutex_t *mutex)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
#ifdef DEBUG_GXX_WRAPPERS
|
||||
printk( "gxx_wrappers: unlock mutex=%X\n", *mutex );
|
||||
#endif
|
||||
|
||||
status = rtems_semaphore_release( *(rtems_id *)mutex );
|
||||
if ( status == RTEMS_SUCCESSFUL )
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void rtems_gxx_recursive_mutex_init(__gthread_recursive_mutex_t *mutex)
|
||||
{
|
||||
rtems_gxx_mutex_init(mutex);
|
||||
}
|
||||
|
||||
int rtems_gxx_recursive_mutex_lock(__gthread_recursive_mutex_t *mutex)
|
||||
{
|
||||
return rtems_gxx_mutex_lock(mutex);
|
||||
}
|
||||
|
||||
int rtems_gxx_recursive_mutex_trylock(__gthread_recursive_mutex_t *mutex)
|
||||
{
|
||||
return rtems_gxx_mutex_trylock(mutex);
|
||||
}
|
||||
|
||||
int rtems_gxx_recursive_mutex_unlock(__gthread_recursive_mutex_t *mutex)
|
||||
{
|
||||
return rtems_gxx_mutex_unlock(mutex);
|
||||
}
|
||||
|
||||
#endif /* __GNUC__ */
|
||||
@@ -108,7 +108,6 @@ install:
|
||||
- cpukit/include/rtems/framebuffer.h
|
||||
- cpukit/include/rtems/fs.h
|
||||
- cpukit/include/rtems/fsmount.h
|
||||
- cpukit/include/rtems/gxx_wrappers.h
|
||||
- cpukit/include/rtems/ide_part_table.h
|
||||
- cpukit/include/rtems/imfs.h
|
||||
- cpukit/include/rtems/init.h
|
||||
@@ -658,7 +657,6 @@ source:
|
||||
- cpukit/libcsupport/src/getreentglobal.c
|
||||
- cpukit/libcsupport/src/getrusage.c
|
||||
- cpukit/libcsupport/src/getuid.c
|
||||
- cpukit/libcsupport/src/gxx_wrappers.c
|
||||
- cpukit/libcsupport/src/ioctl.c
|
||||
- cpukit/libcsupport/src/isatty_r.c
|
||||
- cpukit/libcsupport/src/issetugid.c
|
||||
|
||||
@@ -141,8 +141,6 @@ links:
|
||||
uid: gettimeofday
|
||||
- role: build-dependency
|
||||
uid: getuid
|
||||
- role: build-dependency
|
||||
uid: gxx01
|
||||
- role: build-dependency
|
||||
uid: heapwalk
|
||||
- role: build-dependency
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
|
||||
build-type: test-program
|
||||
cflags: []
|
||||
copyrights:
|
||||
- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||
cppflags: []
|
||||
cxxflags: []
|
||||
enabled-by: true
|
||||
features: c cprogram
|
||||
includes: []
|
||||
ldflags: []
|
||||
links: []
|
||||
source:
|
||||
- testsuites/libtests/gxx01/init.c
|
||||
stlib: []
|
||||
target: testsuites/libtests/gxx01.exe
|
||||
type: build
|
||||
use-after: []
|
||||
use-before: []
|
||||
@@ -237,10 +237,6 @@ links:
|
||||
uid: spfatal14
|
||||
- role: build-dependency
|
||||
uid: spfatal15
|
||||
- role: build-dependency
|
||||
uid: spfatal24
|
||||
- role: build-dependency
|
||||
uid: spfatal25
|
||||
- role: build-dependency
|
||||
uid: spfatal26
|
||||
- role: build-dependency
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
|
||||
build-type: test-program
|
||||
cflags: []
|
||||
copyrights:
|
||||
- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||
cppflags: []
|
||||
cxxflags: []
|
||||
enabled-by: true
|
||||
features: c cprogram
|
||||
includes: []
|
||||
ldflags: []
|
||||
links: []
|
||||
source:
|
||||
- testsuites/sptests/spfatal24/init.c
|
||||
stlib: []
|
||||
target: testsuites/sptests/spfatal24.exe
|
||||
type: build
|
||||
use-after: []
|
||||
use-before: []
|
||||
@@ -1,19 +0,0 @@
|
||||
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
|
||||
build-type: test-program
|
||||
cflags: []
|
||||
copyrights:
|
||||
- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||
cppflags: []
|
||||
cxxflags: []
|
||||
enabled-by: true
|
||||
features: c cprogram
|
||||
includes: []
|
||||
ldflags: []
|
||||
links: []
|
||||
source:
|
||||
- testsuites/sptests/spfatal25/init.c
|
||||
stlib: []
|
||||
target: testsuites/sptests/spfatal25.exe
|
||||
type: build
|
||||
use-after: []
|
||||
use-before: []
|
||||
@@ -1,33 +0,0 @@
|
||||
# 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.org/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_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.
|
||||
@@ -1,35 +0,0 @@
|
||||
*** 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
|
||||
rtems_gxx_mutex_destroy(mutex) - OK
|
||||
rtems_gxx_mutex_destroy(mutex) - NOT 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_getspecific(key) not set - OK
|
||||
rtems_gxx_setspecific(key, 0x1234) - OK
|
||||
rtems_gxx_getspecific(key) already existing - OK
|
||||
rtems_gxx_key_delete(key) - OK
|
||||
rtems_gxx_getspecific(key) non-existent - OK
|
||||
rtems_gxx_key_delete(key) - NOT OK
|
||||
rtems_gxx_setspecific(NULL, 0x1234) - NOT OK
|
||||
rtems_gxx_getspecific(NULL) - OK
|
||||
rtems_gxx_key_delete(NULL) - NOT OK
|
||||
|
||||
*** END OF TEST GXX 01 ***
|
||||
@@ -1,228 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2012.
|
||||
* 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.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <tmacros.h>
|
||||
#include "test_support.h"
|
||||
#include <rtems/gxx_wrappers.h>
|
||||
|
||||
const char rtems_test_name[] = "GXX 1";
|
||||
|
||||
/* forward declarations to avoid warnings */
|
||||
rtems_task Init(rtems_task_argument argument);
|
||||
void test_recursive_mutex(void);
|
||||
void test_mutex(void);
|
||||
void once_function(void);
|
||||
void test_once(void);
|
||||
void key_dtor(void *ptr);
|
||||
void test_key(void);
|
||||
|
||||
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 );
|
||||
|
||||
puts( "rtems_gxx_mutex_destroy(mutex) - OK" );
|
||||
sc = rtems_gxx_mutex_destroy(&mutex);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_mutex_destroy(mutex) - NOT OK" );
|
||||
sc = rtems_gxx_mutex_destroy(&mutex);
|
||||
rtems_test_assert( sc == -1 );
|
||||
}
|
||||
|
||||
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_getspecific(key) not set - OK" );
|
||||
p = rtems_gxx_getspecific(key);
|
||||
rtems_test_assert( p == NULL );
|
||||
|
||||
puts( "rtems_gxx_setspecific(key, 0x1234) - OK" );
|
||||
sc = rtems_gxx_setspecific(key, (void *)0x1234);
|
||||
rtems_test_assert( sc == 0 );
|
||||
|
||||
puts( "rtems_gxx_getspecific(key) already existing - 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 );
|
||||
/* pthread_key man-page: the dtor should _not_ be called */
|
||||
rtems_test_assert( key_dtor_ran != true );
|
||||
|
||||
key = calloc( 1, sizeof( *key ) );
|
||||
rtems_test_assert( key != NULL );
|
||||
|
||||
puts( "rtems_gxx_getspecific(key) non-existent - OK" );
|
||||
p = rtems_gxx_getspecific( key );
|
||||
rtems_test_assert( p == NULL );
|
||||
|
||||
puts( "rtems_gxx_key_delete(key) - NOT OK" );
|
||||
sc = rtems_gxx_key_delete( key );
|
||||
rtems_test_assert( sc != 0 );
|
||||
|
||||
puts( "rtems_gxx_setspecific(NULL, 0x1234) - NOT OK" );
|
||||
sc = rtems_gxx_setspecific( NULL, (void *)0x1234 );
|
||||
rtems_test_assert( sc == EINVAL );
|
||||
|
||||
puts( "rtems_gxx_getspecific(NULL) - OK" );
|
||||
p = rtems_gxx_getspecific( NULL );
|
||||
rtems_test_assert( p == NULL );
|
||||
|
||||
puts( "rtems_gxx_key_delete(NULL) - NOT OK" );
|
||||
sc = rtems_gxx_key_delete( NULL );
|
||||
rtems_test_assert( sc == EINVAL );
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
{
|
||||
TEST_BEGIN();
|
||||
|
||||
test_mutex();
|
||||
puts( "" );
|
||||
|
||||
test_recursive_mutex();
|
||||
puts( "" );
|
||||
|
||||
test_once();
|
||||
puts( "" );
|
||||
|
||||
test_key();
|
||||
puts( "" );
|
||||
|
||||
TEST_END();
|
||||
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
|
||||
#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 1
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 2
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
/* end of file */
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "../spfatal_support/spfatal.h"
|
||||
|
||||
/*
|
||||
* 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.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <rtems/gxx_wrappers.h>
|
||||
#include <rtems/malloc.h>
|
||||
|
||||
#define FATAL_ERROR_TEST_NAME "GXX KEY ADD FAILURE"
|
||||
#define FATAL_ERROR_DESCRIPTION "GXX KEY ADD FAILURE"
|
||||
#define FATAL_ERROR_EXPECTED_SOURCE INTERNAL_ERROR_CORE
|
||||
#define FATAL_ERROR_EXPECTED_ERROR INTERNAL_ERROR_GXX_KEY_ADD_FAILED
|
||||
|
||||
static void force_error(void)
|
||||
{
|
||||
pthread_key_t key = -1;
|
||||
|
||||
rtems_gxx_setspecific( &key, NULL );
|
||||
}
|
||||
|
||||
#include "../spfatal_support/spfatalimpl.h"
|
||||
@@ -1,19 +0,0 @@
|
||||
# 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.org/license/LICENSE.
|
||||
#
|
||||
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: spfatal24
|
||||
|
||||
directives:
|
||||
|
||||
rtems_gxx_setspecific();
|
||||
|
||||
concepts:
|
||||
|
||||
+ Trigger fatal error.
|
||||
@@ -1,3 +0,0 @@
|
||||
*** TEST FATAL GXX KEY ADD FAILURE ***
|
||||
Fatal error (GXX KEY ADD FAILURE) hit
|
||||
*** END OF TEST FATAL GXX KEY ADD FAILURE ***
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "../spfatal_support/spfatal.h"
|
||||
|
||||
/*
|
||||
* 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.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <rtems/gxx_wrappers.h>
|
||||
|
||||
#define FATAL_ERROR_TEST_NAME "GXX MUTEX INIT FAILED"
|
||||
#define FATAL_ERROR_DESCRIPTION "GXX MUTEX INIT FAILED"
|
||||
#define FATAL_ERROR_EXPECTED_SOURCE INTERNAL_ERROR_CORE
|
||||
#define FATAL_ERROR_EXPECTED_ERROR INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED
|
||||
|
||||
static void force_error(void)
|
||||
{
|
||||
__gthread_mutex_t mutex;
|
||||
|
||||
while ( true ) {
|
||||
rtems_gxx_mutex_init( &mutex );
|
||||
rtems_test_assert( mutex != 0 );
|
||||
}
|
||||
}
|
||||
|
||||
#include "../spfatal_support/spfatalimpl.h"
|
||||
@@ -1,19 +0,0 @@
|
||||
# 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.org/license/LICENSE.
|
||||
#
|
||||
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: spfatal24
|
||||
|
||||
directives:
|
||||
|
||||
rtems_gxx_getspecific();
|
||||
|
||||
concepts:
|
||||
|
||||
+ Trigger fatal error.
|
||||
@@ -1,3 +0,0 @@
|
||||
*** TEST FATAL GXX MUTEX INIT FAILED ***
|
||||
Fatal error (GXX MUTEX INIT FAILED) hit
|
||||
*** END OF TEST FATAL GXX MUTEX INIT FAILED ***
|
||||
Reference in New Issue
Block a user