summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/sptls04/init.c
blob: bbbe81b9d1e0c07e16d3817bbdc0a581c8608427 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * Copyright (c) 2017 embedded brains GmbH & Co. KG
 *
 * 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.
 */

/*
 * This test program runs also on GNU/Linux and FreeBSD.  Use
 *
 * cc init.c tls.c && ./a.out
 *
 * to run it.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "sptls04.h"

#ifdef __rtems__

#include <tmacros.h>

#else /* __rtems__ */

#include <assert.h>

#define rtems_test_assert(x) assert(x)

#endif /* __rtems__ */

static _Thread_local int i;

static _Thread_local int j;

static __attribute__((__constructor__)) void con(void)
{
  i = 1;
}

static void test(void)
{
  rtems_test_assert(i == 1);
  rtems_test_assert(j == 0);
  rtems_test_assert(k == 2);
}

#ifdef __rtems__

const char rtems_test_name[] = "SPTLS 4";

static void Init(rtems_task_argument arg)
{
  TEST_BEGIN();
  test();
  TEST_END();
  rtems_test_exit(0);
}

#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER

#define CONFIGURE_MAXIMUM_TASKS 1

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE

#define CONFIGURE_INIT

#include <rtems/confdefs.h>

#else /* __rtems__ */

int main(void)
{
  test();
  return 0;
}

#endif /* __rtems__ */