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