Bug 1181026 (part 3) - Fix libevent constants for 32-bit Linux/Mac/BSD builds. r=glandium.

The patch also adds the CHECK_EVENT_SIZEOF macro which checks that the
_EVENT_SIZEOF_* constants have the right values.

--HG--
extra : rebase_source : 36a41bb25adcef55814aa51a280cad91062d2147
This commit is contained in:
Nicholas Nethercote 2015-09-22 20:01:29 -07:00
parent 34ad9836d9
commit e2d96fab66
5 changed files with 94 additions and 0 deletions

View File

@ -18,6 +18,19 @@
#include "third_party/libevent/event.h"
#include "mozilla/UniquePtr.h"
// This macro checks that the _EVENT_SIZEOF_* constants defined in
// ipc/chromiume/src/third_party/<platform>/event2/event-config.h are correct.
#define CHECK_EVENT_SIZEOF(TYPE, type) \
static_assert(_EVENT_SIZEOF_##TYPE == sizeof(type), \
"bad _EVENT_SIZEOF_"#TYPE);
CHECK_EVENT_SIZEOF(LONG, long);
CHECK_EVENT_SIZEOF(LONG_LONG, long long);
CHECK_EVENT_SIZEOF(PTHREAD_T, pthread_t);
CHECK_EVENT_SIZEOF(SHORT, short);
CHECK_EVENT_SIZEOF(SIZE_T, size_t);
CHECK_EVENT_SIZEOF(VOID_P, void*);
// Lifecycle of struct event
// Libevent uses two main data structures:
// struct event_base (of which there is one per message pump), and

View File

@ -5,6 +5,7 @@ modifications.
- linux/event2/event-config.h
- mac/event2/event-config.h
- bsd/event2/event-config.h
- android/event2/event-config.h
These files are taken from libevent-2.0.21-stable built on the development
@ -12,6 +13,11 @@ environment indicated by the first path component. You have to run
"./configure" and "make" to get all of the pre-processing done. The file can
then be found in "include/event2/".
You then need to modify the _EVENT_SIZEOF_* constants in the generated linux,
mac and bsd headers to be appropriate for both 32-bit and 64-bit platforms. Use
__LP64__ to distinguish the two cases. If you get something wrong the
CHECK_EVENT_SIZEOF static assertions in message_pump_libevent.cc will fail.
2. This is ugly, prepare yourself. OS X has a weird problem with how the
"TAILQ_END(head)" is used, causing a linking error. Just replace all use of the
"TAILQ_END(head)" macro with "NULL".

View File

@ -398,26 +398,51 @@
your system. */
/* #undef _EVENT_PTHREAD_CREATE_JOINABLE */
/* ------------------------------------------------------------------------ */
/* MOZILLA NOTE: the following constants are hand-modified to be suitable */
/* for both 32-bit and 64-bit platforms. See README.mozilla for details. */
/* ------------------------------------------------------------------------ */
/* The size of `int', as computed by sizeof. */
#define _EVENT_SIZEOF_INT 4
/* The size of `long', as computed by sizeof. */
#ifdef __LP64__
#define _EVENT_SIZEOF_LONG 8
#else
#define _EVENT_SIZEOF_LONG 4
#endif
/* The size of `long long', as computed by sizeof. */
#define _EVENT_SIZEOF_LONG_LONG 8
/* The size of `pthread_t', as computed by sizeof. */
#ifdef __LP64__
#define _EVENT_SIZEOF_PTHREAD_T 8
#else
#define _EVENT_SIZEOF_PTHREAD_T 4
#endif
/* The size of `short', as computed by sizeof. */
#define _EVENT_SIZEOF_SHORT 2
/* The size of `size_t', as computed by sizeof. */
#ifdef __LP64__
#define _EVENT_SIZEOF_SIZE_T 8
#else
#define _EVENT_SIZEOF_SIZE_T 4
#endif
/* The size of `void *', as computed by sizeof. */
#ifdef __LP64__
#define _EVENT_SIZEOF_VOID_P 8
#else
#define _EVENT_SIZEOF_VOID_P 4
#endif
/* ------------------------------------------------------------------------ */
/* END MOZILLA NOTE */
/* ------------------------------------------------------------------------ */
/* Define to 1 if you have the ANSI C header files. */
#define _EVENT_STDC_HEADERS 1

View File

@ -398,26 +398,51 @@
your system. */
/* #undef _EVENT_PTHREAD_CREATE_JOINABLE */
/* ------------------------------------------------------------------------ */
/* MOZILLA NOTE: the following constants are hand-modified to be suitable */
/* for both 32-bit and 64-bit platforms. See README.mozilla for details. */
/* ------------------------------------------------------------------------ */
/* The size of `int', as computed by sizeof. */
#define _EVENT_SIZEOF_INT 4
/* The size of `long', as computed by sizeof. */
#ifdef __LP64__
#define _EVENT_SIZEOF_LONG 8
#else
#define _EVENT_SIZEOF_LONG 4
#endif
/* The size of `long long', as computed by sizeof. */
#define _EVENT_SIZEOF_LONG_LONG 8
/* The size of `pthread_t', as computed by sizeof. */
#ifdef __LP64__
#define _EVENT_SIZEOF_PTHREAD_T 8
#else
#define _EVENT_SIZEOF_PTHREAD_T 4
#endif
/* The size of `short', as computed by sizeof. */
#define _EVENT_SIZEOF_SHORT 2
/* The size of `size_t', as computed by sizeof. */
#ifdef __LP64__
#define _EVENT_SIZEOF_SIZE_T 8
#else
#define _EVENT_SIZEOF_SIZE_T 4
#endif
/* The size of `void *', as computed by sizeof. */
#ifdef __LP64__
#define _EVENT_SIZEOF_VOID_P 8
#else
#define _EVENT_SIZEOF_VOID_P 4
#endif
/* ------------------------------------------------------------------------ */
/* END MOZILLA NOTE */
/* ------------------------------------------------------------------------ */
/* Define to 1 if you have the ANSI C header files. */
#define _EVENT_STDC_HEADERS 1

View File

@ -397,26 +397,51 @@
your system. */
/* #undef _EVENT_PTHREAD_CREATE_JOINABLE */
/* ------------------------------------------------------------------------ */
/* MOZILLA NOTE: the following constants are hand-modified to be suitable */
/* for both 32-bit and 64-bit platforms. See README.mozilla for details. */
/* ------------------------------------------------------------------------ */
/* The size of `int', as computed by sizeof. */
#define _EVENT_SIZEOF_INT 4
/* The size of `long', as computed by sizeof. */
#ifdef __LP64__
#define _EVENT_SIZEOF_LONG 8
#else
#define _EVENT_SIZEOF_LONG 4
#endif
/* The size of `long long', as computed by sizeof. */
#define _EVENT_SIZEOF_LONG_LONG 8
/* The size of `pthread_t', as computed by sizeof. */
#ifdef __LP64__
#define _EVENT_SIZEOF_PTHREAD_T 8
#else
#define _EVENT_SIZEOF_PTHREAD_T 4
#endif
/* The size of `short', as computed by sizeof. */
#define _EVENT_SIZEOF_SHORT 2
/* The size of `size_t', as computed by sizeof. */
#ifdef __LP64__
#define _EVENT_SIZEOF_SIZE_T 8
#else
#define _EVENT_SIZEOF_SIZE_T 4
#endif
/* The size of `void *', as computed by sizeof. */
#ifdef __LP64__
#define _EVENT_SIZEOF_VOID_P 8
#else
#define _EVENT_SIZEOF_VOID_P 4
#endif
/* ------------------------------------------------------------------------ */
/* END MOZILLA NOTE */
/* ------------------------------------------------------------------------ */
/* Define to 1 if you have the ANSI C header files. */
#define _EVENT_STDC_HEADERS 1