Skip to content

Commit

Permalink
Merge pull request #26 from bpowers/musl-support
Browse files Browse the repository at this point in the history
mallocheap: on linux, use <malloc.h> for malloc_usable_size
  • Loading branch information
emeryberger committed Oct 18, 2019
2 parents 5808161 + ab07751 commit 364bb7d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions heaps/top/mallocheap.h
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions heaps/utility/localmallocheap.h
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions utility/tprintf.h
Expand Up @@ -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
Expand All @@ -127,7 +127,7 @@ namespace tprintf {
}
}

};
}


#endif

0 comments on commit 364bb7d

Please sign in to comment.