mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 10:53:40 +00:00
tests/general/float_test.exp3:
tests/general/float_test.m:
tests/general/read_dir_regression.exp4:
tests/general/read_dir_regression.m:
tests/hard_coded/remove_file.exp2:
tests/hard_coded/remove_file.m:
Delete Erlang backend specific expected outputs.
tests/hard_coded/Mmakefile:
tests/hard_coded/erlang_deconstruct.exp:
tests/hard_coded/erlang_deconstruct.m:
tests/hard_coded/existential_list.exp:
tests/hard_coded/existential_list.m:
tests/valid/Mmakefile:
tests/valid/erl_ite_vars.m:
tests/valid/zf_erlang_bug.m:
Delete erlang target specific tests.
tests/*:
Delete Erlang foreign procs and foreign types.
52 lines
1.1 KiB
Mathematica
52 lines
1.1 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% In low-level parallel grades, running with many threads could cause
|
|
% the program to deadlock.
|
|
|
|
:- module threads_hang.
|
|
:- interface.
|
|
:- import_module io.
|
|
|
|
:- impure pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
:- import_module int.
|
|
|
|
main(!IO) :-
|
|
% Set a signal to go off if the program is taking too long.
|
|
% The default SIGALRM handler will abort the program.
|
|
impure alarm(10),
|
|
|
|
fib(7, F),
|
|
fib(6, G),
|
|
io.write_int(F, !IO),
|
|
io.nl(!IO),
|
|
io.write_int(G, !IO),
|
|
io.nl(!IO),
|
|
io.flush_output(!IO).
|
|
|
|
:- pred fib(int::in, int::out) is det.
|
|
|
|
fib(N, F) :-
|
|
( if N < 2 then
|
|
F = 1
|
|
else
|
|
( fib(N-1, F1)
|
|
& fib(N-2, F2)
|
|
),
|
|
F = F1 + F2
|
|
).
|
|
|
|
:- pragma foreign_decl("C", "#include <unistd.h>").
|
|
|
|
:- impure pred alarm(int::in) is det.
|
|
|
|
:- pragma foreign_proc("C",
|
|
alarm(Seconds::in),
|
|
[will_not_call_mercury],
|
|
"
|
|
alarm(Seconds);
|
|
").
|