diff --git a/HISTORY b/HISTORY index b0bbc35..0ab9d4b 100755 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,6 @@ +Feb. 15 2016 +Fixed some compile issues with Xcode + Feb. 11 2016 Fixed a bug of the EXIT statement with multiple line IF statement @@ -521,7 +524,7 @@ Fixed a crash bug when missing colon in a combined line, thanks to Michael P. We Fixed a missing lexical cursor stepping bug in INPUT statement Mar. 17 2014 -Added an XCode project +Added an Xcode project Added a safe stdin reader function mb_gets Fixed a crash bug in INPUT statement diff --git a/makefile b/makefile index feafdfb..b92458d 100755 --- a/makefile +++ b/makefile @@ -1,5 +1,13 @@ +OS := $(shell uname -s) +IS_APPLE := $(shell echo $(OS)|grep -i darwin) + +ifdef IS_APPLE +my_basic : main.o my_basic.o + cc -o output/my_basic_bin main.o my_basic.o -lm +else my_basic : main.o my_basic.o cc -o output/my_basic_bin main.o my_basic.o -lm -lrt +endif main.o : shell/main.c core/my_basic.h cc -Os -c shell/main.c -Wno-unused-result diff --git a/shell/main.c b/shell/main.c index b5f0cf5..17d2060 100755 --- a/shell/main.c +++ b/shell/main.c @@ -46,6 +46,9 @@ #include #include #include +#ifdef __APPLE__ +# include +#endif /* __APPLE__ */ #ifdef __cplusplus extern "C" { @@ -1080,7 +1083,18 @@ static int_t _ticks(void) { return ret; } -#elif defined __APPLE__ || defined __GNUC__ +#elif defined __APPLE__ +static int_t _ticks(void) { + struct timespec ts; + struct timeval now; + int rv = gettimeofday(&now, NULL); + if(rv) return 0; + ts.tv_sec = now.tv_sec; + ts.tv_nsec = now.tv_usec * 1000; + + return (int_t)(ts.tv_sec * 1000 + ts.tv_nsec / 1000000); +} +#elif defined defined __GNUC__ static int_t _ticks(void) { struct timespec ts;