home *** CD-ROM | disk | FTP | other *** search
/ PC User 1997 April / PCU_APR_97.ISO / utils / cpu / cpuinfo / source / cpuinf32 / speed.h < prev   
Encoding:
C/C++ Source or Header  |  1996-11-13  |  3.9 KB  |  117 lines

  1. /***************************************************************
  2. *
  3. * C file:   speed.h... for cpuinf32 DLL
  4. *
  5. *       This program has been developed by Intel Corporation.  
  6. *        You have Intel's permission to incorporate this code 
  7. *       into your product, royalty free.  Intel has various 
  8. *        intellectual property rights which it may assert under
  9. *       certain circumstances, such as if another manufacturer's
  10. *       processor mis-identifies itself as being "GenuineIntel"
  11. *        when the CPUID instruction is executed.
  12. *
  13. *       Intel specifically disclaims all warranties, express or
  14. *       implied, and all liability, including consequential and
  15. *        other indirect damages, for the use of this code, 
  16. *        including liability for infringement of any proprietary
  17. *        rights, and including the warranties of merchantability
  18. *        and fitness for a particular purpose.  Intel does not 
  19. *        assume any responsibility for any errors which may 
  20. *        appear in this code nor any responsibility to update it.
  21. *
  22. *  * Other brands and names are the property of their respective
  23. *    owners.
  24. *
  25. *  Copyright (c) 1995, Intel Corporation.  All rights reserved.
  26. ***************************************************************/
  27.  
  28. #ifndef speed_h
  29. #define speed_h
  30.  
  31.  
  32.  
  33. // CONSTANT DEFINITIONS ////////////////////////////////////////
  34. #define CLONE_MASK        0x8000    // Mask to be 'OR'ed with proc-
  35. #define MAXCLOCKS        150        // Maximum number of cycles per
  36.                                 //   BSF instruction
  37.     // ACCURACY AFFECTING CONSTANTS ////////////////////////////
  38. #define ITERATIONS        4000    // Number of times to repeat BSF
  39.                                 //   instruction in samplings.
  40.                                 //   Initially set to 4000.
  41.  
  42. #define MAX_TRIES        20        // Maximum number of samplings
  43.                                 //   to allow before giving up
  44.                                 //   and returning current 
  45.                                 //   average. Initially set to
  46.                                 //   20.
  47.     
  48. #define TOLERANCE        1        // Number of MHz to allow
  49.                                 //   samplings to deviate from
  50.                                 //   average of samplings.
  51.                                 //   Initially set to 2.
  52.  
  53. #define    SAMPLINGS        10        // Number of BSF sequence 
  54.                                 //   samplings to make.
  55.                                 //   Initially set to 10.
  56.  
  57. // VARIABLE STRUCTURE DEFINITIONS //////////////////////////////
  58. struct FREQ_INFO
  59. {
  60.     unsigned long in_cycles;    // Internal clock cycles during
  61.                                 //   test
  62.                                 
  63.     unsigned long ex_ticks;        // Microseconds elapsed during 
  64.                                 //   test
  65.                                 
  66.     unsigned long raw_freq;        // Raw frequency of CPU in MHz
  67.     
  68.     unsigned long norm_freq;    // Normalized frequency of CPU
  69.                                 //   in MHz.
  70. };
  71.  
  72.  
  73. typedef unsigned short ushort;
  74. typedef unsigned long  ulong;
  75.  
  76.  
  77.  
  78. /***************************************************************
  79. * BOOL WINAPI DllMain()
  80. *
  81. * Inputs:    hDLL       - handle of DLL
  82. *           dwReason   - indicates why DLL called
  83. *           lpReserved - reserved
  84. *
  85. * Return Value: TRUE (always) 
  86. ***************************************************************/
  87. BOOL WINAPI DllMain (HINSTANCE hDLL, 
  88.                      DWORD dwReason, 
  89.                      LPVOID lpReserved);
  90.  
  91.  
  92. /***************************************************************
  93. * CpuSpeed() -- Return the raw clock rate of the host CPU.
  94. *
  95. * Inputs:
  96. *    clocks:        NULL: Use default value for number of cycles
  97. *                   per BSF instruction.
  98. *               Positive Integer: Use clocks value for number
  99. *                   of cycles per BSF instruction.
  100. *                 -1: Use CMos timer to calculate speed
  101. *                     (May not work for WinNT.
  102. *
  103. * Returns:
  104. *        If error then return all zeroes in FREQ_INFO structure
  105. *        Else return FREQ_INFO structure containing calculated 
  106. *       clock frequency, normalized clock frequency, number of 
  107. *       clock cycles during test sampling, and the number of 
  108. *       microseconds elapsed during the sampling.
  109. ***************************************************************/
  110. struct FREQ_INFO cpuspeed(int clocks);
  111. unsigned long cpurawspeed(int clocks);
  112. unsigned long cpunormspeed(int clocks);
  113. unsigned long ProcessorCount();
  114.  
  115. #endif speed_h
  116.  
  117.