Fix build warnings in libevent
cherry-picked from 98da59020d0d01409ff40a0aa362403258d4af90
Fix warnings related to EV_SSIZE_MAX by correctly defining
_EVENT_SIZEOF_SIZE_T, which is the basis for EV_SSIZE_MAX.
This apparently was only broken for 32 bit host builds of libevent.
Apply -Werror to make future warnings fatal.
Bug: 27075012
Test: mmma -j29 external/libevent for aosp_arm-eng and aosp_x86_64-eng
speculatively fixed darwin warnings.
Change-Id: Iceda4de60192784c2cfa59d127c0e74d05056621
diff --git a/Android.mk b/Android.mk
index 8eaf4e5..72eca2b 100644
--- a/Android.mk
+++ b/Android.mk
@@ -55,7 +55,8 @@
-O3 \
-Wno-implicit-function-declaration \
-Wno-strict-aliasing \
- -Wno-unused-parameter
+ -Wno-unused-parameter \
+ -Werror
include $(CLEAR_VARS)
LOCAL_MODULE := libevent
diff --git a/include/event2/event-config-darwin.h b/include/event2/event-config-darwin.h
index 06ecd0f..4d4e239 100644
--- a/include/event2/event-config-darwin.h
+++ b/include/event2/event-config-darwin.h
@@ -10,6 +10,18 @@
#ifndef _EVENT2_EVENT_CONFIG_H_
#define _EVENT2_EVENT_CONFIG_H_
+
+#include <stdint.h>
+
+/* The size of `size_t', as computed by sizeof. */
+#if SIZE_MAX == UINT64_MAX
+# define _EVENT_SIZEOF_SIZE_T 8
+#elif SIZE_MAX == UINT32_MAX
+# define _EVENT_SIZEOF_SIZE_T 4
+#else
+# error "No way to infer sizeof size_t"
+#endif
+
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
@@ -415,9 +427,6 @@
/* The size of `short', as computed by sizeof. */
#define _EVENT_SIZEOF_SHORT 2
-/* The size of `size_t', as computed by sizeof. */
-#define _EVENT_SIZEOF_SIZE_T 8
-
/* The size of `void *', as computed by sizeof. */
#define _EVENT_SIZEOF_VOID_P 8
diff --git a/include/event2/event-config-linux.h b/include/event2/event-config-linux.h
index 60a0855..5a906df 100644
--- a/include/event2/event-config-linux.h
+++ b/include/event2/event-config-linux.h
@@ -11,6 +11,17 @@
#ifndef _EVENT2_EVENT_CONFIG_H_
#define _EVENT2_EVENT_CONFIG_H_
+#include <stdint.h>
+
+/* The size of `size_t', as computed by sizeof. */
+#if SIZE_MAX == UINT64_MAX
+# define _EVENT_SIZEOF_SIZE_T 8
+#elif SIZE_MAX == UINT32_MAX
+# define _EVENT_SIZEOF_SIZE_T 4
+#else
+# error "No way to infer sizeof size_t"
+#endif
+
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
@@ -416,9 +427,6 @@
/* The size of `short', as computed by sizeof. */
#define _EVENT_SIZEOF_SHORT 2
-/* The size of `size_t', as computed by sizeof. */
-#define _EVENT_SIZEOF_SIZE_T 8
-
/* The size of `void *', as computed by sizeof. */
#define _EVENT_SIZEOF_VOID_P 8