2 /*---------------------------------------------------------------*/
3 /*--- begin main_util.h ---*/
4 /*---------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2004-2010 OpenWorks LLP
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.
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.
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
28 The GNU General Public License is contained in the file COPYING.
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.
36 #ifndef __VEX_MAIN_UTIL_H
37 #define __VEX_MAIN_UTIL_H
39 #include "libvex_basictypes.h"
44 #define NULL ((void*)0)
46 #define LIKELY(x) __builtin_expect(!!(x), 1)
47 #define UNLIKELY(x) __builtin_expect(!!(x), 0)
49 /* Stuff for panicking and assertion. */
51 #define VG__STRING(__str) #__str
53 #define vassert(expr) \
54 ((void) (LIKELY(expr) ? 0 : \
55 (vex_assert_fail (VG__STRING(expr), \
57 __PRETTY_FUNCTION__), 0)))
59 __attribute__ ((__noreturn__))
60 extern void vex_assert_fail ( const HChar* expr, const HChar* file,
61 Int line, const HChar* fn );
62 __attribute__ ((__noreturn__))
63 extern void vpanic ( HChar* str );
68 __attribute__ ((format (printf, 1, 2)))
69 extern UInt vex_printf ( HChar *format, ... );
71 __attribute__ ((format (printf, 2, 3)))
72 extern UInt vex_sprintf ( HChar* buf, HChar *format, ... );
77 extern Bool vex_streq ( const HChar* s1, const HChar* s2 );
78 extern Int vex_strlen ( const HChar* str );
81 /* Storage management: clear the area, and allocate from it. */
83 /* By default allocation occurs in the temporary area. However, it is
84 possible to switch to permanent area allocation if that's what you
85 want. Permanent area allocation is very limited, tho. */
94 extern void vexSetAllocMode ( VexAllocMode );
95 extern VexAllocMode vexGetAllocMode ( void );
96 extern void vexAllocSanityCheck ( void );
98 extern void vexSetAllocModeTEMP_and_clear ( void );
100 #endif /* ndef __VEX_MAIN_UTIL_H */
102 /*---------------------------------------------------------------*/
103 /*--- main_util.h ---*/
104 /*---------------------------------------------------------------*/