[Bf-blender-cvs] [95b93b5] master: Add BLI_compiler_compat.h to help with portability
Campbell Barton
noreply at git.blender.org
Thu May 1 17:24:53 CEST 2014
Commit: 95b93b5d46b7fb8b98295a1368bc44a3f63fe8c7
Author: Campbell Barton
Date: Fri May 2 01:14:15 2014 +1000
https://developer.blender.org/rB95b93b5d46b7fb8b98295a1368bc44a3f63fe8c7
Add BLI_compiler_compat.h to help with portability
===================================================================
M source/blender/blenkernel/intern/customdata.c
M source/blender/blenlib/BLI_alloca.h
A source/blender/blenlib/BLI_compiler_compat.h
M source/blender/blenlib/BLI_utildefines.h
M source/blender/blenlib/CMakeLists.txt
M source/blender/blenlib/intern/smallhash.c
M source/blender/bmesh/intern/bmesh_mesh.c
M source/blender/editors/screen/area.c
===================================================================
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 57758ac..fd43501 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -63,10 +63,6 @@
#include <math.h>
#include <string.h>
-#ifdef WIN32
-# include "BLI_alloca.h"
-#endif
-
/* number of layers to add when growing a CustomData object */
#define CUSTOMDATA_GROW 5
diff --git a/source/blender/blenlib/BLI_alloca.h b/source/blender/blenlib/BLI_alloca.h
index 06c3e8d..fd81494 100644
--- a/source/blender/blenlib/BLI_alloca.h
+++ b/source/blender/blenlib/BLI_alloca.h
@@ -28,9 +28,6 @@
*/
/* BLI_array_alloca / alloca */
-#ifdef _MSC_VER
-# define alloca _alloca
-#endif
#if defined(__MINGW32__)
# include <malloc.h> /* mingw needs for alloca() */
diff --git a/source/blender/blenlib/BLI_alloca.h b/source/blender/blenlib/BLI_compiler_compat.h
similarity index 62%
copy from source/blender/blenlib/BLI_alloca.h
copy to source/blender/blenlib/BLI_compiler_compat.h
index 06c3e8d..60a7d8d 100644
--- a/source/blender/blenlib/BLI_alloca.h
+++ b/source/blender/blenlib/BLI_compiler_compat.h
@@ -18,30 +18,18 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#ifndef __BLI_ALLOCA_H__
-#define __BLI_ALLOCA_H__
+#ifndef __BLI_COMPILER_COMPAT_H__
+#define __BLI_COMPILER_COMPAT_H__
-/** \file BLI_alloca.h
+/** \file BLI_compiler_compat.h
* \ingroup bli
*
- * Defines alloca and utility macro BLI_array_alloca
+ * Use to help with cross platform portability.
*/
-/* BLI_array_alloca / alloca */
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
+# define __func__ __FUNCTION__
# define alloca _alloca
#endif
-#if defined(__MINGW32__)
-# include <malloc.h> /* mingw needs for alloca() */
-#endif
-
-#if defined(__GNUC__) || defined(__clang__)
-#define BLI_array_alloca(arr, realsize) \
- (typeof(arr))alloca(sizeof(*arr) * (realsize))
-#else
-#define BLI_array_alloca(arr, realsize) \
- alloca(sizeof(*arr) * (realsize))
-#endif
-
-#endif /* __BLI_ALLOCA_H__ */
+#endif /* __BLI_COMPILER_COMPAT_H__ */
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index ea3701f..8c67c76 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -34,6 +34,7 @@
/* avoid many includes for now */
#include "BLI_sys_types.h"
+#include "BLI_compiler_compat.h"
#ifndef NDEBUG /* for BLI_assert */
#include <stdio.h>
@@ -386,16 +387,9 @@
#define STRCASEEQLEN(a, b, n) (strncasecmp(a, b, n) == 0)
#define STRPREFIX(a, b) (strncmp((a), (b), strlen(b)) == 0)
-
-
/* useful for debugging */
#define AT __FILE__ ":" STRINGIFY(__LINE__)
-/* so we can use __func__ everywhere */
-#if defined(_MSC_VER)
-# define __func__ __FUNCTION__
-#endif
-
/* UNUSED macro, for function argument */
#ifdef __GNUC__
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 1575f8e..9e36074 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -116,6 +116,7 @@ set(SRC
BLI_buffer.h
BLI_callbacks.h
BLI_compiler_attrs.h
+ BLI_compiler_compat.h
BLI_convexhull2d.h
BLI_dlrbTree.h
BLI_dynlib.h
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index e8e3387..d6b2383 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -56,10 +56,6 @@
#include "BLI_utildefines.h"
-#ifdef WIN32
-# include "BLI_alloca.h"
-#endif
-
#include "BLI_smallhash.h"
#include "BLI_strict_flags.h"
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 6b040ef..e9d3c36 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -40,10 +40,6 @@
#include "BKE_editmesh.h"
#include "BKE_multires.h"
-#ifdef WIN32
-# include "BLI_alloca.h"
-#endif
-
#include "intern/bmesh_private.h"
/* used as an extern, defined in bmesh.h */
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 05659f6..151764d 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -68,10 +68,6 @@
#include "screen_intern.h"
-#ifdef WIN32
-# include "BLI_alloca.h"
-#endif
-
extern void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); /* xxx temp */
/* general area and region code */
More information about the Bf-blender-cvs
mailing list