]> rtime.felk.cvut.cz Git - orte.git/blobdiff - orte/libjorte/JORTERecvInfoHelpers.c
JORTE: add static asserts on values of platform-specific sizes
[orte.git] / orte / libjorte / JORTERecvInfoHelpers.c
index 32740b13f88febb4c845f8aa039f968f4f4e2093..c113d5ff20d9ac0c84f3ed7fdc7ac6356e2a04af 100644 (file)
@@ -2,6 +2,7 @@
 #include <stdint.h>
 #include <inttypes.h>
 #include <stddef.h>
+#include <assert.h>
 
 // library header file's path
 #include "orte_all.h"
  * Signature: (Ljava/nio/ByteBuffer;)V
  */
 JNIEXPORT void JNICALL Java_org_ocera_orte_types_RecvInfo_c_1helper
-  (JNIEnv *env, jobject obj, jobject b_buffer) {
+  (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);
     
@@ -48,6 +60,6 @@ JNIEXPORT void JNICALL Java_org_ocera_orte_types_RecvInfo_c_1helper
  * Signature: (J)Ljava/lang/String;
  */
 JNIEXPORT jstring JNICALL Java_org_ocera_orte_types_RecvInfo_get_1string
-  (JNIEnv *env, jobject obj, jlong string_ptr) {
+  (JNIEnv *env, jclass cls, jlong string_ptr) {
     return (*env)->NewStringUTF(env, (char*) string_ptr);
   }