mergesort: add macros for typed sort of linked lists
commit318051eaeb1dbbd2acea1c0dcf9f4e8e8ef5d3a9
authorRené Scharfe <l.s.r@web.de>
Sat, 16 Jul 2022 16:54:51 +0000 (16 18:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 17 Jul 2022 22:20:38 +0000 (17 15:20 -0700)
treeded414dc0cc086ca0031f3fd44cf2af769ba7df0
parent848afebe5604877354bea42d81df380cff03b948
mergesort: add macros for typed sort of linked lists

Add the macros DECLARE_LIST_SORT and DEFINE_LIST_SORT for building
type-specific functions for sorting linked lists.  The generated
function expects a typed comparison function.

The programmer provides full type information (no void pointers).  This
allows the compiler to check whether the comparison function matches the
list type.  It can also inline the "next" pointer accessor functions and
even the comparison function to get rid of the calling overhead.

Also provide a DECLARE_LIST_SORT_DEBUG macro that allows executing
custom code whenever the accessor functions are used.  It's intended to
be used by test-mergesort, which counts these operations.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mergesort.h