[rtems commit] posix: glibc compatibility
Sebastian Huber
sebh at rtems.org
Wed Sep 2 13:05:24 UTC 2015
Module: rtems
Branch: master
Commit: 3b3d1489e409d451b4e7ffabd706d0205f400def
Changeset: http://git.rtems.org/rtems/commit/?id=3b3d1489e409d451b4e7ffabd706d0205f400def
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue Sep 1 14:16:48 2015 +0200
posix: glibc compatibility
---
cpukit/posix/src/setcancelstate.c | 7 +++----
cpukit/posix/src/setcanceltype.c | 7 +++----
testsuites/psxtests/psxcancel/init.c | 8 ++++----
testsuites/psxtests/psxcancel/psxcancel.scn | 6 +++---
4 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/cpukit/posix/src/setcancelstate.c b/cpukit/posix/src/setcancelstate.c
index 0ae7339..a451c2c 100644
--- a/cpukit/posix/src/setcancelstate.c
+++ b/cpukit/posix/src/setcancelstate.c
@@ -50,9 +50,6 @@ int pthread_setcancelstate(
if ( _ISR_Is_in_progress() )
return EPROTO;
- if ( !oldstate )
- return EINVAL;
-
if ( state != PTHREAD_CANCEL_ENABLE && state != PTHREAD_CANCEL_DISABLE )
return EINVAL;
@@ -61,7 +58,9 @@ int pthread_setcancelstate(
executing = _Thread_Executing;
thread_support = executing ->API_Extensions[ THREAD_API_POSIX ];
- *oldstate = thread_support->cancelability_state;
+ if (oldstate != NULL)
+ *oldstate = thread_support->cancelability_state;
+
thread_support->cancelability_state = state;
_POSIX_Thread_Evaluate_cancellation_and_enable_dispatch( executing );
diff --git a/cpukit/posix/src/setcanceltype.c b/cpukit/posix/src/setcanceltype.c
index 2ad7cc9..8c4687a 100644
--- a/cpukit/posix/src/setcanceltype.c
+++ b/cpukit/posix/src/setcanceltype.c
@@ -50,9 +50,6 @@ int pthread_setcanceltype(
if ( _ISR_Is_in_progress() )
return EPROTO;
- if ( !oldtype )
- return EINVAL;
-
if ( type != PTHREAD_CANCEL_DEFERRED && type != PTHREAD_CANCEL_ASYNCHRONOUS )
return EINVAL;
@@ -61,7 +58,9 @@ int pthread_setcanceltype(
executing = _Thread_Executing;
thread_support = executing ->API_Extensions[ THREAD_API_POSIX ];
- *oldtype = thread_support->cancelability_type;
+ if ( oldtype != NULL )
+ *oldtype = thread_support->cancelability_type;
+
thread_support->cancelability_type = type;
_POSIX_Thread_Evaluate_cancellation_and_enable_dispatch( executing );
diff --git a/testsuites/psxtests/psxcancel/init.c b/testsuites/psxtests/psxcancel/init.c
index 2007529..4af4e76 100644
--- a/testsuites/psxtests/psxcancel/init.c
+++ b/testsuites/psxtests/psxcancel/init.c
@@ -95,17 +95,17 @@ void *countTaskAsync(void *ignored)
TEST_BEGIN();
/* generate some error conditions */
- puts( "Init - pthread_setcancelstate - NULL oldstate - EINVAL" );
+ puts( "Init - pthread_setcancelstate - NULL oldstate" );
sc = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- fatal_posix_service_status( sc, EINVAL, "cancel state EINVAL" );
+ fatal_posix_service_status( sc, 0, "cancel state NULL" );
puts( "Init - pthread_setcancelstate - bad state - EINVAL" );
sc = pthread_setcancelstate(12, &old);
fatal_posix_service_status( sc, EINVAL, "cancel state EINVAL" );
- puts( "Init - pthread_setcanceltype - NULL oldtype - EINVAL" );
+ puts( "Init - pthread_setcanceltype - NULL oldtype" );
sc = pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
- fatal_posix_service_status( sc, EINVAL, "cancel type EINVAL" );
+ fatal_posix_service_status( sc, 0, "cancel type NULL" );
puts( "Init - pthread_setcanceltype - bad type - EINVAL" );
sc = pthread_setcanceltype(12, &old);
diff --git a/testsuites/psxtests/psxcancel/psxcancel.scn b/testsuites/psxtests/psxcancel/psxcancel.scn
index b51dd73..7bc9498 100644
--- a/testsuites/psxtests/psxcancel/psxcancel.scn
+++ b/testsuites/psxtests/psxcancel/psxcancel.scn
@@ -1,7 +1,7 @@
-*** POSIX CANCEL TEST ***
-Init - pthread_setcancelstate - NULL oldstate - EINVAL
+*** BEGIN OF TEST PSXCANCEL ***
+Init - pthread_setcancelstate - NULL oldstate
Init - pthread_setcancelstate - bad state - EINVAL
-Init - pthread_setcanceltype - NULL oldtype - EINVAL
+Init - pthread_setcanceltype - NULL oldtype
Init - pthread_setcanceltype - bad type - EINVAL
Init - pthread_cancel - bad ID - EINVAL
countTaskDeferred: elapsed time (second): 0
More information about the vc
mailing list