Module Os.Arch

OS architectures.

type id = string

The type for architecture identifiers. Unless you create them yourself these strings are non-empty, lowercase ASCII, with original '-' characters mapped to '_'.

type t =
  1. | Arm32 of id
  2. | Arm64 of id
  3. | Ppc32 of id
  4. | Ppc64 of id
  5. | Riscv32 of id
  6. | Riscv64 of id
  7. | X86_32 of id
  8. | X86_64 of id
  9. | Other of id

The type for OS machine architectures.

Architectures are sorted into families. The datum of each family has the concrete architecture identifier.

Warning. Minor versions of the library may add new family enumerants or attach a family to an identifier previously classified as Other (moving between families should not happen, except to fix the odd bug). As such:

  • Pattern matching on Other "…" constants is not recommended. If you need to select such an identifier start by pattern matching on id before dropping to pattern matching on this type.
  • Unless you want your code to be informed by the introduction of a new family, end your pattern match with a catch all branch _ rather than Other _.
val of_string : string -> t

of_string s is an architecture determined by from s normalized by ASCII lowercasing it and mapping '-' to '_'. Unrecognized architectures end up as Other with the normalized s. Strings printed by pp are guaranteed to parse (with the family as the identifier).

val id : t -> id

id arch is the identifier of arch.

val bits : t -> int option

bits arch determines the bitness of arch usually Some 32 or Some 64 or None if unknown.

Predicates and comparisons

val equal : t -> t -> bool

equal asserts equality by family, except for Other id values which are each their own distinct family.

val compare : t -> t -> int

compare is a total order compatible with equal.

Formatting

val pp : t Fmt.t

pp formats architecture families for inspection. The concrete identifier is not printed.

val pp_id : t Fmt.t

pp_id ppf arch formats the id of arch.

val pp_bits : t Fmt.t

pp_bits ppf arch formats the integer bits of arch or "<unknown>" if None.