]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/timepps.h
This commit was generated by cvs2svn to compensate for changes in r41227,
[FreeBSD/FreeBSD.git] / include / timepps.h
1 /*
2  * ----------------------------------------------------------------------------
3  * "THE BEER-WARE LICENSE" (Revision 42):
4  * <phk@FreeBSD.org> wrote this file.  As long as you retain this notice you
5  * can do whatever you want with this stuff. If we meet some day, and you think
6  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
7  * ----------------------------------------------------------------------------
8  *
9  * $Id$
10  *
11  * The is a FreeBSD protype version of the "draft-mogul-pps-api-02.txt" 
12  * specification for Pulse Per Second timing interfaces.
13  *
14  */
15
16 #ifndef _TIME_PPS_H_
17 #define _TIME_PPS_H_
18
19 #include <sys/timepps.h>
20
21 int time_pps_create(int filedes, pps_handle_t *handle);
22 int time_pps_destroy(pps_handle_t handle);
23 int time_pps_setparams(pps_handle_t handle, const pps_params_t *ppsparams);
24 int time_pps_getparams(pps_handle_t handle, pps_params_t *ppsparams);
25 int time_pps_getcap(pps_handle_t handle, int *mode);
26 int time_pps_fetch(pps_handle_t handle, pps_info_t *ppsinfobuf);
27 int time_pps_wait(pps_handle_t handle, const struct timespec *timeout, 
28         pps_info_t *ppsinfobuf);
29
30 __inline int
31 time_pps_create(int filedes, pps_handle_t *handle)
32 {
33         int error;
34
35         *handle = -1;
36         error = ioctl(filedes, PPS_IOC_CREATE, 0);
37         if (error < 0) 
38                 return (-1);
39         *handle = filedes;
40         return (0);
41 }
42
43 __inline int
44 time_pps_destroy(pps_handle_t handle)
45 {
46         return (ioctl(handle, PPS_IOC_DESTROY, 0));
47 }
48
49 __inline int
50 time_pps_setparams(pps_handle_t handle, const pps_params_t *ppsparams)
51 {
52         return (ioctl(handle, PPS_IOC_SETPARAMS, ppsparams));
53 }
54
55 __inline int
56 time_pps_getparams(pps_handle_t handle, pps_params_t *ppsparams)
57 {
58         return (ioctl(handle, PPS_IOC_GETPARAMS, ppsparams));
59 }
60
61 __inline int 
62 time_pps_getcap(pps_handle_t handle, int *mode)
63 {
64         return (ioctl(handle, PPS_IOC_GETCAP, mode));
65 }
66
67 __inline int
68 time_pps_fetch(pps_handle_t handle, pps_info_t *ppsinfobuf)
69 {
70         return (ioctl(handle, PPS_IOC_FETCH, ppsinfobuf));
71 }
72
73 __inline int
74 time_pps_wait(pps_handle_t handle, const struct timespec *timeout,
75         pps_info_t *ppsinfobuf)
76 {
77         int error;
78         struct pps_wait_args arg;
79
80         arg.timeout = *timeout;
81         error = ioctl(handle, PPS_IOC_WAIT, &arg);
82         *ppsinfobuf = arg.pps_info_buf;
83         return (error);
84 }
85
86 #endif /* !_TIME_PPS_H_ */