1 /* -*- Mode: C++; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ------------------------------------------------------------------------ */
12 #include "squirreljme.h"
14 JNIEXPORT jlong JNICALL
longPack(JNIEnv
* env
, jclass classy
, jint al
, jint ah
)
16 return (((jlong
)al
) & UINT64_C(0xFFFFFFFF)) |
17 ((((jlong
)ah
) & UINT64_C(0xFFFFFFFF)) << UINT64_C(32));
20 JNIEXPORT jint JNICALL
longUnpackHigh(JNIEnv
* env
, jclass classy
, jlong v
)
22 return (jint
)(v
>> UINT64_C(32));
25 JNIEXPORT jint JNICALL
longUnpackLow(JNIEnv
* env
, jclass classy
, jlong v
)
30 static const JNINativeMethod mleMathMethods
[] =
32 {"longPack", "(II)J", (void*)longPack
},
33 {"longUnpackHigh", "(J)I", (void*)longUnpackHigh
},
34 {"longUnpackLow", "(J)I", (void*)longUnpackLow
},
37 jint JNICALL
mleMathInit(JNIEnv
* env
, jclass classy
)
39 return (*env
)->RegisterNatives(env
,
40 (*env
)->FindClass(env
, "cc/squirreljme/jvm/mle/MathShelf"),
41 mleMathMethods
, sizeof(mleMathMethods
) / sizeof(JNINativeMethod
));