Mercurial > ~darius > hgwebdir.cgi > stm32temp
annotate syscalls.c @ 59:488085e0c7e1
Don't print extra newlines when cat'ing a file.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 08 Apr 2013 23:10:47 +0930 |
parents | 0e7d687a2322 |
children |
rev | line source |
---|---|
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
1 /* |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
2 * syscalls.c |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
3 * |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
4 * Created on: 03.12.2009 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
5 * Author: Martin Thomas, 3BSD license |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
6 */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
7 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
8 #include <stdio.h> |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
9 #include <reent.h> |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
10 #include <errno.h> |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
11 #include <stdlib.h> /* abort */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
12 #include <sys/types.h> |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
13 #include <sys/stat.h> |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
14 #include <sys/time.h> |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
15 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
16 #include "comm.h" |
30
435c6330896c
Set tv_usec in gettimeofday() by using the prescaler counter.
Daniel O'Connor <darius@dons.net.au>
parents:
23
diff
changeset
|
17 #include "rtc.h" |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
18 #include "stm32f10x.h" /* for _get_PSP() from core_cm3.h*/ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
19 |
36
2ecde7a4bc55
Don't use evil errno kludge, write a function that libc can use.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
20 int * |
2ecde7a4bc55
Don't use evil errno kludge, write a function that libc can use.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
21 __errno(void) { |
2ecde7a4bc55
Don't use evil errno kludge, write a function that libc can use.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
22 static int _errno; |
2ecde7a4bc55
Don't use evil errno kludge, write a function that libc can use.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
23 |
2ecde7a4bc55
Don't use evil errno kludge, write a function that libc can use.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
24 return(&errno); |
2ecde7a4bc55
Don't use evil errno kludge, write a function that libc can use.
Daniel O'Connor <darius@dons.net.au>
parents:
33
diff
changeset
|
25 } |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
26 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
27 int |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
28 _kill(int pid, int sig) { |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
29 pid = pid; sig = sig; /* avoid warnings */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
30 errno = EINVAL; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
31 return -1; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
32 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
33 |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
34 void |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
35 _exit(int status) { |
23
2bce4dbf52b8
Use CR/LF to printfs (should probably do the conversion in _write)
Daniel O'Connor <darius@dons.net.au>
parents:
3
diff
changeset
|
36 printf("_exit called with parameter %d\r\n", status); |
2bce4dbf52b8
Use CR/LF to printfs (should probably do the conversion in _write)
Daniel O'Connor <darius@dons.net.au>
parents:
3
diff
changeset
|
37 __disable_irq(); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
38 while(1) |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
39 ; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
40 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
41 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
42 int |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
43 _getpid(void) { |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
44 return 1; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
45 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
46 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
47 extern char _end; /* Defined by the linker */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
48 static char *heap_end; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
49 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
50 char * |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
51 get_heap_end(void) { |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
52 return (char*) heap_end; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
53 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
54 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
55 char * |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
56 get_stack_top(void) { |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
57 /* Use MSP (vs PSP) - the processor is in Thread mode out of reset */ |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
58 return (char*) __get_MSP(); |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
59 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
60 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
61 caddr_t |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
62 _sbrk(int incr) { |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
63 char *prev_heap_end; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
64 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
65 if (heap_end == 0) { |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
66 heap_end = &_end; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
67 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
68 prev_heap_end = heap_end; |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
69 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
70 if (heap_end + incr > get_stack_top()) { |
23
2bce4dbf52b8
Use CR/LF to printfs (should probably do the conversion in _write)
Daniel O'Connor <darius@dons.net.au>
parents:
3
diff
changeset
|
71 printf("Heap and stack collision\r\n"); |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
72 abort(); |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
73 } |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
74 |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
75 heap_end += incr; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
76 return (caddr_t) prev_heap_end; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
77 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
78 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
79 int |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
80 _close(int file) { |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
81 file = file; /* avoid warning */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
82 return -1; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
83 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
84 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
85 int |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
86 _fstat(int file, struct stat *st) { |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
87 file = file; /* avoid warning */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
88 st->st_mode = S_IFCHR; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
89 return 0; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
90 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
91 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
92 int |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
93 _isatty(int file) { |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
94 file = file; /* avoid warning */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
95 return 1; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
96 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
97 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
98 int |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
99 _lseek(int file, int ptr, int dir) { |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
100 file = file; /* avoid warning */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
101 ptr = ptr; /* avoid warning */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
102 dir = dir; /* avoid warning */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
103 return 0; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
104 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
105 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
106 int |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
107 _read(int file, char *ptr, int len) { |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
108 file = file; /* avoid warning */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
109 ptr = ptr; /* avoid warning */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
110 len = len; /* avoid warning */ |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
111 return 0; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
112 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
113 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
114 int |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
115 _write(int file, char *ptr, int len) { |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
116 int todo; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
117 |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
118 for (todo = 0; todo < len; todo++) { |
46
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
36
diff
changeset
|
119 if (file == 1 || file == 2) |
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
36
diff
changeset
|
120 if (*ptr == '\n') |
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
36
diff
changeset
|
121 comm_put('\r'); |
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
36
diff
changeset
|
122 comm_put(*ptr); |
5b7d21698a80
When writing to stdout/stderr translate \n to \r\n.
Daniel O'Connor <darius@dons.net.au>
parents:
36
diff
changeset
|
123 ptr++; |
0
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
124 } |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
125 return len; |
c59513fd84fb
Initial commit of STM32 test code.
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
126 } |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
127 |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
128 int |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
129 _gettimeofday_r(struct _reent *reent __attribute__((unused)), struct timeval *tp, void *tzp __attribute__((unused))) { |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
130 tp->tv_sec = RTC_GetCounter(); |
30
435c6330896c
Set tv_usec in gettimeofday() by using the prescaler counter.
Daniel O'Connor <darius@dons.net.au>
parents:
23
diff
changeset
|
131 tp->tv_usec = RTC_PS2USEC(RTC_GetDivider()); |
435c6330896c
Set tv_usec in gettimeofday() by using the prescaler counter.
Daniel O'Connor <darius@dons.net.au>
parents:
23
diff
changeset
|
132 |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
133 return 0; |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
134 } |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
135 |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
136 int |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
137 settimeofday(const struct timeval *tp, const struct timezone *tzp __attribute__((unused))) { |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
138 RTC_SetCounter(tp->tv_sec); |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
139 |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
140 return 0; |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
141 } |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
142 |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
143 clock_t |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
144 _clock (void) { |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
145 return RTC_GetCounter(); |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
146 } |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
147 |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
148 void |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
149 __tz_lock (void) { |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
150 } |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
151 |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
152 |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
153 void |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
154 __tz_unlock (void) { |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
155 } |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
156 |
33
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
157 /* Set tzinfo directly so we don't need tzset() which requires getenv() */ |
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
158 #ifdef USE_UTC |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
159 static __tzinfo_type tzinfo = {1, 0, |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
160 { {'J', 0, 0, 0, 0, (time_t)0, 0L }, |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
161 {'J', 0, 0, 0, 0, (time_t)0, 0L } |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
162 } |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
163 }; |
33
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
164 #else |
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
165 /* ACST (south) |
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
166 * Switch from DST 3am 1st Sunday of April: -9.5 hours to UTC |
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
167 * Switch to DST 2am 1st Sunday October: -10.5 hours to UTC |
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
168 * |
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
169 * Copied from http://www.sourceware.org/ml/newlib/2008/msg00311.html |
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
170 */ |
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
171 static __tzinfo_type tzinfo = {0, 0, { |
58
0e7d687a2322
Get timezone offsets right.
Daniel O'Connor <darius@dons.net.au>
parents:
46
diff
changeset
|
172 {'M', 4, 5, 0, 10800, (time_t)0, -34200L }, |
0e7d687a2322
Get timezone offsets right.
Daniel O'Connor <darius@dons.net.au>
parents:
46
diff
changeset
|
173 {'M', 10, 5, 0, 7200, (time_t)0, -37800L } |
33
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
174 } |
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
175 }; |
d3b7d4964807
Create a TZ info structure for ACST and use it when printing times.
Daniel O'Connor <darius@dons.net.au>
parents:
30
diff
changeset
|
176 #endif |
3
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
177 |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
178 __tzinfo_type * |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
179 __gettzinfo (void) { |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
180 return &tzinfo; |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
181 } |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
182 |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
183 /* Stub, required for strftime?! */ |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
184 int |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
185 _open(const char *name __attribute__((unused)), int mode __attribute__((unused)), ...) { |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
186 return -1; |
74e9b3baac1e
Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
0
diff
changeset
|
187 } |