1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-23 14:41:43 +00:00

Basic MSC Compatibility (#4147)

MSC Compatibility (Native Compile on Windows)
This commit is contained in:
motwok 2018-11-03 18:52:54 +01:00 committed by TW
parent 08a03126b7
commit 78a3f2475e
2 changed files with 18 additions and 5 deletions

View file

@ -1,4 +1,6 @@
#include <unistd.h>
#if !defined(_MSC_VER)
# include <unistd.h>
#endif
#include <stdlib.h>
#include <stdint.h>
@ -12,7 +14,8 @@
#define BORG_BIG_ENDIAN 1
#elif (defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && (BYTE_ORDER == LITTLE_ENDIAN)) || \
(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) || \
(defined(_LITTLE_ENDIAN) && defined(__SVR4) && defined(__sun))
(defined(_LITTLE_ENDIAN) && defined(__SVR4) && defined(__sun)) || \
(defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_IX86)))
#define BORG_BIG_ENDIAN 0
#else
#error Unknown byte order

View file

@ -8,10 +8,18 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#if !defined(_MSC_VER)
# include <unistd.h>
#endif
#include "_endian.h"
#if defined(_MSC_VER)
# define BORG_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop))
#else
# define BORG_PACKED(x) x __attribute__((packed))
#endif
#define MAGIC "BORG_IDX"
#define MAGIC_LEN 8
@ -25,13 +33,14 @@
} \
} while (0)
BORG_PACKED(
typedef struct {
char magic[MAGIC_LEN];
int32_t num_entries;
int32_t num_buckets;
int8_t key_size;
int8_t value_size;
} __attribute__((__packed__)) HashHeader;
}) HashHeader;
typedef struct {
unsigned char *buckets;
@ -693,7 +702,8 @@ hashindex_size(HashIndex *index)
/*
* Used by the FuseVersionsIndex.
*/
BORG_PACKED(
typedef struct {
uint32_t version;
char hash[16];
} __attribute__((__packed__)) FuseVersionsElement;
} ) FuseVersionsElement;