From eca86489e422f00d96ce59a5c53fa45bdcea593e Mon Sep 17 00:00:00 2001
From: Chris Robinson <chris.kcat@gmail.com>
Date: Mon, 22 May 2023 02:25:30 -0700
Subject: Make the API functions noexcept

Only relevant for C++, but these functions can't throw as it's a C-based API.
Letting the compiler know that helps improve code generation. Extension
callbacks must also not let exceptions leave the callback, or else Bad Things
can happen.

The macro AL_DISABLE_NOEXCEPT may be defined before including the headers to
not mark functions as noexcept, but this should only be done if the caller
can't otherwise be fixed.
---
 al/state.cpp | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

(limited to 'al/state.cpp')

diff --git a/al/state.cpp b/al/state.cpp
index 60d18818..2b6c1bb2 100644
--- a/al/state.cpp
+++ b/al/state.cpp
@@ -294,14 +294,12 @@ inline void UpdateProps(ALCcontext *context)
 /* WARNING: Non-standard export! Not part of any extension, or exposed in the
  * alcFunctions list.
  */
-AL_API const ALchar* AL_APIENTRY alsoft_get_version(void)
-START_API_FUNC
+AL_API const ALchar* AL_APIENTRY alsoft_get_version(void) noexcept
 {
     static const auto spoof = al::getenv("ALSOFT_SPOOF_VERSION");
     if(spoof) return spoof->c_str();
     return ALSOFT_VERSION;
 }
-END_API_FUNC
 
 
 FORCE_ALIGN void AL_APIENTRY alEnableDirect(ALCcontext *context, ALenum capability) noexcept
@@ -380,14 +378,14 @@ FORCE_ALIGN ALboolean AL_APIENTRY alIsEnabledDirect(ALCcontext *context, ALenum
 }
 
 #define DECL_GETFUNC(R, Name, Ext)                                            \
-AL_API R AL_APIENTRY Name##Ext(ALenum pname) START_API_FUNC                   \
+AL_API R AL_APIENTRY Name##Ext(ALenum pname) noexcept                         \
 {                                                                             \
     R value{};                                                                \
     auto context = GetContextRef();                                           \
     if(!context) UNLIKELY return value;                                       \
     Name##vDirect##Ext(GetContextRef().get(), pname, &value);                 \
     return value;                                                             \
-} END_API_FUNC                                                                \
+}                                                                             \
 FORCE_ALIGN R AL_APIENTRY Name##Direct##Ext(ALCcontext *context, ALenum pname) noexcept \
 {                                                                             \
     R value{};                                                                \
@@ -614,7 +612,7 @@ AL_API DECL_FUNCEXT(void, alDeferUpdates,SOFT)
 AL_API DECL_FUNCEXT(void, alProcessUpdates,SOFT)
 AL_API DECL_FUNCEXT2(const ALchar*, alGetStringi,SOFT, ALenum,ALsizei)
 
-AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value) START_API_FUNC
+AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value) noexcept
 {
     ContextRef context{GetContextRef()};
     if(!context) UNLIKELY return;
@@ -633,7 +631,7 @@ AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value) START_API_FUNC
         context->mDopplerVelocity = value;
         UpdateProps(context.get());
     }
-} END_API_FUNC
+}
 
 
 void UpdateContextProps(ALCcontext *context)
-- 
cgit v1.2.3