blob: d9e4d859972044216dcc4ca2ea07af89bade2fd9 [file] [log] [blame]
/*---------------------------------------------------------------*/
/*--- ---*/
/*--- This file (vex_util.h) is ---*/
/*--- Copyright (c) 2004 OpenWorks LLP. All rights reserved. ---*/
/*--- ---*/
/*---------------------------------------------------------------*/
/*
This file is part of LibVEX, a library for dynamic binary
instrumentation and translation.
Copyright (C) 2004 OpenWorks, LLP.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; Version 2 dated June 1991 of the
license.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or liability
for damages. See the GNU General Public License for more details.
Neither the names of the U.S. Department of Energy nor the
University of California nor the names of its contributors may be
used to endorse or promote products derived from this software
without prior written permission.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
*/
#ifndef __VEX_UTIL_H
#define __VEX_UTIL_H
#include "libvex_basictypes.h"
/* Misc. */
#define NULL ((void*)0)
/* Stuff for panicking and assertion. */
#define VG__STRING(__str) #__str
#define vassert(expr) \
((void) ((expr) ? 0 : \
(vex_assert_fail (VG__STRING(expr), \
__FILE__, __LINE__, \
__PRETTY_FUNCTION__), 0)))
__attribute__ ((__noreturn__))
extern void vex_assert_fail ( const Char* expr, const Char* file,
Int line, const Char* fn );
__attribute__ ((__noreturn__))
extern void vpanic ( Char* str );
/* Printing */
__attribute__ ((format (printf, 1, 2)))
extern UInt vex_printf ( const HChar *format, ... );
__attribute__ ((format (printf, 2, 3)))
extern UInt vex_sprintf ( Char* buf, const HChar *format, ... );
/* String ops */
extern Bool vex_streq ( const Char* s1, const Char* s2 );
/* Storage management: clear the area, and allocate from it. */
/* By default allocation occurs in the temporary area. However, it is
possible to switch to permanent area allocation if that's what you
want. Permanent area allocation is very limited, tho. */
typedef
enum {
VexAllocModeTEMP,
VexAllocModePERM
}
VexAllocMode;
extern void vexSetAllocMode ( VexAllocMode );
extern VexAllocMode vexGetAllocMode ( void );
extern void vexClearTEMP ( void );
#endif /* ndef __VEX_UTIL_H */
/*---------------------------------------------------------------*/
/*--- vex_util.h ---*/
/*---------------------------------------------------------------*/