:- module par_builtin.
:- use_module builtin, io, private_builtin, table_builtin.
:- type par_builtin.loop_control.
:- pragma foreign_type(il, par_builtin.loop_control, "class [mscorlib]System.Object").
:- pragma foreign_type(c, par_builtin.loop_control, "MR_LoopControl *", [can_pass_as_mercury_type]).
:- pragma foreign_type(java, par_builtin.loop_control, "java.lang.Object").
:- pragma foreign_type(csharp, par_builtin.loop_control, "object").
:- pragma foreign_type(erlang, par_builtin.loop_control, "").
:- type par_builtin.future(T).
:- pragma foreign_type(il, par_builtin.future(T), "class [mscorlib]System.Object").
:- pragma foreign_type(c, par_builtin.future(T), "MR_Future *", [can_pass_as_mercury_type]).
:- pragma foreign_type(java, par_builtin.future(T), "java.lang.Object").
:- pragma foreign_type(csharp, par_builtin.future(T), "object").
:- pragma foreign_type(erlang, par_builtin.future(T), "").
:- pragma foreign_import_module("C", par_builtin).
:- pragma foreign_import_module("C#", par_builtin).
:- pragma foreign_import_module("Java", par_builtin).
:- pragma foreign_import_module("IL", par_builtin).
:- pragma foreign_import_module("Erlang", par_builtin).
:- pragma foreign_import_module("C", io).
:- pragma foreign_import_module("C#", io).
:- pragma foreign_import_module("Java", io).
:- pragma foreign_import_module("IL", io).
:- pragma foreign_import_module("Erlang", io).
:- pragma foreign_import_module("C", io).
:- pragma foreign_import_module("C#", io).
:- pragma foreign_import_module("Java", io).
:- pragma foreign_import_module("IL", io).
:- pragma foreign_import_module("Erlang", io).
:- pragma foreign_import_module("C", time).
:- pragma foreign_import_module("C", string).
:- pragma foreign_import_module("C", table_builtin).
:- pragma foreign_import_module("IL", table_builtin).
:- pragma foreign_import_module("C", table_builtin).
:- pragma foreign_import_module("IL", table_builtin).
:- pragma foreign_import_module("C", bitmap).
:- pragma foreign_import_module("C#", bitmap).
:- pragma foreign_import_module("Java", bitmap).
:- pragma foreign_import_module("IL", bitmap).
:- pragma foreign_import_module("Erlang", bitmap).
:- pragma foreign_import_module("C", bitmap).
:- pragma foreign_import_module("C#", bitmap).
:- pragma foreign_import_module("Java", bitmap).
:- pragma foreign_import_module("IL", bitmap).
:- pragma foreign_import_module("Erlang", bitmap).
:- pragma foreign_import_module("C", time).
:- pragma foreign_import_module("C#", time).
:- pragma foreign_import_module("Java", time).
:- pragma foreign_import_module("IL", time).
:- pragma foreign_import_module("Erlang", time).
:- pragma foreign_import_module("C", time).
:- pragma foreign_import_module("C#", time).
:- pragma foreign_import_module("Java", time).
:- pragma foreign_import_module("IL", time).
:- pragma foreign_import_module("Erlang", time).
:- pragma foreign_import_module("C#", rtti_implementation).
:- pragma foreign_import_module("Java", rtti_implementation).
:- pragma foreign_import_module("C#", rtti_implementation).
:- pragma foreign_import_module("Java", rtti_implementation).
:- pragma foreign_proc("C", par_builtin.lc_create(NumWorkers :: (builtin.in), LC :: (builtin.out)), [will_not_call_mercury, thread_safe, not_tabled_for_io, promise_pure, will_not_throw_exception, may_modify_trail], "
#if defined(MR_THREAD_SAFE) && defined(MR_LL_PARALLEL_CONJ)
    LC = MR_lc_create(NumWorkers);
#else
    MR_fatal_error(\"lc_create is unavailable in this grade\");
#endif
").
:- pragma foreign_proc("C", par_builtin.num_os_threads(NThreads :: (builtin.out)), [will_not_call_mercury, thread_safe, not_tabled_for_io, promise_pure, will_not_throw_exception, may_modify_trail], "
    /*
    ** MR_num_threads is available in all grades. Although it won\'t make sense
    ** for non-parallel grades, it will still reflect the value configured by
    ** the user.
    */
    NThreads = MR_num_threads
").
:- pragma foreign_proc("C", par_builtin.par_cond_close_stats_file(_IO0 :: (builtin.di), _IO :: (builtin.uo)), [will_not_call_mercury, thread_safe, tabled_for_io, promise_pure, may_modify_trail], "
#if defined(MR_LL_PARALLEL_CONJ) &&         defined(MR_DEBUG_RUNTIME_GRANULARITY_CONTROL)
    MR_write_out_conditional_parallelism_log();
#else
    MR_fatal_error(\"par_cond_close_stats_file is unavailable in this grade\");
#endif
").
:- pragma exceptions(predicate, (par_builtin.new_future), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (par_builtin.wait_future), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (par_builtin.get_future), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (par_builtin.signal_future), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (par_builtin.lc_create), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (par_builtin.lc_free_slot), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (par_builtin.lc_join_and_terminate), 2, 0, will_not_throw).
:- pragma exceptions(predicate, (par_builtin.lc_default_num_contexts), 1, 0, will_not_throw).
:- pragma exceptions(predicate, (par_builtin.evaluate_parallelism_condition), 0, 0, will_not_throw).
:- pragma exceptions(predicate, (par_builtin.num_os_threads), 1, 0, will_not_throw).
:- pragma exceptions(predicate, (par_builtin.par_cond_close_stats_file), 2, 0, will_not_throw).
:- pragma termination_info(par_builtin.new_future((builtin.in), (builtin.uo)), infinite, cannot_loop).
:- pragma termination_info(par_builtin.wait_future((builtin.in), (builtin.out)), infinite, cannot_loop).
:- pragma termination_info(par_builtin.get_future((builtin.in), (builtin.out)), infinite, cannot_loop).
:- pragma termination_info(par_builtin.signal_future((builtin.in), (builtin.in)), finite(0, [no, no]), cannot_loop).
:- pragma termination_info(par_builtin.lc_create((builtin.in), (builtin.out)), infinite, cannot_loop).
:- pragma termination_info(par_builtin.lc_free_slot((builtin.in), (builtin.out)), infinite, cannot_loop).
:- pragma termination_info(par_builtin.lc_join_and_terminate((builtin.in), (builtin.in)), finite(0, [no, no]), cannot_loop).
:- pragma termination_info(par_builtin.lc_default_num_contexts((builtin.out)), infinite, cannot_loop).
:- pragma termination_info((par_builtin.evaluate_parallelism_condition), finite(0, []), cannot_loop).
:- pragma termination_info(par_builtin.num_os_threads((builtin.out)), infinite, cannot_loop).
:- pragma termination_info(par_builtin.par_cond_close_stats_file((builtin.di), (builtin.uo)), infinite, cannot_loop).
