UpstandingHackers / hammer

Parser combinators for binary formats, in C. Yes, in C. What? Don't look at me like that.
GNU General Public License v2.0
430 stars 40 forks source link

Platform compilation improvement (windows port) #138

Closed uucidl closed 8 years ago

uucidl commented 8 years ago

Here is a pull request which moves timing primitives into the platform layer & makes system_allocator.c compile with MSVC.

Timing primitive

The implementation is exactly what it was in benchmark.c and got moved to platform_bsdlike.c (TODO included, about using posix timers)

An implementation for win32 is included, using QueryPerformanceCounter

Finally I normalized tabs to spaces in benchmark.c

System Allocator

We also remove some of the void* arithmetics in system_allocator.c, which allow building with MSVC, and change the system_allocator to store block sizes only when DEBUG__MEMFILL is enabled.

@thequux you introduced the memfill mechanism, can you have a look at my changes?

String Formatting

Since asprintf/vasprintf do not exist in the C standard, we provide an implementation for win32 inside platform_win32.c