De-export test-only helpers via JET_EXTERN / #ifdef JEMALLOC_JET; declare in unit tests, not headers

This commit is contained in:
Slobodan Predolac 2026-06-08 13:26:02 -07:00
parent 6db4d0c468
commit 4de3a4c3d1
46 changed files with 123 additions and 59 deletions

View file

@ -1,5 +1,7 @@
#include "test/jemalloc_test.h"
extern uint64_t prof_sample_new_event_wait(tsd_t *tsd);
/******************************************************************************/
/*

10
test/include/test/hpa.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef TEST_HPA_H
#define TEST_HPA_H
/*
* Static in production builds (JET_EXTERN); exported only for the unit tests
* that share it (hpa_central, psset).
*/
extern bool hpa_hugepage_size_exceeds_limit(void);
#endif /* TEST_HPA_H */

View file

@ -0,0 +1,10 @@
#ifndef TEST_HPDATA_H
#define TEST_HPDATA_H
/*
* Static in production builds (JET_EXTERN); exported only for the unit tests
* that share it (hpdata, psset).
*/
extern void *hpdata_reserve_alloc(hpdata_t *hpdata, size_t sz);
#endif /* TEST_HPDATA_H */

View file

@ -0,0 +1,12 @@
#ifndef TEST_PROF_DATA_H
#define TEST_PROF_DATA_H
/*
* Static in production builds (#ifdef JEMALLOC_JET); exported only for the unit
* tests that share them (prof_reset, prof_accum, prof_active, prof_tctx).
*/
extern size_t prof_tdata_count(void);
extern size_t prof_bt_count(void);
extern void prof_cnt_all(prof_cnt_t *cnt_all);
#endif /* TEST_PROF_DATA_H */

View file

@ -2,6 +2,8 @@
#include "test/extent_hooks.h"
extern ehooks_t *base_ehooks_get_for_metadata(base_t *base);
static extent_hooks_t hooks_null = {
extent_alloc_hook, NULL, /* dalloc */
NULL, /* destroy */

View file

@ -2,6 +2,15 @@
extern void bin_dalloc_locked_begin(
bin_dalloc_locked_info_t *info, szind_t binind);
extern void *bin_slab_reg_alloc(edata_t *slab, const bin_info_t *bin_info);
extern void bin_slabs_nonfull_insert(bin_t *bin, edata_t *slab);
extern void bin_slabs_nonfull_remove(bin_t *bin, edata_t *slab);
extern edata_t *bin_slabs_nonfull_tryget(bin_t *bin);
extern void bin_slabs_full_insert(bool is_auto, bin_t *bin, edata_t *slab);
extern void bin_dissociate_slab(bool is_auto, edata_t *slab, bin_t *bin);
extern void bin_lower_slab(
tsdn_t *tsdn, bool is_auto, edata_t *slab, bin_t *bin);
extern void bin_dalloc_slab_prepare(tsdn_t *tsdn, edata_t *slab, bin_t *bin);
#define INVALID_ARENA_IND ((1U << MALLOCX_ARENA_BITS) - 1)

View file

@ -2,6 +2,9 @@
#include "test/nbits.h"
extern void bitmap_info_init(bitmap_info_t *binfo, size_t nbits);
extern size_t bitmap_size(const bitmap_info_t *binfo);
static void
test_bitmap_initializer_body(const bitmap_info_t *binfo, size_t nbits) {
bitmap_info_t binfo_dyn;

View file

@ -2,6 +2,8 @@
#include "jemalloc/internal/buf_writer.h"
extern void buf_writer_flush(buf_writer_t *buf_writer);
#define TEST_BUF_SIZE 16
#define UNIT_MAX (TEST_BUF_SIZE * 3)

View file

@ -1,5 +1,10 @@
#include "test/jemalloc_test.h"
extern void ckh_string_hash(const void *key, size_t r_hash[2]);
extern bool ckh_string_keycomp(const void *k1, const void *k2);
extern void ckh_pointer_hash(const void *key, size_t r_hash[2]);
extern bool ckh_pointer_keycomp(const void *k1, const void *k2);
TEST_BEGIN(test_new_delete) {
tsd_t *tsd;
ckh_t ckh;

View file

@ -1,5 +1,7 @@
#include "test/jemalloc_test.h"
#include "test/hpa.h"
#include "jemalloc/internal/hpa.h"
#include "jemalloc/internal/hpa_central.h"

View file

@ -1,5 +1,7 @@
#include "test/jemalloc_test.h"
#include "test/hpdata.h"
#define HPDATA_ADDR ((void *)(10 * HUGEPAGE))
#define HPDATA_AGE 123

View file

@ -1,5 +1,8 @@
#include "test/jemalloc_test.h"
extern uint64_t nstime_ms(const nstime_t *time);
extern void nstime_isubtract(nstime_t *time, uint64_t subtrahend);
#define BILLION UINT64_C(1000000000)
TEST_BEGIN(test_nstime_init) {

View file

@ -1,5 +1,6 @@
#include "test/jemalloc_test.h"
#include "test/prof_data.h"
#include "jemalloc/internal/prof_data.h"
#include "jemalloc/internal/prof_sys.h"

View file

@ -1,5 +1,6 @@
#include "test/jemalloc_test.h"
#include "test/prof_data.h"
#include "jemalloc/internal/prof_data.h"
static void

View file

@ -1,6 +1,13 @@
#include "test/jemalloc_test.h"
#include "jemalloc/internal/prof_log.h"
extern size_t prof_log_bt_count(void);
extern size_t prof_log_alloc_count(void);
extern size_t prof_log_thr_count(void);
extern bool prof_log_is_logging(void);
extern bool prof_log_rep_check(void);
extern void prof_log_dummy_set(bool new_value);
#define N_PARAM 100
#define N_THREADS 10

View file

@ -2,6 +2,11 @@
#include "jemalloc/internal/prof_recent.h"
extern edata_t *prof_recent_alloc_edata_get_no_lock_test(
const prof_recent_t *node);
extern prof_recent_t *edata_prof_recent_alloc_get_no_lock_test(
const edata_t *edata);
/* As specified in the shell script */
#define OPT_ALLOC_MAX 3

View file

@ -1,5 +1,6 @@
#include "test/jemalloc_test.h"
#include "test/prof_data.h"
#include "jemalloc/internal/prof_data.h"
#include "jemalloc/internal/prof_sys.h"

View file

@ -1,5 +1,6 @@
#include "test/jemalloc_test.h"
#include "test/prof_data.h"
#include "jemalloc/internal/prof_data.h"
TEST_BEGIN(test_prof_realloc) {

View file

@ -1,5 +1,8 @@
#include "test/jemalloc_test.h"
#include "test/hpa.h"
#include "test/hpdata.h"
#include "jemalloc/internal/psset.h"
#define PAGESLAB_ADDR ((void *)(1234 * HUGEPAGE))

View file

@ -1,5 +1,7 @@
#include "test/jemalloc_test.h"
extern size_t reg_size_compute(int lg_base, int lg_delta, int ndelta);
TEST_BEGIN(test_sz_psz2ind) {
/*
* Testing page size classes which reside prior to the regular group