/********************************************************************************************************************************/ /* Created 2-MAR-1994 10:03:17 by VAX SDL V3.2-12 Source: 2-MAR-1994 10:03:08 CMAPRIVATE_ROOT:[WORK.CORE.VMS]CMA$DEF.SDL;7 */ /********************************************************************************************************************************/ /*** MODULE CMA$DEF IDENT V1.10-031 ***/ /* */ /* Copyright 2000 Compaq Computer Corporation */ /* */ /* Compaq and the Compaq logo Registered in U.S. Patent and Trademark */ /* Office. */ /* */ /* Confidential computer software. Valid license from Compaq required */ /* for possession, use or copying. Consistent with FAR 12.211 and 12.212, */ /* Commercial Computer Software, Computer Software Documentation, and */ /* Technical Data for Commercial Items are licensed to the U.S. Government */ /* under vendor's standard commercial license. */ /* */ /* */ /* FACILITY: */ /* */ /* Common Multithread Architecture (CMA) services */ /* */ /* ABSTRACT: */ /* */ /* External definitions for CMA services */ /* */ /* AUTHORS: */ /* */ /* Dave Butenhof (-Original) */ /* Paul Curtin (-Generic/SDL) */ /* */ /* CREATION DATE: */ /* */ /* 2 November 1988 (-Original) */ /* 7 September 1990 (-Generic/SDL) */ /* */ /* MODIFIED BY: */ /* */ /* Dave Butenhof */ /* Paul Curtin */ /* Gerald Feldman */ /* Webb Scales */ /* */ #ifndef CMA_DEF_INCLUDE #define CMA_DEF_INCLUDE #pragma __nostandard #ifdef __cplusplus extern "C" { #endif /* */ /* Define a symbol which client code can test to determine whether the */ /* underlying threads package is DECthreads or not. This is especially */ /* important to clients of the Pthreads interface who may want to use */ /* certain DECthreads extensions, such as the global lock and non-real-time */ /* scheduling policies, on the DECthreads platform while maintaining */ /* portability to a "vanilla" pthreads implementation. */ /* */ #define _DECTHREADS_ 1 #if defined(vms) || defined(__vms) || defined (VMS) || defined(__VMS) || defined(__vms__) # if defined (__decc) || defined (__DECC) || (defined (__cplusplus) && defined (__DECCXX)) # pragma __extern_model __save # pragma __extern_model __strict_refdef # endif # include /* configuration symbols */ #else # include /* configuration symbols */ #endif /* * The implementation makes these basic decisions */ #if _CMA_OS_ != _CMA__VMS # include # include #endif /* * For the VMS cma$ interface, suppress the EXC_ exceptions */ #if !defined(_EXC_NO_EXCEPTIONS_) #define _EXC_NO_EXCEPTIONS_ #endif #if _CMA_OS_ == _CMA__VMS # include /* Bring in exception services */ #else # include /* Bring in exception services */ #endif #if (_CMA_OSIMPL_ == _CMA__OS_OSF) && _CMA_REENTRANT_CLIB_ # define _REENTRANT 1 /* Enable reentrant errno.h */ #endif #ifdef _CMA_PROTO_ # define _CMA_PROTOTYPE_(arg) arg #else # define _CMA_PROTOTYPE_(arg) () #endif typedef long int cma$t_integer; typedef unsigned long int cma$t_boolean; typedef unsigned long int cma$t_natural; typedef float cma$t_interval; typedef long int cma$t_key; typedef long int cma$t_status; typedef long int cma$t_priority; #if _CMA_VOID_ typedef void *cma$t_address; #else typedef char *cma$t_address; #endif #define cma$c_prio_fifo_min 16 #define cma$c_prio_fifo_mid 24 #define cma$c_prio_fifo_max 31 #define cma$c_prio_rr_min 16 #define cma$c_prio_rr_mid 24 #define cma$c_prio_rr_max 31 #define cma$c_prio_through_min 8 #define cma$c_prio_through_mid 12 #define cma$c_prio_through_max 15 #define cma$c_prio_back_min 0 #define cma$c_prio_back_mid 4 #define cma$c_prio_back_max 7 #define cma$c_prio_ada_low_min 0 #define cma$c_prio_ada_low_mid 4 #define cma$c_prio_ada_low_max 7 #define cma$c_prio_ada_rtb_min 0 #define cma$c_prio_ada_rtb_mid 4 #define cma$c_prio_ada_rtb_max 7 /* */ /* The implementation of the date_time type should match the "native */ /* time" of the platform: that allows clients to use the full set of platform */ /* time operations, rather than just "get_expiration", to compute and */ /* test timed waits. */ /* */ /* This section assumes the platform is either "VMS" or "UNIX-ish". Others */ /* will require changes. */ /* */ #if _CMA_OS_ == _CMA__VMS typedef struct _cma$t_date_time { unsigned long int low; unsigned long int high; } cma$t_date_time; #else typedef struct timeval cma$t_date_time; #endif /* */ /* Sample decisions for what handles shall be */ /* */ typedef struct _cma$t_handle { cma$t_address handle_field1; short int handle_field2; short int handle_field3; } cma$t_handle; #define cma$c_handle_size 8 #if (_CMA_COMPILER_ == _CMA__CFRONT) && (_CMA_OS_ == _CMA__VMS) /* * The following declaration is a hack to support CFRONT (C++ preprocessor); * without an actual instance, the struct definition isn't written out. * Creates problems for VAX C when it compiles CFRONT output. */ static struct CMA_T_HANDLE cxxl_unused_handle; #endif #define cma$thread_get_unique(handle) \ (((unsigned int)((cma$t_thread *)handle)->handle_field2)) /* */ /* Sample decision for a one-time initialization control block and its */ /* initialization macro. */ /* */ /* */ typedef struct _cma$t_once { cma$t_integer once_field1; cma$t_integer once_field2; cma$t_integer once_field3; } cma$t_once; /* */ /* Sample decision for a variable to save the current alert state. */ /* */ typedef struct _cma$t_alert_state { cma$t_integer state1; cma$t_integer state2; } cma$t_alert_state; /* */ /* The following are the portable CMA definitions */ /* */ /* */ /* Operations on threads */ /* */ typedef cma$t_address (*cma$t_start_routine)(); /* */ /* Constants */ /* */ #define cma$c_false 0 #define cma$c_true 1 #define cma$c_null_ptr 0 /* */ /* Objects */ /* */ typedef cma$t_handle cma$t_mutex; /* Needed for ONCE_BLOCK */ typedef cma$t_handle cma$t_attr; typedef cma$t_handle cma$t_thread; typedef cma$t_handle cma$t_cond; typedef cma$t_handle cma$t_stack_np; /* */ /* Predefined null handle */ /* */ _CMA_IMPORT_ cma$t_handle cma$c_null; /* * Declare a one time initialization control block. * * static cma$t_once block = cma$once_init; */ #define cma$once_init {0, 0, 0} /* * Exit status constants */ typedef enum _CMA$T_EXIT_STATUS { cma$c_null_thread = -1, cma$c_term_error = 0, cma$c_term_normal = 1, cma$c_term_alert = 2 } cma$t_exit_status; /* * Schedule inheritance constants */ typedef enum _CMA$T_SCHED_INHERIT { cma$c_sched_inherit = 0, cma$c_sched_use_default = 1 } cma$t_sched_inherit; /* * Schedule policy constants */ typedef enum _CMA$T_SCHED_POLICY { cma$c_sched_fifo = 0, cma$c_sched_rr = 1, cma$c_sched_throughput = 2, cma$c_sched_background = 3, cma$c_sched_ada_low = 4, cma$c_sched_idle = 5 } cma$t_sched_policy; /* * cma$c_sched_default and cma$c_sched_other definitions */ #define cma$c_sched_default cma$c_sched_throughput #define cma$c_sched_other cma$c_sched_default /* * Mutex types */ typedef enum _CMA$T_MUTEX_KIND { cma$c_mutex_fast = 0, cma$c_mutex_recursive = 1, cma$c_mutex_nonrecursive = 2 } cma$t_mutex_kind; /* */ /* Sample decision for error codes */ /* */ /* Values used are "VMS status codes" in decimal. These */ /* must remain in synch with the "message file" MESSAGE_VMS.MSG */ /* Note: these values cannot be altered after they have shipped in */ /* some CMA release. Octal boundaries are shown on the decimal */ /* values. GAF 6/1/92 Coordinated definitions with exc_handling.h */ /* */ #define cma$_exception 4227084 #define cma$_exccop 4227092 #define cma$_uninitexc 4227100 #define cma$_unkstatus 4228100 #define cma$_exccoplos 4228108 #define cma$_illaddr 12 #define cma$_exquota 28 #define cma$_insfmem 292 #define cma$_nopriv 36 #define cma$_normal 1 #define cma$_illinstr 1084 #define cma$_resaddr 1100 #define cma$_privinst 1084 #define cma$_resoper 1108 #define cma$_SIGTRAP 1044 #define cma$_SIGIOT 44 #define cma$_SIGEMT 1068 #define cma$_aritherr 1164 #define cma$_SIGSYS 20 #define cma$_SIGPIPE 628 #define cma$_excpu 8364 #define cma$_exfilsiz 1004 #define cma$_intovf 1148 #define cma$_intdiv 1156 #define cma$_fltovf 1164 #define cma$_fltdiv 1172 #define cma$_fltund 1180 #define cma$_decovf 1188 #define cma$_subrng 1196 #define cma$_accvio 12 #define cma$_SIGILL 1084 #define cma$_SIGFPE 1164 #define cma$_SIGBUS 1084 #define cma$_SIGSEGV 1084 #define cma$_SIGXCPU 8364 #define cma$_SIGXFSZ 1004 #define cma$_alerted 4227460 #define cma$_assertion 4227468 #define cma$_badparam 4227476 #define cma$_bugcheck 4227484 #define cma$_exit_thread 4227492 #define cma$_existence 4227500 #define cma$_in_use 4227508 #define cma$_use_error 4227516 #define cma$_wrongmutex 4227524 #define cma$_stackovf 4227532 #define cma$_nostackmem 4227540 #define cma$_notcmastack 4227548 #define cma$_timed_out 4227556 #define cma$_unimp 4227564 #define cma$_inialrpro 4227572 #define cma$_defer_q_full 4227580 #define cma$_signal_q_full 4227588 #define cma$_alert_nesting 4227596 /* */ /* EXCEPTION TYPE DEFINITIONS */ /* */ typedef char *cma$exc_address_t; typedef long int cma$exc_kind_t; typedef long int cma$exc_int_t; /* */ /* Internal contents of an exception object. */ /* */ typedef struct _cma$t_exception { cma$exc_kind_t exc_kind; cma$exc_address_t exc_info; cma$exc_address_t exc_filler [6]; } cma$t_exception; _CMA_IMPORT_ cma$t_exception cma$e_uninitexc; _CMA_IMPORT_ cma$t_exception cma$e_illaddr; _CMA_IMPORT_ cma$t_exception cma$e_exquota; _CMA_IMPORT_ cma$t_exception cma$e_insfmem; _CMA_IMPORT_ cma$t_exception cma$e_nopriv; _CMA_IMPORT_ cma$t_exception cma$e_illinstr; _CMA_IMPORT_ cma$t_exception cma$e_resaddr; _CMA_IMPORT_ cma$t_exception cma$e_privinst; _CMA_IMPORT_ cma$t_exception cma$e_resoper; _CMA_IMPORT_ cma$t_exception cma$e_SIGTRAP; _CMA_IMPORT_ cma$t_exception cma$e_SIGIOT; _CMA_IMPORT_ cma$t_exception cma$e_SIGEMT; _CMA_IMPORT_ cma$t_exception cma$e_aritherr; _CMA_IMPORT_ cma$t_exception cma$e_SIGSYS; _CMA_IMPORT_ cma$t_exception cma$e_SIGPIPE; _CMA_IMPORT_ cma$t_exception cma$e_excpu; _CMA_IMPORT_ cma$t_exception cma$e_exfilsiz; _CMA_IMPORT_ cma$t_exception cma$e_intovf; _CMA_IMPORT_ cma$t_exception cma$e_intdiv; _CMA_IMPORT_ cma$t_exception cma$e_fltovf; _CMA_IMPORT_ cma$t_exception cma$e_fltdiv; _CMA_IMPORT_ cma$t_exception cma$e_fltund; _CMA_IMPORT_ cma$t_exception cma$e_decovf; _CMA_IMPORT_ cma$t_exception cma$e_subrng; _CMA_IMPORT_ cma$t_exception cma$e_alerted; _CMA_IMPORT_ cma$t_exception cma$e_assertion; _CMA_IMPORT_ cma$t_exception cma$e_badparam; _CMA_IMPORT_ cma$t_exception cma$e_bugcheck; _CMA_IMPORT_ cma$t_exception cma$e_exit_thread; _CMA_IMPORT_ cma$t_exception cma$e_existence; _CMA_IMPORT_ cma$t_exception cma$e_in_use; _CMA_IMPORT_ cma$t_exception cma$e_use_error; _CMA_IMPORT_ cma$t_exception cma$e_wrongmutex; _CMA_IMPORT_ cma$t_exception cma$e_stackovf; _CMA_IMPORT_ cma$t_exception cma$e_nostackmem; _CMA_IMPORT_ cma$t_exception cma$e_notcmastack; _CMA_IMPORT_ cma$t_exception cma$e_unimp; _CMA_IMPORT_ cma$t_exception cma$e_inialrpro; _CMA_IMPORT_ cma$t_exception cma$e_defer_q_full; _CMA_IMPORT_ cma$t_exception cma$e_signal_q_full; _CMA_IMPORT_ cma$t_exception cma$e_alert_nesting; /* */ /* Operations on Handles */ /* */ /* */ /* The value of a handle can be assigned the value of another handle. */ /* */ void cma$handle_assign() ; /* */ /* The value of a handle can be assigned the value of another handle. */ /* */ cma$t_boolean cma$handle_equal() ; /* */ /* An attributes object is created to specify the attributes of other CMA */ /* objects that will be created. */ /* */ void cma$attr_create() ; /* */ /* An attributes object can be deleted when it is no longer needed. */ /* */ void cma$attr_delete() ; /* */ /* The following procedures can be used to control thread creation, */ /* termination and deletion. */ /* */ /* */ /* To create a thread object and runnable thread, a routine must be specified */ /* as the new thread's start routine. An argument may be passed to this */ /* routine, as an untyped address; an untyped address may also be returned as */ /* the routine's value. An attributes object may be used to specify details */ /* about the kind of thread being created. */ /* */ void cma$thread_create() ; /* */ /* A thread object may be "detached" to specify that the return value and */ /* completion status will not be requested. */ /* */ void cma$thread_detach() ; /* */ /* A thread may terminate it's own execution. */ /* */ void cma$thread_exit_error() ; /* */ /* Exit a thread normally. */ /* */ void cma$thread_exit_normal() ; /* */ /* A thread can await termination of another thread and retrieve the return */ /* value and completion status of the thread. */ /* */ void cma$thread_join() ; /* */ /* Operations to define thread creation attributes */ /* */ /* */ /* Set or obtain the default thread priority. */ /* */ void cma$attr_set_priority() ; /* */ /* Obtain thread priority from attributes object. */ /* */ void cma$attr_get_priority() ; /* */ /* Set or obtain the default scheduling algorithm. */ /* */ void cma$attr_set_sched() ; /* */ /* Get thread scheduling algorithm from attributes object. */ /* */ void cma$attr_get_sched() ; /* */ /* Set or obtain whether a thread will use the default scheduling attributes, */ /* or inherit them from the creating thread. */ /* */ void cma$attr_set_inherit_sched() ; /* */ /* Obtain default scheduling attributes. */ /* */ void cma$attr_get_inherit_sched() ; /* */ /* Set the default stack size */ /* */ void cma$attr_set_stacksize() ; /* */ /* Obtain the default stack size. */ /* */ void cma$attr_get_stacksize() ; /* */ /* Set the default guard size */ /* */ void cma$attr_set_guardsize() ; /* */ /* Obtain the default guard size */ /* */ void cma$attr_get_guardsize() ; /* */ /* Thread Scheduling Operations */ /* */ /* */ /* The current user_assigned priority of a thread can be changed. */ /* */ void cma$thread_set_priority() ; /* */ /* The current user_assigned scheduler algorithm of a thread can be changed. */ /* */ void cma$thread_set_sched() ; /* */ /* A thread may tell the scheduler that its processor can be made available. */ /* */ void cma$yield() ; /* */ /* A thread may enter a wait state for a specifed period of time. */ /* */ void cma$delay() ; /* */ /* Thread Information Operations */ /* */ /* */ /* A thread may obtain a copy of its own thread handle. */ /* */ void cma$thread_get_self() ; /* */ /* The current user_assigned priority of a thread can be read. */ /* */ void cma$thread_get_priority() ; /* */ /* The current user_assigned scheduler algorithm of a thread can be read. */ /* */ void cma$thread_get_sched() ; /* */ /* Operations on Mutexes */ /* */ /* */ /* Set whether mutex locks can nest. */ /* */ void cma$attr_set_mutex_kind() ; /* */ /* Obtain whether mutex locks can nest. */ /* */ void cma$attr_get_mutex_kind() ; /* */ /* The following routines create, delete, lock and unlock mutexes. */ /* */ void cma$mutex_create() ; /* */ /* Delete a mutex. */ /* */ void cma$mutex_delete() ; /* */ /* Lock a mutex. */ /* */ void cma$mutex_lock() ; /* */ /* Try to lock a mutex. */ /* */ cma$t_boolean cma$mutex_try_lock() ; /* */ /* Unlock a mutex. */ /* */ void cma$mutex_unlock() ; /* */ /* Lock Global mutex. */ /* */ void cma$lock_global() ; /* */ /* Unlock Global mutex. */ /* */ void cma$unlock_global() ; /* */ /* A thread can create and delete condition variables. */ /* */ void cma$cond_create() ; /* */ /* Delete a condition variable. */ /* */ void cma$cond_delete() ; /* */ /* A thread can signal to and broadcast on a condition variable. */ /* */ void cma$cond_broadcast() ; /* */ /* Signal a condition variable. */ /* */ void cma$cond_signal() ; /* */ /* Interupt signal a condition variable. */ /* */ void cma$cond_signal_int() ; /* */ /* A thread can wait for a condition variable to be signalled or broadcast. */ /* */ void cma$cond_wait() ; /* */ /* Operations for timed waiting */ /* */ /* */ /* A thread can perform a timed wait on a condition variable. */ /* */ cma$t_status cma$cond_timed_wait() ; /* */ /* A thread may perform some operations on absolute date-time and intervals. */ /* */ void cma$time_get_expiration() ; /* */ /* Operations for CMA and client initialization. */ /* */ /* */ /* Initialize the CMA facility. */ /* */ void cma$init() ; /* */ /* A thread can declare a one-time initialization routine. The address of */ /* the init block and routine are passed as parameters. */ /* */ typedef void (*cma$t_init_routine)(); /* */ /* Once routine */ /* */ void cma$once() ; /* */ /* Operations for per-thread context */ /* */ typedef void (*cma$t_destructor)(); /* */ /* A unique per-thread context key can be obtained for the process */ /* */ void cma$key_create() ; /* */ /* A thread can set a per-thread context value identified by a key. */ /* */ void cma$key_set_context() ; /* */ /* A thread can retrieve a per-thread context value identified by a key. */ /* */ void cma$key_get_context() ; /* */ /* Operations for alerts. */ /* */ /* */ /* The current thread can request that a thread terminate it's execution. */ /* */ void cma$thread_alert() ; /* */ /* The current thread can poll for alert delivery. */ /* */ void cma$alert_test() ; /* */ /* Control alert delivery state. */ /* */ void cma$alert_disable_asynch() ; void cma$alert_disable_general() ; void cma$alert_enable_asynch() ; void cma$alert_enable_general() ; void cma$alert_restore() ; /* */ /* Operations on stacks */ /* */ typedef void (*cma$t_call_routine)(); /* */ /* Assign a stack to a thread */ /* */ void cma$stack_assign_np() ; /* */ /* Call a routine on a new stack */ /* */ void cma$stack_call_routine_np() ; /* */ /* Check stack limit */ /* */ cma$t_boolean cma$stack_check_limit_np() ; /* */ /* Create a new stack */ /* */ void cma$stack_create_np() ; /* */ /* Delete a stack */ /* */ void cma$stack_delete_np() ; /* */ /* CMA Debug entry point */ /* */ void cma$debug() ; cma$t_integer cma$sigwait() ; /************************************************************************** */ /* */ /* The following are the portable CMA High-Level Library definitions */ /* */ /************************************************************************** */ /* */ /* Operations on attributes objects */ /* */ typedef cma$t_handle cma$lib_t_attr; /* */ /* An attributes object is created to specify the attributes of other CMA */ /* objects that will be created. */ /* */ void cma$lib_attr_create() ; /* */ /* An attributes object can be deleted when it is no longer needed. */ /* */ void cma$lib_attr_delete() ; /* */ /* Operations on queues */ /* */ typedef cma$t_handle cma$lib_t_queue; void cma$lib_queue_create() ; void cma$lib_queue_delete() ; void cma$lib_queue_dequeue() ; void cma$lib_queue_enqueue() ; cma$t_boolean cma$lib_queue_try_enqueue_int() ; void cma$lib_queue_requeue() ; cma$t_boolean cma$lib_queue_try_dequeue() ; cma$t_boolean cma$lib_queue_try_enqueue() ; cma$t_boolean cma$lib_queue_try_requeue() ; /* */ /* Set or obtain the default queue size */ /* */ void cma$lib_attr_get_queuesize() ; void cma$lib_attr_set_queuesize() ; #define sigaction cma$sigaction #if defined(vms) || defined(__vms) || defined (VMS) || defined(__VMS) || defined(__vms__) # if defined (__decc) || defined (__DECC) || (defined (__cplusplus) && defined (__DECCXX)) # pragma __extern_model __restore /* saved before including cma_config.h */ # endif #endif #pragma __standard /* set at top of this file */ #ifdef __cplusplus } #endif #endif