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