All Downloads are FREE. Search and download functionalities are using the official Maven repository.

evops.ci-plugins.sigar.1.7.0.0.source-code.javasigar_generated.h Maven / Gradle / Ivy

The newest version!
/*****************************************************
 * WARNING: this file was generated by -e
 * on Mon Sep 21 16:05:35 2020.
 * Any changes made here will be LOST.
 *****************************************************/
#define JSIGAR_FIELDS_PROCMEM 0
#   define JSIGAR_FIELDS_PROCMEM_SIZE 0
#   define JSIGAR_FIELDS_PROCMEM_RESIDENT 1
#   define JSIGAR_FIELDS_PROCMEM_SHARE 2
#   define JSIGAR_FIELDS_PROCMEM_MINOR_FAULTS 3
#   define JSIGAR_FIELDS_PROCMEM_MAJOR_FAULTS 4
#   define JSIGAR_FIELDS_PROCMEM_PAGE_FAULTS 5
#   define JSIGAR_FIELDS_PROCMEM_MAX 6
#define JSIGAR_FIELDS_CPU 1
#   define JSIGAR_FIELDS_CPU_USER 0
#   define JSIGAR_FIELDS_CPU_SYS 1
#   define JSIGAR_FIELDS_CPU_NICE 2
#   define JSIGAR_FIELDS_CPU_IDLE 3
#   define JSIGAR_FIELDS_CPU_WAIT 4
#   define JSIGAR_FIELDS_CPU_IRQ 5
#   define JSIGAR_FIELDS_CPU_SOFT_IRQ 6
#   define JSIGAR_FIELDS_CPU_STOLEN 7
#   define JSIGAR_FIELDS_CPU_TOTAL 8
#   define JSIGAR_FIELDS_CPU_MAX 9
#define JSIGAR_FIELDS_PROCCUMULATIVEDISKIO 2
#   define JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_BYTES_READ 0
#   define JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_BYTES_WRITTEN 1
#   define JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_BYTES_TOTAL 2
#   define JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_MAX 3
#define JSIGAR_FIELDS_NETINTERFACECONFIG 3
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_NAME 0
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_HWADDR 1
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_TYPE 2
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_DESCRIPTION 3
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_ADDRESS 4
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_ADDRESS6 5
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_PREFIX6_LENGTH 6
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_SCOPE6 7
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_DESTINATION 8
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_BROADCAST 9
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_NETMASK 10
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_FLAGS 11
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_MTU 12
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_METRIC 13
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_TX_QUEUE_LEN 14
#   define JSIGAR_FIELDS_NETINTERFACECONFIG_MAX 15
#define JSIGAR_FIELDS_NETCONNECTION 4
#   define JSIGAR_FIELDS_NETCONNECTION_LOCAL_PORT 0
#   define JSIGAR_FIELDS_NETCONNECTION_LOCAL_ADDRESS 1
#   define JSIGAR_FIELDS_NETCONNECTION_REMOTE_PORT 2
#   define JSIGAR_FIELDS_NETCONNECTION_REMOTE_ADDRESS 3
#   define JSIGAR_FIELDS_NETCONNECTION_TYPE 4
#   define JSIGAR_FIELDS_NETCONNECTION_STATE 5
#   define JSIGAR_FIELDS_NETCONNECTION_SEND_QUEUE 6
#   define JSIGAR_FIELDS_NETCONNECTION_RECEIVE_QUEUE 7
#   define JSIGAR_FIELDS_NETCONNECTION_MAX 8
#define JSIGAR_FIELDS_TCP 5
#   define JSIGAR_FIELDS_TCP_ACTIVE_OPENS 0
#   define JSIGAR_FIELDS_TCP_PASSIVE_OPENS 1
#   define JSIGAR_FIELDS_TCP_ATTEMPT_FAILS 2
#   define JSIGAR_FIELDS_TCP_ESTAB_RESETS 3
#   define JSIGAR_FIELDS_TCP_CURR_ESTAB 4
#   define JSIGAR_FIELDS_TCP_IN_SEGS 5
#   define JSIGAR_FIELDS_TCP_OUT_SEGS 6
#   define JSIGAR_FIELDS_TCP_RETRANS_SEGS 7
#   define JSIGAR_FIELDS_TCP_IN_ERRS 8
#   define JSIGAR_FIELDS_TCP_OUT_RSTS 9
#   define JSIGAR_FIELDS_TCP_MAX 10
#define JSIGAR_FIELDS_MEM 6
#   define JSIGAR_FIELDS_MEM_TOTAL 0
#   define JSIGAR_FIELDS_MEM_RAM 1
#   define JSIGAR_FIELDS_MEM_USED 2
#   define JSIGAR_FIELDS_MEM_FREE 3
#   define JSIGAR_FIELDS_MEM_ACTUAL_USED 4
#   define JSIGAR_FIELDS_MEM_ACTUAL_FREE 5
#   define JSIGAR_FIELDS_MEM_USED_PERCENT 6
#   define JSIGAR_FIELDS_MEM_FREE_PERCENT 7
#   define JSIGAR_FIELDS_MEM_MAX 8
#define JSIGAR_FIELDS_NETROUTE 7
#   define JSIGAR_FIELDS_NETROUTE_DESTINATION 0
#   define JSIGAR_FIELDS_NETROUTE_GATEWAY 1
#   define JSIGAR_FIELDS_NETROUTE_FLAGS 2
#   define JSIGAR_FIELDS_NETROUTE_REFCNT 3
#   define JSIGAR_FIELDS_NETROUTE_USE 4
#   define JSIGAR_FIELDS_NETROUTE_METRIC 5
#   define JSIGAR_FIELDS_NETROUTE_MASK 6
#   define JSIGAR_FIELDS_NETROUTE_MTU 7
#   define JSIGAR_FIELDS_NETROUTE_WINDOW 8
#   define JSIGAR_FIELDS_NETROUTE_IRTT 9
#   define JSIGAR_FIELDS_NETROUTE_IFNAME 10
#   define JSIGAR_FIELDS_NETROUTE_MAX 11
#define JSIGAR_FIELDS_DIRSTAT 8
#   define JSIGAR_FIELDS_DIRSTAT_TOTAL 0
#   define JSIGAR_FIELDS_DIRSTAT_FILES 1
#   define JSIGAR_FIELDS_DIRSTAT_SUBDIRS 2
#   define JSIGAR_FIELDS_DIRSTAT_SYMLINKS 3
#   define JSIGAR_FIELDS_DIRSTAT_CHRDEVS 4
#   define JSIGAR_FIELDS_DIRSTAT_BLKDEVS 5
#   define JSIGAR_FIELDS_DIRSTAT_SOCKETS 6
#   define JSIGAR_FIELDS_DIRSTAT_DISK_USAGE 7
#   define JSIGAR_FIELDS_DIRSTAT_MAX 8
#define JSIGAR_FIELDS_FILESYSTEMUSAGE 9
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_TOTAL 0
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_FREE 1
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_USED 2
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_AVAIL 3
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_FILES 4
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_FREE_FILES 5
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_READS 6
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_WRITES 7
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_READ_BYTES 8
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_WRITE_BYTES 9
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_QUEUE 10
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_SERVICE_TIME 11
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_USE_PERCENT 12
#   define JSIGAR_FIELDS_FILESYSTEMUSAGE_MAX 13
#define JSIGAR_FIELDS_NETSTAT 10
#   define JSIGAR_FIELDS_NETSTAT_TCP_INBOUND_TOTAL 0
#   define JSIGAR_FIELDS_NETSTAT_TCP_OUTBOUND_TOTAL 1
#   define JSIGAR_FIELDS_NETSTAT_ALL_INBOUND_TOTAL 2
#   define JSIGAR_FIELDS_NETSTAT_ALL_OUTBOUND_TOTAL 3
#   define JSIGAR_FIELDS_NETSTAT_MAX 4
#define JSIGAR_FIELDS_RESOURCELIMIT 11
#   define JSIGAR_FIELDS_RESOURCELIMIT_CPU_CUR 0
#   define JSIGAR_FIELDS_RESOURCELIMIT_CPU_MAX 1
#   define JSIGAR_FIELDS_RESOURCELIMIT_FILE_SIZE_CUR 2
#   define JSIGAR_FIELDS_RESOURCELIMIT_FILE_SIZE_MAX 3
#   define JSIGAR_FIELDS_RESOURCELIMIT_PIPE_SIZE_MAX 4
#   define JSIGAR_FIELDS_RESOURCELIMIT_PIPE_SIZE_CUR 5
#   define JSIGAR_FIELDS_RESOURCELIMIT_DATA_CUR 6
#   define JSIGAR_FIELDS_RESOURCELIMIT_DATA_MAX 7
#   define JSIGAR_FIELDS_RESOURCELIMIT_STACK_CUR 8
#   define JSIGAR_FIELDS_RESOURCELIMIT_STACK_MAX 9
#   define JSIGAR_FIELDS_RESOURCELIMIT_CORE_CUR 10
#   define JSIGAR_FIELDS_RESOURCELIMIT_CORE_MAX 11
#   define JSIGAR_FIELDS_RESOURCELIMIT_MEMORY_CUR 12
#   define JSIGAR_FIELDS_RESOURCELIMIT_MEMORY_MAX 13
#   define JSIGAR_FIELDS_RESOURCELIMIT_PROCESSES_CUR 14
#   define JSIGAR_FIELDS_RESOURCELIMIT_PROCESSES_MAX 15
#   define JSIGAR_FIELDS_RESOURCELIMIT_OPEN_FILES_CUR 16
#   define JSIGAR_FIELDS_RESOURCELIMIT_OPEN_FILES_MAX 17
#   define JSIGAR_FIELDS_RESOURCELIMIT_VIRTUAL_MEMORY_CUR 18
#   define JSIGAR_FIELDS_RESOURCELIMIT_VIRTUAL_MEMORY_MAX 19
#   define JSIGAR_FIELDS_RESOURCELIMIT_MAX 20
#define JSIGAR_FIELDS_NFSCLIENTV3 12
#   define JSIGAR_FIELDS_NFSCLIENTV3_NULL 0
#   define JSIGAR_FIELDS_NFSCLIENTV3_GETATTR 1
#   define JSIGAR_FIELDS_NFSCLIENTV3_SETATTR 2
#   define JSIGAR_FIELDS_NFSCLIENTV3_LOOKUP 3
#   define JSIGAR_FIELDS_NFSCLIENTV3_ACCESS 4
#   define JSIGAR_FIELDS_NFSCLIENTV3_READLINK 5
#   define JSIGAR_FIELDS_NFSCLIENTV3_READ 6
#   define JSIGAR_FIELDS_NFSCLIENTV3_WRITE 7
#   define JSIGAR_FIELDS_NFSCLIENTV3_CREATE 8
#   define JSIGAR_FIELDS_NFSCLIENTV3_MKDIR 9
#   define JSIGAR_FIELDS_NFSCLIENTV3_SYMLINK 10
#   define JSIGAR_FIELDS_NFSCLIENTV3_MKNOD 11
#   define JSIGAR_FIELDS_NFSCLIENTV3_REMOVE 12
#   define JSIGAR_FIELDS_NFSCLIENTV3_RMDIR 13
#   define JSIGAR_FIELDS_NFSCLIENTV3_RENAME 14
#   define JSIGAR_FIELDS_NFSCLIENTV3_LINK 15
#   define JSIGAR_FIELDS_NFSCLIENTV3_READDIR 16
#   define JSIGAR_FIELDS_NFSCLIENTV3_READDIRPLUS 17
#   define JSIGAR_FIELDS_NFSCLIENTV3_FSSTAT 18
#   define JSIGAR_FIELDS_NFSCLIENTV3_FSINFO 19
#   define JSIGAR_FIELDS_NFSCLIENTV3_PATHCONF 20
#   define JSIGAR_FIELDS_NFSCLIENTV3_COMMIT 21
#   define JSIGAR_FIELDS_NFSCLIENTV3_MAX 22
#define JSIGAR_FIELDS_PROCCRED 13
#   define JSIGAR_FIELDS_PROCCRED_UID 0
#   define JSIGAR_FIELDS_PROCCRED_GID 1
#   define JSIGAR_FIELDS_PROCCRED_EUID 2
#   define JSIGAR_FIELDS_PROCCRED_EGID 3
#   define JSIGAR_FIELDS_PROCCRED_MAX 4
#define JSIGAR_FIELDS_NFSSERVERV3 14
#   define JSIGAR_FIELDS_NFSSERVERV3_NULL 0
#   define JSIGAR_FIELDS_NFSSERVERV3_GETATTR 1
#   define JSIGAR_FIELDS_NFSSERVERV3_SETATTR 2
#   define JSIGAR_FIELDS_NFSSERVERV3_LOOKUP 3
#   define JSIGAR_FIELDS_NFSSERVERV3_ACCESS 4
#   define JSIGAR_FIELDS_NFSSERVERV3_READLINK 5
#   define JSIGAR_FIELDS_NFSSERVERV3_READ 6
#   define JSIGAR_FIELDS_NFSSERVERV3_WRITE 7
#   define JSIGAR_FIELDS_NFSSERVERV3_CREATE 8
#   define JSIGAR_FIELDS_NFSSERVERV3_MKDIR 9
#   define JSIGAR_FIELDS_NFSSERVERV3_SYMLINK 10
#   define JSIGAR_FIELDS_NFSSERVERV3_MKNOD 11
#   define JSIGAR_FIELDS_NFSSERVERV3_REMOVE 12
#   define JSIGAR_FIELDS_NFSSERVERV3_RMDIR 13
#   define JSIGAR_FIELDS_NFSSERVERV3_RENAME 14
#   define JSIGAR_FIELDS_NFSSERVERV3_LINK 15
#   define JSIGAR_FIELDS_NFSSERVERV3_READDIR 16
#   define JSIGAR_FIELDS_NFSSERVERV3_READDIRPLUS 17
#   define JSIGAR_FIELDS_NFSSERVERV3_FSSTAT 18
#   define JSIGAR_FIELDS_NFSSERVERV3_FSINFO 19
#   define JSIGAR_FIELDS_NFSSERVERV3_PATHCONF 20
#   define JSIGAR_FIELDS_NFSSERVERV3_COMMIT 21
#   define JSIGAR_FIELDS_NFSSERVERV3_MAX 22
#define JSIGAR_FIELDS_ARP 15
#   define JSIGAR_FIELDS_ARP_IFNAME 0
#   define JSIGAR_FIELDS_ARP_HWADDR 1
#   define JSIGAR_FIELDS_ARP_TYPE 2
#   define JSIGAR_FIELDS_ARP_ADDRESS 3
#   define JSIGAR_FIELDS_ARP_FLAGS 4
#   define JSIGAR_FIELDS_ARP_MAX 5
#define JSIGAR_FIELDS_CPUINFO 16
#   define JSIGAR_FIELDS_CPUINFO_VENDOR 0
#   define JSIGAR_FIELDS_CPUINFO_MODEL 1
#   define JSIGAR_FIELDS_CPUINFO_MHZ 2
#   define JSIGAR_FIELDS_CPUINFO_MHZ_MAX 3
#   define JSIGAR_FIELDS_CPUINFO_MHZ_MIN 4
#   define JSIGAR_FIELDS_CPUINFO_CACHE_SIZE 5
#   define JSIGAR_FIELDS_CPUINFO_TOTAL_CORES 6
#   define JSIGAR_FIELDS_CPUINFO_TOTAL_SOCKETS 7
#   define JSIGAR_FIELDS_CPUINFO_CORES_PER_SOCKET 8
#   define JSIGAR_FIELDS_CPUINFO_MAX 9
#define JSIGAR_FIELDS_DIRUSAGE 17
#   define JSIGAR_FIELDS_DIRUSAGE_TOTAL 0
#   define JSIGAR_FIELDS_DIRUSAGE_FILES 1
#   define JSIGAR_FIELDS_DIRUSAGE_SUBDIRS 2
#   define JSIGAR_FIELDS_DIRUSAGE_SYMLINKS 3
#   define JSIGAR_FIELDS_DIRUSAGE_CHRDEVS 4
#   define JSIGAR_FIELDS_DIRUSAGE_BLKDEVS 5
#   define JSIGAR_FIELDS_DIRUSAGE_SOCKETS 6
#   define JSIGAR_FIELDS_DIRUSAGE_DISK_USAGE 7
#   define JSIGAR_FIELDS_DIRUSAGE_MAX 8
#define JSIGAR_FIELDS_FILEATTRS 18
#   define JSIGAR_FIELDS_FILEATTRS_PERMISSIONS 0
#   define JSIGAR_FIELDS_FILEATTRS_TYPE 1
#   define JSIGAR_FIELDS_FILEATTRS_UID 2
#   define JSIGAR_FIELDS_FILEATTRS_GID 3
#   define JSIGAR_FIELDS_FILEATTRS_INODE 4
#   define JSIGAR_FIELDS_FILEATTRS_DEVICE 5
#   define JSIGAR_FIELDS_FILEATTRS_NLINK 6
#   define JSIGAR_FIELDS_FILEATTRS_SIZE 7
#   define JSIGAR_FIELDS_FILEATTRS_ATIME 8
#   define JSIGAR_FIELDS_FILEATTRS_CTIME 9
#   define JSIGAR_FIELDS_FILEATTRS_MTIME 10
#   define JSIGAR_FIELDS_FILEATTRS_MAX 11
#define JSIGAR_FIELDS_PROCTIME 19
#   define JSIGAR_FIELDS_PROCTIME_START_TIME 0
#   define JSIGAR_FIELDS_PROCTIME_USER 1
#   define JSIGAR_FIELDS_PROCTIME_SYS 2
#   define JSIGAR_FIELDS_PROCTIME_TOTAL 3
#   define JSIGAR_FIELDS_PROCTIME_MAX 4
#define JSIGAR_FIELDS_DUMPPIDCACHE 20
#   define JSIGAR_FIELDS_DUMPPIDCACHE_DUMMY 0
#   define JSIGAR_FIELDS_DUMPPIDCACHE_MAX 1
#define JSIGAR_FIELDS_NETINTERFACESTAT 21
#   define JSIGAR_FIELDS_NETINTERFACESTAT_RX_BYTES 0
#   define JSIGAR_FIELDS_NETINTERFACESTAT_RX_PACKETS 1
#   define JSIGAR_FIELDS_NETINTERFACESTAT_RX_ERRORS 2
#   define JSIGAR_FIELDS_NETINTERFACESTAT_RX_DROPPED 3
#   define JSIGAR_FIELDS_NETINTERFACESTAT_RX_OVERRUNS 4
#   define JSIGAR_FIELDS_NETINTERFACESTAT_RX_FRAME 5
#   define JSIGAR_FIELDS_NETINTERFACESTAT_TX_BYTES 6
#   define JSIGAR_FIELDS_NETINTERFACESTAT_TX_PACKETS 7
#   define JSIGAR_FIELDS_NETINTERFACESTAT_TX_ERRORS 8
#   define JSIGAR_FIELDS_NETINTERFACESTAT_TX_DROPPED 9
#   define JSIGAR_FIELDS_NETINTERFACESTAT_TX_OVERRUNS 10
#   define JSIGAR_FIELDS_NETINTERFACESTAT_TX_COLLISIONS 11
#   define JSIGAR_FIELDS_NETINTERFACESTAT_TX_CARRIER 12
#   define JSIGAR_FIELDS_NETINTERFACESTAT_SPEED 13
#   define JSIGAR_FIELDS_NETINTERFACESTAT_MAX 14
#define JSIGAR_FIELDS_PROCSTAT 22
#   define JSIGAR_FIELDS_PROCSTAT_TOTAL 0
#   define JSIGAR_FIELDS_PROCSTAT_IDLE 1
#   define JSIGAR_FIELDS_PROCSTAT_RUNNING 2
#   define JSIGAR_FIELDS_PROCSTAT_SLEEPING 3
#   define JSIGAR_FIELDS_PROCSTAT_STOPPED 4
#   define JSIGAR_FIELDS_PROCSTAT_ZOMBIE 5
#   define JSIGAR_FIELDS_PROCSTAT_THREADS 6
#   define JSIGAR_FIELDS_PROCSTAT_MAX 7
#define JSIGAR_FIELDS_PROCCREDNAME 23
#   define JSIGAR_FIELDS_PROCCREDNAME_USER 0
#   define JSIGAR_FIELDS_PROCCREDNAME_GROUP 1
#   define JSIGAR_FIELDS_PROCCREDNAME_MAX 2
#define JSIGAR_FIELDS_PROCFD 24
#   define JSIGAR_FIELDS_PROCFD_TOTAL 0
#   define JSIGAR_FIELDS_PROCFD_MAX 1
#define JSIGAR_FIELDS_NFSSERVERV2 25
#   define JSIGAR_FIELDS_NFSSERVERV2_NULL 0
#   define JSIGAR_FIELDS_NFSSERVERV2_GETATTR 1
#   define JSIGAR_FIELDS_NFSSERVERV2_SETATTR 2
#   define JSIGAR_FIELDS_NFSSERVERV2_ROOT 3
#   define JSIGAR_FIELDS_NFSSERVERV2_LOOKUP 4
#   define JSIGAR_FIELDS_NFSSERVERV2_READLINK 5
#   define JSIGAR_FIELDS_NFSSERVERV2_READ 6
#   define JSIGAR_FIELDS_NFSSERVERV2_WRITECACHE 7
#   define JSIGAR_FIELDS_NFSSERVERV2_WRITE 8
#   define JSIGAR_FIELDS_NFSSERVERV2_CREATE 9
#   define JSIGAR_FIELDS_NFSSERVERV2_REMOVE 10
#   define JSIGAR_FIELDS_NFSSERVERV2_RENAME 11
#   define JSIGAR_FIELDS_NFSSERVERV2_LINK 12
#   define JSIGAR_FIELDS_NFSSERVERV2_SYMLINK 13
#   define JSIGAR_FIELDS_NFSSERVERV2_MKDIR 14
#   define JSIGAR_FIELDS_NFSSERVERV2_RMDIR 15
#   define JSIGAR_FIELDS_NFSSERVERV2_READDIR 16
#   define JSIGAR_FIELDS_NFSSERVERV2_FSSTAT 17
#   define JSIGAR_FIELDS_NFSSERVERV2_MAX 18
#define JSIGAR_FIELDS_CPUPERC 26
#   define JSIGAR_FIELDS_CPUPERC_USER 0
#   define JSIGAR_FIELDS_CPUPERC_SYS 1
#   define JSIGAR_FIELDS_CPUPERC_NICE 2
#   define JSIGAR_FIELDS_CPUPERC_IDLE 3
#   define JSIGAR_FIELDS_CPUPERC_WAIT 4
#   define JSIGAR_FIELDS_CPUPERC_IRQ 5
#   define JSIGAR_FIELDS_CPUPERC_SOFT_IRQ 6
#   define JSIGAR_FIELDS_CPUPERC_STOLEN 7
#   define JSIGAR_FIELDS_CPUPERC_COMBINED 8
#   define JSIGAR_FIELDS_CPUPERC_MAX 9
#define JSIGAR_FIELDS_SWAP 27
#   define JSIGAR_FIELDS_SWAP_TOTAL 0
#   define JSIGAR_FIELDS_SWAP_USED 1
#   define JSIGAR_FIELDS_SWAP_FREE 2
#   define JSIGAR_FIELDS_SWAP_PAGE_IN 3
#   define JSIGAR_FIELDS_SWAP_PAGE_OUT 4
#   define JSIGAR_FIELDS_SWAP_MAX 5
#define JSIGAR_FIELDS_NETINFO 28
#   define JSIGAR_FIELDS_NETINFO_DEFAULT_GATEWAY 0
#   define JSIGAR_FIELDS_NETINFO_DEFAULT_GATEWAY_INTERFACE 1
#   define JSIGAR_FIELDS_NETINFO_HOST_NAME 2
#   define JSIGAR_FIELDS_NETINFO_DOMAIN_NAME 3
#   define JSIGAR_FIELDS_NETINFO_PRIMARY_DNS 4
#   define JSIGAR_FIELDS_NETINFO_SECONDARY_DNS 5
#   define JSIGAR_FIELDS_NETINFO_MAX 6
#define JSIGAR_FIELDS_WHO 29
#   define JSIGAR_FIELDS_WHO_USER 0
#   define JSIGAR_FIELDS_WHO_DEVICE 1
#   define JSIGAR_FIELDS_WHO_HOST 2
#   define JSIGAR_FIELDS_WHO_TIME 3
#   define JSIGAR_FIELDS_WHO_MAX 4
#define JSIGAR_FIELDS_UPTIME 30
#   define JSIGAR_FIELDS_UPTIME_UPTIME 0
#   define JSIGAR_FIELDS_UPTIME_MAX 1
#define JSIGAR_FIELDS_SYSINFO 31
#   define JSIGAR_FIELDS_SYSINFO_NAME 0
#   define JSIGAR_FIELDS_SYSINFO_VERSION 1
#   define JSIGAR_FIELDS_SYSINFO_ARCH 2
#   define JSIGAR_FIELDS_SYSINFO_MACHINE 3
#   define JSIGAR_FIELDS_SYSINFO_DESCRIPTION 4
#   define JSIGAR_FIELDS_SYSINFO_PATCH_LEVEL 5
#   define JSIGAR_FIELDS_SYSINFO_VENDOR 6
#   define JSIGAR_FIELDS_SYSINFO_VENDOR_VERSION 7
#   define JSIGAR_FIELDS_SYSINFO_VENDOR_NAME 8
#   define JSIGAR_FIELDS_SYSINFO_VENDOR_CODE_NAME 9
#   define JSIGAR_FIELDS_SYSINFO_MAX 10
#define JSIGAR_FIELDS_DISKUSAGE 32
#   define JSIGAR_FIELDS_DISKUSAGE_READS 0
#   define JSIGAR_FIELDS_DISKUSAGE_WRITES 1
#   define JSIGAR_FIELDS_DISKUSAGE_READ_BYTES 2
#   define JSIGAR_FIELDS_DISKUSAGE_WRITE_BYTES 3
#   define JSIGAR_FIELDS_DISKUSAGE_QUEUE 4
#   define JSIGAR_FIELDS_DISKUSAGE_SERVICE_TIME 5
#   define JSIGAR_FIELDS_DISKUSAGE_MAX 6
#define JSIGAR_FIELDS_PROCEXE 33
#   define JSIGAR_FIELDS_PROCEXE_NAME 0
#   define JSIGAR_FIELDS_PROCEXE_CWD 1
#   define JSIGAR_FIELDS_PROCEXE_MAX 2
#define JSIGAR_FIELDS_NFSCLIENTV2 34
#   define JSIGAR_FIELDS_NFSCLIENTV2_NULL 0
#   define JSIGAR_FIELDS_NFSCLIENTV2_GETATTR 1
#   define JSIGAR_FIELDS_NFSCLIENTV2_SETATTR 2
#   define JSIGAR_FIELDS_NFSCLIENTV2_ROOT 3
#   define JSIGAR_FIELDS_NFSCLIENTV2_LOOKUP 4
#   define JSIGAR_FIELDS_NFSCLIENTV2_READLINK 5
#   define JSIGAR_FIELDS_NFSCLIENTV2_READ 6
#   define JSIGAR_FIELDS_NFSCLIENTV2_WRITECACHE 7
#   define JSIGAR_FIELDS_NFSCLIENTV2_WRITE 8
#   define JSIGAR_FIELDS_NFSCLIENTV2_CREATE 9
#   define JSIGAR_FIELDS_NFSCLIENTV2_REMOVE 10
#   define JSIGAR_FIELDS_NFSCLIENTV2_RENAME 11
#   define JSIGAR_FIELDS_NFSCLIENTV2_LINK 12
#   define JSIGAR_FIELDS_NFSCLIENTV2_SYMLINK 13
#   define JSIGAR_FIELDS_NFSCLIENTV2_MKDIR 14
#   define JSIGAR_FIELDS_NFSCLIENTV2_RMDIR 15
#   define JSIGAR_FIELDS_NFSCLIENTV2_READDIR 16
#   define JSIGAR_FIELDS_NFSCLIENTV2_FSSTAT 17
#   define JSIGAR_FIELDS_NFSCLIENTV2_MAX 18
#define JSIGAR_FIELDS_PROCCPU 35
#   define JSIGAR_FIELDS_PROCCPU_PERCENT 0
#   define JSIGAR_FIELDS_PROCCPU_LAST_TIME 1
#   define JSIGAR_FIELDS_PROCCPU_START_TIME 2
#   define JSIGAR_FIELDS_PROCCPU_USER 3
#   define JSIGAR_FIELDS_PROCCPU_SYS 4
#   define JSIGAR_FIELDS_PROCCPU_TOTAL 5
#   define JSIGAR_FIELDS_PROCCPU_MAX 6
#define JSIGAR_FIELDS_PROCSTATE 36
#   define JSIGAR_FIELDS_PROCSTATE_STATE 0
#   define JSIGAR_FIELDS_PROCSTATE_NAME 1
#   define JSIGAR_FIELDS_PROCSTATE_PPID 2
#   define JSIGAR_FIELDS_PROCSTATE_TTY 3
#   define JSIGAR_FIELDS_PROCSTATE_NICE 4
#   define JSIGAR_FIELDS_PROCSTATE_PRIORITY 5
#   define JSIGAR_FIELDS_PROCSTATE_THREADS 6
#   define JSIGAR_FIELDS_PROCSTATE_PROCESSOR 7
#   define JSIGAR_FIELDS_PROCSTATE_MAX 8
#define JSIGAR_FIELDS_FILESYSTEM 37
#   define JSIGAR_FIELDS_FILESYSTEM_DIR_NAME 0
#   define JSIGAR_FIELDS_FILESYSTEM_DEV_NAME 1
#   define JSIGAR_FIELDS_FILESYSTEM_TYPE_NAME 2
#   define JSIGAR_FIELDS_FILESYSTEM_SYS_TYPE_NAME 3
#   define JSIGAR_FIELDS_FILESYSTEM_OPTIONS 4
#   define JSIGAR_FIELDS_FILESYSTEM_TYPE 5
#   define JSIGAR_FIELDS_FILESYSTEM_FLAGS 6
#   define JSIGAR_FIELDS_FILESYSTEM_MAX 7
#define JSIGAR_FIELDS_PROCDISKIO 38
#   define JSIGAR_FIELDS_PROCDISKIO_BYTES_READ 0
#   define JSIGAR_FIELDS_PROCDISKIO_BYTES_WRITTEN 1
#   define JSIGAR_FIELDS_PROCDISKIO_BYTES_TOTAL 2
#   define JSIGAR_FIELDS_PROCDISKIO_MAX 3
#define JSIGAR_FIELDS_THREADCPU 39
#   define JSIGAR_FIELDS_THREADCPU_USER 0
#   define JSIGAR_FIELDS_THREADCPU_SYS 1
#   define JSIGAR_FIELDS_THREADCPU_TOTAL 2
#   define JSIGAR_FIELDS_THREADCPU_MAX 3
#define JSIGAR_FIELDS_MAX 40
#define JAVA_SIGAR_INIT_FIELDS_PROCMEM(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_PROCMEM]) { \
        jsigar->fields[JSIGAR_FIELDS_PROCMEM] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCMEM])); \
        jsigar->fields[JSIGAR_FIELDS_PROCMEM]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids =  \
            malloc(JSIGAR_FIELDS_PROCMEM_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_SIZE] =  \
            JENV->GetFieldID(env, cls, "size", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_RESIDENT] =  \
            JENV->GetFieldID(env, cls, "resident", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_SHARE] =  \
            JENV->GetFieldID(env, cls, "share", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_MINOR_FAULTS] =  \
            JENV->GetFieldID(env, cls, "minorFaults", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_MAJOR_FAULTS] =  \
            JENV->GetFieldID(env, cls, "majorFaults", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_PAGE_FAULTS] =  \
            JENV->GetFieldID(env, cls, "pageFaults", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_PROCMEM(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_SIZE], s.size); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_RESIDENT], s.resident); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_SHARE], s.share); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_MINOR_FAULTS], s.minor_faults); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_MAJOR_FAULTS], s.major_faults); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_PAGE_FAULTS], s.page_faults);

