From efd2965abf0beaa66e918107be0b667f086d6ea4 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 2 Feb 2015 15:25:26 +0100 Subject: Filesystem: Statically initialize rtems_libio_iops --- cpukit/libcsupport/include/rtems/libio_.h | 2 +- cpukit/libcsupport/src/libio_init.c | 8 +------- cpukit/sapi/include/confdefs.h | 6 ++++-- testsuites/sptests/Makefile.am | 2 +- testsuites/sptests/configure.ac | 1 - testsuites/sptests/spfatal22/Makefile.am | 21 --------------------- testsuites/sptests/spfatal22/spfatal22.doc | 19 ------------------- testsuites/sptests/spfatal22/spfatal22.scn | 4 ---- testsuites/sptests/spfatal22/testcase.h | 24 ------------------------ 9 files changed, 7 insertions(+), 80 deletions(-) delete mode 100644 testsuites/sptests/spfatal22/Makefile.am delete mode 100644 testsuites/sptests/spfatal22/spfatal22.doc delete mode 100644 testsuites/sptests/spfatal22/spfatal22.scn delete mode 100644 testsuites/sptests/spfatal22/testcase.h diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h index 1300d39b41..c26782e015 100644 --- a/cpukit/libcsupport/include/rtems/libio_.h +++ b/cpukit/libcsupport/include/rtems/libio_.h @@ -65,7 +65,7 @@ extern rtems_id rtems_libio_semaphore; */ extern const uint32_t rtems_libio_number_iops; -extern rtems_libio_t *rtems_libio_iops; +extern rtems_libio_t rtems_libio_iops[]; extern rtems_libio_t *rtems_libio_iop_freelist; extern const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers; diff --git a/cpukit/libcsupport/src/libio_init.c b/cpukit/libcsupport/src/libio_init.c index e64ddd6e3a..a14fe866f0 100644 --- a/cpukit/libcsupport/src/libio_init.c +++ b/cpukit/libcsupport/src/libio_init.c @@ -38,7 +38,6 @@ */ rtems_id rtems_libio_semaphore; -rtems_libio_t *rtems_libio_iops; rtems_libio_t *rtems_libio_iop_freelist; void rtems_libio_init( void ) @@ -50,12 +49,7 @@ void rtems_libio_init( void ) if (rtems_libio_number_iops > 0) { - rtems_libio_iops = (rtems_libio_t *) calloc(rtems_libio_number_iops, - sizeof(rtems_libio_t)); - if (rtems_libio_iops == NULL) - rtems_fatal_error_occurred(RTEMS_NO_MEMORY); - - iop = rtems_libio_iop_freelist = rtems_libio_iops; + iop = rtems_libio_iop_freelist = &rtems_libio_iops[0]; for (i = 0 ; (i + 1) < rtems_libio_number_iops ; i++, iop++) iop->data1 = iop + 1; iop->data1 = NULL; diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h index 569f136210..65d07facf6 100644 --- a/cpukit/sapi/include/confdefs.h +++ b/cpukit/sapi/include/confdefs.h @@ -92,7 +92,7 @@ extern rtems_initialization_tasks_table Initialization_tasks[]; #endif #ifndef RTEMS_SCHEDSIM -#include +#include #ifdef CONFIGURE_INIT const rtems_libio_helper rtems_libio_init_helper = @@ -153,11 +153,13 @@ const rtems_libio_helper rtems_fs_init_helper = #define CONFIGURE_LIBIO_POSIX_KEYS 1 #ifdef CONFIGURE_INIT + rtems_libio_t rtems_libio_iops[CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS]; + /** * When instantiating the configuration tables, this variable is * initialized to specify the maximum number of file descriptors. */ - const uint32_t rtems_libio_number_iops = CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS; + const uint32_t rtems_libio_number_iops = RTEMS_ARRAY_SIZE(rtems_libio_iops); #endif /** diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index a71c02436f..2bbe661b4b 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -18,7 +18,7 @@ _SUBDIRS = \ spfatal01 spfatal02 spfatal03 spfatal04 spfatal05 spfatal06 spfatal07 \ spfatal08 spfatal09 spfatal10 spfatal11 spfatal12 spfatal13 spfatal14 \ spfatal15 spfatal16 spfatal17 spfatal18 spfatal19 spfatal20 \ - spfatal22 spfatal24 spfatal25 spfatal27\ + spfatal24 spfatal25 spfatal27\ spfifo01 spfifo02 spfifo03 spfifo04 spfifo05 \ spfreechain01 \ spintrcritical01 spintrcritical02 spintrcritical03 spintrcritical04 \ diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac index 79a0b2da62..47a9d3fcfd 100644 --- a/testsuites/sptests/configure.ac +++ b/testsuites/sptests/configure.ac @@ -175,7 +175,6 @@ spfatal17/Makefile spfatal18/Makefile spfatal19/Makefile spfatal20/Makefile -spfatal22/Makefile spfatal24/Makefile spfatal25/Makefile spfatal27/Makefile diff --git a/testsuites/sptests/spfatal22/Makefile.am b/testsuites/sptests/spfatal22/Makefile.am deleted file mode 100644 index f41b836705..0000000000 --- a/testsuites/sptests/spfatal22/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -rtems_tests_PROGRAMS = spfatal22 -spfatal22_SOURCES = ../spfatal_support/init.c \ - ../spfatal_support/system.h ../../support/src/test_support.c testcase.h - -dist_rtems_tests_DATA = spfatal22.scn -dist_rtems_tests_DATA += spfatal22.doc - -include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg -include $(top_srcdir)/../automake/compile.am -include $(top_srcdir)/../automake/leaf.am - -AM_CPPFLAGS += -I$(top_srcdir)/../support/include - -LINK_OBJS = $(spfatal22_OBJECTS) -LINK_LIBS = $(spfatal22_LDLIBS) - -spfatal22$(EXEEXT): $(spfatal22_OBJECTS) $(spfatal22_DEPENDENCIES) - @rm -f spfatal22$(EXEEXT) - $(make-exe) - -include $(top_srcdir)/../automake/local.am diff --git a/testsuites/sptests/spfatal22/spfatal22.doc b/testsuites/sptests/spfatal22/spfatal22.doc deleted file mode 100644 index 02abfef376..0000000000 --- a/testsuites/sptests/spfatal22/spfatal22.doc +++ /dev/null @@ -1,19 +0,0 @@ -# COPYRIGHT (c) 1989-2010. -# On-Line Applications Research Corporation (OAR). -# -# 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. -# - -This file describes the directives and concepts tested by this test set. - -test set name: spfatal22 - -directives: - - rtems_libio_init - -concepts: - -+ Exercise path when unable to allocate memory. diff --git a/testsuites/sptests/spfatal22/spfatal22.scn b/testsuites/sptests/spfatal22/spfatal22.scn deleted file mode 100644 index b4239e6424..0000000000 --- a/testsuites/sptests/spfatal22/spfatal22.scn +++ /dev/null @@ -1,4 +0,0 @@ -*** TEST FATAL FATAL 22 *** -Allocate_majority_of_heap: -Fatal error (libio init out of memory) hit -*** END OF TEST FATAL 22 *** diff --git a/testsuites/sptests/spfatal22/testcase.h b/testsuites/sptests/spfatal22/testcase.h deleted file mode 100644 index 195b7ecc3f..0000000000 --- a/testsuites/sptests/spfatal22/testcase.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * COPYRIGHT (c) 1989-2010. - * On-Line Applications Research Corporation (OAR). - * - * 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. - */ - -#define FATAL_ERROR_TEST_NAME "22" -#define FATAL_ERROR_DESCRIPTION "libio init out of memory" -#define FATAL_ERROR_EXPECTED_SOURCE INTERNAL_ERROR_RTEMS_API -#define FATAL_ERROR_EXPECTED_IS_INTERNAL FALSE -#define FATAL_ERROR_EXPECTED_ERROR RTEMS_NO_MEMORY - -#include -#include - -void force_error() -{ - rtems_heap_greedy_allocate( NULL, 0 ); - - rtems_libio_init(); -} -- cgit v1.2.3