1 /*****************************************************************************
2   FILE           : $Source: /projects/higgs1/SNNS/CVS/SNNS/kernel/sources/kr_mac.h,v $
3   SHORTNAME      :
4   SNNS VERSION   : 4.2
5 
6   PURPOSE        : SNNS-Kernel Macros
7   NOTES          :
8 
9   AUTHOR         : Niels Mache
10   DATE           : 09.12.91
11 
12   CHANGED BY     : Michael Vogt
13   RCS VERSION    : $Revision: 2.7 $
14   LAST CHANGE    : $Date: 1998/02/25 15:26:50 $
15 
16     Copyright (c) 1990-1995  SNNS Group, IPVR, Univ. Stuttgart, FRG
17     Copyright (c) 1996-1998  SNNS Group, WSI, Univ. Tuebingen, FRG
18 
19 ******************************************************************************/
20 /*  Macro Definitions  */
21 #ifndef numeric
22 #define numeric(c)	       (c >= '0' && c <= '9')
23 #endif
24 #ifndef Max
25 #define Max(a,b)	       (a<b ? b : a)
26 #endif
27 #ifndef Min
28 #define Min(a,b)	       (a>b ? b : a)
29 #endif
30 #ifndef abs
31 #define abs(x)		       (x>=0 ? x : -(x))
32 #endif
33 
34 
35 /*  Macros for stepping thru the unit array and the site/link lists
36 */
37 #define FOR_ALL_UNITS( unit_ptr ) \
38 for ((unit_ptr) = (unit_array != NULL ? \
39 		   unit_array + MinUnitNo : unit_array + MaxUnitNo + 1); \
40      (unit_ptr) <= unit_array + MaxUnitNo; (unit_ptr)++)
41 
42 #define FOR_ALL_SITES( unit_ptr, site_ptr ) \
43 for ((site_ptr) = (unit_ptr)->sites; (site_ptr) != NULL; \
44      (site_ptr) = (site_ptr)->next)
45 
46 #define FOR_ALL_SITES_AND_LINKS( unit_ptr, site_ptr, link_ptr ) \
47 for ((site_ptr) = (unit_ptr)->sites; (site_ptr) != NULL; \
48      (site_ptr) = (site_ptr)->next) \
49   for ((link_ptr) = (site_ptr)->links; (link_ptr) != NULL; \
50        (link_ptr) = (link_ptr)->next)
51 
52 #define FOR_ALL_LINKS( unit_ptr, link_ptr ) \
53 for ((link_ptr) = (struct Link *) (unit_ptr)->sites; (link_ptr) != NULL; \
54      (link_ptr) = (link_ptr)->next)
55 
56 #define FOR_ALL_LINKS_AT_SITE( site_ptr, link_ptr ) \
57 for ((link_ptr) = (site_ptr)->links; (link_ptr) != NULL; \
58      (link_ptr) = (link_ptr)->next)
59 
60 
61 
62 /*  Some useful macros to determine the input type of a given unit
63 */
64 #define UNIT_HAS_SITES( unit_ptr ) \
65 ((unit_ptr)->flags & UFLAG_SITES)
66 
67 #define UNIT_HAS_DIRECT_INPUTS( unit_ptr ) \
68 ((unit_ptr)->flags & UFLAG_DLINKS)
69 
70 #define UNIT_HAS_INPUTS( unit_ptr ) \
71 ((unit_ptr)->flags & UFLAG_INPUT_PAT)
72 
73 #define IS_INPUT_UNIT( unit_ptr ) \
74 ((unit_ptr)->flags & UFLAG_TTYP_IN)
75 
76 #define IS_OUTPUT_UNIT( unit_ptr ) \
77 ((unit_ptr)->flags & UFLAG_TTYP_OUT)
78 
79 #define IS_HIDDEN_UNIT( unit_ptr ) \
80 ((unit_ptr)->flags & UFLAG_TTYP_HIDD)
81 
82 #define IS_DUAL_UNIT( unit_ptr ) \
83 (((unit_ptr)->flags & UFLAG_TTYP_DUAL) == UFLAG_TTYP_DUAL)
84 
85 #define IS_SPECIAL_UNIT( unit_ptr ) \
86 ((unit_ptr)->flags & UFLAG_TTYP_SPEC)
87 
88 #define IS_SPECIAL_I_UNIT( unit_ptr ) \
89 (((unit_ptr)->flags & UFLAG_TTYP_SPEC_I) == UFLAG_TTYP_SPEC_I)
90 
91 #define IS_SPECIAL_H_UNIT( unit_ptr ) \
92 (((unit_ptr)->flags & UFLAG_TTYP_SPEC_H) == UFLAG_TTYP_SPEC_H)
93 
94 #define IS_SPECIAL_O_UNIT( unit_ptr ) \
95 (((unit_ptr)->flags & UFLAG_TTYP_SPEC_O) == UFLAG_TTYP_SPEC_O)
96 
97 #define IS_SPECIAL_D_UNIT( unit_ptr ) \
98 (((unit_ptr)->flags & UFLAG_TTYP_SPEC_D) == UFLAG_TTYP_SPEC_D)
99 
100 
101 
102 /*  Macro to determine if a given unit is in use or not
103 */
104 #define UNIT_IN_USE( unit_ptr ) \
105 ((unit_ptr)->flags & UFLAG_IN_USE)
106 
107 #define UNIT_REFRESHED( unit_ptr ) \
108 ((unit_ptr)->flags & UFLAG_REFRESH)
109 
110 
111 /*  Some macros for determine the current kernel type
112 */
113 #define  KERNEL_STANDARD  (specialNetworkType == NET_TYPE_GENERAL)
114 
115 
116 
117