Skip to content

Commit

Permalink
fix: Add missing endian conversion macros to enable MacOS builds
Browse files Browse the repository at this point in the history
We had been manually hacking this into our headers to build locally. I _believe_ this is the correct place to put them, or at least this change allows Gazette to build on my Mac without hacks.
  • Loading branch information
jshearer authored and jgraettinger committed Jun 28, 2024
1 parent 724b2cf commit aa568b5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions consumer/store-sqlite/store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@
#include <rocksdb/db.h>
#include <rocksdb/utilities/write_batch_with_index.h>

#ifdef __APPLE__

#include <libkern/OSByteOrder.h>

#define htobe16(x) OSSwapHostToBigInt16(x)
#define htole16(x) OSSwapHostToLittleInt16(x)
#define be16toh(x) OSSwapBigToHostInt16(x)
#define le16toh(x) OSSwapLittleToHostInt16(x)

#define htobe32(x) OSSwapHostToBigInt32(x)
#define htole32(x) OSSwapHostToLittleInt32(x)
#define be32toh(x) OSSwapBigToHostInt32(x)
#define le32toh(x) OSSwapLittleToHostInt32(x)

#define htobe64(x) OSSwapHostToBigInt64(x)
#define htole64(x) OSSwapHostToLittleInt64(x)
#define be64toh(x) OSSwapBigToHostInt64(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)

#endif

// recFS is a sqlite3_vfs which records mutations of stateful SQLite DB files.
struct recFS {
sqlite3_vfs base; // C-style subclass (is-a sqlite3_vfs).
Expand Down

0 comments on commit aa568b5

Please sign in to comment.