Skip to content

Commit 482fe9e

Browse files
samitolvanenGerrit Code Review
authored and
Gerrit Code Review
committed
Merge "fec: enable building on Mac"
2 parents 3625af9 + 0403024 commit 482fe9e

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed

libfec/Android.mk

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ LOCAL_STATIC_LIBRARIES := \
3838
$(common_static_libraries)
3939
include $(BUILD_STATIC_LIBRARY)
4040

41-
ifeq ($(HOST_OS),linux)
42-
4341
include $(CLEAR_VARS)
4442
LOCAL_CFLAGS := $(common_cflags) -D_GNU_SOURCE -DFEC_NO_KLOG
4543
LOCAL_C_INCLUDES := $(common_c_includes)
4644
LOCAL_CLANG := true
45+
ifeq ($(HOST_OS),linux)
4746
LOCAL_SANITIZE := integer
47+
endif
4848
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
4949
LOCAL_MODULE := libfec_host
5050
LOCAL_SRC_FILES := $(common_src_files)
@@ -55,6 +55,4 @@ LOCAL_STATIC_LIBRARIES := \
5555
$(common_static_libraries)
5656
include $(BUILD_HOST_STATIC_LIBRARY)
5757

58-
endif # HOST_OS == linux
59-
6058
include $(LOCAL_PATH)/test/Android.mk

libfec/fec_open.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include <linux/fs.h>
1817
#include <stdlib.h>
1918
#include <sys/ioctl.h>
2019
#include <sys/stat.h>
@@ -24,6 +23,14 @@ extern "C" {
2423
#include <ext4_sb.h>
2524
}
2625

26+
#if defined(__linux__)
27+
#include <linux/fs.h>
28+
#elif defined(__APPLE__)
29+
#include <sys/disk.h>
30+
#define BLKGETSIZE64 DKIOCGETBLOCKCOUNT
31+
#define fdatasync(fd) fcntl((fd), F_FULLFSYNC)
32+
#endif
33+
2734
#include "fec_private.h"
2835

2936
/* used by `find_offset'; returns metadata size for a file size `size' and

libfec/fec_private.h

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <unordered_map>
3232
#include <vector>
3333

34+
#include <utils/Compat.h>
3435
#include <mincrypt/rsa.h>
3536
#include <openssl/sha.h>
3637
#include <fec/io.h>

verity/fec/Android.mk

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
LOCAL_PATH:= $(call my-dir)
22

3-
ifeq ($(HOST_OS),linux)
4-
53
include $(CLEAR_VARS)
64
LOCAL_CLANG := true
5+
ifeq ($(HOST_OS),linux)
76
LOCAL_SANITIZE := integer
7+
endif
88
LOCAL_MODULE := fec
99
LOCAL_SRC_FILES := main.cpp image.cpp
1010
LOCAL_MODULE_TAGS := optional
@@ -21,8 +21,6 @@ LOCAL_CFLAGS += -Wall -Werror -O3
2121
LOCAL_C_INCLUDES += external/fec
2222
include $(BUILD_HOST_EXECUTABLE)
2323

24-
endif # HOST_OS == linux
25-
2624
include $(CLEAR_VARS)
2725
LOCAL_CLANG := true
2826
LOCAL_SANITIZE := integer

verity/fec/image.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ extern "C" {
2626
#include <errno.h>
2727
#include <fcntl.h>
2828
#include <getopt.h>
29-
#include <linux/fs.h>
3029
#include <openssl/sha.h>
3130
#include <pthread.h>
3231
#include <stdbool.h>
@@ -39,6 +38,14 @@ extern "C" {
3938
#endif
4039
#include "image.h"
4140

41+
#if defined(__linux__)
42+
#include <linux/fs.h>
43+
#elif defined(__APPLE__)
44+
#include <sys/disk.h>
45+
#define BLKGETSIZE64 DKIOCGETBLOCKCOUNT
46+
#define O_LARGEFILE 0
47+
#endif
48+
4249
void image_init(image *ctx)
4350
{
4451
memset(ctx, 0, sizeof(*ctx));

verity/fec/image.h

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef __FEC_H__
1818
#define __FEC_H__
1919

20+
#include <utils/Compat.h>
2021
#include <fec/io.h>
2122
#include <fec/ecc.h>
2223

0 commit comments

Comments
 (0)