xue@11
|
1 /*
|
xue@11
|
2 Harmonic sinusoidal modelling and tools
|
xue@11
|
3
|
xue@11
|
4 C++ code package for harmonic sinusoidal modelling and relevant signal processing.
|
xue@11
|
5 Centre for Digital Music, Queen Mary, University of London.
|
xue@11
|
6 This file copyright 2011 Wen Xue.
|
xue@11
|
7
|
xue@11
|
8 This program is free software; you can redistribute it and/or
|
xue@11
|
9 modify it under the terms of the GNU General Public License as
|
xue@11
|
10 published by the Free Software Foundation; either version 2 of the
|
xue@11
|
11 License, or (at your option) any later version.
|
xue@11
|
12 */
|
xue@1
|
13 //---------------------------------------------------------------------------
|
xue@1
|
14
|
xue@1
|
15 #ifndef align8H
|
xue@1
|
16 #define align8H
|
xue@1
|
17
|
Chris@5
|
18 /**
|
Chris@5
|
19 \file align8.h - 8-byte (64-bit) alignment routines.
|
xue@1
|
20
|
xue@12
|
21 This file provides tools for aligning boundaries of arrays, particularly of 64-bit units, e.g. double-
|
xue@1
|
22 precision floating points, to physical addresses divisible by 8, including aligning dynamically
|
xue@1
|
23 allocated memory block and aligning call stack. Currently stack alignment is disabled due to lack
|
xue@1
|
24 of compiler support for Intel assembly.
|
xue@1
|
25
|
xue@1
|
26 Further reading: "Double precision floating point alignment issue.pdf"
|
xue@1
|
27 */
|
xue@1
|
28
|
xue@1
|
29 //--stack alignment----------------------------------------------------------
|
xue@1
|
30 /*
|
xue@1
|
31 These two macros are used to envelop a function call so that the function is called with a stack
|
xue@1
|
32 pointer that is a multiple of 8. Aligning the stack does not automatically ensure that local double
|
xue@1
|
33 -precision floating-point variables (or other variables one wants to align to 8-byte boundaries) are
|
xue@1
|
34 aligned to 8-byte boundaries; one has to adjust the variable declaration order, using dummy variables
|
xue@1
|
35 if necessary, to make the alignment happen.
|
xue@1
|
36 */
|
xue@1
|
37 //macro ALIGN_STACK_8 moves the current stack pointer to a multiple of 8
|
xue@1
|
38 #define ALIGN_STACK_8 {int alignstack; asm {mov alignstack, esp} asm {and esp, 0xFFFFFFF8}
|
xue@1
|
39 //macro RESTORE_STACK moves the stack pointer back to where it was before ALIGN_STACK_8
|
xue@1
|
40 #define RESTORE_STACK asm {mov esp, alignstack}}
|
xue@1
|
41
|
xue@1
|
42 //ALIGN8 ensures F is executed with a start stack pointer divisible by 8. Currently disabled.
|
xue@1
|
43 #define ALIGN8(F) F
|
xue@1
|
44 //uncomment the following line to enable stack alignment
|
xue@1
|
45 //#define ALIGN8(F) ALIGN_STACK_8 F RESTORE_STACK
|
xue@1
|
46
|
xue@1
|
47 //--64-bit aligned memory allocation routines--------------------------------
|
xue@1
|
48 void* malloc8(unsigned size);
|
xue@1
|
49 void free8(void* buffer8);
|
xue@1
|
50
|
xue@1
|
51 #endif
|