Skip to content

Commit c628e4e

Browse files
Add safe pragma to systems module
1 parent 09cb1ae commit c628e4e

18 files changed

+434
-382
lines changed

src/system/Clock.sac

Lines changed: 80 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,65 @@
1+
#pragma safe
12
class Clock;
23

34
external classtype;
45

5-
use String : {string};
6+
use String: { string };
67

78
export all;
89

9-
1010
external typedef time;
1111

12-
objdef Clock TheClock = create_TheClock( );
12+
objdef Clock TheClock = create_TheClock();
1313

14-
external Clock create_TheClock( );
14+
external Clock create_TheClock();
1515
#pragma effect World::TheWorld
16+
#pragma linkobj "src/Clock/clock.o"
1617
#pragma linksign [0]
17-
#pragma linkobj "src/Clock/clock.o"
18-
19-
20-
21-
/*
22-
* Functions for generating time values.
23-
*/
18+
/*
19+
* Functions for generating time values.
20+
*/
2421

25-
external time to_time( int secs);
22+
external time to_time(int secs);
23+
#pragma linkobj "src/Clock/to_time.o"
2624
#pragma linkname "SACto_time"
27-
#pragma linkobj "src/Clock/to_time.o"
2825
#pragma linksign [0,1]
29-
/*
30-
* Convert seconds since the Epoch into a time value
26+
/*
27+
* Convert seconds since the Epoch into a time value.
3128
*/
3229

3330
external time gettime();
3431
#pragma effect TheClock
32+
#pragma linkobj "src/Clock/gettime.o"
3533
#pragma linkname "SACgettime"
36-
#pragma linkobj "src/Clock/gettime.o"
3734
#pragma linksign [0]
3835
/* Get the current system time.
3936
*
40-
* Note: Although the system clock of course is not effected by a call
41-
* to this function, the pragma effect is used instead of touch.
42-
* This is done to achieve a sequentialization which is necessary
43-
* since the state of the clock is not constant although it may
44-
* not be modified from within a SAC program.
37+
* Note: Although the system clock of course is not effected by a call
38+
* to this function, the pragma effect is used instead of touch.
39+
* This is done to achieve a sequentialization which is necessary
40+
* since the state of the clock is not constant although it may
41+
* not be modified from within a SAC program.
4542
*/
4643

47-
4844
external time, bool mktime(int YEAR, int MON, int DAY, int HOUR, int MIN, int SEC);
45+
#pragma linkobj "src/Clock/mktime.o"
4946
#pragma linkname "SACmktime"
50-
#pragma linkobj "src/Clock/mktime.o"
5147
#pragma linksign [0,1,2,3,4,5,6,7]
52-
/* Generate a time value for a given time. The boolean result informs
53-
* about success or failure (The given time may not be specified as
54-
* time value).
48+
/*
49+
* Generate a time value for a given time. The boolean result informs
50+
* about success or failure (The given time may not be specified as
51+
* time value).
5552
*/
5653

57-
58-
59-
/*
60-
* Functions for decomposing time values.
61-
*/
62-
54+
/******************************************************************************
55+
*
56+
* Functions for decomposing time values.
57+
*
58+
******************************************************************************/
6359

6460
external int sec(time T);
61+
#pragma linkobj "src/Clock/extracttime.o"
6562
#pragma linkname "SACsec"
66-
#pragma linkobj "src/Clock/extracttime.o"
6763
#pragma linksign [0,1]
6864
/*
6965
* The number of seconds after the minute, normally in
@@ -72,146 +68,140 @@ external int sec(time T);
7268
*/
7369

7470
external int min(time T);
71+
#pragma linkobj "src/Clock/extracttime.o"
7572
#pragma linkname "SACmin"
76-
#pragma linkobj "src/Clock/extracttime.o"
7773
#pragma linksign [0,1]
7874
/*
79-
* The number of minutes after the hour, in the range 0 to 59.
75+
* The number of minutes after the hour, in the range 0 to 59.
8076
*/
8177

