Skip navigation links
JNA API 5.10.0
com.sun.jna.platform.unix

Interface LibCAPI

  • All Superinterfaces:
    Reboot, Resource
    All Known Subinterfaces:
    LibC, LibC, SystemB


    public interface LibCAPI
    extends Reboot, Resource
    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
    • Method Detail

      • getuid

        int getuid()
      • geteuid

        int geteuid()
      • getgid

        int getgid()
      • getegid

        int getegid()
      • setuid

        int setuid(int uid)
      • seteuid

        int seteuid(int uid)
      • setgid

        int setgid(int gid)
      • setegid

        int setegid(int gid)
      • gethostname

        int gethostname(byte[] name,
                        int len)
      • sethostname

        int sethostname(java.lang.String name,
                        int len)
      • getdomainname

        int getdomainname(byte[] name,
                          int len)
      • setdomainname

        int setdomainname(java.lang.String name,
                          int len)
      • getenv

        java.lang.String getenv(java.lang.String name)
        Parameters:
        name - Environment variable name
        Returns:
        Returns the value in the environment, or null if there is no match for the name
        See Also:
        getenv(3)
      • setenv

        int setenv(java.lang.String name,
                   java.lang.String value,
                   int overwrite)
        Update or add a variable in the environment of the calling process.
        Parameters:
        name - Environment variable name
        value - Required value
        overwrite - 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:
        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)
      • unsetenv

        int unsetenv(java.lang.String name)
        Parameters:
        name - 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:
        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)
      • getloadavg

        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 - An array of doubles which will be filled with the results
        nelem - Number of samples to return
        Returns:
        If the load average was unobtainable, -1 is returned; otherwise, the number of samples actually retrieved is returned.
        See Also:
        getloadavg(3)
      • close

        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 - a file descriptor
        Returns:
        returns zero on success. On error, -1 is returned, and errno is set appropriately.

        close() should not be retried after an error.

      • msync

        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 - The start of the memory area to sync to the filesystem.
        length - The length of the memory area to sync to the filesystem.
        flags - The flags argument should specify exactly one of MS_ASYNC and MS_SYNC, and may additionally include the MS_INVALIDATE bit.
        Returns:
        On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
      • munmap

        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 - 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 - 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:
        On success, returns 0. On failure, it returns -1, and errno is set to indicate the cause of the error (probably to EINVAL).
JNA API 5.10.0

Copyright © 2007-2018 Timothy Wall. All Rights Reserved.