finally fix alignment issues
This commit is contained in:
parent
f5758537c7
commit
156dcd2233
5 changed files with 30 additions and 1 deletions
1
Makefile
1
Makefile
|
@ -62,6 +62,7 @@ exe: $(EXE)
|
|||
dll: $(DLL)
|
||||
|
||||
windows: ALL_CXXFLAGS += $(OPT_FLAGS)
|
||||
windows: ALL_CXXFLAGS += -mstackrealign
|
||||
windows: dll
|
||||
|
||||
linux: ALL_CXXFLAGS += $(OPT_FLAGS) -fpic
|
||||
|
|
|
@ -32,6 +32,9 @@ and odds are that your version is horribly outdated anyway.
|
|||
*Debian/Ubuntu users:* your stable version of g++ can't even build this.
|
||||
just `apt-get install clang-3.6` and export `CXX=clang++-3.6` when building.
|
||||
|
||||
If you really have to use g++,
|
||||
you may need to add `-fabi-version=6` to CXXFLAGS.
|
||||
|
||||
### general building
|
||||
|
||||
`make linux` or `make windows` (works well with [mxe])
|
||||
|
|
22
include/Aligned.hpp
Normal file
22
include/Aligned.hpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
// http://stackoverflow.com/a/18137117
|
||||
struct Aligned {
|
||||
static void*
|
||||
operator new(size_t sz) {
|
||||
const size_t extra = sizeof(void *);
|
||||
void *mem = new char[sz + extra + 15];
|
||||
void *aligned = (void *)(
|
||||
((uintptr_t)(mem) + extra + 15) & ~15
|
||||
);
|
||||
void **ptr = (void **)(aligned);
|
||||
ptr[-1] = mem;
|
||||
return aligned;
|
||||
}
|
||||
|
||||
static void
|
||||
operator delete(void* aligned, size_t sz)
|
||||
{
|
||||
void **ptr = (void **) aligned;
|
||||
char *mem = (char *)(ptr[-1]);
|
||||
delete[] mem;
|
||||
}
|
||||
};
|
|
@ -1,4 +1,6 @@
|
|||
struct Crap {
|
||||
#include "Aligned.hpp"
|
||||
|
||||
struct Crap : public Aligned {
|
||||
virtual inline
|
||||
~Crap() {}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "ladspa.hpp"
|
||||
|
||||
//#INCLUDE
|
||||
|
|
Loading…
Add table
Reference in a new issue