File: globus_utp_private.h

package info (click to toggle)
globus-xio 6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 8,128 kB
  • sloc: ansic: 46,711; sh: 11,139; perl: 1,598; makefile: 289
file content (240 lines) | stat: -rw-r--r-- 6,208 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/*
 * Copyright 1999-2006 University of Chicago
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**********************************************************************
globus_utp_private.h

Private declarations for the Unnamed Timing Package (UTP).
**********************************************************************/

#ifndef GLOBUS_UTP_PRIVATE_INCLUDE
#define GLOBUS_UTP_PRIVATE_INCLUDE

#include "globus_utp.h"

/**********************************************************************
Machine-dependent definitions.
**********************************************************************/

/*
Supported machine types are as follows:

UNIX : generic Unix; assumes BSD 4.3-compatible gettimeofday(2) and
	"struct timeval" from <sys/time.h>.  I have not yet seen a modern
	Unix worksation which doesn't have this.

RS6000 : IBM RS6000 running AIX 3.2 or higher.  Relies on the gettimer()
	routine, which is supposed to be a standard (yet the IBM "info"
	pages say it may change!).  Clock frequency is supposed to be
	256 nanosec.
*/

/*
Check that at least one supported machine type macro was defined.
*/

#define UNIX
#if !defined(UNIX) && !defined(RS6000) && !defined(SOLHR) && \
	!defined(SPARCSUNOS41) && !defined(PARAGON)
#error "No machine type was defined."
#endif


/*
globus_utp_TimeValue_t is a machine-dependent type representing a time, at the
highest resolution available.
*/

#if defined(UNIX) || defined(SPARCSUNOS41)

#include <sys/time.h>

#if 0
#ifdef BSDGETTIMEOFDAY
extern int
BSDgettimeofday(struct timeval *tvp, struct timezone *tzp);
#else
extern int
gettimeofday(struct timeval *tvp, struct timezone *tzp);
#endif
#endif

typedef struct timeval globus_utp_TimeValue_t;

#endif /* #ifdef UNIX */


#ifdef RS6000

/*
See also comments on RS6000 version of globus_utp_readTime() in globus_utp_main.c.
*/

#include <sys/time.h>

typedef struct timestruc_t globus_utp_TimeValue_t;

#endif	/* #ifdef RS6000 */


#ifdef SOLHR

#include <sys/time.h>

typedef hrtime_t globus_utp_TimeValue_t;

#endif


#ifdef PARAGON

#include <nx.h>

typedef double globus_utp_TimeValue_t;

#endif


/**********************************************************************
Machine-independent definitions.
**********************************************************************/

/*
globus_utp_TimerState represents the current state of a timer.  A timer which is
either "stopped" or "running" is implicitly enabled.
*/

typedef enum _globus_utp_TimerState {
	GLOBUS_UTP_TIMER_STOPPED,
	GLOBUS_UTP_TIMER_RUNNING,
	GLOBUS_UTP_TIMER_DISABLED
} globus_utp_TimerState;


/*
globus_utp_Timer_t contains all data associated with a timer.
*/

typedef struct _globus_utp_Timer_t {
	globus_utp_TimerState state;
	globus_utp_TimeValue_t startTime;/* If running, when did it start? */
					/* Total time accumulated. */
	globus_utp_TimeValue_t accumulatedTime;
	unsigned long numEvents;	/* Number of timed events
					   accumulated into the timer. */
	char *name;			/* Human-readable name. */
} globus_utp_Timer_t;


/*
Attributes (key/value pairs) are stored in a linked-list structure.
*/

struct _globus_utp_Attribute_t;		/* Forward declaration. */

typedef struct _globus_utp_Attribute_t {
	char *key;
	char *value;
	struct _globus_utp_Attribute_t *next;
} globus_utp_Attribute_t;


/*
Masks to select fields of the globus_utp_init "mode" parameter.
*/

#define GLOBUS_UTP_MODE_SHARING_FIELD 0x1


/**********************************************************************
Private but global functions, to be used only internally by the UTP
package.
**********************************************************************/

/*
Read current clock time, in a machine-dependent way; store result in *tv.
*/

extern void
globus_utp_readTime(globus_utp_TimeValue_t *tv);

/*
Place elapsed time between *start and *end into *diff (machine-dependent).
It is permissible for start and/or end to be identical to diff.
*/

extern void
globus_utp_timeDifference(globus_utp_TimeValue_t *diff, const globus_utp_TimeValue_t *start,
		   const globus_utp_TimeValue_t *end);

/*
Accumulate *newElapsed time into *oldElapsed (machine-dependent).
*/

extern void
globus_utp_timeAdd(globus_utp_TimeValue_t *oldElapsed,
	    const globus_utp_TimeValue_t *newElapsed);

/*
Set *tv to time zero (machine-dependent).
*/

extern void
globus_utp_timeZero(globus_utp_TimeValue_t *tv);


/*
Convert *tv to its double-precision floating-point representation; store it
in *time, store number of significant digits after the decimal place in
*precision.  Machine-dependent.
*/

extern void
globus_utp_timeToDouble(double *time, int *precision, const globus_utp_TimeValue_t *tv);


/*
Convert *tv to its floating-point string representation, with seconds as
the units; store result in timeString.  Machine-dependent.
*/

extern void
globus_utp_timeToString(char timeString[], const globus_utp_TimeValue_t *tv);


/*
Emit the warning message messageStr in some appropriate way.  messageStr is
a printf()-format output specfier string; the "..." represents data to be
printed using the specifier.
*/

extern void
globus_utp_warn(const char *messageStr, ...);


/**********************************************************************
Private but global variables, to be used only internally by the UTP
package.
**********************************************************************/

extern char *globus_utp_outFilename;		/* Name of output dump file. */
extern unsigned globus_utp_numTimers;		/* Number of timers in use. */
extern globus_utp_Timer_t *globus_utp_timers;		/* Array for the timers. */
extern globus_utp_Attribute_t *globus_utp_attributes;	/* Key/value pairs (comments). */


#endif /* #ifndef GLOBUS_UTP_PRIVATE_INCLUDE */