summaryrefslogtreecommitdiff
path: root/libfec
diff options
context:
space:
mode:
authorSami Tolvanen <samitolvanen@google.com>2015-09-28 17:05:11 +0100
committerSami Tolvanen <samitolvanen@google.com>2015-09-29 13:27:30 +0100
commit0403024cd6763fff3a0118b15e68c0f7fe4766d5 (patch)
tree23743430e125723a3017f67d8e79542cebdc806d /libfec
parent3625af964efa97cc7163f88ff711e67fab57af23 (diff)
downloadextras-0403024cd6763fff3a0118b15e68c0f7fe4766d5.tar.gz
fec: enable building on Mac
Enable the host libfec and the fec tool to be built on Mac with the help of <utils/Compat.h>. Change-Id: I5e7c9fac11f4a00814bad92734e703ec8dc22dc9
Diffstat (limited to 'libfec')
-rw-r--r--libfec/Android.mk6
-rw-r--r--libfec/fec_open.cpp9
-rw-r--r--libfec/fec_private.h1
3 files changed, 11 insertions, 5 deletions
diff --git a/libfec/Android.mk b/libfec/Android.mk
index 4ca563e4..45fb19ec 100644
--- a/libfec/Android.mk
+++ b/libfec/Android.mk
@@ -38,13 +38,13 @@ LOCAL_STATIC_LIBRARIES := \
$(common_static_libraries)
include $(BUILD_STATIC_LIBRARY)
-ifeq ($(HOST_OS),linux)
-
include $(CLEAR_VARS)
LOCAL_CFLAGS := $(common_cflags) -D_GNU_SOURCE -DFEC_NO_KLOG
LOCAL_C_INCLUDES := $(common_c_includes)
LOCAL_CLANG := true
+ifeq ($(HOST_OS),linux)
LOCAL_SANITIZE := integer
+endif
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
LOCAL_MODULE := libfec_host
LOCAL_SRC_FILES := $(common_src_files)
@@ -55,6 +55,4 @@ LOCAL_STATIC_LIBRARIES := \
$(common_static_libraries)
include $(BUILD_HOST_STATIC_LIBRARY)
-endif # HOST_OS == linux
-
include $(LOCAL_PATH)/test/Android.mk
diff --git a/libfec/fec_open.cpp b/libfec/fec_open.cpp
index f25aa7fb..1923406f 100644
--- a/libfec/fec_open.cpp
+++ b/libfec/fec_open.cpp
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-#include <linux/fs.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
@@ -24,6 +23,14 @@ extern "C" {
#include <ext4_sb.h>
}
+#if defined(__linux__)
+ #include <linux/fs.h>
+#elif defined(__APPLE__)
+ #include <sys/disk.h>
+ #define BLKGETSIZE64 DKIOCGETBLOCKCOUNT
+ #define fdatasync(fd) fcntl((fd), F_FULLFSYNC)
+#endif
+
#include "fec_private.h"
/* used by `find_offset'; returns metadata size for a file size `size' and
diff --git a/libfec/fec_private.h b/libfec/fec_private.h
index fab81cfe..21758990 100644
--- a/libfec/fec_private.h
+++ b/libfec/fec_private.h
@@ -31,6 +31,7 @@
#include <unordered_map>
#include <vector>
+#include <utils/Compat.h>
#include <mincrypt/rsa.h>
#include <openssl/sha.h>
#include <fec/io.h>