# gizlang/linux-abi

The records of the Linux ABI that native code reads and writes in memory: the structs of system calls and messages. gizlang/linux keeps the numbers and stays portable; this module needs gizlang/target, so it is native only.

```gizlang
import * as Linux-abi from "gizlang/linux-abi";
```

## Types

### `Timespec`

```gizlang
@Packed export type Timespec = { seconds: i64; nanoseconds: i64; }
```

struct timespec: seconds and nanoseconds.

- `seconds`: `i64`
- `nanoseconds`: `i64`

### `Timeval`

```gizlang
@Packed export type Timeval = { seconds: i64; microseconds: i64; }
```

struct timeval: seconds and microseconds.

- `seconds`: `i64`
- `microseconds`: `i64`

### `Itimerspec`

```gizlang
@Packed export type Itimerspec = { interval: Timespec; value: Timespec; }
```

struct itimerspec: the interval, then the first expiry.

- `interval`: `gizlang_linux_abi.Timespec`
- `value`: `gizlang_linux_abi.Timespec`

### `PollFd`

```gizlang
@Packed export type PollFd = { fd: i32; events: u16; revents: u16; }
```

struct pollfd: a descriptor (-1: not asked), the events asked for, and those that came.

- `fd`: `i32`
- `events`: `u16`
- `revents`: `u16`

### `FdPair`

```gizlang
@Packed export type FdPair = { first: i32; second: i32; }
```

The two descriptors pipe2(2) and socketpair(2) write.

- `first`: `i32`
- `second`: `i32`

### `SockaddrUn`

```gizlang
@Packed export type SockaddrUn = { family: u16; path: Fixed<u8, 108>; }
```

struct sockaddr_un: the family, then the path with its NUL.

- `family`: `u16`
- `path`: `gizlang_target.Fixed<u8, 108>`

### `StatxTime`

```gizlang
@Packed export type StatxTime
```

struct statx_timestamp.

- `seconds`: `i64`
- `nanoseconds`: `u32`

### `Statx`

```gizlang
@Packed export type Statx
```

struct statx (statx(2)).

- `mask`: `u32`
- `blockSize`: `u32`
- `attributes`: `u64`
- `links`: `u32`
- `uid`: `u32`
- `gid`: `u32`
- `mode`: `u16`
- `inode`: `u64`
- `size`: `u64`
- `blocks`: `u64`
- `attributesMask`: `u64`
- `accessed`: `gizlang_linux_abi.StatxTime`
- `btime`: `gizlang_linux_abi.StatxTime`
- `changed`: `gizlang_linux_abi.StatxTime`
- `modified`: `gizlang_linux_abi.StatxTime`
- `rdevMajor`: `u32`
- `rdevMinor`: `u32`
- `devMajor`: `u32`
- `devMinor`: `u32`
- `mountId`: `u64`
- `memoryAlign`: `u32`
- `offsetAlign`: `u32`

### `Rusage`

```gizlang
@Packed export type Rusage = { user: Timeval; system: Timeval; maxResidentKb: i64; sharedKb: i64; dataKb: i64; stackKb: i64; minorFaults: i64; majorFaults: i64; swaps: i64; blocksIn: i64; blocksOut: i64; messagesSent: i64; messagesReceived: i64; signals: i64; voluntarySwitches: i64; involuntarySwitches: i64; }
```

struct rusage (getrusage(2)): the user and system times, then the counters; sizes in KB.

- `user`: `gizlang_linux_abi.Timeval`
- `system`: `gizlang_linux_abi.Timeval`
- `maxResidentKb`: `i64`
- `sharedKb`: `i64`
- `dataKb`: `i64`
- `stackKb`: `i64`
- `minorFaults`: `i64`
- `majorFaults`: `i64`
- `swaps`: `i64`
- `blocksIn`: `i64`
- `blocksOut`: `i64`
- `messagesSent`: `i64`
- `messagesReceived`: `i64`
- `signals`: `i64`
- `voluntarySwitches`: `i64`
- `involuntarySwitches`: `i64`

### `Iovec`

```gizlang
@Packed export type Iovec = { base: u64; length: u64; }
```

struct iovec: one buffer of a vectored call or message, its address then its length.

- `base`: `u64`
- `length`: `u64`

### `Msghdr`

```gizlang
@Packed export type Msghdr = { address: u64; addressSize: u64; vector: u64; vectorCount: u64; control: u64; controlSize: u64; flags: u64; }
```

struct msghdr on a 64-bit ABI; its int fields are written as whole 64-bit words, padding included.

- `address`: `u64`
- `addressSize`: `u64`
- `vector`: `u64`
- `vectorCount`: `u64`
- `control`: `u64`
- `controlSize`: `u64`
- `flags`: `u64`

### `Cmsghdr`

```gizlang
@Packed export type Cmsghdr = { size: u64; level: u32; kind: u32; }
```

struct cmsghdr: the size of a control message with its header, its level and its kind.

- `size`: `u64`
- `level`: `u32`
- `kind`: `u32`

### `ScmRights`

```gizlang
@Packed export type ScmRights = { header: Cmsghdr; descriptor: u32; }
```

A control message that passes one descriptor (SCM_RIGHTS): its header, then the descriptor.

- `header`: `gizlang_linux_abi.Cmsghdr`
- `descriptor`: `u32`

