Use O_SYNC instead of O_DSYNC on FreeBSD. This fixes build on FreeBSD 9-10.
One more file installed on FreeBSD.
Define LLONG_MAX for FreeBSD 9-10.
Fix build on FreeBSD 9-10:
- malloc.h breaks actively on FreeBSD for a long time, use stdlib.h as suggested;
- treat FreeBSD uniformly with other BSD systems.
Stop using malloc.h, it is deliberately broken on FreeBSD.
FreeBSD requires additional header file to get access to history.