Ensure log directory exists first.
[SquirrelJME.git] / emulators / emulator-base / src / main / c / mle_math.c
blob98aeb4ea4a1e40589d877962cdbb4653c37302dd
1 /* -*- Mode: C++; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
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 // ------------------------------------------------------------------------ */
10 #include <stdint.h>
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)
27 return (jint)(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));