Skip to content

Commit da987e0

Browse files
committed
Upgrade ocamlformat to 0.28.1
1 parent cd68168 commit da987e0

File tree

22 files changed

+248
-289
lines changed

22 files changed

+248
-289
lines changed

.ocamlformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
profile = default
2-
version = 0.27.0
2+
version = 0.28.1
33

44
exp-grouping=preserve

bench/bench_hashtbl.ml

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,38 @@ let run_one ~budgetf ~n_domains ?(n_ops = 100 * Util.iter_factor)
3030
let n_ops_todo = Countdown.create ~n_domains () in
3131

3232
let before () =
33-
begin
34-
match lock_type with
35-
| `Lock ->
36-
Lock.holding lock @@ fun () ->
37-
Hashtbl.clear t;
38-
if prepopulate then begin
39-
for _ = 1 to n_keys do
40-
let value = Random.bits () in
41-
let key = value mod n_keys in
42-
Hashtbl.replace t key value
43-
done
44-
end
45-
| `Rwlock ->
46-
Rwlock.holding rwlock @@ fun () ->
47-
Hashtbl.clear t;
48-
if prepopulate then begin
49-
for _ = 1 to n_keys do
50-
let value = Random.bits () in
51-
let key = value mod n_keys in
52-
Hashtbl.replace t key value
53-
done
54-
end
55-
| `Sem ->
56-
Sem.acquire sem;
57-
Hashtbl.clear t;
58-
if prepopulate then begin
59-
for _ = 1 to n_keys do
60-
let value = Random.bits () in
61-
let key = value mod n_keys in
62-
Hashtbl.replace t key value
63-
done
64-
end;
65-
Sem.release sem
33+
begin match lock_type with
34+
| `Lock ->
35+
Lock.holding lock @@ fun () ->
36+
Hashtbl.clear t;
37+
if prepopulate then begin
38+
for _ = 1 to n_keys do
39+
let value = Random.bits () in
40+
let key = value mod n_keys in
41+
Hashtbl.replace t key value
42+
done
43+
end
44+
| `Rwlock ->
45+
Rwlock.holding rwlock @@ fun () ->
46+
Hashtbl.clear t;
47+
if prepopulate then begin
48+
for _ = 1 to n_keys do
49+
let value = Random.bits () in
50+
let key = value mod n_keys in
51+
Hashtbl.replace t key value
52+
done
53+
end
54+
| `Sem ->
55+
Sem.acquire sem;
56+
Hashtbl.clear t;
57+
if prepopulate then begin
58+
for _ = 1 to n_keys do
59+
let value = Random.bits () in
60+
let key = value mod n_keys in
61+
Hashtbl.replace t key value
62+
done
63+
end;
64+
Sem.release sem
6665
end;
6766
Countdown.non_atomic_set n_ops_todo n_ops
6867
in

bench/bench_ref.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ module Ref = struct
99
let[@inline] compare_and_set x before after =
1010
!x == before
1111
&& begin
12-
x := after;
13-
true
14-
end
12+
x := after;
13+
true
14+
end
1515

1616
let[@inline] exchange x after =
1717
let before = !x in

bench/bench_stdio.ml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ let run_one ~budgetf ~block_or_nonblock ~n_domains () =
1111
in
1212
let wrap _ _ = Scheduler.run in
1313
let work _ (inn, out, block, byte) =
14-
begin
15-
match block_or_nonblock with
16-
| `Block -> ()
17-
| `Nonblock -> Unix.set_nonblock inn
14+
begin match block_or_nonblock with
15+
| `Block -> ()
16+
| `Nonblock -> Unix.set_nonblock inn
1817
end;
1918
for _ = 1 to n_blocks do
2019
let n = Unix.write out block 0 block_size in

lib/picos.domain/picos_domain.ocaml4.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module DLS = struct
1111
let[@poll error] [@inline never] compare_and_set key before after =
1212
!key == before
1313
&& begin
14-
key := after;
15-
true
16-
end
14+
key := after;
15+
true
16+
end
1717

1818
let rec get key =
1919
match !key with

