[PATCH 6/8] libcsupport: Make LibIO helper const

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Apr 25 09:19:59 UTC 2013


Add and use rtems_libio_helper function type.  Add and use
rtems_libio_helper_null() instead of NULL pointer.
---
 c/src/lib/libbsp/shared/bsplibc.c          |    4 +--
 c/src/lib/libbsp/shared/bsppost.c          |    7 +-----
 cpukit/libcsupport/Makefile.am             |    1 +
 cpukit/libcsupport/include/rtems/libio.h   |   15 +++++++------
 cpukit/libcsupport/src/libio_helper_null.c |   30 ++++++++++++++++++++++++++++
 cpukit/libcsupport/src/libio_init.c        |    4 +--
 cpukit/sapi/include/confdefs.h             |   30 ++++++++++++++--------------
 7 files changed, 57 insertions(+), 34 deletions(-)
 create mode 100644 cpukit/libcsupport/src/libio_helper_null.c

diff --git a/c/src/lib/libbsp/shared/bsplibc.c b/c/src/lib/libbsp/shared/bsplibc.c
index 181dcff..58fcf65 100644
--- a/c/src/lib/libbsp/shared/bsplibc.c
+++ b/c/src/lib/libbsp/shared/bsplibc.c
@@ -3,7 +3,6 @@
  *  On-Line Applications Research Corporation (OAR).
  */
 
-#include <rtems.h>
 #include <rtems/libio.h>
 #include <rtems/libcsupport.h>
 
@@ -16,8 +15,7 @@ void bsp_libc_init(void)
      *  calls for use by newlib (ie: provide open, close, etc)
      *  Uses malloc() to get area for the iops, so must be after malloc init
      */
-    if (rtems_libio_init_helper)
-	(*rtems_libio_init_helper)();
+   (*rtems_libio_init_helper)();
 
     /*
      * Set up for the libc handling.
diff --git a/c/src/lib/libbsp/shared/bsppost.c b/c/src/lib/libbsp/shared/bsppost.c
index ec5e57d..351e4d7 100644
--- a/c/src/lib/libbsp/shared/bsppost.c
+++ b/c/src/lib/libbsp/shared/bsppost.c
@@ -12,16 +12,11 @@
  *  http://www.rtems.com/license/LICENSE.
  */
 
-#include <fcntl.h>
-
-#include <rtems.h>
 #include <rtems/libio.h>
-#include <rtems/libcsupport.h>
 
 #include <bsp/bootcard.h>
 
 void bsp_postdriver_hook(void)
 {
-  if (rtems_libio_supp_helper)
-    (*rtems_libio_supp_helper)();
+  (*rtems_libio_supp_helper)();
 }
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
index 76147c9..42de63c 100644
--- a/cpukit/libcsupport/Makefile.am
+++ b/cpukit/libcsupport/Makefile.am
@@ -55,6 +55,7 @@ ASSOCIATION_C_FILES = src/assoclocalbyname.c \
 BASE_FS_C_FILES = src/base_fs.c src/mount.c src/unmount.c src/libio.c \
     src/mount-mgr.c src/mount-mktgt.c src/libio_init.c \
     src/privateenv.c \
+    src/libio_helper_null.c \
     src/open_dev_console.c src/__usrenv.c src/rtems_mkdir.c
 
 TERMIOS_C_FILES = src/cfgetispeed.c src/cfgetospeed.c src/cfsetispeed.c \
diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h
index 51e25c9..02db6bb 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -1386,16 +1386,17 @@ static inline rtems_device_minor_number rtems_filesystem_dev_minor_t(
  */
 void rtems_filesystem_initialize( void );
 
-typedef void (*rtems_libio_init_functions_t)(void);
-extern  rtems_libio_init_functions_t rtems_libio_init_helper;
+typedef void (*rtems_libio_helper)(void);
 
-void    open_dev_console(void);
+extern const rtems_libio_helper rtems_libio_init_helper;
 
-typedef void (*rtems_libio_supp_functions_t)(void);
-extern  rtems_libio_supp_functions_t rtems_libio_supp_helper;
+extern const rtems_libio_helper rtems_libio_supp_helper;
 
-typedef void (*rtems_fs_init_functions_t)(void);
-extern  rtems_fs_init_functions_t    rtems_fs_init_helper;
+extern const rtems_libio_helper rtems_fs_init_helper;
+
+void rtems_libio_helper_null(void);
+
+void open_dev_console(void);
 
 /**
  * @brief Creates a directory and all its parent directories according to
diff --git a/cpukit/libcsupport/src/libio_helper_null.c b/cpukit/libcsupport/src/libio_helper_null.c
new file mode 100644
index 0000000..17bdb7a
--- /dev/null
+++ b/cpukit/libcsupport/src/libio_helper_null.c
@@ -0,0 +1,30 @@
+/**
+ * @file
+ *
+ * @ingroup LibIO
+ */
+
+/*
+ * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Obere Lagerstr. 30
+ *  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.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems/libio.h>
+
+void rtems_libio_helper_null(void)
+{
+  /* Do nothing */
+}
diff --git a/cpukit/libcsupport/src/libio_init.c b/cpukit/libcsupport/src/libio_init.c
index 3496b59..655c2e3 100644
--- a/cpukit/libcsupport/src/libio_init.c
+++ b/cpukit/libcsupport/src/libio_init.c
@@ -78,7 +78,5 @@ void rtems_libio_init( void )
   /*
    *  Initialize the base file system infrastructure.
    */
-
-  if (rtems_fs_init_helper)
-     (* rtems_fs_init_helper)();
+  (* rtems_fs_init_helper)();
 }
diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 1e1e3bb..04d8ae2 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -92,26 +92,26 @@ extern rtems_driver_address_table       Device_drivers[];
 #include <rtems/libio.h>
 
 #ifdef CONFIGURE_INIT
-rtems_libio_init_functions_t rtems_libio_init_helper =
-    #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
-    NULL;
-    #else
+const rtems_libio_helper rtems_libio_init_helper =
+  #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
+    rtems_libio_helper_null;
+  #else
     rtems_libio_init;
-    #endif
+  #endif
 
-rtems_libio_supp_functions_t rtems_libio_supp_helper =
-    #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
-    NULL;
-    #else
+const rtems_libio_helper rtems_libio_supp_helper =
+  #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
+    rtems_libio_helper_null;
+  #else
     open_dev_console;
-    #endif
+  #endif
 
-rtems_fs_init_functions_t    rtems_fs_init_helper =
-    #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
-    NULL;
-    #else
+const rtems_libio_helper rtems_fs_init_helper =
+  #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
+    rtems_libio_helper_null;
+  #else
     rtems_filesystem_initialize;
-    #endif
+  #endif
 #endif
 #endif
 
-- 
1.7.7




More information about the devel mailing list