170 Java Stand-alone Applications on z/OS Volume 1
com_ibm_itso_timer_ThreadSafeTimeUsed.c
#include "com_ibm_itso_timer_ThreadSafeTimeUsed.h"
void CPU (void *);
#pragma linkage(CPU,OS)
JNIEXPORT jlong JNICALL Java_com_ibm_itso_timer_ThreadSafeTimeUsed_timeUsed
(JNIEnv * env, jobject thisObject) {
jlong microseconds = 0L;
CPU(&microseconds);
return microseconds;
}
cpu.s
* PRINT NOGEN
R1 EQU 1
R2 EQU 2
R3 EQU 3
R4 EQU 4
R5 EQU 5
R6 EQU 6
R7 EQU 7
R8 EQU 8
R9 EQU 9
R10 EQU 10
R11 EQU 11
R12 EQU 12
R13 EQU 13
R14 EQU 14
R15 EQU 15
CPU_PARMS DSECT
CPU_PARMS_START DS 0F
CPU_PARMS_FIRST_PTR DS F
CPU RMODE ANY
CPU AMODE 31
CPU CSECT
USING CPU,R15
B DOIT
DC CL8'CPU--STR'
DOIT DS 0H
SAVE (14,12)
LR R10,R15
HERE DS 0H
L R2,0(,R1)
Chapter 5. Measuring performance and application profiling 171
TIMEUSED STORADR=(2),LINKAGE=SYSTEM,CPU=MIC
RETURN (14,12),RC=0
DC CL8'CPU--END'
END
Build commands
javac com/ibm/itso/timer/ThreadSafeTimeUsed
javah com.ibm.itso.timer.ThreadSafeTimeUsed
c89 -o libtimeused.so -W "l,xplink,dll" -W
"c,langlvl(extended),xplink,dll,exportall" -I/usr/lpp/java/J1.4/include
com_ibm_itso_timer_ThreadSafeTimeUsed.c cpu.s
/usr/lpp/java/J1.4/bin/classic/libjvm.x
172 Java Stand-alone Applications on z/OS Volume 1

Get Java Stand-alone Applications on z/OS, Volume I now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.