[PATCH 1/2] rtems: Rename rtems_smp_get_processor_count()
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Apr 10 09:06:38 UTC 2014
Rename rtems_smp_get_processor_count() in rtems_get_processor_count().
Make rtems_get_processor_count() a function in uni-processor
configurations to enable ABI compatibility with SMP configurations.
---
c/src/lib/libbsp/sparc/leon3/startup/bspreset.c | 2 +-
cpukit/libmisc/cpuuse/cpuusagereset.c | 2 +-
cpukit/rtems/Makefile.am | 2 +
cpukit/rtems/include/rtems/rtems/smp.h | 6 +---
cpukit/rtems/src/getprocessorcount.c | 25 +++++++++++++++++++++++
cpukit/sapi/src/profilingiterate.c | 2 +-
testsuites/smptests/smp01/init.c | 6 ++--
testsuites/smptests/smp02/init.c | 4 +-
testsuites/smptests/smp03/init.c | 10 ++++----
testsuites/smptests/smp05/init.c | 4 +-
testsuites/smptests/smp07/init.c | 2 +-
testsuites/smptests/smp08/init.c | 2 +-
testsuites/smptests/smp09/init.c | 2 +-
testsuites/smptests/smpaffinity01/init.c | 2 +-
testsuites/smptests/smpatomic01/init.c | 2 +-
testsuites/smptests/smpfatal01/init.c | 2 +-
testsuites/smptests/smpfatal02/init.c | 2 +-
testsuites/smptests/smpfatal03/init.c | 2 +-
testsuites/smptests/smpload01/init.c | 6 ++--
testsuites/smptests/smplock01/init.c | 4 +-
testsuites/smptests/smpmigration01/init.c | 2 +-
testsuites/smptests/smppsxaffinity01/init.c | 2 +-
testsuites/smptests/smppsxaffinity02/init.c | 2 +-
testsuites/smptests/smppsxsignal01/init.c | 2 +-
testsuites/smptests/smpscheduler01/init.c | 2 +-
testsuites/smptests/smpsignal01/init.c | 2 +-
testsuites/smptests/smpswitchextension01/init.c | 2 +-
testsuites/smptests/smpthreadlife01/init.c | 2 +-
testsuites/tmtests/tmcontext01/init.c | 2 +-
29 files changed, 66 insertions(+), 41 deletions(-)
create mode 100644 cpukit/rtems/src/getprocessorcount.c
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/bspreset.c b/c/src/lib/libbsp/sparc/leon3/startup/bspreset.c
index e1430b2..c3c9e98 100644
--- a/c/src/lib/libbsp/sparc/leon3/startup/bspreset.c
+++ b/c/src/lib/libbsp/sparc/leon3/startup/bspreset.c
@@ -32,7 +32,7 @@ void bsp_reset(void)
*/
uint32_t max_wait = 1234567;
- uint32_t cpu_count = rtems_smp_get_processor_count();
+ uint32_t cpu_count = rtems_get_processor_count();
uint32_t halt_mask = 0;
uint32_t i;
diff --git a/cpukit/libmisc/cpuuse/cpuusagereset.c b/cpukit/libmisc/cpuuse/cpuusagereset.c
index b74414b..e77ac2c 100644
--- a/cpukit/libmisc/cpuuse/cpuusagereset.c
+++ b/cpukit/libmisc/cpuuse/cpuusagereset.c
@@ -45,7 +45,7 @@ void rtems_cpu_usage_reset( void )
_TOD_Get_uptime( &CPU_usage_Uptime_at_last_reset );
- processor_count = rtems_smp_get_processor_count();
+ processor_count = rtems_get_processor_count();
for ( processor = 0 ; processor < processor_count ; ++processor ) {
Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( processor );
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index 062b986..fc2a0e1 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -266,6 +266,8 @@ librtems_a_SOURCES += src/modes.c
librtems_a_SOURCES += src/status.c
librtems_a_SOURCES += src/statustext.c
+librtems_a_SOURCES += src/getprocessorcount.c
+
if HAS_MP
# We only build multiprocessing related files if HAS_MP was defined
librtems_a_SOURCES += src/eventmp.c
diff --git a/cpukit/rtems/include/rtems/rtems/smp.h b/cpukit/rtems/include/rtems/rtems/smp.h
index d2904e4..b327514 100644
--- a/cpukit/rtems/include/rtems/rtems/smp.h
+++ b/cpukit/rtems/include/rtems/rtems/smp.h
@@ -40,8 +40,7 @@ extern "C" {
/**
* @brief Returns the count of processors in the system.
*
- * On uni-processor configurations this is a compile time constant and defined
- * to be one.
+ * On uni-processor configurations a value of one will be returned.
*
* On SMP configurations this returns the value of a global variable set during
* system initialization to indicate the count of processors. The processor
@@ -51,8 +50,7 @@ extern "C" {
*
* @return The count of processors in the system.
*/
-#define rtems_smp_get_processor_count() \
- _SMP_Get_processor_count()
+uint32_t rtems_get_processor_count(void);
/**
* @brief Returns the index of the current processor.
diff --git a/cpukit/rtems/src/getprocessorcount.c b/cpukit/rtems/src/getprocessorcount.c
new file mode 100644
index 0000000..438eec6
--- /dev/null
+++ b/cpukit/rtems/src/getprocessorcount.c
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems at embedded-brains.de>
+ *
+ * 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.
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/rtems/smp.h>
+#include <rtems/score/smp.h>
+
+uint32_t rtems_get_processor_count(void)
+{
+ return _SMP_Get_processor_count();
+}
diff --git a/cpukit/sapi/src/profilingiterate.c b/cpukit/sapi/src/profilingiterate.c
index bc98205..0fd96fa 100644
--- a/cpukit/sapi/src/profilingiterate.c
+++ b/cpukit/sapi/src/profilingiterate.c
@@ -30,7 +30,7 @@ static void per_cpu_stats_iterate(
)
{
#ifdef RTEMS_PROFILING
- uint32_t n = rtems_smp_get_processor_count();
+ uint32_t n = rtems_get_processor_count();
uint32_t i;
memset(data, 0, sizeof(*data));
diff --git a/testsuites/smptests/smp01/init.c b/testsuites/smptests/smp01/init.c
index 91a6e40..8439293 100644
--- a/testsuites/smptests/smp01/init.c
+++ b/testsuites/smptests/smp01/init.c
@@ -48,12 +48,12 @@ rtems_task Init(
locked_print_initialize();
/* Initialize the TaskRan array */
- for ( i=0; i<rtems_smp_get_processor_count() ; i++ ) {
+ for ( i=0; i<rtems_get_processor_count() ; i++ ) {
TaskRan[i] = false;
}
/* Create and start tasks for each processor */
- for ( i=0; i< rtems_smp_get_processor_count() ; i++ ) {
+ for ( i=0; i< rtems_get_processor_count() ; i++ ) {
if ( i != cpu_self ) {
ch = '0' + i;
@@ -78,7 +78,7 @@ rtems_task Init(
/* Wait on the all tasks to run */
while (1) {
allDone = true;
- for ( i=0; i<rtems_smp_get_processor_count() ; i++ ) {
+ for ( i=0; i<rtems_get_processor_count() ; i++ ) {
if ( i != cpu_self && TaskRan[i] == false)
allDone = false;
}
diff --git a/testsuites/smptests/smp02/init.c b/testsuites/smptests/smp02/init.c
index c2cf5a3..05f6351 100644
--- a/testsuites/smptests/smp02/init.c
+++ b/testsuites/smptests/smp02/init.c
@@ -40,7 +40,7 @@ rtems_task Init(
locked_print_initialize();
- if ( rtems_smp_get_processor_count() == 1 ) {
+ if ( rtems_get_processor_count() == 1 ) {
success();
}
@@ -59,7 +59,7 @@ rtems_task Init(
status = rtems_semaphore_obtain( Semaphore, RTEMS_WAIT, 0);
directive_failed( status,"rtems_semaphore_obtain of SEM1\n");
- for ( i=1; i < rtems_smp_get_processor_count(); i++ ){
+ for ( i=1; i < rtems_get_processor_count(); i++ ){
/* Create and start tasks for each CPU */
ch = '0' + i;
diff --git a/testsuites/smptests/smp03/init.c b/testsuites/smptests/smp03/init.c
index 0d0bb62..3acdfe9 100644
--- a/testsuites/smptests/smp03/init.c
+++ b/testsuites/smptests/smp03/init.c
@@ -57,13 +57,13 @@ rtems_task Init(
locked_print_initialize();
- if ( rtems_smp_get_processor_count() == 1 ) {
+ if ( rtems_get_processor_count() == 1 ) {
success();
}
/* Initialize the TaskRan array */
TaskRan[0] = true;
- for ( i=1; i<rtems_smp_get_processor_count() ; i++ ) {
+ for ( i=1; i<rtems_get_processor_count() ; i++ ) {
TaskRan[i] = false;
}
@@ -71,7 +71,7 @@ rtems_task Init(
PrintTaskInfo( "Init" );
/* for each remaining cpu create and start a task */
- for ( i=1; i < rtems_smp_get_processor_count(); i++ ){
+ for ( i=1; i < rtems_get_processor_count(); i++ ){
ch = '0' + i;
@@ -101,12 +101,12 @@ rtems_task Init(
RTEMS_DEFAULT_ATTRIBUTES,
&id
);
- status = rtems_task_start(id,Test_task,rtems_smp_get_processor_count());
+ status = rtems_task_start(id,Test_task,rtems_get_processor_count());
/* Wait on all tasks to run */
while (1) {
TestFinished = true;
- for ( i=1; i < (rtems_smp_get_processor_count()+1) ; i++ ) {
+ for ( i=1; i < (rtems_get_processor_count()+1) ; i++ ) {
if (TaskRan[i] == false)
TestFinished = false;
}
diff --git a/testsuites/smptests/smp05/init.c b/testsuites/smptests/smp05/init.c
index 23669ec..cf7ea3a 100644
--- a/testsuites/smptests/smp05/init.c
+++ b/testsuites/smptests/smp05/init.c
@@ -44,11 +44,11 @@ rtems_task Init(
locked_print_initialize();
- if ( rtems_smp_get_processor_count() == 1 ) {
+ if ( rtems_get_processor_count() == 1 ) {
success();
}
- for ( i=0; i<rtems_smp_get_processor_count() ; i++ ) {
+ for ( i=0; i<rtems_get_processor_count() ; i++ ) {
ch = '1' + i;
status = rtems_task_create(
diff --git a/testsuites/smptests/smp07/init.c b/testsuites/smptests/smp07/init.c
index 5f9c496..53993ce 100644
--- a/testsuites/smptests/smp07/init.c
+++ b/testsuites/smptests/smp07/init.c
@@ -93,7 +93,7 @@ rtems_task Init(
locked_print_initialize();
- if ( rtems_smp_get_processor_count() == 1 ) {
+ if ( rtems_get_processor_count() == 1 ) {
success();
}
diff --git a/testsuites/smptests/smp08/init.c b/testsuites/smptests/smp08/init.c
index aee7c18..dc4c789 100644
--- a/testsuites/smptests/smp08/init.c
+++ b/testsuites/smptests/smp08/init.c
@@ -76,7 +76,7 @@ rtems_task Init(
/* Show that the init task is running on this cpu */
PrintTaskInfo( "Init", &time );
- for ( i=1; i <= rtems_smp_get_processor_count() *3; i++ ) {
+ for ( i=1; i <= rtems_get_processor_count() *3; i++ ) {
sprintf(ch, "%02" PRId32, i );
status = rtems_task_create(
diff --git a/testsuites/smptests/smp09/init.c b/testsuites/smptests/smp09/init.c
index 7128198..09e9c09 100644
--- a/testsuites/smptests/smp09/init.c
+++ b/testsuites/smptests/smp09/init.c
@@ -45,7 +45,7 @@ rtems_task Init(
for ( killtime=0; killtime<1000000; killtime++ )
;
- for ( i=0; i<rtems_smp_get_processor_count() -1; i++ ) {
+ for ( i=0; i<rtems_get_processor_count() -1; i++ ) {
ch = '1' + i;
status = rtems_task_create(
diff --git a/testsuites/smptests/smpaffinity01/init.c b/testsuites/smptests/smpaffinity01/init.c
index cc5f321..06d5719 100644
--- a/testsuites/smptests/smpaffinity01/init.c
+++ b/testsuites/smptests/smpaffinity01/init.c
@@ -112,7 +112,7 @@ void Validate_affinity(void )
directive_failed( sc, "Get Affinity of Init Task" );
/* Get the number of processors that we are using. */
- cpu_count = rtems_smp_get_processor_count();
+ cpu_count = rtems_get_processor_count();
/* Fill the remaining cpus with med priority tasks */
puts( "Init - Create Medium priority tasks");
diff --git a/testsuites/smptests/smpatomic01/init.c b/testsuites/smptests/smpatomic01/init.c
index e055ea4..283200b 100644
--- a/testsuites/smptests/smpatomic01/init.c
+++ b/testsuites/smptests/smpatomic01/init.c
@@ -446,7 +446,7 @@ static void test(void)
test_static_and_dynamic_initialization();
- ctx->worker_count = rtems_smp_get_processor_count();
+ ctx->worker_count = rtems_get_processor_count();
sc = rtems_timer_create(
rtems_build_name('S', 'T', 'O', 'P'),
diff --git a/testsuites/smptests/smpfatal01/init.c b/testsuites/smptests/smpfatal01/init.c
index 0ba627a..178148b 100644
--- a/testsuites/smptests/smpfatal01/init.c
+++ b/testsuites/smptests/smpfatal01/init.c
@@ -69,7 +69,7 @@ static rtems_status_code test_driver_init(
)
{
uint32_t self = rtems_smp_get_current_processor();
- uint32_t cpu_count = rtems_smp_get_processor_count();
+ uint32_t cpu_count = rtems_get_processor_count();
uint32_t cpu;
rtems_test_begink();
diff --git a/testsuites/smptests/smpfatal02/init.c b/testsuites/smptests/smpfatal02/init.c
index c801a28..fb42e5d 100644
--- a/testsuites/smptests/smpfatal02/init.c
+++ b/testsuites/smptests/smpfatal02/init.c
@@ -77,7 +77,7 @@ static rtems_status_code test_driver_init(
)
{
uint32_t self = rtems_smp_get_current_processor();
- uint32_t cpu_count = rtems_smp_get_processor_count();
+ uint32_t cpu_count = rtems_get_processor_count();
uint32_t cpu;
rtems_test_begink();
diff --git a/testsuites/smptests/smpfatal03/init.c b/testsuites/smptests/smpfatal03/init.c
index 714e7b9..13a9db5 100644
--- a/testsuites/smptests/smpfatal03/init.c
+++ b/testsuites/smptests/smpfatal03/init.c
@@ -68,7 +68,7 @@ static void wait_for_giant(void)
static void Init(rtems_task_argument arg)
{
uint32_t self = rtems_smp_get_current_processor();
- uint32_t cpu_count = rtems_smp_get_processor_count();
+ uint32_t cpu_count = rtems_get_processor_count();
rtems_test_begink();
diff --git a/testsuites/smptests/smpload01/init.c b/testsuites/smptests/smpload01/init.c
index 56faac0..7f0169d 100644
--- a/testsuites/smptests/smpload01/init.c
+++ b/testsuites/smptests/smpload01/init.c
@@ -82,7 +82,7 @@ static void inherit_obtain_task(rtems_task_argument arg)
test_context *ctx = &test_instance;
rtems_status_code sc;
SMP_barrier_State barrier_state = SMP_BARRIER_STATE_INITIALIZER;
- uint32_t cpu_count = rtems_smp_get_processor_count();
+ uint32_t cpu_count = rtems_get_processor_count();
rtems_counter_ticks delay = (cpu_count - 1 - arg) * ctx->inherit_obtain_delay;
while (true) {
@@ -352,7 +352,7 @@ static void test(void)
sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
- for (i = 0; i < rtems_smp_get_processor_count(); ++i) {
+ for (i = 0; i < rtems_get_processor_count(); ++i) {
sc = rtems_task_create(
rtems_build_name('I', 'N', 'H', 'O'),
INHERIT_OBTAIN_PRIO_BASE + i,
@@ -387,7 +387,7 @@ static void test(void)
ctx->inherit_release_counter
);
- for (i = 0; i < rtems_smp_get_processor_count(); ++i) {
+ for (i = 0; i < rtems_get_processor_count(); ++i) {
printf(
"priority inheritance obtain count %2" PRIu32 ": %" PRIu64 "\n",
i,
diff --git a/testsuites/smptests/smplock01/init.c b/testsuites/smptests/smplock01/init.c
index f0d9c92..85995e8 100644
--- a/testsuites/smptests/smplock01/init.c
+++ b/testsuites/smptests/smplock01/init.c
@@ -259,7 +259,7 @@ static void run_tests(
static void task(rtems_task_argument arg)
{
global_context *ctx = (global_context *) arg;
- uint32_t cpu_count = rtems_smp_get_processor_count();
+ uint32_t cpu_count = rtems_get_processor_count();
uint32_t cpu_self = rtems_smp_get_current_processor();
rtems_status_code sc;
SMP_barrier_State bs = SMP_BARRIER_STATE_INITIALIZER;
@@ -273,7 +273,7 @@ static void task(rtems_task_argument arg)
static void test(void)
{
global_context *ctx = &context;
- uint32_t cpu_count = rtems_smp_get_processor_count();
+ uint32_t cpu_count = rtems_get_processor_count();
uint32_t cpu_self = rtems_smp_get_current_processor();
uint32_t cpu;
int test;
diff --git a/testsuites/smptests/smpmigration01/init.c b/testsuites/smptests/smpmigration01/init.c
index e492911..fe321c8 100644
--- a/testsuites/smptests/smpmigration01/init.c
+++ b/testsuites/smptests/smpmigration01/init.c
@@ -224,7 +224,7 @@ static void Init(rtems_task_argument arg)
{
TEST_BEGIN();
- if (rtems_smp_get_processor_count() >= 2) {
+ if (rtems_get_processor_count() >= 2) {
test();
}
diff --git a/testsuites/smptests/smppsxaffinity01/init.c b/testsuites/smptests/smppsxaffinity01/init.c
index 5485149..cb9e0b3 100644
--- a/testsuites/smptests/smppsxaffinity01/init.c
+++ b/testsuites/smptests/smppsxaffinity01/init.c
@@ -106,7 +106,7 @@ void Validate_attr(void )
rtems_test_assert( priority != -1 );
- cpus = rtems_smp_get_processor_count();
+ cpus = rtems_get_processor_count();
puts(
"Init - Validate pthread_attr_setaffinity_np and "
"pthread_attr_getaffinity_np"
diff --git a/testsuites/smptests/smppsxaffinity02/init.c b/testsuites/smptests/smppsxaffinity02/init.c
index 7916e60..ad98da4 100644
--- a/testsuites/smptests/smppsxaffinity02/init.c
+++ b/testsuites/smptests/smppsxaffinity02/init.c
@@ -121,7 +121,7 @@ void Validate_affinity(void )
rtems_test_assert( !sc );
/* Get the number of processors that we are using. */
- cpu_count = rtems_smp_get_processor_count();
+ cpu_count = rtems_get_processor_count();
/* Fill the remaining cpus with med priority tasks */
puts( "Init - Create Medium priority tasks");
diff --git a/testsuites/smptests/smppsxsignal01/init.c b/testsuites/smptests/smppsxsignal01/init.c
index 495af06..61eaec1 100644
--- a/testsuites/smptests/smppsxsignal01/init.c
+++ b/testsuites/smptests/smppsxsignal01/init.c
@@ -165,7 +165,7 @@ static void *POSIX_Init(void *arg)
{
TEST_BEGIN();
- if (rtems_smp_get_processor_count() >= 2) {
+ if (rtems_get_processor_count() >= 2) {
test();
}
diff --git a/testsuites/smptests/smpscheduler01/init.c b/testsuites/smptests/smpscheduler01/init.c
index a0d3760..10ac735 100644
--- a/testsuites/smptests/smpscheduler01/init.c
+++ b/testsuites/smptests/smpscheduler01/init.c
@@ -69,7 +69,7 @@ static void task(rtems_task_argument arg)
static bool is_per_cpu_state_ok(void)
{
bool ok = true;
- uint32_t n = rtems_smp_get_processor_count();
+ uint32_t n = rtems_get_processor_count();
uint32_t i;
for (i = 0; i < n; ++i) {
diff --git a/testsuites/smptests/smpsignal01/init.c b/testsuites/smptests/smpsignal01/init.c
index d5d31d5..1aaa700 100644
--- a/testsuites/smptests/smpsignal01/init.c
+++ b/testsuites/smptests/smpsignal01/init.c
@@ -166,7 +166,7 @@ static void Init(rtems_task_argument arg)
{
TEST_BEGIN();
- if (rtems_smp_get_processor_count() >= 2) {
+ if (rtems_get_processor_count() >= 2) {
test();
}
diff --git a/testsuites/smptests/smpswitchextension01/init.c b/testsuites/smptests/smpswitchextension01/init.c
index 017ff97..eda8a9c 100644
--- a/testsuites/smptests/smpswitchextension01/init.c
+++ b/testsuites/smptests/smpswitchextension01/init.c
@@ -225,7 +225,7 @@ static void Init(rtems_task_argument arg)
{
TEST_BEGIN();
- if (rtems_smp_get_processor_count() >= 2) {
+ if (rtems_get_processor_count() >= 2) {
test();
}
diff --git a/testsuites/smptests/smpthreadlife01/init.c b/testsuites/smptests/smpthreadlife01/init.c
index 8ff5ea1..38b054f 100644
--- a/testsuites/smptests/smpthreadlife01/init.c
+++ b/testsuites/smptests/smpthreadlife01/init.c
@@ -298,7 +298,7 @@ static void Init(rtems_task_argument arg)
{
TEST_BEGIN();
- if (rtems_smp_get_processor_count() >= CPU_COUNT) {
+ if (rtems_get_processor_count() >= CPU_COUNT) {
test_restart();
test_delete();
test_set_life_protection();
diff --git a/testsuites/tmtests/tmcontext01/init.c b/testsuites/tmtests/tmcontext01/init.c
index 2f5ada4..c5162a29 100644
--- a/testsuites/tmtests/tmcontext01/init.c
+++ b/testsuites/tmtests/tmcontext01/init.c
@@ -214,7 +214,7 @@ static void Init(rtems_task_argument arg)
test(false, load);
test(true, load);
- for (load = 1; load < rtems_smp_get_processor_count(); ++load) {
+ for (load = 1; load < rtems_get_processor_count(); ++load) {
rtems_status_code sc;
rtems_id id;
volatile int *load_data = NULL;
--
1.7.7
More information about the devel
mailing list