diff options
author | Chia-I Wu <[email protected]> | 2014-08-20 14:40:22 +0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2014-10-30 02:26:19 -0700 |
commit | e3f20294799d727107012d40f6c973975084e4e6 (patch) | |
tree | 0078109ef4b6fed9197e3bd2c19dd5502c1966e0 /src/mesa | |
parent | 2c2ada67206326911a36368015b9501a023bbac8 (diff) |
util: add _mesa_strtod and _mesa_strtof
Both core mesa and glsl have their own wrappers for strtof_l. Merge
and move them to util/. They are compiled with a C++ compiler so that
we can make them thread-safe in a following commit.
Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/imports.c | 19 | ||||
-rw-r--r-- | src/mesa/main/imports.h | 3 | ||||
-rw-r--r-- | src/mesa/program/program_lexer.l | 1 |
3 files changed, 1 insertions, 22 deletions
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index b8c75481516..4f5a2d11fa9 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -499,25 +499,6 @@ _mesa_strdup( const char *s ) } } -/** Wrapper around strtof() */ -float -_mesa_strtof( const char *s, char **end ) -{ -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ - !defined(ANDROID) && !defined(__HAIKU__) && !defined(__UCLIBC__) && \ - !defined(__NetBSD__) - static locale_t loc = NULL; - if (!loc) { - loc = newlocale(LC_CTYPE_MASK, "C", NULL); - } - return strtof_l(s, end, loc); -#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) - return strtof(s, end); -#else - return (float)strtod(s, end); -#endif -} - /** Compute simple checksum/hash for a string */ unsigned int _mesa_str_checksum(const char *str) diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 436d1651a82..0fcba4fb986 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -540,9 +540,6 @@ _mesa_half_is_negative(GLhalfARB h) extern char * _mesa_strdup( const char *s ); -extern float -_mesa_strtof( const char *s, char **end ); - extern unsigned int _mesa_str_checksum(const char *str); diff --git a/src/mesa/program/program_lexer.l b/src/mesa/program/program_lexer.l index d5dbcf347b3..e3639122058 100644 --- a/src/mesa/program/program_lexer.l +++ b/src/mesa/program/program_lexer.l @@ -28,6 +28,7 @@ #include "program/symbol_table.h" #include "program/program_parser.h" #include "program/program_parse.tab.h" +#include "util/strtod.h" #define require_ARB_vp (yyextra->mode == ARB_vertex) #define require_ARB_fp (yyextra->mode == ARB_fragment) |