Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

System Information & Misc.

arch_prctl

Supported functionality in SCML:

// Get or set the FS/GS base registers.
arch_prctl(
    code = ARCH_SET_GS | ARCH_SET_FS | ARCH_GET_FS | ARCH_GET_GS,
    addr
);

Unsupported codes:

  • ARCH_GET_CPUID and ARCH_SET_CPUID

For more information, see the man page.

getrusage

Supported functionality in SCML:

// Return resource usage statistics for the calling process
getrusage(
    who = RUSAGE_SELF,
    usage
);

// Return resource usage statistics for the calling thread
getrusage(
    who = RUSAGE_THREAD,
    usage
);

Unsupported who flags:

  • RUSAGE_CHILDREN

For more information, see the man page.

getrandom

Supported functionality in SCML:

// Obtain random bytes
getrandom(
    buf, buflen,
    flags =
        // Optional flags:
        //
        // High-entropy pool
        GRND_RANDOM
);

Silently-ignored flags:

  • GRND_NONBLOCK because the underlying operation never blocks

For more information, see the man page.

reboot

Supported functionality in SCML:

reboot_magic2 = LINUX_REBOOT_MAGIC2 | LINUX_REBOOT_MAGIC2A | LINUX_REBOOT_MAGIC2B | LINUX_REBOOT_MAGIC2C;

// Stop the current system
reboot(
    magic  = LINUX_REBOOT_MAGIC1,
    magic2 = <reboot_magic2>,
    op     = LINUX_REBOOT_CMD_HALT | LINUX_REBOOT_CMD_POWER_OFF | LINUX_REBOOT_CMD_RESTART,
    arg
);

Unsupported op flags:

  • LINUX_REBOOT_CMD_CAD_OFF
  • LINUX_REBOOT_CMD_CAD_ON
  • LINUX_REBOOT_CMD_KEXEC
  • LINUX_REBOOT_CMD_RESTART2
  • LINUX_REBOOT_CMD_SW_SUSPEND

For more information, see the man page.

sysinfo

Supported functionality in SCML:

// Return system information.
sysinfo(info);

Supported returned fields:

  • uptime, rounded up to seconds when it has a fractional part
  • loads, containing the 1-, 5-, and 15-minute load averages as fixed-point values scaled by 1 << SI_LOAD_SHIFT
  • totalram, freeram, procs, and mem_unit

The sharedram, bufferram, totalhigh, and freehigh fields are reported as zero. The totalswap and freeswap fields are reported as zero because swap is not supported.

For more information, see the man page.

POSIX clocks

clock_gettime

Supported functionality in SCML:

predefined_clockid = CLOCK_REALTIME | CLOCK_MONOTONIC | CLOCK_MONOTONIC_RAW |
                     CLOCK_REALTIME_COARSE | CLOCK_MONOTONIC_COARSE | CLOCK_BOOTTIME |
                     CLOCK_PROCESS_CPUTIME_ID | CLOCK_THREAD_CPUTIME_ID;

// Get the time of a clock specified by a static ID
clock_gettime(clockid = <predefined_clockid>, tp);

// Get the time of a clock specified by a dynamic ID
clock_gettime(clockid = <INTEGER>, tp);

Unsupported predefined clock IDs:

  • CLOCK_REALTIME_ALARM
  • CLOCK_BOOTTIME_ALARM
  • CLOCK_TAI

For more information, see the man page.

clock_nanosleep

Supported functionality in SCML:

// Sleep with a specified clock
clock_nanosleep(
    clockid = CLOCK_REALTIME | CLOCK_MONOTONIC | CLOCK_BOOTTIME | CLOCK_PROCESS_CPUTIME_ID,
    flags =
        // Optional flags:
        //
        // Sleep until an absolute time point
        TIMER_ABSTIME,
    t, remain
);

Unsupported clock IDs:

  • CLOCK_TAI

For more information, see the man page.