Skip to content
Permalink
Browse files

Merge pull request #26 from bpowers/musl-support

mallocheap: on linux, use <malloc.h> for malloc_usable_size
  • Loading branch information...
emeryberger committed Oct 18, 2019
2 parents 5808161 + ab07751 commit 364bb7d2519525a3faf0e7607d2e2da2255928df
Showing with 12 additions and 6 deletions.
  1. +2 −0 heaps/top/mallocheap.h
  2. +4 −0 heaps/utility/localmallocheap.h
  3. +6 −6 utility/tprintf.h
@@ -33,6 +33,8 @@
extern "C" size_t malloc_usable_size (void *);
#elif defined(__APPLE__)
#include <malloc/malloc.h>
#elif defined(__linux__)
#include <malloc.h>
#else
extern "C" size_t malloc_usable_size (void *) throw ();
#endif
@@ -38,6 +38,10 @@

#if defined(__SVR4)
extern "C" size_t malloc_usable_size (void *);
#elif defined(__APPLE__)
#include <malloc/malloc.h>
#elif defined(__linux__)
#include <malloc.h>
#else
extern "C" size_t malloc_usable_size (void *) throw ();
#endif
@@ -78,30 +78,30 @@ namespace tprintf {
inline void writeval(double n) {
char buf[MAXBUF];
int len = ftoa(buf, n);
write(FD, buf, len);
auto _ __attribute__((unused)) = write(FD, buf, len);
}

inline void writeval(const char * str) {
write(FD, str, strlen(str));
auto _ __attribute__((unused)) = write(FD, str, strlen(str));
}

inline void writeval(const char c) {
char buf[1];
buf[0] = c;
write(FD, buf, 1);
auto _ __attribute__((unused)) = write(FD, buf, 1);
}

inline void writeval(uint64_t n) {
char buf[MAXBUF];
int len = itoa(buf, n);
write(FD, buf, len);
auto _ __attribute__((unused)) = write(FD, buf, len);
}

template <class T>
inline void writeval(T n) {
char buf[MAXBUF];
int len = itoa(buf, n);
write(FD, buf, len);
auto _ __attribute__((unused)) = write(FD, buf, len);
}

inline void tprintf(const char* format) // base function
@@ -127,7 +127,7 @@ namespace tprintf {
}
}

};
}


#endif

0 comments on commit 364bb7d

Please sign in to comment.
You can’t perform that action at this time.