1 /* 2 * Local definitions for the user allocation level 3 * 4 * Copyright 2020 by Gray Watson 5 * 6 * This file is part of the dmalloc package. 7 * 8 * Permission to use, copy, modify, and distribute this software for 9 * any purpose and without fee is hereby granted, provided that the 10 * above copyright notice and this permission notice appear in all 11 * copies, and that the name of Gray Watson not be used in advertising 12 * or publicity pertaining to distribution of the document or software 13 * without specific, written prior permission. 14 * 15 * Gray Watson makes no representations about the suitability of the 16 * software described herein for any purpose. It is provided "as is" 17 * without express or implied warranty. 18 * 19 * The author may be contacted via http://dmalloc.com/ 20 */ 21 22 #ifndef __DMALLOC_LOC_H__ 23 #define __DMALLOC_LOC_H__ 24 25 #include "conf.h" /* for HAVE_BCMP and BASIC_BLOCK */ 26 27 /* 28 * env variable(s) 29 */ 30 #define OPTIONS_ENVIRON "DMALLOC_OPTIONS" 31 32 /* 33 * web home directory 34 */ 35 #define DMALLOC_HOME "http://dmalloc.com/" 36 37 /* 38 * generic constants 39 */ 40 /* special consideration for NULL. some compilers bitch if I redefine it */ 41 #ifndef NULL 42 #define NULL 0L 43 #endif 44 45 /* 46 * standard i/o file descriptors 47 */ 48 #undef STDIN 49 #define STDIN 0 /* fileno(stdin) */ 50 51 #undef STDOUT 52 #define STDOUT 1 /* fileno(stdout) */ 53 54 #undef STDERR 55 #define STDERR 2 /* fileno(stderr) */ 56 57 /* 58 * Default values for the file and line variables. 59 */ 60 #define DMALLOC_DEFAULT_FILE 0L 61 #define DMALLOC_DEFAULT_LINE 0 62 63 /* 64 * Min/max macros 65 * 66 * WARNING: these use their arguments multiple times which may be bad 67 */ 68 #undef MAX 69 #define MAX(a,b) (((a) > (b)) ? (a) : (b)) 70 #undef MIN 71 #define MIN(a,b) (((a) < (b)) ? (a) : (b)) 72 73 /* 74 * bitflag tools for Variable and a Flag 75 */ 76 #undef BIT_FLAG 77 #define BIT_FLAG(x) (1 << (x)) 78 #undef BIT_SET 79 #define BIT_SET(v,f) (v) |= (f) 80 #undef BIT_CLEAR 81 #define BIT_CLEAR(v,f) (v) &= ~(f) 82 #undef BIT_IS_SET 83 #define BIT_IS_SET(v,f) ((v) & (f)) 84 85 /* 86 * set pointer macro 87 */ 88 #define SET_POINTER(pnt, val) \ 89 do { \ 90 if ((pnt) != NULL) { \ 91 (*(pnt)) = (val); \ 92 } \ 93 } while(0) 94 95 /* 96 * Global malloc defines 97 */ 98 #define BLOCK_SIZE (int)(1 << BASIC_BLOCK) /* size of a block */ 99 100 #endif /* ! __DMALLOC_LOC_H__ */ 101