#define JAVA_SIGAR_GET_FIELDS_PROCMEM(obj, s) \
    s.size = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_SIZE]); \
    s.resident = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_RESIDENT]); \
    s.share = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_SHARE]); \
    s.minor_faults = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_MINOR_FAULTS]); \
    s.major_faults = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_MAJOR_FAULTS]); \
    s.page_faults = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCMEM]->ids[JSIGAR_FIELDS_PROCMEM_PAGE_FAULTS]);

#define JAVA_SIGAR_INIT_FIELDS_CPU(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_CPU]) { \
        jsigar->fields[JSIGAR_FIELDS_CPU] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_CPU])); \
        jsigar->fields[JSIGAR_FIELDS_CPU]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_CPU]->ids =  \
            malloc(JSIGAR_FIELDS_CPU_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_CPU]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_USER] =  \
            JENV->GetFieldID(env, cls, "user", "J"); \
        jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_SYS] =  \
            JENV->GetFieldID(env, cls, "sys", "J"); \
        jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_NICE] =  \
            JENV->GetFieldID(env, cls, "nice", "J"); \
        jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_IDLE] =  \
            JENV->GetFieldID(env, cls, "idle", "J"); \
        jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_WAIT] =  \
            JENV->GetFieldID(env, cls, "wait", "J"); \
        jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_IRQ] =  \
            JENV->GetFieldID(env, cls, "irq", "J"); \
        jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_SOFT_IRQ] =  \
            JENV->GetFieldID(env, cls, "softIrq", "J"); \
        jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_STOLEN] =  \
            JENV->GetFieldID(env, cls, "stolen", "J"); \
        jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_TOTAL] =  \
            JENV->GetFieldID(env, cls, "total", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_CPU(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_USER], s.user); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_SYS], s.sys); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_NICE], s.nice); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_IDLE], s.idle); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_WAIT], s.wait); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_IRQ], s.irq); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_SOFT_IRQ], s.soft_irq); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_STOLEN], s.stolen); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_TOTAL], s.total);

