diff --git a/Knot.files b/Knot.files index 78981fcfbff8e5e93aefd11c1980d6ef390d2d86..a49f32f4ed6c6ece2df80852c77176a1b4351f3f 100644 --- a/Knot.files +++ b/Knot.files @@ -31,6 +31,12 @@ libtap/tap/float.h libtap/tap/macros.h samples/Makefile.am src/Makefile.am +src/contrib/ucw/array-sort.h +src/contrib/ucw/binsearch.h +src/contrib/ucw/heap.c +src/contrib/ucw/heap.h +src/contrib/ucw/mempool.c +src/contrib/ucw/mempool.h src/dnssec/Makefile.am src/dnssec/contrib/gnutls_error.c src/dnssec/lib/binary.c @@ -335,20 +341,16 @@ src/libknot/dnssec/rrset-sign.c src/libknot/dnssec/rrset-sign.h src/libknot/errcode.c src/libknot/errcode.h -src/libknot/internal/array-sort.h src/libknot/internal/base32hex.c src/libknot/internal/base32hex.h src/libknot/internal/base64.c src/libknot/internal/base64.h -src/libknot/internal/binsearch.h src/libknot/internal/consts.h src/libknot/internal/endian.h src/libknot/internal/errcode.c src/libknot/internal/errcode.h src/libknot/internal/getline.c src/libknot/internal/getline.h -src/libknot/internal/heap.c -src/libknot/internal/heap.h src/libknot/internal/hhash.c src/libknot/internal/hhash.h src/libknot/internal/lists.c @@ -358,8 +360,6 @@ src/libknot/internal/mem.c src/libknot/internal/mem.h src/libknot/internal/mempattern.c src/libknot/internal/mempattern.h -src/libknot/internal/mempool.c -src/libknot/internal/mempool.h src/libknot/internal/namedb/lmdb.h src/libknot/internal/namedb/mdb.c src/libknot/internal/namedb/midl.c @@ -412,6 +412,7 @@ src/libknot/rrset.c src/libknot/rrset.h src/libknot/rrtype/aaaa.h src/libknot/rrtype/dnskey.h +src/libknot/rrtype/naptr.c src/libknot/rrtype/naptr.h src/libknot/rrtype/nsec.h src/libknot/rrtype/nsec3.c @@ -496,6 +497,7 @@ src/zscanner/tests/tests.h src/zscanner/tests/zscanner-tool.c tests-fuzz/Makefile.am tests-fuzz/packet.c +tests-fuzz/packet_libfuzzer.c tests-fuzz/wrap/server.c tests-fuzz/wrap/tcp-handler.c tests-fuzz/wrap/udp-handler.c diff --git a/Knot.includes b/Knot.includes index 93181e1cdec4f1129465949d68a4429a2b5d17a6..9d34de5639b1d0d8ba7d8a6d65d8d7b054228077 100644 --- a/Knot.includes +++ b/Knot.includes @@ -1,9 +1,11 @@ libtap src +src/contrib src/dnssec/lib src/dnssec/lib/dnssec src/dnssec/shared src/dnssec/utils src/zscanner tests -tests-fuzz \ No newline at end of file +tests-fuzz +tests-fuzz/wrap diff --git a/src/Makefile.am b/src/Makefile.am index 341401bf56825b1e37835642dc652d861bba329d..094e60107e367af22abad4c83a9a151d86abc9b8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,6 +4,7 @@ SUBDIRS = zscanner dnssec dnstap . lib_LTLIBRARIES = \ libknot.la noinst_LTLIBRARIES = \ + libcontrib.la \ libknot-internal.la \ libknot-yparser.la @@ -21,6 +22,13 @@ AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) # Knot DNS Libraries # ###################### +libcontrib_ladir = $(includedir) +nobase_libcontrib_la_HEADERS = \ + contrib/ucw/array-sort.h \ + contrib/ucw/binsearch.h \ + contrib/ucw/heap.h \ + contrib/ucw/mempool.h + # dynamic: libknot headers libknot_ladir = $(includedir) nobase_libknot_la_HEADERS = \ @@ -59,21 +67,17 @@ nobase_libknot_la_HEADERS = \ libknot_internal_ladir = $(includedir) nobase_libknot_internal_la_HEADERS = \ - libknot/internal/array-sort.h \ libknot/internal/base32hex.h \ libknot/internal/base64.h \ - libknot/internal/binsearch.h \ libknot/internal/consts.h \ libknot/internal/endian.h \ libknot/internal/errcode.h \ libknot/internal/getline.h \ - libknot/internal/heap.h \ libknot/internal/hhash.h \ libknot/internal/lists.h \ libknot/internal/macros.h \ libknot/internal/mem.h \ libknot/internal/mempattern.h \ - libknot/internal/mempool.h \ libknot/internal/namedb/namedb.h \ libknot/internal/namedb/namedb_lmdb.h \ libknot/internal/namedb/namedb_trie.h \ @@ -96,6 +100,11 @@ nobase_libknot_yparser_la_HEADERS = \ libknot/yparser/yptrafo.h # dynamic: libknot sources +libcontrib_la_SOURCES = \ + contrib/ucw/heap.c \ + contrib/ucw/mempool.c \ + $(nobase_libcontrib_la_HEADERS) + libknot_la_SOURCES = \ libknot/binary.c \ libknot/consts.c \ @@ -135,12 +144,10 @@ libknot_internal_la_SOURCES = \ libknot/internal/base64.c \ libknot/internal/errcode.c \ libknot/internal/getline.c \ - libknot/internal/heap.c \ libknot/internal/hhash.c \ libknot/internal/lists.c \ libknot/internal/mem.c \ libknot/internal/mempattern.c \ - libknot/internal/mempool.c \ libknot/internal/namedb/namedb_lmdb.c \ libknot/internal/namedb/namedb_trie.c \ libknot/internal/net.c \ @@ -154,13 +161,16 @@ libknot_internal_la_SOURCES = \ libknot/internal/utils.c \ $(nobase_libknot_internal_la_HEADERS) +libcontrib_la_CPPFLAGS = $(AM_CPPFLAGS) +libcontrib_la_CFLAGS = $(AM_CFLAGS) + libknot_internal_la_CPPFLAGS = $(AM_CPPFLAGS) $(lmdb_CFLAGS) libknot_internal_la_CFLAGS = $(AM_CFLAGS) libknot_la_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAG_VISIBILITY) $(lmdb_CFLAGS) libknot_la_CFLAGS = $(AM_CFLAGS) libknot_la_LDFLAGS = $(AM_LDFLAGS) $(libknot_VERSION_INFO) $(lmdb_LIBS) -libknot_la_LIBADD = dnssec/libdnssec.la libknot-internal.la +libknot_la_LIBADD = dnssec/libdnssec.la libcontrib.la libknot-internal.la # pkg-config pkgconfig_DATA = libknot.pc @@ -352,7 +362,7 @@ libknotd_la_LIBADD = libknot.la libknot-yparser.la zscanner/libzscanner.la $(lib knotd_CPPFLAGS = $(AM_CPPFLAGS) $(liburcu_CFLAGS) knotd_LDADD = libknotd.la $(liburcu_LIBS) knotc_LDADD = libknotd.la -knot1to2_LDADD = libknot-internal.la +knot1to2_LDADD = libknot-internal.la libcontrib.la #################################### # Optional Knot DNS Daemon modules # @@ -434,7 +444,7 @@ libknotus_la_SOURCES = \ libknotus_la_CPPFLAGS = $(AM_CPPFLAGS) $(libidn_CFLAGS) libknotus_la_LDFLAGS = $(AM_LDFLAGS) $(libidn_LIBS) -libknotus_la_LIBADD = libknot.la +libknotus_la_LIBADD = libcontrib.la libknot.la # bin programs kdig_LDADD = $(libidn_LIBS) libknotus.la diff --git a/src/libknot/internal/array-sort.h b/src/contrib/ucw/array-sort.h similarity index 93% rename from src/libknot/internal/array-sort.h rename to src/contrib/ucw/array-sort.h index b578e06ab03793b2cb768fce5dbb11bf9fb63622..c2c3ec4d6745d9528f42123b63a5c6c8c3c012d9 100644 --- a/src/libknot/internal/array-sort.h +++ b/src/contrib/ucw/array-sort.h @@ -7,6 +7,10 @@ * of the GNU Lesser General Public License. */ +#pragma once + +#include "libknot/internal/macros.h" + /* * This is not a normal header file, it's a generator of sorting * routines. Each time you include it with parameters set in the @@ -27,25 +31,19 @@ * ASORT_KEY_TYPE [*] data type of a single array entry key * ASORT_ELT(i) returns the key of i-th element; if this macro is not * defined, the function gets a pointer to an array to be sorted - * ASORT_LT(x,y) x < y for ASORT_TYPE (default: "x<y") + * ASORT_LT(x,y) x < y for ASORT_KEY_TYPE (default: "x<y") * ASORT_SWAP(i,j) swap i-th and j-th element (default: assume _ELT * is an l-value and swap just the keys) * ASORT_THRESHOLD threshold for switching between quicksort and insertsort * ASORT_EXTRA_ARGS extra arguments for the sort function (they are always * visible in all the macros supplied above), starts with comma * - * After including this file, a function ASORT_PREFIX(sort)(uns array_size) - * or ASORT_PREFIX(sort)(ASORT_KEY_TYPE *array, uns array_size) [if ASORT_ELT + * After including this file, a function ASORT_PREFIX(sort)(unsigned array_size) + * or ASORT_PREFIX(sort)(ASORT_KEY_TYPE *array, unsigned array_size) [if ASORT_ELT * is not defined] is declared and all parameter macros are automatically * undef'd. */ -#pragma once - -#include "libknot/internal/macros.h" - -typedef unsigned uns; - #ifndef ASORT_LT #define ASORT_LT(x,y) ((x) < (y)) #endif @@ -75,11 +73,11 @@ typedef unsigned uns; * sorted. If the macro is provided, this parameter is omitted. In that case, * you can sort global variables or pass your structure by @ASORT_EXTRA_ARGS. **/ -static void ASORT_PREFIX(sort)(ASORT_ARRAY_ARG uns array_size ASORT_EXTRA_ARGS) +static void ASORT_PREFIX(sort)(ASORT_ARRAY_ARG unsigned array_size ASORT_EXTRA_ARGS) { - struct stk { int l, r; } stack[8*sizeof(uns)]; + struct stk { int l, r; } stack[8*sizeof(unsigned)]; int l, r, left, right, m; - uns sp = 0; + unsigned sp = 0; ASORT_KEY_TYPE pivot; if (array_size <= 1) diff --git a/src/libknot/internal/binsearch.h b/src/contrib/ucw/binsearch.h similarity index 95% rename from src/libknot/internal/binsearch.h rename to src/contrib/ucw/binsearch.h index 2117921c31b789c4ca655fd8b1003e02ef2f7e68..dffcd1f996e738c159eda39e0c723022d54da84b 100644 --- a/src/libknot/internal/binsearch.h +++ b/src/contrib/ucw/binsearch.h @@ -21,10 +21,10 @@ * The time complexity is `O(log(N))`. **/ #define BIN_SEARCH_FIRST_GE_CMP(ary, N, ary_lt_x, x, ...) ({ \ - uns l = 0, r = (N); \ + unsigned l = 0, r = (N); \ while (l < r) \ { \ - uns m = (l+r)/2; \ + unsigned m = (l+r)/2; \ if (ary_lt_x(ary, m, x, __VA_ARGS__)) \ l = m+1; \ else \ diff --git a/src/libknot/internal/heap.c b/src/contrib/ucw/heap.c similarity index 96% rename from src/libknot/internal/heap.c rename to src/contrib/ucw/heap.c index 3565921b6770d202ea43d1ba76de3002e496fc43..5ffb770cdb74fc63110764b345ef46f84a58bbbd 100644 --- a/src/libknot/internal/heap.c +++ b/src/contrib/ucw/heap.c @@ -1,5 +1,5 @@ /* - * Universal Heap Macros + * Binary heap * * (c) 2012 Ondrej Filip <feela@network.cz> * @@ -8,7 +8,6 @@ */ /*** - * [[intro]] * Introduction * ------------ * @@ -31,17 +30,11 @@ * - `heap[i] >= heap[i / 2]` for each `i` in `[2, num]` * * The first element `heap[1]` is always lower or equal to all other elements. - * - * [[macros]] - * Macros - * ------ ***/ - -#include "libknot/internal/macros.h" -#include "libknot/internal/heap.h" #include <string.h> #include <stdlib.h> +#include "contrib/ucw/heap.h" static inline void heap_swap(heap_val_t *e1, heap_val_t *e2) { diff --git a/src/libknot/internal/heap.h b/src/contrib/ucw/heap.h similarity index 70% rename from src/libknot/internal/heap.h rename to src/contrib/ucw/heap.h index 73f665c4a7bce689c9e9a4506e7175967ef333ea..af4882b950bee436283a6beb9b4fb1834d32de19 100644 --- a/src/libknot/internal/heap.h +++ b/src/contrib/ucw/heap.h @@ -13,17 +13,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/*! - * \file heap.h - * - * \author Ondrej Filip <ondrej.filip@nic.cz> - * - * \brief Universal heap support - * - * - * \addtogroup common_lib - * @{ - */ #pragma once @@ -36,12 +25,12 @@ struct heap { heap_val_t *data; }; /* Array follows */ -#define INITIAL_HEAP_SIZE 512 /* initial heap size */ -#define HEAP_INCREASE_STEP 2 /* multiplier for each inflation, keep conservative */ -#define HEAP_DECREASE_THRESHOLD 2 /* threshold for deflation, keep conservative */ -#define HELEMENT(h,num) ((h)->data + (num)) -#define HHEAD(h) HELEMENT((h),1) -#define EMPTY_HEAP(h) ((h)->num == 0) /* h->num == 0 */ +#define INITIAL_HEAP_SIZE 512 /* initial heap size */ +#define HEAP_INCREASE_STEP 2 /* multiplier for each inflation, keep conservative */ +#define HEAP_DECREASE_THRESHOLD 2 /* threshold for deflation, keep conservative */ +#define HELEMENT(h,num) ((h)->data + (num)) +#define HHEAD(h) HELEMENT((h), 1) +#define EMPTY_HEAP(h) ((h)->num == 0) /* h->num == 0 */ int heap_init(struct heap *, int (*cmp)(), int); void heap_delmin(struct heap *); @@ -49,6 +38,3 @@ int heap_insert(struct heap *, void *); int heap_find(struct heap *, void *); void heap_delete(struct heap *, int); void heap_replace(struct heap *h, int pos, void *e); - - -/*! @} */ diff --git a/src/libknot/internal/mempool.c b/src/contrib/ucw/mempool.c similarity index 98% rename from src/libknot/internal/mempool.c rename to src/contrib/ucw/mempool.c index 15007e0b1f62feafac13e170898f58c2b0acb699..9a0e7762c1f23b2c72a3f836fdd5566ec6c5d3a3 100644 --- a/src/libknot/internal/mempool.c +++ b/src/contrib/ucw/mempool.c @@ -10,12 +10,12 @@ #undef LOCAL_DEBUG -#include "libknot/internal/mempool.h" - #include <string.h> #include <stdlib.h> #include <stdio.h> #include <assert.h> +#include "libknot/internal/macros.h" +#include "contrib/ucw/mempool.h" /** \todo This shouldn't be precalculated, but computed on load. */ #define CPU_PAGE_SIZE 4096 @@ -24,10 +24,6 @@ #define ALIGN_TO(s, a) (((s)+a-1)&~(a-1)) #define MP_CHUNK_TAIL ALIGN_TO(sizeof(struct mempool_chunk), CPU_STRUCT_ALIGN) #define MP_SIZE_MAX (~0U - MP_CHUNK_TAIL - CPU_PAGE_SIZE) -#ifndef MAX -#define MAX(a, b) \ - ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; }) -#endif #define DBG(s, ...) /** \note Imported MMAP backend from bigalloc.c */ diff --git a/src/libknot/internal/mempool.h b/src/contrib/ucw/mempool.h similarity index 100% rename from src/libknot/internal/mempool.h rename to src/contrib/ucw/mempool.h diff --git a/src/knot/common/evsched.h b/src/knot/common/evsched.h index 1ee14149f74578b62bcb6fd6106ee22b28403074..2168326f278395aa972efdddd64573e8b4ce3136 100644 --- a/src/knot/common/evsched.h +++ b/src/knot/common/evsched.h @@ -31,8 +31,8 @@ #include <stdint.h> #include <sys/time.h> -#include "libknot/internal/heap.h" #include "knot/server/dthreads.h" +#include "contrib/ucw/heap.h" /* Forward decls. */ struct evsched; diff --git a/src/knot/conf/base.c b/src/knot/conf/base.c index 46b09a60904250bfed11ab355006444c06db7141..8afdf6e86f5b76d81db43529d3c8124f321a2864 100644 --- a/src/knot/conf/base.c +++ b/src/knot/conf/base.c @@ -30,7 +30,7 @@ #include "libknot/internal/sockaddr.h" #include "libknot/yparser/ypformat.h" #include "libknot/yparser/yptrafo.h" -#include "libknot/internal/mempool.h" +#include "contrib/ucw/mempool.h" // The active configuration. conf_t *s_conf; diff --git a/src/knot/server/tcp-handler.c b/src/knot/server/tcp-handler.c index 416ae76b353fe064bc5de365d6a5ac6d5cc1fdce..6c5374e38d39766643e916fa160fa2b29d398aaa 100644 --- a/src/knot/server/tcp-handler.c +++ b/src/knot/server/tcp-handler.c @@ -38,11 +38,11 @@ #include "knot/common/log.h" #include "knot/common/time.h" #include "knot/nameserver/process_query.h" -#include "libknot/internal/mempool.h" #include "libknot/internal/macros.h" #include "libknot/internal/net.h" #include "libknot/internal/sockaddr.h" #include "libknot/processing/overlay.h" +#include "contrib/ucw/mempool.h" /*! \brief TCP context data. */ typedef struct tcp_context { diff --git a/src/knot/server/udp-handler.c b/src/knot/server/udp-handler.c index f668e90f72586431379c1b46aa49c4ca50c349d0..eb0ef045b678480b00b0c18ce73ce82eaa6674f3 100644 --- a/src/knot/server/udp-handler.c +++ b/src/knot/server/udp-handler.c @@ -39,10 +39,10 @@ #include "knot/server/server.h" #include "libknot/internal/sockaddr.h" #include "libknot/internal/mempattern.h" -#include "libknot/internal/mempool.h" #include "libknot/internal/macros.h" #include "libknot/libknot.h" #include "libknot/processing/overlay.h" +#include "contrib/ucw/mempool.h" /* Buffer identifiers. */ enum { diff --git a/src/knot/updates/zone-update.c b/src/knot/updates/zone-update.c index bd19fbc7ab6d73ac57fec8bcf8ae4d6f821d5054..e74214855055cad9976ef9f6a09d554460519390 100644 --- a/src/knot/updates/zone-update.c +++ b/src/knot/updates/zone-update.c @@ -22,7 +22,7 @@ #include "knot/zone/serial.h" #include "libknot/internal/lists.h" -#include "libknot/internal/mempool.h" +#include "contrib/ucw/mempool.h" static int add_to_node(zone_node_t *node, const zone_node_t *add_node, mm_ctx_t *mm) diff --git a/src/knot/zone/events/handlers.c b/src/knot/zone/events/handlers.c index 76220bd094bec7ecfc129a954bb911c01787cf6d..6066027b43d3827ad8bcc5861ebc435dfb0a8a13 100644 --- a/src/knot/zone/events/handlers.c +++ b/src/knot/zone/events/handlers.c @@ -18,10 +18,10 @@ #include "dnssec/random.h" #include "libknot/libknot.h" -#include "libknot/internal/mempool.h" #include "libknot/internal/macros.h" #include "libknot/processing/requestor.h" #include "libknot/yparser/yptrafo.h" +#include "contrib/ucw/mempool.h" #include "knot/common/log.h" #include "knot/common/trim.h" diff --git a/src/knot/zone/zonedb.c b/src/knot/zone/zonedb.c index ce07724d2c4a2b223cc5a5e1311111e71281ae14..cf48cee94ac796fd5aeb333871674a4a192c9f33 100644 --- a/src/knot/zone/zonedb.c +++ b/src/knot/zone/zonedb.c @@ -27,8 +27,8 @@ #include "libknot/packet/wire.h" #include "knot/zone/node.h" #include "libknot/internal/mempattern.h" -#include "libknot/internal/mempool.h" #include "libknot/internal/macros.h" +#include "contrib/ucw/mempool.h" /*----------------------------------------------------------------------------*/ /* Non-API functions */ diff --git a/src/libknot/internal/hhash.c b/src/libknot/internal/hhash.c index cf349e68043f09d1da5c3a600f5edd3461a30099..ae297caa7a6e10ac4adb39932fa01e722ace150d 100644 --- a/src/libknot/internal/hhash.c +++ b/src/libknot/internal/hhash.c @@ -4,7 +4,6 @@ #include "libknot/internal/macros.h" #include "libknot/internal/hhash.h" -#include "libknot/internal/binsearch.h" #include "libknot/internal/trie/murmurhash3.h" #include "libknot/internal/errcode.h" @@ -14,7 +13,8 @@ static int universal_cmp(uint32_t k1, uint32_t k2, hhash_t *tbl); #define ASORT_KEY_TYPE uint32_t #define ASORT_LT(x, y) (universal_cmp((x), (y), tbl) < 0) #define ASORT_EXTRA_ARGS , hhash_t *tbl -#include "libknot/internal/array-sort.h" +#include "contrib/ucw/array-sort.h" +#include "contrib/ucw/binsearch.h" /* Hopscotch internal defines. */ #define HOP_NEXT(x) __builtin_ctz((x)) diff --git a/src/libknot/internal/mempattern.c b/src/libknot/internal/mempattern.c index b48c62cd9672af294b2bd396f1e0c181b607eb07..f9067bf72f145d011b723fb956b21b297362dfdf 100644 --- a/src/libknot/internal/mempattern.c +++ b/src/libknot/internal/mempattern.c @@ -18,7 +18,7 @@ #include "libknot/internal/macros.h" #include "libknot/internal/mempattern.h" -#include "libknot/internal/mempool.h" +#include "contrib/ucw/mempool.h" static void mm_nofree(void *p) { diff --git a/src/utils/knsupdate/knsupdate_params.c b/src/utils/knsupdate/knsupdate_params.c index 68b18e6aab7503cb1f0520439062e0bdb011400f..a873f6644b7be5271eb28616ce129f0464ff1913 100644 --- a/src/utils/knsupdate/knsupdate_params.c +++ b/src/utils/knsupdate/knsupdate_params.c @@ -25,8 +25,8 @@ #include "utils/common/netio.h" #include "libknot/libknot.h" #include "libknot/internal/mempattern.h" -#include "libknot/internal/mempool.h" #include "libknot/tsig.h" +#include "contrib/ucw/mempool.h" #define DEFAULT_RETRIES_NSUPDATE 3 #define DEFAULT_TIMEOUT_NSUPDATE 12 diff --git a/tests/hattrie.c b/tests/hattrie.c index 7b3f04ea7251919dba87a6f811199e41b5226da9..8f80ab31836bbbab14b8f61704a2de56eb1bad31 100644 --- a/tests/hattrie.c +++ b/tests/hattrie.c @@ -19,8 +19,15 @@ #include <tap/basic.h> #include "libknot/internal/trie/hat-trie.h" +#include "libknot/internal/macros.h" #include "libknot/internal/mem.h" +/* UCW array sorting defines. */ +#define ASORT_PREFIX(X) str_key_##X +#define ASORT_KEY_TYPE char* +#define ASORT_LT(x, y) (strcmp((x), (y)) < 0) +#include "contrib/ucw/array-sort.h" + /* Constants. */ #define KEY_MAXLEN 64 @@ -93,12 +100,6 @@ static bool str_key_find_leq(hattrie_t *trie, char **keys, size_t i, size_t size } -/* UCW array sorting defines. */ -#define ASORT_PREFIX(X) str_key_##X -#define ASORT_KEY_TYPE char* -#define ASORT_LT(x, y) (strcmp((x), (y)) < 0) -#include "libknot/internal/array-sort.h" - int main(int argc, char *argv[]) { plan_lazy(); diff --git a/tests/hhash.c b/tests/hhash.c index 5c46801073bec6438564bee8d0ed1270f3cf58c7..89d73d9e4517292ae4ef1c51de422ea05a0b66a2 100644 --- a/tests/hhash.c +++ b/tests/hhash.c @@ -20,9 +20,9 @@ #include "libknot/internal/hhash.h" #include "libknot/internal/mempattern.h" -#include "libknot/internal/mempool.h" #include "libknot/internal/macros.h" #include "libknot/libknot.h" +#include "contrib/ucw/mempool.h" /* Test defines. */ #define ELEM_COUNT 65535 diff --git a/tests/namedb.c b/tests/namedb.c index 65d0ee24510dbcc9daadc7fc0672daab5e889500..1dbb4ca894c2425f623c869e2ea0448370e8519f 100644 --- a/tests/namedb.c +++ b/tests/namedb.c @@ -23,12 +23,18 @@ #include <assert.h> #include <tap/basic.h> -#include "libknot/internal/mempool.h" #include "libknot/internal/mem.h" #include "libknot/internal/namedb/namedb_lmdb.h" #include "libknot/internal/namedb/namedb_trie.h" #include "libknot/internal/strlcpy.h" #include "libknot/libknot.h" +#include "contrib/ucw/mempool.h" + +/* UCW array sorting defines. */ +#define ASORT_PREFIX(X) str_key_##X +#define ASORT_KEY_TYPE char* +#define ASORT_LT(x, y) (strcmp((x), (y)) < 0) +#include "contrib/ucw/array-sort.h" /* Constants. */ #define KEY_MAXLEN 64 @@ -46,12 +52,6 @@ static char *str_key_rand(size_t len, mm_ctx_t *pool) return s; } -/* UCW array sorting defines. */ -#define ASORT_PREFIX(X) str_key_##X -#define ASORT_KEY_TYPE char* -#define ASORT_LT(x, y) (strcmp((x), (y)) < 0) -#include "libknot/internal/array-sort.h" - static void namedb_test_set(unsigned nkeys, char **keys, void *opts, const namedb_api_t *api, mm_ctx_t *pool) { diff --git a/tests/overlay.c b/tests/overlay.c index 4550811e3eb6e65c838990c998041bfa9fffb10e..ae4ffba3070a7977b3b9ec7fddfdeac511989565 100644 --- a/tests/overlay.c +++ b/tests/overlay.c @@ -18,8 +18,8 @@ #include <string.h> #include <stdlib.h> -#include "libknot/internal/mempool.h" #include "libknot/processing/overlay.h" +#include "contrib/ucw/mempool.h" /* @note Purpose of this test is to verify, that FSM chaining works. */ diff --git a/tests/pkt.c b/tests/pkt.c index c1ec3b1538919f0b9c62ad93a8c729628038798f..ad6d30fb7eb7e4e321522257e44609a432e0ba66 100644 --- a/tests/pkt.c +++ b/tests/pkt.c @@ -17,11 +17,11 @@ #include <tap/basic.h> #include "libknot/libknot.h" -#include "libknot/internal/mempool.h" #include "libknot/descriptor.h" #include "libknot/libknot.h" #include "libknot/packet/pkt.h" #include "libknot/rrtype/tsig.h" +#include "contrib/ucw/mempool.h" #define TTL 7200 #define NAMECOUNT 3 diff --git a/tests/process_answer.c b/tests/process_answer.c index c3534704973185009ced2578ceb7b98e9e59757e..063b72abbfc091bba7d67cb26d666522b97f27d8 100644 --- a/tests/process_answer.c +++ b/tests/process_answer.c @@ -18,11 +18,11 @@ #include <string.h> #include <stdlib.h> -#include "libknot/internal/mempool.h" #include "libknot/descriptor.h" #include "libknot/packet/wire.h" #include "knot/nameserver/process_answer.h" #include "fake_server.h" +#include "contrib/ucw/mempool.h" /* @note Test helpers. */ #define TEST_RESET() \ diff --git a/tests/process_query.c b/tests/process_query.c index 8c2bda070d0ca96df6d6b2001a53266d9956f591..7dba613a531caffaec5dc7fd5a0175bbaeb6365f 100644 --- a/tests/process_query.c +++ b/tests/process_query.c @@ -18,11 +18,11 @@ #include <string.h> #include <stdlib.h> -#include "libknot/internal/mempool.h" #include "libknot/descriptor.h" #include "libknot/packet/wire.h" #include "knot/nameserver/process_query.h" #include "fake_server.h" +#include "contrib/ucw/mempool.h" /* Basic response check (4 TAP tests). */ static void answer_sanity_check(const uint8_t *query, diff --git a/tests/query_module.c b/tests/query_module.c index 3aae9ff35ef8b3925355b9c3a9ea6bfeb7edf0dc..334cc474da4a94134a3f816c3f5dd024072940ea 100644 --- a/tests/query_module.c +++ b/tests/query_module.c @@ -19,10 +19,10 @@ #include <stdlib.h> #include "libknot/internal/mempattern.h" -#include "libknot/internal/mempool.h" #include "libknot/libknot.h" #include "knot/nameserver/query_module.h" #include "libknot/packet/pkt.h" +#include "contrib/ucw/mempool.h" /* Universal processing stage. */ int state_visit(int state, knot_pkt_t *pkt, struct query_data *qdata, void *ctx) diff --git a/tests/requestor.c b/tests/requestor.c index 8858819529cd3fa9d0622aed687880da3663e603..a1eb50643bc4fec2679a5cef4b2dcfa43265772f 100644 --- a/tests/requestor.c +++ b/tests/requestor.c @@ -21,10 +21,10 @@ #include <fcntl.h> #include "knot/conf/conf.h" -#include "libknot/internal/mempool.h" #include "libknot/internal/net.h" #include "libknot/processing/layer.h" #include "libknot/processing/requestor.h" +#include "contrib/ucw/mempool.h" /* @note Purpose of this test is not to verify process_answer functionality, * but simply if the requesting/receiving works, so mirror is okay. */