lib/picos/picos.ocaml5.ml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,13 @@ module Computation = struct
139139
let rec rollback tx = function
140140
| Nil -> true
141141
| Completion r -> begin
142-
begin
143-
match Atomic.get r.computation with
144-
| ( S (Canceled { tx = previous_tx; _ })
145-
| S (Returned { tx = previous_tx; _ }) ) as before ->
146-
if tx == previous_tx then
147-
Atomic.compare_and_set r.computation before (S r.before)
148-
|> ignore
149-
| S (Continue _) -> ()
142+
begin match Atomic.get r.computation with
143+
| ( S (Canceled { tx = previous_tx; _ })
144+
| S (Returned { tx = previous_tx; _ }) ) as before ->
145+
if tx == previous_tx then
146+
Atomic.compare_and_set r.computation before (S r.before)
147+
|> ignore
148+
| S (Continue _) -> ()
150149
end;
151150
rollback tx r.completions
152151
end
@@ -188,11 +187,10 @@ module Computation = struct
188187
let rec commit = function
189188
| Nil -> true
190189
| Completion r ->
191-
begin
192-
match Atomic.get r.computation with
193-
| S (Canceled r) -> r.tx <- Stopped
194-
| S (Returned r) -> r.tx <- Stopped
195-
| S (Continue _) -> impossible ()
190+
begin match Atomic.get r.computation with
191+
| S (Canceled r) -> r.tx <- Stopped
192+
| S (Returned r) -> r.tx <- Stopped
193+
| S (Continue _) -> impossible ()
196194
end;
197195
signal r.before;
198196
commit r.completions
@@ -346,8 +344,8 @@ module Computation = struct
346344
let capture t fn x =
347345
(* Intentionally manually inlined [try_capture] to minimize stack usage *)
348346
(match fn x with
349-
| y -> try_return t y
350-
| exception exn -> try_capture_raised exn t)
347+
| y -> try_return t y
348+
| exception exn -> try_capture_raised exn t)
351349
|> ignore
352350

