Module Os.Arch

OS architectures.

type id = string

The type for architecture identifiers. Unless you create them yourself these strings are normalized: 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 : ?family:t -> string -> t

of_string s is an architecture determined by 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).

If family is provided, s is simply normalized and the family of family is used in the result.

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.

Family constants

These constants can be used as family representatives.

val arm32 : t

arm32 is Arm32 "arm32".

val arm64 : t

arm64 is Arm64 "arm64".

val ppc32 : t

ppc32 is Ppc32 "ppc32".

val ppc64 : t

ppc64 is Ppc64 "ppc64".

val riscv32 : t

riscv32 is Riscv32 "riscv32".

val riscv64 : t

riscv64 is Riscv64 "riscv64".

val x86_32 : t

x86_32 is X86_32 "x86_32".

val x86_64 : t

x86_64 is X86_32 "x86_64".

val unknown : t

unknown is Other "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.