main_util.h revision e739ac0589b4fb43561f801c4faba8c1b89f8680
1 2/*---------------------------------------------------------------*/ 3/*--- begin main_util.h ---*/ 4/*---------------------------------------------------------------*/ 5 6/* 7 This file is part of Valgrind, a dynamic binary instrumentation 8 framework. 9 10 Copyright (C) 2004-2010 OpenWorks LLP 11 info@open-works.net 12 13 This program is free software; you can redistribute it and/or 14 modify it under the terms of the GNU General Public License as 15 published by the Free Software Foundation; either version 2 of the 16 License, or (at your option) any later version. 17 18 This program is distributed in the hope that it will be useful, but 19 WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 General Public License for more details. 22 23 You should have received a copy of the GNU General Public License 24 along with this program; if not, write to the Free Software 25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 26 02110-1301, USA. 27 28 The GNU General Public License is contained in the file COPYING. 29 30 Neither the names of the U.S. Department of Energy nor the 31 University of California nor the names of its contributors may be 32 used to endorse or promote products derived from this software 33 without prior written permission. 34*/ 35 36#ifndef __VEX_MAIN_UTIL_H 37#define __VEX_MAIN_UTIL_H 38 39#include "libvex_basictypes.h" 40 41 42/* Misc. */ 43 44#define NULL ((void*)0) 45 46 47/* Stuff for panicking and assertion. */ 48 49#define VG__STRING(__str) #__str 50 51#define vassert(expr) \ 52 ((void) ((expr) ? 0 : \ 53 (vex_assert_fail (VG__STRING(expr), \ 54 __FILE__, __LINE__, \ 55 __PRETTY_FUNCTION__), 0))) 56 57__attribute__ ((__noreturn__)) 58extern void vex_assert_fail ( const HChar* expr, const HChar* file, 59 Int line, const HChar* fn ); 60__attribute__ ((__noreturn__)) 61extern void vpanic ( HChar* str ); 62 63 64/* Printing */ 65 66__attribute__ ((format (printf, 1, 2))) 67extern UInt vex_printf ( HChar *format, ... ); 68 69__attribute__ ((format (printf, 2, 3))) 70extern UInt vex_sprintf ( HChar* buf, HChar *format, ... ); 71 72 73/* String ops */ 74 75extern Bool vex_streq ( const HChar* s1, const HChar* s2 ); 76 77 78/* Storage management: clear the area, and allocate from it. */ 79 80/* By default allocation occurs in the temporary area. However, it is 81 possible to switch to permanent area allocation if that's what you 82 want. Permanent area allocation is very limited, tho. */ 83 84typedef 85 enum { 86 VexAllocModeTEMP, 87 VexAllocModePERM 88 } 89 VexAllocMode; 90 91extern void vexSetAllocMode ( VexAllocMode ); 92extern VexAllocMode vexGetAllocMode ( void ); 93extern void vexAllocSanityCheck ( void ); 94 95extern void vexSetAllocModeTEMP_and_clear ( void ); 96 97#endif /* ndef __VEX_MAIN_UTIL_H */ 98 99/*---------------------------------------------------------------*/ 100/*--- main_util.h ---*/ 101/*---------------------------------------------------------------*/ 102