author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 14 May 2010 17:13:29 +0300 | |
changeset 109 | b3a1d9898418 |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32test\bench\t_dhry.cpp |
|
15 |
// * "DHRYSTONE" Benchmark Program |
|
16 |
// * Version: C/1 |
|
17 |
// * Date: 12/01/84, RESULTS updated 10/22/85 |
|
18 |
// * Author: Reinhold P. Weicker, CACM Vol 27, No 10, 10/84 pg. 1013 |
|
19 |
// * Translated from ADA by Rick Richardson |
|
20 |
// * Every method to preserve ADA-likeness has been used, |
|
21 |
// * at the expense of C-ness. |
|
22 |
// * Compile: cc -O dry.c -o drynr : No registers |
|
23 |
// * cc -O -DREG=register dry.c -o dryr : Registers |
|
24 |
// * Defines: Defines are provided for old C compiler's |
|
25 |
// * which don't have enums, and can't assign structures. |
|
26 |
// * The time(2) function is library dependant; One is |
|
27 |
// * provided for CI-C86. Your compiler may be different. |
|
28 |
// * The LOOPS define is initially set for 50000 loops. |
|
29 |
// * If you have a machine with large integers and is |
|
30 |
// * very fast, please change this number to 500000 to |
|
31 |
// * get better accuracy. Please select the way to |
|
32 |
// * measure the execution time using the TIME define. |
|
33 |
// * For single user machines, time(2) is adequate. For |
|
34 |
// * multi-user machines where you cannot get single-user |
|
35 |
// * access, use the times(2) function. If you have |
|
36 |
// * neither, use a stopwatch in the dead of night. |
|
37 |
// * Use a "printf" at the point marked "start timer" |
|
38 |
// * to begin your timings. DO NOT use the UNIX "time(1)" |
|
39 |
// * command, as this will measure the total time to |
|
40 |
// * run this program, which will (erroneously) include |
|
41 |
// * the time to malloc(3) storage and to compute the |
|
42 |
// * time it takes to do nothing. |
|
43 |
// * Run: drynr; dryr |
|
44 |
// * Results: If you get any new machine/OS results, please send to: |
|
45 |
// * {ihnp4,vax135,..}!houxm!vaximile!rer |
|
46 |
// * and thanks to all that do. Space prevents listing |
|
47 |
// * the names of those who have provided some of these |
|
48 |
// * results. |
|
49 |
// * Note: I order the list in increasing performance of the |
|
50 |
// * "with registers" benchmark. If the compiler doesn't |
|
51 |
// * provide register variables, then the benchmark |
|
52 |
// * is the same for both REG and NOREG. I'm not going |
|
53 |
// * to list a compiler in a better place because if it |
|
54 |
// * had register variables it might do better. No |
|
55 |
// * register variables is a big loss in my book. |
|
56 |
// * PLEASE: Send complete information about the machine type, |
|
57 |
// * clock speed, OS and C manufacturer/version. If |
|
58 |
// * the machine is modified, tell me what was done. |
|
59 |
// * Otherwise, I won't include it in this list. My |
|
60 |
// * favorite flame on this subject was a machine that |
|
61 |
// * was listed as an IBM PC/XT 8086-9.54Mhz. That must |
|
62 |
// * have been some kind of co-processor board that ran |
|
63 |
// * the benchmark, not the XT. Tell me what it was! |
|
64 |
// * MACHINE MICROPROCESSOR OPERATING COMPILER DHRYSTONES/SEC. |
|
65 |
// * TYPE SYSTEM NO REG REGS |
|
66 |
// * IBM PC/XT 8088-4.77Mhz PC/IX cc 257 287 |
|
67 |
// * Cosmos 68000-8Mhz UniSoft cc 305 322 |
|
68 |
// * IBM PC/XT 8088-4.77Mhz VENIX/86 2.0 cc 297 324 |
|
69 |
// * IBM PC 8088-4.77Mhz MSDOS 2.0 b16cc 2.0 310 340 |
|
70 |
// * IBM PC 8088-4.77Mhz MSDOS 2.0 CI-C86 2.20M 390 390 |
|
71 |
// * IBM PC/XT 8088-4.77Mhz PCDOS 2.1 Lattice 2.15 403 - @ |
|
72 |
// * PDP-11/34 - UNIX V7M cc 387 438 |
|
73 |
// * Onyx C8002 Z8000-4Mhz IS/1 1.1 (V7) cc 476 511 |
|
74 |
// * ATT PC6300 8086-8Mhz MSDOS 2.11 b16cc 2.0 632 684 |
|
75 |
// * IBM PC/AT 80286-6Mhz PCDOS 3.0 CI-C86 2.1 666 684 |
|
76 |
// * Macintosh 68000-7.8Mhz 2M Mac Rom Mac C 32 bit int 694 704 |
|
77 |
// * Macintosh 68000-7.7Mhz - MegaMax C 2.0 661 709 |
|
78 |
// * NEC PC9801F 8086-8Mhz PCDOS 2.11 Lattice 2.15 768 - @ |
|
79 |
// * ATT PC6300 8086-8Mhz MSDOS 2.11 CI-C86 2.20M 769 769 |
|
80 |
// * ATT 3B2/300 WE32000-?Mhz UNIX 5.0.2 cc 735 806 |
|
81 |
// * IBM PC/AT 80286-6Mhz PCDOS 3.0 MS 3.0(large) 833 847 LM |
|
82 |
// * VAX 11/750 - Unix 4.2bsd cc 862 877 |
|
83 |
// * IBM PC/AT 80286-6Mhz PCDOS 3.0 MS 3.0(small) 1063 1086 |
|
84 |
// * ATT PC7300 68010-10Mhz UNIX 5.2 cc 1041 1111 |
|
85 |
// * ATT PC6300+ 80286-6Mhz MSDOS 3.1 b16cc 2.0 1111 1219 |
|
86 |
// * Sun2/120 68010-10Mhz Sun 4.2BSD cc 1136 1219 |
|
87 |
// * IBM PC/AT 80286-6Mhz PCDOS 3.0 CI-C86 2.20M 1219 1219 |
|
88 |
// * MASSCOMP 500 68010-10MHz RTU V3.0 cc (V3.2) 1156 1238 |
|
89 |
// * Cyb DataMate 68010-12.5Mhz Uniplus 5.0 Unisoft cc 1162 1250 |
|
90 |
// * PDP 11/70 - UNIX 5.2 cc 1162 1250 |
|
91 |
// * IBM PC/AT 80286-6Mhz PCDOS 3.1 Lattice 2.15 1250 - @ |
|
92 |
// * IBM PC/AT 80286-7.5Mhz VENIX/86 2.1 cc 1190 1315 * |
|
93 |
// * Sun2/120 68010-10Mhz Standalone cc 1219 1315 |
|
94 |
// * ATT 3B2/400 WE32100-?Mhz UNIX 5.2 cc 1315 1315 |
|
95 |
// * HP-110 8086-5.33Mhz MSDOS 2.11 Aztec-C 1282 1351 ? |
|
96 |
// * IBM PC/AT 80286-6Mhz ? ? 1250 1388 ? |
|
97 |
// * ATT PC6300+ 80286-6Mhz MSDOS 3.1 CI-C86 2.20M 1428 1428 |
|
98 |
// * Cyb DataMate 68010-12.5Mhz Uniplus 5.0 Unisoft cc 1470 1562 S |
|
99 |
// * VAX 11/780 - UNIX 5.2 cc 1515 1562 |
|
100 |
// * MicroVAX-II - - - 1562 1612 |
|
101 |
// * ATT 3B20 - UNIX 5.2 cc 1515 1724 |
|
102 |
// * HP9000-500 B series CPU HP-UX 4.02 cc 1724 - |
|
103 |
// * IBM PC/STD 80286-8Mhz ? ? 1724 1785 |
|
104 |
// * Gould PN6005 - UTX 1.1(4.2BSD) cc 1675 1964 |
|
105 |
// * VAX 11/785 - UNIX 5.2 cc 2083 2083 |
|
106 |
// * VAX 11/785 - VMS VAX-11 C 2.0 2083 2083 |
|
107 |
// * SUN 3/75 68020-16.67Mhz SUN 4.2 V3 cc 3333 3571 |
|
108 |
// * Sun 3/180 68020-16.67Mhz Sun 4.2 cc 3333 3846 |
|
109 |
// * MC 5400 68020-16.67MHz RTU V3.0 cc (V4.0) 3952 4054 |
|
110 |
// * SUN-3/160C 68020-16.67Mhz Sun3.0ALPHA1 Un*x 3333 4166 |
|
111 |
// * Gould PN9080 - UTX-32 1.1c cc - 4629 |
|
112 |
// * MC 5600/5700 68020-16.67MHz RTU V3.0 cc (V4.0) 4504 4746 % |
|
113 |
// * VAX 8600 - VMS VAX-11 C 2.0 7142 7142 |
|
114 |
// * Amdahl 470 V/8 ? ? - 15015 |
|
115 |
// * Amdahl 580 - UTS 5.0 Rel 1.2 cc Ver. 1.5 23076 23076 |
|
116 |
// * Amdahl 5860 ? ? - 28355 |
|
117 |
// * * 15Mhz crystal substituted for original 12Mhz; |
|
118 |
// * + This Macintosh was upgraded from 128K to 512K in such a way that |
|
119 |
// * the new 384K of memory is not slowed down by video generator accesses. |
|
120 |
// * % Single processor; MC == MASSCOMP |
|
121 |
// * & Seattle Telecom STD-286 board |
|
122 |
// * @ vanilla Lattice compiler used with MicroPro standard library |
|
123 |
// * S Shorts used instead of ints |
|
124 |
// * LM Large Memory Model. (Otherwise, all 80x8x results are small model) |
|
125 |
// * ? I don't trust results marked with '?'. These were sent to me with |
|
126 |
// * either incomplete information, or with times that just don't make sense. |
|
127 |
// * If anybody can confirm these figures, please respond. |
|
128 |
// * The following program contains statements of a high-level programming |
|
129 |
// * language (C) in a distribution considered representative: |
|
130 |
// * assignments 53% |
|
131 |
// * control statements 32% |
|
132 |
// * procedure, function calls 15% |
|
133 |
// * 100 statements are dynamically executed. The program is balanced with |
|
134 |
// * respect to the three aspects: |
|
135 |
// * - statement type |
|
136 |
// * - operand type (for simple data types) |
|
137 |
// * - operand access |
|
138 |
// * operand global, local, parameter, or constant. |
|
139 |
// * The combination of these three aspects is balanced only approximately. |
|
140 |
// * The program does not compute anything meaningfull, but it is |
|
141 |
// * syntactically and semantically correct. |
|
142 |
// |
|
143 |
// |
|
144 |
||
145 |
||
146 |
#include <e32test.h> |
|
147 |
#include <e32std.h> |
|
148 |
#include <e32std_private.h> |
|
149 |
||
150 |
//Accuracy of timings and human fatigue controlled by next two lines |
|
151 |
#if defined(__EPOC32) |
|
152 |
#define LOOPS 50000 /* Use this for slow or 16 bit machines */ |
|
153 |
#else |
|
154 |
#define LOOPS 10000000 /* Use this for faster machines */ |
|
155 |
#endif |
|
156 |
||
157 |
// Compiler dependent options |
|
158 |
#undef NOENUM /* Define if compiler has no enum's */ |
|
159 |
#undef NOSTRUCTASSIGN /* Define if compiler can't assign structures */ |
|
160 |
||
161 |
// define only one of the next three defines |
|
162 |
#define NOTIME /* Define if no time() function in library */ |
|
163 |
//#define TIMES /* Use times(2) time function */ |
|
164 |
//#define TIME /* Use time(2) time function */ |
|
165 |
||
166 |
// define the granularity of your times(2) function (when used) |
|
167 |
//#define HZ 60 /* times(2) returns 1/60 second (most) */ |
|
168 |
//#define HZ 100 /* times(2) returns 1/100 second (WECo) */ |
|
169 |
||
170 |
||
171 |
||
172 |
#ifdef NOSTRUCTASSIGN |
|
173 |
#define structassign(d,s) memcpy(&(d),&(s),sizeof(d)) |
|
174 |
#else |
|
175 |
#define structassign(d,s) d=s |
|
176 |
#endif |
|
177 |
||
178 |
#ifdef NOENUM |
|
179 |
#define Ident1 1 |
|
180 |
#define Ident2 2 |
|
181 |
#define Ident3 3 |
|
182 |
#define Ident4 4 |
|
183 |
#define Ident5 5 |
|
184 |
typedef int Enumeration; |
|
185 |
#else |
|
186 |
typedef enum {Ident1, Ident2, Ident3, Ident4, Ident5} Enumeration; |
|
187 |
#endif |
|
188 |
||
189 |
typedef int OneToThirty; |
|
190 |
typedef int OneToFifty; |
|
191 |
typedef char CapitalLetter; |
|
192 |
typedef char String30[31]; |
|
193 |
typedef int Array1Dim[51]; |
|
194 |
typedef int Array2Dim[51][51]; |
|
195 |
||
196 |
struct Record |
|
197 |
{ |
|
198 |
struct Record *PtrComp; |
|
199 |
Enumeration Discr; |
|
200 |
Enumeration EnumComp; |
|
201 |
OneToFifty IntComp; |
|
202 |
String30 StringComp; |
|
203 |
}; |
|
204 |
||
205 |
typedef struct Record RecordType; |
|
206 |
typedef RecordType* RecordPtr; |
|
207 |
typedef int boolean; |
|
208 |
||
209 |
#define NULL 0 |
|
210 |
#define TRUE 1 |
|
211 |
#define FALSE 0 |
|
212 |
||
213 |
#ifndef REG |
|
214 |
#define REG |
|
215 |
#endif |
|
216 |
||
217 |
extern Enumeration Func1(CapitalLetter,CapitalLetter); |
|
218 |
extern boolean Func2(String30, String30); |
|
219 |
||
220 |
#ifdef TIMES |
|
221 |
#include <sys/types.h> |
|
222 |
#include <sys/times.h> |
|
223 |
#endif |
|
224 |
||
225 |
int strcmp(const char* aSrc, const char* aDst); |
|
226 |
char* strcpy(char* aDest, const char* aSrc); |
|
227 |
void Proc0(); |
|
228 |
void Proc1(REG RecordPtr); |
|
229 |
void Proc2(OneToFifty*); |
|
230 |
void Proc3(RecordPtr*); |
|
231 |
void Proc4(); |
|
232 |
void Proc5(); |
|
233 |
void Proc6(REG Enumeration, REG Enumeration*); |
|
234 |
void Proc7(OneToFifty, OneToFifty, OneToFifty*); |
|
235 |
void Proc8(Array1Dim, Array2Dim, OneToFifty, OneToFifty); |
|
236 |
#ifdef NOTIME |
|
237 |
TInt64 time(); |
|
238 |
#endif |
|
239 |
LOCAL_D RTest test(_L("DHRY")); |
|
240 |
||
241 |
GLDEF_C TInt E32Main() |
|
242 |
{ |
|
243 |
test.Title(); |
|
244 |
test.Start(_L("Running dhrystone benchmark")); |
|
245 |
Proc0(); |
|
246 |
test.End(); |
|
247 |
return(KErrNone); |
|
248 |
} |
|
249 |
||
250 |
/* |
|
251 |
* Package 1 |
|
252 |
*/ |
|
253 |
int IntGlob; |
|
254 |
boolean BoolGlob; |
|
255 |
char Char1Glob; |
|
256 |
char Char2Glob; |
|
257 |
Array1Dim Array1Glob; |
|
258 |
Array2Dim Array2Glob; |
|
259 |
RecordPtr PtrGlb; |
|
260 |
RecordPtr PtrGlbNext; |
|
261 |
||
262 |
void Proc0() |
|
263 |
{ |
|
264 |
OneToFifty IntLoc1; |
|
265 |
REG OneToFifty IntLoc2; |
|
266 |
OneToFifty IntLoc3=1; |
|
267 |
REG char CharIndex; |
|
268 |
Enumeration EnumLoc; |
|
269 |
String30 String1Loc; |
|
270 |
String30 String2Loc; |
|
271 |
||
272 |
#ifdef NOTIME |
|
273 |
TInt64 starttime; |
|
274 |
TInt64 benchtime; |
|
275 |
TInt64 nulltime; |
|
276 |
register unsigned int i; |
|
277 |
starttime=time(); |
|
278 |
for (i = 0; i < LOOPS; ++i) |
|
279 |
; |
|
280 |
nulltime = time()-starttime; /* Computes overhead of looping */ |
|
281 |
#endif |
|
282 |
#ifdef TIME |
|
283 |
REG char CharLoc; |
|
284 |
long time(); |
|
285 |
long starttime; |
|
286 |
long benchtime; |
|
287 |
long nulltime; |
|
288 |
register unsigned int i; |
|
289 |
starttime = time(0); |
|
290 |
for (i = 0; i < LOOPS; ++i) |
|
291 |
; |
|
292 |
nulltime = time(0) - starttime; /* Computes overhead of looping */ |
|
293 |
#endif |
|
294 |
#ifdef TIMES |
|
295 |
REG char CharLoc; |
|
296 |
time_t starttime; |
|
297 |
time_t benchtime; |
|
298 |
time_t nulltime; |
|
299 |
struct tms tms; |
|
300 |
register unsigned int i; |
|
301 |
times(&tms); starttime = tms.tms_utime; |
|
302 |
for (i = 0; i < LOOPS; ++i) |
|
303 |
; |
|
304 |
times(&tms); |
|
305 |
nulltime = tms.tms_utime - starttime; /* Computes overhead of looping */ |
|
306 |
#endif |
|
307 |
||
308 |
// PtrGlbNext = (RecordPtr) malloc(sizeof(RecordType)); |
|
309 |
PtrGlbNext = (RecordPtr) new Record; |
|
310 |
// PtrGlb = (RecordPtr) malloc(sizeof(RecordType)); |
|
311 |
PtrGlb = (RecordPtr) new Record; |
|
312 |
PtrGlb->PtrComp = PtrGlbNext; |
|
313 |
PtrGlb->Discr = Ident1; |
|
314 |
PtrGlb->EnumComp = Ident3; |
|
315 |
PtrGlb->IntComp = 40; |
|
316 |
strcpy(String2Loc, "DHRYSTONE PROGRAM, SOME STRING"); |
|
317 |
||
318 |
// Start the timer |
|
319 |
#ifdef NOTIME |
|
320 |
starttime = time(); |
|
321 |
#endif |
|
322 |
#ifdef TIME |
|
323 |
starttime = time(0); |
|
324 |
#endif |
|
325 |
#ifdef TIMES |
|
326 |
times(&tms); starttime = tms.tms_utime; |
|
327 |
#endif |
|
328 |
for (i = 0; i < LOOPS; ++i) |
|
329 |
{ |
|
330 |
||
331 |
Proc5(); |
|
332 |
Proc4(); |
|
333 |
IntLoc1 = 2; |
|
334 |
IntLoc2 = 3; |
|
335 |
strcpy(String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING"); |
|
336 |
EnumLoc = Ident2; |
|
337 |
BoolGlob = ! Func2(String1Loc, String2Loc); |
|
338 |
while (IntLoc1 < IntLoc2) |
|
339 |
{ |
|
340 |
IntLoc3 = 5 * IntLoc1 - IntLoc2; |
|
341 |
Proc7(IntLoc1, IntLoc2, &IntLoc3); |
|
342 |
++IntLoc1; |
|
343 |
} |
|
344 |
Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3); |
|
345 |
Proc1(PtrGlb); |
|
346 |
for (CharIndex = 'A'; CharIndex <= Char2Glob; ++CharIndex) |
|
347 |
if (EnumLoc == Func1(CharIndex, 'C')) |
|
348 |
Proc6(Ident1, &EnumLoc); |
|
349 |
IntLoc3 = IntLoc2 * IntLoc1; |
|
350 |
IntLoc2 = IntLoc3 / IntLoc1; |
|
351 |
IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1; |
|
352 |
Proc2(&IntLoc1); |
|
353 |
||
354 |
/***************** |
|
355 |
-- Stop Timer -- |
|
356 |
*****************/ |
|
357 |
} |
|
358 |
#ifdef TIME |
|
359 |
benchtime = time(0) - starttime - nulltime; |
|
360 |
printf("Dhrystone time for %ld passes = %ld\n", (long) LOOPS, benchtime); |
|
361 |
printf("This machine benchmarks at %ld dhrystones/second\n", |
|
362 |
((long) LOOPS) / benchtime); |
|
363 |
#endif |
|
364 |
#ifdef TIMES |
|
365 |
times(&tms); |
|
366 |
benchtime = tms.tms_utime - starttime - nulltime; |
|
367 |
printf("Dhrystone time for %ld passes = %ld\n", (long) LOOPS, benchtime/HZ); |
|
368 |
printf("This machine benchmarks at %ld dhrystones/second\n", |
|
369 |
((long) LOOPS) * HZ / benchtime); |
|
370 |
#endif |
|
371 |
#ifdef NOTIME |
|
372 |
TInt64 timenow = time(); |
|
373 |
benchtime = (timenow - starttime - nulltime)/1000000; |
|
374 |
TInt bench=I64INT(benchtime); |
|
375 |
test.Printf(_L("Dhrystone time for %d passes = %d\n"), LOOPS, bench); |
|
376 |
test.Printf(_L("This machine benchmarks at %d dhrystones per second\n"), LOOPS/bench); |
|
377 |
test.Printf(_L("Press any key to exit (or wait 20 seconds)")); |
|
378 |
{ |
|
379 |
TRequestStatus keyStat; |
|
380 |
test.Console()->Read(keyStat); |
|
381 |
RTimer timer; |
|
382 |
test(timer.CreateLocal()==KErrNone); |
|
383 |
TRequestStatus timerStat; |
|
384 |
timer.After(timerStat,20*1000000); |
|
385 |
User::WaitForRequest(timerStat,keyStat); |
|
386 |
if(keyStat!=KRequestPending) |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
387 |
(void)test.Console()->KeyCode(); |
0 | 388 |
timer.Cancel(); |
389 |
test.Console()->ReadCancel(); |
|
390 |
User::WaitForAnyRequest(); |
|
391 |
} |
|
392 |
#endif |
|
393 |
} |
|
394 |
||
395 |
void Proc1 (REG RecordPtr PtrParIn) |
|
396 |
{ |
|
397 |
#define NextRecord (*(PtrParIn->PtrComp)) |
|
398 |
||
399 |
structassign(NextRecord, *PtrGlb); |
|
400 |
PtrParIn->IntComp = 5; |
|
401 |
NextRecord.IntComp = PtrParIn->IntComp; |
|
402 |
NextRecord.PtrComp = PtrParIn->PtrComp; |
|
403 |
Proc3((RecordPtr*)NextRecord.PtrComp); //Jane - has to cast this |
|
404 |
if (NextRecord.Discr == Ident1) |
|
405 |
{ |
|
406 |
NextRecord.IntComp = 6; |
|
407 |
Proc6(PtrParIn->EnumComp, &NextRecord.EnumComp); |
|
408 |
NextRecord.PtrComp = PtrGlb->PtrComp; |
|
409 |
Proc7(NextRecord.IntComp, 10, &NextRecord.IntComp); |
|
410 |
} |
|
411 |
else |
|
412 |
structassign(*PtrParIn, NextRecord); |
|
413 |
||
414 |
#undef NextRecord |
|
415 |
} |
|
416 |
||
417 |
void Proc2(OneToFifty* IntParIO) |
|
418 |
{ |
|
419 |
REG OneToFifty IntLoc=0; |
|
420 |
REG Enumeration EnumLoc=Ident3; |
|
421 |
||
422 |
IntLoc = *IntParIO + 10; |
|
423 |
for(;;) |
|
424 |
{ |
|
425 |
if (Char1Glob == 'A') |
|
426 |
{ |
|
427 |
--IntLoc; |
|
428 |
*IntParIO = IntLoc - IntGlob; |
|
429 |
EnumLoc = Ident1; |
|
430 |
} |
|
431 |
if (EnumLoc == Ident1) |
|
432 |
break; |
|
433 |
} |
|
434 |
} |
|
435 |
||
436 |
void Proc3(RecordPtr* PtrParOut) |
|
437 |
{ |
|
438 |
if (PtrGlb != NULL) |
|
439 |
*PtrParOut = PtrGlb->PtrComp; |
|
440 |
else |
|
441 |
IntGlob = 100; |
|
442 |
Proc7(10, IntGlob, &PtrGlb->IntComp); |
|
443 |
} |
|
444 |
||
445 |
void Proc4() |
|
446 |
{ |
|
447 |
REG boolean BoolLoc; |
|
448 |
||
449 |
BoolLoc = Char1Glob == 'A'; |
|
450 |
BoolLoc |= BoolGlob; |
|
451 |
Char2Glob = 'B'; |
|
452 |
} |
|
453 |
||
454 |
void Proc5() |
|
455 |
{ |
|
456 |
Char1Glob = 'A'; |
|
457 |
BoolGlob = FALSE; |
|
458 |
} |
|
459 |
||
460 |
extern boolean Func3(REG Enumeration EnumParIn); |
|
461 |
||
462 |
void Proc6(REG Enumeration EnumParIn, REG Enumeration* EnumParOut) |
|
463 |
||
464 |
{ |
|
465 |
*EnumParOut = EnumParIn; |
|
466 |
if (! Func3(EnumParIn) ) |
|
467 |
*EnumParOut = Ident4; |
|
468 |
switch (EnumParIn) |
|
469 |
{ |
|
470 |
case Ident1: *EnumParOut = Ident1; break; |
|
471 |
case Ident2: if (IntGlob > 100) *EnumParOut = Ident1; |
|
472 |
else *EnumParOut = Ident4; |
|
473 |
break; |
|
474 |
case Ident3: *EnumParOut = Ident2; break; |
|
475 |
case Ident4: break; |
|
476 |
case Ident5: *EnumParOut = Ident3; |
|
477 |
} |
|
478 |
} |
|
479 |
||
480 |
void Proc7(OneToFifty IntParI1, OneToFifty IntParI2, OneToFifty* IntParOut) |
|
481 |
{ |
|
482 |
REG OneToFifty IntLoc; |
|
483 |
||
484 |
IntLoc = IntParI1 + 2; |
|
485 |
*IntParOut = IntParI2 + IntLoc; |
|
486 |
} |
|
487 |
||
488 |
void Proc8(Array1Dim Array1Par, Array2Dim Array2Par, OneToFifty IntParI1, OneToFifty IntParI2) |
|
489 |
{ |
|
490 |
REG OneToFifty IntLoc; |
|
491 |
REG OneToFifty IntIndex; |
|
492 |
||
493 |
IntLoc = IntParI1 + 5; |
|
494 |
Array1Par[IntLoc] = IntParI2; |
|
495 |
Array1Par[IntLoc+1] = Array1Par[IntLoc]; |
|
496 |
Array1Par[IntLoc+30] = IntLoc; |
|
497 |
for (IntIndex = IntLoc; IntIndex <= (IntLoc+1); ++IntIndex) |
|
498 |
Array2Par[IntLoc][IntIndex] = IntLoc; |
|
499 |
++Array2Par[IntLoc][IntLoc-1]; |
|
500 |
Array2Par[IntLoc+20][IntLoc] = Array1Par[IntLoc]; |
|
501 |
IntGlob = 5; |
|
502 |
} |
|
503 |
||
504 |
Enumeration Func1(CapitalLetter CharPar1, CapitalLetter CharPar2) |
|
505 |
||
506 |
{ |
|
507 |
REG CapitalLetter CharLoc1; |
|
508 |
REG CapitalLetter CharLoc2; |
|
509 |
||
510 |
CharLoc1 = CharPar1; |
|
511 |
CharLoc2 = CharLoc1; |
|
512 |
if (CharLoc2 != CharPar2) |
|
513 |
return (Ident1); |
|
514 |
else |
|
515 |
return (Ident2); |
|
516 |
} |
|
517 |
||
518 |
boolean Func2(String30 StrParI1, String30 StrParI2) |
|
519 |
{ |
|
520 |
REG OneToThirty IntLoc=0; |
|
521 |
REG CapitalLetter CharLoc=0; |
|
522 |
||
523 |
IntLoc = 1; |
|
524 |
while (IntLoc <= 1) |
|
525 |
if (Func1(StrParI1[IntLoc], StrParI2[IntLoc+1]) == Ident1) |
|
526 |
{ |
|
527 |
CharLoc = 'A'; |
|
528 |
++IntLoc; |
|
529 |
} |
|
530 |
if (CharLoc >= 'W' && CharLoc <= 'Z') |
|
531 |
IntLoc = 7; |
|
532 |
if (CharLoc == 'X') |
|
533 |
return(TRUE); |
|
534 |
else |
|
535 |
{ |
|
536 |
if (strcmp(StrParI1, StrParI2) > 0) |
|
537 |
{ |
|
538 |
IntLoc += 7; |
|
539 |
return (TRUE); |
|
540 |
} |
|
541 |
else |
|
542 |
return (FALSE); |
|
543 |
} |
|
544 |
} |
|
545 |
||
546 |
boolean Func3(REG Enumeration EnumParIn) |
|
547 |
{ |
|
548 |
REG Enumeration EnumLoc; |
|
549 |
||
550 |
EnumLoc = EnumParIn; |
|
551 |
if (EnumLoc == Ident3) return (TRUE); |
|
552 |
return (FALSE); |
|
553 |
} |
|
554 |
||
555 |
#ifdef NOSTRUCTASSIGN |
|
556 |
memcpy(d, s, l) |
|
557 |
register char *d; |
|
558 |
register char *s; |
|
559 |
int l; |
|
560 |
{ |
|
561 |
while (l--) *d++ = *s++; |
|
562 |
} |
|
563 |
#endif |
|
564 |
||
565 |
/* |
|
566 |
* Library function for compilers with no time(2) function in the |
|
567 |
* library. |
|
568 |
*/ |
|
569 |
#ifdef NOTIME |
|
570 |
||
571 |
TInt64 time() |
|
572 |
// |
|
573 |
// EPOC32 time function - don't use around midnight |
|
574 |
// |
|
575 |
{ |
|
576 |
// long t; |
|
577 |
// struct regval {unsigned int ax,bx,cx,dx,si,di,ds,es; } regs; |
|
578 |
// regs.ax = 0x2c00; |
|
579 |
// sysint21(®s, ®s); |
|
580 |
// t = ((regs.cx>>8)*60L + (regs.cx & 0xff))*60L + (regs.dx>>8); |
|
581 |
// if (p) *p = t; |
|
582 |
// return t; |
|
583 |
||
584 |
||
585 |
TTime timeNow; |
|
586 |
timeNow.HomeTime(); |
|
587 |
return(timeNow.Int64()); |
|
588 |
} |
|
589 |
||
590 |
||
591 |
#endif |
|
592 |
||
593 |
char* strcpy(char* aDst, const char* aSrc) |
|
594 |
{ |
|
595 |
||
596 |
char* cp = aDst; |
|
597 |
while((*cp++ = *aSrc++)!=0) |
|
598 |
; /* Copy src over dst */ |
|
599 |
||
600 |
return(aDst); |
|
601 |
} |
|
602 |
||
603 |
int strcmp(const char* aSrc, const char* aDst) |
|
604 |
{ |
|
605 |
int ret=0 ; |
|
606 |
||
607 |
while( (ret = *(unsigned char*)aSrc - *(unsigned char*)aDst)==0 && *aDst) |
|
608 |
++aSrc, ++aDst; |
|
609 |
||
610 |
if (ret<0) |
|
611 |
ret=-1 ; |
|
612 |
else if (ret>0) |
|
613 |
ret=1 ; |
|
614 |
||
615 |
return(ret); |
|
616 |
} |