ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/AmigaOS/timer_amiga.cpp
Revision: 1.3
Committed: 1999-11-01T16:24:13Z (24 years, 8 months ago) by cebix
Branch: MAIN
CVS Tags: snapshot-22121999, release-0_8-1, snapshot-02111999
Changes since 1.2: +10 -8 lines
Log Message:
- AmigaOS: removed support for SAS/C
- AmigaOS: sys_amiga.cpp: supports 64-bit device access and respects
  device block size on writes
- AmigaOS: added support for resource forks and Finder info for ExtFS
- AmigaOS: added "ExtFS" gadget to prefs editor
- protection mask for all open()/creat()/mkdir() calls is now 0666 or
  0777

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * timer_amiga.cpp - Time Manager emulation, AmigaOS specific stuff
3     *
4     * Basilisk II (C) 1997-1999 Christian Bauer
5     *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19     */
20    
21     #include <exec/types.h>
22     #include <devices/timer.h>
23     #include <proto/timer.h>
24     #include <proto/intuition.h>
25    
26     #include "sysdeps.h"
27     #include "timer.h"
28    
29     #define DEBUG 0
30     #include "debug.h"
31    
32    
33     /*
34     * Return microseconds since boot (64 bit)
35     */
36    
37     void Microseconds(uint32 &hi, uint32 &lo)
38     {
39     D(bug("Microseconds\n"));
40     struct timeval tv;
41     GetSysTime(&tv);
42 cebix 1.3 uint64 tl = (uint64)tv.tv_secs * 1000000 + tv.tv_micro;
43     hi = tl >> 32;
44     lo = tl;
45 cebix 1.1 }
46    
47    
48     /*
49     * Return local date/time in Mac format (seconds since 1.1.1904)
50     */
51    
52     uint32 TimerDateTime(void)
53     {
54     ULONG secs;
55     ULONG mics;
56     CurrentTime(&secs, &mics);
57     return secs + TIME_OFFSET;
58     }
59    
60    
61     /*
62     * Get current time
63     */
64    
65     void timer_current_time(tm_time_t &t)
66     {
67     GetSysTime(&t);
68     }
69    
70    
71     /*
72     * Add times
73     */
74    
75     void timer_add_time(tm_time_t &res, tm_time_t a, tm_time_t b)
76     {
77     res = a;
78     AddTime(&res, &b);
79     }
80    
81    
82     /*
83     * Subtract times
84     */
85    
86     void timer_sub_time(tm_time_t &res, tm_time_t a, tm_time_t b)
87     {
88     res = a;
89     SubTime(&res, &b);
90     }
91    
92    
93     /*
94     * Compare times (<0: a < b, =0: a = b, >0: a > b)
95     */
96    
97     int timer_cmp_time(tm_time_t a, tm_time_t b)
98     {
99     return CmpTime(&b, &a);
100     }
101    
102    
103     /*
104     * Convert Mac time value (>0: microseconds, <0: microseconds) to tm_time_t
105     */
106    
107     void timer_mac2host_time(tm_time_t &res, int32 mactime)
108     {
109     if (mactime > 0) {
110     res.tv_secs = mactime / 1000; // Time in milliseconds
111     res.tv_micro = (mactime % 1000) * 1000;
112     } else {
113     res.tv_secs = -mactime / 1000000; // Time in negative microseconds
114     res.tv_micro = -mactime % 1000000;
115     }
116     }
117    
118    
119     /*
120     * Convert positive tm_time_t to Mac time value (>0: microseconds, <0: microseconds)
121     * A negative input value for hosttime results in a zero return value
122     * As long as the microseconds value fits in 32 bit, it must not be converted to milliseconds!
123     */
124    
125     int32 timer_host2mac_time(tm_time_t hosttime)
126     {
127     if (hosttime.tv_secs < 0)
128     return 0;
129 cebix 1.3 else {
130     uint64 t = (uint64)hosttime.tv_secs * 1000000 + hosttime.tv_micro;
131     if (t > 0x7fffffff)
132     return t / 1000; // Time in milliseconds
133     else
134     return -t; // Time in negative microseconds
135     }
136 cebix 1.1 }