]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/tcboffset.cc
Inital import
[l4.git] / kernel / fiasco / src / kern / tcboffset.cc
1 #include "irq.h"
2 #include "jdb_ktrace.h"
3 #include "thread.h"
4 #include "types.h"
5
6 bool dumpzero;
7
8 #define NAME_LEN 58
9
10 static int _t;
11
12 #if 1
13 #define DUMP_CAST_OFFSET(type, subtype)                 \
14   ((unsigned long)((subtype *)((type *)(&_t))) - (unsigned long)&_t),
15 #endif
16
17 #define DUMP_OFFSET(prefix,name,offset) (offset), 
18
19 #define DUMP_BITSHIFT(prefix, value) (value),
20
21 #define GET_MEMBER_PTR(type,member)                                     \
22   ((unsigned long)(&(((type *) 1)->member)) - 1)
23
24 #define DUMP_MEMBER1(prefix,                                            \
25                      type1,member1,                                     \
26                      name) (GET_MEMBER_PTR (type1, member1)),
27
28 #define DUMP_CONSTANT(prefix, value) (value),
29
30 #if 0
31 #define DUMP_CAST_OFFSET(type, subtype, member)                 \
32   (GET_MEMBER_PTR(type, member) - GET_MEMBER_PTR(subtype, member)),
33 #endif
34
35 /**
36  * Calculates the logarithm base 2 from the given 2^n integer.
37  * @param value the 2^n integer
38  * @return the log base 2 of value, the exponent n
39  */
40 int log2(int value)
41 {
42   unsigned c = 0; // c will be lg(v)
43   while (value >>= 1)
44     c++;
45   return c;
46 }
47
48
49 void offsets_func(char **a, unsigned long **b) 
50 {
51 static char length[32] __attribute__((unused, section(".e_length"))) = 
52   { sizeof(unsigned long), };
53 static unsigned long offsets[] __attribute__((unused, section(".offsets"))) = 
54 {
55 #include "tcboffset_in.h"
56 };
57   *a = length;
58   *b = offsets;
59
60 }