From 0d0e118f513f32524ead942d49a4c5fb25f0d022 Mon Sep 17 00:00:00 2001 From: Stanislav Paskalev Date: Sat, 15 Jun 2024 02:08:42 +0300 Subject: [PATCH] Support compiling with Pelles C (#109) * Support compiling with Pelles C (#108) * Update bench.c to avoid errors from strict c++ compilers * Update .gitignore --- .gitignore | 8 +++++++- README.md | 2 +- bench.c | 4 ++-- buddy_alloc.h | 11 +++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 56c1ec3..e8f5658 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,10 @@ dkms.conf *.static # Perf -bench \ No newline at end of file +bench + +# cmake output dir +out/* + +# visual studio metadata +.vs/* diff --git a/README.md b/README.md index b37d1c5..48ac597 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ This is a buddy memory allocator that might be suitable for use in applications - 100% line and branch test coverage - Supports 32-bit and 64-bit platforms - Endian-agnostic, works on both LE and BE -- Compiles with GCC, Clang and MSVC +- Compiles with GCC, Clang, MSVC and Pelles C ## Usage diff --git a/bench.c b/bench.c index 2e33f43..6bf43a8 100644 --- a/bench.c +++ b/bench.c @@ -22,8 +22,8 @@ int main() { setvbuf(stdout, NULL, _IONBF, 0); size_t arena_size = 1 << 30; - unsigned char *buddy_buf = malloc(buddy_sizeof_alignment(arena_size, 64)); - unsigned char *data_buf = malloc(arena_size); + unsigned char *buddy_buf = (unsigned char *) malloc(buddy_sizeof_alignment(arena_size, 64)); + unsigned char *data_buf = (unsigned char *) malloc(arena_size); struct buddy *buddy = buddy_init_alignment(buddy_buf, data_buf, arena_size, 64); double total = 0; diff --git a/buddy_alloc.h b/buddy_alloc.h index 1e827ce..b42c4c4 100644 --- a/buddy_alloc.h +++ b/buddy_alloc.h @@ -187,6 +187,17 @@ typedef signed long ssize_t; #define _SSIZE_T_DEFINED #endif +/* Support compiling with Pelles C */ +#if defined(__POCC__) && defined(__POCC_TARGET__) +#if __POCC_TARGET__ == 3 +typedef signed long long ssize_t; +#elif __POCC_TARGET__ == 1 +typedef signed long ssize_t; +#else +#error Uknown POCC target +#endif +#endif + #ifndef BUDDY_PRINTF #define BUDDY_PRINTF printf #endif