blob: 5cb989316c8288c895ad361e09a40c6de3da4dfb [file] [log] [blame]
njn5c004e42002-11-18 11:04:50 +00001
2/*--------------------------------------------------------------------*/
njn43c799e2003-04-08 00:08:52 +00003/*--- Declarations shared between MemCheck and AddrCheck. ---*/
4/*--- mac_shared.h ---*/
njn5c004e42002-11-18 11:04:50 +00005/*--------------------------------------------------------------------*/
6
7/*
8 This file is part of MemCheck, a heavyweight Valgrind skin for
9 detecting memory errors, and AddrCheck, a lightweight Valgrind skin
10 for detecting memory errors.
11
njn0e1b5142003-04-15 14:58:06 +000012 Copyright (C) 2000-2003 Julian Seward
njn5c004e42002-11-18 11:04:50 +000013 jseward@acm.org
14
15 This program is free software; you can redistribute it and/or
16 modify it under the terms of the GNU General Public License as
17 published by the Free Software Foundation; either version 2 of the
18 License, or (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 02111-1307, USA.
29
30 The GNU General Public License is contained in the file COPYING.
31*/
32
njn43c799e2003-04-08 00:08:52 +000033/* Note: This header contains the declarations shared between
34 Addrcheck and Memcheck, and is #included by both. */
35
36#ifndef __MAC_SHARED_H
37#define __MAC_SHARED_H
njn5c004e42002-11-18 11:04:50 +000038
39#include "vg_skin.h"
njn43c799e2003-04-08 00:08:52 +000040
41#define MAC_(str) VGAPPEND(vgMAC_,str)
njn5c004e42002-11-18 11:04:50 +000042
njn9b007f62003-04-07 14:40:25 +000043/*------------------------------------------------------------*/
44/*--- Errors and suppressions ---*/
45/*------------------------------------------------------------*/
46
njn5c004e42002-11-18 11:04:50 +000047/* The classification of a faulting address. */
48typedef
njn43c799e2003-04-08 00:08:52 +000049 enum {
50 Undescribed, /* as-yet unclassified */
51 Stack,
52 Unknown, /* classification yielded nothing useful */
53 Freed, Mallocd,
54 UserG /* in a user-defined block; Addrcheck & Memcheck only */
njn5c004e42002-11-18 11:04:50 +000055 }
56 AddrKind;
57
58/* Records info about a faulting address. */
59typedef
60 struct {
61 /* ALL */
62 AddrKind akind;
63 /* Freed, Mallocd */
64 Int blksize;
65 /* Freed, Mallocd */
66 Int rwoffset;
67 /* Freed, Mallocd */
68 ExeContext* lastchange;
69 /* Stack */
70 ThreadId stack_tid;
71 /* True if is just-below %esp -- could be a gcc bug. */
72 Bool maybe_gcc;
73 }
74 AddrInfo;
75
76typedef
77 enum {
78 /* Bad syscall params */
79 ParamSupp,
80 /* Memory errors in core (pthread ops, signal handling) */
81 CoreMemSupp,
82 /* Use of invalid values of given size (MemCheck only) */
njnc0616662003-06-12 09:58:41 +000083 Value0Supp, Value1Supp, Value2Supp, Value4Supp, Value8Supp, Value16Supp,
njn5c004e42002-11-18 11:04:50 +000084 /* Invalid read/write attempt at given size */
njnc0616662003-06-12 09:58:41 +000085 Addr1Supp, Addr2Supp, Addr4Supp, Addr8Supp, Addr16Supp,
njn5c004e42002-11-18 11:04:50 +000086 /* Invalid or mismatching free */
sewardj99aac972002-12-26 01:53:45 +000087 FreeSupp,
njn34419c12003-05-02 17:24:29 +000088 /* Overlapping blocks in memcpy(), strcpy(), etc */
89 OverlapSupp,
sewardj99aac972002-12-26 01:53:45 +000090 /* Something to be suppressed in a leak check. */
91 LeakSupp
njn5c004e42002-11-18 11:04:50 +000092 }
njn43c799e2003-04-08 00:08:52 +000093 MAC_SuppKind;
njn5c004e42002-11-18 11:04:50 +000094
95/* What kind of error it is. */
96typedef
97 enum { ValueErr, /* Memcheck only */
98 CoreMemErr,
99 AddrErr,
100 ParamErr, UserErr, /* behaves like an anonymous ParamErr */
njn43c799e2003-04-08 00:08:52 +0000101 FreeErr, FreeMismatchErr,
njn34419c12003-05-02 17:24:29 +0000102 OverlapErr, /* Memcheck only */
njn43c799e2003-04-08 00:08:52 +0000103 LeakErr
njn5c004e42002-11-18 11:04:50 +0000104 }
njn43c799e2003-04-08 00:08:52 +0000105 MAC_ErrorKind;
njn5c004e42002-11-18 11:04:50 +0000106
107/* What kind of memory access is involved in the error? */
108typedef
109 enum { ReadAxs, WriteAxs, ExecAxs }
110 AxsKind;
111
112/* Extra context for memory errors */
113typedef
114 struct {
115 /* AddrErr */
116 AxsKind axskind;
117 /* AddrErr, ValueErr */
118 Int size;
119 /* AddrErr, FreeErr, FreeMismatchErr, ParamErr, UserErr */
120 AddrInfo addrinfo;
121 /* ParamErr, UserErr, CoreMemErr */
122 Bool isWrite;
123 }
njn43c799e2003-04-08 00:08:52 +0000124 MAC_Error;
njn5c004e42002-11-18 11:04:50 +0000125
njn3e884182003-04-15 13:03:23 +0000126/* For malloc()/new/new[] vs. free()/delete/delete[] mismatch checking. */
127typedef
128 enum {
129 MAC_AllocMalloc = 0,
130 MAC_AllocNew = 1,
njn10785452003-05-20 16:38:24 +0000131 MAC_AllocNewVec = 2,
132 MAC_AllocCustom = 3
njn3e884182003-04-15 13:03:23 +0000133 }
134 MAC_AllocKind;
135
136/* Nb: first two fields must match core's VgHashNode. */
137typedef
138 struct _MAC_Chunk {
139 struct _MAC_Chunk* next;
140 Addr data; /* ptr to actual block */
141 UInt size : 30; /* size requested */
142 MAC_AllocKind allockind : 2; /* which wrapper did the allocation */
143 ExeContext* where; /* where it was allocated */
144 }
145 MAC_Chunk;
146
njn9b007f62003-04-07 14:40:25 +0000147/*------------------------------------------------------------*/
148/*--- Profiling of skins and memory events ---*/
149/*------------------------------------------------------------*/
150
151typedef
152 enum {
153 VgpCheckMem = VgpFini+1,
154 VgpSetMem,
155 VgpESPAdj
156 }
157 VgpSkinCC;
158
159/* Define to collect detailed performance info. */
njn43c799e2003-04-08 00:08:52 +0000160/* #define MAC_PROFILE_MEMORY */
njn5c004e42002-11-18 11:04:50 +0000161
njn43c799e2003-04-08 00:08:52 +0000162#ifdef MAC_PROFILE_MEMORY
njn9b007f62003-04-07 14:40:25 +0000163# define N_PROF_EVENTS 150
njn5c004e42002-11-18 11:04:50 +0000164
njn43c799e2003-04-08 00:08:52 +0000165extern UInt MAC_(event_ctr)[N_PROF_EVENTS];
njn9b007f62003-04-07 14:40:25 +0000166
njn43c799e2003-04-08 00:08:52 +0000167# define PROF_EVENT(ev) \
168 do { sk_assert((ev) >= 0 && (ev) < N_PROF_EVENTS); \
169 MAC_(event_ctr)[ev]++; \
njn5c004e42002-11-18 11:04:50 +0000170 } while (False);
171
172#else
173
njn9b007f62003-04-07 14:40:25 +0000174# define PROF_EVENT(ev) /* */
njn5c004e42002-11-18 11:04:50 +0000175
njn43c799e2003-04-08 00:08:52 +0000176#endif /* MAC_PROFILE_MEMORY */
njn5c004e42002-11-18 11:04:50 +0000177
njn9b007f62003-04-07 14:40:25 +0000178/*------------------------------------------------------------*/
179/*--- V and A bits ---*/
180/*------------------------------------------------------------*/
181
njn5c004e42002-11-18 11:04:50 +0000182#define IS_DISTINGUISHED_SM(smap) \
183 ((smap) == &distinguished_secondary_map)
184
njn43c799e2003-04-08 00:08:52 +0000185#define ENSURE_MAPPABLE(addr,caller) \
186 do { \
njn5c004e42002-11-18 11:04:50 +0000187 if (IS_DISTINGUISHED_SM(primary_map[(addr) >> 16])) { \
188 primary_map[(addr) >> 16] = alloc_secondary_map(caller); \
njn43c799e2003-04-08 00:08:52 +0000189 /* VG_(printf)("new 2map because of %p\n", addr); */ \
190 } \
njn5c004e42002-11-18 11:04:50 +0000191 } while(0)
192
193#define BITARR_SET(aaa_p,iii_p) \
194 do { \
195 UInt iii = (UInt)iii_p; \
196 UChar* aaa = (UChar*)aaa_p; \
197 aaa[iii >> 3] |= (1 << (iii & 7)); \
198 } while (0)
199
200#define BITARR_CLEAR(aaa_p,iii_p) \
201 do { \
202 UInt iii = (UInt)iii_p; \
203 UChar* aaa = (UChar*)aaa_p; \
204 aaa[iii >> 3] &= ~(1 << (iii & 7)); \
205 } while (0)
206
207#define BITARR_TEST(aaa_p,iii_p) \
208 (0 != (((UChar*)aaa_p)[ ((UInt)iii_p) >> 3 ] \
209 & (1 << (((UInt)iii_p) & 7)))) \
210
211
212#define VGM_BIT_VALID 0
213#define VGM_BIT_INVALID 1
214
215#define VGM_NIBBLE_VALID 0
216#define VGM_NIBBLE_INVALID 0xF
217
218#define VGM_BYTE_VALID 0
219#define VGM_BYTE_INVALID 0xFF
220
221#define VGM_WORD_VALID 0
222#define VGM_WORD_INVALID 0xFFFFFFFF
223
224#define VGM_EFLAGS_VALID 0xFFFFFFFE
225#define VGM_EFLAGS_INVALID 0xFFFFFFFF /* not used */
226
227/*------------------------------------------------------------*/
228/*--- Command line options + defaults ---*/
229/*------------------------------------------------------------*/
230
njn43c799e2003-04-08 00:08:52 +0000231/* Memcheck defines a couple more. */
njn5c004e42002-11-18 11:04:50 +0000232
233/* Allow loads from partially-valid addresses? default: YES */
njn43c799e2003-04-08 00:08:52 +0000234extern Bool MAC_(clo_partial_loads_ok);
njn5c004e42002-11-18 11:04:50 +0000235
236/* Max volume of the freed blocks queue. */
njn43c799e2003-04-08 00:08:52 +0000237extern Int MAC_(clo_freelist_vol);
njn5c004e42002-11-18 11:04:50 +0000238
239/* Do leak check at exit? default: NO */
njn43c799e2003-04-08 00:08:52 +0000240extern Bool MAC_(clo_leak_check);
njn5c004e42002-11-18 11:04:50 +0000241
242/* How closely should we compare ExeContexts in leak records? default: 2 */
njn43c799e2003-04-08 00:08:52 +0000243extern VgRes MAC_(clo_leak_resolution);
njn5c004e42002-11-18 11:04:50 +0000244
245/* In leak check, show reachable-but-not-freed blocks? default: NO */
njn43c799e2003-04-08 00:08:52 +0000246extern Bool MAC_(clo_show_reachable);
njn5c004e42002-11-18 11:04:50 +0000247
248/* Assume accesses immediately below %esp are due to gcc-2.96 bugs.
249 * default: NO*/
njn43c799e2003-04-08 00:08:52 +0000250extern Bool MAC_(clo_workaround_gcc296_bugs);
njn5c004e42002-11-18 11:04:50 +0000251
njn3e884182003-04-15 13:03:23 +0000252extern Bool MAC_(process_common_cmd_line_option) ( Char* arg );
253extern void MAC_(print_common_usage) ( void );
254extern void MAC_(print_common_debug_usage) ( void );
255
256
257/*------------------------------------------------------------*/
258/*--- Variables ---*/
259/*------------------------------------------------------------*/
260
261/* For tracking malloc'd blocks */
262extern VgHashTable MAC_(malloc_list);
263
264/* Function pointers for the two skins to track interesting events. */
265extern void (*MAC_(new_mem_heap)) ( Addr a, UInt len, Bool is_inited );
266extern void (*MAC_(ban_mem_heap)) ( Addr a, UInt len );
267extern void (*MAC_(die_mem_heap)) ( Addr a, UInt len );
268extern void (*MAC_(copy_mem_heap))( Addr from, Addr to, UInt len );
269
sewardjecf8e102003-07-12 12:11:39 +0000270/* Function pointers for internal sanity checking. */
271extern Bool (*MAC_(check_noaccess))( Addr a, UInt len, Addr* bad_addr );
272
njn3e884182003-04-15 13:03:23 +0000273/* Used in describe_addr() */
274extern Bool (*MAC_(describe_addr_supp)) ( Addr a, AddrInfo* ai );
njn5c004e42002-11-18 11:04:50 +0000275
njn47363ab2003-04-21 13:24:40 +0000276/* For VALGRIND_COUNT_LEAKS client request */
277extern Int MAC_(total_bytes_leaked);
278extern Int MAC_(total_bytes_dubious);
279extern Int MAC_(total_bytes_reachable);
280extern Int MAC_(total_bytes_suppressed);
sewardj99aac972002-12-26 01:53:45 +0000281
njn5c004e42002-11-18 11:04:50 +0000282/*------------------------------------------------------------*/
283/*--- Functions ---*/
284/*------------------------------------------------------------*/
285
njn43c799e2003-04-08 00:08:52 +0000286extern void MAC_(pp_AddrInfo) ( Addr a, AddrInfo* ai );
njn5c004e42002-11-18 11:04:50 +0000287
njn43c799e2003-04-08 00:08:52 +0000288extern void MAC_(clear_MAC_Error) ( MAC_Error* err_extra );
njn5c004e42002-11-18 11:04:50 +0000289
njn43c799e2003-04-08 00:08:52 +0000290extern Bool MAC_(shared_recognised_suppression) ( Char* name, Supp* su );
njn5c004e42002-11-18 11:04:50 +0000291
njn10785452003-05-20 16:38:24 +0000292extern void MAC_(new_block) ( ThreadState* tst, Addr p, UInt size,
293 UInt rzB, Bool is_zeroed,
294 MAC_AllocKind kind );
295extern void MAC_(handle_free) ( ThreadState* tst, Addr p, UInt rzB,
296 MAC_AllocKind kind );
297
sewardjaf48a602003-07-06 00:54:47 +0000298extern void MAC_(record_address_error) ( ThreadState* tst, Addr a,
299 Int size, Bool isWrite );
njn43c799e2003-04-08 00:08:52 +0000300extern void MAC_(record_core_mem_error) ( ThreadState* tst, Bool isWrite,
301 Char* s );
302extern void MAC_(record_param_error) ( ThreadState* tst, Addr a,
303 Bool isWriteLack, Char* msg );
304extern void MAC_(record_jump_error) ( ThreadState* tst, Addr a );
305extern void MAC_(record_free_error) ( ThreadState* tst, Addr a );
306extern void MAC_(record_freemismatch_error)( ThreadState* tst, Addr a );
njn5c004e42002-11-18 11:04:50 +0000307
njn43c799e2003-04-08 00:08:52 +0000308extern void MAC_(pp_shared_SkinError) ( Error* err);
309
njn3e884182003-04-15 13:03:23 +0000310extern MAC_Chunk* MAC_(first_matching_freed_MAC_Chunk)( Bool (*p)(MAC_Chunk*) );
njn43c799e2003-04-08 00:08:52 +0000311
njn3e884182003-04-15 13:03:23 +0000312extern void MAC_(common_pre_clo_init) ( void );
313extern void MAC_(common_fini) ( void (*leak_check)(void) );
314
njn47363ab2003-04-21 13:24:40 +0000315extern Bool MAC_(handle_common_client_requests)
316 ( ThreadState* tst, UInt* arg_block, UInt* ret );
317
njn3e884182003-04-15 13:03:23 +0000318extern void MAC_(print_malloc_stats) ( void );
njn43c799e2003-04-08 00:08:52 +0000319
320/* For leak checking */
321extern void MAC_(pp_LeakError)(void* vl, UInt n_this_record,
322 UInt n_total_records);
323
324extern void MAC_(do_detect_memory_leaks) (
325 Bool is_valid_64k_chunk ( UInt ),
326 Bool is_valid_address ( Addr )
327 );
328
329extern __attribute__((regparm(1))) void MAC_(new_mem_stack_4) ( Addr old_ESP );
330extern __attribute__((regparm(1))) void MAC_(die_mem_stack_4) ( Addr old_ESP );
331extern __attribute__((regparm(1))) void MAC_(new_mem_stack_8) ( Addr old_ESP );
332extern __attribute__((regparm(1))) void MAC_(die_mem_stack_8) ( Addr old_ESP );
333extern __attribute__((regparm(1))) void MAC_(new_mem_stack_12) ( Addr old_ESP );
334extern __attribute__((regparm(1))) void MAC_(die_mem_stack_12) ( Addr old_ESP );
335extern __attribute__((regparm(1))) void MAC_(new_mem_stack_16) ( Addr old_ESP );
336extern __attribute__((regparm(1))) void MAC_(die_mem_stack_16) ( Addr old_ESP );
337extern __attribute__((regparm(1))) void MAC_(new_mem_stack_32) ( Addr old_ESP );
338extern __attribute__((regparm(1))) void MAC_(die_mem_stack_32) ( Addr old_ESP );
njn3e884182003-04-15 13:03:23 +0000339extern void MAC_(die_mem_stack) ( Addr a, UInt len);
340extern void MAC_(new_mem_stack) ( Addr a, UInt len);
njn9b007f62003-04-07 14:40:25 +0000341
342
343/*------------------------------------------------------------*/
344/*--- Stack pointer adjustment ---*/
345/*------------------------------------------------------------*/
346
347/* Some noble preprocessor abuse, to enable Memcheck and Addrcheck to
njn3e884182003-04-15 13:03:23 +0000348 share this code, but call different functions.
njn9b007f62003-04-07 14:40:25 +0000349
350 Note that this code is executed very frequently and must be highly
351 optimised, which is why I resort to the preprocessor to achieve the
352 factoring, rather than eg. using function pointers.
353*/
354
355#define ESP_UPDATE_HANDLERS(ALIGNED4_NEW, ALIGNED4_DIE, \
356 ALIGNED8_NEW, ALIGNED8_DIE, \
357 UNALIGNED_NEW, UNALIGNED_DIE) \
358 \
njn43c799e2003-04-08 00:08:52 +0000359void __attribute__((regparm(1))) MAC_(new_mem_stack_4)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000360{ \
361 PROF_EVENT(110); \
362 if (IS_ALIGNED4_ADDR(new_ESP)) { \
363 ALIGNED4_NEW ( new_ESP ); \
364 } else { \
365 UNALIGNED_NEW ( new_ESP, 4 ); \
366 } \
367} \
368 \
njn43c799e2003-04-08 00:08:52 +0000369void __attribute__((regparm(1))) MAC_(die_mem_stack_4)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000370{ \
371 PROF_EVENT(120); \
372 if (IS_ALIGNED4_ADDR(new_ESP)) { \
373 ALIGNED4_DIE ( new_ESP-4 ); \
374 } else { \
375 UNALIGNED_DIE ( new_ESP-4, 4 ); \
376 } \
377} \
378 \
njn43c799e2003-04-08 00:08:52 +0000379void __attribute__((regparm(1))) MAC_(new_mem_stack_8)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000380{ \
381 PROF_EVENT(111); \
382 if (IS_ALIGNED8_ADDR(new_ESP)) { \
383 ALIGNED8_NEW ( new_ESP ); \
384 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
385 ALIGNED4_NEW ( new_ESP ); \
386 ALIGNED4_NEW ( new_ESP+4 ); \
387 } else { \
388 UNALIGNED_NEW ( new_ESP, 8 ); \
389 } \
390} \
391 \
njn43c799e2003-04-08 00:08:52 +0000392void __attribute__((regparm(1))) MAC_(die_mem_stack_8)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000393{ \
394 PROF_EVENT(121); \
395 if (IS_ALIGNED8_ADDR(new_ESP)) { \
396 ALIGNED8_DIE ( new_ESP-8 ); \
397 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
398 ALIGNED4_DIE ( new_ESP-8 ); \
399 ALIGNED4_DIE ( new_ESP-4 ); \
400 } else { \
401 UNALIGNED_DIE ( new_ESP-8, 8 ); \
402 } \
403} \
404 \
njn43c799e2003-04-08 00:08:52 +0000405void __attribute__((regparm(1))) MAC_(new_mem_stack_12)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000406{ \
407 PROF_EVENT(112); \
408 if (IS_ALIGNED8_ADDR(new_ESP)) { \
409 ALIGNED8_NEW ( new_ESP ); \
410 ALIGNED4_NEW ( new_ESP+8 ); \
411 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
412 ALIGNED4_NEW ( new_ESP ); \
413 ALIGNED8_NEW ( new_ESP+4 ); \
414 } else { \
415 UNALIGNED_NEW ( new_ESP, 12 ); \
416 } \
417} \
418 \
njn43c799e2003-04-08 00:08:52 +0000419void __attribute__((regparm(1))) MAC_(die_mem_stack_12)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000420{ \
421 PROF_EVENT(122); \
422 /* Note the -12 in the test */ \
423 if (IS_ALIGNED8_ADDR(new_ESP-12)) { \
424 ALIGNED8_DIE ( new_ESP-12 ); \
425 ALIGNED4_DIE ( new_ESP-4 ); \
426 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
427 ALIGNED4_DIE ( new_ESP-12 ); \
428 ALIGNED8_DIE ( new_ESP-8 ); \
429 } else { \
430 UNALIGNED_DIE ( new_ESP-12, 12 ); \
431 } \
432} \
433 \
njn43c799e2003-04-08 00:08:52 +0000434void __attribute__((regparm(1))) MAC_(new_mem_stack_16)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000435{ \
436 PROF_EVENT(113); \
437 if (IS_ALIGNED8_ADDR(new_ESP)) { \
438 ALIGNED8_NEW ( new_ESP ); \
439 ALIGNED8_NEW ( new_ESP+8 ); \
440 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
441 ALIGNED4_NEW ( new_ESP ); \
442 ALIGNED8_NEW ( new_ESP+4 ); \
443 ALIGNED4_NEW ( new_ESP+12 ); \
444 } else { \
445 UNALIGNED_NEW ( new_ESP, 16 ); \
446 } \
447} \
448 \
njn43c799e2003-04-08 00:08:52 +0000449void __attribute__((regparm(1))) MAC_(die_mem_stack_16)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000450{ \
451 PROF_EVENT(123); \
452 if (IS_ALIGNED8_ADDR(new_ESP)) { \
453 ALIGNED8_DIE ( new_ESP-16 ); \
454 ALIGNED8_DIE ( new_ESP-8 ); \
455 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
456 ALIGNED4_DIE ( new_ESP-16 ); \
457 ALIGNED8_DIE ( new_ESP-12 ); \
458 ALIGNED4_DIE ( new_ESP-4 ); \
459 } else { \
460 UNALIGNED_DIE ( new_ESP-16, 16 ); \
461 } \
462} \
463 \
njn43c799e2003-04-08 00:08:52 +0000464void __attribute__((regparm(1))) MAC_(new_mem_stack_32)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000465{ \
466 PROF_EVENT(114); \
467 if (IS_ALIGNED8_ADDR(new_ESP)) { \
468 ALIGNED8_NEW ( new_ESP ); \
469 ALIGNED8_NEW ( new_ESP+8 ); \
470 ALIGNED8_NEW ( new_ESP+16 ); \
471 ALIGNED8_NEW ( new_ESP+24 ); \
472 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
473 ALIGNED4_NEW ( new_ESP ); \
474 ALIGNED8_NEW ( new_ESP+4 ); \
475 ALIGNED8_NEW ( new_ESP+12 ); \
476 ALIGNED8_NEW ( new_ESP+20 ); \
477 ALIGNED4_NEW ( new_ESP+28 ); \
478 } else { \
479 UNALIGNED_NEW ( new_ESP, 32 ); \
480 } \
481} \
482 \
njn43c799e2003-04-08 00:08:52 +0000483void __attribute__((regparm(1))) MAC_(die_mem_stack_32)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000484{ \
485 PROF_EVENT(124); \
486 if (IS_ALIGNED8_ADDR(new_ESP)) { \
487 ALIGNED8_DIE ( new_ESP-32 ); \
488 ALIGNED8_DIE ( new_ESP-24 ); \
489 ALIGNED8_DIE ( new_ESP-16 ); \
490 ALIGNED8_DIE ( new_ESP- 8 ); \
491 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
492 ALIGNED4_DIE ( new_ESP-32 ); \
493 ALIGNED8_DIE ( new_ESP-28 ); \
494 ALIGNED8_DIE ( new_ESP-20 ); \
495 ALIGNED8_DIE ( new_ESP-12 ); \
496 ALIGNED4_DIE ( new_ESP-4 ); \
497 } else { \
498 UNALIGNED_DIE ( new_ESP-32, 32 ); \
499 } \
500} \
501 \
njn43c799e2003-04-08 00:08:52 +0000502void MAC_(new_mem_stack) ( Addr a, UInt len ) \
njn9b007f62003-04-07 14:40:25 +0000503{ \
504 PROF_EVENT(115); \
505 UNALIGNED_NEW ( a, len ); \
506} \
507 \
njn43c799e2003-04-08 00:08:52 +0000508void MAC_(die_mem_stack) ( Addr a, UInt len ) \
njn9b007f62003-04-07 14:40:25 +0000509{ \
510 PROF_EVENT(125); \
511 UNALIGNED_DIE ( a, len ); \
512}
513
njn43c799e2003-04-08 00:08:52 +0000514#endif /* __MAC_SHARED_H */
njn5c004e42002-11-18 11:04:50 +0000515
516/*--------------------------------------------------------------------*/
njn43c799e2003-04-08 00:08:52 +0000517/*--- end mac_shared.h ---*/
njn5c004e42002-11-18 11:04:50 +0000518/*--------------------------------------------------------------------*/