#define JAVA_SIGAR_GET_FIELDS_CPU(obj, s) \
    s.user = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_USER]); \
    s.sys = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_SYS]); \
    s.nice = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_NICE]); \
    s.idle = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_IDLE]); \
    s.wait = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_WAIT]); \
    s.irq = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_IRQ]); \
    s.soft_irq = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_SOFT_IRQ]); \
    s.stolen = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_STOLEN]); \
    s.total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPU]->ids[JSIGAR_FIELDS_CPU_TOTAL]);

#define JAVA_SIGAR_INIT_FIELDS_PROCCUMULATIVEDISKIO(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]) { \
        jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO])); \
        jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]->ids =  \
            malloc(JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]->ids[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_BYTES_READ] =  \
            JENV->GetFieldID(env, cls, "bytesRead", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]->ids[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_BYTES_WRITTEN] =  \
            JENV->GetFieldID(env, cls, "bytesWritten", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]->ids[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_BYTES_TOTAL] =  \
            JENV->GetFieldID(env, cls, "bytesTotal", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_PROCCUMULATIVEDISKIO(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]->ids[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_BYTES_READ], s.bytes_read); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]->ids[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_BYTES_WRITTEN], s.bytes_written); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]->ids[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_BYTES_TOTAL], s.bytes_total);

#define JAVA_SIGAR_GET_FIELDS_PROCCUMULATIVEDISKIO(obj, s) \
    s.bytes_read = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]->ids[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_BYTES_READ]); \
    s.bytes_written = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]->ids[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_BYTES_WRITTEN]); \
    s.bytes_total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO]->ids[JSIGAR_FIELDS_PROCCUMULATIVEDISKIO_BYTES_TOTAL]);

#define JAVA_SIGAR_INIT_FIELDS_NETINTERFACECONFIG(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]) { \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG])); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids =  \
            malloc(JSIGAR_FIELDS_NETINTERFACECONFIG_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_NAME] =  \
            JENV->GetFieldID(env, cls, "name", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_HWADDR] =  \
            JENV->GetFieldID(env, cls, "hwaddr", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_TYPE] =  \
            JENV->GetFieldID(env, cls, "type", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_DESCRIPTION] =  \
            JENV->GetFieldID(env, cls, "description", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_ADDRESS] =  \
            JENV->GetFieldID(env, cls, "address", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_ADDRESS6] =  \
            JENV->GetFieldID(env, cls, "address6", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_PREFIX6_LENGTH] =  \
            JENV->GetFieldID(env, cls, "prefix6Length", "I"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_SCOPE6] =  \
            JENV->GetFieldID(env, cls, "scope6", "I"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_DESTINATION] =  \
            JENV->GetFieldID(env, cls, "destination", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_BROADCAST] =  \
            JENV->GetFieldID(env, cls, "broadcast", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_NETMASK] =  \
            JENV->GetFieldID(env, cls, "netmask", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_FLAGS] =  \
            JENV->GetFieldID(env, cls, "flags", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_MTU] =  \
            JENV->GetFieldID(env, cls, "mtu", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_METRIC] =  \
            JENV->GetFieldID(env, cls, "metric", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_TX_QUEUE_LEN] =  \
            JENV->GetFieldID(env, cls, "txQueueLen", "I"); \
    }

#define JAVA_SIGAR_SET_FIELDS_NETINTERFACECONFIG(cls, obj, s) \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_NAME], s.name); \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_HWADDR], s.hwaddr); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_TYPE], s.type); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_DESCRIPTION], s.description); \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_ADDRESS], s.address); \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_ADDRESS6], s.address6); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_PREFIX6_LENGTH], s.prefix6_length); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_SCOPE6], s.scope6); \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_DESTINATION], s.destination); \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_BROADCAST], s.broadcast); \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_NETMASK], s.netmask); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_FLAGS], s.flags); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_MTU], s.mtu); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_METRIC], s.metric); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_TX_QUEUE_LEN], s.tx_queue_len);

#define JAVA_SIGAR_GET_FIELDS_NETINTERFACECONFIG(obj, s) \
    s.name = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_NAME]); \
    s.hwaddr = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_HWADDR]); \
    s.type = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_TYPE]); \
    s.description = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_DESCRIPTION]); \
    s.address = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_ADDRESS]); \
    s.address6 = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_ADDRESS6]); \
    s.prefix6_length = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_PREFIX6_LENGTH]); \
    s.scope6 = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_SCOPE6]); \
    s.destination = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_DESTINATION]); \
    s.broadcast = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_BROADCAST]); \
    s.netmask = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_NETMASK]); \
    s.flags = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_FLAGS]); \
    s.mtu = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_MTU]); \
    s.metric = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_METRIC]); \
    s.tx_queue_len = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACECONFIG]->ids[JSIGAR_FIELDS_NETINTERFACECONFIG_TX_QUEUE_LEN]);

#define JAVA_SIGAR_INIT_FIELDS_NETCONNECTION(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]) { \
        jsigar->fields[JSIGAR_FIELDS_NETCONNECTION] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_NETCONNECTION])); \
        jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids =  \
            malloc(JSIGAR_FIELDS_NETCONNECTION_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_LOCAL_PORT] =  \
            JENV->GetFieldID(env, cls, "localPort", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_LOCAL_ADDRESS] =  \
            JENV->GetFieldID(env, cls, "localAddress", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_REMOTE_PORT] =  \
            JENV->GetFieldID(env, cls, "remotePort", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_REMOTE_ADDRESS] =  \
            JENV->GetFieldID(env, cls, "remoteAddress", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_TYPE] =  \
            JENV->GetFieldID(env, cls, "type", "I"); \
        jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_STATE] =  \
            JENV->GetFieldID(env, cls, "state", "I"); \
        jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_SEND_QUEUE] =  \
            JENV->GetFieldID(env, cls, "sendQueue", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_RECEIVE_QUEUE] =  \
            JENV->GetFieldID(env, cls, "receiveQueue", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_NETCONNECTION(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_LOCAL_PORT], s.local_port); \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_LOCAL_ADDRESS], s.local_address); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_REMOTE_PORT], s.remote_port); \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_REMOTE_ADDRESS], s.remote_address); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_TYPE], s.type); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_STATE], s.state); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_SEND_QUEUE], s.send_queue); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_RECEIVE_QUEUE], s.receive_queue);

#define JAVA_SIGAR_GET_FIELDS_NETCONNECTION(obj, s) \
    s.local_port = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_LOCAL_PORT]); \
    s.local_address = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_LOCAL_ADDRESS]); \
    s.remote_port = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_REMOTE_PORT]); \
    s.remote_address = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_REMOTE_ADDRESS]); \
    s.type = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_TYPE]); \
    s.state = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_STATE]); \
    s.send_queue = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_SEND_QUEUE]); \
    s.receive_queue = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETCONNECTION]->ids[JSIGAR_FIELDS_NETCONNECTION_RECEIVE_QUEUE]);

#define JAVA_SIGAR_INIT_FIELDS_TCP(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_TCP]) { \
        jsigar->fields[JSIGAR_FIELDS_TCP] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_TCP])); \
        jsigar->fields[JSIGAR_FIELDS_TCP]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_TCP]->ids =  \
            malloc(JSIGAR_FIELDS_TCP_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_TCP]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_ACTIVE_OPENS] =  \
            JENV->GetFieldID(env, cls, "activeOpens", "J"); \
        jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_PASSIVE_OPENS] =  \
            JENV->GetFieldID(env, cls, "passiveOpens", "J"); \
        jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_ATTEMPT_FAILS] =  \
            JENV->GetFieldID(env, cls, "attemptFails", "J"); \
        jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_ESTAB_RESETS] =  \
            JENV->GetFieldID(env, cls, "estabResets", "J"); \
        jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_CURR_ESTAB] =  \
            JENV->GetFieldID(env, cls, "currEstab", "J"); \
        jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_IN_SEGS] =  \
            JENV->GetFieldID(env, cls, "inSegs", "J"); \
        jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_OUT_SEGS] =  \
            JENV->GetFieldID(env, cls, "outSegs", "J"); \
        jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_RETRANS_SEGS] =  \
            JENV->GetFieldID(env, cls, "retransSegs", "J"); \
        jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_IN_ERRS] =  \
            JENV->GetFieldID(env, cls, "inErrs", "J"); \
        jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_OUT_RSTS] =  \
            JENV->GetFieldID(env, cls, "outRsts", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_TCP(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_ACTIVE_OPENS], s.active_opens); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_PASSIVE_OPENS], s.passive_opens); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_ATTEMPT_FAILS], s.attempt_fails); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_ESTAB_RESETS], s.estab_resets); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_CURR_ESTAB], s.curr_estab); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_IN_SEGS], s.in_segs); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_OUT_SEGS], s.out_segs); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_RETRANS_SEGS], s.retrans_segs); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_IN_ERRS], s.in_errs); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_OUT_RSTS], s.out_rsts);

