blob: 1392b4b1d63acd3da3a4c249d153d4db5dc4f9d6 [file] [log] [blame]
sewardj5cf515f2004-06-26 20:10:35 +00001
2/*---------------------------------------------------------------*/
sewardj752f9062010-05-03 21:38:49 +00003/*--- begin main_util.h ---*/
sewardj5cf515f2004-06-26 20:10:35 +00004/*---------------------------------------------------------------*/
5
sewardjf8ed9d82004-11-12 17:40:23 +00006/*
sewardj752f9062010-05-03 21:38:49 +00007 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
sewardjf8ed9d82004-11-12 17:40:23 +00009
sewardj752f9062010-05-03 21:38:49 +000010 Copyright (C) 2004-2010 OpenWorks LLP
11 info@open-works.net
sewardjf8ed9d82004-11-12 17:40:23 +000012
sewardj752f9062010-05-03 21:38:49 +000013 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.
sewardjf8ed9d82004-11-12 17:40:23 +000017
sewardj752f9062010-05-03 21:38:49 +000018 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
sewardj7bd6ffe2005-08-03 16:07:36 +000026 02110-1301, USA.
27
sewardj752f9062010-05-03 21:38:49 +000028 The GNU General Public License is contained in the file COPYING.
sewardjf8ed9d82004-11-12 17:40:23 +000029
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.
sewardjf8ed9d82004-11-12 17:40:23 +000034*/
35
sewardjcef7d3e2009-07-02 12:21:59 +000036#ifndef __VEX_MAIN_UTIL_H
37#define __VEX_MAIN_UTIL_H
sewardj5cf515f2004-06-26 20:10:35 +000038
sewardj887a11a2004-07-05 17:26:47 +000039#include "libvex_basictypes.h"
sewardj5cf515f2004-06-26 20:10:35 +000040
41
sewardj35421a32004-07-05 13:12:34 +000042/* Misc. */
43
44#define NULL ((void*)0)
45
46
sewardj5cf515f2004-06-26 20:10:35 +000047/* Stuff for panicking and assertion. */
48
49#define VG__STRING(__str) #__str
50
sewardj35421a32004-07-05 13:12:34 +000051#define vassert(expr) \
sewardj5cf515f2004-06-26 20:10:35 +000052 ((void) ((expr) ? 0 : \
53 (vex_assert_fail (VG__STRING(expr), \
54 __FILE__, __LINE__, \
55 __PRETTY_FUNCTION__), 0)))
56
57__attribute__ ((__noreturn__))
sewardj58277842005-02-07 03:11:17 +000058extern void vex_assert_fail ( const HChar* expr, const HChar* file,
59 Int line, const HChar* fn );
sewardj5cf515f2004-06-26 20:10:35 +000060__attribute__ ((__noreturn__))
sewardj8c332e22005-01-28 01:36:56 +000061extern void vpanic ( HChar* str );
sewardj5cf515f2004-06-26 20:10:35 +000062
63
sewardj35421a32004-07-05 13:12:34 +000064/* Printing */
65
66__attribute__ ((format (printf, 1, 2)))
sewardjda46fdd2005-08-25 21:20:18 +000067extern UInt vex_printf ( HChar *format, ... );
sewardj35421a32004-07-05 13:12:34 +000068
sewardj41f43bc2004-07-08 14:23:22 +000069__attribute__ ((format (printf, 2, 3)))
sewardjda46fdd2005-08-25 21:20:18 +000070extern UInt vex_sprintf ( HChar* buf, HChar *format, ... );
sewardj35421a32004-07-05 13:12:34 +000071
sewardj36ca5132004-07-24 13:12:23 +000072
73/* String ops */
74
sewardj58277842005-02-07 03:11:17 +000075extern Bool vex_streq ( const HChar* s1, const HChar* s2 );
sewardj36ca5132004-07-24 13:12:23 +000076
77
sewardjd887b862005-01-17 18:34:34 +000078/* 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 );
sewardj2d6b14a2005-11-23 04:25:07 +000093extern void vexAllocSanityCheck ( void );
sewardjd887b862005-01-17 18:34:34 +000094
sewardj2d6b14a2005-11-23 04:25:07 +000095extern void vexSetAllocModeTEMP_and_clear ( void );
sewardjd887b862005-01-17 18:34:34 +000096
sewardjcef7d3e2009-07-02 12:21:59 +000097#endif /* ndef __VEX_MAIN_UTIL_H */
sewardjac9af022004-07-05 01:15:34 +000098
99/*---------------------------------------------------------------*/
sewardjcef7d3e2009-07-02 12:21:59 +0000100/*--- main_util.h ---*/
sewardjac9af022004-07-05 01:15:34 +0000101/*---------------------------------------------------------------*/