Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.5 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // mspnutil.h
  4. //
  5. // Sundry span utility declarations.
  6. //
  7. // Copyright (C) Microsoft Corporation, 1997.
  8. //
  9. //----------------------------------------------------------------------------
  10. #ifndef _SPANUTIL_H_
  11. #define _SPANUTIL_H_
  12. #ifdef _X86_
  13. // warning C4035: 'imul32h' : no return value
  14. #pragma warning( disable : 4035 )
  15. #endif
  16. //-----------------------------------------------------------------------------
  17. //
  18. // imul32h
  19. //
  20. // Returns the upper 32 bits of a 32 bit by 32 bit signed multiply.
  21. //
  22. //-----------------------------------------------------------------------------
  23. inline INT32 imul32h(INT32 x, INT32 y)
  24. {
  25. #ifdef _X86_
  26. _asm
  27. {
  28. mov eax, x
  29. mov edx, y
  30. imul edx
  31. mov eax, edx
  32. }
  33. #else
  34. return (INT32)(((LONGLONG)x * y) >> 32);
  35. #endif
  36. }
  37. //-----------------------------------------------------------------------------
  38. //
  39. // imul32h_s20
  40. //
  41. // Returns (x*y)>>20
  42. //
  43. //-----------------------------------------------------------------------------
  44. inline INT32 imul32h_s20(INT32 x, INT32 y)
  45. {
  46. #ifdef _X86_
  47. _asm
  48. {
  49. mov eax, x
  50. mov edx, y
  51. imul edx
  52. shrd eax, edx, 20
  53. }
  54. #else
  55. return (INT32)(((LONGLONG)x * y) >> 20);
  56. #endif
  57. }
  58. #ifdef _X86_
  59. // in general, we want to look at these warnings
  60. #pragma warning( default : 4035 )
  61. #endif
  62. #endif // #ifndef _SPANUTIL_H_