[Mesa-dev] [PATCHv3 01/16] util: add _mesa_strtod and _mesa_strtof

2014-08-20 Thread Chia-I Wu
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 o...@lunarg.com
---
 src/glsl/Makefile.sources|  3 +-
 src/glsl/glsl_lexer.ll   | 12 +++---
 src/glsl/s_expression.cpp|  2 +-
 src/glsl/s_expression.h  |  2 +-
 src/glsl/strtod.c| 79 ---
 src/glsl/strtod.h| 46 ---
 src/mesa/main/imports.c  | 19 --
 src/mesa/main/imports.h  |  3 --
 src/mesa/program/program_lexer.l |  1 +
 src/util/Makefile.sources|  3 +-
 src/util/strtod.cpp  | 81 
 src/util/strtod.h| 46 +++
 12 files changed, 139 insertions(+), 158 deletions(-)
 delete mode 100644 src/glsl/strtod.c
 delete mode 100644 src/glsl/strtod.h
 create mode 100644 src/util/strtod.cpp
 create mode 100644 src/util/strtod.h

diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index 2131dda..472ad89 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -101,8 +101,7 @@ LIBGLSL_FILES = \
$(GLSL_SRCDIR)/opt_swizzle_swizzle.cpp \
$(GLSL_SRCDIR)/opt_tree_grafting.cpp \
$(GLSL_SRCDIR)/opt_vectorize.cpp \
-   $(GLSL_SRCDIR)/s_expression.cpp \
-   $(GLSL_SRCDIR)/strtod.c
+   $(GLSL_SRCDIR)/s_expression.cpp
 
 # glsl_compiler
 
diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index b7c4aad..ed2f26d 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -23,7 +23,7 @@
  */
 #include ctype.h
 #include limits.h
-#include strtod.h
+#include util/strtod.h
 #include ast.h
 #include glsl_parser_extras.h
 #include glsl_parser.h
@@ -448,23 +448,23 @@ layout{
}
 
 [0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]?  {
-   yylval-real = glsl_strtof(yytext, NULL);
+   yylval-real = _mesa_strtof(yytext, NULL);
return FLOATCONSTANT;
}
 \.[0-9]+([eE][+-]?[0-9]+)?[fF]?{
-   yylval-real = glsl_strtof(yytext, NULL);
+   yylval-real = _mesa_strtof(yytext, NULL);
return FLOATCONSTANT;
}
 [0-9]+\.([eE][+-]?[0-9]+)?[fF]?{
-   yylval-real = glsl_strtof(yytext, NULL);
+   yylval-real = _mesa_strtof(yytext, NULL);
return FLOATCONSTANT;
}
 [0-9]+[eE][+-]?[0-9]+[fF]? {
-   yylval-real = glsl_strtof(yytext, NULL);
+   yylval-real = _mesa_strtof(yytext, NULL);
return FLOATCONSTANT;
}
 [0-9]+[fF] {
-   yylval-real = glsl_strtof(yytext, NULL);
+   yylval-real = _mesa_strtof(yytext, NULL);
return FLOATCONSTANT;
}
 
diff --git a/src/glsl/s_expression.cpp b/src/glsl/s_expression.cpp
index 1a28e1d..2928a4d 100644
--- a/src/glsl/s_expression.cpp
+++ b/src/glsl/s_expression.cpp
@@ -73,7 +73,7 @@ read_atom(void *ctx, const char *src, char *symbol_buffer)
} else {
   // Check if the atom is a number.
   char *float_end = NULL;
-  float f = glsl_strtof(src, float_end);
+  float f = _mesa_strtof(src, float_end);
   if (float_end != src) {
  char *int_end = NULL;
  int i = strtol(src, int_end, 10);
diff --git a/src/glsl/s_expression.h b/src/glsl/s_expression.h
index 642af19..1d47535 100644
--- a/src/glsl/s_expression.h
+++ b/src/glsl/s_expression.h
@@ -27,7 +27,7 @@
 #define S_EXPRESSION_H
 
 #include main/core.h /* for Elements */
-#include strtod.h
+#include util/strtod.h
 #include list.h
 
 /* Type-safe downcasting macros (also safe to pass NULL) */
diff --git a/src/glsl/strtod.c b/src/glsl/strtod.c
deleted file mode 100644
index 5d4346b..000
--- a/src/glsl/strtod.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * Software), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS 

Re: [Mesa-dev] [PATCHv3 01/16] util: add _mesa_strtod and _mesa_strtof

2014-08-20 Thread Kenneth Graunke
On Wednesday, August 20, 2014 02:40:22 PM Chia-I Wu wrote:
 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 o...@lunarg.com
 ---
  src/glsl/Makefile.sources|  3 +-
  src/glsl/glsl_lexer.ll   | 12 +++---
  src/glsl/s_expression.cpp|  2 +-
  src/glsl/s_expression.h  |  2 +-
  src/glsl/strtod.c| 79 ---
  src/glsl/strtod.h| 46 ---
  src/mesa/main/imports.c  | 19 --
  src/mesa/main/imports.h  |  3 --
  src/mesa/program/program_lexer.l |  1 +
  src/util/Makefile.sources|  3 +-
  src/util/strtod.cpp  | 81 
 
  src/util/strtod.h| 46 +++
  12 files changed, 139 insertions(+), 158 deletions(-)
  delete mode 100644 src/glsl/strtod.c
  delete mode 100644 src/glsl/strtod.h
  create mode 100644 src/util/strtod.cpp
  create mode 100644 src/util/strtod.h

Patches 1-4 are:
Reviewed-by: Kenneth Graunke kenn...@whitecape.org

signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev