1/* { dg-do compile } */
2/* { dg-options "-Os -mlock -mswape -mrtsc -fno-reorder-blocks" } */
3
4/* This caused an ICE in arc_ifcvt when the 1->3 state change was not
5   implemented for TYPE_UNCOND_BRANCH in arc_ccfsm_post_advance.  */
6
7typedef long __kernel_long_t;
8typedef __kernel_long_t __kernel_time_t;
9
10struct timespec {
11 __kernel_time_t tv_sec;
12 long tv_nsec;
13};
14
15
16struct module;
17struct device {
18 struct device *parent;
19};
20
21struct rtc_time {
22 int tm_sec;
23 int tm_min;
24 int tm_hour;
25 int tm_mday;
26 int tm_mon;
27 int tm_year;
28 int tm_wday;
29 int tm_yday;
30 int tm_isdst;
31};
32struct rtc_wkalrm {
33 unsigned char enabled;
34 unsigned char pending;
35 struct rtc_time time;
36};
37
38struct rtc_class_ops {
39 int (*open)(struct device *);
40 void (*release)(struct device *);
41 int (*ioctl)(struct device *, unsigned int, unsigned long);
42 int (*read_time)(struct device *, struct rtc_time *);
43 int (*set_time)(struct device *, struct rtc_time *);
44 int (*read_alarm)(struct device *, struct rtc_wkalrm *);
45 int (*set_alarm)(struct device *, struct rtc_wkalrm *);
46  //int (*proc)(struct device *, struct seq_file *);
47 int (*set_mmss)(struct device *, unsigned long secs);
48 int (*read_callback)(struct device *, int data);
49 int (*alarm_irq_enable)(struct device *, unsigned int enabled);
50};
51
52struct rtc_device
53{
54 struct device dev;
55 struct module *owner;
56
57 int id;
58 char name[20];
59
60 const struct rtc_class_ops *ops;
61  // struct mutex ops_lock;
62
63  // struct cdev char_dev;
64 unsigned long flags;
65
66 unsigned long irq_data;
67  //spinlock_t irq_lock;
68  //wait_queue_head_t irq_queue;
69  //struct fasync_struct *async_queue;
70
71  //struct rtc_task *irq_task;
72  //spinlock_t irq_task_lock;
73 int irq_freq;
74 int max_user_freq;
75
76  //struct timerqueue_head timerqueue;
77  //struct rtc_timer aie_timer;
78  //struct rtc_timer uie_rtctimer;
79  //struct hrtimer pie_timer;
80 int pie_enabled;
81  //struct work_struct irqwork;
82
83 int uie_unsupported;
84
85
86  //struct work_struct uie_task;
87  //struct timer_list uie_timer;
88
89 unsigned int oldsecs;
90 unsigned int uie_irq_active:1;
91 unsigned int stop_uie_polling:1;
92 unsigned int uie_task_active:1;
93 unsigned int uie_timer_active:1;
94
95};
96
97extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm);
98extern struct rtc_device *rtc_class_open(const char *name);
99extern void rtc_class_close(struct rtc_device *rtc);
100
101
102int rtc_set_ntp_time(struct timespec now)
103{
104 struct rtc_device *rtc;
105 struct rtc_time tm;
106 int err = -19;
107
108 if (now.tv_nsec < (1000000000L >> 1))
109  rtc_time_to_tm(now.tv_sec, &tm);
110 else
111  rtc_time_to_tm(now.tv_sec + 1, &tm);
112
113 rtc = rtc_class_open("rtc0");
114 if (rtc) {
115
116
117  if (rtc->ops && (rtc->ops->set_time || rtc->ops->set_mmss))
118   err = rtc_set_time(rtc, &tm);
119  rtc_class_close(rtc);
120 }
121
122 return err;
123}
124