git-commit-vandalism/reftable
Ævar Arnfjörð Bjarmason 07564773c2 compat: auto-detect if zlib has uncompress2()
We have a copy of uncompress2() implementation in compat/ so that we
can build with an older version of zlib that lack the function, and
the build procedure selects if it is used via the NO_UNCOMPRESS2
$(MAKE) variable.  This is yet another "annoying" knob the porters
need to tweak on platforms that are not common enough to have the
default set in the config.mak.uname file.

Attempt to instead ask the system header <zlib.h> to decide if we
need the compatibility implementation.  This is a deviation from the
way we have been handling the "compatiblity" features so far, and if
it can be done cleanly enough, it could work as a model for features
that need compatibility definition we discover in the future.  With
that goal in mind, avoid expedient but ugly hacks, like shoving the
code that is conditionally compiled into an unrelated .c file, which
may not work in future cases---instead, take an approach that uses a
file that is independently compiled and stands on its own.

Compile and link compat/zlib-uncompress2.c file unconditionally, but
conditionally hide the implementation behind #if/#endif when zlib
version is 1.2.9 or newer, and unconditionally archive the resulting
object file in the libgit.a to be picked up by the linker.

There are a few things to note in the shape of the code base after
this change:

 - We no longer use NO_UNCOMPRESS2 knob; if the system header
   <zlib.h> claims a version that is more cent than the library
   actually is, this would break, but it is easy to add it back when
   we find such a system.

 - The object file compat/zlib-uncompress2.o is always compiled and
   archived in libgit.a, just like a few other compat/ object files
   already are.

 - The inclusion of <zlib.h> is done in <git-compat-util.h>; we used
   to do so from <cache.h> which includes <git-compat-util.h> as the
   first thing it does, so from the *.c codes, there is no practical
   change.

 - Until objects in libgit.a that is already used gains a reference
   to the function, the reftable code will be the only one that
   wants it, so libgit.a on the linker command line needs to appear
   once more at the end to satisify the mutual dependency.

 - Beat found a trick used by OpenSSL to avoid making the
   conditionally-compiled object truly empty (apparently because
   they had to deal with compilers that do not want to see an
   effectively empty input file).  Our compat/zlib-uncompress2.c
   file borrows the same trick for portabilty.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Helped-by: Beat Bolli <dev+git@drbeat.li>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-01-26 09:05:55 -08:00
..
basics_test.c reftable: utility functions 2021-10-08 10:45:48 -07:00
basics.c reftable: utility functions 2021-10-08 10:45:48 -07:00
basics.h reftable: utility functions 2021-10-08 10:45:48 -07:00
block_test.c reftable: reading/writing blocks 2021-10-08 10:45:48 -07:00
block.c reftable: reading/writing blocks 2021-10-08 10:45:48 -07:00
block.h reftable: fix typo in header 2021-12-23 12:28:28 -08:00
blocksource.c reftable: add blocksource, an abstraction for random access reads 2021-10-08 10:45:48 -07:00
blocksource.h reftable: add blocksource, an abstraction for random access reads 2021-10-08 10:45:48 -07:00
constants.h reftable: (de)serialization for the polymorphic record type. 2021-10-08 10:45:48 -07:00
dump.c reftable: add dump utility 2021-10-08 10:45:48 -07:00
error.c reftable: signal overflow 2021-12-23 12:28:34 -08:00
generic.c reftable: generic interface to tables 2021-10-08 10:45:48 -07:00
generic.h reftable: generic interface to tables 2021-10-08 10:45:48 -07:00
iter.c reftable: read reftable files 2021-10-08 10:45:48 -07:00
iter.h reftable: read reftable files 2021-10-08 10:45:48 -07:00
LICENSE
merged_test.c reftable tests: avoid "int" overflow, use "uint64_t" 2022-01-13 13:39:09 -08:00
merged.c reftable: add merged table view 2021-10-08 10:45:48 -07:00
merged.h reftable: add merged table view 2021-10-08 10:45:48 -07:00
pq_test.c reftable: add a heap-based priority queue for reftable records 2021-10-08 10:45:48 -07:00
pq.c reftable: add a heap-based priority queue for reftable records 2021-10-08 10:45:48 -07:00
pq.h reftable: add a heap-based priority queue for reftable records 2021-10-08 10:45:48 -07:00
publicbasics.c reftable: utility functions 2021-10-08 10:45:48 -07:00
reader.c reftable: read reftable files 2021-10-08 10:45:48 -07:00
reader.h reftable: read reftable files 2021-10-08 10:45:48 -07:00
readwrite_test.c reftable: signal overflow 2021-12-23 12:28:34 -08:00
record_test.c reftable: (de)serialization for the polymorphic record type. 2021-10-08 10:45:48 -07:00
record.c reftable: (de)serialization for the polymorphic record type. 2021-10-08 10:45:48 -07:00
record.h reftable: (de)serialization for the polymorphic record type. 2021-10-08 10:45:48 -07:00
refname_test.c reftable: implement refname validation 2021-10-08 10:45:48 -07:00
refname.c reftable: implement refname validation 2021-10-08 10:45:48 -07:00
refname.h reftable: implement refname validation 2021-10-08 10:45:48 -07:00
reftable-blocksource.h reftable: add blocksource, an abstraction for random access reads 2021-10-08 10:45:48 -07:00
reftable-error.h reftable: signal overflow 2021-12-23 12:28:34 -08:00
reftable-generic.h reftable: generic interface to tables 2021-10-08 10:45:48 -07:00
reftable-iterator.h reftable: generic interface to tables 2021-10-08 10:45:48 -07:00
reftable-malloc.h reftable: utility functions 2021-10-08 10:45:48 -07:00
reftable-merged.h reftable: add merged table view 2021-10-08 10:45:48 -07:00
reftable-reader.h reftable: read reftable files 2021-10-08 10:45:48 -07:00
reftable-record.h reftable: (de)serialization for the polymorphic record type. 2021-10-08 10:45:48 -07:00
reftable-stack.h reftable: implement stack, a mutable database of reftable files. 2021-10-08 10:45:48 -07:00
reftable-tests.h reftable: add a heap-based priority queue for reftable records 2021-10-08 10:45:48 -07:00
reftable-writer.h reftable: support preset file mode for writing 2021-12-23 12:28:36 -08:00
reftable.c reftable: generic interface to tables 2021-10-08 10:45:48 -07:00
stack_test.c reftable: support preset file mode for writing 2021-12-23 12:28:36 -08:00
stack.c reftable: support preset file mode for writing 2021-12-23 12:28:36 -08:00
stack.h reftable: implement stack, a mutable database of reftable files. 2021-10-08 10:45:48 -07:00
system.h compat: auto-detect if zlib has uncompress2() 2022-01-26 09:05:55 -08:00
test_framework.c reftable: utility functions 2021-10-08 10:45:48 -07:00
test_framework.h reftable: utility functions 2021-10-08 10:45:48 -07:00
tree_test.c reftable: a generic binary tree implementation 2021-10-08 10:45:48 -07:00
tree.c reftable: a generic binary tree implementation 2021-10-08 10:45:48 -07:00
tree.h reftable: a generic binary tree implementation 2021-10-08 10:45:48 -07:00
writer.c reftable: signal overflow 2021-12-23 12:28:34 -08:00
writer.h reftable: write reftable files 2021-10-08 10:45:48 -07:00