pa.c (pa_print_operand): Use HOST_WIDE_INT_PRINT_DEC instead of "%d" for 'o' operand.
[official-gcc.git] / libvtv / vtv_malloc.h
blob2af565f6e661ce6306a06d675d9fa2b962e6cfe7
1 // Copyright (C) 2012-2013
2 // Free Software Foundation
3 //
4 // This file is part of GCC.
5 //
6 // GCC is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3, or (at your option)
9 // any later version.
11 // GCC is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 #ifndef _VTV_MALLOC_H
26 #define _VTV_MALLOC_H 1
28 #include <stdlib.h>
30 /* Alignment mask for any object returned by the VTV memory pool */
31 #ifdef __LP64__
32 #define VTV_ALIGNMENT_MASK (0x7)
33 #else
34 #define VTV_ALIGNMENT_MASK (0x3)
35 #endif
37 /* The following function is used to instrument the compiler and find
38 out how many cycles are being spent in various vtable verification
39 runtime library functions. */
41 #ifdef __x86_64__
42 static inline unsigned long
43 rdtsc ()
45 unsigned long long hi, lo;
47 asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
48 return hi << 32 | lo;
50 #elif defined (__i386__)
51 static inline unsigned long long
52 rdtsc ()
54 unsigned long long var;
56 asm volatile ("rdtsc" : "=A" (var));
58 return var;
60 #else
61 static inline unsigned long long
62 rdtsc ()
64 /* Create an empty function for unknown architectures, so that the
65 calls to this function in vtv_malloc.cc and vtv_rts.cc do not cause
66 compilation errors. */
67 return ((unsigned long long) 0);
69 #endif
72 /* The following variables are used only for debugging and performance tuning
73 purposes. Therefore they do not need to be "protected". They cannot be used
74 to attack the vtable verification system and if they become corrupted it will
75 not affect the correctness or security of any of the rest of the vtable
76 verification feature. */
78 extern unsigned int num_calls_to_mprotect;
79 extern unsigned int num_pages_protected;
80 extern unsigned int num_calls_to_regset;
81 extern unsigned int num_calls_to_regpair;
82 extern unsigned long long mprotect_cycles;
83 extern unsigned long long regset_cycles;
84 extern unsigned long long regpair_cycles;
87 /* Function declarations. */
89 extern void __vtv_malloc_init (void);
90 extern void *__vtv_malloc (size_t size) __attribute__ ((malloc));
91 extern void __vtv_free (void * ptr);
92 extern void __vtv_malloc_protect (void);
93 extern void __vtv_malloc_unprotect (void);
94 extern void __vtv_malloc_stats (void);
95 extern void __vtv_malloc_dump_stats (void);
96 extern int __vtv_count_mmapped_pages (void);
98 #if defined (__CYGWIN__) || defined (__MINGW32__)
99 extern "C" int mprotect (void *addr, int len, int prot);
101 #define PROT_READ 0x1
102 #define PROT_WRITE 0x2
103 #endif
105 #endif /* vtv_malloc.h */