smDllLib.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:5k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* smDllLib.h - shared memory doubly linked list library header */
  2. /* Copyright 1984-2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01e,06may02,mas  macros use volatile pointers (SPR 68334)
  7. 01d,29jan93,pme  added little endian support 
  8. 01c,22sep92,rrr  added support for c++
  9. 01b,27jul92,pme  changed structure declarations.
  10. 01a,19jul92,pme  written from dllLib
  11. */
  12. #ifndef __INCsmDllLibh
  13. #define __INCsmDllLibh
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /* typedefs */
  18. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  19. #pragma align 1                 /* tell gcc960 not to optimize alignments */
  20. #endif  /* CPU_FAMILY==I960 */
  21. typedef struct sm_dl_node /* Node of a shared linked list. */
  22.     {
  23.     struct sm_dl_node * next;  /* Points at the next node in list */
  24.     struct sm_dl_node * previous;/* Points at the previous node in list */
  25.     } SM_DL_NODE;
  26. /* HIDDEN */
  27. typedef struct sm_dl_list /* Header for a shared linked list. */
  28.     {
  29.     SM_DL_NODE * head; /* Header list node */
  30.     SM_DL_NODE * tail; /* Tail list node */
  31.     } SM_DL_LIST;
  32. /* END_HIDDEN */
  33. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  34. #pragma align 0                 /* turn off alignment requirement */
  35. #endif  /* CPU_FAMILY==I960 */
  36. /*******************************************************************************
  37. *
  38. * smDllFirst - find first node in shared memory list
  39. *
  40. * DESCRIPTION
  41. * Finds the first node in a doubly linked shared memory list.
  42. *
  43. * RETURNS
  44. *       Local address of the first node in a list, or
  45. *       LOC_NULL if the list is empty.
  46. *
  47. * NOMANUAL
  48. */
  49. #define SM_DL_FIRST(pList)                               
  50.     (                                                    
  51.     (GLOB_TO_LOC_ADRS (ntohl ((int)(((SM_DL_LIST volatile *)(pList))->head))))
  52.     )
  53. /*******************************************************************************
  54. *
  55. * smDllLast - find last node in shared memory list
  56. *
  57. * Finds the last node in a doubly linked shared memory list.
  58. *
  59. * RETURNS
  60. *       Local address pointer to the last node in list, or
  61. *       LOC_NULL if the list is empty.
  62. *
  63. * NOMANUAL
  64. */
  65. #define SM_DL_LAST(pList)                                
  66.     (                                                    
  67.     (GLOB_TO_LOC_ADRS (ntohl ((int)(((SM_DL_LIST volatile *)(pList))->tail))))
  68.     )
  69. /*******************************************************************************
  70. *
  71. * smDllNext - find next node in shared memory list
  72. *
  73. * Locates the node immediately after the node pointed to by the pNode.
  74. *
  75. * RETURNS:
  76. *       Local address pointer to the next node in the list, or
  77. *       LOC_NULL if there is no next node.
  78. *
  79. * NOMANUAL
  80. */
  81. #define SM_DL_NEXT(pNode)                                
  82.     (                                                    
  83.     (GLOB_TO_LOC_ADRS (ntohl ((int)(((SM_DL_NODE volatile *)(pNode))->next))))
  84.     )
  85. /*******************************************************************************
  86. *
  87. * smDllPrevious - find previous node in shared memory doubly linked list
  88. *
  89. * Locates the node immediately before the node pointed to by the pNode.
  90. *
  91. * RETURNS:
  92. *       Local address pointer to the preceding node in the list, or
  93. *       LOC_NULL if there is no next node.
  94. *
  95. * NOMANUAL
  96. */
  97. #define SM_DL_PREVIOUS(pNode)                                        
  98.     (                                                                
  99.     (GLOB_TO_LOC_ADRS (ntohl ((int)                                           
  100.                                ((SM_DL_NODE volatile *) (pNode))->previous))))
  101.     )
  102. /*******************************************************************************
  103. *
  104. * smDllEmpty - boolean function to check for empty shared memory list
  105. *
  106. * RETURNS:
  107. *       TRUE if list is empty
  108. *       FALSE otherwise
  109. *
  110. * NOMANUAL
  111. */
  112. #define SM_DL_EMPTY(pList)                         
  113.     (                                              
  114.     (((SM_DL_LIST volatile *)pList)->head == NULL) 
  115.     )
  116. /* function declarations */
  117. #if defined(__STDC__) || defined(__cplusplus)
  118. extern SM_DL_LIST * smDllCreate (void);
  119. extern SM_DL_NODE * smDllEach (SM_DL_LIST * pList, FUNCPTR routine,
  120.        int routineArg);
  121. extern SM_DL_NODE * smDllGet (SM_DL_LIST * pList);
  122. extern STATUS       smDllDelete (SM_DL_LIST * pList);
  123. extern STATUS       smDllInit (SM_DL_LIST * pList);
  124. extern STATUS       smDllTerminate (SM_DL_LIST * pList);
  125. extern int          smDllCount (SM_DL_LIST * pList);
  126. extern void         smDllAdd (SM_DL_LIST * pList, SM_DL_NODE * pNode);
  127. extern void         smDllInsert (SM_DL_LIST * pList, SM_DL_NODE * pPrev,
  128.  SM_DL_NODE * pNode);
  129. extern void         smDllRemove (SM_DL_LIST * pList, SM_DL_NODE * pNode);
  130. extern void         smDllConcat (SM_DL_LIST * pDstList, SM_DL_LIST * pAddList);
  131. #else /* __STDC__ */
  132. extern SM_DL_LIST * smDllCreate ();
  133. extern SM_DL_NODE * smDllEach ();
  134. extern SM_DL_NODE * smDllGet ();
  135. extern STATUS       smDllDelete ();
  136. extern STATUS       smDllInit ();
  137. extern STATUS       smDllTerminate ();
  138. extern int          smDllCount ();
  139. extern void         smDllAdd ();
  140. extern void         smDllInsert ();
  141. extern void         smDllRemove ();
  142. extern void         smDllConcat ();
  143. #endif /* __STDC__ */
  144. #ifdef __cplusplus
  145. }
  146. #endif
  147. #endif /* __INCsmDllLibh */