#define JAVA_SIGAR_GET_FIELDS_TCP(obj, s) \
    s.active_opens = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_ACTIVE_OPENS]); \
    s.passive_opens = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_PASSIVE_OPENS]); \
    s.attempt_fails = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_ATTEMPT_FAILS]); \
    s.estab_resets = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_ESTAB_RESETS]); \
    s.curr_estab = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_CURR_ESTAB]); \
    s.in_segs = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_IN_SEGS]); \
    s.out_segs = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_OUT_SEGS]); \
    s.retrans_segs = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_RETRANS_SEGS]); \
    s.in_errs = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_IN_ERRS]); \
    s.out_rsts = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_TCP]->ids[JSIGAR_FIELDS_TCP_OUT_RSTS]);

#define JAVA_SIGAR_INIT_FIELDS_MEM(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_MEM]) { \
        jsigar->fields[JSIGAR_FIELDS_MEM] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_MEM])); \
        jsigar->fields[JSIGAR_FIELDS_MEM]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_MEM]->ids =  \
            malloc(JSIGAR_FIELDS_MEM_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_MEM]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_TOTAL] =  \
            JENV->GetFieldID(env, cls, "total", "J"); \
        jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_RAM] =  \
            JENV->GetFieldID(env, cls, "ram", "J"); \
        jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_USED] =  \
            JENV->GetFieldID(env, cls, "used", "J"); \
        jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_FREE] =  \
            JENV->GetFieldID(env, cls, "free", "J"); \
        jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_ACTUAL_USED] =  \
            JENV->GetFieldID(env, cls, "actualUsed", "J"); \
        jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_ACTUAL_FREE] =  \
            JENV->GetFieldID(env, cls, "actualFree", "J"); \
        jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_USED_PERCENT] =  \
            JENV->GetFieldID(env, cls, "usedPercent", "D"); \
        jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_FREE_PERCENT] =  \
            JENV->GetFieldID(env, cls, "freePercent", "D"); \
    }

#define JAVA_SIGAR_SET_FIELDS_MEM(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_TOTAL], s.total); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_RAM], s.ram); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_USED], s.used); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_FREE], s.free); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_ACTUAL_USED], s.actual_used); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_ACTUAL_FREE], s.actual_free); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_USED_PERCENT], s.used_percent); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_FREE_PERCENT], s.free_percent);

#define JAVA_SIGAR_GET_FIELDS_MEM(obj, s) \
    s.total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_TOTAL]); \
    s.ram = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_RAM]); \
    s.used = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_USED]); \
    s.free = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_FREE]); \
    s.actual_used = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_ACTUAL_USED]); \
    s.actual_free = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_ACTUAL_FREE]); \
    s.used_percent = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_USED_PERCENT]); \
    s.free_percent = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_MEM]->ids[JSIGAR_FIELDS_MEM_FREE_PERCENT]);

#define JAVA_SIGAR_INIT_FIELDS_NETROUTE(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_NETROUTE]) { \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_NETROUTE])); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids =  \
            malloc(JSIGAR_FIELDS_NETROUTE_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_DESTINATION] =  \
            JENV->GetFieldID(env, cls, "destination", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_GATEWAY] =  \
            JENV->GetFieldID(env, cls, "gateway", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_FLAGS] =  \
            JENV->GetFieldID(env, cls, "flags", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_REFCNT] =  \
            JENV->GetFieldID(env, cls, "refcnt", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_USE] =  \
            JENV->GetFieldID(env, cls, "use", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_METRIC] =  \
            JENV->GetFieldID(env, cls, "metric", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_MASK] =  \
            JENV->GetFieldID(env, cls, "mask", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_MTU] =  \
            JENV->GetFieldID(env, cls, "mtu", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_WINDOW] =  \
            JENV->GetFieldID(env, cls, "window", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_IRTT] =  \
            JENV->GetFieldID(env, cls, "irtt", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_IFNAME] =  \
            JENV->GetFieldID(env, cls, "ifname", "Ljava/lang/String;"); \
    }

#define JAVA_SIGAR_SET_FIELDS_NETROUTE(cls, obj, s) \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_DESTINATION], s.destination); \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_GATEWAY], s.gateway); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_FLAGS], s.flags); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_REFCNT], s.refcnt); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_USE], s.use); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_METRIC], s.metric); \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_MASK], s.mask); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_MTU], s.mtu); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_WINDOW], s.window); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_IRTT], s.irtt); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_IFNAME], s.ifname);

#define JAVA_SIGAR_GET_FIELDS_NETROUTE(obj, s) \
    s.destination = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_DESTINATION]); \
    s.gateway = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_GATEWAY]); \
    s.flags = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_FLAGS]); \
    s.refcnt = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_REFCNT]); \
    s.use = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_USE]); \
    s.metric = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_METRIC]); \
    s.mask = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_MASK]); \
    s.mtu = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_MTU]); \
    s.window = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_WINDOW]); \
    s.irtt = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_IRTT]); \
    s.ifname = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETROUTE]->ids[JSIGAR_FIELDS_NETROUTE_IFNAME]);

#define JAVA_SIGAR_INIT_FIELDS_DIRSTAT(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_DIRSTAT]) { \
        jsigar->fields[JSIGAR_FIELDS_DIRSTAT] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_DIRSTAT])); \
        jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids =  \
            malloc(JSIGAR_FIELDS_DIRSTAT_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_TOTAL] =  \
            JENV->GetFieldID(env, cls, "total", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_FILES] =  \
            JENV->GetFieldID(env, cls, "files", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_SUBDIRS] =  \
            JENV->GetFieldID(env, cls, "subdirs", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_SYMLINKS] =  \
            JENV->GetFieldID(env, cls, "symlinks", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_CHRDEVS] =  \
            JENV->GetFieldID(env, cls, "chrdevs", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_BLKDEVS] =  \
            JENV->GetFieldID(env, cls, "blkdevs", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_SOCKETS] =  \
            JENV->GetFieldID(env, cls, "sockets", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_DISK_USAGE] =  \
            JENV->GetFieldID(env, cls, "diskUsage", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_DIRSTAT(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_TOTAL], s.total); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_FILES], s.files); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_SUBDIRS], s.subdirs); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_SYMLINKS], s.symlinks); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_CHRDEVS], s.chrdevs); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_BLKDEVS], s.blkdevs); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_SOCKETS], s.sockets); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_DISK_USAGE], s.disk_usage);

#define JAVA_SIGAR_GET_FIELDS_DIRSTAT(obj, s) \
    s.total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_TOTAL]); \
    s.files = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_FILES]); \
    s.subdirs = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_SUBDIRS]); \
    s.symlinks = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_SYMLINKS]); \
    s.chrdevs = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_CHRDEVS]); \
    s.blkdevs = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_BLKDEVS]); \
    s.sockets = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_SOCKETS]); \
    s.disk_usage = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRSTAT]->ids[JSIGAR_FIELDS_DIRSTAT_DISK_USAGE]);

#define JAVA_SIGAR_INIT_FIELDS_FILESYSTEMUSAGE(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]) { \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE])); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids =  \
            malloc(JSIGAR_FIELDS_FILESYSTEMUSAGE_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_TOTAL] =  \
            JENV->GetFieldID(env, cls, "total", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_FREE] =  \
            JENV->GetFieldID(env, cls, "free", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_USED] =  \
            JENV->GetFieldID(env, cls, "used", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_AVAIL] =  \
            JENV->GetFieldID(env, cls, "avail", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_FILES] =  \
            JENV->GetFieldID(env, cls, "files", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_FREE_FILES] =  \
            JENV->GetFieldID(env, cls, "freeFiles", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_READS] =  \
            JENV->GetFieldID(env, cls, "diskReads", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_WRITES] =  \
            JENV->GetFieldID(env, cls, "diskWrites", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_READ_BYTES] =  \
            JENV->GetFieldID(env, cls, "diskReadBytes", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_WRITE_BYTES] =  \
            JENV->GetFieldID(env, cls, "diskWriteBytes", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_QUEUE] =  \
            JENV->GetFieldID(env, cls, "diskQueue", "D"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_SERVICE_TIME] =  \
            JENV->GetFieldID(env, cls, "diskServiceTime", "D"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_USE_PERCENT] =  \
            JENV->GetFieldID(env, cls, "usePercent", "D"); \
    }

#define JAVA_SIGAR_SET_FIELDS_FILESYSTEMUSAGE(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_TOTAL], s.total); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_FREE], s.free); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_USED], s.used); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_AVAIL], s.avail); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_FILES], s.files); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_FREE_FILES], s.free_files); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_READS], s.disk_reads); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_WRITES], s.disk_writes); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_READ_BYTES], s.disk_read_bytes); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_WRITE_BYTES], s.disk_write_bytes); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_QUEUE], s.disk_queue); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_SERVICE_TIME], s.disk_service_time); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_USE_PERCENT], s.use_percent);

#define JAVA_SIGAR_GET_FIELDS_FILESYSTEMUSAGE(obj, s) \
    s.total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_TOTAL]); \
    s.free = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_FREE]); \
    s.used = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_USED]); \
    s.avail = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_AVAIL]); \
    s.files = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_FILES]); \
    s.free_files = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_FREE_FILES]); \
    s.disk_reads = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_READS]); \
    s.disk_writes = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_WRITES]); \
    s.disk_read_bytes = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_READ_BYTES]); \
    s.disk_write_bytes = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_WRITE_BYTES]); \
    s.disk_queue = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_QUEUE]); \
    s.disk_service_time = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_DISK_SERVICE_TIME]); \
    s.use_percent = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEMUSAGE]->ids[JSIGAR_FIELDS_FILESYSTEMUSAGE_USE_PERCENT]);

#define JAVA_SIGAR_INIT_FIELDS_NETSTAT(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_NETSTAT]) { \
        jsigar->fields[JSIGAR_FIELDS_NETSTAT] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_NETSTAT])); \
        jsigar->fields[JSIGAR_FIELDS_NETSTAT]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids =  \
            malloc(JSIGAR_FIELDS_NETSTAT_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids[JSIGAR_FIELDS_NETSTAT_TCP_INBOUND_TOTAL] =  \
            JENV->GetFieldID(env, cls, "tcpInboundTotal", "I"); \
        jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids[JSIGAR_FIELDS_NETSTAT_TCP_OUTBOUND_TOTAL] =  \
            JENV->GetFieldID(env, cls, "tcpOutboundTotal", "I"); \
        jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids[JSIGAR_FIELDS_NETSTAT_ALL_INBOUND_TOTAL] =  \
            JENV->GetFieldID(env, cls, "allInboundTotal", "I"); \
        jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids[JSIGAR_FIELDS_NETSTAT_ALL_OUTBOUND_TOTAL] =  \
            JENV->GetFieldID(env, cls, "allOutboundTotal", "I"); \
    }

#define JAVA_SIGAR_SET_FIELDS_NETSTAT(cls, obj, s) \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids[JSIGAR_FIELDS_NETSTAT_TCP_INBOUND_TOTAL], s.tcp_inbound_total); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids[JSIGAR_FIELDS_NETSTAT_TCP_OUTBOUND_TOTAL], s.tcp_outbound_total); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids[JSIGAR_FIELDS_NETSTAT_ALL_INBOUND_TOTAL], s.all_inbound_total); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids[JSIGAR_FIELDS_NETSTAT_ALL_OUTBOUND_TOTAL], s.all_outbound_total);

#define JAVA_SIGAR_GET_FIELDS_NETSTAT(obj, s) \
    s.tcp_inbound_total = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids[JSIGAR_FIELDS_NETSTAT_TCP_INBOUND_TOTAL]); \
    s.tcp_outbound_total = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids[JSIGAR_FIELDS_NETSTAT_TCP_OUTBOUND_TOTAL]); \
    s.all_inbound_total = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids[JSIGAR_FIELDS_NETSTAT_ALL_INBOUND_TOTAL]); \
    s.all_outbound_total = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETSTAT]->ids[JSIGAR_FIELDS_NETSTAT_ALL_OUTBOUND_TOTAL]);

#define JAVA_SIGAR_INIT_FIELDS_RESOURCELIMIT(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]) { \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT])); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids =  \
            malloc(JSIGAR_FIELDS_RESOURCELIMIT_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_CPU_CUR] =  \
            JENV->GetFieldID(env, cls, "cpuCur", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_CPU_MAX] =  \
            JENV->GetFieldID(env, cls, "cpuMax", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_FILE_SIZE_CUR] =  \
            JENV->GetFieldID(env, cls, "fileSizeCur", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_FILE_SIZE_MAX] =  \
            JENV->GetFieldID(env, cls, "fileSizeMax", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_PIPE_SIZE_MAX] =  \
            JENV->GetFieldID(env, cls, "pipeSizeMax", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_PIPE_SIZE_CUR] =  \
            JENV->GetFieldID(env, cls, "pipeSizeCur", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_DATA_CUR] =  \
            JENV->GetFieldID(env, cls, "dataCur", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_DATA_MAX] =  \
            JENV->GetFieldID(env, cls, "dataMax", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_STACK_CUR] =  \
            JENV->GetFieldID(env, cls, "stackCur", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_STACK_MAX] =  \
            JENV->GetFieldID(env, cls, "stackMax", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_CORE_CUR] =  \
            JENV->GetFieldID(env, cls, "coreCur", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_CORE_MAX] =  \
            JENV->GetFieldID(env, cls, "coreMax", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_MEMORY_CUR] =  \
            JENV->GetFieldID(env, cls, "memoryCur", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_MEMORY_MAX] =  \
            JENV->GetFieldID(env, cls, "memoryMax", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_PROCESSES_CUR] =  \
            JENV->GetFieldID(env, cls, "processesCur", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_PROCESSES_MAX] =  \
            JENV->GetFieldID(env, cls, "processesMax", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_OPEN_FILES_CUR] =  \
            JENV->GetFieldID(env, cls, "openFilesCur", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_OPEN_FILES_MAX] =  \
            JENV->GetFieldID(env, cls, "openFilesMax", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_VIRTUAL_MEMORY_CUR] =  \
            JENV->GetFieldID(env, cls, "virtualMemoryCur", "J"); \
        jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_VIRTUAL_MEMORY_MAX] =  \
            JENV->GetFieldID(env, cls, "virtualMemoryMax", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_RESOURCELIMIT(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_CPU_CUR], s.cpu_cur); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_CPU_MAX], s.cpu_max); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_FILE_SIZE_CUR], s.file_size_cur); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_FILE_SIZE_MAX], s.file_size_max); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_PIPE_SIZE_MAX], s.pipe_size_max); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_PIPE_SIZE_CUR], s.pipe_size_cur); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_DATA_CUR], s.data_cur); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_DATA_MAX], s.data_max); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_STACK_CUR], s.stack_cur); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_STACK_MAX], s.stack_max); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_CORE_CUR], s.core_cur); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_CORE_MAX], s.core_max); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_MEMORY_CUR], s.memory_cur); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_MEMORY_MAX], s.memory_max); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_PROCESSES_CUR], s.processes_cur); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_PROCESSES_MAX], s.processes_max); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_OPEN_FILES_CUR], s.open_files_cur); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_OPEN_FILES_MAX], s.open_files_max); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_VIRTUAL_MEMORY_CUR], s.virtual_memory_cur); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_VIRTUAL_MEMORY_MAX], s.virtual_memory_max);