8278
external int hour(time T);
79+
#pragma linkobj "src/Clock/extracttime.o"
8380
#pragma linkname "SAChour"
84-
#pragma linkobj "src/Clock/extracttime.o"
8581
#pragma linksign [0,1]
8682
/*
87-
* The number of hours past midnight, in the range 0 to 23.
83+
* The number of hours past midnight, in the range 0 to 23.
8884
*/
8985

9086
external int mday(time T);
87+
#pragma linkobj "src/Clock/extracttime.o"
9188
#pragma linkname "SACmday"
92-
#pragma linkobj "src/Clock/extracttime.o"
9389
#pragma linksign [0,1]
9490
/*
95-
* The day of the month, in the range 1 to 31.
91+
* The day of the month, in the range 1 to 31.
9692
*/
9793

9894
external int mon(time T);
95+
#pragma linkobj "src/Clock/extracttime.o"
9996
#pragma linkname "SACmon"
100-
#pragma linkobj "src/Clock/extracttime.o"
10197
#pragma linksign [0,1]
10298
/*
103-
* The number of months since January, in the range 0 to 11.
99+
* The number of months since January, in the range 0 to 11.
104100
*/
105101

106102
external int year(time T);
103+
#pragma linkobj "src/Clock/extracttime.o"
107104
#pragma linkname "SACyear"
108-
#pragma linkobj "src/Clock/extracttime.o"
109105
#pragma linksign [0,1]
110106
/*
111-
* The year, starting with 0=1900.
107+
* The year, starting with 0=1900.
112108
*/
113109

114110
external int wday(time T);
111+
#pragma linkobj "src/Clock/extracttime.o"
115112
#pragma linkname "SACwday"
116-
#pragma linkobj "src/Clock/extracttime.o"
117113
#pragma linksign [0,1]
118114
/*
119-
* The number of days since Sunday, in the range 0 to 6
115+
* The number of days since Sunday, in the range 0 to 6
120116
*/
121-
117+
122118
external int yday(time T);
119+
#pragma linkobj "src/Clock/extracttime.o"
123120
#pragma linkname "SACyday"
124-
#pragma linkobj "src/Clock/extracttime.o"
125121
#pragma linksign [0,1]
126122
/*
127-
* The number of days since January 1, in the range 0 to 365.
123+
* The number of days since January 1, in the range 0 to 365.
128124
*/
129125

130126
external int, int, int clock(time T);
127+
#pragma linkobj "src/Clock/date.o"
131128
#pragma linkname "SACclock"
132-
#pragma linkobj "src/Clock/date.o"
133129
#pragma linksign [0,1,2,3]
134130
/*
135-
* Extract hours, minutes, and seconds from time value T.
131+
* Extract hours, minutes, and seconds from time value T.
136132
*/
137133

138134
external int, int, int date(time T);
135+
#pragma linkobj "src/Clock/date.o"
139136
#pragma linkname "SACdate"
140-
#pragma linkobj "src/Clock/date.o"
141137
#pragma linksign [0,1,2,3]
142138
/*
143-
* Extract year, month, and day from time value T.
139+
* Extract year, month, and day from time value T.
144140
*/
145141

146-
147-
148-
/*
149-
* Functions for getting additional information about the time.
150-
*/
151-
142+
/******************************************************************************
143+
*
144+
* Functions for getting additional information about the time.
145+
*
146+
******************************************************************************/
152147

153148
external int isdst(time T);
149+
#pragma linkobj "src/Clock/isdst.o"
154150
#pragma linkname "SACisdst"
155-
#pragma linkobj "src/Clock/isdst.o"
156151
#pragma linksign [0,1]
157152
/*
158-
* A flag that indicates whether daylight saving time
159-
* is in effect at the time described. The value is
160-
* positive if daylight saving time is in effect, zero
161-
* if it is not, and negative if the information is
153+
* A flag that indicates whether daylight saving time is in effect at
154+
* the time described. The value is positive if daylight saving time
155+
* is in effect, zero if it is not, and negative if the information is
162156
* not available.
163157
*/
164158

165159
external bool isleap(int YEAR);
160+
#pragma linkobj "src/Clock/isleap.o"
166161
#pragma linkname "SACisleap"
167-
#pragma linkobj "src/Clock/isleap.o"
168162
#pragma linksign [0,1]
169163

