X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fos.hpp;h=1f924680d4aefa6917e4f69f2f59f21dc3a0b471;hb=0a5b526074fc4c7ef3cb43496c1adc7b5a098ea9;hp=c80b2ea1d3404e1ee8a3dd93fc08664681bb59c4;hpb=88f744a367568af52344807c8be35b4fe1d553bb;p=cacao.git diff --git a/src/vm/os.hpp b/src/vm/os.hpp index c80b2ea1d..1f924680d 100644 --- a/src/vm/os.hpp +++ b/src/vm/os.hpp @@ -1,6 +1,6 @@ /* src/vm/os.hpp - system (OS) functions - Copyright (C) 2007, 2008, 2009 + Copyright (C) 2007, 2008, 2009, 2010, 2011 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO Copyright (C) 2008 Theobroma Systems Ltd. @@ -89,6 +89,12 @@ # include #endif +#if defined(__DARWIN__) +# if defined(HAVE_MACH_MACH_H) +# include +# endif +#endif + #if defined(HAVE_SYS_LOADAVG_H) # include #endif @@ -109,6 +115,10 @@ # include #endif +#if defined(HAVE_SYS_UTSNAME_H) +# include +#endif + #ifdef __cplusplus @@ -134,7 +144,7 @@ public: static inline void* dlsym(void* handle, const char* symbol); static inline int fclose(FILE* fp); static inline FILE* fopen(const char* path, const char* mode); - static inline int fprintf(FILE* stream, const char* format, ...); + static inline int vfprintf ( FILE * stream, const char * format, va_list arg ); static inline size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream); static inline void free(void* ptr); static inline char* getcwd(char* buf, size_t size); @@ -177,8 +187,8 @@ public: static int processors_online(); // Template helper - template - static int call_scandir(int (*scandir)(const char *, struct dirent ***, F1, F2), const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const void *, const void *)); + template + static int call_scandir(int (*scandir)(const char *, struct dirent ***, _F1, _F2), const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const void *, const void *)); }; @@ -332,16 +342,18 @@ inline FILE* os::fopen(const char* path, const char* mode) #endif } -inline int os::fprintf(FILE* stream, const char* format, ...) +//fprintf is mandatory and can't be replaced with an equivalent fast wrapper +#if !defined (HAVE_FPRINTF) +#error fprintf not available +#endif + +inline int os::vfprintf ( FILE * stream, const char * format, va_list arg ) { -#if defined(HAVE_FPRINTF) - va_list ap; - va_start(ap, format); - int result = ::vfprintf(stream, format, ap); - va_end(ap); +#if defined(HAVE_VFPRINTF) + int result = ::vfprintf(stream, format, arg); return result; #else -# error fprintf not available +# error vfprintf not available #endif } @@ -543,10 +555,10 @@ inline static void *system_realloc(void *ptr, size_t size) #endif } -template -inline int os::call_scandir(int (*scandir)(const char *, struct dirent ***, F1, F2), const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const void *, const void *)) +template +inline int os::call_scandir(int (*scandir)(const char *, struct dirent ***, _F1, _F2), const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const void *, const void *)) { - return scandir(dir, namelist, (F1) filter, (F2) compar); + return scandir(dir, namelist, (_F1) filter, (_F2) compar); } inline int os::scandir(const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const void *, const void *))