~mcf/samurai

ref: edeec43d638c826d9e446917f97e95151988e0e0 samurai/log.c -rw-r--r-- 3.2 KiB
log: Use fgets instead of getline
log: Make output file line-buffered

This way, if samu is interrupted during build, it is less likely
to write a partial log record.
Improve some error messages slightly
Simplify error handling

We were using our own implementations err.h anyway, and we don't
necessarily need to match the same interface.
Don't recalculate string length when we already have it
log: Rewrite on read failure
deps, log: Only create during rewrite
deps, log: Improve some error messages
Avoid POSIX-specific *at functions
log: Free line buffer when finished
Use MTIME_MISSING instead of hash to detect presence of node in .ninja_log

Take this opportunity to give a better explain message for a missing
entry.
Move definition of _POSIX_C_SOURCE to the files that require it

Now that we don't use `struct timespec` in `struct node`, we don't need
it for every file.
Store time internally as nanoseconds in an int64_t

This is what ninja does, and should last until around 2262, which should
be good enough.

In the next release, ninja will also switch to storing nanoseconds in
.ninja_log and .ninja_deps, and sets us up to easily make that change as
well.
log: Fix recompact condition
Move _POSIX_C_SOURCE definition to Makefile/build.ninja

glibc requires _POSIX_C_SOURCE (or -std=c11) to expose struct timespec from
time.h. So, now that we need it for all source files, just define it on the
command-line.
Avoid err.h for POSIX conformance
log: Close old logfile in loginit in case of manifest rebuild
Rename lognode -> logrecord
Fix error message for loginit
Implement restat support
Next