#define JAVA_SIGAR_GET_FIELDS_RESOURCELIMIT(obj, s) \
    s.cpu_cur = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_CPU_CUR]); \
    s.cpu_max = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_CPU_MAX]); \
    s.file_size_cur = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_FILE_SIZE_CUR]); \
    s.file_size_max = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_FILE_SIZE_MAX]); \
    s.pipe_size_max = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_PIPE_SIZE_MAX]); \
    s.pipe_size_cur = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_PIPE_SIZE_CUR]); \
    s.data_cur = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_DATA_CUR]); \
    s.data_max = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_DATA_MAX]); \
    s.stack_cur = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_STACK_CUR]); \
    s.stack_max = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_STACK_MAX]); \
    s.core_cur = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_CORE_CUR]); \
    s.core_max = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_CORE_MAX]); \
    s.memory_cur = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_MEMORY_CUR]); \
    s.memory_max = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_MEMORY_MAX]); \
    s.processes_cur = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_PROCESSES_CUR]); \
    s.processes_max = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_PROCESSES_MAX]); \
    s.open_files_cur = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_OPEN_FILES_CUR]); \
    s.open_files_max = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_OPEN_FILES_MAX]); \
    s.virtual_memory_cur = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_VIRTUAL_MEMORY_CUR]); \
    s.virtual_memory_max = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_RESOURCELIMIT]->ids[JSIGAR_FIELDS_RESOURCELIMIT_VIRTUAL_MEMORY_MAX]);

#define JAVA_SIGAR_INIT_FIELDS_NFSCLIENTV3(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]) { \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3])); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids =  \
            malloc(JSIGAR_FIELDS_NFSCLIENTV3_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_NULL] =  \
            JENV->GetFieldID(env, cls, "_null", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_GETATTR] =  \
            JENV->GetFieldID(env, cls, "getattr", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_SETATTR] =  \
            JENV->GetFieldID(env, cls, "setattr", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_LOOKUP] =  \
            JENV->GetFieldID(env, cls, "lookup", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_ACCESS] =  \
            JENV->GetFieldID(env, cls, "access", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_READLINK] =  \
            JENV->GetFieldID(env, cls, "readlink", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_READ] =  \
            JENV->GetFieldID(env, cls, "read", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_WRITE] =  \
            JENV->GetFieldID(env, cls, "write", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_CREATE] =  \
            JENV->GetFieldID(env, cls, "create", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_MKDIR] =  \
            JENV->GetFieldID(env, cls, "mkdir", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_SYMLINK] =  \
            JENV->GetFieldID(env, cls, "symlink", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_MKNOD] =  \
            JENV->GetFieldID(env, cls, "mknod", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_REMOVE] =  \
            JENV->GetFieldID(env, cls, "remove", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_RMDIR] =  \
            JENV->GetFieldID(env, cls, "rmdir", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_RENAME] =  \
            JENV->GetFieldID(env, cls, "rename", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_LINK] =  \
            JENV->GetFieldID(env, cls, "link", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_READDIR] =  \
            JENV->GetFieldID(env, cls, "readdir", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_READDIRPLUS] =  \
            JENV->GetFieldID(env, cls, "readdirplus", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_FSSTAT] =  \
            JENV->GetFieldID(env, cls, "fsstat", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_FSINFO] =  \
            JENV->GetFieldID(env, cls, "fsinfo", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_PATHCONF] =  \
            JENV->GetFieldID(env, cls, "pathconf", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_COMMIT] =  \
            JENV->GetFieldID(env, cls, "commit", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_NFSCLIENTV3(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_NULL], s.null); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_GETATTR], s.getattr); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_SETATTR], s.setattr); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_LOOKUP], s.lookup); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_ACCESS], s.access); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_READLINK], s.readlink); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_READ], s.read); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_WRITE], s.write); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_CREATE], s.create); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_MKDIR], s.mkdir); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_SYMLINK], s.symlink); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_MKNOD], s.mknod); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_REMOVE], s.remove); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_RMDIR], s.rmdir); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_RENAME], s.rename); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_LINK], s.link); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_READDIR], s.readdir); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_READDIRPLUS], s.readdirplus); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_FSSTAT], s.fsstat); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_FSINFO], s.fsinfo); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_PATHCONF], s.pathconf); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_COMMIT], s.commit);

#define JAVA_SIGAR_GET_FIELDS_NFSCLIENTV3(obj, s) \
    s.null = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_NULL]); \
    s.getattr = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_GETATTR]); \
    s.setattr = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_SETATTR]); \
    s.lookup = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_LOOKUP]); \
    s.access = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_ACCESS]); \
    s.readlink = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_READLINK]); \
    s.read = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_READ]); \
    s.write = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_WRITE]); \
    s.create = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_CREATE]); \
    s.mkdir = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_MKDIR]); \
    s.symlink = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_SYMLINK]); \
    s.mknod = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_MKNOD]); \
    s.remove = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_REMOVE]); \
    s.rmdir = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_RMDIR]); \
    s.rename = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_RENAME]); \
    s.link = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_LINK]); \
    s.readdir = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_READDIR]); \
    s.readdirplus = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_READDIRPLUS]); \
    s.fsstat = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_FSSTAT]); \
    s.fsinfo = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_FSINFO]); \
    s.pathconf = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_PATHCONF]); \
    s.commit = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV3]->ids[JSIGAR_FIELDS_NFSCLIENTV3_COMMIT]);

#define JAVA_SIGAR_INIT_FIELDS_PROCCRED(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_PROCCRED]) { \
        jsigar->fields[JSIGAR_FIELDS_PROCCRED] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCCRED])); \
        jsigar->fields[JSIGAR_FIELDS_PROCCRED]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids =  \
            malloc(JSIGAR_FIELDS_PROCCRED_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids[JSIGAR_FIELDS_PROCCRED_UID] =  \
            JENV->GetFieldID(env, cls, "uid", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids[JSIGAR_FIELDS_PROCCRED_GID] =  \
            JENV->GetFieldID(env, cls, "gid", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids[JSIGAR_FIELDS_PROCCRED_EUID] =  \
            JENV->GetFieldID(env, cls, "euid", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids[JSIGAR_FIELDS_PROCCRED_EGID] =  \
            JENV->GetFieldID(env, cls, "egid", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_PROCCRED(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids[JSIGAR_FIELDS_PROCCRED_UID], s.uid); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids[JSIGAR_FIELDS_PROCCRED_GID], s.gid); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids[JSIGAR_FIELDS_PROCCRED_EUID], s.euid); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids[JSIGAR_FIELDS_PROCCRED_EGID], s.egid);

#define JAVA_SIGAR_GET_FIELDS_PROCCRED(obj, s) \
    s.uid = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids[JSIGAR_FIELDS_PROCCRED_UID]); \
    s.gid = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids[JSIGAR_FIELDS_PROCCRED_GID]); \
    s.euid = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids[JSIGAR_FIELDS_PROCCRED_EUID]); \
    s.egid = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCRED]->ids[JSIGAR_FIELDS_PROCCRED_EGID]);

#define JAVA_SIGAR_INIT_FIELDS_NFSSERVERV3(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]) { \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3])); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids =  \
            malloc(JSIGAR_FIELDS_NFSSERVERV3_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_NULL] =  \
            JENV->GetFieldID(env, cls, "_null", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_GETATTR] =  \
            JENV->GetFieldID(env, cls, "getattr", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_SETATTR] =  \
            JENV->GetFieldID(env, cls, "setattr", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_LOOKUP] =  \
            JENV->GetFieldID(env, cls, "lookup", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_ACCESS] =  \
            JENV->GetFieldID(env, cls, "access", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_READLINK] =  \
            JENV->GetFieldID(env, cls, "readlink", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_READ] =  \
            JENV->GetFieldID(env, cls, "read", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_WRITE] =  \
            JENV->GetFieldID(env, cls, "write", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_CREATE] =  \
            JENV->GetFieldID(env, cls, "create", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_MKDIR] =  \
            JENV->GetFieldID(env, cls, "mkdir", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_SYMLINK] =  \
            JENV->GetFieldID(env, cls, "symlink", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_MKNOD] =  \
            JENV->GetFieldID(env, cls, "mknod", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_REMOVE] =  \
            JENV->GetFieldID(env, cls, "remove", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_RMDIR] =  \
            JENV->GetFieldID(env, cls, "rmdir", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_RENAME] =  \
            JENV->GetFieldID(env, cls, "rename", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_LINK] =  \
            JENV->GetFieldID(env, cls, "link", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_READDIR] =  \
            JENV->GetFieldID(env, cls, "readdir", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_READDIRPLUS] =  \
            JENV->GetFieldID(env, cls, "readdirplus", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_FSSTAT] =  \
            JENV->GetFieldID(env, cls, "fsstat", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_FSINFO] =  \
            JENV->GetFieldID(env, cls, "fsinfo", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_PATHCONF] =  \
            JENV->GetFieldID(env, cls, "pathconf", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_COMMIT] =  \
            JENV->GetFieldID(env, cls, "commit", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_NFSSERVERV3(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_NULL], s.null); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_GETATTR], s.getattr); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_SETATTR], s.setattr); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_LOOKUP], s.lookup); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_ACCESS], s.access); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_READLINK], s.readlink); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_READ], s.read); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_WRITE], s.write); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_CREATE], s.create); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_MKDIR], s.mkdir); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_SYMLINK], s.symlink); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_MKNOD], s.mknod); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_REMOVE], s.remove); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_RMDIR], s.rmdir); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_RENAME], s.rename); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_LINK], s.link); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_READDIR], s.readdir); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_READDIRPLUS], s.readdirplus); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_FSSTAT], s.fsstat); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_FSINFO], s.fsinfo); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_PATHCONF], s.pathconf); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_COMMIT], s.commit);

#define JAVA_SIGAR_GET_FIELDS_NFSSERVERV3(obj, s) \
    s.null = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_NULL]); \
    s.getattr = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_GETATTR]); \
    s.setattr = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_SETATTR]); \
    s.lookup = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_LOOKUP]); \
    s.access = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_ACCESS]); \
    s.readlink = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_READLINK]); \
    s.read = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_READ]); \
    s.write = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_WRITE]); \
    s.create = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_CREATE]); \
    s.mkdir = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_MKDIR]); \
    s.symlink = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_SYMLINK]); \
    s.mknod = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_MKNOD]); \
    s.remove = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_REMOVE]); \
    s.rmdir = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_RMDIR]); \
    s.rename = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_RENAME]); \
    s.link = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_LINK]); \
    s.readdir = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_READDIR]); \
    s.readdirplus = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_READDIRPLUS]); \
    s.fsstat = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_FSSTAT]); \
    s.fsinfo = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_FSINFO]); \
    s.pathconf = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_PATHCONF]); \
    s.commit = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV3]->ids[JSIGAR_FIELDS_NFSSERVERV3_COMMIT]);

#define JAVA_SIGAR_INIT_FIELDS_ARP(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_ARP]) { \
        jsigar->fields[JSIGAR_FIELDS_ARP] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_ARP])); \
        jsigar->fields[JSIGAR_FIELDS_ARP]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_ARP]->ids =  \
            malloc(JSIGAR_FIELDS_ARP_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_ARP]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_IFNAME] =  \
            JENV->GetFieldID(env, cls, "ifname", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_HWADDR] =  \
            JENV->GetFieldID(env, cls, "hwaddr", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_TYPE] =  \
            JENV->GetFieldID(env, cls, "type", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_ADDRESS] =  \
            JENV->GetFieldID(env, cls, "address", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_FLAGS] =  \
            JENV->GetFieldID(env, cls, "flags", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_ARP(cls, obj, s) \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_IFNAME], s.ifname); \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_HWADDR], s.hwaddr); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_TYPE], s.type); \
    JENV->SetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_ADDRESS], s.address); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_FLAGS], s.flags);

#define JAVA_SIGAR_GET_FIELDS_ARP(obj, s) \
    s.ifname = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_IFNAME]); \
    s.hwaddr = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_HWADDR]); \
    s.type = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_TYPE]); \
    s.address = JENV->GetNetAddressField(env, obj, jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_ADDRESS]); \
    s.flags = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_ARP]->ids[JSIGAR_FIELDS_ARP_FLAGS]);

#define JAVA_SIGAR_INIT_FIELDS_CPUINFO(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_CPUINFO]) { \
        jsigar->fields[JSIGAR_FIELDS_CPUINFO] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_CPUINFO])); \
        jsigar->fields[JSIGAR_FIELDS_CPUINFO]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids =  \
            malloc(JSIGAR_FIELDS_CPUINFO_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_VENDOR] =  \
            JENV->GetFieldID(env, cls, "vendor", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_MODEL] =  \
            JENV->GetFieldID(env, cls, "model", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_MHZ] =  \
            JENV->GetFieldID(env, cls, "mhz", "I"); \
        jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_MHZ_MAX] =  \
            JENV->GetFieldID(env, cls, "mhzMax", "I"); \
        jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_MHZ_MIN] =  \
            JENV->GetFieldID(env, cls, "mhzMin", "I"); \
        jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_CACHE_SIZE] =  \
            JENV->GetFieldID(env, cls, "cacheSize", "J"); \
        jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_TOTAL_CORES] =  \
            JENV->GetFieldID(env, cls, "totalCores", "I"); \
        jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_TOTAL_SOCKETS] =  \
            JENV->GetFieldID(env, cls, "totalSockets", "I"); \
        jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_CORES_PER_SOCKET] =  \
            JENV->GetFieldID(env, cls, "coresPerSocket", "I"); \
    }

#define JAVA_SIGAR_SET_FIELDS_CPUINFO(cls, obj, s) \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_VENDOR], s.vendor); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_MODEL], s.model); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_MHZ], s.mhz); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_MHZ_MAX], s.mhz_max); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_MHZ_MIN], s.mhz_min); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_CACHE_SIZE], s.cache_size); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_TOTAL_CORES], s.total_cores); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_TOTAL_SOCKETS], s.total_sockets); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_CORES_PER_SOCKET], s.cores_per_socket);

