From 4bc8d2e71774452e66c619dad98ccab6db8a2324 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 10 Apr 2014 10:58:27 +0200 Subject: rtems: Rename rtems_smp_get_processor_count() 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 e1430b2e40..c3c9e988cf 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 b74414b8de..e77ac2c006 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 6cb5181188..4e6438c780 100644 --- a/cpukit/rtems/Makefile.am +++ b/cpukit/rtems/Makefile.am @@ -259,6 +259,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 d2904e4191..b327514c09 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 0000000000..438eec6635 --- /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 + * + * + * 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 +#include + +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 bc98205c36..0fd96fa12d 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 91a6e4056c..8439293d95 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; iworker_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 0ba627a138..178148b123 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 c801a287b9..fb42e5d411 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 714e7b9ee4..13a9db511a 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 b26437c95d..e85d89e780 100644 --- a/testsuites/smptests/smpload01/init.c +++ b/testsuites/smptests/smpload01/init.c @@ -81,7 +81,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) { @@ -338,7 +338,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, @@ -373,7 +373,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 f0d9c92ebe..85995e8e99 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 e4929119b8..fe321c8787 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 54851490a9..cb9e0b37d9 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 7916e60ece..ad98da4ec1 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 495af063a7..61eaec1667 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 a0d37602b3..10ac735ca2 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 d5d31d5a06..1aaa70090a 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 017ff97e9d..eda8a9cfde 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 8ff5ea1c50..38b054f41c 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 2f5ada40b5..c5162a29a6 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; -- cgit v1.2.3