Pigweed
 
Loading...
Searching...
No Matches
config.h
1// Copyright 2024 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14#pragma once
15
16#include <cstdint>
17
18#include "pw_allocator/metrics.h"
19
20#ifndef PW_MALLOC_LOCK_TYPE
25#include "pw_allocator/synchronized_allocator.h"
26#define PW_MALLOC_LOCK_TYPE ::pw::allocator::NoSync
27#endif // PW_MALLOC_LOCK_TYPE
28
29#ifndef PW_MALLOC_METRICS_TYPE
33#include "pw_allocator/tracking_allocator.h"
34#define PW_MALLOC_METRICS_TYPE ::pw::allocator::NoMetrics
35
36#elif defined(PW_MALLOC_METRICS_INCLUDE)
37
39#include PW_MALLOC_METRICS_INCLUDE
40
41#endif // PW_MALLOC_METRICS_TYPE
42
43#ifndef PW_MALLOC_BLOCK_OFFSET_TYPE
51#define PW_MALLOC_BLOCK_OFFSET_TYPE uintptr_t
52#endif // PW_MALLOC_BLOCK_OFFSET_TYPE
53
54#ifndef PW_MALLOC_MIN_BUCKET_SIZE
61#define PW_MALLOC_MIN_BUCKET_SIZE 32
62#endif // PW_MALLOC_MIN_BUCKET_SIZE
63static_assert(((PW_MALLOC_MIN_BUCKET_SIZE - 1) & PW_MALLOC_MIN_BUCKET_SIZE) ==
64 0,
65 "PW_MALLOC_MIN_BUCKET_SIZE must be a power of two");
66
67#ifndef PW_MALLOC_NUM_BUCKETS
74#define PW_MALLOC_NUM_BUCKETS 5
75#endif // PW_MALLOC_NUM_BUCKETS
76
77#ifndef PW_MALLOC_DUAL_FIRST_FIT_THRESHOLD
84#define PW_MALLOC_DUAL_FIRST_FIT_THRESHOLD 2048
85#endif // PW_MALLOC_DUAL_FIRST_FIT_THRESHOLD