170164
external bool isleap(time T);
165+
#pragma linkobj "src/Clock/isleap.o"
171166
#pragma linkname "SACisleapt"
172-
#pragma linkobj "src/Clock/isleap.o"
173167
#pragma linksign [0,1]
174168
/*
175-
* Test the given year YEAR or the time value T respectively
169+
* Test the given year YEAR or the time value T respectively
176170
* for being a leap year.
177171
*/
178172

179173
external double difftime(time T1, time T0);
174+
#pragma linkobj "src/Clock/difftime.o"
180175
#pragma linkname "SACdifftime"
181-
#pragma linkobj "src/Clock/difftime.o"
182176
#pragma linksign [0,1,2]
183177
/*
184-
* This function returns the number of seconds
185-
* elapsed between time T1 and time T0.
178+
* The number of seconds elapsed between time T1 and time T0.
186179
*/
187180

188-
189-
190-
/*
191-
* Functions for converting time values and string representations.
192-
*/
193-
181+
/******************************************************************************
182+
*
183+
* Functions for converting time values and string representations.
184+
*
185+
******************************************************************************/
194186

195187
external string ctime(time T);
188+
#pragma linkobj "src/Clock/ctime.o"
196189
#pragma linkname "SACctime"
197-
#pragma linkobj "src/Clock/ctime.o"
198190
#pragma linksign [0,1]
199191
/*
200-
* The ctime() function converts the time T into
201-
* a string of the form
202-
*
203-
* "Wed Jun 30 21:49:08 1993\n"
192+
* The ctime() function converts the time T into a string of the form
193+
* `Wed Jun 30 21:49:08 1993'
204194
*
205-
* The abbreviations for the days of the week are `Sun',
206-
* `Mon', `Tue', `Wed', `Thu', `Fri', and `Sat'.
207-
* The abbreviations for the months are `Jan', `Feb', `Mar', `Apr',
208-
* `May', `Jun', `Jul', `Aug', `Sep', `Oct', `Nov', and `Dec'
209-
*
195+
* The abbreviations for the days of the week are:
196+
* `Mon', `Tue', `Wed', `Thu', `Fri', `Sat', and `Sun'.
197+
* The abbreviations for the months are:
198+
* `Jan', `Feb', `Mar', `Apr', `May', `Jun', `Jul',
199+
* `Aug', `Sep', `Oct', `Nov', and `Dec'.
210200
*/
211201

212202
external string strftime(int LEN, string FORMAT, time T);
203+
#pragma linkobj "src/Clock/strftime.o"
213204
#pragma linkname "SACstrftime"
214-
#pragma linkobj "src/Clock/strftime.o"
215205
#pragma linksign [0,1,2,3]
216206
/*
217207
* Convert the time T into a string of maximum length LEN
@@ -220,9 +210,9 @@ external string strftime(int LEN, string FORMAT, time T);
220210
* If an error occurs the returned string is empty.
221211
*/
222212

223-
external time, string strptime(string S, string FORMAT);
213+
external time, string strptime(string S, string FORMAT);
214+
#pragma linkobj "src/Clock/strptime.o"
224215
#pragma linkname "SACstrptime"
225-
#pragma linkobj "src/Clock/strptime.o"
226216
#pragma linksign [0,1,2,3]
227217
/*
228218
* Complementary function to strftime(),
@@ -235,14 +225,11 @@ external time, string strptime(string S, string FORMAT);
235225
* and the returned time is 0.
236226
*/
237227

238-
239-
external void sleep(int SECONDS);
228+
external void sleep(int SECONDS);
240229
#pragma effect World::TheWorld
230+
#pragma linkobj "src/Clock/sleep.o"
241231
#pragma linkname "SACsleep"
242-
#pragma linkobj "src/Clock/sleep.o"
243232
#pragma linksign [1]
244233
/*
245234
* Make the calling thread sleep until SECONDS seconds have elapsed.
246235
*/
247-
248-

0 commit comments

Comments
 (0)