From b8435c6523d9377f04d5e21629f3dc68b8865016 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 23 Nov 2020 15:31:45 -0800
Subject: [PATCH] heaptrack_preload: Make noexcept attribute conditional

musl does not define these functions with noexcept and hence compiler
complains about them

Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 src/track/heaptrack_preload.cpp | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/track/heaptrack_preload.cpp b/src/track/heaptrack_preload.cpp
index 63110ce..ee85331 100644
--- a/src/track/heaptrack_preload.cpp
+++ b/src/track/heaptrack_preload.cpp
@@ -171,11 +171,17 @@ void init()
 }
 }
 
+#ifdef __GLIBC__
+#define NOEXECPT noexcept
+#else
+#define NOEXECPT
+#endif
+
 extern "C" {
 
 /// TODO: memalign, pvalloc, ...?
 
-void* malloc(size_t size) noexcept
+void* malloc(size_t size) NOEXECPT
 {
     if (!hooks::malloc) {
         hooks::init();
@@ -186,7 +192,7 @@ void* malloc(size_t size) noexcept
     return ptr;
 }
 
-void free(void* ptr) noexcept
+void free(void* ptr) NOEXECPT
 {
     if (!hooks::free) {
         hooks::init();
@@ -204,7 +210,7 @@ void free(void* ptr) noexcept
     hooks::free(ptr);
 }
 
-void* realloc(void* ptr, size_t size) noexcept
+void* realloc(void* ptr, size_t size) NOEXECPT
 {
     if (!hooks::realloc) {
         hooks::init();
@@ -219,7 +225,7 @@ void* realloc(void* ptr, size_t size) noexcept
     return ret;
 }
 
-void* calloc(size_t num, size_t size) noexcept
+void* calloc(size_t num, size_t size) NOEXECPT
 {
     if (!hooks::calloc) {
         hooks::init();
@@ -235,7 +241,7 @@ void* calloc(size_t num, size_t size) noexcept
 }
 
 #if HAVE_CFREE
-void cfree(void* ptr) noexcept
+void cfree(void* ptr) NOEXECPT
 {
     if (!hooks::cfree) {
         hooks::init();
@@ -252,7 +258,7 @@ void cfree(void* ptr) noexcept
 }
 #endif
 
-int posix_memalign(void** memptr, size_t alignment, size_t size) noexcept
+int posix_memalign(void** memptr, size_t alignment, size_t size) NOEXECPT
 {
     if (!hooks::posix_memalign) {
         hooks::init();
@@ -268,7 +274,7 @@ int posix_memalign(void** memptr, size_t alignment, size_t size) noexcept
 }
 
 #if HAVE_ALIGNED_ALLOC
-void* aligned_alloc(size_t alignment, size_t size) noexcept
+void* aligned_alloc(size_t alignment, size_t size) NOEXECPT
 {
     if (!hooks::aligned_alloc) {
         hooks::init();
@@ -285,7 +291,7 @@ void* aligned_alloc(size_t alignment, size_t size) noexcept
 #endif
 
 #if HAVE_VALLOC
-void* valloc(size_t size) noexcept
+void* valloc(size_t size) NOEXECPT
 {
     if (!hooks::valloc) {
         hooks::init();
@@ -301,7 +307,7 @@ void* valloc(size_t size) noexcept
 }
 #endif
 
-void* dlopen(const char* filename, int flag) noexcept
+void* dlopen(const char* filename, int flag) NOEXECPT
 {
     if (!hooks::dlopen) {
         hooks::init();
@@ -316,7 +322,7 @@ void* dlopen(const char* filename, int flag) noexcept
     return ret;
 }
 
-int dlclose(void* handle) noexcept
+int dlclose(void* handle) NOEXECPT
 {
     if (!hooks::dlclose) {
         hooks::init();
