blob: 302d9ffe692012266d0a83089d8de0c60e985ba4 [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) */
83 Value0Supp, Value1Supp, Value2Supp, Value4Supp, Value8Supp,
84 /* Invalid read/write attempt at given size */
85 Addr1Supp, Addr2Supp, Addr4Supp, Addr8Supp,
86 /* 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,
131 MAC_AllocNewVec = 2
132 }
133 MAC_AllocKind;
134
135/* Nb: first two fields must match core's VgHashNode. */
136typedef
137 struct _MAC_Chunk {
138 struct _MAC_Chunk* next;
139 Addr data; /* ptr to actual block */
140 UInt size : 30; /* size requested */
141 MAC_AllocKind allockind : 2; /* which wrapper did the allocation */
142 ExeContext* where; /* where it was allocated */
143 }
144 MAC_Chunk;
145
njn9b007f62003-04-07 14:40:25 +0000146/*------------------------------------------------------------*/
147/*--- Profiling of skins and memory events ---*/
148/*------------------------------------------------------------*/
149
150typedef
151 enum {
152 VgpCheckMem = VgpFini+1,
153 VgpSetMem,
154 VgpESPAdj
155 }
156 VgpSkinCC;
157
158/* Define to collect detailed performance info. */
njn43c799e2003-04-08 00:08:52 +0000159/* #define MAC_PROFILE_MEMORY */
njn5c004e42002-11-18 11:04:50 +0000160
njn43c799e2003-04-08 00:08:52 +0000161#ifdef MAC_PROFILE_MEMORY
njn9b007f62003-04-07 14:40:25 +0000162# define N_PROF_EVENTS 150
njn5c004e42002-11-18 11:04:50 +0000163
njn43c799e2003-04-08 00:08:52 +0000164extern UInt MAC_(event_ctr)[N_PROF_EVENTS];
njn9b007f62003-04-07 14:40:25 +0000165
njn43c799e2003-04-08 00:08:52 +0000166# define PROF_EVENT(ev) \
167 do { sk_assert((ev) >= 0 && (ev) < N_PROF_EVENTS); \
168 MAC_(event_ctr)[ev]++; \
njn5c004e42002-11-18 11:04:50 +0000169 } while (False);
170
171#else
172
njn9b007f62003-04-07 14:40:25 +0000173# define PROF_EVENT(ev) /* */
njn5c004e42002-11-18 11:04:50 +0000174
njn43c799e2003-04-08 00:08:52 +0000175#endif /* MAC_PROFILE_MEMORY */
njn5c004e42002-11-18 11:04:50 +0000176
njn9b007f62003-04-07 14:40:25 +0000177/*------------------------------------------------------------*/
178/*--- V and A bits ---*/
179/*------------------------------------------------------------*/
180
njn5c004e42002-11-18 11:04:50 +0000181#define IS_DISTINGUISHED_SM(smap) \
182 ((smap) == &distinguished_secondary_map)
183
njn43c799e2003-04-08 00:08:52 +0000184#define ENSURE_MAPPABLE(addr,caller) \
185 do { \
njn5c004e42002-11-18 11:04:50 +0000186 if (IS_DISTINGUISHED_SM(primary_map[(addr) >> 16])) { \
187 primary_map[(addr) >> 16] = alloc_secondary_map(caller); \
njn43c799e2003-04-08 00:08:52 +0000188 /* VG_(printf)("new 2map because of %p\n", addr); */ \
189 } \
njn5c004e42002-11-18 11:04:50 +0000190 } while(0)
191
192#define BITARR_SET(aaa_p,iii_p) \
193 do { \
194 UInt iii = (UInt)iii_p; \
195 UChar* aaa = (UChar*)aaa_p; \
196 aaa[iii >> 3] |= (1 << (iii & 7)); \
197 } while (0)
198
199#define BITARR_CLEAR(aaa_p,iii_p) \
200 do { \
201 UInt iii = (UInt)iii_p; \
202 UChar* aaa = (UChar*)aaa_p; \
203 aaa[iii >> 3] &= ~(1 << (iii & 7)); \
204 } while (0)
205
206#define BITARR_TEST(aaa_p,iii_p) \
207 (0 != (((UChar*)aaa_p)[ ((UInt)iii_p) >> 3 ] \
208 & (1 << (((UInt)iii_p) & 7)))) \
209
210
211#define VGM_BIT_VALID 0
212#define VGM_BIT_INVALID 1
213
214#define VGM_NIBBLE_VALID 0
215#define VGM_NIBBLE_INVALID 0xF
216
217#define VGM_BYTE_VALID 0
218#define VGM_BYTE_INVALID 0xFF
219
220#define VGM_WORD_VALID 0
221#define VGM_WORD_INVALID 0xFFFFFFFF
222
223#define VGM_EFLAGS_VALID 0xFFFFFFFE
224#define VGM_EFLAGS_INVALID 0xFFFFFFFF /* not used */
225
226/*------------------------------------------------------------*/
227/*--- Command line options + defaults ---*/
228/*------------------------------------------------------------*/
229
njn43c799e2003-04-08 00:08:52 +0000230/* Memcheck defines a couple more. */
njn5c004e42002-11-18 11:04:50 +0000231
232/* Allow loads from partially-valid addresses? default: YES */
njn43c799e2003-04-08 00:08:52 +0000233extern Bool MAC_(clo_partial_loads_ok);
njn5c004e42002-11-18 11:04:50 +0000234
235/* Max volume of the freed blocks queue. */
njn43c799e2003-04-08 00:08:52 +0000236extern Int MAC_(clo_freelist_vol);
njn5c004e42002-11-18 11:04:50 +0000237
238/* Do leak check at exit? default: NO */
njn43c799e2003-04-08 00:08:52 +0000239extern Bool MAC_(clo_leak_check);
njn5c004e42002-11-18 11:04:50 +0000240
241/* How closely should we compare ExeContexts in leak records? default: 2 */
njn43c799e2003-04-08 00:08:52 +0000242extern VgRes MAC_(clo_leak_resolution);
njn5c004e42002-11-18 11:04:50 +0000243
244/* In leak check, show reachable-but-not-freed blocks? default: NO */
njn43c799e2003-04-08 00:08:52 +0000245extern Bool MAC_(clo_show_reachable);
njn5c004e42002-11-18 11:04:50 +0000246
247/* Assume accesses immediately below %esp are due to gcc-2.96 bugs.
248 * default: NO*/
njn43c799e2003-04-08 00:08:52 +0000249extern Bool MAC_(clo_workaround_gcc296_bugs);
njn5c004e42002-11-18 11:04:50 +0000250
njn3e884182003-04-15 13:03:23 +0000251extern Bool MAC_(process_common_cmd_line_option) ( Char* arg );
252extern void MAC_(print_common_usage) ( void );
253extern void MAC_(print_common_debug_usage) ( void );
254
255
256/*------------------------------------------------------------*/
257/*--- Variables ---*/
258/*------------------------------------------------------------*/
259
260/* For tracking malloc'd blocks */
261extern VgHashTable MAC_(malloc_list);
262
263/* Function pointers for the two skins to track interesting events. */
264extern void (*MAC_(new_mem_heap)) ( Addr a, UInt len, Bool is_inited );
265extern void (*MAC_(ban_mem_heap)) ( Addr a, UInt len );
266extern void (*MAC_(die_mem_heap)) ( Addr a, UInt len );
267extern void (*MAC_(copy_mem_heap))( Addr from, Addr to, UInt len );
268
269/* Used in describe_addr() */
270extern Bool (*MAC_(describe_addr_supp)) ( Addr a, AddrInfo* ai );
njn5c004e42002-11-18 11:04:50 +0000271
njn47363ab2003-04-21 13:24:40 +0000272/* For VALGRIND_COUNT_LEAKS client request */
273extern Int MAC_(total_bytes_leaked);
274extern Int MAC_(total_bytes_dubious);
275extern Int MAC_(total_bytes_reachable);
276extern Int MAC_(total_bytes_suppressed);
sewardj99aac972002-12-26 01:53:45 +0000277
njn5c004e42002-11-18 11:04:50 +0000278/*------------------------------------------------------------*/
279/*--- Functions ---*/
280/*------------------------------------------------------------*/
281
njn43c799e2003-04-08 00:08:52 +0000282extern void MAC_(pp_AddrInfo) ( Addr a, AddrInfo* ai );
njn5c004e42002-11-18 11:04:50 +0000283
njn43c799e2003-04-08 00:08:52 +0000284extern void MAC_(clear_MAC_Error) ( MAC_Error* err_extra );
njn5c004e42002-11-18 11:04:50 +0000285
njn43c799e2003-04-08 00:08:52 +0000286extern Bool MAC_(shared_recognised_suppression) ( Char* name, Supp* su );
njn5c004e42002-11-18 11:04:50 +0000287
njn43c799e2003-04-08 00:08:52 +0000288extern void MAC_(record_address_error) ( Addr a, Int size, Bool isWrite );
289extern void MAC_(record_core_mem_error) ( ThreadState* tst, Bool isWrite,
290 Char* s );
291extern void MAC_(record_param_error) ( ThreadState* tst, Addr a,
292 Bool isWriteLack, Char* msg );
293extern void MAC_(record_jump_error) ( ThreadState* tst, Addr a );
294extern void MAC_(record_free_error) ( ThreadState* tst, Addr a );
295extern void MAC_(record_freemismatch_error)( ThreadState* tst, Addr a );
njn5c004e42002-11-18 11:04:50 +0000296
njn43c799e2003-04-08 00:08:52 +0000297extern void MAC_(pp_shared_SkinError) ( Error* err);
298
njn3e884182003-04-15 13:03:23 +0000299extern MAC_Chunk* MAC_(first_matching_freed_MAC_Chunk)( Bool (*p)(MAC_Chunk*) );
njn43c799e2003-04-08 00:08:52 +0000300
njn3e884182003-04-15 13:03:23 +0000301extern void MAC_(common_pre_clo_init) ( void );
302extern void MAC_(common_fini) ( void (*leak_check)(void) );
303
njn47363ab2003-04-21 13:24:40 +0000304extern Bool MAC_(handle_common_client_requests)
305 ( ThreadState* tst, UInt* arg_block, UInt* ret );
306
njn3e884182003-04-15 13:03:23 +0000307extern void MAC_(print_malloc_stats) ( void );
njn43c799e2003-04-08 00:08:52 +0000308
309/* For leak checking */
310extern void MAC_(pp_LeakError)(void* vl, UInt n_this_record,
311 UInt n_total_records);
312
313extern void MAC_(do_detect_memory_leaks) (
314 Bool is_valid_64k_chunk ( UInt ),
315 Bool is_valid_address ( Addr )
316 );
317
318extern __attribute__((regparm(1))) void MAC_(new_mem_stack_4) ( Addr old_ESP );
319extern __attribute__((regparm(1))) void MAC_(die_mem_stack_4) ( Addr old_ESP );
320extern __attribute__((regparm(1))) void MAC_(new_mem_stack_8) ( Addr old_ESP );
321extern __attribute__((regparm(1))) void MAC_(die_mem_stack_8) ( Addr old_ESP );
322extern __attribute__((regparm(1))) void MAC_(new_mem_stack_12) ( Addr old_ESP );
323extern __attribute__((regparm(1))) void MAC_(die_mem_stack_12) ( Addr old_ESP );
324extern __attribute__((regparm(1))) void MAC_(new_mem_stack_16) ( Addr old_ESP );
325extern __attribute__((regparm(1))) void MAC_(die_mem_stack_16) ( Addr old_ESP );
326extern __attribute__((regparm(1))) void MAC_(new_mem_stack_32) ( Addr old_ESP );
327extern __attribute__((regparm(1))) void MAC_(die_mem_stack_32) ( Addr old_ESP );
njn3e884182003-04-15 13:03:23 +0000328extern void MAC_(die_mem_stack) ( Addr a, UInt len);
329extern void MAC_(new_mem_stack) ( Addr a, UInt len);
njn9b007f62003-04-07 14:40:25 +0000330
331
332/*------------------------------------------------------------*/
333/*--- Stack pointer adjustment ---*/
334/*------------------------------------------------------------*/
335
336/* Some noble preprocessor abuse, to enable Memcheck and Addrcheck to
njn3e884182003-04-15 13:03:23 +0000337 share this code, but call different functions.
njn9b007f62003-04-07 14:40:25 +0000338
339 Note that this code is executed very frequently and must be highly
340 optimised, which is why I resort to the preprocessor to achieve the
341 factoring, rather than eg. using function pointers.
342*/
343
344#define ESP_UPDATE_HANDLERS(ALIGNED4_NEW, ALIGNED4_DIE, \
345 ALIGNED8_NEW, ALIGNED8_DIE, \
346 UNALIGNED_NEW, UNALIGNED_DIE) \
347 \
njn43c799e2003-04-08 00:08:52 +0000348void __attribute__((regparm(1))) MAC_(new_mem_stack_4)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000349{ \
350 PROF_EVENT(110); \
351 if (IS_ALIGNED4_ADDR(new_ESP)) { \
352 ALIGNED4_NEW ( new_ESP ); \
353 } else { \
354 UNALIGNED_NEW ( new_ESP, 4 ); \
355 } \
356} \
357 \
njn43c799e2003-04-08 00:08:52 +0000358void __attribute__((regparm(1))) MAC_(die_mem_stack_4)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000359{ \
360 PROF_EVENT(120); \
361 if (IS_ALIGNED4_ADDR(new_ESP)) { \
362 ALIGNED4_DIE ( new_ESP-4 ); \
363 } else { \
364 UNALIGNED_DIE ( new_ESP-4, 4 ); \
365 } \
366} \
367 \
njn43c799e2003-04-08 00:08:52 +0000368void __attribute__((regparm(1))) MAC_(new_mem_stack_8)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000369{ \
370 PROF_EVENT(111); \
371 if (IS_ALIGNED8_ADDR(new_ESP)) { \
372 ALIGNED8_NEW ( new_ESP ); \
373 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
374 ALIGNED4_NEW ( new_ESP ); \
375 ALIGNED4_NEW ( new_ESP+4 ); \
376 } else { \
377 UNALIGNED_NEW ( new_ESP, 8 ); \
378 } \
379} \
380 \
njn43c799e2003-04-08 00:08:52 +0000381void __attribute__((regparm(1))) MAC_(die_mem_stack_8)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000382{ \
383 PROF_EVENT(121); \
384 if (IS_ALIGNED8_ADDR(new_ESP)) { \
385 ALIGNED8_DIE ( new_ESP-8 ); \
386 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
387 ALIGNED4_DIE ( new_ESP-8 ); \
388 ALIGNED4_DIE ( new_ESP-4 ); \
389 } else { \
390 UNALIGNED_DIE ( new_ESP-8, 8 ); \
391 } \
392} \
393 \
njn43c799e2003-04-08 00:08:52 +0000394void __attribute__((regparm(1))) MAC_(new_mem_stack_12)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000395{ \
396 PROF_EVENT(112); \
397 if (IS_ALIGNED8_ADDR(new_ESP)) { \
398 ALIGNED8_NEW ( new_ESP ); \
399 ALIGNED4_NEW ( new_ESP+8 ); \
400 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
401 ALIGNED4_NEW ( new_ESP ); \
402 ALIGNED8_NEW ( new_ESP+4 ); \
403 } else { \
404 UNALIGNED_NEW ( new_ESP, 12 ); \
405 } \
406} \
407 \
njn43c799e2003-04-08 00:08:52 +0000408void __attribute__((regparm(1))) MAC_(die_mem_stack_12)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000409{ \
410 PROF_EVENT(122); \
411 /* Note the -12 in the test */ \
412 if (IS_ALIGNED8_ADDR(new_ESP-12)) { \
413 ALIGNED8_DIE ( new_ESP-12 ); \
414 ALIGNED4_DIE ( new_ESP-4 ); \
415 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
416 ALIGNED4_DIE ( new_ESP-12 ); \
417 ALIGNED8_DIE ( new_ESP-8 ); \
418 } else { \
419 UNALIGNED_DIE ( new_ESP-12, 12 ); \
420 } \
421} \
422 \
njn43c799e2003-04-08 00:08:52 +0000423void __attribute__((regparm(1))) MAC_(new_mem_stack_16)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000424{ \
425 PROF_EVENT(113); \
426 if (IS_ALIGNED8_ADDR(new_ESP)) { \
427 ALIGNED8_NEW ( new_ESP ); \
428 ALIGNED8_NEW ( new_ESP+8 ); \
429 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
430 ALIGNED4_NEW ( new_ESP ); \
431 ALIGNED8_NEW ( new_ESP+4 ); \
432 ALIGNED4_NEW ( new_ESP+12 ); \
433 } else { \
434 UNALIGNED_NEW ( new_ESP, 16 ); \
435 } \
436} \
437 \
njn43c799e2003-04-08 00:08:52 +0000438void __attribute__((regparm(1))) MAC_(die_mem_stack_16)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000439{ \
440 PROF_EVENT(123); \
441 if (IS_ALIGNED8_ADDR(new_ESP)) { \
442 ALIGNED8_DIE ( new_ESP-16 ); \
443 ALIGNED8_DIE ( new_ESP-8 ); \
444 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
445 ALIGNED4_DIE ( new_ESP-16 ); \
446 ALIGNED8_DIE ( new_ESP-12 ); \
447 ALIGNED4_DIE ( new_ESP-4 ); \
448 } else { \
449 UNALIGNED_DIE ( new_ESP-16, 16 ); \
450 } \
451} \
452 \
njn43c799e2003-04-08 00:08:52 +0000453void __attribute__((regparm(1))) MAC_(new_mem_stack_32)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000454{ \
455 PROF_EVENT(114); \
456 if (IS_ALIGNED8_ADDR(new_ESP)) { \
457 ALIGNED8_NEW ( new_ESP ); \
458 ALIGNED8_NEW ( new_ESP+8 ); \
459 ALIGNED8_NEW ( new_ESP+16 ); \
460 ALIGNED8_NEW ( new_ESP+24 ); \
461 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
462 ALIGNED4_NEW ( new_ESP ); \
463 ALIGNED8_NEW ( new_ESP+4 ); \
464 ALIGNED8_NEW ( new_ESP+12 ); \
465 ALIGNED8_NEW ( new_ESP+20 ); \
466 ALIGNED4_NEW ( new_ESP+28 ); \
467 } else { \
468 UNALIGNED_NEW ( new_ESP, 32 ); \
469 } \
470} \
471 \
njn43c799e2003-04-08 00:08:52 +0000472void __attribute__((regparm(1))) MAC_(die_mem_stack_32)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000473{ \
474 PROF_EVENT(124); \
475 if (IS_ALIGNED8_ADDR(new_ESP)) { \
476 ALIGNED8_DIE ( new_ESP-32 ); \
477 ALIGNED8_DIE ( new_ESP-24 ); \
478 ALIGNED8_DIE ( new_ESP-16 ); \
479 ALIGNED8_DIE ( new_ESP- 8 ); \
480 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
481 ALIGNED4_DIE ( new_ESP-32 ); \
482 ALIGNED8_DIE ( new_ESP-28 ); \
483 ALIGNED8_DIE ( new_ESP-20 ); \
484 ALIGNED8_DIE ( new_ESP-12 ); \
485 ALIGNED4_DIE ( new_ESP-4 ); \
486 } else { \
487 UNALIGNED_DIE ( new_ESP-32, 32 ); \
488 } \
489} \
490 \
njn43c799e2003-04-08 00:08:52 +0000491void MAC_(new_mem_stack) ( Addr a, UInt len ) \
njn9b007f62003-04-07 14:40:25 +0000492{ \
493 PROF_EVENT(115); \
494 UNALIGNED_NEW ( a, len ); \
495} \
496 \
njn43c799e2003-04-08 00:08:52 +0000497void MAC_(die_mem_stack) ( Addr a, UInt len ) \
njn9b007f62003-04-07 14:40:25 +0000498{ \
499 PROF_EVENT(125); \
500 UNALIGNED_DIE ( a, len ); \
501}
502
njn43c799e2003-04-08 00:08:52 +0000503#endif /* __MAC_SHARED_H */
njn5c004e42002-11-18 11:04:50 +0000504
505/*--------------------------------------------------------------------*/
njn43c799e2003-04-08 00:08:52 +0000506/*--- end mac_shared.h ---*/
njn5c004e42002-11-18 11:04:50 +0000507/*--------------------------------------------------------------------*/