ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/macos_util.cpp
(Generate patch)

Comparing BasiliskII/src/macos_util.cpp (file contents):
Revision 1.7 by cebix, 2001-02-02T20:52:57Z vs.
Revision 1.8 by cebix, 2001-07-06T17:36:06Z

# Line 106 | Line 106 | void FileDiskLayout(loff_t size, uint8 *
106  
107   uint32 DebugUtil(uint32 Selector)
108   {
109 <        switch (Selector)
110 <                {
111 <        case duDebuggerGetMax:
112 <                return 3;
113 <        case duDebuggerEnter:
114 <                return 0;
115 <        case duDebuggerExit:
116 <                return 0;
117 <        case duDebuggerPoll:
118 <                ADBInterrupt();
119 <                return 0;
120 <        default:
121 <                return (uint32) paramErr;
122 <                }
109 >        switch (Selector) {
110 >                case duDebuggerGetMax:
111 >                        return 3;
112 >                case duDebuggerEnter:
113 >                        return 0;
114 >                case duDebuggerExit:
115 >                        return 0;
116 >                case duDebuggerPoll:
117 >                        ADBInterrupt();
118 >                        return 0;
119 >                default:
120 >                        return (uint32) paramErr;
121 >        }
122   }
123  
124 +
125 + /*
126 + *  Convert time_t value to MacOS time (seconds since 1.1.1904)
127 + */
128 +
129 + uint32 TimeToMacTime(time_t t)
130 + {
131 +        // This code is taken from glibc 2.2
132 +
133 +        // Convert to number of seconds elapsed since 1-Jan-1904
134 +        struct tm *local = localtime(&t);
135 +        const int TM_EPOCH_YEAR = 1900;
136 +        const int MAC_EPOCH_YEAR = 1904;
137 +        int a4 = ((local->tm_year + TM_EPOCH_YEAR) >> 2) - !(local->tm_year & 3);
138 +        int b4 = (MAC_EPOCH_YEAR >> 2) - !(MAC_EPOCH_YEAR & 3);
139 +        int a100 = a4 / 25 - (a4 % 25 < 0);
140 +        int b100 = b4 / 25 - (b4 % 25 < 0);
141 +        int a400 = a100 >> 2;
142 +        int b400 = b100 >> 2;
143 +        int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
144 +        uint32 days = local->tm_yday + 365 * (local->tm_year - 4) + intervening_leap_days;
145 +        return local->tm_sec + 60 * (local->tm_min + 60 * (local->tm_hour + 24 * days));
146 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines