Mac OS 9
Timer.h
Go to the documentation of this file.
1 
19 #ifndef __TIMER__
20 #define __TIMER__
21 
22 #ifndef __CONDITIONALMACROS__
23 #include <ConditionalMacros.h>
24 #endif
25 
26 #ifndef __MACTYPES__
27 #include <MacTypes.h>
28 #endif
29 
30 #ifndef __OSUTILS__
31 #include <OSUtils.h>
32 #endif
33 
34 #if PRAGMA_ONCE
35 #pragma once
36 #endif
37 
38 #ifdef __cplusplus
39 extern "C"
40 {
41 #endif
42 
43 #if PRAGMA_IMPORT
44 #pragma import on
45 #endif
46 
47 #if PRAGMA_STRUCT_ALIGN
48 #pragma options align = mac68k
49 #elif PRAGMA_STRUCT_PACKPUSH
50 #pragma pack(push, 2)
51 #elif PRAGMA_STRUCT_PACK
52 #pragma pack(2)
53 #endif
54 
55  enum
56  {
57  /* high bit of qType is set if task is active */
58  kTMTaskActive = (1L << 15)
59  };
60 
61  typedef struct TMTask TMTask;
62  typedef TMTask *TMTaskPtr;
63  typedef CALLBACK_API_REGISTER68K(void, TimerProcPtr, (TMTaskPtr tmTaskPtr));
64  typedef REGISTER_UPP_TYPE(TimerProcPtr) TimerUPP;
65  struct TMTask
66  {
67  QElemPtr qLink;
68  short qType;
69  TimerUPP tmAddr;
70  long tmCount;
71  long tmWakeUp;
72  long tmReserved;
73  };
74 
121 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
122 #pragma parameter InsTime(__A0)
123 #endif
124  void
125  InsTime(QElemPtr tmTaskPtr);
126 
152 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
153 #pragma parameter InsXTime(__A0)
154 #endif
155  void
156  InsXTime(QElemPtr tmTaskPtr);
157 
204 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
205 #pragma parameter PrimeTime(__A0, __D0)
206 #endif
207  void
208  PrimeTime(QElemPtr tmTaskPtr, long count);
209 
240 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
241 #pragma parameter RmvTime(__A0)
242 #endif
243  void
244  RmvTime(QElemPtr tmTaskPtr);
245 
246 /* InstallTimeTask, InstallXTimeTask, PrimeTimeTask and RemoveTimeTask work */
247 /* just like InsTime, InsXTime, PrimeTime, and RmvTime except that they */
248 /* return an OSErr result. */
257 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
258 #pragma parameter __D0 InstallTimeTask(__A0)
259 #endif
260  OSErr
262 
271 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
272 #pragma parameter __D0 InstallXTimeTask(__A0)
273 #endif
274  OSErr
276 
285 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
286 #pragma parameter __D0 PrimeTimeTask(__A0, __D0)
287 #endif
288  OSErr
289  PrimeTimeTask(QElemPtr tmTaskPtr, long count);
290 
299 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
300 #pragma parameter __D0 RemoveTimeTask(__A0)
301 #endif
302  OSErr
304 
313  void
314  Microseconds(UnsignedWide *microTickCount);
315 
324  TimerUPP
325  NewTimerUPP(TimerProcPtr userRoutine);
326 #if !OPAQUE_UPP_TYPES
327  enum
328  {
329  uppTimerProcInfo = 0x0000B802
330  }; /* register no_return_value Func(4_bytes:A1) */
331 #ifdef __cplusplus
332  inline TimerUPP NewTimerUPP(TimerProcPtr userRoutine)
333  {
334  return (TimerUPP)NewRoutineDescriptor(
335  (ProcPtr)(userRoutine), uppTimerProcInfo, GetCurrentArchitecture());
336  }
337 #else
338 #define NewTimerUPP(userRoutine) \
339  (TimerUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTimerProcInfo, \
340  GetCurrentArchitecture())
341 #endif
342 #endif
343 
352  void
353  DisposeTimerUPP(TimerUPP userUPP);
354 #if !OPAQUE_UPP_TYPES
355 #ifdef __cplusplus
356  inline void DisposeTimerUPP(TimerUPP userUPP)
357  {
358  DisposeRoutineDescriptor((UniversalProcPtr)userUPP);
359  }
360 #else
361 #define DisposeTimerUPP(userUPP) DisposeRoutineDescriptor(userUPP)
362 #endif
363 #endif
364 
373 #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
374 #pragma parameter InvokeTimerUPP(__A1, __A0)
375 #endif
376  void
377  InvokeTimerUPP(TMTaskPtr tmTaskPtr, TimerUPP userUPP);
378 #if !OPAQUE_UPP_TYPES && \
379  (!TARGET_OS_MAC || !TARGET_CPU_68K || TARGET_RT_MAC_CFM)
380 #ifdef __cplusplus
381  inline void InvokeTimerUPP(TMTaskPtr tmTaskPtr, TimerUPP userUPP)
382  {
383  CALL_ONE_PARAMETER_UPP(userUPP, uppTimerProcInfo, tmTaskPtr);
384  }
385 #else
386 #define InvokeTimerUPP(tmTaskPtr, userUPP) \
387  CALL_ONE_PARAMETER_UPP((userUPP), uppTimerProcInfo, (tmTaskPtr))
388 #endif
389 #endif
390 
391 #if CALL_NOT_IN_CARBON || OLDROUTINENAMES
392 /* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
393 #define NewTimerProc(userRoutine) NewTimerUPP(userRoutine)
394 #define CallTimerProc(userRoutine, tmTaskPtr) \
395  InvokeTimerUPP(tmTaskPtr, userRoutine)
396 #endif /* CALL_NOT_IN_CARBON */
397 
398 #if PRAGMA_STRUCT_ALIGN
399 #pragma options align = reset
400 #elif PRAGMA_STRUCT_PACKPUSH
401 #pragma pack(pop)
402 #elif PRAGMA_STRUCT_PACK
403 #pragma pack()
404 #endif
405 
406 #ifdef PRAGMA_IMPORT_OFF
407 #pragma import off
408 #elif PRAGMA_IMPORT
409 #pragma import reset
410 #endif
411 
412 #ifdef __cplusplus
413 }
414 #endif
415 
416 #endif /* __TIMER__ */
417 * /*/*/ * /
Set up for compiler independent conditionals.
Basic Macintosh data types.
void DisposeRoutineDescriptor(UniversalProcPtr theUPP)
UniversalProcPtr NewRoutineDescriptor(ProcPtr theProc, ProcInfoType theProcInfo, ISAType theISA)
OS Utilities Interfaces.
typedef CALLBACK_API_REGISTER68K(void, SIInterruptProcPtr,(SPBPtr inParamPtr, Ptr dataBuffer, short peakAmplitude, long sampleSize))
typedef REGISTER_UPP_TYPE(HighHookProcPtr) HighHookUPP
void InsTime(QElemPtr tmTaskPtr)
Install timer task.
void RmvTime(QElemPtr tmTaskPtr)
Remove task from Time Manager queue.
void InsXTime(QElemPtr tmTaskPtr)
Install extended Time Manager task.
OSErr InstallTimeTask(QElemPtr tmTaskPtr)
OSErr InstallXTimeTask(QElemPtr tmTaskPtr)
TimerUPP NewTimerUPP(TimerProcPtr userRoutine)
OSErr RemoveTimeTask(QElemPtr tmTaskPtr)
OSErr PrimeTimeTask(QElemPtr tmTaskPtr, long count)
void InvokeTimerUPP(TMTaskPtr tmTaskPtr, TimerUPP userUPP)
void PrimeTime(QElemPtr tmTaskPtr, long count)
Set interval for timer and start it ticking.
void DisposeTimerUPP(TimerUPP userUPP)
void Microseconds(UnsignedWide *microTickCount)
Definition: OSUtils.h:131
Definition: Timer.h:66
Definition: MacTypes.h:110