lib/Linux/RTC/Ioctl.xs

filter: Statementstmt 36.3% 218 / 600 Branchbran 25.3% 128 / 506 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 31.2% 346 / 1106 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Linux/RTC/Ioctl.pm ↑ Summary lib/Linux/RTC/const-xs.inc »
1 # include <sys/ioctl.h>
2 # include <linux/rtc.h>
3  
4 #define PERL_NO_GET_CONTEXT
5 #include "EXTERN.h"
6 #include "perl.h"
7 #include "XSUB.h"
8  
9 #if defined(read) || defined(ioctl)
10 # warning "POSIX read/ioctl re-defined"
11 # include "src/IoctlNative.h"
12 #else
13 # define linux_rtc_native_read read
14 # define linux_rtc_native_ioctl ioctl
15 #endif
16  
17 #include "const-c.inc"
18  
19 static const char
20 invalidHandleMsg[] = "Invalid device file handle.",
21 missingDeviceFileMsg[] = "No device file given.",
22 rtcRecordSizeMsg[] = "Unexpected end of file from real time clock device %s.",
23 unsignedParamMsg[] = "Unsigned number parameter expected.",
24 numericParamMsg[] = "Numeric parameter expected.",
25 hashAccessFailedMsg[] = "Failed to access $rtc object hash keys.",
26 objectFieldsMissingMsg[] = "Member field \"%s\" is missing or is non-numeric in RTC object.";
27  
28 MODULE = Linux::RTC::Ioctl PACKAGE = Linux::RTC::Ioctl
29  
30 INCLUDE: const-xs.inc
31  
32 void
33 wait_for_timer(HV *rtc)
34 PROTOTYPE: \%
35 PPCODE:
36 3 int fd = -1;
37 3 char const *node = "";
38 3 unsigned long record = 0;
39 3 ssize_t read_size = -1;
40 3 SV **device = hv_fetch(rtc, "device", 6, 0);
41  
42 {
43 3 SV **nodename = hv_fetch(rtc, "nodename", 8, 0);
44  
45 6 ▶ if (nodename && (node = SvPV_nolen(*nodename), SvPOK(*nodename)))
Branch: 2 branches
BranchTrueFalseTotal
if (nodename && (node = SvPV_nolen(*nodename), SvPOK(*nodename))) 3 0 3
if (nodename && (node = SvPV_nolen(*nodename), SvPOK(*nodename))) 3 0 3
46 ;
47 else
48 0 node = "";
49 }
50  
51 3 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 3 0 3
52 {
53 3 IO *file_io = sv_2io(*device);
54  
55 3 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 3 0 3
56 {
57 3 PerlIO *device_perlio = IoIFP(file_io);
58  
59 3 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 2 1 3
60 {
61 2 fd = PerlIO_fileno(device_perlio);
62  
63 2 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 2 2
64 0 croak(invalidHandleMsg);
65 }
66 else
67 1 croak(invalidHandleMsg);
68 }
69 else
70 0 croak(invalidHandleMsg);
71 }
72 else
73 0 croak(missingDeviceFileMsg);
74  
75 2 read_size = linux_rtc_native_read(fd, &record, sizeof record);
76  
77 2 ▶ if (read_size == sizeof record)
Branch: 1 branch
BranchTrueFalseTotal
if (read_size == sizeof record) 1 1 2
78 {
79 1 ▶ EXTEND(SP, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); 0 1 1
80 1 PUSHs(sv_2mortal(newSVuv(record & ((1 << CHAR_BIT) - 1))));
81 1 PUSHs(sv_2mortal(newSVuv(record >> CHAR_BIT)));
82 1 XSRETURN(2);
83 }
84 else
85 1 ▶ if (read_size >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (read_size >= 0) 1 0 1
86 1 croak(rtcRecordSizeMsg, node);
87 else
88 {
89 // return undef after a read error, check $!
90 0 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 0 0
91 0 XSRETURN(1);
92 }
93  
94 #if defined(RTC_IRQP_SET) && defined(RTC_IRQP_READ)
95  
96 void
97 periodic_frequency(HV *rtc, ...)
98 PROTOTYPE: \%;$
99 PPCODE:
100 2 int fd = -1;
101 2 SV **device = hv_fetch(rtc, "device", 6, 0);;
102  
103 2 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 2 0 2
104 {
105 2 IO *file_io = sv_2io(*device);
106  
107 2 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 2 0 2
108 {
109 2 PerlIO *device_perlio = IoIFP(file_io);
110  
111 2 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 2 0 2
112 {
113 2 fd = PerlIO_fileno(device_perlio);
114  
115 2 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 2 2
116 0 croak(invalidHandleMsg);
117 }
118 else
119 0 croak(invalidHandleMsg);
120 }
121 else
122 0 croak(invalidHandleMsg);
123 }
124 else
125 0 croak(missingDeviceFileMsg);
126  
127 2 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 1 1 2
128 {
129 1 IV freq = SvIV(ST(1));
130  
131 1 ▶ if (SvIOK(ST(1)) && freq > 0)
Branch: 2 branches
BranchTrueFalseTotal
if (SvIOK(ST(1)) && freq > 0) 1 0 1
if (SvIOK(ST(1)) && freq > 0) 1 0 1
132 {
133 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
134 1 unsigned long frequency = freq;
135 1 int result = ioctl(fd, RTC_IRQP_SET, frequency);
136  
137 1 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 1 0 1
138 1 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 1 1
139 else
140 0 ▶ XPUSHu(result);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHu(result); 0 0 0
XPUSHu(result); 0 0 0
141  
142 1 XSRETURN(1);
143 }
144 else
145 0 croak(unsignedParamMsg);
146 }
147 else
148 {
149 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
150 unsigned long frequency;
151 1 int result = ioctl(fd, RTC_IRQP_READ, &frequency);
152  
153 1 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 1 0 1
154 1 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 1 1
155 else
156 0 ▶ XPUSHu(frequency);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHu(frequency); 0 0 0
XPUSHu(frequency); 0 0 0
157  
158 1 XSRETURN(1);
159 }
160  
161 #endif
162  
163 #if defined(RTC_PIE_ON) && defined(RTC_PIE_OFF)
164  
165 void
166 periodic_interrupt(HV *rtc, bool fEnable)
167 PROTOTYPE: \%$
168 PPCODE:
169 2 int fd = -1;
170 2 SV **device = hv_fetch(rtc, "device", 6, 0);;
171  
172 2 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 2 0 2
173 {
174 2 IO *file_io = sv_2io(*device);
175  
176 2 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 2 0 2
177 {
178 2 PerlIO *device_perlio = IoIFP(file_io);
179  
180 2 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 2 0 2
181 {
182 2 fd = PerlIO_fileno(device_perlio);
183  
184 2 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 2 2
185 0 croak(invalidHandleMsg);
186 }
187 else
188 0 croak(invalidHandleMsg);
189 }
190 else
191 0 croak(invalidHandleMsg);
192 }
193 else
194 0 croak(missingDeviceFileMsg);
195  
196 {
197 2 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 2 0 2
198 2 ▶ int result = ioctl(fd, fEnable ? RTC_PIE_ON : RTC_PIE_OFF, 0);
Branch: 1 branch
BranchTrueFalseTotal
int result = ioctl(fd, fEnable ? RTC_PIE_ON : RTC_PIE_OFF, 0); 1 1 2
199  
200 2 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 2 0 2
201 2 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 2 2
202 else
203 0 ▶ XPUSHu(result);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHu(result); 0 0 0
XPUSHu(result); 0 0 0
204  
205 2 XSRETURN(1);
206 }
207  
208 #endif
209  
210 #if defined(RTC_UIE_ON) && defined(RTC_UIE_OFF)
211  
212 void
213 update_interrupt(HV *rtc, bool fEnable)
214 PROTOTYPE: \%$
215 PPCODE:
216 2 int fd = -1;
217 2 SV **device = hv_fetch(rtc, "device", 6, 0);;
218  
219 2 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 2 0 2
220 {
221 2 IO *file_io = sv_2io(*device);
222  
223 2 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 2 0 2
224 {
225 2 PerlIO *device_perlio = IoIFP(file_io);
226  
227 2 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 2 0 2
228 {
229 2 fd = PerlIO_fileno(device_perlio);
230  
231 2 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 2 2
232 0 croak(invalidHandleMsg);
233 }
234 else
235 0 croak(invalidHandleMsg);
236 }
237 else
238 0 croak(invalidHandleMsg);
239 }
240 else
241 0 croak(missingDeviceFileMsg);
242  
243 {
244 2 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 2 0 2
245 2 ▶ int result = ioctl(fd, fEnable ? RTC_UIE_ON : RTC_UIE_OFF, 0);
Branch: 1 branch
BranchTrueFalseTotal
int result = ioctl(fd, fEnable ? RTC_UIE_ON : RTC_UIE_OFF, 0); 1 1 2
246  
247 2 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 2 0 2
248 2 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 2 2
249 else
250 0 ▶ XPUSHu(result);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHu(result); 0 0 0
XPUSHu(result); 0 0 0
251  
252 2 XSRETURN(1);
253 }
254  
255 #endif
256  
257 #if defined(RTC_AIE_ON) && defined(RTC_AIE_OFF)
258  
259 void
260 alarm_interrupt(HV *rtc, bool fEnable)
261 PROTOTYPE: \%$
262 PPCODE:
263 2 int fd = -1;
264 2 SV **device = hv_fetch(rtc, "device", 6, 0);;
265  
266 2 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 2 0 2
267 {
268 2 IO *file_io = sv_2io(*device);
269  
270 2 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 2 0 2
271 {
272 2 PerlIO *device_perlio = IoIFP(file_io);
273  
274 2 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 2 0 2
275 {
276 2 fd = PerlIO_fileno(device_perlio);
277  
278 2 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 2 2
279 0 croak(invalidHandleMsg);
280 }
281 else
282 0 croak(invalidHandleMsg);
283 }
284 else
285 0 croak(invalidHandleMsg);
286 }
287 else
288 0 croak(missingDeviceFileMsg);
289  
290 {
291 2 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 2 0 2
292 2 ▶ int result = ioctl(fd, fEnable ? RTC_AIE_ON : RTC_AIE_OFF, 0);
Branch: 1 branch
BranchTrueFalseTotal
int result = ioctl(fd, fEnable ? RTC_AIE_ON : RTC_AIE_OFF, 0); 1 1 2
293  
294 2 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 2 0 2
295 2 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 2 2
296 else
297 0 ▶ XPUSHu(result);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHu(result); 0 0 0
XPUSHu(result); 0 0 0
298  
299 2 XSRETURN(1);
300 }
301  
302 #endif
303  
304 #if defined(RTC_RD_TIME)
305  
306 void
307 read_time(HV *rtc)
308 PROTOTYPE: \%
309 PPCODE:
310 1 struct rtc_time tm = { 0, 0, 0, 0, 0, 0, -1, -1, -1 };
311 1 int fd = -1;
312 1 SV **device = hv_fetch(rtc, "device", 6, 0);
313 int result;
314  
315 1 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 1 0 1
316 {
317 1 IO *file_io = sv_2io(*device);
318  
319 1 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 1 0 1
320 {
321 1 PerlIO *device_perlio = IoIFP(file_io);
322  
323 1 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 1 0 1
324 {
325 1 fd = PerlIO_fileno(device_perlio);
326  
327 1 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 1 1
328 0 croak(invalidHandleMsg);
329 }
330 else
331 0 croak(invalidHandleMsg);
332 }
333 else
334 0 croak(invalidHandleMsg);
335 }
336 else
337 0 croak(missingDeviceFileMsg);
338  
339 1 result = ioctl(fd, RTC_RD_TIME, &tm);
340  
341 1 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 1 0 1
342 {
343 1 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 1 1
344 1 XSRETURN(1);
345 }
346 else
347 0 ▶ if (G_ARRAY == GIMME_V)
Branch: 1 branch
BranchTrueFalseTotal
if (G_ARRAY == GIMME_V) 0 0 0
348 {
349 /* called in list context, push time members on stack and do not store them. */
350 0 ▶ EXTEND(SP, 9);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 9); 0 0 0
351 0 mPUSHi(tm.tm_sec);
352 0 mPUSHi(tm.tm_min);
353 0 mPUSHi(tm.tm_hour);
354  
355 0 mPUSHi(tm.tm_mday);
356 0 mPUSHi(tm.tm_mon);
357 0 mPUSHi(tm.tm_year);
358  
359 0 mPUSHi(tm.tm_wday);
360 0 mPUSHi(tm.tm_yday);
361 0 mPUSHi(tm.tm_isdst);
362 0 XSRETURN(9);
363 }
364 else
365 {
366 0 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 0 0 0
367 /* called in void (or scalar) context, save members in the perl object. */
368 0 SV **val = hv_fetch(rtc, "sec", 3, !0);
369  
370 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
371 0 sv_setiv(*val, (IV)(tm.tm_sec));
372 else
373 0 croak(hashAccessFailedMsg);
374  
375 0 val = hv_fetch(rtc, "min", 3, !0);
376 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
377 0 sv_setiv(*val, (IV)(tm.tm_min));
378 else
379 0 croak(hashAccessFailedMsg);
380  
381 0 val = hv_fetch(rtc, "hour", 4, !0);
382 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
383 0 sv_setiv(*val, (IV)(tm.tm_hour));
384 else
385 0 croak(hashAccessFailedMsg);
386  
387 0 val = hv_fetch(rtc, "mday", 4, !0);
388 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
389 0 sv_setiv(*val, (IV)(tm.tm_mday));
390 else
391 0 croak(hashAccessFailedMsg);
392  
393 0 val = hv_fetch(rtc, "mon", 3, !0);
394 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
395 0 sv_setiv(*val, (IV)(tm.tm_mon));
396 else
397 0 croak(hashAccessFailedMsg);
398  
399 0 val = hv_fetch(rtc, "year", 4, !0);
400 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
401 0 sv_setiv(*val, (IV)(tm.tm_year));
402 else
403 0 croak(hashAccessFailedMsg);
404  
405 0 val = hv_fetch(rtc, "wday", 4, !0);
406 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
407 0 sv_setiv(*val, (IV)(tm.tm_wday));
408 else
409 0 croak(hashAccessFailedMsg);
410  
411 0 val = hv_fetch(rtc, "yday", 4, !0);
412 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
413 0 sv_setiv(*val, (IV)(tm.tm_yday));
414 else
415 0 croak(hashAccessFailedMsg);
416  
417 0 val = hv_fetch(rtc, "isdst", 5, !0);
418 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
419 0 sv_setiv(*val, (IV)(tm.tm_isdst));
420 else
421 0 croak(hashAccessFailedMsg);
422  
423 0 ▶ XPUSHu(result);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHu(result); 0 0 0
XPUSHu(result); 0 0 0
424 0 XSRETURN(1);
425 }
426  
427 #endif
428  
429 #if defined(RTC_SET_TIME)
430  
431 void
432 set_time(HV *rtc, ...)
433 PROTOTYPE: \*%;$$$$$$$$$
434 PPCODE:
435 1 int args_count = items;
436 1 struct rtc_time tm = { 0, 0, 0, 0, 0, 0, -1, -1, -1 };
437 1 int fd = -1;
438 1 SV **device = hv_fetch(rtc, "device", 6, 0);;
439  
440 1 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 1 0 1
441 {
442 1 IO *file_io = sv_2io(*device);
443  
444 1 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 1 0 1
445 {
446 1 PerlIO *device_perlio = IoIFP(file_io);
447  
448 1 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 1 0 1
449 {
450 1 fd = PerlIO_fileno(device_perlio);
451  
452 1 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 1 1
453 0 croak(invalidHandleMsg);
454 }
455 else
456 0 croak(invalidHandleMsg);
457 }
458 else
459 0 croak(invalidHandleMsg);
460 }
461 else
462 0 croak(missingDeviceFileMsg);
463  
464 1 ▶ if (args_count > 10)
Branch: 1 branch
BranchTrueFalseTotal
if (args_count > 10) 0 1 1
465 0 args_count = 10;
466  
467 1 switch (args_count)
468 {
469 0 case 10:
470 0 ▶ if (tm.tm_isdst = SvIV(ST(9)), SvIOK(ST(9)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_isdst = SvIV(ST(9)), SvIOK(ST(9))) 0 0 0
471 ;
472 else
473 0 croak(numericParamMsg);
474 // fall-through
475 case 9:
476 0 ▶ if (tm.tm_yday = SvIV(ST(8)), SvIOK(ST(8)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_yday = SvIV(ST(8)), SvIOK(ST(8))) 0 0 0
477 ;
478 else
479 0 croak(numericParamMsg);
480 // fall-through
481 case 8:
482 0 ▶ if (tm.tm_wday = SvIV(ST(7)), SvIOK(ST(7)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_wday = SvIV(ST(7)), SvIOK(ST(7))) 0 0 0
483 ;
484 else
485 0 croak(numericParamMsg);
486 // fall-through
487 case 7:
488 0 ▶ if (tm.tm_year = SvIV(ST(6)), SvIOK(ST(6)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_year = SvIV(ST(6)), SvIOK(ST(6))) 0 0 0
489 ;
490 else
491 0 croak(numericParamMsg);
492 // fall-through
493 case 6:
494 0 ▶ if (tm.tm_mon = SvIV(ST(5)), SvIOK(ST(5)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_mon = SvIV(ST(5)), SvIOK(ST(5))) 0 0 0
495 ;
496 else
497 0 croak(numericParamMsg);
498 case 5:
499 0 ▶ if (tm.tm_mday = SvIV(ST(4)), SvIOK(ST(4)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_mday = SvIV(ST(4)), SvIOK(ST(4))) 0 0 0
500 ;
501 else
502 0 croak(numericParamMsg);
503 // fall-through
504 case 4:
505 0 ▶ if (tm.tm_hour = SvIV(ST(3)), SvIOK(ST(3)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_hour = SvIV(ST(3)), SvIOK(ST(3))) 0 0 0
506 ;
507 else
508 0 croak(numericParamMsg);
509 // fall-through
510 case 3:
511 0 ▶ if (tm.tm_min = SvIV(ST(2)), SvIOK(ST(2)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_min = SvIV(ST(2)), SvIOK(ST(2))) 0 0 0
512 ;
513 else
514 0 croak(numericParamMsg);
515 // fall-through
516 case 2:
517 0 ▶ if (tm.tm_sec = SvIV(ST(1)), SvIOK(ST(1)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_sec = SvIV(ST(1)), SvIOK(ST(1))) 0 0 0
518 ;
519 else
520 0 croak(numericParamMsg);
521 0 break;
522 1 case 1:
523 {
524 1 SV **val = hv_fetch(rtc, "isdst", 5, 0);
525  
526 1 ▶ if (*val && (tm.tm_isdst = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_isdst = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_isdst = SvIV(*val), SvIOK(*val))) 1 0 1
527 ;
528 else
529 0 croak(objectFieldsMissingMsg, "isdst");
530  
531 1 val = hv_fetch(rtc, "yday", 4, 0);
532 1 ▶ if (*val && (tm.tm_yday = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_yday = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_yday = SvIV(*val), SvIOK(*val))) 1 0 1
533 ;
534 else
535 0 croak(objectFieldsMissingMsg, "yday");
536  
537 1 val = hv_fetch(rtc, "wday", 4, 0);
538 1 ▶ if (*val && (tm.tm_wday = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_wday = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_wday = SvIV(*val), SvIOK(*val))) 1 0 1
539 ;
540 else
541 0 croak(objectFieldsMissingMsg, "wday");
542  
543 1 val = hv_fetch(rtc, "year", 4, 0);
544 1 ▶ if (*val && (tm.tm_year = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_year = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_year = SvIV(*val), SvIOK(*val))) 1 0 1
545 ;
546 else
547 0 croak(objectFieldsMissingMsg, "year");
548  
549 1 val = hv_fetch(rtc, "mon", 3, 0);
550 1 ▶ if (*val && (tm.tm_mon = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_mon = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_mon = SvIV(*val), SvIOK(*val))) 1 0 1
551 ;
552 else
553 0 croak(objectFieldsMissingMsg, "mon");
554  
555 1 val = hv_fetch(rtc, "mday", 4, 0);
556 1 ▶ if (*val && (tm.tm_mday = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_mday = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_mday = SvIV(*val), SvIOK(*val))) 1 0 1
557 ;
558 else
559 0 croak(objectFieldsMissingMsg, "mday");
560  
561 1 val = hv_fetch(rtc, "hour", 4, 0);
562 1 ▶ if (*val && (tm.tm_hour = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_hour = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_hour = SvIV(*val), SvIOK(*val))) 1 0 1
563 ;
564 else
565 0 croak(objectFieldsMissingMsg, "hour");
566  
567 1 val = hv_fetch(rtc, "min", 3, 0);
568 1 ▶ if (*val && (tm.tm_min = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_min = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_min = SvIV(*val), SvIOK(*val))) 1 0 1
569 ;
570 else
571 0 croak(objectFieldsMissingMsg, "min");
572  
573 1 val = hv_fetch(rtc, "sec", 3, 0);
574 1 ▶ if (*val && (tm.tm_sec = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_sec = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_sec = SvIV(*val), SvIOK(*val))) 1 0 1
575 ;
576 else
577 0 croak(objectFieldsMissingMsg, "sec");
578  
579 1 break;
580 }
581 }
582  
583 {
584 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
585 1 int result = ioctl(fd, RTC_SET_TIME, &tm);
586  
587 1 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 1 0 1
588 1 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 1 1
589 else
590 0 ▶ XPUSHu(result);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHu(result); 0 0 0
XPUSHu(result); 0 0 0
591  
592 1 XSRETURN(1);
593 }
594  
595 #endif
596  
597 #if defined(RTC_ALM_READ)
598  
599 void
600 read_alarm(HV *rtc)
601 PROTOTYPE: \%
602 PPCODE:
603 1 struct rtc_time tm = { 0, 0, 0, 0, 0, 0, -1, -1, -1 };
604 1 int fd = -1;
605 1 SV **device = hv_fetch(rtc, "device", 6, 0);;
606 int result;
607  
608 1 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 1 0 1
609 {
610 1 IO *file_io = sv_2io(*device);
611  
612 1 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 1 0 1
613 {
614 1 PerlIO *device_perlio = IoIFP(file_io);
615  
616 1 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 1 0 1
617 {
618 1 fd = PerlIO_fileno(device_perlio);
619  
620 1 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 1 1
621 0 croak(invalidHandleMsg);
622 }
623 else
624 0 croak(invalidHandleMsg);
625 }
626 else
627 0 croak(invalidHandleMsg);
628 }
629 else
630 0 croak(missingDeviceFileMsg);
631  
632 1 result = ioctl(fd, RTC_ALM_READ, &tm);
633  
634 1 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 1 0 1
635 {
636 1 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 1 1
637 1 XSRETURN(1);
638 }
639 else
640 0 ▶ if (G_ARRAY == GIMME_V)
Branch: 1 branch
BranchTrueFalseTotal
if (G_ARRAY == GIMME_V) 0 0 0
641 {
642 /* called in list context, push time members on stack and do not store them. */
643 0 ▶ EXTEND(SP, 9);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 9); 0 0 0
644 0 mPUSHi(tm.tm_sec);
645 0 mPUSHi(tm.tm_min);
646 0 mPUSHi(tm.tm_hour);
647  
648 0 mPUSHi(tm.tm_mday);
649 0 mPUSHi(tm.tm_mon);
650 0 mPUSHi(tm.tm_year);
651  
652 0 mPUSHi(tm.tm_wday);
653 0 mPUSHi(tm.tm_yday);
654 0 mPUSHi(tm.tm_isdst);
655 0 XSRETURN(9);
656 }
657 else
658 {
659 0 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 0 0 0
660  
661 /* called in void (or scalar) context, save members in the perl object. */
662 0 SV **val = hv_fetch(rtc, "sec", 3, !0);
663  
664 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
665 0 sv_setiv(*val, (IV)(tm.tm_sec));
666 else
667 0 croak(hashAccessFailedMsg);
668  
669 0 val = hv_fetch(rtc, "min", 3, !0);
670 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
671 0 sv_setiv(*val, (IV)(tm.tm_min));
672 else
673 0 croak(hashAccessFailedMsg);
674  
675 0 val = hv_fetch(rtc, "hour", 4, !0);
676 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
677 0 sv_setiv(*val, (IV)(tm.tm_hour));
678 else
679 0 croak(hashAccessFailedMsg);
680  
681 0 val = hv_fetch(rtc, "mday", 4, !0);
682 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
683 0 sv_setiv(*val, (IV)(tm.tm_mday));
684 else
685 0 croak(hashAccessFailedMsg);
686  
687 0 val = hv_fetch(rtc, "mon", 3, !0);
688 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
689 0 sv_setiv(*val, (IV)(tm.tm_mon));
690 else
691 0 croak(hashAccessFailedMsg);
692  
693 0 val = hv_fetch(rtc, "year", 4, !0);
694 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
695 0 sv_setiv(*val, (IV)(tm.tm_year));
696 else
697 0 croak(hashAccessFailedMsg);
698  
699 0 val = hv_fetch(rtc, "wday", 4, !0);
700 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
701 0 sv_setiv(*val, (IV)(tm.tm_wday));
702 else
703 0 croak(hashAccessFailedMsg);
704  
705 0 val = hv_fetch(rtc, "yday", 4, !0);
706 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
707 0 sv_setiv(*val, (IV)(tm.tm_yday));
708 else
709 0 croak(hashAccessFailedMsg);
710  
711 0 val = hv_fetch(rtc, "isdst", 5, !0);
712 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
713 0 sv_setiv(*val, (IV)(tm.tm_isdst));
714 else
715 0 croak(hashAccessFailedMsg);
716  
717 0 ▶ XPUSHu(result);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHu(result); 0 0 0
XPUSHu(result); 0 0 0
718 0 XSRETURN(1);
719 }
720  
721 #endif
722  
723  
724 #if defined(RTC_ALM_SET)
725  
726 void
727 set_alarm(HV *rtc, ...)
728 PROTOTYPE: \*%;$$$$$$$$$
729 PPCODE:
730 1 int args_count = items;
731 1 struct rtc_time tm = { 0, 0, 0, 0, 0, 0, -1, -1, -1 };
732 1 int fd = -1;
733 1 SV **device = hv_fetch(rtc, "device", 6, 0);;
734  
735 1 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 1 0 1
736 {
737 1 IO *file_io = sv_2io(*device);
738  
739 1 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 1 0 1
740 {
741 1 PerlIO *device_perlio = IoIFP(file_io);
742  
743 1 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 1 0 1
744 {
745 1 fd = PerlIO_fileno(device_perlio);
746  
747 1 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 1 1
748 0 croak(invalidHandleMsg);
749 }
750 else
751 0 croak(invalidHandleMsg);
752 }
753 else
754 0 croak(invalidHandleMsg);
755 }
756 else
757 0 croak(missingDeviceFileMsg);
758  
759 1 ▶ if (args_count > 10)
Branch: 1 branch
BranchTrueFalseTotal
if (args_count > 10) 0 1 1
760 0 args_count = 10;
761  
762 1 switch (args_count)
763 {
764 0 case 10:
765 0 ▶ if (tm.tm_isdst = SvIV(ST(9)), SvIOK(ST(9)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_isdst = SvIV(ST(9)), SvIOK(ST(9))) 0 0 0
766 ;
767 else
768 0 croak(numericParamMsg);
769 // fall-through
770 case 9:
771 0 ▶ if (tm.tm_yday = SvIV(ST(8)), SvIOK(ST(8)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_yday = SvIV(ST(8)), SvIOK(ST(8))) 0 0 0
772 ;
773 else
774 0 croak(numericParamMsg);
775 // fall-through
776 case 8:
777 0 ▶ if (tm.tm_wday = SvIV(ST(7)), SvIOK(ST(7)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_wday = SvIV(ST(7)), SvIOK(ST(7))) 0 0 0
778 ;
779 else
780 0 croak(numericParamMsg);
781 // fall-through
782 case 7:
783 0 ▶ if (tm.tm_year = SvIV(ST(6)), SvIOK(ST(6)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_year = SvIV(ST(6)), SvIOK(ST(6))) 0 0 0
784 ;
785 else
786 0 croak(numericParamMsg);
787 // fall-through
788 case 6:
789 0 ▶ if (tm.tm_mon = SvIV(ST(5)), SvIOK(ST(5)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_mon = SvIV(ST(5)), SvIOK(ST(5))) 0 0 0
790 ;
791 else
792 0 croak(numericParamMsg);
793 case 5:
794 0 ▶ if (tm.tm_mday = SvIV(ST(4)), SvIOK(ST(4)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_mday = SvIV(ST(4)), SvIOK(ST(4))) 0 0 0
795 ;
796 else
797 0 croak(numericParamMsg);
798 // fall-through
799 case 4:
800 0 ▶ if (tm.tm_hour = SvIV(ST(3)), SvIOK(ST(3)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_hour = SvIV(ST(3)), SvIOK(ST(3))) 0 0 0
801 ;
802 else
803 0 croak(numericParamMsg);
804 // fall-through
805 case 3:
806 0 ▶ if (tm.tm_min = SvIV(ST(2)), SvIOK(ST(2)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_min = SvIV(ST(2)), SvIOK(ST(2))) 0 0 0
807 ;
808 else
809 0 croak(numericParamMsg);
810 // fall-through
811 case 2:
812 0 ▶ if (tm.tm_sec = SvIV(ST(1)), SvIOK(ST(1)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.tm_sec = SvIV(ST(1)), SvIOK(ST(1))) 0 0 0
813 ;
814 else
815 0 croak(numericParamMsg);
816 0 break;
817 1 case 1:
818 {
819 1 SV **val = hv_fetch(rtc, "isdst", 5, 0);
820  
821 1 ▶ if (*val && (tm.tm_isdst = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_isdst = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_isdst = SvIV(*val), SvIOK(*val))) 1 0 1
822 ;
823 else
824 0 croak(objectFieldsMissingMsg, "isdst");
825  
826 1 val = hv_fetch(rtc, "yday", 4, 0);
827 1 ▶ if (*val && (tm.tm_yday = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_yday = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_yday = SvIV(*val), SvIOK(*val))) 1 0 1
828 ;
829 else
830 0 croak(objectFieldsMissingMsg, "yday");
831  
832 1 val = hv_fetch(rtc, "wday", 4, 0);
833 1 ▶ if (*val && (tm.tm_wday = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_wday = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_wday = SvIV(*val), SvIOK(*val))) 1 0 1
834 ;
835 else
836 0 croak(objectFieldsMissingMsg, "wday");
837  
838 1 val = hv_fetch(rtc, "year", 4, 0);
839 1 ▶ if (*val && (tm.tm_year = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_year = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_year = SvIV(*val), SvIOK(*val))) 1 0 1
840 ;
841 else
842 0 croak(objectFieldsMissingMsg, "year");
843  
844 1 val = hv_fetch(rtc, "mon", 3, 0);
845 1 ▶ if (*val && (tm.tm_mon = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_mon = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_mon = SvIV(*val), SvIOK(*val))) 1 0 1
846 ;
847 else
848 0 croak(objectFieldsMissingMsg, "mon");
849  
850 1 val = hv_fetch(rtc, "mday", 4, 0);
851 1 ▶ if (*val && (tm.tm_mday = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_mday = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_mday = SvIV(*val), SvIOK(*val))) 1 0 1
852 ;
853 else
854 0 croak(objectFieldsMissingMsg, "mday");
855  
856 1 val = hv_fetch(rtc, "hour", 4, 0);
857 1 ▶ if (*val && (tm.tm_hour = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_hour = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_hour = SvIV(*val), SvIOK(*val))) 1 0 1
858 ;
859 else
860 0 croak(objectFieldsMissingMsg, "hour");
861  
862 1 val = hv_fetch(rtc, "min", 3, 0);
863 1 ▶ if (*val && (tm.tm_min = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_min = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_min = SvIV(*val), SvIOK(*val))) 1 0 1
864 ;
865 else
866 0 croak(objectFieldsMissingMsg, "min");
867  
868 1 val = hv_fetch(rtc, "sec", 3, 0);
869 1 ▶ if (*val && (tm.tm_sec = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.tm_sec = SvIV(*val), SvIOK(*val))) 1 0 1
if (*val && (tm.tm_sec = SvIV(*val), SvIOK(*val))) 1 0 1
870 ;
871 else
872 0 croak(objectFieldsMissingMsg, "sec");
873  
874 1 break;
875 }
876 }
877  
878 {
879 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
880 1 int result = ioctl(fd, RTC_ALM_SET, &tm);
881  
882 1 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 1 0 1
883 1 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 1 1
884 else
885 0 ▶ XPUSHu(result);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHu(result); 0 0 0
XPUSHu(result); 0 0 0
886  
887 1 XSRETURN(1);
888 }
889  
890 #endif
891  
892 #if defined(RTC_WKALM_RD)
893  
894 void
895 read_wakeup_alarm(HV *rtc)
896 PROTOTYPE: \%
897 PPCODE:
898 0 struct rtc_wkalrm tm = { 0, 0, { 0, 0, 0, 0, 0, 0, -1, -1, -1 } };
899 0 int fd = -1;
900 0 SV **device = hv_fetch(rtc, "device", 6, 0);;
901 int result;
902  
903 0 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 0 0 0
904 {
905 0 IO *file_io = sv_2io(*device);
906  
907 0 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 0 0 0
908 {
909 0 PerlIO *device_perlio = IoIFP(file_io);
910  
911 0 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 0 0 0
912 {
913 0 fd = PerlIO_fileno(device_perlio);
914  
915 0 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 0 0
916 0 croak(invalidHandleMsg);
917 }
918 else
919 0 croak(invalidHandleMsg);
920 }
921 else
922 0 croak(invalidHandleMsg);
923 }
924 else
925 0 croak(missingDeviceFileMsg);
926  
927 0 result = ioctl(fd, RTC_WKALM_RD, &tm);
928  
929 0 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 0 0 0
930 {
931 0 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 0 0
932 0 XSRETURN(1);
933 }
934 else
935 0 ▶ if (G_ARRAY == GIMME_V)
Branch: 1 branch
BranchTrueFalseTotal
if (G_ARRAY == GIMME_V) 0 0 0
936 {
937 /* called in list context, push time members on stack and do not store them. */
938 0 ▶ EXTEND(SP, 11);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 11); 0 0 0
939 0 mPUSHi(tm.enabled);
940 0 mPUSHi(tm.pending);
941  
942 0 mPUSHi(tm.time.tm_sec);
943 0 mPUSHi(tm.time.tm_min);
944 0 mPUSHi(tm.time.tm_hour);
945  
946 0 mPUSHi(tm.time.tm_mday);
947 0 mPUSHi(tm.time.tm_mon);
948 0 mPUSHi(tm.time.tm_year);
949  
950 0 mPUSHi(tm.time.tm_wday);
951 0 mPUSHi(tm.time.tm_yday);
952 0 mPUSHi(tm.time.tm_isdst);
953 0 XSRETURN(9);
954 }
955 else
956 {
957 0 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 0 0 0
958  
959 /* called in void (or scalar) context, save members in the perl object. */
960 0 SV **val = hv_fetch(rtc, "enabled", 7, !0);
961  
962 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
963 0 sv_setiv(*val, (IV)(tm.enabled));
964 else
965 0 croak(hashAccessFailedMsg);
966  
967 0 val = hv_fetch(rtc, "pending", 7, !0);
968 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
969 0 sv_setiv(*val, (IV)(tm.pending));
970 else
971 0 croak(hashAccessFailedMsg);
972  
973 0 val = hv_fetch(rtc, "sec", 3, !0);
974 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
975 0 sv_setiv(*val, (IV)(tm.time.tm_sec));
976 else
977 0 croak(hashAccessFailedMsg);
978  
979 0 val = hv_fetch(rtc, "min", 3, !0);
980 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
981 0 sv_setiv(*val, (IV)(tm.time.tm_min));
982 else
983 0 croak(hashAccessFailedMsg);
984  
985 0 val = hv_fetch(rtc, "hour", 4, !0);
986 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
987 0 sv_setiv(*val, (IV)(tm.time.tm_hour));
988 else
989 0 croak(hashAccessFailedMsg);
990  
991 0 val = hv_fetch(rtc, "mday", 4, !0);
992 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
993 0 sv_setiv(*val, (IV)(tm.time.tm_mday));
994 else
995 0 croak(hashAccessFailedMsg);
996  
997 0 val = hv_fetch(rtc, "mon", 3, !0);
998 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
999 0 sv_setiv(*val, (IV)(tm.time.tm_mon));
1000 else
1001 0 croak(hashAccessFailedMsg);
1002  
1003 0 val = hv_fetch(rtc, "year", 4, !0);
1004 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
1005 0 sv_setiv(*val, (IV)(tm.time.tm_year));
1006 else
1007 0 croak(hashAccessFailedMsg);
1008  
1009 0 val = hv_fetch(rtc, "wday", 4, !0);
1010 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
1011 0 sv_setiv(*val, (IV)(tm.time.tm_wday));
1012 else
1013 0 croak(hashAccessFailedMsg);
1014  
1015 0 val = hv_fetch(rtc, "yday", 4, !0);
1016 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
1017 0 sv_setiv(*val, (IV)(tm.time.tm_yday));
1018 else
1019 0 croak(hashAccessFailedMsg);
1020  
1021 0 val = hv_fetch(rtc, "isdst", 5, !0);
1022 0 ▶ if (*val)
Branch: 1 branch
BranchTrueFalseTotal
if (*val) 0 0 0
1023 0 sv_setiv(*val, (IV)(tm.time.tm_isdst));
1024 else
1025 0 croak(hashAccessFailedMsg);
1026  
1027 0 ▶ XPUSHu(result);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHu(result); 0 0 0
XPUSHu(result); 0 0 0
1028 0 XSRETURN(1);
1029 }
1030  
1031 #endif
1032  
1033  
1034 #if defined(RTC_WKALM_SET)
1035  
1036 void
1037 set_wakeup_alarm(HV *rtc, ...)
1038 PROTOTYPE: \*%;$$$$$$$$$
1039 PPCODE:
1040 0 int args_count = items;
1041 0 struct rtc_wkalrm tm = { 0, 0, { 0, 0, 0, 0, 0, 0, -1, -1, -1 } };
1042 0 int fd = -1;
1043 0 SV **device = hv_fetch(rtc, "device", 6, 0);;
1044  
1045 0 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 0 0 0
1046 {
1047 0 IO *file_io = sv_2io(*device);
1048  
1049 0 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 0 0 0
1050 {
1051 0 PerlIO *device_perlio = IoIFP(file_io);
1052  
1053 0 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 0 0 0
1054 {
1055 0 fd = PerlIO_fileno(device_perlio);
1056  
1057 0 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 0 0
1058 0 croak(invalidHandleMsg);
1059 }
1060 else
1061 0 croak(invalidHandleMsg);
1062 }
1063 else
1064 0 croak(invalidHandleMsg);
1065 }
1066 else
1067 0 croak(missingDeviceFileMsg);
1068  
1069 0 ▶ if (args_count > 10)
Branch: 1 branch
BranchTrueFalseTotal
if (args_count > 10) 0 0 0
1070 0 args_count = 10;
1071  
1072 0 switch (args_count)
1073 {
1074 0 case 12:
1075 0 ▶ if (tm.time.tm_isdst = SvIV(ST(11)), SvIOK(ST(11)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.time.tm_isdst = SvIV(ST(11)), SvIOK(ST(11))) 0 0 0
1076 ;
1077 else
1078 0 croak(numericParamMsg);
1079 // fall-through
1080 case 11:
1081 0 ▶ if (tm.time.tm_yday = SvIV(ST(10)), SvIOK(ST(10)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.time.tm_yday = SvIV(ST(10)), SvIOK(ST(10))) 0 0 0
1082 ;
1083 else
1084 0 croak(numericParamMsg);
1085 // fall-through
1086 case 10:
1087 0 ▶ if (tm.time.tm_wday = SvIV(ST(9)), SvIOK(ST(9)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.time.tm_wday = SvIV(ST(9)), SvIOK(ST(9))) 0 0 0
1088 ;
1089 else
1090 0 croak(numericParamMsg);
1091 // fall-through
1092 case 9:
1093 0 ▶ if (tm.time.tm_year = SvIV(ST(8)), SvIOK(ST(8)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.time.tm_year = SvIV(ST(8)), SvIOK(ST(8))) 0 0 0
1094 ;
1095 else
1096 0 croak(numericParamMsg);
1097 // fall-through
1098 case 8:
1099 0 ▶ if (tm.time.tm_mon = SvIV(ST(7)), SvIOK(ST(7)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.time.tm_mon = SvIV(ST(7)), SvIOK(ST(7))) 0 0 0
1100 ;
1101 else
1102 0 croak(numericParamMsg);
1103 case 7:
1104 0 ▶ if (tm.time.tm_mday = SvIV(ST(6)), SvIOK(ST(6)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.time.tm_mday = SvIV(ST(6)), SvIOK(ST(6))) 0 0 0
1105 ;
1106 else
1107 0 croak(numericParamMsg);
1108 // fall-through
1109 case 6:
1110 0 ▶ if (tm.time.tm_hour = SvIV(ST(5)), SvIOK(ST(5)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.time.tm_hour = SvIV(ST(5)), SvIOK(ST(5))) 0 0 0
1111 ;
1112 else
1113 0 croak(numericParamMsg);
1114 // fall-through
1115 case 5:
1116 0 ▶ if (tm.time.tm_min = SvIV(ST(4)), SvIOK(ST(4)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.time.tm_min = SvIV(ST(4)), SvIOK(ST(4))) 0 0 0
1117 ;
1118 else
1119 0 croak(numericParamMsg);
1120 // fall-through
1121 case 4:
1122 0 ▶ if (tm.time.tm_sec = SvIV(ST(3)), SvIOK(ST(3)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.time.tm_sec = SvIV(ST(3)), SvIOK(ST(3))) 0 0 0
1123 ;
1124 else
1125 0 croak(numericParamMsg);
1126 // fall-through
1127 case 3:
1128 0 ▶ if (tm.pending = SvIV(ST(2)), SvIOK(ST(2)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.pending = SvIV(ST(2)), SvIOK(ST(2))) 0 0 0
1129 ;
1130 else
1131 0 croak(numericParamMsg);
1132 // fall-through
1133 case 2:
1134 0 ▶ if (tm.enabled = SvIV(ST(1)), SvIOK(ST(1)))
Branch: 1 branch
BranchTrueFalseTotal
if (tm.enabled = SvIV(ST(1)), SvIOK(ST(1))) 0 0 0
1135 ;
1136 else
1137 0 croak(numericParamMsg);
1138 0 break;
1139 0 case 1:
1140 {
1141 0 SV **val = hv_fetch(rtc, "isdst", 5, 0);
1142  
1143 0 ▶ if (*val && (tm.time.tm_isdst = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.time.tm_isdst = SvIV(*val), SvIOK(*val))) 0 0 0
if (*val && (tm.time.tm_isdst = SvIV(*val), SvIOK(*val))) 0 0 0
1144 ;
1145 else
1146 0 croak(objectFieldsMissingMsg, "isdst");
1147  
1148 0 val = hv_fetch(rtc, "yday", 4, 0);
1149 0 ▶ if (*val && (tm.time.tm_yday = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.time.tm_yday = SvIV(*val), SvIOK(*val))) 0 0 0
if (*val && (tm.time.tm_yday = SvIV(*val), SvIOK(*val))) 0 0 0
1150 ;
1151 else
1152 0 croak(objectFieldsMissingMsg, "yday");
1153  
1154 0 val = hv_fetch(rtc, "wday", 4, 0);
1155 0 ▶ if (*val && (tm.time.tm_wday = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.time.tm_wday = SvIV(*val), SvIOK(*val))) 0 0 0
if (*val && (tm.time.tm_wday = SvIV(*val), SvIOK(*val))) 0 0 0
1156 ;
1157 else
1158 0 croak(objectFieldsMissingMsg, "wday");
1159  
1160 0 val = hv_fetch(rtc, "year", 4, 0);
1161 0 ▶ if (*val && (tm.time.tm_year = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.time.tm_year = SvIV(*val), SvIOK(*val))) 0 0 0
if (*val && (tm.time.tm_year = SvIV(*val), SvIOK(*val))) 0 0 0
1162 ;
1163 else
1164 0 croak(objectFieldsMissingMsg, "year");
1165  
1166 0 val = hv_fetch(rtc, "mon", 3, 0);
1167 0 ▶ if (*val && (tm.time.tm_mon = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.time.tm_mon = SvIV(*val), SvIOK(*val))) 0 0 0
if (*val && (tm.time.tm_mon = SvIV(*val), SvIOK(*val))) 0 0 0
1168 ;
1169 else
1170 0 croak(objectFieldsMissingMsg, "mon");
1171  
1172 0 val = hv_fetch(rtc, "mday", 4, 0);
1173 0 ▶ if (*val && (tm.time.tm_mday = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.time.tm_mday = SvIV(*val), SvIOK(*val))) 0 0 0
if (*val && (tm.time.tm_mday = SvIV(*val), SvIOK(*val))) 0 0 0
1174 ;
1175 else
1176 0 croak(objectFieldsMissingMsg, "mday");
1177  
1178 0 val = hv_fetch(rtc, "hour", 4, 0);
1179 0 ▶ if (*val && (tm.time.tm_hour = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.time.tm_hour = SvIV(*val), SvIOK(*val))) 0 0 0
if (*val && (tm.time.tm_hour = SvIV(*val), SvIOK(*val))) 0 0 0
1180 ;
1181 else
1182 0 croak(objectFieldsMissingMsg, "hour");
1183  
1184 0 val = hv_fetch(rtc, "min", 3, 0);
1185 0 ▶ if (*val && (tm.time.tm_min = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.time.tm_min = SvIV(*val), SvIOK(*val))) 0 0 0
if (*val && (tm.time.tm_min = SvIV(*val), SvIOK(*val))) 0 0 0
1186 ;
1187 else
1188 0 croak(objectFieldsMissingMsg, "min");
1189  
1190 0 val = hv_fetch(rtc, "sec", 3, 0);
1191 0 ▶ if (*val && (tm.time.tm_sec = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.time.tm_sec = SvIV(*val), SvIOK(*val))) 0 0 0
if (*val && (tm.time.tm_sec = SvIV(*val), SvIOK(*val))) 0 0 0
1192 ;
1193 else
1194 0 croak(objectFieldsMissingMsg, "sec");
1195  
1196 0 val = hv_fetch(rtc, "pending", 7, 0);
1197 0 ▶ if (*val && (tm.pending = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.pending = SvIV(*val), SvIOK(*val))) 0 0 0
if (*val && (tm.pending = SvIV(*val), SvIOK(*val))) 0 0 0
1198 ;
1199 else
1200 0 croak(objectFieldsMissingMsg, "pending");
1201  
1202 0 val = hv_fetch(rtc, "enabled", 7, 0);
1203 0 ▶ if (*val && (tm.enabled = SvIV(*val), SvIOK(*val)))
Branch: 2 branches
BranchTrueFalseTotal
if (*val && (tm.enabled = SvIV(*val), SvIOK(*val))) 0 0 0
if (*val && (tm.enabled = SvIV(*val), SvIOK(*val))) 0 0 0
1204 ;
1205 else
1206 0 croak(objectFieldsMissingMsg, "enabled");
1207  
1208 0 break;
1209 }
1210  
1211 break;
1212 }
1213  
1214 {
1215 0 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 0 0 0
1216 0 int result = ioctl(fd, RTC_WKALM_SET, &tm);
1217  
1218 0 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 0 0 0
1219 0 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 0 0
1220 else
1221 0 ▶ XPUSHu(result);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHu(result); 0 0 0
XPUSHu(result); 0 0 0
1222  
1223 0 XSRETURN(1);
1224 }
1225  
1226 #endif
1227  
1228 #if defined(RTC_VL_READ)
1229  
1230 void
1231 read_voltage_low_indicator(HV *rtc)
1232 PROTOTYPE: \%
1233 PPCODE:
1234 int result, voltage_low_indicator;
1235 1 int fd = -1;
1236 1 SV **device = hv_fetch(rtc, "device", 6, 0);;
1237  
1238 1 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 1 0 1
1239 {
1240 1 IO *file_io = sv_2io(*device);
1241  
1242 1 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 1 0 1
1243 {
1244 1 PerlIO *device_perlio = IoIFP(file_io);
1245  
1246 1 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 1 0 1
1247 {
1248 1 fd = PerlIO_fileno(device_perlio);
1249  
1250 1 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 1 1
1251 0 croak(invalidHandleMsg);
1252 }
1253 else
1254 0 croak(invalidHandleMsg);
1255 }
1256 else
1257 0 croak(invalidHandleMsg);
1258 }
1259 else
1260 0 croak(missingDeviceFileMsg);
1261  
1262 1 result = ioctl(fd, RTC_VL_READ, &voltage_low_indicator);
1263  
1264 1 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 1 0 1
1265 1 XSRETURN_UNDEF;
1266 else
1267 {
1268 0 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 0 0 0
1269 0 ▶ XPUSHi(voltage_low_indicator);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHi(voltage_low_indicator); 0 0 0
XPUSHi(voltage_low_indicator); 0 0 0
1270 0 XSRETURN(1);
1271 }
1272  
1273 #endif
1274  
1275 #if defined(RTC_VL_CLR)
1276  
1277 void
1278 clear_voltage_low_indicator(HV *rtc)
1279 PROTOTYPE: \%
1280 PPCODE:
1281 1 int fd = -1;
1282 1 SV **device = hv_fetch(rtc, "device", 6, 0);;
1283  
1284 1 ▶ if (device)
Branch: 1 branch
BranchTrueFalseTotal
if (device) 1 0 1
1285 {
1286 1 IO *file_io = sv_2io(*device);
1287  
1288 1 ▶ if (file_io)
Branch: 1 branch
BranchTrueFalseTotal
if (file_io) 1 0 1
1289 {
1290 1 PerlIO *device_perlio = IoIFP(file_io);
1291  
1292 1 ▶ if (device_perlio)
Branch: 1 branch
BranchTrueFalseTotal
if (device_perlio) 1 0 1
1293 {
1294 1 fd = PerlIO_fileno(device_perlio);
1295  
1296 1 ▶ if (fd < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (fd < 0) 0 1 1
1297 0 croak(invalidHandleMsg);
1298 }
1299 else
1300 0 croak(invalidHandleMsg);
1301 }
1302 else
1303 0 croak(invalidHandleMsg);
1304 }
1305 else
1306 0 croak(missingDeviceFileMsg);
1307  
1308 {
1309 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
1310 1 int result = ioctl(fd, RTC_VL_CLR, 0);
1311  
1312 1 ▶ if (result < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (result < 0) 1 0 1
1313 1 ▶ XPUSHs(&PL_sv_undef);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(&PL_sv_undef); 0 1 1
1314 else
1315 0 ▶ XPUSHu(result);
Branch: 2 branches
BranchTrueFalseTotal
XPUSHu(result); 0 0 0
XPUSHu(result); 0 0 0
1316  
1317 1 XSRETURN(1);
1318 }
1319  
1320 #endif
« blib/lib/Linux/RTC/Ioctl.pm ↑ Summary lib/Linux/RTC/const-xs.inc »