Browse Source

no need to include alloca.h if gcc is used

(cherry picked from commit 3b1c0305c536607d578512b64a477e140e0aab56)
Stasik0 10 years ago
parent
commit
8185304c07
1 changed files with 7 additions and 4 deletions
  1. 7 4
      src/ua_util.h

+ 7 - 4
src/ua_util.h

@@ -31,8 +31,6 @@
 
 #ifdef _WIN32
 # include <malloc.h>
-#else
-# include <alloca.h>
 #endif
 
 #define UA_NULL ((void *)0)
@@ -52,9 +50,14 @@
 #define UA_memset(ptr, value, size) memset(ptr, value, size)
 
 #ifdef _WIN32
-# define UA_alloca(SIZE) _alloca(SIZE)
+    # define UA_alloca(SIZE) _alloca(SIZE)
 #else
-# define UA_alloca(SIZE) alloca(SIZE)
+ #ifdef __GNUC__
+    # define UA_alloca(size)   __builtin_alloca (size)
+ #else
+    # include <alloca.h>
+    # define UA_alloca(SIZE) alloca(SIZE)
+ #endif
 #endif
 
 /********************/