Top Description Inners Fields Methods
com.sun.jna.platform.unix

public Interface LibCAPI

extends Reboot, Resource
Known Direct Subinterfaces
com.sun.jna.platform.linux.LibC, com.sun.jna.platform.mac.SystemB, com.sun.jna.platform.unix.LibC
Imports
com.sun.jna.IntegerType, .Native, .Pointer

Note

we are using this "intermediate" API in order to allow Linux-like O/S-es to implement the same API, but maybe using a different library name

Author
Lyor Goldstein

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
LibCAPI.size_t

This is an unsigned integer type used to represent the sizes of objects.

public static class
LibCAPI.ssize_t

This is a signed integer type used for a count of bytes or an error indication.

Field Summary

Modifier and TypeField and Description
public static final int
Inherited from com.sun.jna.platform.unix.Reboot:
RB_AUTOBOOTRB_DISABLE_CADRB_ENABLE_CADRB_HALT_SYSTEMRB_KEXECRB_POWER_OFFRB_SW_SUSPEND
Inherited from com.sun.jna.platform.unix.Resource:
RLIMIT_ASRLIMIT_CORERLIMIT_CPURLIMIT_DATARLIMIT_FSIZERLIMIT_LOCKSRLIMIT_MEMLOCKRLIMIT_MSGQUEUERLIMIT_NICERLIMIT_NLIMITSRLIMIT_NOFILERLIMIT_NPROCRLIMIT_RSSRLIMIT_RTPRIORLIMIT_RTTIMERLIMIT_SIGPENDINGRLIMIT_STACK

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

returns zero on success. On error, -1 is returned, and errno is set appropriately.

close() should not be retried after an error.

close
(int
a file descriptor
fd
)

Closes a file descriptor, so that it no longer refers to any file and may be reused.

public int
getdomainname(byte[] name, int len)

public int
public String

Returns:

Returns the value in the environment, or null if there is no match for the name
getenv
(String
Environment variable name
name
)

public int
public int
public int
gethostname(byte[] name, int len)

public int

Returns:

If the load average was unobtainable, -1 is returned; otherwise, the number of samples actually retrieved is returned.
getloadavg
(double[]
An array of doubles which will be filled with the results
loadavg
,
int
Number of samples to return
nelem
)

The getloadavg() function returns the number of processes in the system run queue averaged over various periods of time.

public int
public int

Returns:

On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
msync
(Pointer
The start of the memory area to sync to the filesystem.
addr
,
LibCAPI.size_t
The length of the memory area to sync to the filesystem.
length
,
int
The flags argument should specify exactly one of MS_ASYNC and MS_SYNC, and may additionally include the MS_INVALIDATE bit.
flags
)

Flushes changes made to the in-core copy of a file that was mapped into memory using LibCUtil#mmap(Pointer, long, int, int, int, long) back to the filesystem.

public int

Returns:

On success, returns 0. On failure, it returns -1, and errno is set to indicate the cause of the error (probably to EINVAL).
munmap
(Pointer
The base address from which to delete mappings. The address addr must be a multiple of the page size (but length need not be).
addr
,
LibCAPI.size_t
The length from the base address to delete mappings. All pages containing a part of the indicated range are unmapped, and subsequent references to these pages will generate SIGSEGV.
length
)

Deletes the mappings for the specified address range, and causes further references to addresses within the range to generate invalid memory references.

public int
setdomainname(String name, int len)

public int
setegid(int gid)

public int

Returns:

Upon successful completion, zero shall be returned. Otherwise, -1 shall be returned, errno set to indicate the error, and the environment shall be unchanged
setenv
(String
Environment variable name
name
,
String
Required value
value
,
int
If the environment variable already exists and the value of overwrite is non-zero, the function shall return success and the environment shall be updated. If the environment variable already exists and the value of overwrite is zero, the function shall return success and the environment shall remain unchanged.
overwrite
)

Update or add a variable in the environment of the calling process.

public int
seteuid(int uid)

public int
setgid(int gid)

public int
sethostname(String name, int len)

public int
setuid(int uid)

public int

Returns:

Upon successful completion, zero shall be returned. Otherwise, -1 shall be returned, errno set to indicate the error, and the environment shall be unchanged
unsetenv
(String
Environment variable name - If the named variable does not exist in the current environment, the environment shall be unchanged and the function is considered to have completed successfully.
name
)

Inherited from com.sun.jna.platform.unix.Reboot:
reboot
Inherited from com.sun.jna.platform.unix.Resource:
getrlimitsetrlimit

Field Detail

HOST_NAME_MAXback to summary
public static final int HOST_NAME_MAX

Method Detail

closeback to summary
public int close(int fd)

Closes a file descriptor, so that it no longer refers to any file and may be reused. Any record locks held on the file it was associated with, and owned by the process, are removed (regardless of the file descriptor that was used to obtain the lock).

If fd is the last file descriptor referring to the underlying open file description, the resources associated with the open file description are freed; if the file descriptor was the last reference to a file which has been removed using unlink, the file is deleted.

Parameters
fd:int

a file descriptor

Returns:int

returns zero on success. On error, -1 is returned, and errno is set appropriately.

close() should not be retried after an error.

getdomainnameback to summary
public int getdomainname(byte[] name, int len)
getegidback to summary
public int getegid()
getenvback to summary
public String getenv(String name)
Parameters
name:String

Environment variable name

Returns:String

Returns the value in the environment, or null if there is no match for the name

See Also
getenv(3)
geteuidback to summary
public int geteuid()
getgidback to summary
public int getgid()
gethostnameback to summary
public int gethostname(byte[] name, int len)
getloadavgback to summary
public int getloadavg(double[] loadavg, int nelem)