353351
let[@inline never] raise (Canceled { exn; bt; _ } : (_, [ `Canceled ]) st) =

lib/picos_aux.htbl/picos_aux_htbl.ml

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,14 @@ let rec copy_all r target i t step =
146146
[compare_and_set] below does not disrupt the next resize. *)
147147
Atomic.get t == r
148148
&& begin
149-
begin
150-
match before with
151-
| Resize _ ->
152-
Atomic_array.unsafe_compare_and_set target i (B before) (B spine)
153-
|> ignore
154-
| Nil | Cons _ -> ()
155-
end;
156-
i = 0 || copy_all r target i t step
157-
end
149+
begin match before with
150+
| Resize _ ->
151+
Atomic_array.unsafe_compare_and_set target i (B before) (B spine)
152+
|> ignore
153+
| Nil | Cons _ -> ()
154+
end;
155+
i = 0 || copy_all r target i t step
156+
end
158157

159158
(* *)
160159

@@ -179,24 +178,21 @@ let rec split_all r target i t step =
179178
resize. *)
180179
Atomic.get t == r
181180
&& begin
182-
begin
183-
match before_lo with
184-
| Resize _ ->
185-
Atomic_array.unsafe_compare_and_set target i (B before_lo)
186-
(B after_lo)
187-
|> ignore
188-
| Nil | Cons _ -> ()
189-
end;
190-
begin
191-
match before_hi with
192-
| Resize _ ->
193-
Atomic_array.unsafe_compare_and_set target (i + high) (B before_hi)
194-
(B after_hi)
195-
|> ignore
196-
| Nil | Cons _ -> ()
197-
end;
198-
i = 0 || split_all r target i t step
199-
end
181+
begin match before_lo with
182+
| Resize _ ->
183+
Atomic_array.unsafe_compare_and_set target i (B before_lo) (B after_lo)
184+
|> ignore
185+
| Nil | Cons _ -> ()
186+
end;
187+
begin match before_hi with
188+
| Resize _ ->
189+
Atomic_array.unsafe_compare_and_set target (i + high) (B before_hi)
190+
(B after_hi)
191+
|> ignore
192+
| Nil | Cons _ -> ()
193+
end;
194+
i = 0 || split_all r target i t step
195+
end
200196

201197
(* *)
202198

@@ -217,15 +213,14 @@ let rec merge_all r target i t step =
217213
[compare_and_set] below does not disrupt the next resize. *)
218214
Atomic.get t == r
219215
&& begin
220-
begin
221-
match before with
222-
| Resize _ ->
223-
Atomic_array.unsafe_compare_and_set target i (B before) (B after)
224-
|> ignore
225-
| Nil | Cons _ -> ()
226-
end;
227-
i = 0 || merge_all r target i t step
228-
end
216+
begin match before with
217+
| Resize _ ->
218+
Atomic_array.unsafe_compare_and_set target i (B before) (B after)
219+
|> ignore
220+
| Nil | Cons _ -> ()
221+
end;
222+
i = 0 || merge_all r target i t step
223+
end
229224

230225
(* *)
231226

@@ -277,9 +272,9 @@ let[@inline never] try_resize t r new_capacity ~clear =
277272
let new_r = { r with pending = Resize { buckets; non_linearizable_size } } in
278273
Atomic.compare_and_set t r new_r
279274
&& begin
280-
finish t new_r |> ignore;
281-
true
282-
end
275+
finish t new_r |> ignore;
276+
true
277+
end
283278

284279
(** This only gives an "estimate" of the size, which can be off by one or more
285280
and even be negative, so this must be used with care. *)

lib/picos_aux.mpmcq/picos_aux_mpmcq.ml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,14 @@ let rec push t value backoff = function
6161
let backoff = Backoff.once backoff in
6262
push t value backoff (Atomic.fenceless_get t.tail)
6363
| Snoc move_r as move ->
64-
begin
65-
match Atomic.get t.head with
66-
| H (Head head_r as head) when head_r.counter < move_r.counter ->
67-
let after = rev move in
68-
if
69-
Atomic.fenceless_get t.head == H head
70-
&& Atomic.compare_and_set t.head (H head) (H after)
71-
then tail_r.move <- Used
72-
| _ -> tail_r.move <- Used
64+
begin match Atomic.get t.head with
65+
| H (Head head_r as head) when head_r.counter < move_r.counter ->
66+
let after = rev move in
67+
if
68+
Atomic.fenceless_get t.head == H head
69+
&& Atomic.compare_and_set t.head (H head) (H after)
70+
then tail_r.move <- Used
71+
| _ -> tail_r.move <- Used
7372
end;
7473
push t value backoff (Atomic.get t.tail)
7574
end
@@ -171,16 +170,14 @@ let rec push_head t value backoff =
171170
end
172171
else push_head t value backoff
173172
| Snoc move_r as move ->
174-
begin
175-
match Atomic.get t.head with
176-
| H (Head head_r as head) when head_r.counter < move_r.counter
177-
->
178-
let after = rev move in
179-
if
180-
Atomic.fenceless_get t.head == H head
181-
&& Atomic.compare_and_set t.head (H head) (H after)
182-
then tail_r.move <- Used
183-
| _ -> tail_r.move <- Used
173+
begin match Atomic.get t.head with
174+
| H (Head head_r as head) when head_r.counter < move_r.counter ->
175+
let after = rev move in
176+
if
177+
Atomic.fenceless_get t.head == H head
178+
&& Atomic.compare_and_set t.head (H head) (H after)
179+
then tail_r.move <- Used
180+
| _ -> tail_r.move <- Used
184181
end;
185182
push_head t value backoff
186183
end

lib/picos_io.select/picos_io_select.ml

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ let key =
137137
let[@poll error] [@inline never] try_transition s from into =
138138
s.state == from
139139
&& begin
140-
s.state <- into;
141-
true
142-
end
140+
s.state <- into;
141+
true
142+
end
143143

144144
let[@poll error] [@inline never] transition s into =
145145
let from = s.state in
@@ -282,16 +282,15 @@ let select_thread s =
282282
[ Sys.sigchld ]
283283
|> ignore
284284
end;
285-
begin
286-
try
287-
let pipe_inn, pipe_out = Unix.pipe ~cloexec:true () in
288-
s.pipe_inn <- pipe_inn;
289-
s.pipe_out <- pipe_out;
290-
if try_transition s `Starting `Alive then
291-
select_thread s (-1.0) fos_empty fos_empty fos_empty
292-
with exn ->
293-
let bt = Printexc.get_raw_backtrace () in
294-
s.exn_bt <- (exn, bt)
285+
begin try
286+
let pipe_inn, pipe_out = Unix.pipe ~cloexec:true () in
287+
s.pipe_inn <- pipe_inn;
288+
s.pipe_out <- pipe_out;
289+
if try_transition s `Starting `Alive then
290+
select_thread s (-1.0) fos_empty fos_empty fos_empty
291+
with exn ->
292+
let bt = Printexc.get_raw_backtrace () in
293+
s.exn_bt <- (exn, bt)
295294
end;
296295
transition s `Stopped |> ignore;
297296
if s.pipe_inn != Unix.stdin then Unix.close s.pipe_inn;
@@ -301,13 +300,13 @@ let[@poll error] [@inline never] try_configure ~intr_sig ~intr_sigs
301300
~handle_sigchld ~ignore_sigpipe =
302301
config.intr_sigs == []
303302
&& begin
304-
config.bits <-
305-
Bool.to_int handle_sigchld
306-
lor (ignore_sigpipe_bit land -Bool.to_int ignore_sigpipe);
307-
config.intr_sig <- intr_sig;
308-
config.intr_sigs <- intr_sigs;
309-
true
310-
end
303+
config.bits <-
304+
Bool.to_int handle_sigchld
305+
lor (ignore_sigpipe_bit land -Bool.to_int ignore_sigpipe);
306+
config.intr_sig <- intr_sig;
307+
config.intr_sigs <- intr_sigs;
308+
true
309+
end
311310

312311
let is_intr_sig signum = signum = config.intr_sig
313312

@@ -485,12 +484,11 @@ module Intr = struct
485484
(* [intr_pending] must be read before [r.unused]! *)
486485
r.unused && before.req != R req
487486
&& begin
488-
use before.req;
489-
let after = { value = before.value + 1; req = R req } in
490-
if Atomic.compare_and_set intr_pending before after then
491-
after.value = 1
492-
else incr_once req (Backoff.once backoff)
493-
end
487+
use before.req;
488+
let after = { value = before.value + 1; req = R req } in
489+
if Atomic.compare_and_set intr_pending before after then after.value = 1
490+
else incr_once req (Backoff.once backoff)
491+
end
494492

495493
let intr_action trigger (Req r as req : [ `Req ] tdt) id =
496494
match Computation.peek_exn r.computation with

0 commit comments

Comments
 (0)