util: Implement os_read_file for Windows
authorMichael Tang <tangm@microsoft.com>
Mon, 21 Dec 2020 22:57:48 +0000 (14:57 -0800)
committerMichael Tang <tangm@microsoft.com>
Tue, 22 Dec 2020 21:28:21 +0000 (13:28 -0800)
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8043>

src/util/os_file.c

index c5970dd..9fd3f68 100644 (file)
@@ -79,16 +79,12 @@ os_dupfd_cloexec(int fd)
 }
 #endif
 
-
-#if DETECT_OS_LINUX
-
 #include <fcntl.h>
 #include <sys/stat.h>
-#include <sys/syscall.h>
-#include <unistd.h>
 
-/* copied from <linux/kcmp.h> */
-#define KCMP_FILE 0
+#if DETECT_OS_WINDOWS
+typedef ptrdiff_t ssize_t;
+#endif
 
 static ssize_t
 readN(int fd, char *buf, size_t len)
@@ -185,6 +181,14 @@ os_read_file(const char *filename, size_t *size)
    return buf;
 }
 
+#if DETECT_OS_LINUX
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+/* copied from <linux/kcmp.h> */
+#define KCMP_FILE 0
+
 int
 os_same_file_description(int fd1, int fd2)
 {
@@ -199,15 +203,6 @@ os_same_file_description(int fd1, int fd2)
 
 #else
 
-#include "u_debug.h"
-
-char *
-os_read_file(const char *filename, size_t *size)
-{
-   errno = -ENOSYS;
-   return NULL;
-}
-
 int
 os_same_file_description(int fd1, int fd2)
 {