PageRenderTime 68ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/gdb/osf-share/cma_attr.h

https://github.com/rofl0r/gdb
C Header | 344 lines | 106 code | 20 blank | 218 comment | 2 complexity | 09c00dd64d8863a53eb3dc7b2b891e51 MD5 | raw file
  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 attributes object
  18. */
  19. #ifndef CMA_ATTR
  20. #define CMA_ATTR
  21. /*
  22. * INCLUDE FILES
  23. */
  24. #include <cma_defs.h>
  25. #include <cma_queue.h>
  26. #ifdef __hpux
  27. # include <sys/param.h>
  28. #endif
  29. #if _CMA_UNIX_TYPE == _CMA__SVR4
  30. #include <sys/unistd.h>
  31. #endif
  32. /*
  33. * CONSTANTS AND MACROS
  34. */
  35. /*
  36. * FUNCTIONAL DESCRIPTION:
  37. *
  38. * cma__int_attr_get_priority - Performs the work of
  39. * cma_attr_get_priority
  40. *
  41. * FORMAL PARAMETERS:
  42. *
  43. * cma_t_attr *_att_ - Attribute object to get from
  44. * cma_t_priority *_setting_ - Current setting
  45. *
  46. * IMPLICIT INPUTS:
  47. *
  48. * none
  49. *
  50. * IMPLICIT OUTPUTS:
  51. *
  52. * priority
  53. *
  54. * FUNCTION VALUE:
  55. *
  56. * none
  57. *
  58. * SIDE EFFECTS:
  59. *
  60. * none
  61. */
  62. #define cma__int_attr_get_priority(_att_,_setting_) { \
  63. cma__t_int_attr *_int_att_; \
  64. (_int_att_) = cma__validate_default_attr (_att_); \
  65. cma__int_lock ((_int_att_)->mutex); \
  66. (*(_setting_)) = (_int_att_)->priority; \
  67. cma__int_unlock ((_int_att_)->mutex); \
  68. }
  69. /*
  70. * FUNCTIONAL DESCRIPTION:
  71. *
  72. * cma__int_attr_get_sched - Performs work of cma_attr_get_sched
  73. *
  74. * FORMAL PARAMETERS:
  75. *
  76. * cma_t_attr *_att_ _ Attributes object used
  77. * cma_t_sched_policy *_setting_ - Current setting
  78. *
  79. * IMPLICIT INPUTS:
  80. *
  81. * none
  82. *
  83. * IMPLICIT OUTPUTS:
  84. *
  85. * scheduling policy
  86. *
  87. * FUNCTION VALUE:
  88. *
  89. * none
  90. *
  91. * SIDE EFFECTS:
  92. *
  93. * none
  94. */
  95. #define cma__int_attr_get_sched(_att_,_setting_) { \
  96. cma__t_int_attr *_int_att_; \
  97. (_int_att_) = cma__validate_default_attr (_att_); \
  98. cma__int_lock ((_int_att_)->mutex); \
  99. (*(_setting_)) = (_int_att_)->policy; \
  100. cma__int_unlock ((_int_att_)->mutex); \
  101. }
  102. /*
  103. * FUNCTIONAL DESCRIPTION:
  104. *
  105. * cma__int_attr_get_inherit_sched - Performs work of
  106. * cma_attr_get_inherit_sched
  107. *
  108. * FORMAL PARAMETERS:
  109. *
  110. * cma_t_attr *_att_ - Attributes object to use
  111. * cma_t_sched_inherit *_setting_ - Current setting
  112. *
  113. * IMPLICIT INPUTS:
  114. *
  115. * none
  116. *
  117. * IMPLICIT OUTPUTS:
  118. *
  119. * Inheritable scheduling policy
  120. *
  121. * FUNCTION VALUE:
  122. *
  123. * none
  124. *
  125. * SIDE EFFECTS:
  126. *
  127. * none
  128. */
  129. #define cma__int_attr_get_inherit_sched(_att_,_setting_) { \
  130. cma__t_int_attr *_int_att_; \
  131. (_int_att_) = cma__validate_default_attr (_att_); \
  132. cma__int_lock ((_int_att_)->mutex); \
  133. (*(_setting_)) \
  134. = ((_int_att_)->inherit_sched \
  135. ? cma_c_sched_inherit : cma_c_sched_use_default); \
  136. cma__int_unlock ((_int_att_)->mutex); \
  137. }
  138. /*
  139. * FUNCTIONAL DESCRIPTION:
  140. *
  141. * cma__int_attr_set_stacksize - Performs work for cma_attr_set_stacksize
  142. *
  143. * FORMAL PARAMETERS:
  144. *
  145. * cma_t_attr *_att_ - Attributes object to use
  146. * cma_t_natural _setting_ - Setting
  147. *
  148. * IMPLICIT INPUTS:
  149. *
  150. * none
  151. *
  152. * IMPLICIT OUTPUTS:
  153. *
  154. * none
  155. *
  156. * FUNCTION VALUE:
  157. *
  158. * none
  159. *
  160. * SIDE EFFECTS:
  161. *
  162. * Change attribute objects stack size setting
  163. */
  164. #define cma__int_attr_set_stacksize(_att_,_setting_) { \
  165. cma__t_int_attr *_int_att_; \
  166. if ((_setting_) <= 0) \
  167. cma__error (cma_s_badparam); \
  168. _int_att_ = cma__validate_attr (_att_); \
  169. cma__int_lock ((_int_att_)->mutex); \
  170. _int_att_->stack_size = cma__roundup_chunksize(_setting_); \
  171. cma__free_cache (_int_att_, cma__c_obj_tcb); \
  172. _int_att_->cache[cma__c_obj_tcb].revision++; \
  173. _int_att_->cache[cma__c_obj_stack].revision++; \
  174. cma__int_unlock (_int_att_->mutex); \
  175. }
  176. /*
  177. * FUNCTIONAL DESCRIPTION:
  178. *
  179. * cma__int_attr_get_stacksize - Performs work of cma_attr_get_stacksize
  180. *
  181. * FORMAL PARAMETERS:
  182. *
  183. * cma_t_attr *_att_ - Attributes object to use
  184. * cma_t_natural *_setting_ - Current setting
  185. *
  186. * IMPLICIT INPUTS:
  187. *
  188. * none
  189. *
  190. * IMPLICIT OUTPUTS:
  191. *
  192. * Attribute objects stack size setting
  193. *
  194. * FUNCTION VALUE:
  195. *
  196. * none
  197. *
  198. * SIDE EFFECTS:
  199. *
  200. * none
  201. */
  202. #define cma__int_attr_get_stacksize(_att_,_setting_) { \
  203. cma__t_int_attr *_int_att_; \
  204. (_int_att_) = cma__validate_default_attr (_att_); \
  205. cma__int_lock ((_int_att_)->mutex); \
  206. (*(_setting_)) = (_int_att_)->stack_size; \
  207. cma__int_unlock ((_int_att_)->mutex); \
  208. }
  209. /*
  210. * FUNCTIONAL DESCRIPTION:
  211. *
  212. * cma__int_attr_set_guardsize - Performs work for cma_attr_set_guardsize
  213. *
  214. * FORMAL PARAMETERS:
  215. *
  216. * cma_t_attr *_att_ - Attributes object to use
  217. * cma_t_natural _setting_ - Setting
  218. *
  219. * IMPLICIT INPUTS:
  220. *
  221. * none
  222. *
  223. * IMPLICIT OUTPUTS:
  224. *
  225. * none
  226. *
  227. * FUNCTION VALUE:
  228. *
  229. * none
  230. *
  231. * SIDE EFFECTS:
  232. *
  233. * Change attribute objects guard size setting
  234. */
  235. #define cma__int_attr_set_guardsize(_att_,_setting_) { \
  236. cma__t_int_attr *_int_att_; \
  237. _int_att_ = cma__validate_attr (_att_); \
  238. cma__int_lock ((_int_att_)->mutex); \
  239. _int_att_->guard_size = cma__roundup_chunksize(_setting_); \
  240. cma__free_cache (_int_att_, cma__c_obj_tcb); \
  241. _int_att_->cache[cma__c_obj_tcb].revision++; \
  242. _int_att_->cache[cma__c_obj_stack].revision++; \
  243. cma__int_unlock (_int_att_->mutex); \
  244. }
  245. /*
  246. * FUNCTIONAL DESCRIPTION:
  247. *
  248. * cma__int_attr_get_guardsize - Performs work of cma_attr_get_guardsize
  249. *
  250. * FORMAL PARAMETERS:
  251. *
  252. * cma_t_attr *_att_ - Attributes object to use
  253. * cma_t_natural *_setting_ - Current setting
  254. *
  255. * IMPLICIT INPUTS:
  256. *
  257. * none
  258. *
  259. * IMPLICIT OUTPUTS:
  260. *
  261. * Attribute objects guard size setting
  262. *
  263. * FUNCTION VALUE:
  264. *
  265. * none
  266. *
  267. * SIDE EFFECTS:
  268. *
  269. * none
  270. */
  271. #define cma__int_attr_get_guardsize(_att_,_setting_) { \
  272. cma__t_int_attr *_int_att_; \
  273. (_int_att_) = cma__validate_default_attr (_att_); \
  274. cma__int_lock ((_int_att_)->mutex); \
  275. (*(_setting_)) = (_int_att_)->guard_size; \
  276. cma__int_unlock ((_int_att_)->mutex); \
  277. }
  278. /*
  279. * TYPEDEFS
  280. */
  281. #ifndef __STDC__
  282. struct CMA__T_INT_MUTEX; /* Avoid circular dependency */
  283. #endif
  284. typedef struct CMA__T_CACHE {
  285. cma_t_natural revision; /* Revisions */
  286. cma_t_natural count;
  287. cma__t_queue queue; /* Cache headers */
  288. } cma__t_cache;
  289. typedef struct CMA__T_INT_ATTR {
  290. cma__t_object header; /* Common header */
  291. struct CMA__T_INT_ATTR *attributes; /* Point to controlling attr */
  292. struct CMA__T_INT_MUTEX *mutex; /* Serialize access to
  293. object */
  294. cma_t_priority priority; /* Priority of new thread */
  295. cma_t_sched_policy policy; /* Sched policy of thread */
  296. cma_t_boolean inherit_sched; /* Is scheduling inherited? */
  297. cma_t_natural stack_size; /* Size of stack (bytes) */
  298. cma_t_natural guard_size; /* Size of guard (bytes) */
  299. cma_t_mutex_kind mutex_kind; /* Mutex kind */
  300. cma__t_cache cache[cma__c_obj_num]; /* Cache information */
  301. cma_t_boolean delete_pending; /* attr. obj. is deleted */
  302. cma_t_natural refcnt; /* Number of objects using attr. obj */
  303. } cma__t_int_attr;
  304. /*
  305. * GLOBAL DATA
  306. */
  307. extern cma__t_int_attr cma__g_def_attr;
  308. /*
  309. * INTERNAL INTERFACES
  310. */
  311. extern void cma__destroy_attributes (cma__t_int_attr *);
  312. extern void cma__free_attributes (cma__t_int_attr *);
  313. extern void cma__free_cache (cma__t_int_attr *,cma_t_natural );
  314. extern cma__t_int_attr *cma__get_attributes (cma__t_int_attr *);
  315. extern void cma__init_attr (void);
  316. extern void cma__reinit_attr (cma_t_integer);
  317. #endif