#define JAVA_SIGAR_GET_FIELDS_CPUINFO(obj, s) \
    s.vendor = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_VENDOR]); \
    s.model = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_MODEL]); \
    s.mhz = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_MHZ]); \
    s.mhz_max = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_MHZ_MAX]); \
    s.mhz_min = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_MHZ_MIN]); \
    s.cache_size = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_CACHE_SIZE]); \
    s.total_cores = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_TOTAL_CORES]); \
    s.total_sockets = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_TOTAL_SOCKETS]); \
    s.cores_per_socket = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUINFO]->ids[JSIGAR_FIELDS_CPUINFO_CORES_PER_SOCKET]);

#define JAVA_SIGAR_INIT_FIELDS_DIRUSAGE(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]) { \
        jsigar->fields[JSIGAR_FIELDS_DIRUSAGE] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_DIRUSAGE])); \
        jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids =  \
            malloc(JSIGAR_FIELDS_DIRUSAGE_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_TOTAL] =  \
            JENV->GetFieldID(env, cls, "total", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_FILES] =  \
            JENV->GetFieldID(env, cls, "files", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_SUBDIRS] =  \
            JENV->GetFieldID(env, cls, "subdirs", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_SYMLINKS] =  \
            JENV->GetFieldID(env, cls, "symlinks", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_CHRDEVS] =  \
            JENV->GetFieldID(env, cls, "chrdevs", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_BLKDEVS] =  \
            JENV->GetFieldID(env, cls, "blkdevs", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_SOCKETS] =  \
            JENV->GetFieldID(env, cls, "sockets", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_DISK_USAGE] =  \
            JENV->GetFieldID(env, cls, "diskUsage", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_DIRUSAGE(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_TOTAL], s.total); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_FILES], s.files); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_SUBDIRS], s.subdirs); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_SYMLINKS], s.symlinks); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_CHRDEVS], s.chrdevs); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_BLKDEVS], s.blkdevs); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_SOCKETS], s.sockets); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_DISK_USAGE], s.disk_usage);

#define JAVA_SIGAR_GET_FIELDS_DIRUSAGE(obj, s) \
    s.total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_TOTAL]); \
    s.files = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_FILES]); \
    s.subdirs = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_SUBDIRS]); \
    s.symlinks = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_SYMLINKS]); \
    s.chrdevs = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_CHRDEVS]); \
    s.blkdevs = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_BLKDEVS]); \
    s.sockets = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_SOCKETS]); \
    s.disk_usage = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DIRUSAGE]->ids[JSIGAR_FIELDS_DIRUSAGE_DISK_USAGE]);

#define JAVA_SIGAR_INIT_FIELDS_FILEATTRS(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_FILEATTRS]) { \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_FILEATTRS])); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids =  \
            malloc(JSIGAR_FIELDS_FILEATTRS_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_PERMISSIONS] =  \
            JENV->GetFieldID(env, cls, "permissions", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_TYPE] =  \
            JENV->GetFieldID(env, cls, "type", "I"); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_UID] =  \
            JENV->GetFieldID(env, cls, "uid", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_GID] =  \
            JENV->GetFieldID(env, cls, "gid", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_INODE] =  \
            JENV->GetFieldID(env, cls, "inode", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_DEVICE] =  \
            JENV->GetFieldID(env, cls, "device", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_NLINK] =  \
            JENV->GetFieldID(env, cls, "nlink", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_SIZE] =  \
            JENV->GetFieldID(env, cls, "size", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_ATIME] =  \
            JENV->GetFieldID(env, cls, "atime", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_CTIME] =  \
            JENV->GetFieldID(env, cls, "ctime", "J"); \
        jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_MTIME] =  \
            JENV->GetFieldID(env, cls, "mtime", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_FILEATTRS(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_PERMISSIONS], s.permissions); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_TYPE], s.type); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_UID], s.uid); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_GID], s.gid); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_INODE], s.inode); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_DEVICE], s.device); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_NLINK], s.nlink); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_SIZE], s.size); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_ATIME], s.atime); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_CTIME], s.ctime); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_MTIME], s.mtime);

#define JAVA_SIGAR_GET_FIELDS_FILEATTRS(obj, s) \
    s.permissions = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_PERMISSIONS]); \
    s.type = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_TYPE]); \
    s.uid = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_UID]); \
    s.gid = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_GID]); \
    s.inode = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_INODE]); \
    s.device = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_DEVICE]); \
    s.nlink = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_NLINK]); \
    s.size = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_SIZE]); \
    s.atime = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_ATIME]); \
    s.ctime = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_CTIME]); \
    s.mtime = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILEATTRS]->ids[JSIGAR_FIELDS_FILEATTRS_MTIME]);

#define JAVA_SIGAR_INIT_FIELDS_PROCTIME(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_PROCTIME]) { \
        jsigar->fields[JSIGAR_FIELDS_PROCTIME] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCTIME])); \
        jsigar->fields[JSIGAR_FIELDS_PROCTIME]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids =  \
            malloc(JSIGAR_FIELDS_PROCTIME_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids[JSIGAR_FIELDS_PROCTIME_START_TIME] =  \
            JENV->GetFieldID(env, cls, "startTime", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids[JSIGAR_FIELDS_PROCTIME_USER] =  \
            JENV->GetFieldID(env, cls, "user", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids[JSIGAR_FIELDS_PROCTIME_SYS] =  \
            JENV->GetFieldID(env, cls, "sys", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids[JSIGAR_FIELDS_PROCTIME_TOTAL] =  \
            JENV->GetFieldID(env, cls, "total", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_PROCTIME(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids[JSIGAR_FIELDS_PROCTIME_START_TIME], s.start_time); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids[JSIGAR_FIELDS_PROCTIME_USER], s.user); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids[JSIGAR_FIELDS_PROCTIME_SYS], s.sys); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids[JSIGAR_FIELDS_PROCTIME_TOTAL], s.total);

#define JAVA_SIGAR_GET_FIELDS_PROCTIME(obj, s) \
    s.start_time = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids[JSIGAR_FIELDS_PROCTIME_START_TIME]); \
    s.user = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids[JSIGAR_FIELDS_PROCTIME_USER]); \
    s.sys = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids[JSIGAR_FIELDS_PROCTIME_SYS]); \
    s.total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCTIME]->ids[JSIGAR_FIELDS_PROCTIME_TOTAL]);

#define JAVA_SIGAR_INIT_FIELDS_DUMPPIDCACHE(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_DUMPPIDCACHE]) { \
        jsigar->fields[JSIGAR_FIELDS_DUMPPIDCACHE] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_DUMPPIDCACHE])); \
        jsigar->fields[JSIGAR_FIELDS_DUMPPIDCACHE]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_DUMPPIDCACHE]->ids =  \
            malloc(JSIGAR_FIELDS_DUMPPIDCACHE_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_DUMPPIDCACHE]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_DUMPPIDCACHE]->ids[JSIGAR_FIELDS_DUMPPIDCACHE_DUMMY] =  \
            JENV->GetFieldID(env, cls, "dummy", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_DUMPPIDCACHE(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DUMPPIDCACHE]->ids[JSIGAR_FIELDS_DUMPPIDCACHE_DUMMY], s.dummy);

#define JAVA_SIGAR_GET_FIELDS_DUMPPIDCACHE(obj, s) \
    s.dummy = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DUMPPIDCACHE]->ids[JSIGAR_FIELDS_DUMPPIDCACHE_DUMMY]);

#define JAVA_SIGAR_INIT_FIELDS_NETINTERFACESTAT(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]) { \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT])); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids =  \
            malloc(JSIGAR_FIELDS_NETINTERFACESTAT_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_BYTES] =  \
            JENV->GetFieldID(env, cls, "rxBytes", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_PACKETS] =  \
            JENV->GetFieldID(env, cls, "rxPackets", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_ERRORS] =  \
            JENV->GetFieldID(env, cls, "rxErrors", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_DROPPED] =  \
            JENV->GetFieldID(env, cls, "rxDropped", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_OVERRUNS] =  \
            JENV->GetFieldID(env, cls, "rxOverruns", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_FRAME] =  \
            JENV->GetFieldID(env, cls, "rxFrame", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_BYTES] =  \
            JENV->GetFieldID(env, cls, "txBytes", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_PACKETS] =  \
            JENV->GetFieldID(env, cls, "txPackets", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_ERRORS] =  \
            JENV->GetFieldID(env, cls, "txErrors", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_DROPPED] =  \
            JENV->GetFieldID(env, cls, "txDropped", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_OVERRUNS] =  \
            JENV->GetFieldID(env, cls, "txOverruns", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_COLLISIONS] =  \
            JENV->GetFieldID(env, cls, "txCollisions", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_CARRIER] =  \
            JENV->GetFieldID(env, cls, "txCarrier", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_SPEED] =  \
            JENV->GetFieldID(env, cls, "speed", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_NETINTERFACESTAT(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_BYTES], s.rx_bytes); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_PACKETS], s.rx_packets); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_ERRORS], s.rx_errors); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_DROPPED], s.rx_dropped); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_OVERRUNS], s.rx_overruns); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_FRAME], s.rx_frame); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_BYTES], s.tx_bytes); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_PACKETS], s.tx_packets); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_ERRORS], s.tx_errors); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_DROPPED], s.tx_dropped); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_OVERRUNS], s.tx_overruns); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_COLLISIONS], s.tx_collisions); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_CARRIER], s.tx_carrier); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_SPEED], s.speed);

#define JAVA_SIGAR_GET_FIELDS_NETINTERFACESTAT(obj, s) \
    s.rx_bytes = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_BYTES]); \
    s.rx_packets = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_PACKETS]); \
    s.rx_errors = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_ERRORS]); \
    s.rx_dropped = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_DROPPED]); \
    s.rx_overruns = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_OVERRUNS]); \
    s.rx_frame = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_RX_FRAME]); \
    s.tx_bytes = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_BYTES]); \
    s.tx_packets = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_PACKETS]); \
    s.tx_errors = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_ERRORS]); \
    s.tx_dropped = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_DROPPED]); \
    s.tx_overruns = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_OVERRUNS]); \
    s.tx_collisions = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_COLLISIONS]); \
    s.tx_carrier = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_TX_CARRIER]); \
    s.speed = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINTERFACESTAT]->ids[JSIGAR_FIELDS_NETINTERFACESTAT_SPEED]);

#define JAVA_SIGAR_INIT_FIELDS_PROCSTAT(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_PROCSTAT]) { \
        jsigar->fields[JSIGAR_FIELDS_PROCSTAT] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCSTAT])); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids =  \
            malloc(JSIGAR_FIELDS_PROCSTAT_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_TOTAL] =  \
            JENV->GetFieldID(env, cls, "total", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_IDLE] =  \
            JENV->GetFieldID(env, cls, "idle", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_RUNNING] =  \
            JENV->GetFieldID(env, cls, "running", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_SLEEPING] =  \
            JENV->GetFieldID(env, cls, "sleeping", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_STOPPED] =  \
            JENV->GetFieldID(env, cls, "stopped", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_ZOMBIE] =  \
            JENV->GetFieldID(env, cls, "zombie", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_THREADS] =  \
            JENV->GetFieldID(env, cls, "threads", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_PROCSTAT(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_TOTAL], s.total); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_IDLE], s.idle); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_RUNNING], s.running); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_SLEEPING], s.sleeping); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_STOPPED], s.stopped); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_ZOMBIE], s.zombie); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_THREADS], s.threads);

#define JAVA_SIGAR_GET_FIELDS_PROCSTAT(obj, s) \
    s.total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_TOTAL]); \
    s.idle = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_IDLE]); \
    s.running = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_RUNNING]); \
    s.sleeping = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_SLEEPING]); \
    s.stopped = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_STOPPED]); \
    s.zombie = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_ZOMBIE]); \
    s.threads = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTAT]->ids[JSIGAR_FIELDS_PROCSTAT_THREADS]);

#define JAVA_SIGAR_INIT_FIELDS_PROCCREDNAME(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_PROCCREDNAME]) { \
        jsigar->fields[JSIGAR_FIELDS_PROCCREDNAME] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCCREDNAME])); \
        jsigar->fields[JSIGAR_FIELDS_PROCCREDNAME]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_PROCCREDNAME]->ids =  \
            malloc(JSIGAR_FIELDS_PROCCREDNAME_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCCREDNAME]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_PROCCREDNAME]->ids[JSIGAR_FIELDS_PROCCREDNAME_USER] =  \
            JENV->GetFieldID(env, cls, "user", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_PROCCREDNAME]->ids[JSIGAR_FIELDS_PROCCREDNAME_GROUP] =  \
            JENV->GetFieldID(env, cls, "group", "Ljava/lang/String;"); \
    }

#define JAVA_SIGAR_SET_FIELDS_PROCCREDNAME(cls, obj, s) \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCREDNAME]->ids[JSIGAR_FIELDS_PROCCREDNAME_USER], s.user); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCREDNAME]->ids[JSIGAR_FIELDS_PROCCREDNAME_GROUP], s.group);

#define JAVA_SIGAR_GET_FIELDS_PROCCREDNAME(obj, s) \
    s.user = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCREDNAME]->ids[JSIGAR_FIELDS_PROCCREDNAME_USER]); \
    s.group = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCREDNAME]->ids[JSIGAR_FIELDS_PROCCREDNAME_GROUP]);

#define JAVA_SIGAR_INIT_FIELDS_PROCFD(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_PROCFD]) { \
        jsigar->fields[JSIGAR_FIELDS_PROCFD] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCFD])); \
        jsigar->fields[JSIGAR_FIELDS_PROCFD]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_PROCFD]->ids =  \
            malloc(JSIGAR_FIELDS_PROCFD_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCFD]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_PROCFD]->ids[JSIGAR_FIELDS_PROCFD_TOTAL] =  \
            JENV->GetFieldID(env, cls, "total", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_PROCFD(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCFD]->ids[JSIGAR_FIELDS_PROCFD_TOTAL], s.total);

#define JAVA_SIGAR_GET_FIELDS_PROCFD(obj, s) \
    s.total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCFD]->ids[JSIGAR_FIELDS_PROCFD_TOTAL]);

