Calling TNS floating-point functions from JNI code

This section describes the procedure to call a TNS floating-point function from an IEEE floating-point function.

Perform the following when using TNS floating-point compiled functions in native code linked in the java executable:

  • Do not call the Common Runtime Environment (CRE) functions with TNS floating-point values because CRE functions are expecting IEEE floating-point values.

  • Do not pass floating-point values (float and double) across mixed float compilation units. When passing or returning floating-point values between IEEE floating-point compiled functions and TNS floating-point compiled functions, pass or return the following:

    A double as one of the structures defined in $SYSTEM.SYSTEM.KFPCONVH (NSK_float_ieee64, NSK_float_tns64) or /usr/include/kfpconv.h.

  • You can call a native function that accepts or returns a TNS float or double value if you create an intermediate function. The intermediate function assembles between the IEEE floating-point compiled JNI method that the JVM calls and the native function that accepts or returns the float or double value.

    Either the JNI method or intermediate method can be responsible for calling one of the NSK_float_* procedures to convert between IEEE and TNS floating-point formats.

    The intermediate function:
    • Is compiled with TNS floating-point.

    • Accepts float and double arguments as one of the special structures defined in the $SYSTEM.SYSTEM.KFPCONVH or /usr/include/kfpconv.h file.

    • Calls the TNS compiled native function passing TNS float or double arguments.

    • Converts any float or double return value to an IEEE floating-point value, which the JNI caller expects.

    • Returns the float or double in one of the special structures defined in the $SYSTEM.SYSTEM.KFPCONVH or /usr/include/kfpconv.h file.

For an example, see nsjjni Demonstration programs.