package kcas_data

  1. Overview
  2. Docs
Compositional lock-free data structures and primitives for communication and synchronization

Install

dune-project
 Dependency

Authors

Maintainers

Sources

kcas-0.4.0.tbz
sha256=15fbb643bbdf741fc8deba8144a3826690684b6af4ca2b89f596145b51db51e8
sha512=b8b23de11a1becb5818975501802ad134f64546ebd45ef7b7104c88d40e3916afbd8465b0950e4f3e21ced49306d04aff1d308e918156df12c23a52bf335b278

doc/src/kcas_data/bits.ml.html

Source file bits.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
let is_pow_2 n = n land (n - 1) = 0

let max_0 n =
  let m = n asr (Sys.int_size - 1) in
  n land lnot m

let ceil_pow_2_minus_1 n =
  let n = n lor (n lsr 1) in
  let n = n lor (n lsr 2) in
  let n = n lor (n lsr 4) in
  let n = n lor (n lsr 8) in
  let n = n lor (n lsr 16) in
  if Sys.int_size > 32 then n lor (n lsr 32) else n

let ceil_pow_2 n =
  if n <= 1 then 1
  else
    let n = n - 1 in
    let n = ceil_pow_2_minus_1 n in
    n + 1
OCaml

Innovation. Community. Security.