Grid Community Toolkit  6.2.1629922860 (tag: v6.2.20210826)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
globus_utp_private.h
1 /*
2  * Copyright 1999-2006 University of Chicago
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /**********************************************************************
18 globus_utp_private.h
19 
20 Private declarations for the Unnamed Timing Package (UTP).
21 **********************************************************************/
22 
23 #ifndef GLOBUS_UTP_PRIVATE_INCLUDE
24 #define GLOBUS_UTP_PRIVATE_INCLUDE
25 
26 #include "globus_utp.h"
27 
28 /**********************************************************************
29 Machine-dependent definitions.
30 **********************************************************************/
31 
32 /*
33 Supported machine types are as follows:
34 
35 UNIX : generic Unix; assumes BSD 4.3-compatible gettimeofday(2) and
36  "struct timeval" from <sys/time.h>. I have not yet seen a modern
37  Unix worksation which doesn't have this.
38 
39 RS6000 : IBM RS6000 running AIX 3.2 or higher. Relies on the gettimer()
40  routine, which is supposed to be a standard (yet the IBM "info"
41  pages say it may change!). Clock frequency is supposed to be
42  256 nanosec.
43 */
44 
45 /*
46 Check that at least one supported machine type macro was defined.
47 */
48 
49 #define UNIX
50 #if !defined(UNIX) && !defined(RS6000) && !defined(SOLHR) && \
51  !defined(SPARCSUNOS41) && !defined(PARAGON)
52 #error "No machine type was defined."
53 #endif
54 
55 
56 /*
57 globus_utp_TimeValue_t is a machine-dependent type representing a time, at the
58 highest resolution available.
59 */
60 
61 #if defined(UNIX) || defined(SPARCSUNOS41)
62 
63 #include <sys/time.h>
64 
65 #if 0
66 #ifdef BSDGETTIMEOFDAY
67 extern int
68 BSDgettimeofday(struct timeval *tvp, struct timezone *tzp);
69 #else
70 extern int
71 gettimeofday(struct timeval *tvp, struct timezone *tzp);
72 #endif
73 #endif
74 
75 typedef struct timeval globus_utp_TimeValue_t;
76 
77 #endif /* #ifdef UNIX */
78 
79 
80 #ifdef RS6000
81 
82 /*
83 See also comments on RS6000 version of globus_utp_readTime() in globus_utp_main.c.
84 */
85 
86 #include <sys/time.h>
87 
88 typedef struct timestruc_t globus_utp_TimeValue_t;
89 
90 #endif /* #ifdef RS6000 */
91 
92 
93 #ifdef SOLHR
94 
95 #include <sys/time.h>
96 
97 typedef hrtime_t globus_utp_TimeValue_t;
98 
99 #endif
100 
101 
102 #ifdef PARAGON
103 
104 #include <nx.h>
105 
106 typedef double globus_utp_TimeValue_t;
107 
108 #endif
109 
110 
111 /**********************************************************************
112 Machine-independent definitions.
113 **********************************************************************/
114 
115 /*
116 globus_utp_TimerState represents the current state of a timer. A timer which is
117 either "stopped" or "running" is implicitly enabled.
118 */
119 
120 typedef enum _globus_utp_TimerState {
121  GLOBUS_UTP_TIMER_STOPPED,
122  GLOBUS_UTP_TIMER_RUNNING,
123  GLOBUS_UTP_TIMER_DISABLED
124 } globus_utp_TimerState;
125 
126 
127 /*
128 globus_utp_Timer_t contains all data associated with a timer.
129 */
130 
131 typedef struct _globus_utp_Timer_t {
132  globus_utp_TimerState state;
133  globus_utp_TimeValue_t startTime;/* If running, when did it start? */
134  /* Total time accumulated. */
135  globus_utp_TimeValue_t accumulatedTime;
136  unsigned long numEvents; /* Number of timed events
137  accumulated into the timer. */
138  char *name; /* Human-readable name. */
139 } globus_utp_Timer_t;
140 
141 
142 /*
143 Attributes (key/value pairs) are stored in a linked-list structure.
144 */
145 
146 struct _globus_utp_Attribute_t; /* Forward declaration. */
147 
148 typedef struct _globus_utp_Attribute_t {
149  char *key;
150  char *value;
151  struct _globus_utp_Attribute_t *next;
152 } globus_utp_Attribute_t;
153 
154 
155 /*
156 Masks to select fields of the globus_utp_init "mode" parameter.
157 */
158 
159 #define GLOBUS_UTP_MODE_SHARING_FIELD 0x1
160 
161 
162 /**********************************************************************
163 Private but global functions, to be used only internally by the UTP
164 package.
165 **********************************************************************/
166 
167 /*
168 Read current clock time, in a machine-dependent way; store result in *tv.
169 */
170 
171 extern void
172 globus_utp_readTime(globus_utp_TimeValue_t *tv);
173 
174 /*
175 Place elapsed time between *start and *end into *diff (machine-dependent).
176 It is permissible for start and/or end to be identical to diff.
177 */
178 
179 extern void
180 globus_utp_timeDifference(globus_utp_TimeValue_t *diff, const globus_utp_TimeValue_t *start,
181  const globus_utp_TimeValue_t *end);
182 
183 /*
184 Accumulate *newElapsed time into *oldElapsed (machine-dependent).
185 */
186 
187 extern void
188 globus_utp_timeAdd(globus_utp_TimeValue_t *oldElapsed,
189  const globus_utp_TimeValue_t *newElapsed);
190 
191 /*
192 Set *tv to time zero (machine-dependent).
193 */
194 
195 extern void
196 globus_utp_timeZero(globus_utp_TimeValue_t *tv);
197 
198 
199 /*
200 Convert *tv to its double-precision floating-point representation; store it
201 in *time, store number of significant digits after the decimal place in
202 *precision. Machine-dependent.
203 */
204 
205 extern void
206 globus_utp_timeToDouble(double *time, int *precision, const globus_utp_TimeValue_t *tv);
207 
208 
209 /*
210 Convert *tv to its floating-point string representation, with seconds as
211 the units; store result in timeString. Machine-dependent.
212 */
213 
214 extern void
215 globus_utp_timeToString(char timeString[], const globus_utp_TimeValue_t *tv);
216 
217 
218 /*
219 Emit the warning message messageStr in some appropriate way. messageStr is
220 a printf()-format output specfier string; the "..." represents data to be
221 printed using the specifier.
222 */
223 
224 extern void
225 globus_utp_warn(const char *messageStr, ...);
226 
227 
228 /**********************************************************************
229 Private but global variables, to be used only internally by the UTP
230 package.
231 **********************************************************************/
232 
233 extern char *globus_utp_outFilename; /* Name of output dump file. */
234 extern unsigned globus_utp_numTimers; /* Number of timers in use. */
235 extern globus_utp_Timer_t *globus_utp_timers; /* Array for the timers. */
236 extern globus_utp_Attribute_t *globus_utp_attributes; /* Key/value pairs (comments). */
237 
238 
239 #endif /* #ifndef GLOBUS_UTP_PRIVATE_INCLUDE */
240