Sfoglia il codice sorgente

inline functions on MSVC

Julius Pfrommer 10 anni fa
parent
commit
5c34c68c14
2 ha cambiato i file con 12 aggiunte e 6 eliminazioni
  1. 3 3
      src/util/ua_util.c
  2. 9 3
      src/util/ua_util.h

+ 3 - 3
src/util/ua_util.c

@@ -2,9 +2,9 @@
 
 /* the extern inline in a *.c-file is required for other compilation units to
    see the inline function. */
-extern inline UA_Int32 _UA_free(void *ptr, char *pname, char *f, UA_Int32 l);
-extern inline UA_Int32 _UA_alloc(void **ptr, UA_Int32 size, char *pname, char *sname, char *f, UA_Int32 l);
-extern inline UA_Int32 _UA_alloca(void **ptr, UA_Int32 size, char *pname, char *sname, char *f, UA_Int32 l);
+extern INLINE UA_Int32 _UA_free(void *ptr, char *pname, char *f, UA_Int32 l);
+extern INLINE UA_Int32 _UA_alloc(void **ptr, UA_Int32 size, char *pname, char *sname, char *f, UA_Int32 l);
+extern INLINE UA_Int32 _UA_alloca(void **ptr, UA_Int32 size, char *pname, char *sname, char *f, UA_Int32 l);
 
 UA_Int32 UA_memcpy(void *dst, void const *src, UA_Int32 size) {
 	if(dst == UA_NULL) return UA_ERR_INVALID_VALUE;

+ 9 - 3
src/util/ua_util.h

@@ -25,6 +25,12 @@
 # endif
 #endif
 
+#ifdef MSVC
+#define INLINE __inline
+#else
+#define INLINE inline
+#endif
+
 /* Global Variables */
 extern UA_ByteString UA_ByteString_securityPoliceNone;
 void const *UA_alloc_lastptr;
@@ -32,13 +38,13 @@ void const *UA_alloc_lastptr;
 /* Heap memory functions */
 #define UA_NULL ((void *)0)
 
-inline UA_Int32 _UA_free(void *ptr, char *pname, char *f, UA_Int32 l) {
+INLINE UA_Int32 _UA_free(void *ptr, char *pname, char *f, UA_Int32 l) {
 	DBG_VERBOSE(printf("UA_free;%p;;%s;;%s;%d\n", ptr, pname, f, l); fflush(stdout));
 	free(ptr); // checks if ptr != NULL in the background
 	return UA_SUCCESS;
 }
 
-inline UA_Int32 _UA_alloc(void **ptr, UA_Int32 size, char *pname, char *sname, char *f, UA_Int32 l) {
+INLINE UA_Int32 _UA_alloc(void **ptr, UA_Int32 size, char *pname, char *sname, char *f, UA_Int32 l) {
 	if(ptr == UA_NULL)
 		return UA_ERR_INVALID_VALUE;
 	UA_alloc_lastptr = *ptr = malloc(size);
@@ -48,7 +54,7 @@ inline UA_Int32 _UA_alloc(void **ptr, UA_Int32 size, char *pname, char *sname, c
 	return UA_SUCCESS;
 }
 
-inline UA_Int32 _UA_alloca(void **ptr, UA_Int32 size, char *pname, char *sname, char *f, UA_Int32 l) {
+INLINE UA_Int32 _UA_alloca(void **ptr, UA_Int32 size, char *pname, char *sname, char *f, UA_Int32 l) {
 	if(ptr == UA_NULL)
 		return UA_ERR_INVALID_VALUE;
 #ifdef WIN32