#define JAVA_SIGAR_INIT_FIELDS_NFSSERVERV2(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]) { \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2])); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids =  \
            malloc(JSIGAR_FIELDS_NFSSERVERV2_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_NULL] =  \
            JENV->GetFieldID(env, cls, "_null", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_GETATTR] =  \
            JENV->GetFieldID(env, cls, "getattr", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_SETATTR] =  \
            JENV->GetFieldID(env, cls, "setattr", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_ROOT] =  \
            JENV->GetFieldID(env, cls, "root", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_LOOKUP] =  \
            JENV->GetFieldID(env, cls, "lookup", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_READLINK] =  \
            JENV->GetFieldID(env, cls, "readlink", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_READ] =  \
            JENV->GetFieldID(env, cls, "read", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_WRITECACHE] =  \
            JENV->GetFieldID(env, cls, "writecache", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_WRITE] =  \
            JENV->GetFieldID(env, cls, "write", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_CREATE] =  \
            JENV->GetFieldID(env, cls, "create", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_REMOVE] =  \
            JENV->GetFieldID(env, cls, "remove", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_RENAME] =  \
            JENV->GetFieldID(env, cls, "rename", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_LINK] =  \
            JENV->GetFieldID(env, cls, "link", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_SYMLINK] =  \
            JENV->GetFieldID(env, cls, "symlink", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_MKDIR] =  \
            JENV->GetFieldID(env, cls, "mkdir", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_RMDIR] =  \
            JENV->GetFieldID(env, cls, "rmdir", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_READDIR] =  \
            JENV->GetFieldID(env, cls, "readdir", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_FSSTAT] =  \
            JENV->GetFieldID(env, cls, "fsstat", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_NFSSERVERV2(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_NULL], s.null); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_GETATTR], s.getattr); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_SETATTR], s.setattr); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_ROOT], s.root); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_LOOKUP], s.lookup); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_READLINK], s.readlink); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_READ], s.read); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_WRITECACHE], s.writecache); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_WRITE], s.write); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_CREATE], s.create); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_REMOVE], s.remove); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_RENAME], s.rename); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_LINK], s.link); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_SYMLINK], s.symlink); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_MKDIR], s.mkdir); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_RMDIR], s.rmdir); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_READDIR], s.readdir); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_FSSTAT], s.fsstat);

#define JAVA_SIGAR_GET_FIELDS_NFSSERVERV2(obj, s) \
    s.null = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_NULL]); \
    s.getattr = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_GETATTR]); \
    s.setattr = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_SETATTR]); \
    s.root = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_ROOT]); \
    s.lookup = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_LOOKUP]); \
    s.readlink = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_READLINK]); \
    s.read = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_READ]); \
    s.writecache = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_WRITECACHE]); \
    s.write = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_WRITE]); \
    s.create = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_CREATE]); \
    s.remove = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_REMOVE]); \
    s.rename = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_RENAME]); \
    s.link = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_LINK]); \
    s.symlink = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_SYMLINK]); \
    s.mkdir = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_MKDIR]); \
    s.rmdir = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_RMDIR]); \
    s.readdir = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_READDIR]); \
    s.fsstat = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSSERVERV2]->ids[JSIGAR_FIELDS_NFSSERVERV2_FSSTAT]);

#define JAVA_SIGAR_INIT_FIELDS_CPUPERC(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_CPUPERC]) { \
        jsigar->fields[JSIGAR_FIELDS_CPUPERC] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_CPUPERC])); \
        jsigar->fields[JSIGAR_FIELDS_CPUPERC]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids =  \
            malloc(JSIGAR_FIELDS_CPUPERC_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_USER] =  \
            JENV->GetFieldID(env, cls, "user", "D"); \
        jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_SYS] =  \
            JENV->GetFieldID(env, cls, "sys", "D"); \
        jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_NICE] =  \
            JENV->GetFieldID(env, cls, "nice", "D"); \
        jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_IDLE] =  \
            JENV->GetFieldID(env, cls, "idle", "D"); \
        jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_WAIT] =  \
            JENV->GetFieldID(env, cls, "wait", "D"); \
        jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_IRQ] =  \
            JENV->GetFieldID(env, cls, "irq", "D"); \
        jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_SOFT_IRQ] =  \
            JENV->GetFieldID(env, cls, "softIrq", "D"); \
        jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_STOLEN] =  \
            JENV->GetFieldID(env, cls, "stolen", "D"); \
        jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_COMBINED] =  \
            JENV->GetFieldID(env, cls, "combined", "D"); \
    }

#define JAVA_SIGAR_SET_FIELDS_CPUPERC(cls, obj, s) \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_USER], s.user); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_SYS], s.sys); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_NICE], s.nice); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_IDLE], s.idle); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_WAIT], s.wait); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_IRQ], s.irq); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_SOFT_IRQ], s.soft_irq); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_STOLEN], s.stolen); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_COMBINED], s.combined);

#define JAVA_SIGAR_GET_FIELDS_CPUPERC(obj, s) \
    s.user = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_USER]); \
    s.sys = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_SYS]); \
    s.nice = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_NICE]); \
    s.idle = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_IDLE]); \
    s.wait = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_WAIT]); \
    s.irq = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_IRQ]); \
    s.soft_irq = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_SOFT_IRQ]); \
    s.stolen = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_STOLEN]); \
    s.combined = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_CPUPERC]->ids[JSIGAR_FIELDS_CPUPERC_COMBINED]);

#define JAVA_SIGAR_INIT_FIELDS_SWAP(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_SWAP]) { \
        jsigar->fields[JSIGAR_FIELDS_SWAP] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_SWAP])); \
        jsigar->fields[JSIGAR_FIELDS_SWAP]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_SWAP]->ids =  \
            malloc(JSIGAR_FIELDS_SWAP_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_SWAP]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_TOTAL] =  \
            JENV->GetFieldID(env, cls, "total", "J"); \
        jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_USED] =  \
            JENV->GetFieldID(env, cls, "used", "J"); \
        jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_FREE] =  \
            JENV->GetFieldID(env, cls, "free", "J"); \
        jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_PAGE_IN] =  \
            JENV->GetFieldID(env, cls, "pageIn", "J"); \
        jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_PAGE_OUT] =  \
            JENV->GetFieldID(env, cls, "pageOut", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_SWAP(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_TOTAL], s.total); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_USED], s.used); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_FREE], s.free); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_PAGE_IN], s.page_in); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_PAGE_OUT], s.page_out);

#define JAVA_SIGAR_GET_FIELDS_SWAP(obj, s) \
    s.total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_TOTAL]); \
    s.used = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_USED]); \
    s.free = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_FREE]); \
    s.page_in = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_PAGE_IN]); \
    s.page_out = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_SWAP]->ids[JSIGAR_FIELDS_SWAP_PAGE_OUT]);

#define JAVA_SIGAR_INIT_FIELDS_NETINFO(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_NETINFO]) { \
        jsigar->fields[JSIGAR_FIELDS_NETINFO] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_NETINFO])); \
        jsigar->fields[JSIGAR_FIELDS_NETINFO]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids =  \
            malloc(JSIGAR_FIELDS_NETINFO_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_DEFAULT_GATEWAY] =  \
            JENV->GetFieldID(env, cls, "defaultGateway", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_DEFAULT_GATEWAY_INTERFACE] =  \
            JENV->GetFieldID(env, cls, "defaultGatewayInterface", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_HOST_NAME] =  \
            JENV->GetFieldID(env, cls, "hostName", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_DOMAIN_NAME] =  \
            JENV->GetFieldID(env, cls, "domainName", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_PRIMARY_DNS] =  \
            JENV->GetFieldID(env, cls, "primaryDns", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_SECONDARY_DNS] =  \
            JENV->GetFieldID(env, cls, "secondaryDns", "Ljava/lang/String;"); \
    }

#define JAVA_SIGAR_SET_FIELDS_NETINFO(cls, obj, s) \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_DEFAULT_GATEWAY], s.default_gateway); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_DEFAULT_GATEWAY_INTERFACE], s.default_gateway_interface); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_HOST_NAME], s.host_name); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_DOMAIN_NAME], s.domain_name); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_PRIMARY_DNS], s.primary_dns); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_SECONDARY_DNS], s.secondary_dns);

#define JAVA_SIGAR_GET_FIELDS_NETINFO(obj, s) \
    s.default_gateway = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_DEFAULT_GATEWAY]); \
    s.default_gateway_interface = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_DEFAULT_GATEWAY_INTERFACE]); \
    s.host_name = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_HOST_NAME]); \
    s.domain_name = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_DOMAIN_NAME]); \
    s.primary_dns = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_PRIMARY_DNS]); \
    s.secondary_dns = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_NETINFO]->ids[JSIGAR_FIELDS_NETINFO_SECONDARY_DNS]);

#define JAVA_SIGAR_INIT_FIELDS_WHO(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_WHO]) { \
        jsigar->fields[JSIGAR_FIELDS_WHO] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_WHO])); \
        jsigar->fields[JSIGAR_FIELDS_WHO]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_WHO]->ids =  \
            malloc(JSIGAR_FIELDS_WHO_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_WHO]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_WHO]->ids[JSIGAR_FIELDS_WHO_USER] =  \
            JENV->GetFieldID(env, cls, "user", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_WHO]->ids[JSIGAR_FIELDS_WHO_DEVICE] =  \
            JENV->GetFieldID(env, cls, "device", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_WHO]->ids[JSIGAR_FIELDS_WHO_HOST] =  \
            JENV->GetFieldID(env, cls, "host", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_WHO]->ids[JSIGAR_FIELDS_WHO_TIME] =  \
            JENV->GetFieldID(env, cls, "time", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_WHO(cls, obj, s) \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_WHO]->ids[JSIGAR_FIELDS_WHO_USER], s.user); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_WHO]->ids[JSIGAR_FIELDS_WHO_DEVICE], s.device); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_WHO]->ids[JSIGAR_FIELDS_WHO_HOST], s.host); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_WHO]->ids[JSIGAR_FIELDS_WHO_TIME], s.time);

#define JAVA_SIGAR_GET_FIELDS_WHO(obj, s) \
    s.user = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_WHO]->ids[JSIGAR_FIELDS_WHO_USER]); \
    s.device = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_WHO]->ids[JSIGAR_FIELDS_WHO_DEVICE]); \
    s.host = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_WHO]->ids[JSIGAR_FIELDS_WHO_HOST]); \
    s.time = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_WHO]->ids[JSIGAR_FIELDS_WHO_TIME]);

#define JAVA_SIGAR_INIT_FIELDS_UPTIME(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_UPTIME]) { \
        jsigar->fields[JSIGAR_FIELDS_UPTIME] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_UPTIME])); \
        jsigar->fields[JSIGAR_FIELDS_UPTIME]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_UPTIME]->ids =  \
            malloc(JSIGAR_FIELDS_UPTIME_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_UPTIME]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_UPTIME]->ids[JSIGAR_FIELDS_UPTIME_UPTIME] =  \
            JENV->GetFieldID(env, cls, "uptime", "D"); \
    }

#define JAVA_SIGAR_SET_FIELDS_UPTIME(cls, obj, s) \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_UPTIME]->ids[JSIGAR_FIELDS_UPTIME_UPTIME], s.uptime);

#define JAVA_SIGAR_GET_FIELDS_UPTIME(obj, s) \
    s.uptime = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_UPTIME]->ids[JSIGAR_FIELDS_UPTIME_UPTIME]);

#define JAVA_SIGAR_INIT_FIELDS_SYSINFO(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_SYSINFO]) { \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_SYSINFO])); \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids =  \
            malloc(JSIGAR_FIELDS_SYSINFO_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_NAME] =  \
            JENV->GetFieldID(env, cls, "name", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VERSION] =  \
            JENV->GetFieldID(env, cls, "version", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_ARCH] =  \
            JENV->GetFieldID(env, cls, "arch", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_MACHINE] =  \
            JENV->GetFieldID(env, cls, "machine", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_DESCRIPTION] =  \
            JENV->GetFieldID(env, cls, "description", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_PATCH_LEVEL] =  \
            JENV->GetFieldID(env, cls, "patchLevel", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VENDOR] =  \
            JENV->GetFieldID(env, cls, "vendor", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VENDOR_VERSION] =  \
            JENV->GetFieldID(env, cls, "vendorVersion", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VENDOR_NAME] =  \
            JENV->GetFieldID(env, cls, "vendorName", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VENDOR_CODE_NAME] =  \
            JENV->GetFieldID(env, cls, "vendorCodeName", "Ljava/lang/String;"); \
    }

#define JAVA_SIGAR_SET_FIELDS_SYSINFO(cls, obj, s) \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_NAME], s.name); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VERSION], s.version); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_ARCH], s.arch); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_MACHINE], s.machine); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_DESCRIPTION], s.description); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_PATCH_LEVEL], s.patch_level); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VENDOR], s.vendor); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VENDOR_VERSION], s.vendor_version); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VENDOR_NAME], s.vendor_name); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VENDOR_CODE_NAME], s.vendor_code_name);

#define JAVA_SIGAR_GET_FIELDS_SYSINFO(obj, s) \
    s.name = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_NAME]); \
    s.version = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VERSION]); \
    s.arch = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_ARCH]); \
    s.machine = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_MACHINE]); \
    s.description = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_DESCRIPTION]); \
    s.patch_level = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_PATCH_LEVEL]); \
    s.vendor = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VENDOR]); \
    s.vendor_version = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VENDOR_VERSION]); \
    s.vendor_name = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VENDOR_NAME]); \
    s.vendor_code_name = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_SYSINFO]->ids[JSIGAR_FIELDS_SYSINFO_VENDOR_CODE_NAME]);

#define JAVA_SIGAR_INIT_FIELDS_DISKUSAGE(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]) { \
        jsigar->fields[JSIGAR_FIELDS_DISKUSAGE] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_DISKUSAGE])); \
        jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids =  \
            malloc(JSIGAR_FIELDS_DISKUSAGE_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_READS] =  \
            JENV->GetFieldID(env, cls, "reads", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_WRITES] =  \
            JENV->GetFieldID(env, cls, "writes", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_READ_BYTES] =  \
            JENV->GetFieldID(env, cls, "readBytes", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_WRITE_BYTES] =  \
            JENV->GetFieldID(env, cls, "writeBytes", "J"); \
        jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_QUEUE] =  \
            JENV->GetFieldID(env, cls, "queue", "D"); \
        jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_SERVICE_TIME] =  \
            JENV->GetFieldID(env, cls, "serviceTime", "D"); \
    }

