]> rtime.felk.cvut.cz Git - omk.git/blob - tests/cmetric.files
47fd437cf6f7c20fc922ef84a273406aefee96a6
[omk.git] / tests / cmetric.files
1 cat > 'correct_cmetric_config.h' <<EOF
2 /* Automatically generated from for_cmetric_config.o */
3 /* Conditionals to control compilation */
4 /* Defines from the values defined to symbols in hexadecimal format */
5 #define FLAG_BAR_b 0x01
6 #define FLAG_BAR_m 0x02
7 #define FLAG_FOO_b 0x0
8 #define FLAG_FOO_m 0x01
9 #define VALUE_HEX 0x07b
10 #define o_blah_field1 0x0
11 #define o_blah_field2 0x04
12 #define o_blah_flags 0x08
13 #define s_blah_field1 0x04
14 #define s_blah_field2 0x01
15 #define s_blah_flags 0x04
16 /* Defines from the values defined to symbols in decimal format */
17 #define VALUE_DEC 123
18 #define VALUE_DEC_ZERO 0
19 EOF
20 cat > 'Makefile.omk' <<EOF
21 # -*- makefile -*-
22
23 NM=nm
24
25 cmetric_include_HEADERS = test/cmetric_config.h
26 cmetric_config_CMETRIC_SOURCES = for_cmetric_config.c
27
28 bin_PROGRAMS = test
29 test_SOURCES = test.S
30 EOF
31 cat > 'for_cmetric_config.c' <<EOF
32 /* Export of offset information to assembly source code */
33
34 /* %N (for N a digit) means print operand N in usual manner.
35    %lN label name with no punctuation
36    %cN constant expression with no punctuation
37    %aN means expect operand N to be a memory address
38        (not a memory reference!) and print a reference
39        to that address.
40    %nN constant expression for minus the value with no other punctuation. 
41  */
42
43 #include "header.h"
44
45 #define NUM2ASM(sym,val) \
46     __asm__ ( \
47         ".set " #sym ",%c0\n" \
48         ".global " #sym "\n" \
49         ::"n"(val) \
50     )
51
52 #define FIELD2ASM(strct, fld)                              \
53         NUM2ASM(_cmetric2def_o_##strct##_##fld,&((struct strct*)0L)->fld); \
54         NUM2ASM(_cmetric2def_s_##strct##_##fld,sizeof(((struct strct*)0L)->fld))
55
56 #define MASKBIT2ASM(def_base) \
57         NUM2ASM(_cmetric2def_##def_base##_b,def_base##_b); \
58         NUM2ASM(_cmetric2def_##def_base##_m,def_base##_m)
59
60 #define VALUE2ASM(value_name,value) \
61         NUM2ASM(_cmetric2def_##value_name,value)
62
63 #define DEC_VALUE2ASM(value_name,value) \
64         NUM2ASM(_cmetric2defdec_##value_name,value)
65
66 void pxmc_public2asm(void)
67 {
68
69 #ifdef CONFIG_TEST_OPTION1
70 VALUE2ASM(CMETRIC_TEST_OPTION1,1);
71 #endif
72 #ifdef CONFIG_TEST_OPTION2
73 VALUE2ASM(CMETRIC_TEST_OPTION2,1);
74 #endif
75 #ifdef CONFIG_TEST_OPTION3
76 VALUE2ASM(CMETRIC_TEST_OPTION3,1);
77 #endif
78 #ifdef CONFIG_TEST_OPTION4
79 VALUE2ASM(CMETRIC_TEST_OPTION4,1);
80 #endif
81 #ifdef CONFIG_TEST_OPTION5
82 VALUE2ASM(CMETRIC_TEST_OPTION5,1);
83 #endif
84 #ifdef CONFIG_TEST_OPTION6
85 VALUE2ASM(CMETRIC_TEST_OPTION6,1);
86 #endif
87
88 VALUE2ASM(VALUE_HEX, 123);
89 DEC_VALUE2ASM(VALUE_DEC, 123);
90 DEC_VALUE2ASM(VALUE_DEC_ZERO, 0);
91
92 MASKBIT2ASM(FLAG_FOO);
93 MASKBIT2ASM(FLAG_BAR);
94
95 FIELD2ASM(blah, field1);
96 FIELD2ASM(blah, field2);
97 FIELD2ASM(blah, flags);
98
99 }
100 EOF
101 cat > 'test.S' <<EOF
102 #include <test/cmetric_config.h>
103
104 /*
105  * In this file, we can use the symbols extracted from .o generated by
106  * a C compiler
107  */
108
109 .global main
110 main:
111 EOF
112 cat > 'header.h' <<EOF
113 #ifndef HEADER_H
114 #define HEADER_H
115
116 #define FLAG_FOO_b 0
117 #define FLAG_FOO_m (1<<FLAG_FOO_b)
118 #define FLAG_BAR_b 1
119 #define FLAG_BAR_m (1<<FLAG_BAR_b)
120
121 struct blah {
122         int field1;
123         char field2;
124         int flags;
125 };
126
127 #endif
128 EOF