1 /* 2 * (c) Copyright 1990-1996 OPEN SOFTWARE FOUNDATION, INC. 3 * (c) Copyright 1990-1996 HEWLETT-PACKARD COMPANY 4 * (c) Copyright 1990-1996 DIGITAL EQUIPMENT CORPORATION 5 * (c) Copyright 1991, 1992 Siemens-Nixdorf Information Systems 6 * To anyone who acknowledges that this file is provided "AS IS" without 7 * any express or implied warranty: permission to use, copy, modify, and 8 * distribute this file for any purpose is hereby granted without fee, 9 * provided that the above copyright notices and this notice appears in 10 * all source code copies, and that none of the names listed above be used 11 * in advertising or publicity pertaining to distribution of the software 12 * without specific, written prior permission. None of these organizations 13 * makes any representations about the suitability of this software for 14 * any purpose. 15 */ 16 /* 17 * Header file for CMA initialization 18 */ 19 20 #ifndef CMA_INIT 21 #define CMA_INIT 22 23 /* 24 * INCLUDE FILES 25 */ 26 #include <dce/cma_host.h> 27 #include <cma_errors.h> 28 29 /* 30 * CONSTANTS AND MACROS 31 */ 32 33 #define cma__c_env_maxattr 0 34 #define cma__c_env_minattr 1 35 #define cma__c_env_maxcond 2 36 #define cma__c_env_mincond 3 37 #define cma__c_env_maxmutex 4 38 #define cma__c_env_minmutex 5 39 #define cma__c_env_maxthread 6 40 #define cma__c_env_minthread 7 41 #define cma__c_env_maxcluster 8 42 #define cma__c_env_mincluster 9 43 #define cma__c_env_maxvp 10 44 #define cma__c_env_multiplex 11 45 #define cma__c_env_trace 12 46 #define cma__c_env_trace_file 13 47 48 #define cma__c_env_count 13 49 50 51 /* 52 * cma__int_init 53 * 54 * Initialize the main body of CMA exactly once. 55 * 56 * We raise an exception if, for some odd reason, there are already threads 57 * in the environment (e.g. kernel threads), and one of them is trying to 58 * initialize CMA before the first thread got all the way through the actual 59 * initialization. This code maintains the invariants: "after successfully 60 * calling CMA_INIT, you can call any CMA function", and "CMA is actually 61 * initialized at most once". 62 */ 63 /*#ifndef _HP_LIBC_R */ 64 65 #if defined _HP_LIBC_R ||(defined(SNI_SVR4) && !defined(CMA_INIT_NEEDED)) 66 # define cma__int_init() 67 #else 68 # define cma__int_init() { \ 69 if (!cma__tac_isset(&cma__g_init_started)) { \ 70 if (!cma__test_and_set (&cma__g_init_started)) { \ 71 cma__init_static (); \ 72 cma__test_and_set (&cma__g_init_done); \ 73 } \ 74 else if (!cma__tac_isset (&cma__g_init_done)) { \ 75 cma__error (cma_s_inialrpro); \ 76 }}} 77 #endif 78 79 /* 80 * TYPEDEFS 81 */ 82 83 typedef enum CMA__T_ENV_TYPE { 84 cma__c_env_type_int, 85 cma__c_env_type_file 86 } cma__t_env_type; 87 88 typedef struct CMA__T_ENV { 89 char *name; /* Name of environment variable */ 90 cma__t_env_type type; /* Type of variable */ 91 cma_t_integer value; /* Numeric value of the variable */ 92 } cma__t_env; 93 94 /* 95 * GLOBAL DATA 96 */ 97 98 extern cma__t_env cma__g_env[cma__c_env_count]; 99 extern cma__t_atomic_bit cma__g_init_started; 100 extern cma__t_atomic_bit cma__g_init_done; 101 extern char *cma__g_version; 102 103 /* 104 * INTERNAL INTERFACES 105 */ 106 107 extern void 108 cma__init_static (void); /* Initialize static data */ 109 110 #if _CMA_OS_ != _CMA__VMS 111 extern void cma__init_atfork (void); 112 #endif 113 114 #endif 115