#define JAVA_SIGAR_SET_FIELDS_DISKUSAGE(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_READS], s.reads); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_WRITES], s.writes); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_READ_BYTES], s.read_bytes); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_WRITE_BYTES], s.write_bytes); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_QUEUE], s.queue); \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_SERVICE_TIME], s.service_time);

#define JAVA_SIGAR_GET_FIELDS_DISKUSAGE(obj, s) \
    s.reads = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_READS]); \
    s.writes = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_WRITES]); \
    s.read_bytes = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_READ_BYTES]); \
    s.write_bytes = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_WRITE_BYTES]); \
    s.queue = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_QUEUE]); \
    s.service_time = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_DISKUSAGE]->ids[JSIGAR_FIELDS_DISKUSAGE_SERVICE_TIME]);

#define JAVA_SIGAR_INIT_FIELDS_PROCEXE(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_PROCEXE]) { \
        jsigar->fields[JSIGAR_FIELDS_PROCEXE] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCEXE])); \
        jsigar->fields[JSIGAR_FIELDS_PROCEXE]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_PROCEXE]->ids =  \
            malloc(JSIGAR_FIELDS_PROCEXE_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCEXE]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_PROCEXE]->ids[JSIGAR_FIELDS_PROCEXE_NAME] =  \
            JENV->GetFieldID(env, cls, "name", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_PROCEXE]->ids[JSIGAR_FIELDS_PROCEXE_CWD] =  \
            JENV->GetFieldID(env, cls, "cwd", "Ljava/lang/String;"); \
    }

#define JAVA_SIGAR_SET_FIELDS_PROCEXE(cls, obj, s) \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCEXE]->ids[JSIGAR_FIELDS_PROCEXE_NAME], s.name); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCEXE]->ids[JSIGAR_FIELDS_PROCEXE_CWD], s.cwd);

#define JAVA_SIGAR_GET_FIELDS_PROCEXE(obj, s) \
    s.name = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCEXE]->ids[JSIGAR_FIELDS_PROCEXE_NAME]); \
    s.cwd = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCEXE]->ids[JSIGAR_FIELDS_PROCEXE_CWD]);

#define JAVA_SIGAR_INIT_FIELDS_NFSCLIENTV2(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]) { \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2])); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids =  \
            malloc(JSIGAR_FIELDS_NFSCLIENTV2_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_NULL] =  \
            JENV->GetFieldID(env, cls, "_null", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_GETATTR] =  \
            JENV->GetFieldID(env, cls, "getattr", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_SETATTR] =  \
            JENV->GetFieldID(env, cls, "setattr", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_ROOT] =  \
            JENV->GetFieldID(env, cls, "root", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_LOOKUP] =  \
            JENV->GetFieldID(env, cls, "lookup", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_READLINK] =  \
            JENV->GetFieldID(env, cls, "readlink", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_READ] =  \
            JENV->GetFieldID(env, cls, "read", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_WRITECACHE] =  \
            JENV->GetFieldID(env, cls, "writecache", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_WRITE] =  \
            JENV->GetFieldID(env, cls, "write", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_CREATE] =  \
            JENV->GetFieldID(env, cls, "create", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_REMOVE] =  \
            JENV->GetFieldID(env, cls, "remove", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_RENAME] =  \
            JENV->GetFieldID(env, cls, "rename", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_LINK] =  \
            JENV->GetFieldID(env, cls, "link", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_SYMLINK] =  \
            JENV->GetFieldID(env, cls, "symlink", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_MKDIR] =  \
            JENV->GetFieldID(env, cls, "mkdir", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_RMDIR] =  \
            JENV->GetFieldID(env, cls, "rmdir", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_READDIR] =  \
            JENV->GetFieldID(env, cls, "readdir", "J"); \
        jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_FSSTAT] =  \
            JENV->GetFieldID(env, cls, "fsstat", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_NFSCLIENTV2(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_NULL], s.null); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_GETATTR], s.getattr); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_SETATTR], s.setattr); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_ROOT], s.root); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_LOOKUP], s.lookup); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_READLINK], s.readlink); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_READ], s.read); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_WRITECACHE], s.writecache); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_WRITE], s.write); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_CREATE], s.create); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_REMOVE], s.remove); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_RENAME], s.rename); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_LINK], s.link); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_SYMLINK], s.symlink); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_MKDIR], s.mkdir); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_RMDIR], s.rmdir); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_READDIR], s.readdir); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_FSSTAT], s.fsstat);

#define JAVA_SIGAR_GET_FIELDS_NFSCLIENTV2(obj, s) \
    s.null = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_NULL]); \
    s.getattr = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_GETATTR]); \
    s.setattr = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_SETATTR]); \
    s.root = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_ROOT]); \
    s.lookup = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_LOOKUP]); \
    s.readlink = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_READLINK]); \
    s.read = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_READ]); \
    s.writecache = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_WRITECACHE]); \
    s.write = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_WRITE]); \
    s.create = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_CREATE]); \
    s.remove = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_REMOVE]); \
    s.rename = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_RENAME]); \
    s.link = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_LINK]); \
    s.symlink = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_SYMLINK]); \
    s.mkdir = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_MKDIR]); \
    s.rmdir = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_RMDIR]); \
    s.readdir = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_READDIR]); \
    s.fsstat = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_NFSCLIENTV2]->ids[JSIGAR_FIELDS_NFSCLIENTV2_FSSTAT]);

#define JAVA_SIGAR_INIT_FIELDS_PROCCPU(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_PROCCPU]) { \
        jsigar->fields[JSIGAR_FIELDS_PROCCPU] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCCPU])); \
        jsigar->fields[JSIGAR_FIELDS_PROCCPU]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids =  \
            malloc(JSIGAR_FIELDS_PROCCPU_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_PERCENT] =  \
            JENV->GetFieldID(env, cls, "percent", "D"); \
        jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_LAST_TIME] =  \
            JENV->GetFieldID(env, cls, "lastTime", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_START_TIME] =  \
            JENV->GetFieldID(env, cls, "startTime", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_USER] =  \
            JENV->GetFieldID(env, cls, "user", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_SYS] =  \
            JENV->GetFieldID(env, cls, "sys", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_TOTAL] =  \
            JENV->GetFieldID(env, cls, "total", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_PROCCPU(cls, obj, s) \
    JENV->SetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_PERCENT], s.percent); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_LAST_TIME], s.last_time); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_START_TIME], s.start_time); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_USER], s.user); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_SYS], s.sys); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_TOTAL], s.total);

#define JAVA_SIGAR_GET_FIELDS_PROCCPU(obj, s) \
    s.percent = JENV->GetDoubleField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_PERCENT]); \
    s.last_time = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_LAST_TIME]); \
    s.start_time = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_START_TIME]); \
    s.user = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_USER]); \
    s.sys = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_SYS]); \
    s.total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCCPU]->ids[JSIGAR_FIELDS_PROCCPU_TOTAL]);

#define JAVA_SIGAR_INIT_FIELDS_PROCSTATE(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_PROCSTATE]) { \
        jsigar->fields[JSIGAR_FIELDS_PROCSTATE] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCSTATE])); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids =  \
            malloc(JSIGAR_FIELDS_PROCSTATE_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_STATE] =  \
            JENV->GetFieldID(env, cls, "state", "C"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_NAME] =  \
            JENV->GetFieldID(env, cls, "name", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_PPID] =  \
            JENV->GetFieldID(env, cls, "ppid", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_TTY] =  \
            JENV->GetFieldID(env, cls, "tty", "I"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_NICE] =  \
            JENV->GetFieldID(env, cls, "nice", "I"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_PRIORITY] =  \
            JENV->GetFieldID(env, cls, "priority", "I"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_THREADS] =  \
            JENV->GetFieldID(env, cls, "threads", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_PROCESSOR] =  \
            JENV->GetFieldID(env, cls, "processor", "I"); \
    }

#define JAVA_SIGAR_SET_FIELDS_PROCSTATE(cls, obj, s) \
    JENV->SetCharField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_STATE], s.state); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_NAME], s.name); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_PPID], s.ppid); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_TTY], s.tty); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_NICE], s.nice); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_PRIORITY], s.priority); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_THREADS], s.threads); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_PROCESSOR], s.processor);

#define JAVA_SIGAR_GET_FIELDS_PROCSTATE(obj, s) \
    s.state = JENV->GetCharField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_STATE]); \
    s.name = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_NAME]); \
    s.ppid = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_PPID]); \
    s.tty = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_TTY]); \
    s.nice = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_NICE]); \
    s.priority = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_PRIORITY]); \
    s.threads = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_THREADS]); \
    s.processor = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCSTATE]->ids[JSIGAR_FIELDS_PROCSTATE_PROCESSOR]);

#define JAVA_SIGAR_INIT_FIELDS_FILESYSTEM(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]) { \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEM] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_FILESYSTEM])); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids =  \
            malloc(JSIGAR_FIELDS_FILESYSTEM_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_DIR_NAME] =  \
            JENV->GetFieldID(env, cls, "dirName", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_DEV_NAME] =  \
            JENV->GetFieldID(env, cls, "devName", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_TYPE_NAME] =  \
            JENV->GetFieldID(env, cls, "typeName", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_SYS_TYPE_NAME] =  \
            JENV->GetFieldID(env, cls, "sysTypeName", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_OPTIONS] =  \
            JENV->GetFieldID(env, cls, "options", "Ljava/lang/String;"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_TYPE] =  \
            JENV->GetFieldID(env, cls, "type", "I"); \
        jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_FLAGS] =  \
            JENV->GetFieldID(env, cls, "flags", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_FILESYSTEM(cls, obj, s) \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_DIR_NAME], s.dir_name); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_DEV_NAME], s.dev_name); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_TYPE_NAME], s.type_name); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_SYS_TYPE_NAME], s.sys_type_name); \
    JENV->SetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_OPTIONS], s.options); \
    JENV->SetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_TYPE], s.type); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_FLAGS], s.flags);

#define JAVA_SIGAR_GET_FIELDS_FILESYSTEM(obj, s) \
    s.dir_name = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_DIR_NAME]); \
    s.dev_name = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_DEV_NAME]); \
    s.type_name = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_TYPE_NAME]); \
    s.sys_type_name = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_SYS_TYPE_NAME]); \
    s.options = JENV->GetStringField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_OPTIONS]); \
    s.type = JENV->GetIntField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_TYPE]); \
    s.flags = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_FILESYSTEM]->ids[JSIGAR_FIELDS_FILESYSTEM_FLAGS]);

#define JAVA_SIGAR_INIT_FIELDS_PROCDISKIO(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]) { \
        jsigar->fields[JSIGAR_FIELDS_PROCDISKIO] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCDISKIO])); \
        jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]->ids =  \
            malloc(JSIGAR_FIELDS_PROCDISKIO_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]->ids[JSIGAR_FIELDS_PROCDISKIO_BYTES_READ] =  \
            JENV->GetFieldID(env, cls, "bytesRead", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]->ids[JSIGAR_FIELDS_PROCDISKIO_BYTES_WRITTEN] =  \
            JENV->GetFieldID(env, cls, "bytesWritten", "J"); \
        jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]->ids[JSIGAR_FIELDS_PROCDISKIO_BYTES_TOTAL] =  \
            JENV->GetFieldID(env, cls, "bytesTotal", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_PROCDISKIO(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]->ids[JSIGAR_FIELDS_PROCDISKIO_BYTES_READ], s.bytes_read); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]->ids[JSIGAR_FIELDS_PROCDISKIO_BYTES_WRITTEN], s.bytes_written); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]->ids[JSIGAR_FIELDS_PROCDISKIO_BYTES_TOTAL], s.bytes_total);

#define JAVA_SIGAR_GET_FIELDS_PROCDISKIO(obj, s) \
    s.bytes_read = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]->ids[JSIGAR_FIELDS_PROCDISKIO_BYTES_READ]); \
    s.bytes_written = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]->ids[JSIGAR_FIELDS_PROCDISKIO_BYTES_WRITTEN]); \
    s.bytes_total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_PROCDISKIO]->ids[JSIGAR_FIELDS_PROCDISKIO_BYTES_TOTAL]);

#define JAVA_SIGAR_INIT_FIELDS_THREADCPU(cls) \
    if (!jsigar->fields[JSIGAR_FIELDS_THREADCPU]) { \
        jsigar->fields[JSIGAR_FIELDS_THREADCPU] =  \
            malloc(sizeof(*jsigar->fields[JSIGAR_FIELDS_THREADCPU])); \
        jsigar->fields[JSIGAR_FIELDS_THREADCPU]->classref =  \
            (jclass)JENV->NewGlobalRef(env, cls); \
        jsigar->fields[JSIGAR_FIELDS_THREADCPU]->ids =  \
            malloc(JSIGAR_FIELDS_THREADCPU_MAX * \
                   sizeof(*jsigar->fields[JSIGAR_FIELDS_THREADCPU]->ids)); \
        jsigar->fields[JSIGAR_FIELDS_THREADCPU]->ids[JSIGAR_FIELDS_THREADCPU_USER] =  \
            JENV->GetFieldID(env, cls, "user", "J"); \
        jsigar->fields[JSIGAR_FIELDS_THREADCPU]->ids[JSIGAR_FIELDS_THREADCPU_SYS] =  \
            JENV->GetFieldID(env, cls, "sys", "J"); \
        jsigar->fields[JSIGAR_FIELDS_THREADCPU]->ids[JSIGAR_FIELDS_THREADCPU_TOTAL] =  \
            JENV->GetFieldID(env, cls, "total", "J"); \
    }

#define JAVA_SIGAR_SET_FIELDS_THREADCPU(cls, obj, s) \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_THREADCPU]->ids[JSIGAR_FIELDS_THREADCPU_USER], s.user); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_THREADCPU]->ids[JSIGAR_FIELDS_THREADCPU_SYS], s.sys); \
    JENV->SetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_THREADCPU]->ids[JSIGAR_FIELDS_THREADCPU_TOTAL], s.total);

#define JAVA_SIGAR_GET_FIELDS_THREADCPU(obj, s) \
    s.user = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_THREADCPU]->ids[JSIGAR_FIELDS_THREADCPU_USER]); \
    s.sys = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_THREADCPU]->ids[JSIGAR_FIELDS_THREADCPU_SYS]); \
    s.total = JENV->GetLongField(env, obj, jsigar->fields[JSIGAR_FIELDS_THREADCPU]->ids[JSIGAR_FIELDS_THREADCPU_TOTAL]);





© 2015 - 2024 Weber Informatics LLC | Privacy Policy