summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Duncan Ogilvie2024-11-26 18:39:28 +0100
committerGravatar Duncan Ogilvie2024-11-28 17:32:39 +0100
commit9bdf7fe983311e8c573d7c466c2006059645c4ba (patch)
tree293fe31fda5a98b03d83fe4fe6e821a4664264e6
parent7d3cc96077d859fcda6dfe2a6bd2b1eb589af66d (diff)
downloadlibimobiledevice-glue-9bdf7fe983311e8c573d7c466c2006059645c4ba.tar.gz
libimobiledevice-glue-9bdf7fe983311e8c573d7c466c2006059645c4ba.tar.bz2
Fix compilation on MSVC
-rw-r--r--include/libimobiledevice-glue/nskeyedarchive.h4
-rw-r--r--src/Makefile.am1
-rw-r--r--src/fixedint.h72
-rw-r--r--src/sha1.c2
-rw-r--r--src/sha256.c2
-rw-r--r--src/sha512.c2
-rw-r--r--src/socket.c14
-rw-r--r--src/termcolors.c2
-rw-r--r--src/utils.c2
9 files changed, 20 insertions, 81 deletions
diff --git a/include/libimobiledevice-glue/nskeyedarchive.h b/include/libimobiledevice-glue/nskeyedarchive.h
index 5aad4d6..304495a 100644
--- a/include/libimobiledevice-glue/nskeyedarchive.h
+++ b/include/libimobiledevice-glue/nskeyedarchive.h
@@ -57,9 +57,9 @@ LIMD_GLUE_API void nskeyedarchive_free(nskeyedarchive_t ka);
LIMD_GLUE_API void nskeyedarchive_set_top_ref_key_name(nskeyedarchive_t ka, const char* keyname);
-LIMD_GLUE_API uint64_t nskeyedarchive_add_top_class(nskeyedarchive_t ka, const char* classname, ...) __attribute__ ((sentinel(0)));
+LIMD_GLUE_API uint64_t nskeyedarchive_add_top_class(nskeyedarchive_t ka, const char* classname, ...);
LIMD_GLUE_API void nskeyedarchive_add_top_class_uid(nskeyedarchive_t ka, uint64_t uid);
-LIMD_GLUE_API void nskeyedarchive_append_class(nskeyedarchive_t ka, const char* classname, ...) __attribute__ ((sentinel(0)));
+LIMD_GLUE_API void nskeyedarchive_append_class(nskeyedarchive_t ka, const char* classname, ...);
LIMD_GLUE_API void nskeyedarchive_append_object(nskeyedarchive_t ka, plist_t object);
LIMD_GLUE_API void nskeyedarchive_nsarray_append_item(nskeyedarchive_t ka, uint64_t uid, enum nskeyedarchive_class_type_t type, ...);
diff --git a/src/Makefile.am b/src/Makefile.am
index 0089b5d..451b753 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,7 +21,6 @@ libimobiledevice_glue_1_0_la_SOURCES = \
sha1.c \
sha256.c \
sha512.c \
- fixedint.h \
common.h
if WIN32
diff --git a/src/fixedint.h b/src/fixedint.h
deleted file mode 100644
index 1a8745b..0000000
--- a/src/fixedint.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Portable header to provide the 32 and 64 bits type.
-
- Not a compatible replacement for <stdint.h>, do not blindly use it as such.
-*/
-
-#if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__WATCOMC__) && (defined(_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_) || defined(__UINT_FAST64_TYPE__)) )) && !defined(FIXEDINT_H_INCLUDED)
- #include <stdint.h>
- #define FIXEDINT_H_INCLUDED
-
- #if defined(__WATCOMC__) && __WATCOMC__ >= 1250 && !defined(UINT64_C)
- #include <limits.h>
- #define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
- #endif
-#endif
-
-
-#ifndef FIXEDINT_H_INCLUDED
- #define FIXEDINT_H_INCLUDED
-
- #include <limits.h>
-
- /* (u)int32_t */
- #ifndef uint32_t
- #if (ULONG_MAX == 0xffffffffUL)
- typedef unsigned long uint32_t;
- #elif (UINT_MAX == 0xffffffffUL)
- typedef unsigned int uint32_t;
- #elif (USHRT_MAX == 0xffffffffUL)
- typedef unsigned short uint32_t;
- #endif
- #endif
-
-
- #ifndef int32_t
- #if (LONG_MAX == 0x7fffffffL)
- typedef signed long int32_t;
- #elif (INT_MAX == 0x7fffffffL)
- typedef signed int int32_t;
- #elif (SHRT_MAX == 0x7fffffffL)
- typedef signed short int32_t;
- #endif
- #endif
-
-
- /* (u)int64_t */
- #if (defined(__STDC__) && defined(__STDC_VERSION__) && __STDC__ && __STDC_VERSION__ >= 199901L)
- typedef long long int64_t;
- typedef unsigned long long uint64_t;
-
- #define UINT64_C(v) v ##ULL
- #define INT64_C(v) v ##LL
- #elif defined(__GNUC__)
- __extension__ typedef long long int64_t;
- __extension__ typedef unsigned long long uint64_t;
-
- #define UINT64_C(v) v ##ULL
- #define INT64_C(v) v ##LL
- #elif defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) || defined(__APPLE_CC__) || defined(_LONG_LONG) || defined(_CRAYC)
- typedef long long int64_t;
- typedef unsigned long long uint64_t;
-
- #define UINT64_C(v) v ##ULL
- #define INT64_C(v) v ##LL
- #elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined(__BORLANDC__) && __BORLANDC__ > 0x460) || defined(__alpha) || defined(__DECC)
- typedef __int64 int64_t;
- typedef unsigned __int64 uint64_t;
-
- #define UINT64_C(v) v ##UI64
- #define INT64_C(v) v ##I64
- #endif
-#endif
diff --git a/src/sha1.c b/src/sha1.c
index 60c3b56..b4f87b3 100644
--- a/src/sha1.c
+++ b/src/sha1.c
@@ -12,7 +12,7 @@
#include "common.h"
#include "libimobiledevice-glue/sha.h"
-#include "fixedint.h"
+#include <stdint.h>
#define ROLc(x, y) \
( (((unsigned long)(x)<<(unsigned long)((y)&31)) | \
diff --git a/src/sha256.c b/src/sha256.c
index 71be516..e5da53f 100644
--- a/src/sha256.c
+++ b/src/sha256.c
@@ -12,7 +12,7 @@
#include "common.h"
#include "libimobiledevice-glue/sha.h"
-#include "fixedint.h"
+#include <stdint.h>
/* the K array */
static const uint32_t K[64] = {
diff --git a/src/sha512.c b/src/sha512.c
index 62c7159..c27f9ff 100644
--- a/src/sha512.c
+++ b/src/sha512.c
@@ -9,7 +9,7 @@
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
-#include "fixedint.h"
+#include <stdint.h>
#include "common.h"
#include "libimobiledevice-glue/sha.h"
diff --git a/src/socket.c b/src/socket.c
index b42d366..f09d3a5 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -26,10 +26,12 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#include <errno.h>
+#ifndef _MSC_VER
+#include <unistd.h>
#include <sys/time.h>
#include <sys/stat.h>
+#endif
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
@@ -154,8 +156,14 @@ enum poll_status
poll_status_error
};
+#ifdef _MSC_VER
+#define ALWAYS_INLINE __forceinline
+#else
+#define ALWAYS_INLINE __attribute__((always_inline))
+#endif
+
#ifdef _WIN32
-static inline __attribute__((always_inline)) int WSAError_to_errno(int wsaerr)
+static ALWAYS_INLINE int WSAError_to_errno(int wsaerr)
{
switch (wsaerr) {
case WSAEINVAL:
@@ -200,7 +208,7 @@ static inline __attribute__((always_inline)) int WSAError_to_errno(int wsaerr)
#endif
// timeout of -1 means infinity
-static inline __attribute__((always_inline)) enum poll_status poll_wrapper(int fd, fd_mode mode, int timeout)
+static ALWAYS_INLINE enum poll_status poll_wrapper(int fd, fd_mode mode, int timeout)
{
#ifdef HAVE_POLL
// https://man7.org/linux/man-pages/man2/select.2.html
diff --git a/src/termcolors.c b/src/termcolors.c
index 798e47a..6199bed 100644
--- a/src/termcolors.c
+++ b/src/termcolors.c
@@ -28,7 +28,9 @@
#include <stdio.h>
#include <stdlib.h>
+#ifndef _MSC_VER
#include <unistd.h>
+#endif
#include <string.h>
#include <stdarg.h>
diff --git a/src/utils.c b/src/utils.c
index ad8e9c4..b9803ac 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -30,7 +30,9 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#ifndef _MSC_VER
#include <sys/time.h>
+#endif
#include <inttypes.h>
#include <ctype.h>
#include <errno.h>