mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-01 13:29:32 +00:00
91d33b586d
The main changes made to most tests are: *Declarations always include explicit types, not relying on implicit int. The declaration of main in most test programs is changed to be "int main (void) {...}", adding an explicit return type and a prototype. (There are still some non-prototyped functions, though.) *Functions are always declared before use, either by including a header or by providing a declaration for the specific function. The latter approach is usually used for printf, to avoid requiring ORCA/C to process stdio.h when compiling every test case (which might make test runs noticeably slower). *Make all return statements in non-void functions (e.g. main) return a value. *Avoid some instances of undefined behavior and type errors in printf and scanf calls. Several miscellaneous bugs are also fixed. There are still a couple test cases that intentionally rely on the C89 behavior, to ensure it still works.
104 lines
2.8 KiB
C++
104 lines
2.8 KiB
C++
/* Conformance Test 20.1.0.1: Verification of clock library function */
|
|
|
|
#include <time.h>
|
|
#include <orca.h>
|
|
#include <adb.h>
|
|
#include <event.h>
|
|
#include <locator.h>
|
|
#include <memory.h>
|
|
#include <misctool.h>
|
|
#include <desk.h>
|
|
#include <quickdraw.h>
|
|
|
|
int printf(const char *, ...);
|
|
|
|
int main (void)
|
|
{
|
|
clock_t clicks;
|
|
char **dpHandle, *dPageAddr;
|
|
int myID;
|
|
|
|
struct TSInfo { int toolSet; /* Tool Locator table to */
|
|
int minVersion; }; /* load RAM-based tools */
|
|
struct ToolTable { int count;
|
|
struct TSInfo tsInfo [2]; } toolTbl;
|
|
|
|
|
|
/* In order to use the clock function, must ensure that Event Manager */
|
|
/* has been started. The Event Manager requires the Miscellaneous Toolset */
|
|
/* QuickDraw II, the Desk Manager, and the ADB Toolset. First allocate */
|
|
/* 4 pages of direct page workspace for the Event Manager and QD II. */
|
|
|
|
myID = userid ();
|
|
dpHandle = NewHandle (1024L, myID, 0xC015, 0x00000000L);
|
|
if ( toolerror () )
|
|
goto Fail1;
|
|
if (dpHandle == NULL)
|
|
goto Fail1;
|
|
dPageAddr = *dpHandle;
|
|
|
|
if (! (MTStatus ()) ) /* start the Miscellaneous Toolset */
|
|
MTStartUp ();
|
|
|
|
if (! (QDStatus ()) ) /* start QuickDraw II */
|
|
{
|
|
QDStartUp ((int) dPageAddr, 0, 0, myID);
|
|
if ( toolerror () )
|
|
goto Fail2;
|
|
}
|
|
|
|
if (! (EMStatus ()) ) /* start Event Manager */
|
|
{
|
|
EMStartUp (((int) dPageAddr) + 768, 0, 0, 640, 0, 200, myID);
|
|
if ( toolerror () )
|
|
goto Fail3;
|
|
}
|
|
|
|
toolTbl.count = 2; /* load Desk Mgr & ADB tools */
|
|
toolTbl.tsInfo [0].toolSet = 5;
|
|
toolTbl.tsInfo [1].toolSet = 9;
|
|
toolTbl.tsInfo [0].minVersion = toolTbl.tsInfo [1].minVersion = 1;
|
|
|
|
LoadTools ((void *) (&toolTbl));
|
|
if ( toolerror () )
|
|
goto Fail4;
|
|
|
|
if (! (DeskStatus ()) ) /* start the Desk Manager */
|
|
DeskStartUp ();
|
|
|
|
if (! (ADBStatus ()) ) /* start the Apple Desktop Bus */
|
|
ADBStartUp ();
|
|
|
|
|
|
/* Finally, can call clock. */
|
|
|
|
clicks = clock ();
|
|
|
|
|
|
/* Shut down the tools in the reverse order of start up. */
|
|
|
|
ADBShutDown ();
|
|
DeskShutDown ();
|
|
EMShutDown ();
|
|
QDShutDown ();
|
|
MTShutDown ();
|
|
|
|
printf ("Passed Conformance Test 20.1.0.1\n");
|
|
return 0;
|
|
|
|
Fail:
|
|
printf ("Failed Conformance Test 20.1.0.1\n");
|
|
|
|
Fail1:
|
|
printf ("Unable to allocate direct page for Conformance Test 20.1.0.1\n");
|
|
|
|
Fail2:
|
|
printf ("Unable to start QuickDraw II for Conformance Test 20.1.0.1\n");
|
|
|
|
Fail3:
|
|
printf ("Unable to start Event Manager for Conformance Test 20.1.0.1\n");
|
|
|
|
Fail4:
|
|
printf ("Unable to load RAM tools for Conformance Test 20.1.0.1\n");
|
|
}
|