/*
 * Copyright (c) 2015, AZQ. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 */

package ac.ncic.syssw.azq.JniExamples;

/**
 * A collection of native methods for accessing native RDMA verbs APIs.
 *
 * @author azq
 */
final class IBVerbsNative {
	static {
		System.loadLibrary("jniverbs");
	}

	private IBVerbsNative() {}

	/**
	 * A wrapper around <code>ibv_get_device_list()</code>.
	 *
	 * <p>
	 * TODO return an object array of custom class `IbvDevice`.
	 * <p>
	 * But that kind of passing back means that much more data will have to go
	 * through JNI, which I'd like to avoid.
	 *
	 * @param devNum to which the number of devices will be written.
	 *
	 * @return the value of <code>struct ibv_device **dev_list</code>, or the
	 *         virtual address of device list. be cautious, this is considered
	 *         unsafe in Java.
	 */
	static native long ibvGetDeviceList(MutableInteger devNum) throws JNIVerbsException;

	/**
	 * Direct call into <code>ibv_free_device_list()</code>.
	 *
	 * @param devListAddr the address value of <code>**dev_list</code>.
	 */
	static native void ibvFreeDeviceList(long devListAddr);

	/**
	 * Invoke <code>ibv_get_device_name</code> and return.
	 *
	 * @param devListAddr the pointer/address of device list array.
	 *
	 * @param devId the device id (0, 1, 2, ...).
	 *
	 * @return the name of the device as a Java String.
	 */
	static native String ibvGetDeviceName(long devListAddr, int devId);

	/**
	 * @see #ibvGetDeviceName(long, int)
	 */
	static native long ibvGetDeviceGUID(long devListAddr, int devId);
}

@@ -218,12 +218,10 @@
 ive 
-RDMA
+IB
  ver
@@ -426,207 +426,8 @@
 %09 *%0A
-%09 * %3Cp%3E%0A%09 * TODO return an object array of custom class %60IbvDevice%60.%0A%09 * %3Cp%3E%0A%09 * But that kind of passing back means that much more data will have to go%0A%09 * through JNI, which I'd like to avoid.%0A%09 *%0A
 %09 * 
@@ -672,24 +672,24 @@
  Java.%0A%09 */%0A
-
 %09static nati
@@ -763,16 +763,405 @@
 ption;%0A%0A
+%09/**%0A%09 * Another wrapper around %3Ccode%3Eibv_get_device_list()%3C/code%3E.%0A%09 *%0A%09 * %3Cp%3E%0A%09 * TODO Object should be a peer Java class for struct ibv_device, and how to handle the device list pointer???%0A%09 * %3Cp%3E%0A%09 * This kind of passing back means that much more data will have to go%0A%09 * through JNI, which I'd like to avoid.%0A%09 */%0A%09static native Object%5B%5D ibvGetDeviceList() throws JNIVerbsException;%0A%0A
 %09/**%0A%09 *

add another prototype of ibvGetDeviceList().