Liking cljdoc? Tell your friends :D

clj-ebpf.dsl.mem

Memory operations for BPF programs.

Provides:

  • Load operations (ldx, ld)
  • Store operations (stx, st)
  • Atomic operations (atomic-add, atomic-xchg, etc.)
  • 64-bit immediate loads (lddw)
Memory operations for BPF programs.

Provides:
- Load operations (ldx, ld)
- Store operations (stx, st)
- Atomic operations (atomic-add, atomic-xchg, etc.)
- 64-bit immediate loads (lddw)
raw docstring

atomic-addclj

(atomic-add size dst src offset)

Atomic add to memory.

(size)(dst + offset) += src

Arguments:

  • size: :w (32-bit) or :dw (64-bit)
  • dst: Destination register (memory address)
  • src: Source register
  • offset: Memory offset
Atomic add to memory.

*(size*)(dst + offset) += src

Arguments:
- size: :w (32-bit) or :dw (64-bit)
- dst: Destination register (memory address)
- src: Source register
- offset: Memory offset
sourceraw docstring

atomic-andclj

(atomic-and size dst src offset)

Atomic AND to memory.

(size)(dst + offset) &= src

Atomic AND to memory.

*(size*)(dst + offset) &= src
sourceraw docstring

atomic-cmpxchgclj

(atomic-cmpxchg size dst src offset)

Atomic compare and exchange.

r0 = cmpxchg((size)(dst + offset), r0, src) If *addr == r0, then *addr = src

Atomic compare and exchange.

r0 = cmpxchg(*(size*)(dst + offset), r0, src)
If *addr == r0, then *addr = src
sourceraw docstring

atomic-fetch-addclj

(atomic-fetch-add size dst src offset)

Atomic fetch and add.

src = fetch_add((size)(dst + offset), src) Returns old value in src.

Atomic fetch and add.

src = fetch_add(*(size*)(dst + offset), src)
Returns old value in src.
sourceraw docstring

atomic-fetch-andclj

(atomic-fetch-and size dst src offset)

Atomic fetch and AND.

Atomic fetch and AND.
sourceraw docstring

atomic-fetch-orclj

(atomic-fetch-or size dst src offset)

Atomic fetch and OR.

Atomic fetch and OR.
sourceraw docstring

atomic-fetch-xorclj

(atomic-fetch-xor size dst src offset)

Atomic fetch and XOR.

Atomic fetch and XOR.
sourceraw docstring

atomic-orclj

(atomic-or size dst src offset)

Atomic OR to memory.

(size)(dst + offset) |= src

Atomic OR to memory.

*(size*)(dst + offset) |= src
sourceraw docstring

atomic-xchgclj

(atomic-xchg size dst src offset)

Atomic exchange.

src = xchg((size)(dst + offset), src)

Atomic exchange.

src = xchg(*(size*)(dst + offset), src)
sourceraw docstring

atomic-xorclj

(atomic-xor size dst src offset)

Atomic XOR to memory.

(size)(dst + offset) ^= src

Atomic XOR to memory.

*(size*)(dst + offset) ^= src
sourceraw docstring

ld-map-fdclj

(ld-map-fd dst map-fd)

Load map file descriptor as a pseudo 64-bit immediate.

dst = map_fd (with BPF_PSEUDO_MAP_FD marker)

Arguments:

  • dst: Destination register
  • map-fd: Map file descriptor
Load map file descriptor as a pseudo 64-bit immediate.

dst = map_fd (with BPF_PSEUDO_MAP_FD marker)

Arguments:
- dst: Destination register
- map-fd: Map file descriptor
sourceraw docstring

ld-map-valueclj

(ld-map-value dst map-fd)

Load map value pointer as 64-bit immediate.

dst = &map[0] (for direct value access)

Arguments:

  • dst: Destination register
  • map-fd: Map file descriptor
Load map value pointer as 64-bit immediate.

dst = &map[0] (for direct value access)

Arguments:
- dst: Destination register
- map-fd: Map file descriptor
sourceraw docstring

lddwclj

(lddw dst imm)

Load 64-bit immediate to register.

dst = imm64

This requires two instructions due to the 64-bit immediate. Returns a vector of two instructions.

Load 64-bit immediate to register.

dst = imm64

This requires two instructions due to the 64-bit immediate.
Returns a vector of two instructions.
sourceraw docstring

ldxclj

(ldx size dst src offset)

Load from memory to register.

dst = (size)(src + offset)

Arguments:

  • size: :b (byte), :h (half-word), :w (word), :dw (double-word)
  • dst: Destination register
  • src: Source register (base address)
  • offset: Memory offset
Load from memory to register.

dst = *(size*)(src + offset)

Arguments:
- size: :b (byte), :h (half-word), :w (word), :dw (double-word)
- dst: Destination register
- src: Source register (base address)
- offset: Memory offset
sourceraw docstring

ldxbclj

(ldxb dst src offset)

Load byte from memory.

dst = (u8)(src + offset)

Load byte from memory.

