]> rtime.felk.cvut.cz Git - omk.git/commitdiff
CMETRIC learned how to export values in decimal format
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 22 Oct 2009 11:31:26 +0000 (13:31 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 22 Oct 2009 11:31:26 +0000 (13:31 +0200)
See for_cmetric_config.c file for usage details.
Thanks to Pavel Němeček for implementation.

snippets/gcc.omk
snippets/linux.omk
tests/cmetric/correct_cmetric_config.h
tests/cmetric/for_cmetric_config.c

index 89dc45d7d860525a5b80e397b1186702130b581b..3d8d68234e190f8b2bd6eb25d7b7e26d28da546d 100644 (file)
@@ -132,10 +132,14 @@ $(2): $(1)
        $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
                | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
                | sort >>$$@.tmp` && exit $$$$status
-       $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols */'
+       $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */'
        $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
                | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
                | sort >>$$@.tmp` && exit $$$$status
+       $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */'
+       $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\
+               | sed -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \
+               | sort >>$$@.tmp` && exit $$$$status
        $(Q)mv $$@.tmp $$@
 endef
 
index ac3d7c031cf3ae9b8c496780f021417670421ad8..5f44734aaaa6c3ebeab257d2c35b4aea2e425dd6 100644 (file)
@@ -231,6 +231,7 @@ $(2): $(1) $$(GEN_HEADERS)
        fi
 endef
 
+NM ?= nm
 
 # Syntax: $(call CMETRIC_o_h_template,<object_file>,<target_header>)
 define CMETRIC_o_h_template
@@ -246,10 +247,14 @@ $(2): $(1)
        $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
                | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
                | sort >>$$@.tmp` && exit $$$$status
-       $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols */'
+       $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */'
        $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
                | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
                | sort >>$$@.tmp` && exit $$$$status
+       $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */'
+       $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\
+               | sed -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \
+               | sort >>$$@.tmp` && exit $$$$status
        $(Q)mv $$@.tmp $$@
 endef
 
index d9b94789e9157e8a223436f323fd527b74ca5fa9..f80de7003f27616ecd6161dbb2c975fdd92a1b48 100644 (file)
@@ -1,6 +1,6 @@
 /* Automatically generated from for_cmetric_config.o */
 /* Conditionals to control compilation */
-/* Defines from the values defined to symbols */
+/* Defines from the values defined to symbols in hexadecimal format */
 #define FLAG_BAR_b 0x01
 #define FLAG_BAR_m 0x02
 #define FLAG_FOO_b 0x0
@@ -11,3 +11,7 @@
 #define s_blah_field1 0x04
 #define s_blah_field2 0x01
 #define s_blah_flags 0x04
+#define VALUE_HEX 0x07b
+/* Defines from the values defined to symbols in decimal format */
+#define VALUE_DEC_ZERO 0
+#define VALUE_DEC 123
index aeab4b050b99bfab28937cecb6144686512b572e..8eaea65d89dc84106fe4441858b3728f2f2a2290 100644 (file)
@@ -29,6 +29,8 @@
 #define VALUE2ASM(value_name,value) \
        NUM2ASM(_cmetric2def_##value_name,value)
 
+#define DEC_VALUE2ASM(value_name,value) \
+       NUM2ASM(_cmetric2defdec_##value_name,value)
 
 void pxmc_public2asm(void)
 {
@@ -52,6 +54,10 @@ VALUE2ASM(CMETRIC_TEST_OPTION5,1);
 VALUE2ASM(CMETRIC_TEST_OPTION6,1);
 #endif
 
+VALUE2ASM(VALUE_HEX, 123);
+DEC_VALUE2ASM(VALUE_DEC, 123);
+DEC_VALUE2ASM(VALUE_DEC_ZERO, 0);
+
 MASKBIT2ASM(FLAG_FOO);
 MASKBIT2ASM(FLAG_BAR);