Source code of Windows XP (NT5)
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.

55 lines
1.5 KiB

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