diff --git a/.gitignore b/.gitignore index a845ddcb..4985f6a3 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,8 @@ config.mak config.texi tests tags +.DS_Store +*.swp +lib/x86_64 +tcc-doc.info +conftest* diff --git a/Makefile b/Makefile index 43d7cfd0..fd8602e9 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,10 @@ NATIVE_DEFINES+=$(if $(wildcard /lib/ld-linux.so.3),-DTCC_ARM_EABI) NATIVE_DEFINES+=$(if $(shell grep -l "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo),-DTCC_ARM_VFP) endif +ifeq ($(TARGETOS),Darwin) +NATIVE_DEFINES+=-DWITHOUT_LIBTCC +endif + ifdef CONFIG_WIN32 NATIVE_DEFINES+=-DTCC_TARGET_PE endif diff --git a/configure b/configure index 3d68b1c0..188c3609 100755 --- a/configure +++ b/configure @@ -352,6 +352,7 @@ echo "Doc directory $docdir" echo "Target root prefix $sysroot" echo "Source path $source_path" echo "C compiler $cc" +echo "Target OS $targetos" echo "CPU $cpu" echo "Big Endian $bigendian" echo "gprof enabled $gprof" @@ -425,6 +426,7 @@ else echo "Unsupported CPU" exit 1 fi +echo "TARGETOS=$targetos" >> config.mak if test "$noldl" = "yes" ; then echo "CONFIG_NOLDL=yes" >> config.mak fi diff --git a/tccrun.c b/tccrun.c index 64a1dfd6..de0ef891 100644 --- a/tccrun.c +++ b/tccrun.c @@ -461,7 +461,9 @@ static int rt_get_caller_pc(unsigned long *paddr, ucontext_t *uc, int level) int i; if (level == 0) { -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__APPLE__) + *paddr = uc->uc_mcontext->__ss.__eip; +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) *paddr = uc->uc_mcontext.mc_eip; #elif defined(__dietlibc__) *paddr = uc->uc_mcontext.eip; @@ -470,7 +472,9 @@ static int rt_get_caller_pc(unsigned long *paddr, ucontext_t *uc, int level) #endif return 0; } else { -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__APPLE__) + fp = uc->uc_mcontext->__ss.__ebp; +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) fp = uc->uc_mcontext.mc_ebp; #elif defined(__dietlibc__) fp = uc->uc_mcontext.ebp; @@ -500,14 +504,18 @@ static int rt_get_caller_pc(unsigned long *paddr, if (level == 0) { /* XXX: only support linux */ -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__APPLE__) + *paddr = uc->uc_mcontext->__ss.__rip; +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) *paddr = uc->uc_mcontext.mc_rip; #else *paddr = uc->uc_mcontext.gregs[REG_RIP]; #endif return 0; } else { -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__APPLE__) + fp = uc->uc_mcontext->__ss.__rbp; +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) fp = uc->uc_mcontext.mc_rbp; #else fp = uc->uc_mcontext.gregs[REG_RBP]; diff --git a/tests/Makefile b/tests/Makefile index 8cd906d4..2cf9e281 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -45,7 +45,7 @@ libtcc_test$(EXESUF): libtcc_test.c ../$(LIBTCC) # test.ref - generate using gcc # copy only tcclib.h so GCC's stddef and stdarg will be used test.ref: tcctest.c - cp -u ../include/tcclib.h . + cp ../include/tcclib.h . $(CC) -o tcctest.gcc $< -I. -w $(CFLAGS) -std=gnu99 ./tcctest.gcc > $@