]> granicus.if.org Git - xz/commitdiff
Use __cdecl also for function pointers in liblzma API when
authorLasse Collin <lasse.collin@tukaani.org>
Sat, 31 Jan 2009 22:10:07 +0000 (00:10 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Sat, 31 Jan 2009 22:10:07 +0000 (00:10 +0200)
on Windows.

src/liblzma/api/lzma.h
src/liblzma/api/lzma/base.h
src/liblzma/common/common.h

index bb6172138cfb4ea1a6714c83c09c4aa24d7b5f2a..d4c693238479b2d7c042ba90430ea11bb988166a 100644 (file)
  ******************/
 
 /*
- * Some systems require that the functions are declared specially
- * in the headers.
+ * Some systems require (or at least recommend) that the functions and
+ * function pointers are declared specially in the headers.
  */
+#ifdef _WIN32
+#      define LZMA_API_CALL __cdecl
+#      define LZMA_API_IMPORT __declspec(dllimport)
+#else
+#      define LZMA_API_CALL
+#      define LZMA_API_IMPORT
+#endif
+
 #ifndef LZMA_API
-#      if defined(_WIN32)
-#              define LZMA_API __cdecl __declspec(dllimport)
-#      else
-#              define LZMA_API
-#      endif
+#      define LZMA_API LZMA_API_CALL LZMA_API_IMPORT
 #endif
 
 
index 9fe3ca66179a51b7a0869c1218824963b75a3636..4944e690350fcdb2638856eb33f31a05d947e18b 100644 (file)
@@ -376,7 +376,7 @@ typedef struct {
         *              returned NULL if some function from liblzma
         *              returns LZMA_MEM_ERROR.
         */
-       void *(*alloc)(void *opaque, size_t nmemb, size_t size);
+       void *(LZMA_API_CALL *alloc)(void *opaque, size_t nmemb, size_t size);
 
        /**
         * \brief       Pointer to a custom memory freeing function
@@ -390,7 +390,7 @@ typedef struct {
         *                      or when it is set to NULL, a pointer returned
         *                      by the standard malloc().
         */
-       void (*free)(void *opaque, void *ptr);
+       void (LZMA_API_CALL *free)(void *opaque, void *ptr);
 
        /**
         * \brief       Pointer passed to .alloc() and .free()
index 2642c5bd2abfd682a30d9e0e91b54cc9fdb37741..4d5b773a64fc3a7541b6add1511eb03b42d84c96 100644 (file)
 #include "../../common/mythread.h"
 #include "../../common/integer.h"
 
-// Don't use ifdef...
-#if HAVE_VISIBILITY
-#      define LZMA_VISIBILITY __attribute__((__visibility__("default")))
+#if defined(_WIN32)
+#      define LZMA_API_EXPORT __declspec(dllexport)
+// Don't use ifdef or defined() below.
+#elif HAVE_VISIBILITY
+#      define LZMA_API_EXPORT __attribute__((__visibility__("default")))
 #else
-#      define LZMA_VISIBILITY
+#      define LZMA_API_EXPORT
 #endif
 
-#ifdef _WIN32
-#      define LZMA_EXPORT __cdecl __declspec(dllexport)
-#else
-#      define LZMA_EXPORT
-#endif
-
-#define LZMA_API LZMA_VISIBILITY LZMA_EXPORT
+#define LZMA_API LZMA_API_CALL LZMA_API_EXPORT
 
 #include "lzma.h"