[PATCH 1/8] score: Add and use RTEMS_ARRAY_SIZE()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Nov 7 16:05:56 UTC 2012


---
 cpukit/sapi/include/confdefs.h              |   10 ++++------
 cpukit/score/include/rtems/score/basedefs.h |    2 ++
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index e32942b..5afac3a 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -1022,7 +1022,7 @@ rtems_fs_init_functions_t    rtems_fs_init_helper =
 #define CONFIGURE_INIT_TASK_TABLE Initialization_tasks
 
 #define CONFIGURE_INIT_TASK_TABLE_SIZE \
-  sizeof(CONFIGURE_INIT_TASK_TABLE) / sizeof(rtems_initialization_tasks_table)
+  RTEMS_ARRAY_SIZE(CONFIGURE_INIT_TASK_TABLE)
 
 #endif    /* CONFIGURE_HAS_OWN_INIT_TASK_TABLE */
 
@@ -1150,7 +1150,7 @@ rtems_fs_init_functions_t    rtems_fs_init_helper =
  */
 
 #define CONFIGURE_NUMBER_OF_DRIVERS \
-  ((sizeof(Device_drivers) / sizeof(rtems_driver_address_table)))
+  RTEMS_ARRAY_SIZE(Device_drivers)
 
 /**
  *  This specifies the maximum number of device drivers that
@@ -1622,8 +1622,7 @@ rtems_fs_init_functions_t    rtems_fs_init_helper =
 
   #define CONFIGURE_INITIAL_EXTENSION_TABLE Configuration_Initial_Extensions
   #define CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \
-    ((sizeof(Configuration_Initial_Extensions) / \
-      sizeof(rtems_extensions_table)))
+    RTEMS_ARRAY_SIZE(Configuration_Initial_Extensions)
 #else
   #define CONFIGURE_INITIAL_EXTENSION_TABLE NULL
   #define CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS 0
@@ -1797,8 +1796,7 @@ rtems_fs_init_functions_t    rtems_fs_init_helper =
               POSIX_Initialization_threads
 
       #define CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE \
-        sizeof(CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME) / \
-            sizeof(posix_initialization_threads_table)
+              RTEMS_ARRAY_SIZE(CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME)
 
     #endif    /* CONFIGURE_POSIX_HAS_OWN_INIT_TASK_TABLE */
 
diff --git a/cpukit/score/include/rtems/score/basedefs.h b/cpukit/score/include/rtems/score/basedefs.h
index 8239994..e91467d 100644
--- a/cpukit/score/include/rtems/score/basedefs.h
+++ b/cpukit/score/include/rtems/score/basedefs.h
@@ -174,6 +174,8 @@
     typedef int rtems_static_assert_ ## msg [(cond) ? 1 : -1]
 #endif
 
+#define RTEMS_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
+
 #ifndef ASM
   #ifdef RTEMS_DEPRECATED_TYPES
     typedef bool boolean;
-- 
1.7.7




More information about the devel mailing list