Blame view

RIOT/tests/sizeof_tcb/main.c 1.2 KB
a752c7ab   elopes   add first test an...
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
  /*
   * Copyright (C) 2014 René Kijewski <rene.kijewski@fu-berlin.de>
   *
   * This file is subject to the terms and conditions of the GNU Lesser
   * General Public License v2.1. See the file LICENSE in the top level
   * directory for more details.
   */
  
  /**
   * @ingroup tests
   * @{
   *
   * @file
   * @brief  Print the size of thread_t.
   *
   * @author René Kijewski <rene.kijewski@fu-berlin.de>
   *
   * @}
   */
  
  #include <stdio.h>
  #include <stddef.h>
  
  #include "thread.h"
  
  #define P(NAME) printf("\t%-*s%4u%4u\n", 11, #NAME, \
                         (unsigned)sizeof(((thread_t *) 0)->NAME), \
                         (unsigned)offsetof(thread_t, NAME));
  
  int main(void)
  {
      puts("\tmember, sizeof, offsetof");
  
      printf("sizeof(thread_t): %u\n", (unsigned)sizeof(thread_t));
  
      P(sp);
      P(status);
      P(priority);
      P(pid);
  #ifdef MODULE_CORE_THREAD_FLAGS
      P(flags);
  #endif
      P(rq_entry);
  #ifdef MODULE_CORE_MSG
      P(wait_data);
      P(msg_waiters);
      P(msg_queue);
      P(msg_array);
  #endif
  #ifdef DEVELHELP
      P(name);
  #endif
  #if defined(DEVELHELP) || defined(SCHED_TEST_STACK) || defined(MODULE_MPU_STACK_GUARD)
      P(stack_start);
  #endif
  
  #ifdef DEVELHELP
      P(stack_size);
  #endif
  
      puts("Done.");
      return 0;
  }