From: Martin Vajnar Date: Sat, 2 May 2015 12:51:10 +0000 (+0200) Subject: JORTE: add static asserts on values of platform-specific sizes X-Git-Url: https://rtime.felk.cvut.cz/gitweb/orte.git/commitdiff_plain/8a9254f92ea7fc88d21328a9e27f50800f9161d5 JORTE: add static asserts on values of platform-specific sizes If the sizes differ, die with error. --- diff --git a/orte/libjorte/JORTERecvInfoHelpers.c b/orte/libjorte/JORTERecvInfoHelpers.c index da68b48..c113d5f 100644 --- a/orte/libjorte/JORTERecvInfoHelpers.c +++ b/orte/libjorte/JORTERecvInfoHelpers.c @@ -2,6 +2,7 @@ #include #include #include +#include // library header file's path #include "orte_all.h" @@ -21,6 +22,17 @@ JNIEXPORT void JNICALL Java_org_ocera_orte_types_RecvInfo_c_1helper (JNIEnv *env, jclass cls, jobject b_buffer) { + _Static_assert(sizeof(char*) == 1 || \ + sizeof(char*) == 2 || \ + sizeof(char*) == 4 || \ + sizeof(char*) == 8, \ + "char* has incompatible size"); + _Static_assert(sizeof(ORTERecvStatus) == 1 || \ + sizeof(ORTERecvStatus) == 2 || \ + sizeof(ORTERecvStatus) == 4 || \ + sizeof(ORTERecvStatus) == 8, \ + "ORTERecvStatus has incompatible size"); + int32_t* buffer = (*env)->GetDirectBufferAddress(env, b_buffer); buffer[0] = (int32_t)sizeof(ORTERecvInfo);