aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2016-05-20 09:42:27 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2016-05-20 09:42:27 +0200
commit530240668ac7470b35b3a3f904324d7a2b87bb46 (patch)
tree19dd2f708bf4f07c426af02deb0a6fe8c34cfddc
parentc46b751fb7ea9fa9e34f548b30ce2b884ac5c05f (diff)
downloadalpine-conf-530240668ac7470b35b3a3f904324d7a2b87bb46.tar.bz2
alpine-conf-530240668ac7470b35b3a3f904324d7a2b87bb46.tar.xz
uniso: fix build on OSX
-rw-r--r--uniso.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/uniso.c b/uniso.c
index 7e1adb6..75e0e69 100644
--- a/uniso.c
+++ b/uniso.c
@@ -24,15 +24,26 @@
#include <stdio.h>
#include <fcntl.h>
#include <wchar.h>
-#include <malloc.h>
#include <unistd.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#include <endian.h>
#include <sys/stat.h>
#include <sys/types.h>
+#if defined(__linux__)
+# include <malloc.h>
+# include <endian.h>
+#elif defined(__APPLE__)
+# include <libkern/OSByteOrder.h>
+# define be16toh(x) OSSwapBigToHostInt16(x)
+#endif
+
+#ifndef EMEDIUMTYPE
+#define EMEDIUMTYPE EILSEQ
+#endif
+
+
/**/
#ifndef container_of
@@ -215,6 +226,7 @@ struct uniso_context {
unsigned char *tmpbuf;
};
+#if defined(__linux__)
static int do_splice(struct uniso_context *ctx, int to_fd, int bytes)
{
int r, left;
@@ -230,6 +242,9 @@ static int do_splice(struct uniso_context *ctx, int to_fd, int bytes)
return bytes;
}
+#else
+#define do_splice(ctx,to_fd,bytes) (-1)
+#endif
static int do_read(struct uniso_context *ctx, unsigned char *buf, int bytes)
{