2018-11-16 21:25:35 +01:00
|
|
|
#include <stdbool.h>
|
2018-08-26 09:15:13 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2020-06-17 22:26:01 +02:00
|
|
|
static size_t size_classes[] = {
|
2018-08-26 09:15:13 +02:00
|
|
|
/* large */ 4 * 1024 * 1024,
|
|
|
|
/* 0 */ 0,
|
|
|
|
/* 16 */ 16, 32, 48, 64, 80, 96, 112, 128,
|
|
|
|
/* 32 */ 160, 192, 224, 256,
|
|
|
|
/* 64 */ 320, 384, 448, 512,
|
|
|
|
/* 128 */ 640, 768, 896, 1024,
|
|
|
|
/* 256 */ 1280, 1536, 1792, 2048,
|
|
|
|
/* 512 */ 2560, 3072, 3584, 4096,
|
|
|
|
/* 1024 */ 5120, 6144, 7168, 8192,
|
2019-06-18 21:51:13 +02:00
|
|
|
/* 2048 */ 10240, 12288, 14336, 16384,
|
|
|
|
#if CONFIG_EXTENDED_SIZE_CLASSES
|
|
|
|
/* 4096 */ 20480, 24576, 28672, 32768,
|
|
|
|
/* 8192 */ 40960, 49152, 57344, 65536,
|
|
|
|
/* 16384 */ 81920, 98304, 114688, 131072,
|
|
|
|
#endif
|
2018-08-26 09:15:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#define N_SIZE_CLASSES (sizeof(size_classes) / sizeof(size_classes[0]))
|
|
|
|
|
2018-10-19 22:17:38 +02:00
|
|
|
static const size_t canary_size = SLAB_CANARY ? sizeof(uint64_t) : 0;
|
2018-10-04 08:52:20 +02:00
|
|
|
|
2018-08-26 09:15:13 +02:00
|
|
|
int main(void) {
|
2018-10-19 22:17:38 +02:00
|
|
|
for (unsigned i = 2; i < N_SIZE_CLASSES; i++) {
|
|
|
|
size_classes[i] -= canary_size;
|
|
|
|
}
|
|
|
|
|
2018-08-26 09:15:13 +02:00
|
|
|
void *p[N_SIZE_CLASSES];
|
|
|
|
for (unsigned i = 0; i < N_SIZE_CLASSES; i++) {
|
2020-06-17 22:26:01 +02:00
|
|
|
size_t size = size_classes[i];
|
2018-08-26 09:15:13 +02:00
|
|
|
p[i] = malloc(size);
|
2020-06-17 22:27:59 +02:00
|
|
|
if (!p[i]) {
|
2018-08-26 09:15:13 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
void *q = malloc(size);
|
|
|
|
if (!q) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (i != 0) {
|
2018-10-04 08:40:51 +02:00
|
|
|
printf("%zu to %zu: %zd\n", size_classes[i - 1], size, p[i] - p[i - 1]);
|
2018-08-26 09:15:13 +02:00
|
|
|
}
|
2018-08-26 10:51:38 +02:00
|
|
|
printf("%zu to %zu: %zd\n", size, size, q - p[i]);
|
2018-08-26 09:15:13 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|