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