1explain_gettimeofday(3) Library Functions Manual explain_gettimeofday(3)
2
3
4
6 explain_gettimeofday - explain gettimeofday(2) errors
7
9 #include <libexplain/gettimeofday.h>
10 const char *explain_gettimeofday(struct timeval *tv, struct timezone
11 *tz);
12 const char *explain_errno_gettimeofday(int errnum, struct timeval *tv,
13 struct timezone *tz);
14 void explain_message_gettimeofday(char *message, int message_size,
15 struct timeval *tv, struct timezone *tz);
16 void explain_message_errno_gettimeofday(char *message, int mes‐
17 sage_size, int errnum, struct timeval *tv, struct timezone *tz);
18
20 These functions may be used to obtain explanations for errors returned
21 by the gettimeofday(2) system call.
22
23 explain_gettimeofday
24 const char *explain_gettimeofday(struct timeval *tv, struct timezone
25 *tz);
26
27 The explain_gettimeofday function is used to obtain an explanation of
28 an error returned by the gettimeofday(2) system call. The least the
29 message will contain is the value of strerror(errno), but usually it
30 will do much better, and indicate the underlying cause in more detail.
31
32 The errno global variable will be used to obtain the error value to be
33 decoded.
34
35 This function is intended to be used in a fashion similar to the fol‐
36 lowing example:
37 if (gettimeofday(tv, tz) < 0)
38 {
39 fprintf(stderr, "%s\n", explain_gettimeofday(tv, tz));
40 exit(EXIT_FAILURE);
41 }
42
43 tv The original tv, exactly as passed to the gettimeofday(2) sys‐
44 tem call.
45
46 tz The original tz, exactly as passed to the gettimeofday(2) sys‐
47 tem call.
48
49 Returns:
50 The message explaining the error. This message buffer is
51 shared by all libexplain functions which do not supply a buffer
52 in their argument list. This will be overwritten by the next
53 call to any libexplain function which shares this buffer,
54 including other threads.
55
56 Note: This function is not thread safe, because it shares a return buf‐
57 fer across all threads, and many other functions in this library.
58
59 explain_errno_gettimeofday
60 const char *explain_errno_gettimeofday(int errnum, struct timeval *tv,
61 struct timezone *tz);
62
63 The explain_errno_gettimeofday function is used to obtain an explana‐
64 tion of an error returned by the gettimeofday(2) system call. The
65 least the message will contain is the value of strerror(errnum), but
66 usually it will do much better, and indicate the underlying cause in
67 more detail.
68
69 This function is intended to be used in a fashion similar to the fol‐
70 lowing example:
71 if (gettimeofday(tv, tz) < 0)
72 {
73 int err = errno;
74 fprintf(stderr, "%s\n", explain_errno_gettimeofday(err, tv, tz));
75 exit(EXIT_FAILURE);
76 }
77
78 errnum The error value to be decoded, usually obtained from the errno
79 global variable just before this function is called. This is
80 necessary if you need to call any code between the system call
81 to be explained and this function, because many libc functions
82 will alter the value of errno.
83
84 tv The original tv, exactly as passed to the gettimeofday(2) sys‐
85 tem call.
86
87 tz The original tz, exactly as passed to the gettimeofday(2) sys‐
88 tem call.
89
90 Returns:
91 The message explaining the error. This message buffer is
92 shared by all libexplain functions which do not supply a buffer
93 in their argument list. This will be overwritten by the next
94 call to any libexplain function which shares this buffer,
95 including other threads.
96
97 Note: This function is not thread safe, because it shares a return buf‐
98 fer across all threads, and many other functions in this library.
99
100 explain_message_gettimeofday
101 void explain_message_gettimeofday(char *message, int message_size,
102 struct timeval *tv, struct timezone *tz);
103
104 The explain_message_gettimeofday function may be used to obtain an
105 explanation of an error returned by the gettimeofday(2) system call.
106 The least the message will contain is the value of strerror(errno), but
107 usually it will do much better, and indicate the underlying cause in
108 more detail.
109
110 The errno global variable will be used to obtain the error value to be
111 decoded.
112
113 This function is intended to be used in a fashion similar to the fol‐
114 lowing example:
115 if (gettimeofday(tv, tz) < 0)
116 {
117 char message[3000];
118 explain_message_gettimeofday(message, sizeof(message), tv, tz);
119 fprintf(stderr, "%s\n", message);
120 exit(EXIT_FAILURE);
121 }
122
123 message The location in which to store the returned message. If a
124 suitable message return buffer is supplied, this function is
125 thread safe.
126
127 message_size
128 The size in bytes of the location in which to store the
129 returned message.
130
131 tv The original tv, exactly as passed to the gettimeofday(2) sys‐
132 tem call.
133
134 tz The original tz, exactly as passed to the gettimeofday(2) sys‐
135 tem call.
136
137 explain_message_errno_gettimeofday
138 void explain_message_errno_gettimeofday(char *message, int mes‐
139 sage_size, int errnum, struct timeval *tv, struct timezone *tz);
140
141 The explain_message_errno_gettimeofday function may be used to obtain
142 an explanation of an error returned by the gettimeofday(2) system call.
143 The least the message will contain is the value of strerror(errnum),
144 but usually it will do much better, and indicate the underlying cause
145 in more detail.
146
147 This function is intended to be used in a fashion similar to the fol‐
148 lowing example:
149 if (gettimeofday(tv, tz) < 0)
150 {
151 int err = errno;
152 char message[3000];
153 explain_message_errno_gettimeofday(message, sizeof(message), err,
154 tv, tz);
155 fprintf(stderr, "%s\n", message);
156 exit(EXIT_FAILURE);
157 }
158
159 message The location in which to store the returned message. If a
160 suitable message return buffer is supplied, this function is
161 thread safe.
162
163 message_size
164 The size in bytes of the location in which to store the
165 returned message.
166
167 errnum The error value to be decoded, usually obtained from the errno
168 global variable just before this function is called. This is
169 necessary if you need to call any code between the system call
170 to be explained and this function, because many libc functions
171 will alter the value of errno.
172
173 tv The original tv, exactly as passed to the gettimeofday(2) sys‐
174 tem call.
175
176 tz The original tz, exactly as passed to the gettimeofday(2) sys‐
177 tem call.
178
180 gettimeofday(2)
181 get time
182
183 explain_gettimeofday_or_die(3)
184 get time and report errors
185
187 libexplain version 1.4
188 Copyright (C) 2008 Peter Miller
189
190
191
192 explain_gettimeofday(3)