Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:49

0001 /*
0002  * Copyright (c) 2017 embedded brains GmbH & Co. KG
0003  *
0004  * The license and distribution terms for this file may be
0005  * found in the file LICENSE in this distribution or at
0006  * http://www.rtems.com/license/LICENSE.
0007  */
0008 
0009 /*
0010  * This test program runs also on GNU/Linux and FreeBSD.  Use
0011  *
0012  * cc init.c tls.c && ./a.out
0013  *
0014  * to run it.
0015  */
0016 
0017 #ifdef HAVE_CONFIG_H
0018 #include "config.h"
0019 #endif
0020 
0021 #include "sptls04.h"
0022 
0023 #ifdef __rtems__
0024 
0025 #include <tmacros.h>
0026 
0027 #else /* __rtems__ */
0028 
0029 #include <assert.h>
0030 
0031 #define rtems_test_assert(x) assert(x)
0032 
0033 #endif /* __rtems__ */
0034 
0035 static _Thread_local int i;
0036 
0037 static _Thread_local int j;
0038 
0039 static __attribute__((__constructor__)) void con(void)
0040 {
0041   i = 1;
0042 }
0043 
0044 static void test(void)
0045 {
0046   rtems_test_assert(i == 1);
0047   rtems_test_assert(j == 0);
0048   rtems_test_assert(k == 2);
0049 }
0050 
0051 #ifdef __rtems__
0052 
0053 const char rtems_test_name[] = "SPTLS 4";
0054 
0055 static void Init(rtems_task_argument arg)
0056 {
0057   TEST_BEGIN();
0058   test();
0059   TEST_END();
0060   rtems_test_exit(0);
0061 }
0062 
0063 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
0064 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0065 
0066 #define CONFIGURE_MAXIMUM_TASKS 1
0067 
0068 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0069 
0070 #define CONFIGURE_INIT
0071 
0072 #include <rtems/confdefs.h>
0073 
0074 #else /* __rtems__ */
0075 
0076 int main(void)
0077 {
0078   test();
0079   return 0;
0080 }
0081 
0082 #endif /* __rtems__ */