1/*
2 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 *
4 *  Use of this source code is governed by a BSD-style license
5 *  that can be found in the LICENSE file in the root of the source
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10
11
12/* This code is in the public domain.
13** Version: 1.1  Author: Walt Karas
14*/
15
16/* Configure Heap Memory Manager for processor architecture, compiler,
17** and desired performance characteristics.  This file is included
18** by heapmm.h, so these definitions can be used by code external to
19** HMM.  You can change the default configuration, and/or create alternate
20** configuration(s).
21*/
22
23/* To allow for multiple configurations of HMM to be used in the same
24** compilation unit, undefine all preprocessor symbols that will be
25** defined below.
26*/
27#undef HMM_ADDR_ALIGN_UNIT
28#undef HMM_BLOCK_ALIGN_UNIT
29#undef HMM_UNIQUE
30#undef HMM_DESC_PARAM
31#undef HMM_SYM_TO_STRING
32#undef HMM_SYM_TO_STRING
33#undef HMM_AUDIT_FAIL
34
35/* Turn X into a string after one macro expansion pass of X.  This trick
36** works with both GCC and Visual C++. */
37#define HMM_SYM_TO_STRING(X) HMM_SYM_TO_STRING(X)
38#define HMM_SYM_TO_STRING(X) #X
39
40#ifndef HMM_CNFG_NUM
41
42/* Default configuration. */
43
44/* Use hmm_ prefix to avoid identifier conflicts. */
45#define HMM_UNIQUE(BASE) hmm_ ## BASE
46
47/* Number of bytes in an Address Alignment Unit (AAU). */
48//fwg
49//#define HMM_ADDR_ALIGN_UNIT sizeof(int)
50#define HMM_ADDR_ALIGN_UNIT 32
51
52/* Number of AAUs in a Block Alignment Unit (BAU). */
53#define HMM_BLOCK_ALIGN_UNIT 1
54
55/* Type of unsigned integer big enough to hold the size of a Block in AAUs. */
56typedef unsigned long HMM_UNIQUE(size_aau);
57
58/* Type of unsigned integer big enough to hold the size of a Block/Chunk
59** in BAUs.  The high bit will be robbed. */
60typedef unsigned long HMM_UNIQUE(size_bau);
61
62void hmm_dflt_abort(const char *, const char *);
63
64/* Actions upon a self-audit failure.  Must expand to a single complete
65** statement.  If you remove the definition of this macro, no self-auditing
66** will be performed. */
67#define HMM_AUDIT_FAIL \
68    hmm_dflt_abort(__FILE__, HMM_SYM_TO_STRING(__LINE__));
69
70#elif HMM_CNFG_NUM == 0
71
72/* Definitions for testing. */
73
74#define HMM_UNIQUE(BASE) thmm_ ## BASE
75
76#define HMM_ADDR_ALIGN_UNIT sizeof(int)
77
78#define HMM_BLOCK_ALIGN_UNIT 3
79
80typedef unsigned HMM_UNIQUE(size_aau);
81
82typedef unsigned short HMM_UNIQUE(size_bau);
83
84/* Under this test setup, a long jump is done if there is a self-audit
85** failure.
86*/
87
88extern jmp_buf HMM_UNIQUE(jmp_buf);
89extern const char *HMM_UNIQUE(fail_file);
90extern unsigned HMM_UNIQUE(fail_line);
91
92#define HMM_AUDIT_FAIL \
93    { HMM_UNIQUE(fail_file) = __FILE__; HMM_UNIQUE(fail_line) = __LINE__; \
94        longjmp(HMM_UNIQUE(jmp_buf), 1); }
95
96#elif HMM_CNFG_NUM == 1
97
98/* Put configuration 1 definitions here (if there is a configuration 1). */
99
100#elif HMM_CNFG_NUM == 2
101
102/* Put configuration 2 definitions here. */
103
104#elif HMM_CNFG_NUM == 3
105
106/* Put configuration 3 definitions here. */
107
108#elif HMM_CNFG_NUM == 4
109
110/* Put configuration 4 definitions here. */
111
112#elif HMM_CNFG_NUM == 5
113
114/* Put configuration 5 definitions here. */
115
116#endif
117