1 /* 2 * Copyright (C) 2009 iptelorg GmbH 3 * 4 * This file is part of Kamailio, a free SIP server. 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * \file 21 * \brief Helper definitions for internal memory manager 22 * 23 * Helper definitions for internal memory manager, defines for src location 24 * (function name, module a.s.o.), used for recording a *malloc()/ *free() 25 * caller. Expects MOD_NAME defined for modules (if it's not defined "core" 26 * will be assumed). 27 * 28 * Defines: 29 * - _SRC_FUNCTION_ - current function name 30 * - _SRC_FILENAME_ - current .c filename 31 * - _SRC_LINE_ - current line 32 * - _SRC_MODULE_ - module name, lib name or "<core>" (depends on MOD_NAME 33 * being properly set) 34 * - _SRC_LOC_ - module name + file name 35 * \ingroup mem 36 */ 37 38 39 #ifndef __src_loc_h 40 #define __src_loc_h 41 42 43 /* C >= 99 has __func__, older gcc versions have __FUNCTION__ */ 44 #ifndef _SRC_FUNCTION_ 45 # if __STDC_VERSION__ < 199901L 46 # if __GNUC__ >= 2 47 # define _SRC_FUNCTION_ __FUNCTION__ 48 # else 49 # define _SRC_FUNCTION_ "" 50 # endif 51 # else 52 # define _SRC_FUNCTION_ __func__ 53 # endif /* __STDC_VERSION_ < 199901L */ 54 #endif /* _FUNC_NAME_ */ 55 56 57 #ifndef _SRC_FILENAME_ 58 # define _SRC_FILENAME_ __FILE__ 59 #endif /* _SRC_FILENAME_ */ 60 61 62 #ifndef _SRC_LINE_ 63 # define _SRC_LINE_ __LINE__ 64 #endif /* _SRC_LINE_ */ 65 66 67 #ifndef _SRC_MODULE_ 68 # ifdef MOD_NAME 69 # define _SRC_MODULE_ MOD_NAME 70 # else 71 # define _SRC_MODULE_ "core" 72 # endif /* MOD_NAME */ 73 #endif /* _SRC_MODULE_ */ 74 75 76 #ifndef _SRC_LOC_ 77 # define _SRC_LOC_ _SRC_MODULE_ ": " _SRC_FILENAME_ 78 #endif /*_SRC_LOC_ */ 79 80 81 #endif /*__src_loc_h*/ 82 83 /* vi: set ts=4 sw=4 tw=79:ai:cindent: */ 84