Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / multimedia / tvtime / patches / patch-aa
blobcf9f7bbb8e13c0e81426ce8b05d93dc5a433f48b
1 $NetBSD$
3 --- src/rtctimer.c.orig 2003-10-27 09:49:39.000000000 -0500
4 +++ src/rtctimer.c
5 @@ -27,7 +27,9 @@
6  #include <fcntl.h>
7  #include <math.h>
8  #include <sys/ioctl.h>
9 +#ifdef __linux__
10  #include <linux/rtc.h>
11 +#endif
12  #include "rtctimer.h"
14  struct rtctimer_s
15 @@ -41,6 +43,7 @@ struct rtctimer_s
17  rtctimer_t *rtctimer_new( int verbose )
18  {
19 +#ifdef __linux__
20      rtctimer_t *rtctimer = malloc( sizeof( rtctimer_t ) );
21      if( !rtctimer ) return 0;
23 @@ -74,17 +77,23 @@ rtctimer_t *rtctimer_new( int verbose )
24      rtctimer->current_hz = 0;
25      rtctimer->usecs = 0;
26      return rtctimer;
27 +#else
28 +    return NULL;
29 +#endif
30  }
32  void rtctimer_delete( rtctimer_t *rtctimer )
33  {
34 +#ifdef __linux__
35      rtctimer_stop_clock( rtctimer );
36      close( rtctimer->rtc_fd );
37      free( rtctimer );
38 +#endif
39  }
41  int rtctimer_next_tick( rtctimer_t *rtctimer )
42  {
43 +#ifdef __linux__
44      unsigned long rtc_data;
45      struct pollfd pfd;
46      pfd.fd = rtctimer->rtc_fd;
47 @@ -108,11 +117,13 @@ again:
48      }
50      read( rtctimer->rtc_fd, &rtc_data, sizeof( rtc_data ) );
51 +#endif
52      return 1;
53  }
55  int rtctimer_set_interval( rtctimer_t *rtctimer, int hz )
56  {
57 +#ifdef __linux__
58      int restart;
60      if( hz == rtctimer->current_hz ) {
61 @@ -136,11 +147,13 @@ int rtctimer_set_interval( rtctimer_t *r
62          rtctimer_start_clock( rtctimer );
63      }
65 +#endif
66      return 1;
67  }
69  int rtctimer_start_clock( rtctimer_t *rtctimer )
70  {
71 +#ifdef __linux__
72      if( !rtctimer->rtc_running ) {
73          if( ioctl( rtctimer->rtc_fd, RTC_PIE_ON, 0 ) < 0 ) {
74              if( rtctimer->verbose ) {
75 @@ -152,10 +165,12 @@ int rtctimer_start_clock( rtctimer_t *rt
76          rtctimer->rtc_running = 1;
77      }
78      return rtctimer->rtc_running;
79 +#endif
80  }
82  int rtctimer_stop_clock( rtctimer_t *rtctimer )
83  {
84 +#ifdef __linux__
85      int was_running = rtctimer->rtc_running;
87      if( rtctimer->rtc_running ) {
88 @@ -170,16 +185,23 @@ int rtctimer_stop_clock( rtctimer_t *rtc
89      }
91      return was_running;
92 +#else
93 +    return 0;
94 +#endif
95  }
97  int rtctimer_get_resolution( rtctimer_t *rtctimer )
98  {
99 +#ifdef __linux__
100      return rtctimer->current_hz;
101 +#endif
104  int rtctimer_get_usecs( rtctimer_t *rtctimer )
106 +#ifdef __linux__
107      return rtctimer->usecs;
108 +#endif
111  int set_realtime_priority( int max )