tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] CYGWIN support, Is __cdecl supported, esp. on linux?


From: Christian JULLIEN
Subject: [Tinycc-devel] CYGWIN support, Is __cdecl supported, esp. on linux?
Date: Thu, 30 Jul 2015 10:22:39 +0200 (CEST)

Hi All,

I'm trying to make tcc compile ROOTB on Cygwin and I already have tcc.exe running with very few patches (see below).
The problem I'm facing is a parse error with __cdecl declarations from cygwin includes.

Even on a standard Linux machine running mod tcc, the following code:
void __cdecl foo(void)
{
}

fails with
address@hidden ~/tinycc $ ./tcc -c foo.c
foo.c:1: error: ';' expected (got "foo")
Am I missing something?

Here is my first diff to support Cygwin, at least on x64.

diff --git a/libtcc.c b/libtcc.c
index df98bb0..4568aa3 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1129,6 +1129,9 @@ LIBTCCAPI TCCState *tcc_new(void)
     tcc_define_symbol(s, "__linux__", NULL);
     tcc_define_symbol(s, "__linux", NULL);
 # endif
+# if defined(__CYGWIN__)
+    tcc_define_symbol(s, "__CYGWIN__", NULL);
+# endif
 # if defined(__FreeBSD__)
 #  define str(s) #s
     tcc_define_symbol(s, "__FreeBSD__", str( __FreeBSD__));
diff --git a/tccrun.c b/tccrun.c
index 55db310..0b7ebd1 100644
--- a/tccrun.c
+++ b/tccrun.c
@@ -540,6 +540,8 @@ static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
         *paddr = uc->uc_mcontext.mc_rip;
 #elif defined(__NetBSD__)
         *paddr = uc->uc_mcontext.__gregs[_REG_RIP];
+#elif defined(__CYGWIN__)
+        *paddr = uc->uc_mcontext.rip;
 #else
         *paddr = uc->uc_mcontext.gregs[REG_RIP];
 #endif
@@ -551,6 +553,8 @@ static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
         fp = uc->uc_mcontext.mc_rbp;
 #elif defined(__NetBSD__)
         fp = uc->uc_mcontext.__gregs[_REG_RBP];
+#elif defined(__CYGWIN__)
+        fp = uc->uc_mcontext.rbp;
 #else
         fp = uc->uc_mcontext.gregs[REG_RBP];
 #endif


reply via email to

[Prev in Thread] Current Thread [Next in Thread]