Use C11 alignas when available
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
#ifndef AL_ALIGN_H
|
||||
#define AL_ALIGN_H
|
||||
|
||||
#ifdef HAVE_STDALIGN_H
|
||||
#include <stdalign.h>
|
||||
#endif
|
||||
|
||||
#ifndef alignas
|
||||
#ifdef HAVE_C11_ALIGNAS
|
||||
#define alignas _Alignas
|
||||
#elif defined(IN_IDE_PARSER)
|
||||
/* KDevelop has problems with our align macro, so just use nothing for parsing. */
|
||||
#define alignas(x)
|
||||
#else
|
||||
/* NOTE: Our custom ALIGN macro can't take a type name like alignas can. For
|
||||
* maximum compatibility, only provide constant integer values to alignas. */
|
||||
#define alignas(_x) ALIGN(_x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* AL_ALIGN_H */
|
||||
+3
-1
@@ -2,8 +2,10 @@
|
||||
|
||||
#include "alMain.h"
|
||||
#include "alSource.h"
|
||||
|
||||
#include "hrtf.h"
|
||||
#include "mixer_defs.h"
|
||||
#include "align.h"
|
||||
|
||||
|
||||
#define REAL_MERGE2(a,b) a##b
|
||||
@@ -36,7 +38,7 @@ void MixDirect_Hrtf(DirectParams *params, const ALfloat *restrict data, ALuint s
|
||||
ALfloat (*restrict Values)[2] = params->Mix.Hrtf.State.Values[srcchan];
|
||||
ALuint Counter = maxu(params->Counter, OutPos) - OutPos;
|
||||
ALuint Offset = params->Offset + OutPos;
|
||||
ALIGN(16) ALfloat Coeffs[HRIR_LENGTH][2];
|
||||
alignas(16) ALfloat Coeffs[HRIR_LENGTH][2];
|
||||
ALuint Delay[2];
|
||||
ALfloat left, right;
|
||||
ALuint pos;
|
||||
|
||||
@@ -176,6 +176,15 @@ CHECK_C_SOURCE_COMPILES(
|
||||
}"
|
||||
HAVE_C11_STATIC_ASSERT)
|
||||
|
||||
# Check if we have C11 alignas
|
||||
CHECK_C_SOURCE_COMPILES(
|
||||
"_Alignas(4) int foo;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}"
|
||||
HAVE_C11_ALIGNAS)
|
||||
|
||||
# Add definitions, compiler switches, etc.
|
||||
INCLUDE_DIRECTORIES("${OpenAL_SOURCE_DIR}/include" "${OpenAL_BINARY_DIR}")
|
||||
IF(CMAKE_VERSION VERSION_LESS "2.8.8")
|
||||
@@ -319,6 +328,7 @@ ENDIF()
|
||||
CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
|
||||
int main() {return 0;}" HAVE_GCC_FORMAT)
|
||||
|
||||
CHECK_INCLUDE_FILE(stdalign.h HAVE_STDALIGN_H)
|
||||
IF(NOT HAVE_C99_VLA)
|
||||
CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
|
||||
ENDIF()
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "alMain.h"
|
||||
#include "alEffect.h"
|
||||
|
||||
#include "align.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -72,7 +74,7 @@ typedef struct ALeffectslot {
|
||||
volatile ALenum NeedsUpdate;
|
||||
ALeffectState *EffectState;
|
||||
|
||||
ALIGN(16) ALfloat WetBuffer[1][BUFFERSIZE];
|
||||
alignas(16) ALfloat WetBuffer[1][BUFFERSIZE];
|
||||
|
||||
RefCount ref;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#include "align.h"
|
||||
#include "atomic.h"
|
||||
#include "uintmap.h"
|
||||
#include "vector.h"
|
||||
@@ -271,11 +271,6 @@ ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname,
|
||||
/* KDevelop's parser doesn't recognize the C99-standard restrict keyword, but
|
||||
* recent versions (at least 4.5.1) do recognize GCC's __restrict. */
|
||||
#define restrict __restrict
|
||||
/* KDevelop won't see the ALIGN macro from config.h when viewing files that
|
||||
* don't include it directly (e.g. headers). */
|
||||
#ifndef ALIGN
|
||||
#define ALIGN(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -682,11 +677,11 @@ struct ALCdevice_struct
|
||||
ALuint SamplesDone;
|
||||
|
||||
/* Temp storage used for mixing. */
|
||||
ALIGN(16) ALfloat SampleData1[BUFFERSIZE];
|
||||
ALIGN(16) ALfloat SampleData2[BUFFERSIZE];
|
||||
alignas(16) ALfloat SampleData1[BUFFERSIZE];
|
||||
alignas(16) ALfloat SampleData2[BUFFERSIZE];
|
||||
|
||||
// Dry path buffer mix
|
||||
ALIGN(16) ALfloat DryBuffer[MaxChannels][BUFFERSIZE];
|
||||
alignas(16) ALfloat DryBuffer[MaxChannels][BUFFERSIZE];
|
||||
|
||||
/* Running count of the mixer invocations, in 31.1 fixed point. This
|
||||
* actually increments *twice* when mixing, first at the start and then at
|
||||
@@ -708,7 +703,7 @@ struct ALCdevice_struct
|
||||
ALCdevice *volatile next;
|
||||
|
||||
/* Memory space used by the default slot (Playback devices only) */
|
||||
ALIGN(16) ALCbyte _slot_mem[];
|
||||
alignas(16) ALCbyte _slot_mem[];
|
||||
};
|
||||
|
||||
// Frequency was requested by the app or config file
|
||||
@@ -779,7 +774,7 @@ struct ALCcontext_struct
|
||||
ALCcontext *volatile next;
|
||||
|
||||
/* Memory space used by the listener */
|
||||
ALIGN(16) ALCbyte _listener_mem[];
|
||||
alignas(16) ALCbyte _listener_mem[];
|
||||
};
|
||||
|
||||
ALCcontext *GetContextRef(void);
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
#include "alMain.h"
|
||||
#include "alBuffer.h"
|
||||
#include "alFilter.h"
|
||||
|
||||
#include "hrtf.h"
|
||||
#include "align.h"
|
||||
|
||||
|
||||
#define F_PI (3.14159265358979323846f)
|
||||
@@ -38,15 +40,15 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct HrtfState {
|
||||
ALIGN(16) ALfloat History[MAX_INPUT_CHANNELS][SRC_HISTORY_LENGTH];
|
||||
ALIGN(16) ALfloat Values[MAX_INPUT_CHANNELS][HRIR_LENGTH][2];
|
||||
alignas(16) ALfloat History[MAX_INPUT_CHANNELS][SRC_HISTORY_LENGTH];
|
||||
alignas(16) ALfloat Values[MAX_INPUT_CHANNELS][HRIR_LENGTH][2];
|
||||
} HrtfState;
|
||||
|
||||
typedef struct HrtfParams {
|
||||
ALfloat Gain;
|
||||
ALfloat Dir[3];
|
||||
ALIGN(16) ALfloat Coeffs[MAX_INPUT_CHANNELS][HRIR_LENGTH][2];
|
||||
ALIGN(16) ALfloat CoeffStep[MAX_INPUT_CHANNELS][HRIR_LENGTH][2];
|
||||
alignas(16) ALfloat Coeffs[MAX_INPUT_CHANNELS][HRIR_LENGTH][2];
|
||||
alignas(16) ALfloat CoeffStep[MAX_INPUT_CHANNELS][HRIR_LENGTH][2];
|
||||
ALuint Delay[MAX_INPUT_CHANNELS][2];
|
||||
ALint DelayStep[MAX_INPUT_CHANNELS][2];
|
||||
ALuint IrSize;
|
||||
|
||||
@@ -95,6 +95,9 @@
|
||||
/* Define if we have C11 _Static_assert support */
|
||||
#cmakedefine HAVE_C11_STATIC_ASSERT
|
||||
|
||||
/* Define if we have C11 _Alignas support */
|
||||
#cmakedefine HAVE_C11_ALIGNAS
|
||||
|
||||
/* Define if we have GCC's destructor attribute */
|
||||
#cmakedefine HAVE_GCC_DESTRUCTOR
|
||||
|
||||
@@ -104,6 +107,9 @@
|
||||
/* Define if we have stdint.h */
|
||||
#cmakedefine HAVE_STDINT_H
|
||||
|
||||
/* Define if we have stdalign.h */
|
||||
#cmakedefine HAVE_STDALIGN_H
|
||||
|
||||
/* Define if we have windows.h */
|
||||
#cmakedefine HAVE_WINDOWS_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user