Mercurial > hg > x
comparison align8.h @ 1:6422640a802f
first upload
author | Wen X <xue.wen@elec.qmul.ac.uk> |
---|---|
date | Tue, 05 Oct 2010 10:45:57 +0100 |
parents | |
children | 5f3c32dc6e17 |
comparison
equal
deleted
inserted
replaced
0:9b9f21935f24 | 1:6422640a802f |
---|---|
1 //--------------------------------------------------------------------------- | |
2 | |
3 #ifndef align8H | |
4 #define align8H | |
5 | |
6 /* | |
7 align8.cpp - 8-byte (64-bit) alignment routines. | |
8 | |
9 This file provides tools for aligning boundaries of arrays, particularly of 64-byte units, e.g. double- | |
10 precision floating points, to physical addresses divisible by 8, including aligning dynamically | |
11 allocated memory block and aligning call stack. Currently stack alignment is disabled due to lack | |
12 of compiler support for Intel assembly. | |
13 | |
14 Further reading: "Double precision floating point alignment issue.pdf" | |
15 */ | |
16 | |
17 //--stack alignment---------------------------------------------------------- | |
18 /* | |
19 These two macros are used to envelop a function call so that the function is called with a stack | |
20 pointer that is a multiple of 8. Aligning the stack does not automatically ensure that local double | |
21 -precision floating-point variables (or other variables one wants to align to 8-byte boundaries) are | |
22 aligned to 8-byte boundaries; one has to adjust the variable declaration order, using dummy variables | |
23 if necessary, to make the alignment happen. | |
24 */ | |
25 //macro ALIGN_STACK_8 moves the current stack pointer to a multiple of 8 | |
26 #define ALIGN_STACK_8 {int alignstack; asm {mov alignstack, esp} asm {and esp, 0xFFFFFFF8} | |
27 //macro RESTORE_STACK moves the stack pointer back to where it was before ALIGN_STACK_8 | |
28 #define RESTORE_STACK asm {mov esp, alignstack}} | |
29 | |
30 //ALIGN8 ensures F is executed with a start stack pointer divisible by 8. Currently disabled. | |
31 #define ALIGN8(F) F | |
32 //uncomment the following line to enable stack alignment | |
33 //#define ALIGN8(F) ALIGN_STACK_8 F RESTORE_STACK | |
34 | |
35 //--64-bit aligned memory allocation routines-------------------------------- | |
36 void* malloc8(unsigned size); | |
37 void free8(void* buffer8); | |
38 | |
39 #endif |