dst = *(u8*)(src + offset)
sourceraw docstring

ldxdwclj

(ldxdw dst src offset)

Load double-word (8 bytes) from memory.

dst = (u64)(src + offset)

Load double-word (8 bytes) from memory.

dst = *(u64*)(src + offset)
sourceraw docstring

ldxhclj

(ldxh dst src offset)

Load half-word (2 bytes) from memory.

dst = (u16)(src + offset)

Load half-word (2 bytes) from memory.

dst = *(u16*)(src + offset)
sourceraw docstring

ldxwclj

(ldxw dst src offset)

Load word (4 bytes) from memory.

dst = (u32)(src + offset)

Load word (4 bytes) from memory.

dst = *(u32*)(src + offset)
sourceraw docstring

size->bytesclj

(size->bytes size)

Convert size keyword to byte count

Convert size keyword to byte count
sourceraw docstring

size-mapclj

Map of size keywords to BPF size constants

Map of size keywords to BPF size constants
sourceraw docstring

stclj

(st size dst offset imm)

Store immediate to memory.

(size)(dst + offset) = imm

Arguments:

  • size: :b, :h, :w, :dw
  • dst: Destination register (base address)
  • offset: Memory offset
  • imm: Immediate value
Store immediate to memory.

*(size*)(dst + offset) = imm

Arguments:
- size: :b, :h, :w, :dw
- dst: Destination register (base address)
- offset: Memory offset
- imm: Immediate value
sourceraw docstring

stack-allocclj

(stack-alloc size)

Generate instructions to allocate space on stack.

Arguments:

  • size: Number of bytes to allocate (should be 8-byte aligned)

Returns mov instruction to set up stack pointer offset.

Generate instructions to allocate space on stack.

Arguments:
- size: Number of bytes to allocate (should be 8-byte aligned)

Returns mov instruction to set up stack pointer offset.
sourceraw docstring

stack-loadclj

(stack-load size dst offset)

Load from stack.

dst = (size)(fp - offset)

Arguments:

  • size: :b, :h, :w, :dw
  • dst: Destination register
  • offset: Positive offset from frame pointer
Load from stack.

dst = *(size*)(fp - offset)

Arguments:
- size: :b, :h, :w, :dw
- dst: Destination register
- offset: Positive offset from frame pointer
sourceraw docstring

stack-storeclj

(stack-store size offset src)

Store to stack from register.

(size)(fp - offset) = src

Arguments:

  • size: :b, :h, :w, :dw
  • offset: Positive offset from frame pointer
  • src: Source register
Store to stack from register.

*(size*)(fp - offset) = src

Arguments:
- size: :b, :h, :w, :dw
- offset: Positive offset from frame pointer
- src: Source register
sourceraw docstring

stack-store-immclj

(stack-store-imm size offset imm)

Store to stack from immediate.

(size)(fp - offset) = imm

Store to stack from immediate.

*(size*)(fp - offset) = imm
sourceraw docstring

stbclj

(stb dst offset imm)

Store byte to memory from immediate.

(u8)(dst + offset) = imm

Store byte to memory from immediate.

*(u8*)(dst + offset) = imm
sourceraw docstring

stdwclj

(stdw dst offset imm)

Store double-word to memory from immediate.

(u64)(dst + offset) = imm

Store double-word to memory from immediate.

*(u64*)(dst + offset) = imm
sourceraw docstring

sthclj

(sth dst offset imm)

Store half-word to memory from immediate.

(u16)(dst + offset) = imm

Store half-word to memory from immediate.

*(u16*)(dst + offset) = imm
sourceraw docstring

stwclj

(stw dst offset imm)

Store word to memory from immediate.

(u32)(dst + offset) = imm

Store word to memory from immediate.

*(u32*)(dst + offset) = imm
sourceraw docstring

stxclj

(stx size dst src offset)

Store register to memory.

(size)(dst + offset) = src

Arguments:

  • size: :b, :h, :w, :dw
  • dst: Destination register (base address)
  • src: Source register
  • offset: Memory offset
Store register to memory.

*(size*)(dst + offset) = src

Arguments:
- size: :b, :h, :w, :dw
- dst: Destination register (base address)
- src: Source register
- offset: Memory offset
sourceraw docstring

stxbclj

(stxb dst src offset)

Store byte to memory from register.

(u8)(dst + offset) = src

Store byte to memory from register.

*(u8*)(dst + offset) = src
sourceraw docstring

stxdwclj

(stxdw dst src offset)

Store double-word to memory from register.

(u64)(dst + offset) = src

Store double-word to memory from register.

*(u64*)(dst + offset) = src
sourceraw docstring

stxhclj

(stxh dst src offset)

Store half-word to memory from register.

(u16)(dst + offset) = src

Store half-word to memory from register.

*(u16*)(dst + offset) = src
sourceraw docstring

stxwclj

(stxw dst src offset)

Store word to memory from register.

(u32)(dst + offset) = src

Store word to memory from register.

*(u32*)(dst + offset) = src
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close