/*
 * Class:     org_jnetpcap_nio_JBuffer
 * Method:    setInt0
 * Signature: (JZII)V
 */
JNIEXPORT void JNICALL Java_org_jnetpcap_nio_JBuffer_setInt0
(JNIEnv *env, jclass clazz, jlong address, jboolean big, jint index, jint jval) {
	
	u_int32_t *mem = (u_int32_t *)toPtr(address + index);
	
	*(mem) = ENDIAN32_GET(big, jval);
}
Exemple #2
0
/*
 * Class:     org_jnetpcap_nio_JBuffer
 * Method:    setUInt0
 * Signature: (JZIJ)V
 */
JNIEXPORT void JNICALL Java_org_jnetpcap_nio_JBuffer_setUInt0
(JNIEnv *env, jclass clazz, jlong address, jboolean big, jint index, jlong jval) {
	
	uint32_t *mem = (uint32_t *)toPtr(address + index);
	
	register jint temp = (jint) jval;
	
	*(mem) = ENDIAN32_GET(big, temp);
}
/*
 * Class:     org_jnetpcap_nio_JBuffer
 * Method:    getInt0
 * Signature: (JZI)I
 */
JNIEXPORT jint JNICALL Java_org_jnetpcap_nio_JBuffer_getInt0
(JNIEnv *env, jclass clazz, jlong address, jboolean big, jint index) {
	
	jint *mem = (jint *)toPtr(address + index);

	/*
	 * For efficiency of the endian byte swapping, convert to an atom and use
	 * a CPU register if possible during conversion.
	 */
	register jint data = *(mem);
	
	return ENDIAN32_GET(big, data);
}
Exemple #4
0
/*
 * Class:     org_jnetpcap_nio_JBuffer
 * Method:    getUInt0
 * Signature: (JZI)J
 */
JNIEXPORT jlong JNICALL Java_org_jnetpcap_nio_JBuffer_getUInt0
(JNIEnv *env, jclass clazz, jlong address, jboolean big, jint index) {
	
	address += index;

	/*
	 * For efficiency of the endian byte swapping, convert to an atom and use
	 * a CPU register if possible during conversion.
	 */
	register uint32_t data = UINT32_GETA(address);
	
	return (jlong) ENDIAN32_GET(big, data);
}
/*
 * Class:     org_jnetpcap_nio_JBuffer
 * Method:    setFloat0
 * Signature: (JZIF)V
 */
JNIEXPORT void JNICALL Java_org_jnetpcap_nio_JBuffer_setFloat0
(JNIEnv *env, jclass clazz, jlong address, jboolean big, jint index, jfloat jval) {
	
	u_int32_t *mem = (u_int32_t *)toPtr(address + index);
	
	/*
	 * For efficiency of the endian byte swapping, convert to an atom and use
	 * a CPU register if possible during conversion.
	 */
	u_int32_t data = *(u_int32_t *)(&jval);

	/*
	 * We can't just typecast u_int32 to a float. The float has to be read
	 * out of memory using a float pointer.
	 */
	*(mem) = ENDIAN32_GET(big, data);
}
Exemple #6
0
/*
 * Class:     org_jnetpcap_nio_JBuffer
 * Method:    getFloat0
 * Signature: (JZI)F
 */
JNIEXPORT jfloat JNICALL Java_org_jnetpcap_nio_JBuffer_getFloat0
(JNIEnv *env, jclass clazz, jlong address, jboolean big, jint index) {

	address += index;

	/*
	 * For efficiency of the endian byte swapping, convert to an atom and use
	 * a CPU register if possible during conversion.
	 */
	uint32_t data = UINT64_GETA(address);

	/*
	 * We can't just typecast uint32 to a float. The float has to be read
	 * out of memory using a float pointer.
	 */
	data = ENDIAN32_GET(big, data);
	return *((jfloat *)&data);
}