aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Soroka <gits@joesoroka.com>2011-02-01 15:26:21 -0800
committerJoe Soroka <gits@joesoroka.com>2011-02-01 15:26:21 -0800
commita25325e9be13e52a198807b443bdfbfbe5dcaf33 (patch)
tree92e02d5a2c6c9eca733506a7ec86678d258c4e21
parent75c6695932b55b914f16b20dc32ff3ef1203ed4b (diff)
downloadtinycc-a25325e9be13e52a198807b443bdfbfbe5dcaf33.tar.gz
tinycc-a25325e9be13e52a198807b443bdfbfbe5dcaf33.tar.bz2
tccasm: define __ASSEMBLER__ for .S files, like gcc does
-rw-r--r--libtcc.c6
-rw-r--r--tests/asmtest.S4
2 files changed, 10 insertions, 0 deletions
diff --git a/libtcc.c b/libtcc.c
index 58a5ca0..e538321 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1080,6 +1080,12 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
if (ext[0])
ext++;
+#ifdef CONFIG_TCC_ASM
+ /* if .S file, define __ASSEMBLER__ like gcc does */
+ if (!strcmp(ext, "S"))
+ tcc_define_symbol(s1, "__ASSEMBLER__", NULL);
+#endif
+
/* open the file */
ret = tcc_open(s1, filename);
if (ret < 0) {
diff --git a/tests/asmtest.S b/tests/asmtest.S
index f6fecde..0d4c0fc 100644
--- a/tests/asmtest.S
+++ b/tests/asmtest.S
@@ -564,3 +564,7 @@ int $0x10
pushl $1
pushw $1
push $1
+
+#ifdef __ASSEMBLER__ // should be defined, for S files
+ inc %eax
+#endif