# reason: fix sources to work correctly with musl

--- a/src/track/heaptrack_inject.cpp
+++ b/src/track/heaptrack_inject.cpp
@@ -27,6 +27,7 @@
 #include <link.h>
 #include <malloc.h>
 #include <unistd.h>
+#include <dlfcn.h>
 
 #include <sys/mman.h>
 
--- a/src/track/libheaptrack.cpp
+++ b/src/track/libheaptrack.cpp
@@ -72,7 +72,7 @@
     return chrono::duration_cast<chrono::milliseconds>(clock::now() - startTime());
 }
 
-__pid_t gettid()
+pid_t gettid()
 {
     return syscall(SYS_gettid);
 }

--- a/src/track/heaptrack_inject.cpp
+++ b/src/track/heaptrack_inject.cpp
@@ -38,9 +38,10 @@
  * @brief Experimental support for symbol overloading after runtime injection.
  */
 
-#if __WORDSIZE == 64
+#include <limits.h>
+#if ULONG_MAX == 0xffffffffffffffff
 #define ELF_R_SYM(i) ELF64_R_SYM(i)
-#elif __WORDSIZE == 32
+#elif ULONG_MAX == 0xffffffff
 #define ELF_R_SYM(i) ELF32_R_SYM(i)
 #else
 #error unsupported word size

# simplify stdint.h include which failed on musl due to obscure assumptions
--- a/3rdparty/libbacktrace/backtrace.h
+++ b/3rdparty/libbacktrace/backtrace.h
@@ -36,24 +36,8 @@
 #include <stddef.h>
 #include <stdio.h>
 
-/* We want to get a definition for uintptr_t, but we still care about
-   systems that don't have <stdint.h>.  */
-#if defined(__GLIBC__) && __GLIBC__ >= 2
-
-#include <stdint.h>
-
-#elif defined(HAVE_STDINT_H)
-
 #include <stdint.h>
 
-#else
-
-/* Systems that don't have <stdint.h> must provide gstdint.h, e.g.,
-   from GCC_HEADER_STDINT in configure.ac.  */
-#include "gstdint.h"
-
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
