*added _ticks for apple and gnu compilers.

This commit is contained in:
paladin-t 2016-02-02 15:52:47 +08:00
parent 20e5016bb0
commit ff11eca576
3 changed files with 14 additions and 3 deletions

View File

@ -2158,7 +2158,7 @@ _ls_node_t* _ls_sort(_ls_node_t** list, _ls_compare cmp) {
int insize, nmerges, psize, qsize, i; int insize, nmerges, psize, qsize, i;
_ls_node_t* lst = 0; _ls_node_t* lst = 0;
mb_assert(list && cmp); mb_assert(list && *list && cmp);
lst = *list; lst = *list;
if(lst) lst = lst->next; if(lst) lst = lst->next;
@ -2775,7 +2775,7 @@ char* mb_strupr(char* s) {
/** Unicode handling */ /** Unicode handling */
#ifdef MB_ENABLE_UNICODE #ifdef MB_ENABLE_UNICODE
int mb_uu_ischar(char* ch) { int mb_uu_ischar(char* ch) {
/* Copyright 2008-2009 Bjoern Hoehrmann, http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ */ /* Copyright 2008, 2009 Bjoern Hoehrmann, http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ */
/* Determine whether a buffer is a UTF8 encoded character, and return taken bytes */ /* Determine whether a buffer is a UTF8 encoded character, and return taken bytes */
#define _TAKE(__ch, __c, __r) do { __c = *__ch++; __r++; } while(0) #define _TAKE(__ch, __c, __r) do { __c = *__ch++; __r++; } while(0)
#define _COPY(__ch, __c, __r, __cp) do { _TAKE(__ch, __c, __r); __cp = (__cp << 6) | ((unsigned char)__c & 0x3Fu); } while(0) #define _COPY(__ch, __c, __r, __cp) do { _TAKE(__ch, __c, __r); __cp = (__cp << 6) | ((unsigned char)__c & 0x3Fu); } while(0)

View File

@ -1,5 +1,5 @@
my_basic : main.o my_basic.o my_basic : main.o my_basic.o
cc -o output/my_basic_bin main.o my_basic.o -lm cc -o output/my_basic_bin main.o my_basic.o -lm -lrt
main.o : shell/main.c core/my_basic.h main.o : shell/main.c core/my_basic.h
cc -Os -c shell/main.c -Wno-unused-result cc -Os -c shell/main.c -Wno-unused-result

View File

@ -37,6 +37,9 @@
#elif !defined __BORLANDC__ && !defined __TINYC__ #elif !defined __BORLANDC__ && !defined __TINYC__
# include <unistd.h> # include <unistd.h>
#endif /* _MSC_VER */ #endif /* _MSC_VER */
#ifndef _MSC_VER
# include <stdint.h>
#endif /* _MSC_VER */
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -1077,6 +1080,14 @@ static int_t _ticks(void) {
return ret; return ret;
} }
#elif defined __APPLE__ || defined __GNUC__
static int_t _ticks(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
}
#else /* _MSC_VER */ #else /* _MSC_VER */
# undef _HAS_TICKS # undef _HAS_TICKS
#endif /* _MSC_VER */ #endif /* _MSC_VER */