]> git.ipfire.org Git - thirdparty/git.git/commitdiff
reftable: introduce "reftable-system.h" header
authorPatrick Steinhardt <ps@pks.im>
Thu, 2 Apr 2026 07:31:14 +0000 (09:31 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Apr 2026 17:45:43 +0000 (10:45 -0700)
We're including a couple of standard headers like <stdint.h> in a bunch
of locations, which makes it hard for a project to plug in their own
logic for making required functionality available. For us this is for
example via "compat/posix.h", which already includes all of the system
headers relevant to us.

Introduce a new "reftable-system.h" header that allows projects to
provide their own headers. This new header is supposed to contain all
the project-specific bits to provide the POSIX-like environment, and some
additional supporting code. With this change, we thus have the following
split in our system-specific code:

  - "reftable/reftable-system.h" is the project-specific header that
    provides a POSIX-like environment. Every project is expected to
    provide their own implementation.

  - "reftable/system.h" contains the project-independent definition of
    the interfaces that a project needs to implement. This file should
    not be touched by a project.

  - "reftable/system.c" contains the project-specific implementation of
    the interfaces defined in "system.h". Again, every project is
    expected to provide their own implementation.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 files changed:
reftable/reftable-basics.h
reftable/reftable-block.h
reftable/reftable-blocksource.h
reftable/reftable-error.h
reftable/reftable-fsck.h
reftable/reftable-iterator.h
reftable/reftable-merged.h
reftable/reftable-record.h
reftable/reftable-stack.h
reftable/reftable-system.h [new file with mode: 0644]
reftable/reftable-table.h
reftable/reftable-writer.h
reftable/system.h

index 6d73f19c85b6d3cb3cd75316a770d765bc45554d..dc8622682d7d06576ba7d244109b0ad2d3581f40 100644 (file)
@@ -9,7 +9,7 @@
 #ifndef REFTABLE_BASICS_H
 #define REFTABLE_BASICS_H
 
-#include <stddef.h>
+#include "reftable-system.h"
 
 /* A buffer that contains arbitrary byte slices. */
 struct reftable_buf {
index 0b05a8f7e376bc897399d701f9634f650e4d87c8..94c79b5c58fb765c903c16cbec2410894fff81ba 100644 (file)
@@ -9,8 +9,7 @@
 #ifndef REFTABLE_BLOCK_H
 #define REFTABLE_BLOCK_H
 
-#include <stdint.h>
-
+#include "reftable-system.h"
 #include "reftable-basics.h"
 #include "reftable-blocksource.h"
 #include "reftable-iterator.h"
index f5ba867bd60a10f0d323dbb96004de9f26bf46c2..40c1e94646292130a5adba923aac2d30dd0f5477 100644 (file)
@@ -9,7 +9,7 @@
 #ifndef REFTABLE_BLOCKSOURCE_H
 #define REFTABLE_BLOCKSOURCE_H
 
-#include <stdint.h>
+#include "reftable-system.h"
 
 /*
  * Generic wrapper for a seekable readable file.
index d100e0df927ca219fa2986ff50e1cfe05823b37d..0535e1478bda2df21ea8dc59f23429d4cc389ba3 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef REFTABLE_ERROR_H
 #define REFTABLE_ERROR_H
 
+#include "reftable-system.h"
+
 /*
  * Errors in reftable calls are signaled with negative integer return values. 0
  * means success.
index 007a392cf906c7a69fdafc883deb8cc8ff386d49..340fc7762ed76ffea90762e2dd8b44ad778e8f71 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef REFTABLE_FSCK_H
 #define REFTABLE_FSCK_H
 
+#include "reftable-system.h"
 #include "reftable-stack.h"
 
 enum reftable_fsck_error {
index af582028c27fdcacb086183d43d872e1ea166869..a050cc153be711e3c6fea4ca48e6079d2bab55ed 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef REFTABLE_ITERATOR_H
 #define REFTABLE_ITERATOR_H
 
+#include "reftable-system.h"
 #include "reftable-record.h"
 
 struct reftable_iterator_vtable;
index e5af846b32a95f615e078c960b9fcb2a4a5cdcfa..02a9966835eb151fb9178dcb9ea8604441ab0122 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef REFTABLE_MERGED_H
 #define REFTABLE_MERGED_H
 
+#include "reftable-system.h"
 #include "reftable-iterator.h"
 
 /*
index 385a74cc8649854dc2275f6a7b79d63d42656fc8..e18c5382381c4bc355eb5c273f680e508c829a98 100644 (file)
@@ -9,8 +9,8 @@
 #ifndef REFTABLE_RECORD_H
 #define REFTABLE_RECORD_H
 
+#include "reftable-system.h"
 #include "reftable-basics.h"
-#include <stdint.h>
 
 /*
  * Basic data types
index c2415cbc6e46a61c6cb58820799e7bbcc4be4df5..5f7be573fabf8e1765c22b89711542ccf39ca9ba 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef REFTABLE_STACK_H
 #define REFTABLE_STACK_H
 
+#include "reftable-system.h"
 #include "reftable-writer.h"
 
 /*
diff --git a/reftable/reftable-system.h b/reftable/reftable-system.h
new file mode 100644 (file)
index 0000000..4a18a6a
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef REFTABLE_SYSTEM_H
+#define REFTABLE_SYSTEM_H
+
+/*
+ * This header defines the platform-specific bits required to compile the
+ * reftable library. It should provide an environment that bridges over the
+ * gaps between POSIX and your system, as well as the zlib interfaces. This
+ * header is expected to be changed by the individual project.
+ */
+
+#define MINGW_DONT_HANDLE_IN_USE_ERROR
+#include "compat/posix.h"
+#include "compat/zlib-compat.h"
+
+#endif
index 5f935d02e3b195d5585a56219497baeaff522cea..d7666b53a1ee0c262e21523ef477c859127b9894 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef REFTABLE_TABLE_H
 #define REFTABLE_TABLE_H
 
+#include "reftable-system.h"
 #include "reftable-iterator.h"
 #include "reftable-block.h"
 #include "reftable-blocksource.h"
index 1e7003cd698879ced874260c308d9cac06650a91..065dd93dc6bc613dcd109f0e9b4d3302923248d0 100644 (file)
@@ -9,11 +9,9 @@
 #ifndef REFTABLE_WRITER_H
 #define REFTABLE_WRITER_H
 
+#include "reftable-system.h"
 #include "reftable-record.h"
 
-#include <stdint.h>
-#include <unistd.h> /* ssize_t */
-
 /* Writing single reftables */
 
 /* reftable_write_options sets options for writing a single reftable. */
index c54ed4cad61f734b36c276097579f94cc649beaa..a7eb6acd4a4b67c29519d8d2b631a3ed6d5cd864 100644 (file)
@@ -9,11 +9,14 @@
 #ifndef SYSTEM_H
 #define SYSTEM_H
 
-/* This header glues the reftable library to the rest of Git */
+/*
+ * This header defines the platform-agnostic interface that is to be
+ * implemented by the project to make it work on their respective supported
+ * systems, and to integrate it into the project itself. This header is not
+ * expected to be changed by the individual project.
+ */
 
-#define MINGW_DONT_HANDLE_IN_USE_ERROR
-#include "compat/posix.h"
-#include "compat/zlib-compat.h"
+#include "reftable-system.h"
 
 /*
  * Return a random 32 bit integer. This function is expected to return