mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix for OS X 10.5 compile error wrt llabs()
GCC < 4.1.0 possibly has a problem w/ choosing an llabs() unambigiously from stdlib.h and cstdlib See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13943
This commit is contained in:
parent
e1ebf81f76
commit
3f6aa735e9
3 changed files with 33 additions and 1 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
include(CheckCSourceCompiles)
|
||||||
|
include(CheckCXXSourceCompiles)
|
||||||
|
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||||
# alternate malloc is faster for FreeBSD, but needs more testing
|
# alternate malloc is faster for FreeBSD, but needs more testing
|
||||||
# need to add way to set this from the command line
|
# need to add way to set this from the command line
|
||||||
|
@ -7,6 +10,28 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||||
set(USE_NMALLOC true)
|
set(USE_NMALLOC true)
|
||||||
|
|
||||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
|
# The following may have a greater scope than just Darwin
|
||||||
|
# (i.e. any platform w/ GCC < 4.1.0), but I've only seen
|
||||||
|
# it on OS X 10.5, which has GCC 4.0.1, so the workaround
|
||||||
|
# will be stuck here for now.
|
||||||
|
#
|
||||||
|
# See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13943
|
||||||
|
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <math.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
using namespace std;
|
||||||
|
int main() {
|
||||||
|
llabs(1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" darwin_llabs_works)
|
||||||
|
|
||||||
|
if (NOT darwin_llabs_works)
|
||||||
|
# abs() should be used in this case, the long long version should
|
||||||
|
# exist in the __gnu_cxx namespace
|
||||||
|
set(DARWIN_NO_LLABS true)
|
||||||
|
endif ()
|
||||||
|
|
||||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
set(HAVE_LINUX true)
|
set(HAVE_LINUX true)
|
||||||
|
@ -25,7 +50,7 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "irix")
|
||||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "ultrix")
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "ultrix")
|
||||||
list(APPEND CMAKE_C_FLAGS -std1 -g3)
|
list(APPEND CMAKE_C_FLAGS -std1 -g3)
|
||||||
list(APPEND CMAKE_CXX_FLAGS -std1 -g3)
|
list(APPEND CMAKE_CXX_FLAGS -std1 -g3)
|
||||||
include(CheckCSourceCompiles)
|
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
int main() {
|
int main() {
|
||||||
|
|
|
@ -146,3 +146,6 @@
|
||||||
|
|
||||||
/* Define u_int8_t */
|
/* Define u_int8_t */
|
||||||
#define u_int8_t @U_INT8_T@
|
#define u_int8_t @U_INT8_T@
|
||||||
|
|
||||||
|
/* Whether llabs will be ambiguous in stdlib.h and cstdlib headers */
|
||||||
|
#cmakedefine DARWIN_NO_LLABS
|
||||||
|
|
|
@ -524,7 +524,11 @@ Val* Val::SizeVal() const
|
||||||
{
|
{
|
||||||
switch ( type->InternalType() ) {
|
switch ( type->InternalType() ) {
|
||||||
case TYPE_INTERNAL_INT:
|
case TYPE_INTERNAL_INT:
|
||||||
|
#ifdef DARWIN_NO_LLABS
|
||||||
|
return new Val(abs(val.int_val), TYPE_COUNT);
|
||||||
|
#else
|
||||||
return new Val(llabs(val.int_val), TYPE_COUNT);
|
return new Val(llabs(val.int_val), TYPE_COUNT);
|
||||||
|
#endif
|
||||||
|
|
||||||
case TYPE_INTERNAL_UNSIGNED:
|
case TYPE_INTERNAL_UNSIGNED:
|
||||||
return new Val(val.uint_val, TYPE_COUNT);
|
return new Val(val.uint_val, TYPE_COUNT);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue