home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / PowerPlant / CSpinner / PowerMacros.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-02  |  2.1 KB  |  44 lines  |  [TEXT/CWIE]

  1. #pragma once
  2.  
  3. // This file contains macros useful when writing code to be compiled both on 68K and on PPC.
  4. // Author: François Pottier (pottier@clipper.ens.fr)
  5. // Release: November 2, 1995
  6.  
  7. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  8. // Macro to determine whether a system routine is available. Returns true on 68K. This is useful when using weak-linked libraries.
  9.  
  10. #if USESROUTINEDESCRIPTORS
  11. #define    RoutineIsAvailable(name)                        true
  12. #else
  13. #define    RoutineIsAvailable(name)                        ((long) &name != kUnresolvedCFragSymbolAddress)
  14. #endif
  15.  
  16. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  17. // Apple has defined macros to create and use either a Routine Descriptor or a ProcPtr transparently. The problem is, these macros allocate descriptors from the heap; allocating them
  18. // from global storage, would be cooler. The BUILD_ROUTINE_DESCRIPTOR macro does the job, but works only in PPC mode. The macros below work in both modes.
  19. // They were designed by Zalman Stern.
  20.  
  21. // MakeStaticRoutineDesc(name, procinfo) creates a static descriptor on PPC and does nothing on 68K.
  22. // ExternRoutineDescriptor(name) declares an extern descriptor on PPC and does nothing on 68K.
  23. // ConditionalRD(name) returns a pointer to the routine descriptor on PPC and a procedure pointer on 68K.
  24.  
  25. #if GENERATINGCFM
  26. #define    MakeStaticRoutineDesc(name, procinfo)             static RoutineDescriptor name##RDS = BUILD_ROUTINE_DESCRIPTOR(procinfo, name);
  27. #else
  28. #define    MakeStaticRoutineDesc(name, procinfo)
  29. #endif
  30.  
  31. #if GENERATINGCFM
  32. #define    ExternRoutineDescriptor(name)                 extern RoutineDescriptor name##RDS;
  33. #else
  34. #define    ExternRoutineDesc(name)
  35. #endif
  36.  
  37. #if GENERATINGCFM
  38. #define    ConditionalRD(name)                            (&name##RDS)
  39. #else
  40. #define    ConditionalRD(name)                            (&name)
  41. #endif
  42.  
  43. // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  44.