blob: 5241cbe65f4c226f2f85e9f56bbf6664b91d0f29 [file] [log] [blame]
sewardj4f2683a2008-10-26 11:53:30 +00001
2/*--------------------------------------------------------------------*/
3/*--- Demangling of C++ mangled names. vg_libciface.h ---*/
4/*--------------------------------------------------------------------*/
5
6/*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
9
sewardj0f157dd2013-10-18 14:27:36 +000010 Copyright (C) 2000-2013 Julian Seward
sewardj4f2683a2008-10-26 11:53:30 +000011 jseward@acm.org
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., 59 Temple Place, Suite 330, Boston, MA
26 02111-1307, USA.
27
28 The GNU General Public License is contained in the file COPYING.
29*/
30
31/* This file contains a bunch of macro definitions etc which are
32 really "impedance matchers". They make it possible for
33 cp-demangle.c, cplus-dem.c, dyn-string.c and safe-ctype.c (taken
34 from GNU libiberty) to be compiled in the Valgrind framework with a
35 minimum of changes.
36
37 This file should only be included in files which contain libiberty
38 code. */
39
40#include "pub_core_basics.h"
41#include "pub_core_libcbase.h"
42#include "pub_core_libcassert.h"
43#include "pub_core_libcprint.h"
44#include "pub_core_mallocfree.h"
45
46
47#define abort() vg_assert(0)
njn83df0b62009-02-25 01:01:05 +000048#define atoi(_str) VG_(strtoll10)((_str), NULL)
sewardj4f2683a2008-10-26 11:53:30 +000049#define free(_pt) VG_(arena_free) (VG_AR_DEMANGLE,(_pt))
50#define memcmp(_s1,_s2,_sz) VG_(memcmp)((_s1),(_s2),(_sz))
51#define memcpy(_dd,_ss,_sz) VG_(memcpy)((_dd),(_ss),(_sz))
52#define memset(_ss,_cc,_sz) VG_(memset)((_ss),(_cc),(_sz))
53#define realloc(_cc,_pt,_sz) VG_(arena_realloc)(VG_AR_DEMANGLE,(_cc),(_pt),(_sz))
54#define sprintf(_buf,_fmt,_args...) VG_(sprintf)((_buf),(_fmt),(_args))
55#define strcat(_dd,_ss) VG_(strcat)((_dd),(_ss))
56#define strchr(_ss,_cc) VG_(strchr)((_ss),(_cc))
57#define strcmp(_s1,_s2) VG_(strcmp)((_s1),(_s2))
58#define strcpy(_dd,_ss) VG_(strcpy)((_dd),(_ss))
59#define strcspn(_ss,_rr) VG_(strcspn)((_ss),(_rr))
60#define strlen(_str) VG_(strlen)(_str)
61#define strncat(_dd,_ss,_nn) VG_(strncat)((_dd),(_ss),(_nn))
62#define strncmp(_s1,_s2,_sz) VG_(strncmp)((_s1),(_s2),(_sz))
63#define strncpy(_dd,_ss,_sz) VG_(strncpy)((_dd),(_ss),(_sz))
64#define strpbrk(_ss,_aa) VG_(strpbrk)((_ss),(_aa))
65#define strspn(_ss,_aa) VG_(strspn)((_ss),(_aa))
66#define strstr(_hh,_nn) VG_(strstr)((_hh),(_nn))
67
68#define size_t SizeT
69
70#define xmalloc(_nn) \
71 VG_(arena_malloc)(VG_AR_DEMANGLE, "m_demangle.xmalloc", (_nn))
72#define xrealloc(_pt,_sz) \
73 VG_(arena_realloc)(VG_AR_DEMANGLE,"m_demangle.xrealloc",(_pt),(_sz))
74#define xstrdup(_str) \
75 VG_(arena_strdup)(VG_AR_DEMANGLE,"m_demangle.xstrdup",(_str))
76
sewardj9a2ce3d2008-10-27 09:54:14 +000077/* Required by safe-ctype.h */
78
79#undef EOF
80#define EOF -1
81
sewardj4f2683a2008-10-26 11:53:30 +000082/* Taken from libiberty.h: */
83
84#define ARRAY_SIZE(_arr) \
85 (sizeof (_arr) / sizeof ((_arr)[0]))
86
87#define XNEWVEC(_Ty, _Nn) \
88 ((_Ty *) xmalloc(sizeof (_Ty) * (_Nn)))
89
90#define XRESIZEVEC(_Ty, _Pt, _Nn) \
91 ((_Ty *) xrealloc((void *) (_Pt), sizeof (_Ty) * (_Nn)))
92
93#define XRESIZEVAR(_Ty, _Pt, _Sz) \
94 ((_Ty *) xrealloc((_Pt), (_Sz)))
95
96#define XNEW(_Ty) \
97 ((_Ty *) xmalloc(sizeof (_Ty)))
98
99
100/*--------------------------------------------------------------------*/
101/*--- end vg_libciface.h ---*/
102/*--------------------------------------------------------------------*/