The getloadavg() function returns the number of processes in the system run queue averaged over various periods of time. Up to nelem samples are retrieved and assigned to successive elements of loadavg[]. The system imposes a maximum of 3 samples, representing averages over the last 1, 5, and 15 minutes, respectively.

Parameters
loadavg:double[]

An array of doubles which will be filled with the results

nelem:int

Number of samples to return

Returns:int

If the load average was unobtainable, -1 is returned; otherwise, the number of samples actually retrieved is returned.

See Also
getloadavg(3)
getuidback to summary
public int getuid()
msyncback to summary
public int msync(Pointer addr, LibCAPI.size_t length, int flags)

Flushes changes made to the in-core copy of a file that was mapped into memory using LibCUtil#mmap(Pointer, long, int, int, int, long) back to the filesystem. Without use of this call, there is no guarantee that changes are written back before munmap(Pointer, size_t) is called. To be more precise, the part of the file that corresponds to the memory area starting at addr and having length length is updated.

Parameters
addr:Pointer

The start of the memory area to sync to the filesystem.

length:LibCAPI.size_t

The length of the memory area to sync to the filesystem.

flags:int

The flags argument should specify exactly one of MS_ASYNC and MS_SYNC, and may additionally include the MS_INVALIDATE bit.

Returns:int

On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

munmapback to summary
public int munmap(Pointer addr, LibCAPI.size_t length)

Deletes the mappings for the specified address range, and causes further references to addresses within the range to generate invalid memory references. The region is also automatically unmapped when the process is terminated. On the other hand, closing the file descriptor does not unmap the region.

It is not an error if the indicated range does not contain any mapped pages.

Parameters
addr:Pointer

The base address from which to delete mappings. The address addr must be a multiple of the page size (but length need not be).

length:LibCAPI.size_t

The length from the base address to delete mappings. All pages containing a part of the indicated range are unmapped, and subsequent references to these pages will generate SIGSEGV.

Returns:int

On success, returns 0. On failure, it returns -1, and errno is set to indicate the cause of the error (probably to EINVAL).

setdomainnameback to summary
public int setdomainname(String name, int len)
setegidback to summary
public int setegid(int gid)
setenvback to summary
public int setenv(String name, String value, int overwrite)

Update or add a variable in the environment of the calling process.

Parameters
name:String

Environment variable name

value:String

Required value

overwrite:int

If the environment variable already exists and the value of overwrite is non-zero, the function shall return success and the environment shall be updated. If the environment variable already exists and the value of overwrite is zero, the function shall return success and the environment shall remain unchanged.

Returns:int

Upon successful completion, zero shall be returned. Otherwise, -1 shall be returned, errno set to indicate the error, and the environment shall be unchanged

See Also
getenv(3)
seteuidback to summary
public int seteuid(int uid)
setgidback to summary
public int setgid(int gid)
sethostnameback to summary
public int sethostname(String name, int len)
setuidback to summary
public int setuid(int uid)
unsetenvback to summary
public int unsetenv(String name)
Parameters
name:String

Environment variable name - If the named variable does not exist in the current environment, the environment shall be unchanged and the function is considered to have completed successfully.

Returns:int

Upon successful completion, zero shall be returned. Otherwise, -1 shall be returned, errno set to indicate the error, and the environment shall be unchanged

See Also
getenv(3)
com.sun.jna.platform.unix back to summary

public Class LibCAPI.size_t

extends IntegerType
Class Inheritance

This is an unsigned integer type used to represent the sizes of objects.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private static final long
public static final LibCAPI.size_t

Constructor Summary

AccessConstructor and Description
public
public
size_t(long value)

Method Summary

Inherited from com.sun.jna.IntegerType:
comparecomparecomparedoubleValueequalsfloatValuefromNativehashCodeintValuelongValuenativeTypesetValuetoNativetoString

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.sun.jna.IntegerType.serialVersionUID.

ZEROback to summary
public static final LibCAPI.size_t ZERO

Constructor Detail

size_tback to summary
public size_t()
size_tback to summary
public size_t(long value)
com.sun.jna.platform.unix back to summary

public Class LibCAPI.size_t.ByReference

extends ByReference
Class Inheritance

Constructor Summary

AccessConstructor and Description
public
public
ByReference(long value)

public

Method Summary

Modifier and TypeMethod and Description
public LibCAPI.size_t
public long
public void
setValue(long value)

public void
Inherited from com.sun.jna.ptr.ByReference:
toString

Constructor Detail

ByReferenceback to summary
public ByReference()
ByReferenceback to summary
public ByReference(long value)
ByReferenceback to summary
public ByReference(LibCAPI.size_t value)

Method Detail

getValueback to summary
public LibCAPI.size_t getValue()
longValueback to summary
public long longValue()
setValueback to summary
public void setValue(long value)
setValueback to summary
public void setValue(LibCAPI.size_t value)
com.sun.jna.platform.unix back to summary

public Class LibCAPI.ssize_t

extends IntegerType
Class Inheritance

This is a signed integer type used for a count of bytes or an error indication.

Field Summary

Modifier and TypeField and Description
private static final long
public static final LibCAPI.ssize_t

Constructor Summary

AccessConstructor and Description
public
public
ssize_t(long value)

Method Summary

Inherited from com.sun.jna.IntegerType:
comparecomparecomparedoubleValueequalsfloatValuefromNativehashCodeintValuelongValuenativeTypesetValuetoNativetoString

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.sun.jna.IntegerType.serialVersionUID.

ZEROback to summary
public static final LibCAPI.ssize_t ZERO

Constructor Detail

ssize_tback to summary
public ssize_t()
ssize_tback to summary
public ssize_t(long value)