Android-x86
Fork

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-efivar: コミット

external/efivar


コミットメタ情報

リビジョンac61c4cc65b1eab42a3c3e17e91f5e52f8d9975f (tree)
日時2018-01-12 12:31:18
作者Chih-Wei Huang <cwhuang@linu...>
コミッターChih-Wei Huang

ログメッセージ

Android: inital porting of libefivar

The static library is linked by efibootmgr.

変更サマリ

差分

--- /dev/null
+++ b/src/Android.mk
@@ -0,0 +1,59 @@
1+#
2+# Copyright (C) 2018 The Android-x86 Open Source Project
3+#
4+# Licensed under the GNU Lesser General Public License Version 2.1.
5+# You may not use this file except in compliance with the License.
6+# You may obtain a copy of the License at
7+#
8+# https://www.gnu.org/licenses/lgpl-2.1.html
9+#
10+
11+LOCAL_PATH := $(call my-dir)
12+
13+include $(CLEAR_VARS)
14+
15+LOCAL_MODULE := makeguids
16+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
17+LOCAL_CFLAGS := -DEFIVAR_BUILD_ENVIRONMENT
18+LOCAL_SRC_FILES := guid.c makeguids.c
19+LOCAL_LDLIBS := -ldl
20+include $(BUILD_HOST_EXECUTABLE)
21+
22+include $(CLEAR_VARS)
23+
24+LOCAL_MODULE := libefivar
25+LOCAL_MODULE_CLASS := STATIC_LIBRARIES
26+LIBEFIBOOT_SOURCES := \
27+ crc32.c \
28+ creator.c \
29+ disk.c \
30+ gpt.c \
31+ linux.c \
32+ loadopt.c
33+
34+LIBEFIVAR_SOURCES := \
35+ dp.c \
36+ dp-acpi.c \
37+ dp-hw.c \
38+ dp-media.c \
39+ dp-message.c \
40+ efivarfs.c \
41+ error.c \
42+ export.c \
43+ guid.c \
44+ guids.S \
45+ lib.c \
46+ vars.c
47+
48+LOCAL_SRC_FILES := $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES)
49+LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -std=gnu11
50+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
51+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES) $(LOCAL_C_INCLUDES)/efivar $(local-generated-sources-dir)
52+LIBEFIVAR_GUIDS_H := $(local-generated-sources-dir)/efivar/efivar-guids.h
53+LOCAL_GENERATED_SOURCES := $(LIBEFIVAR_GUIDS_H) $(local-generated-sources-dir)/guid-symbols.c
54+$(LIBEFIVAR_GUIDS_H): PRIVATE_CUSTOM_TOOL = $^ $(addprefix $(dir $(@D)),guids.bin names.bin guid-symbols.c efivar/efivar-guids.h)
55+$(LIBEFIVAR_GUIDS_H): $(BUILD_OUT_EXECUTABLES)/makeguids $(LOCAL_PATH)/guids.txt
56+ $(transform-generated-source)
57+$(lastword $(LOCAL_GENERATED_SOURCES)): $(LIBEFIVAR_GUIDS_H)
58+
59+include $(BUILD_STATIC_LIBRARY)
--- a/src/efivar_endian.h
+++ b/src/efivar_endian.h
@@ -22,6 +22,12 @@
2222
2323 #include <endian.h>
2424
25+#ifdef __ANDROID__
26+#define __bswap_16 __swap16
27+#define __bswap_32 __swap32
28+#define __bswap_64 __swap64
29+#endif
30+
2531 #if __BYTE_ORDER == __LITTLE_ENDIAN
2632 #define cpu_to_le16(x) (x)
2733 #define cpu_to_le32(x) (x)
--- a/src/util.h
+++ b/src/util.h
@@ -217,6 +217,29 @@ get_sector_size(int filedes)
217217 return sector_size;
218218 }
219219
220+#ifdef __ANDROID__
221+#define strdupa(str) \
222+ ({ \
223+ size_t sz = strlen(str) + 1; \
224+ char *copy = alloca(sz); \
225+ if (copy != NULL) { \
226+ memcpy(copy, str, sz); \
227+ } \
228+ copy; \
229+ })
230+
231+#define strndupa(str, maxlen) \
232+ ({ \
233+ size_t len = strnlen(str, maxlen); \
234+ char *copy = alloca(len + 1); \
235+ if (copy != NULL) { \
236+ memcpy(copy, str, len); \
237+ copy[len] = '\0'; \
238+ } \
239+ copy; \
240+ })
241+#endif
242+
220243 #define asprintfa(str, fmt, args...) \
221244 ({ \
222245 char *_tmp = NULL; \
旧リポジトリブラウザで表示