blob: c71e12cc144a9c3475888c5123d030de6be092f6 [file] [log] [blame]
sewardj5cf515f2004-06-26 20:10:35 +00001
2/*---------------------------------------------------------------*/
3/*--- ---*/
sewardj35421a32004-07-05 13:12:34 +00004/*--- This file (vex_util.h) is ---*/
sewardj5cf515f2004-06-26 20:10:35 +00005/*--- Copyright (c) 2004 OpenWorks LLP. All rights reserved. ---*/
6/*--- ---*/
7/*---------------------------------------------------------------*/
8
sewardjf8ed9d82004-11-12 17:40:23 +00009/*
10 This file is part of LibVEX, a library for dynamic binary
11 instrumentation and translation.
12
13 Copyright (C) 2004 OpenWorks, LLP.
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; Version 2 dated June 1991 of the
18 license.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or liability
23 for damages. See the GNU General Public License for more details.
24
25 Neither the names of the U.S. Department of Energy nor the
26 University of California nor the names of its contributors may be
27 used to endorse or promote products derived from this software
28 without prior written permission.
29
30 You should have received a copy of the GNU General Public License
31 along with this program; if not, write to the Free Software
32 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
33 USA.
34*/
35
sewardj35421a32004-07-05 13:12:34 +000036#ifndef __VEX_UTIL_H
37#define __VEX_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)))
sewardj810dcf02004-11-22 12:55:45 +000067extern UInt vex_printf ( const HChar *format, ... );
sewardj35421a32004-07-05 13:12:34 +000068
sewardj41f43bc2004-07-08 14:23:22 +000069__attribute__ ((format (printf, 2, 3)))
sewardj8c332e22005-01-28 01:36:56 +000070extern UInt vex_sprintf ( HChar* buf, const 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 );
93
94extern void vexClearTEMP ( void );
95
96
sewardj35421a32004-07-05 13:12:34 +000097#endif /* ndef __VEX_UTIL_H */
sewardjac9af022004-07-05 01:15:34 +000098
99/*---------------------------------------------------------------*/
sewardj35421a32004-07-05 13:12:34 +0000100/*--- vex_util.h ---*/
sewardjac9af022004-07-05 01:15:34 +0000101/*---------------------------------------------------------------*/