helpers_fileio.c: fix fsync() check.
Both the _POSIX_FSYNC macro and the fsync() declaration are in
<unistd.h>. The current code works by accident on glibc courtesy of
transitive includes, but is broken in Android currently (mistakenly
assuming there is no fsync() because _POSIX_FSYNC isn't defined, merely
because <unistd.h> hasn't been included), and won't compile with Android's
C23 addition of call_once() to <stdlib.h> because _POSIX_FSYNC comes in
transitively via <limits.h> but without <unistd.h> for the fsync()
declaration.
Fix all of this by just including the right POSIX header file for both
the feature macro and the function declaration.
Change-Id: Ifd6eeba56cffabb6a37880c78ea21de4705308b5
Signed-off-by: Elliott Hughes <enh@google.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/90015
Original-Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/390
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Nico Huber <nico.h@gmx.de>
diff --git a/helpers_fileio.c b/helpers_fileio.c
index e3a4993..e292ff4 100644
--- a/helpers_fileio.c
+++ b/helpers_fileio.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <unistd.h>
#ifndef __LIBPAYLOAD__
#include <fcntl.h>