aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c5
-rw-r--r--Alc/ALu.c16
-rw-r--r--Alc/cpu_caps.h8
-rw-r--r--Alc/fpu_modes.h7
-rw-r--r--Alc/helpers.cpp (renamed from Alc/helpers.c)51
5 files changed, 50 insertions, 37 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index ae55e9b4..a483c94f 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1589,6 +1589,11 @@ extern inline void UnlockBufferList(ALCdevice *device);
extern inline ALsizei FrameSizeFromUserFmt(enum UserFmtChannels chans, enum UserFmtType type);
extern inline ALsizei FrameSizeFromFmt(enum FmtChannels chans, enum FmtType type);
+extern inline void alstr_reset(al_string *str);
+extern inline size_t alstr_length(const_al_string str);
+extern inline ALboolean alstr_empty(const_al_string str);
+extern inline const al_string_char_type *alstr_get_cstr(const_al_string str);
+
/* ALCcontext_DeferUpdates
*
diff --git a/Alc/ALu.c b/Alc/ALu.c
index ee3ed68f..b6ea504a 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -49,6 +49,22 @@
#include "backends/base.h"
+extern inline ALuint NextPowerOf2(ALuint value);
+extern inline size_t RoundUp(size_t value, size_t r);
+extern inline ALint fastf2i(ALfloat f);
+extern inline int float2int(float f);
+extern inline float fast_roundf(float f);
+#ifndef __GNUC__
+#if defined(HAVE_BITSCANFORWARD64_INTRINSIC)
+extern inline int msvc64_ctz64(ALuint64 v);
+#elif defined(HAVE_BITSCANFORWARD_INTRINSIC)
+extern inline int msvc_ctz64(ALuint64 v);
+#else
+extern inline int fallback_popcnt64(ALuint64 v);
+extern inline int fallback_ctz64(ALuint64 value);
+#endif
+#endif
+
extern inline ALfloat minf(ALfloat a, ALfloat b);
extern inline ALfloat maxf(ALfloat a, ALfloat b);
extern inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max);
diff --git a/Alc/cpu_caps.h b/Alc/cpu_caps.h
index 328d470e..1d867f37 100644
--- a/Alc/cpu_caps.h
+++ b/Alc/cpu_caps.h
@@ -1,6 +1,10 @@
#ifndef CPU_CAPS_H
#define CPU_CAPS_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern int CPUCapFlags;
enum {
CPU_CAP_SSE = 1<<0,
@@ -12,4 +16,8 @@ enum {
void FillCPUCaps(int capfilter);
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
#endif /* CPU_CAPS_H */
diff --git a/Alc/fpu_modes.h b/Alc/fpu_modes.h
index eb305967..e8858ad9 100644
--- a/Alc/fpu_modes.h
+++ b/Alc/fpu_modes.h
@@ -5,6 +5,9 @@
#include <fenv.h>
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
typedef struct FPUCtl {
#if defined(__GNUC__) && defined(HAVE_SSE)
@@ -31,4 +34,8 @@ void RestoreFPUMode(const FPUCtl *ctl);
#endif
#define LEAVE_MIXER_MODE() RestoreFPUMode(&_oldMode)
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
#endif /* FPU_MODES_H */
diff --git a/Alc/helpers.c b/Alc/helpers.cpp
index 064e03f5..abd010e6 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.cpp
@@ -121,23 +121,6 @@ DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_GUID, 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x
#include "threads.h"
-extern inline ALuint NextPowerOf2(ALuint value);
-extern inline size_t RoundUp(size_t value, size_t r);
-extern inline ALint fastf2i(ALfloat f);
-extern inline int float2int(float f);
-extern inline float fast_roundf(float f);
-#ifndef __GNUC__
-#if defined(HAVE_BITSCANFORWARD64_INTRINSIC)
-extern inline int msvc64_ctz64(ALuint64 v);
-#elif defined(HAVE_BITSCANFORWARD_INTRINSIC)
-extern inline int msvc_ctz64(ALuint64 v);
-#else
-extern inline int fallback_popcnt64(ALuint64 v);
-extern inline int fallback_ctz64(ALuint64 value);
-#endif
-#endif
-
-
#if defined(HAVE_GCC_GET_CPUID) && (defined(__i386__) || defined(__x86_64__) || \
defined(_M_IX86) || defined(_M_X64))
typedef unsigned int reg_type;
@@ -346,12 +329,12 @@ void GetProcBinary(al_string *path, al_string *fname)
DWORD len;
pathlen = 256;
- pathname = malloc(pathlen * sizeof(pathname[0]));
+ pathname = static_cast<WCHAR*>(malloc(pathlen * sizeof(pathname[0])));
while(pathlen > 0 && (len=GetModuleFileNameW(NULL, pathname, pathlen)) == pathlen)
{
free(pathname);
pathlen <<= 1;
- pathname = malloc(pathlen * sizeof(pathname[0]));
+ pathname = static_cast<WCHAR*>(malloc(pathlen * sizeof(pathname[0])));
}
if(len == 0)
{
@@ -395,7 +378,7 @@ static WCHAR *FromUTF8(const char *str)
if((len=MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0)) > 0)
{
- out = calloc(sizeof(WCHAR), len);
+ out = static_cast<WCHAR*>(calloc(sizeof(WCHAR), len));
MultiByteToWideChar(CP_UTF8, 0, str, -1, out, len);
}
return out;
@@ -418,14 +401,13 @@ void *LoadLib(const char *name)
return hdl;
}
void CloseLib(void *handle)
-{ FreeLibrary((HANDLE)handle); }
+{ FreeLibrary(reinterpret_cast<HMODULE>(handle)); }
void *GetSymbol(void *handle, const char *name)
{
void *ret;
- ret = (void*)GetProcAddress((HANDLE)handle, name);
- if(ret == NULL)
- ERR("Failed to load %s\n", name);
+ ret = reinterpret_cast<void*>(GetProcAddress(reinterpret_cast<HMODULE>(handle), name));
+ if(!ret) ERR("Failed to load %s\n", name);
return ret;
}
@@ -502,7 +484,7 @@ vector_al_string SearchDataFiles(const char *ext, const char *subdir)
vector_al_string results = VECTOR_INIT_STATIC();
size_t i;
- while(ATOMIC_EXCHANGE_SEQ(&search_lock, 1) == 1)
+ while(ATOMIC_EXCHANGE_SEQ(&search_lock, 1u) == 1u)
althrd_yield();
/* If the path is absolute, use it directly. */
@@ -573,7 +555,7 @@ vector_al_string SearchDataFiles(const char *ext, const char *subdir)
alstr_reset(&path);
}
- ATOMIC_STORE_SEQ(&search_lock, 0);
+ ATOMIC_STORE_SEQ(&search_lock, 0u);
return results;
}
@@ -623,7 +605,7 @@ void GetProcBinary(al_string *path, al_string *fname)
ssize_t len;
pathlen = 256;
- pathname = malloc(pathlen);
+ pathname = static_cast<char*>(malloc(pathlen));
selfname = "/proc/self/exe";
len = readlink(selfname, pathname, pathlen);
@@ -647,7 +629,7 @@ void GetProcBinary(al_string *path, al_string *fname)
{
free(pathname);
pathlen <<= 1;
- pathname = malloc(pathlen);
+ pathname = static_cast<char*>(malloc(pathlen));
len = readlink(selfname, pathname, pathlen);
}
if(len <= 0)
@@ -770,7 +752,7 @@ vector_al_string SearchDataFiles(const char *ext, const char *subdir)
static RefCount search_lock;
vector_al_string results = VECTOR_INIT_STATIC();
- while(ATOMIC_EXCHANGE_SEQ(&search_lock, 1) == 1)
+ while(ATOMIC_EXCHANGE_SEQ(&search_lock, 1u) == 1u)
althrd_yield();
if(subdir[0] == '/')
@@ -786,7 +768,7 @@ vector_al_string SearchDataFiles(const char *ext, const char *subdir)
else
{
size_t cwdlen = 256;
- char *cwdbuf = malloc(cwdlen);
+ char *cwdbuf = static_cast<char*>(malloc(cwdlen));
while(!getcwd(cwdbuf, cwdlen))
{
free(cwdbuf);
@@ -794,7 +776,7 @@ vector_al_string SearchDataFiles(const char *ext, const char *subdir)
if(errno != ERANGE)
break;
cwdlen <<= 1;
- cwdbuf = malloc(cwdlen);
+ cwdbuf = static_cast<char*>(malloc(cwdlen));
}
if(!cwdbuf)
DirectorySearch(".", ext, &results);
@@ -856,7 +838,7 @@ vector_al_string SearchDataFiles(const char *ext, const char *subdir)
alstr_reset(&path);
}
- ATOMIC_STORE_SEQ(&search_lock, 0);
+ ATOMIC_STORE_SEQ(&search_lock, 0u);
return results;
}
@@ -889,11 +871,6 @@ void SetRTPriority(void)
}
-extern inline void alstr_reset(al_string *str);
-extern inline size_t alstr_length(const_al_string str);
-extern inline ALboolean alstr_empty(const_al_string str);
-extern inline const al_string_char_type *alstr_get_cstr(const_al_string str);
-
void alstr_clear(al_string *str)
{
if(!alstr_empty(*str))