void check_mem_conditions() { int total, contig; #if 0 if (StackSpace() < STACK_WARN_LIMIT) Warning("Stack nearning limit!!!"); if (FreeMem() < HEAP_WARN_LIMIT) { PurgeSpace(&total, &contig); // Warning("Free memory reaching limit\n.Purging would give %d total %d contiguous.\nLet me know Descent minimum and suggested size!!!", total, contig); } #endif }
void fastPoll( void ) { RANDOM_STATE randomState; BYTE buffer[ RANDOM_BUFSIZE + 8 ]; /* BatteryTimeRec batteryTimeInfo; */ SMStatus soundStatus; ThreadID threadID; ThreadState threadState; EventRecord eventRecord; Point point; WindowPtr windowPtr; PScrapStuff scrapInfo; UnsignedWide usSinceStartup; BYTE dataBuffer[ 2 + 8 ]; /* short driverRefNum; */ UInt32 dateTime; /* int count, dummy; */ NumVersion version; initRandomData( randomState, buffer, RANDOM_BUFSIZE ); /* Get the status of the last alert, how much battery time is remaining and the voltage from all batteries, the internal battery status, the current date and time and time since system startup in ticks, the application heap limit and current and heap zone, free memory in the current and system heap, microseconds since system startup, whether QuickDraw has finished drawing, modem status, SCSI status information, maximum block allocatable without compacting, available stack space, the last QuickDraw error code */ /* addRandomValue( randomState, GetAlertStage() ); count = BatteryCount(); while( count-- > 0 ) { addRandomValue( randomState, GetBatteryVoltage( count ) ); GetBatteryTimes( count, &batteryTimeInfo ); addRandomData( randomState, &batteryTimeInfo, sizeof( BatteryTimeRec ) ); } if( !BatteryStatus( buffer, dataBuffer + 1 ) ) addRandomValue( randomState, dataBuffer ); */ GetDateTime( &dateTime ); addRandomValue( randomState, dateTime ); addRandomValue( randomState, TickCount() ); #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON addRandomValue( randomState, GetApplLimit() ); addRandomValue( randomState, GetZone() ); addRandomValue( randomState, SystemZone() ); addRandomValue( randomState, FreeMem() ); addRandomValue( randomState, FreeMemSys() ); #endif /* MicroSeconds( &usSinceStartup ); addRandomData( randomState, &usSinceStartup, sizeof( UnsignedWide ) ); */ addRandomValue( randomState, QDDone( NULL ) ); /* ModemStatus( dataBuffer ); addRandomValue( randomState, dataBuffer[ 0 ] ); */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON addRandomValue( randomState, SCSIStat() ); #endif addRandomValue( randomState, MaxBlock() ); addRandomValue( randomState, StackSpace() ); addRandomValue( randomState, QDError() ); /* Get the event code and message, time, and mouse location for the next event in the event queue and the OS event queue */ if( EventAvail( everyEvent, &eventRecord ) ) addRandomData( randomState, &eventRecord, sizeof( EventRecord ) ); #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON if( OSEventAvail( everyEvent, &eventRecord ) ) addRandomData( randomState, &eventRecord, sizeof( EventRecord ) ); #endif /* Get all sorts of information such as device-specific info, grafport information, visible and clipping region, pattern, pen, text, and colour information, and other details, on the topmost window. Also get the window variant. If there's a colour table record, add the colour table as well */ if( ( windowPtr = FrontWindow() ) != NULL ) { /* CTabHandle colourHandle; */ #if !defined OPAQUE_TOOLBOX_STRUCTS || !OPAQUE_TOOLBOX_STRUCTS addRandomData( randomState, windowPtr, sizeof( GrafPort ) ); #endif addRandomValue( randomState, GetWVariant( windowPtr ) ); /* if( GetAuxWin( windowPtr, colourHandle ) ) { CTabPtr colourPtr; HLock( colourHandle ); colourPtr = *colourHandle; addRandomData( randomState, colourPtr, sizeof( ColorTable ) ); HUnlock( colourHandle ); } */ } /* Get mouse-related such as the mouse button status and mouse position, information on the window underneath the mouse */ addRandomValue( randomState, Button() ); GetMouse( &point ); addRandomData( randomState, &point, sizeof( Point ) ); FindWindow( point, &windowPtr ); #if !defined OPAQUE_TOOLBOX_STRUCTS || !OPAQUE_TOOLBOX_STRUCTS if( windowPtr != NULL ) addRandomData( randomState, windowPtr, sizeof( GrafPort ) ); #endif /* Get the size, handle, and location of the desk scrap/clipboard */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON scrapInfo = InfoScrap(); addRandomData( randomState, scrapInfo, sizeof( ScrapStuff ) ); #endif /* Get information on the current thread */ threadID = kCurrentThreadID; /*GetThreadID( &threadID ); */ GetThreadState( threadID, &threadState ); addRandomData( randomState, &threadState, sizeof( ThreadState ) ); /* Get the sound mananger status. This gets the number of allocated sound channels and the current CPU load from these channels */ SndManagerStatus( sizeof( SMStatus ), &soundStatus ); addRandomData( randomState, &soundStatus, sizeof( SMStatus ) ); /* Get the speech manager version and status */ /* version = SpeechManagerVersion(); addRandomData( randomState, &version, sizeof( NumVersion ) ); addRandomValue( randomState, SpeechBusy() ); */ /* Get the status of the serial port. This gets information on recent errors, read and write pending status, and flow control values */ /* if( !OpenDriver( "\p.AIn", &driverRefNum ) ) { SerStaRec serialStatus; SetStatus( driverRefNum, &serialStatus ); addRandomData( randomState, &serialStatus, sizeof( SerStaRec ) ); } if( !OpenDriver( "\p.AOut", &driverRefNum ) ) { SerStaRec serialStatus; SetStatus( driverRefNum, &serialStatus ); addRandomData( randomState, &serialStatus, sizeof( SerStaRec ) ); } */ /* Flush any remaining data through */ endRandomData( randomState, 10 ); }