endian+x86_64 +linux

The endian module provides support functions for converting the byte encoding ("endianness") of integers. The following abbreviations are used throughout the module:

Index

Types

type endian = struct {
	getu16: *fn(buf: []u8) u16,
	putu16: *fn(buf: []u8, in: u16) void,
	getu32: *fn(buf: []u8) u32,
	putu32: *fn(buf: []u8, in: u32) void,
	getu64: *fn(buf: []u8) u64,
	putu64: *fn(buf: []u8, in: u64) void,
};

Globals

const big: endian;
const host: *endian;
const little: endian;

Functions

fn begetu16(buf: []u8) u16;
fn begetu32(buf: []u8) u32;
fn begetu64(buf: []u8) u64;
fn beputu16(buf: []u8, in: u16) void;
fn beputu32(buf: []u8, in: u32) void;
fn beputu64(buf: []u8, in: u64) void;
fn htonu16(in: u16) u16;
fn htonu32(in: u32) u32;
fn htonu64(in: u64) u64;
fn legetu16(buf: []u8) u16;
fn legetu32(buf: []u8) u32;
fn legetu64(buf: []u8) u64;
fn leputu16(buf: []u8, in: u16) void;
fn leputu32(buf: []u8, in: u32) void;
fn leputu64(buf: []u8, in: u64) void;
fn ntohu16(in: u16) u16;
fn ntohu32(in: u32) u32;
fn ntohu64(in: u64) u64;

Types

type endian[permalink] [source]

type endian = struct {
	getu16: *fn(buf: []u8) u16,
	putu16: *fn(buf: []u8, in: u16) void,
	getu32: *fn(buf: []u8) u32,
	putu32: *fn(buf: []u8, in: u32) void,
	getu64: *fn(buf: []u8) u64,
	putu64: *fn(buf: []u8, in: u64) void,
};

The set of functions used for endian-aware encoding.

Globals

let big[permalink] [source]

const big: endian;

Big endian; MSB first.

let host[permalink] [source]

const host: *endian;

The endian functions which map to the host architecture.

let little[permalink] [source]

const little: endian;

Little endian; LSB first.

Functions

fn begetu16[permalink] [source]

fn begetu16(buf: []u8) u16;

Reads a u16 from a buffer in big-endian order.

fn begetu32[permalink] [source]

fn begetu32(buf: []u8) u32;

Reads a u32 from a buffer in big-endian order.

fn begetu64[permalink] [source]

fn begetu64(buf: []u8) u64;

Reads a u64 from a buffer in big-endian order.

fn beputu16[permalink] [source]

fn beputu16(buf: []u8, in: u16) void;

Writes a u16 into a buffer in big-endian order.

fn beputu32[permalink] [source]

fn beputu32(buf: []u8, in: u32) void;

Writes a u32 into a buffer in big-endian order.

fn beputu64[permalink] [source]

fn beputu64(buf: []u8, in: u64) void;

Writes a u64 into a buffer in big-endian order.

fn htonu16[permalink] [source]

fn htonu16(in: u16) u16;

Converts a u16 from host order to network order.

fn htonu32[permalink] [source]

fn htonu32(in: u32) u32;

Converts a u32 from host order to network order.

fn htonu64[permalink] [source]

fn htonu64(in: u64) u64;

Converts a u64 from host order to network order.

fn legetu16[permalink] [source]

fn legetu16(buf: []u8) u16;

Reads a u16 from a buffer in little-endian order.

fn legetu32[permalink] [source]

fn legetu32(buf: []u8) u32;

Reads a u32 from a buffer in little-endian order.

fn legetu64[permalink] [source]

fn legetu64(buf: []u8) u64;

Reads a u64 from a buffer in little-endian order.

fn leputu16[permalink] [source]

fn leputu16(buf: []u8, in: u16) void;

Writes a u16 into a buffer in little-endian order.

fn leputu32[permalink] [source]

fn leputu32(buf: []u8, in: u32) void;

Writes a u32 into a buffer in little-endian order.

fn leputu64[permalink] [source]

fn leputu64(buf: []u8, in: u64) void;

Writes a u64 into a buffer in little-endian order.

fn ntohu16[permalink] [source]

fn ntohu16(in: u16) u16;

Converts a u16 from network order to host order.

fn ntohu32[permalink] [source]

fn ntohu32(in: u32) u32;

Converts a u32 from network order to host order.

fn ntohu64[permalink] [source]

fn ntohu64(in: u64) u64;

Converts a u64 from network order to host order.