aboutsummaryrefslogtreecommitdiff
path: root/libtcc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libtcc.c')
-rw-r--r--libtcc.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/libtcc.c b/libtcc.c
index dfb000a..54184e2 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1578,10 +1578,18 @@ static int rt_get_caller_pc(unsigned long *paddr,
if (level == 0) {
/* XXX: only support linux */
+#if defined(__FreeBSD__)
+ *paddr = uc->uc_mcontext.mc_rip;
+#else
*paddr = uc->uc_mcontext.gregs[REG_RIP];
+#endif
return 0;
} else {
+#if defined(__FreeBSD__)
+ fp = uc->uc_mcontext.mc_rbp;
+#else
fp = uc->uc_mcontext.gregs[REG_RBP];
+#endif
for(i=1;i<level;i++) {
/* XXX: check address validity with program info */
if (fp <= 0x1000)
@@ -1868,7 +1876,9 @@ TCCState *tcc_new(void)
tcc_define_symbol(s, "__STDC__", NULL);
tcc_define_symbol(s, "__STDC_VERSION__", "199901L");
#if defined(TCC_TARGET_I386)
- tcc_define_symbol(s, "__i386__", NULL);
+ tcc_define_symbol(s, "__i386__", "1");
+ tcc_define_symbol(s, "__i386", "1");
+ tcc_define_symbol(s, "i386", "1");
#endif
#if defined(TCC_TARGET_X86_64)
tcc_define_symbol(s, "__x86_64__", NULL);
@@ -1889,8 +1899,15 @@ TCCState *tcc_new(void)
tcc_define_symbol(s, "_WIN64", NULL);
#endif
#else
- tcc_define_symbol(s, "__unix__", NULL);
- tcc_define_symbol(s, "__unix", NULL);
+ tcc_define_symbol(s, "__unix__", "1");
+ tcc_define_symbol(s, "__unix", "1");
+ tcc_define_symbol(s, "unix", "1");
+#if defined(__FreeBSD__)
+#define str(s) #s
+ tcc_define_symbol(s, "__FreeBSD__", str( __FreeBSD__));
+ tcc_define_symbol(s, "__INTEL_COMPILER", "1");
+#undef str
+#endif
#if defined(__linux)
tcc_define_symbol(s, "__linux__", NULL);
tcc_define_symbol(s, "__linux", NULL);