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.

61 lines
1.9 KiB

  1. /***
  2. *abs.c - find absolute value
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines abs() - find the absolute value of an int.
  8. *
  9. *Revision History:
  10. * 04-22-87 JMB added function pragma for conversion to C 5.0 compiler
  11. * 12-11-87 JCR Added "_LOAD_DS" to declaration
  12. * 03-14-90 GJF Replaced _LOAD_DS with _CALLTYPE1, added #include
  13. * <cruntime.h> and fixed the copyright. Also, cleaned
  14. * up the formatting a bit.
  15. * 10-04-90 GJF New-style function declarator.
  16. * 12-28-90 SRW Added _CRUISER_ conditional around function pragma
  17. * 04-01-91 SRW Enable #pragma function for i386 _WIN32_ builds too.
  18. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  19. * No _CRTIMP for CRT DLL model due to intrinsic
  20. * 12-03-93 GJF Turn on #pragma function for all MS front-ends (esp.,
  21. * Alpha compiler).
  22. * 12-30-94 JCF Turn off #pragma function for MAC.
  23. * 05-17-99 PML Remove all Macintosh support.
  24. * 01-04-01 GB Added __int64 version of abs
  25. *
  26. *******************************************************************************/
  27. #include <cruntime.h>
  28. #include <stdlib.h>
  29. #pragma function(abs, _abs64)
  30. /***
  31. *int abs(number) - find absolute value of number
  32. *
  33. *Purpose:
  34. * Returns the absolute value of number (if number >= 0, returns number,
  35. * else returns -number).
  36. *
  37. *Entry:
  38. * int number - number to find absolute value of
  39. *
  40. *Exit:
  41. * returns the aboslute value of number
  42. *
  43. *Exceptions:
  44. *
  45. *******************************************************************************/
  46. int __cdecl abs (
  47. int number
  48. )
  49. {
  50. return( number>=0 ? number : -number );
  51. }
  52. __int64 __cdecl _abs64(
  53. __int64 num
  54. )
  55. {
  56. return (num >=0 ? num : -num);
  57. }