diff options
author | mwturvey <michael.w.turvey@intel.com> | 2017-03-17 14:41:59 -0700 |
---|---|---|
committer | mwturvey <michael.w.turvey@intel.com> | 2017-03-17 14:41:59 -0700 |
commit | b6981854dff11022e3de56e56cbf4633f1c49598 (patch) | |
tree | f5b8f4ff1425f704d791d5b9af9c8af65455868d /winbuild/tcc_stubs.c | |
parent | 94be8ccdbfb2f44c9bc569428537444030ba8eeb (diff) | |
parent | a53c520c2d1a3bb9faa4cb5e4ee9ccc48bb1835f (diff) | |
download | libsurvive-b6981854dff11022e3de56e56cbf4633f1c49598.tar.gz libsurvive-b6981854dff11022e3de56e56cbf4633f1c49598.tar.bz2 |
Merge branch 'master' into UsbTrackerOnWin
# Conflicts:
# src/survive_vive.c
Diffstat (limited to 'winbuild/tcc_stubs.c')
-rw-r--r-- | winbuild/tcc_stubs.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/winbuild/tcc_stubs.c b/winbuild/tcc_stubs.c new file mode 100644 index 0000000..7872914 --- /dev/null +++ b/winbuild/tcc_stubs.c @@ -0,0 +1,59 @@ + +#include <_mingw.h> + +#define REMATH(x) double __cdecl x( double f ); float x##f(float v) { return x(v); } + +REMATH( acos ); +REMATH( cos ); +REMATH( sin ); +REMATH( sqrt ); +REMATH( asin ); + +double __cdecl strtod (const char* str, char** endptr); +float strtof( const char* str, char** endptr) +{ + return strtod( str, endptr ); +} + +double __cdecl atan2(double a, double b); +float atan2f(float a, float b) +{ + return atan2( a, b ); +} + +//From http://stackoverflow.com/questions/40159892/using-asprintf-on-windows +int __cdecl vsprintf_s( + char *buffer, + size_t numberOfElements, + const char *format, + va_list argptr +); + +int asprintf(char **strp, const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + int r = vasprintf(strp, fmt, ap); + va_end(ap); + return r; +} + +int vasprintf(char **strp, const char *fmt, va_list ap) { + // _vscprintf tells you how big the buffer needs to be + int len = _vscprintf(fmt, ap); + if (len == -1) { + return -1; + } + size_t size = (size_t)len + 1; + char *str = (char*)malloc(size); + if (!str) { + return -1; + } + // _vsprintf_s is the "secure" version of vsprintf + int r = vsprintf_s(str, len + 1, fmt, ap); + if (r == -1) { + free(str); + return -1; + } + *strp = str; + return r; +}
\ No newline at end of file |