[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Fix Solaris and Sun Studio support


This fixes support on Solaris and building with Sun Studio 12.6.

- Add missing includes
- Define compatibility macros to expose function definitions
- Don't enable pedantic, since it disallows `__thread`

Tested on Solaris 11.4 x86
---
CompilerChecks.cmake | 11 ++++++++++-
src/channels.c       |  1 +
src/dh.c             |  2 ++
src/misc.c           |  1 +
4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/CompilerChecks.cmake b/CompilerChecks.cmake
index 5bdc05c3..8806c617 100644
--- a/CompilerChecks.cmake
+++ b/CompilerChecks.cmake
@@ -17,7 +17,6 @@ if (UNIX)
     endif()
     add_c_compiler_flag("-std=gnu99" SUPPORTED_COMPILER_FLAGS)
-    add_c_compiler_flag("-Wpedantic" SUPPORTED_COMPILER_FLAGS)
     add_c_compiler_flag("-Wall" SUPPORTED_COMPILER_FLAGS)
     add_c_compiler_flag("-Wshadow" SUPPORTED_COMPILER_FLAGS)
     add_c_compiler_flag("-Wmissing-prototypes" SUPPORTED_COMPILER_FLAGS)
@@ -58,6 +57,10 @@ if (UNIX)
         add_c_compiler_flag("-Wno-gnu-zero-variadic-macro-arguments" SUPPORTED_COMPILER_FLAGS)
     endif()
+    if (NOT "${_C_COMPILER_ID}" STREQUAL "sunpro")
+        add_c_compiler_flag("-Wpedantic" SUPPORTED_COMPILER_FLAGS)
+    endif()
+
     add_c_compiler_flag("-fno-common" SUPPORTED_COMPILER_FLAGS)
     if (CMAKE_BUILD_TYPE)
@@ -114,6 +117,12 @@ if (OSX)
     add_c_compiler_flag("-Wno-deprecated-declarations" SUPPORTED_COMPILER_FLAGS)
endif()
+# Needed for definitions blocked by compat macros
+if (SOLARIS)
+    list(APPEND SUPPORTED_COMPILER_FLAGS "-D__STDC_WANT_LIB_EXT1__")
+    list(APPEND SUPPORTED_COMPILER_FLAGS "-D__EXTENSIONS__")
+endif()
+
set(DEFAULT_C_COMPILE_FLAGS ${SUPPORTED_COMPILER_FLAGS} CACHE INTERNAL "Default C Compiler Flags" FORCE)
set(DEFAULT_LINK_FLAGS ${SUPPORTED_LINKER_FLAGS} CACHE INTERNAL "Default C Linker Flags" FORCE)
diff --git a/src/channels.c b/src/channels.c
index a670d895..7b3352de 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -29,6 +29,7 @@
#include <errno.h>
#include <time.h>
#include <stdbool.h>
+#include <string.h>
 #ifndef _WIN32
#include <netinet/in.h>
diff --git a/src/dh.c b/src/dh.c
index 13b8e03d..858fe557 100644
--- a/src/dh.c
+++ b/src/dh.c
@@ -25,6 +25,8 @@
 #include "config.h"
+#include <string.h>
+
#include "libssh/priv.h"
#include "libssh/crypto.h"
#include "libssh/buffer.h"
diff --git a/src/misc.c b/src/misc.c
index affb3eb4..1d45c487 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -44,6 +44,7 @@
#include <sys/types.h>
#include <ctype.h>
#include <time.h>
+#include <string.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif /* HAVE_SYS_TIME_H */
-- 
2.15.2 


Archive administrator: postmaster@lists.cynapses.org