Browse Source

fix msvc build

Julius Pfrommer 10 years ago
parent
commit
333d2d244d

+ 0 - 4
CMakeLists.txt

@@ -8,10 +8,6 @@ set(NVIM_VERSION_PATCH 0)
 
 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
 
-# Set available build types for CMake GUIs.
-# A different build type can still be set by -DCMAKE_BUILD_TYPE=...
-set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
-
 # Set default build type.
 if (NOT CMAKE_BUILD_TYPE)
     message(STATUS "CMAKE_BUILD_TYPE not given; setting to 'RelWithDebInfo'.")

+ 2 - 2
examples/networklayer_tcp.c

@@ -17,10 +17,10 @@
 #include <sys/socketvar.h>
 #include <sys/ioctl.h>
 #include <unistd.h> // read, write, close
+#include <arpa/inet.h>
 #define CLOSESOCKET(S) close(S)
 #endif
 
-#include <arpa/inet.h>
 #include <stdio.h>
 #include <errno.h> // errno, EINTR
 #include <fcntl.h> // fcntl
@@ -308,7 +308,7 @@ UA_Int32 NetworkLayerTCP_getWork(NetworkLayerTCP *layer, UA_WorkItem **workItems
             buf.data = malloc(layer->conf.recvBufferSize);
         
 #ifdef _WIN32
-        buf.length = recv(layer->conLinks[i].connection.sockfd, (char *)buf.data,
+        buf.length = recv(layer->conLinks[i].sockfd, (char *)buf.data,
                           layer->conf.recvBufferSize, 0);
 #else
         buf.length = read(layer->conLinks[i].sockfd, buf.data, layer->conf.recvBufferSize);

+ 2 - 2
src/server/ua_services_nodemanagement.c

@@ -287,10 +287,10 @@ void Service_AddReferences(UA_Server *server, UA_Session *session,
 			sizeof(UA_StatusCode) * response->resultsSize);
 	/* ### Begin External Namespaces */
 //UA_Boolean isExternal[MAX_ADDREFERENCES_SIZE];
-	UA_Boolean isExternal[request->referencesToAddSize];
+	UA_Boolean *isExternal = UA_alloca(sizeof(UA_Boolean) * request->referencesToAddSize);
 	UA_memset(isExternal, UA_FALSE,
 			sizeof(UA_Boolean) * request->referencesToAddSize);
-	UA_UInt32 indices[request->referencesToAddSize];
+	UA_UInt32 *indices = UA_alloca(sizeof(UA_UInt32) * request->referencesToAddSize);
 	for (UA_Int32 j = 0; j < server->externalNamespacesSize; j++) {
 		UA_UInt32 indexSize = 0;
 		for (UA_Int32 i = 0; i < request->referencesToAddSize; i++) {

+ 1 - 1
src/ua_config.h.in

@@ -6,7 +6,7 @@
 #cmakedefine UA_MULTITHREADING
 
 /* Visibility */
-#ifdef MSVC
+#ifdef _MSC_VER
 #define INLINE __inline
 #else
 #define INLINE inline

+ 1 - 1
src/ua_transport.c

@@ -7,7 +7,7 @@
 #include "ua_util.h"
 
 // max message size is 64k
-const UA_EXPORT UA_ConnectionConfig UA_ConnectionConfig_standard =
+const UA_ConnectionConfig UA_ConnectionConfig_standard =
     {.protocolVersion = 0, .sendBufferSize = 65536, .recvBufferSize  = 65536,
      .maxMessageSize = 65536, .maxChunkCount   = 1};
 

+ 13 - 7
src/ua_types.c

@@ -3,7 +3,7 @@
 #include <stdio.h> // printf
 #include <string.h> // strlen
 #define __USE_POSIX
-#include <stdlib.h> // malloc, free
+#include <stdlib.h> // malloc, free, rand
 
 #ifdef _WIN32
 #include <windows.h>
@@ -13,6 +13,12 @@
 
 #include "ua_util.h"
 
+#ifdef _MSC_VER
+#define RAND(SEED) rand(SEED)
+#else
+#define RAND(SEED) rand_r(SEED)
+#endif
+
 #ifdef UA_DEBUG
 #include <inttypes.h>
 #endif
@@ -261,7 +267,7 @@ UA_TYPE_AS(UA_DateTime, UA_Int64)
 #define HUNDRED_NANOSEC_PER_USEC 10LL
 #define HUNDRED_NANOSEC_PER_SEC (HUNDRED_NANOSEC_PER_USEC * 1000000LL)
 
-#ifdef MSVC
+#ifdef _MSC_VER
 static const unsigned __int64 epoch = 116444736000000000;
 int gettimeofday(struct timeval *tp, struct timezone *tzp) {
     FILETIME       ft;
@@ -327,16 +333,16 @@ UA_Boolean UA_Guid_equal(const UA_Guid *g1, const UA_Guid *g2) {
     return UA_FALSE;
 }
 
-UA_Guid UA_EXPORT UA_Guid_random(UA_UInt32 *seed) {
+UA_Guid UA_Guid_random(UA_UInt32 *seed) {
     UA_Guid result;
-    result.data1 = rand_r(seed);
-    UA_UInt32 r = rand_r(seed);
+    result.data1 = RAND(seed);
+    UA_UInt32 r = RAND(seed);
     result.data2 = r;
     result.data3 = r >> 16;
     UA_UInt32 *fake_int = (UA_UInt32*) &result.data4[0];
-    *fake_int = rand_r(seed);
+    *fake_int = RAND(seed);
     fake_int = (UA_UInt32*) &result.data4[4];
-    *fake_int = rand_r(seed);
+    *fake_int = RAND(seed);
     return result;
 }