summaryrefslogtreecommitdiff
path: root/lib/avb/libavb/avb_util.h
diff options
context:
space:
mode:
authorfang hui <hui.fang@nxp.com>2017-04-27 14:50:03 +0800
committerfang hui <hui.fang@nxp.com>2017-04-27 15:16:25 +0800
commit71dc860a61a936eca242c2badaad8815b352905b (patch)
tree32469833d886b05dae2ddee032a74bb8d8081a7b /lib/avb/libavb/avb_util.h
parent4dc1d71d0da1d07913ef91e60f54338db70caa69 (diff)
downloadu-boot-imx-imx_v2015.04_brillo.zip
u-boot-imx-imx_v2015.04_brillo.tar.gz
u-boot-imx-imx_v2015.04_brillo.tar.bz2
MA-9530-2 [iot] Revet avb in ubootimx_v2015.04_brillo
Revert "libavb: upgrade avb" This reverts commit 94734eeca56e8d1b9f1baedf67e16cd0397fc178. Change-Id: I6eae3fa9579fb43fa6956c450011b230875d0a96
Diffstat (limited to 'lib/avb/libavb/avb_util.h')
-rw-r--r--lib/avb/libavb/avb_util.h113
1 files changed, 34 insertions, 79 deletions
diff --git a/lib/avb/libavb/avb_util.h b/lib/avb/libavb/avb_util.h
index 07c3258..d53be97 100644
--- a/lib/avb/libavb/avb_util.h
+++ b/lib/avb/libavb/avb_util.h
@@ -70,31 +70,23 @@ extern "C" {
*
* This has no effect unless AVB_ENABLE_DEBUG is defined.
*/
-#define avb_assert_aligned(addr) \
- avb_assert((((uintptr_t)addr) & (AVB_ALIGNMENT_SIZE - 1)) == 0)
+#define avb_assert_word_aligned(addr) \
+ avb_assert((((uintptr_t)addr) & (AVB_WORD_ALIGNMENT_SIZE - 1)) == 0)
#ifdef AVB_ENABLE_DEBUG
/* Print functions, used for diagnostics.
*
* These have no effect unless AVB_ENABLE_DEBUG is defined.
*/
-#define avb_debug(message) \
- do { \
- avb_printv(avb_basename(__FILE__), \
- ":", \
- AVB_TO_STRING(__LINE__), \
- ": DEBUG: ", \
- message, \
- NULL); \
+#define avb_debug(message) \
+ do { \
+ avb_print(__FILE__ ":" AVB_TO_STRING(__LINE__) ": DEBUG: "); \
+ avb_print(message); \
} while (0)
-#define avb_debugv(message, ...) \
- do { \
- avb_printv(avb_basename(__FILE__), \
- ":", \
- AVB_TO_STRING(__LINE__), \
- ": DEBUG: ", \
- message, \
- ##__VA_ARGS__); \
+#define avb_debugv(message, ...) \
+ do { \
+ avb_print(__FILE__ ":" AVB_TO_STRING(__LINE__) ": DEBUG: "); \
+ avb_printv(message, ##__VA_ARGS__); \
} while (0)
#else
#define avb_debug(message)
@@ -104,46 +96,30 @@ extern "C" {
/* Prints out a message. This is typically used if a runtime-error
* occurs.
*/
-#define avb_error(message) \
- do { \
- avb_printv(avb_basename(__FILE__), \
- ":", \
- AVB_TO_STRING(__LINE__), \
- ": ERROR: ", \
- message, \
- NULL); \
+#define avb_error(message) \
+ do { \
+ avb_print(__FILE__ ":" AVB_TO_STRING(__LINE__) ": ERROR: "); \
+ avb_print(message); \
} while (0)
-#define avb_errorv(message, ...) \
- do { \
- avb_printv(avb_basename(__FILE__), \
- ":", \
- AVB_TO_STRING(__LINE__), \
- ": ERROR: ", \
- message, \
- ##__VA_ARGS__); \
+#define avb_errorv(message, ...) \
+ do { \
+ avb_print(__FILE__ ":" AVB_TO_STRING(__LINE__) ": ERROR: "); \
+ avb_printv(message, ##__VA_ARGS__); \
} while (0)
/* Prints out a message and calls avb_abort().
*/
-#define avb_fatal(message) \
- do { \
- avb_printv(avb_basename(__FILE__), \
- ":", \
- AVB_TO_STRING(__LINE__), \
- ": FATAL: ", \
- message, \
- NULL); \
- avb_abort(); \
+#define avb_fatal(message) \
+ do { \
+ avb_print(__FILE__ ":" AVB_TO_STRING(__LINE__) ": FATAL: "); \
+ avb_print(message); \
+ avb_abort(); \
} while (0)
-#define avb_fatalv(message, ...) \
- do { \
- avb_printv(avb_basename(__FILE__), \
- ":", \
- AVB_TO_STRING(__LINE__), \
- ": FATAL: ", \
- message, \
- ##__VA_ARGS__); \
- avb_abort(); \
+#define avb_fatalv(message, ...) \
+ do { \
+ avb_print(__FILE__ ":" AVB_TO_STRING(__LINE__) ": FATAL: "); \
+ avb_printv(message, ##__VA_ARGS__); \
+ avb_abort(); \
} while (0)
/* Converts a 32-bit unsigned integer from big-endian to host byte order. */
@@ -168,8 +144,7 @@ uint64_t avb_htobe64(uint64_t in) AVB_ATTR_WARN_UNUSED_RESULT;
* Note that unlike avb_memcmp(), this only indicates inequality, not
* whether |s1| is less than or greater than |s2|.
*/
-int avb_safe_memcmp(const void* s1,
- const void* s2,
+int avb_safe_memcmp(const void* s1, const void* s2,
size_t n) AVB_ATTR_WARN_UNUSED_RESULT;
/* Adds |value_to_add| to |value| with overflow protection.
@@ -188,8 +163,7 @@ bool avb_safe_add_to(uint64_t* value,
*
* Returns false if the addition overflows, true otherwise.
*/
-bool avb_safe_add(uint64_t* out_result,
- uint64_t a,
+bool avb_safe_add(uint64_t* out_result, uint64_t a,
uint64_t b) AVB_ATTR_WARN_UNUSED_RESULT;
/* Checks if |num_bytes| data at |data| is a valid UTF-8
@@ -206,12 +180,8 @@ bool avb_validate_utf8(const uint8_t* data,
*
* Returns true if the operation succeeds, false otherwise.
*/
-bool avb_str_concat(char* buf,
- size_t buf_size,
- const char* str1,
- size_t str1_len,
- const char* str2,
- size_t str2_len);
+bool avb_str_concat(char* buf, size_t buf_size, const char* str1,
+ size_t str1_len, const char* str2, size_t str2_len);
/* Like avb_malloc_() but prints a error using avb_error() if memory
* allocation fails.
@@ -224,13 +194,6 @@ void* avb_calloc(size_t size) AVB_ATTR_WARN_UNUSED_RESULT;
/* Duplicates a NUL-terminated string. Returns NULL on OOM. */
char* avb_strdup(const char* str) AVB_ATTR_WARN_UNUSED_RESULT;
-/* Duplicates a NULL-terminated array of NUL-terminated strings by
- * concatenating them. The returned string will be
- * NUL-terminated. Returns NULL on OOM.
- */
-char* avb_strdupv(const char* str,
- ...) AVB_ATTR_WARN_UNUSED_RESULT AVB_ATTR_SENTINEL;
-
/* Finds the first occurrence of |needle| in the string |haystack|
* where both strings are NUL-terminated strings. The terminating NUL
* bytes are not compared.
@@ -249,27 +212,19 @@ const char* avb_strstr(const char* haystack,
* Returns NULL if not found, otherwise points into |strings| for the
* first occurrence of |str|.
*/
-const char* avb_strv_find_str(const char* const* strings,
- const char* str,
+const char* avb_strv_find_str(const char* const* strings, const char* str,
size_t str_size);
/* Replaces all occurrences of |search| with |replace| in |str|.
*
* Returns a newly allocated string or NULL if out of memory.
*/
-char* avb_replace(const char* str,
- const char* search,
+char* avb_replace(const char* str, const char* search,
const char* replace) AVB_ATTR_WARN_UNUSED_RESULT;
/* Calculates the CRC-32 for data in |buf| of size |buf_size|. */
uint32_t avb_crc32(const uint8_t* buf, size_t buf_size);
-/* Returns the basename of |str|. This is defined as the last path
- * component, assuming the normal POSIX separator '/'. If there are no
- * separators, returns |str|.
- */
-const char* avb_basename(const char* str);
-
#ifdef __cplusplus
}
#endif