/*
** Automatically generated from `thread.m'
** by the Mercury compiler,
** version 14.01.1, configured for x86_64--netbsd.
** Do not edit.
**
** The autoconfigured grade settings governing
** the generation of this C file were
**
** TAG_BITS=3
** UNBOXED_FLOAT=yes
** PREGENERATED_DIST=no
** HIGHLEVEL_CODE=yes
**
** END_OF_C_GRADE_INFO
*/


/* :- module thread. */
/* :- interface. */

#ifndef MR_HEADER_GUARD_thread
#define MR_HEADER_GUARD_thread

#ifdef __cplusplus
extern "C" {
#endif

#include "mercury.h"


#ifndef THREAD_DECL_GUARD
#define THREAD_DECL_GUARD
#line 59 "thread.m"

#ifndef MR_HIGHLEVEL_CODE
  #if (!defined(MR_EXEC_TRACE) && !defined(MR_DEEP_PROFILING)) || !defined(MR_USE_GCC_NONLOCAL_GOTOS)
    /*
    ** In calling thread.yield, semaphore.wait or semaphore.signal, the
    ** calling context may need to suspend and yield to another context.
    ** This is implemented by setting the resume address of the context to an
    ** auxiliary function outside of the foreign_proc.  This breaks when
    ** execution tracing or deep profiling are enabled as code inserted at the
    ** end of the foreign_proc won't be executed.  In those cases we rely on
    ** the gcc extension that allows us to take the address of labels within
    ** the foreign_proc, so the context will resume back inside the
    ** foreign_proc.
    **
    ** XXX implement those procedures as :- external procedures so that the
    ** transforms won't be applied
    */
    #define ML_THREAD_AVOID_LABEL_ADDRS
  #endif
#endif

#line 225 "thread.m"

/*
INIT mercury_sys_init_thread_modules
*/

#ifndef MR_HIGHLEVEL_CODE
    MR_define_extern_entry(mercury__thread__spawn_begin_thread);
    MR_declare_label(mercury__thread__spawn_end_thread);
    MR_define_extern_entry(mercury__thread__yield_resume);
#endif

#line 322 "thread.m"

#if defined(MR_HIGHLEVEL_CODE) && defined(MR_THREAD_SAFE)
  #include  <pthread.h>

  int ML_create_thread(MR_Word goal);
  void *ML_thread_wrapper(void *arg);

  typedef struct ML_ThreadWrapperArgs ML_ThreadWrapperArgs;
  struct ML_ThreadWrapperArgs {
        MR_Word             goal;
        MR_ThreadLocalMuts  *thread_local_mutables;
  };
#endif /* MR_HIGHLEVEL_CODE && MR_THREAD_SAFE */

#endif




#line 401 "thread.m"
void MR_CALL 
mercury__thread__call_back_to_mercury_3_p_0(
#line 401 "thread.m"
  MR_Word mercury__thread__param_1);

#line 52 "thread.m"
void MR_CALL 
mercury__thread__yield_2_p_0(void);

#line 42 "thread.m"
void MR_CALL 
mercury__thread__spawn_3_p_0(
#line 42 "thread.m"
  MR_Word mercury__thread__param_1);

#line 35 "thread.m"
MR_bool MR_CALL 
mercury__thread__can_spawn_0_p_0(void);

void mercury__thread__init(void);
void mercury__thread__init_type_tables(void);
void mercury__thread__init_debugger(void);

#ifdef __cplusplus
}
#endif

#endif /* MR_HEADER_GUARD_thread */

/* :- end_interface thread. */
