[rtems commit] config: Provide file descriptors only if necessary

Sebastian Huber sebh at rtems.org
Mon Aug 31 14:21:33 UTC 2020


Module:    rtems
Branch:    master
Commit:    ced28f2cfcee6d32ad7bb72e16b235212eb2eaaf
Changeset: http://git.rtems.org/rtems/commit/?id=ced28f2cfcee6d32ad7bb72e16b235212eb2eaaf

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Apr 16 12:13:31 2020 +0200

config: Provide file descriptors only if necessary

Only provide the file descriptor array if
CONFIGURE_MAXIMUM_FILE_DESCRIPTORS > 0.  If someone configured
CONFIGURE_MAXIMUM_FILE_DESCRIPTORS == 0 and the appplication uses
something which requires a file descriptor, then a linker error will
show up.  An alternative would be to add a zero-length array
rtems_libio_iops[ 0 ] to librtemscpu.a which would be used in this
case.

Conditionally include some header files.

---

 cpukit/include/rtems/confdefs/libio.h | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/cpukit/include/rtems/confdefs/libio.h b/cpukit/include/rtems/confdefs/libio.h
index e986262..8f43c49 100644
--- a/cpukit/include/rtems/confdefs/libio.h
+++ b/cpukit/include/rtems/confdefs/libio.h
@@ -43,7 +43,6 @@
 #ifdef CONFIGURE_INIT
 
 #include <rtems/confdefs/bsp.h>
-#include <rtems/libio.h>
 #include <rtems/sysinit.h>
 
 #ifdef CONFIGURE_FILESYSTEM_ALL
@@ -86,6 +85,15 @@
   #define CONFIGURE_IMFS_DISABLE_UTIME
 #endif
 
+#ifndef CONFIGURE_MAXIMUM_FILE_DESCRIPTORS
+  #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 3
+#endif
+
+#if !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) || \
+  CONFIGURE_MAXIMUM_FILE_DESCRIPTORS > 0
+  #include <rtems/libio.h>
+#endif
+
 #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
   #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM"
@@ -122,10 +130,10 @@
   #ifdef CONFIGURE_FILESYSTEM_TFTPFS
     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_TFTPFS"
   #endif
+#else
+  #include <rtems/imfs.h>
 #endif
 
-#include <rtems/imfs.h>
-
 #ifdef CONFIGURE_FILESYSTEM_DOSFS
 #include <rtems/dosfs.h>
 #endif
@@ -316,13 +324,11 @@ RTEMS_SYSINIT_ITEM(
 
 #endif /* !CONFIGURE_APPLICATION_DISABLE_FILESYSTEM */
 
-#ifndef CONFIGURE_MAXIMUM_FILE_DESCRIPTORS
-  #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 3
-#endif
-
-rtems_libio_t rtems_libio_iops[ CONFIGURE_MAXIMUM_FILE_DESCRIPTORS ];
+#if CONFIGURE_MAXIMUM_FILE_DESCRIPTORS > 0
+  rtems_libio_t rtems_libio_iops[ CONFIGURE_MAXIMUM_FILE_DESCRIPTORS ];
 
-const uint32_t rtems_libio_number_iops = RTEMS_ARRAY_SIZE( rtems_libio_iops );
+  const uint32_t rtems_libio_number_iops = RTEMS_ARRAY_SIZE( rtems_libio_iops );
+#endif
 
 #ifdef __cplusplus
 }



More information about the vc mailing list