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.

75 lines
2.0 KiB

  1. /***
  2. *mterrno.c - provide function versions of errno & _doserrno for LIBC.LIB
  3. *
  4. * Copyright (c) 1994-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Sometimes users want to compile code (such as for use in a library)
  8. * for both single-thread and multi-thread applications. Currently the
  9. * one major stumbling block to doing this is the fact that errno &
  10. * _doserrno are defined in different ways in LIBC.LIB and LIBCMT.LIB.
  11. * Code that should otherwise be usable with both LIBC.LIB and LIBCMT.LIB
  12. * but which accesses errno and/or _doserrno is not usable with both.
  13. * By providing the function versions of errno & _doserrno in LIBC.LIB,
  14. * users can compile their code for both LIBCMT.LIB and LIBC.LIB.
  15. * Note that this does not magically make single-thread code safe in a
  16. * multi-threaded environment, it merely makes it easier to use the
  17. * same code with LIBC.LIB and LIBCMT.LIB.
  18. *
  19. *Revision History:
  20. * 03-26-94 SKS Original version.
  21. *
  22. *******************************************************************************/
  23. #ifndef _MT
  24. /* Get the definitions of the function versions of errno/_doserrno */
  25. #define _MT
  26. #include <stdlib.h>
  27. #undef _MT
  28. /* undo the macros that convert the variable names to function calls */
  29. #undef errno
  30. #undef _doserrno
  31. /* declare the variables - must match the definitions in <STDLIB.H> */
  32. extern int errno; /* XENIX style error number */
  33. extern unsigned long _doserrno; /* OS system error value */
  34. /***
  35. *int * _errno() - return pointer to thread's errno
  36. *unsigned long * __doserrno() - return pointer to thread's _doserrno
  37. *
  38. *Purpose:
  39. * _errno() returns a pointer to the global variable errno
  40. * __doserrno returns a pointer to the global variable _doserrno
  41. *
  42. *Entry:
  43. * None.
  44. *
  45. *Exit:
  46. * See above.
  47. *
  48. *Exceptions:
  49. *
  50. *******************************************************************************/
  51. int * __cdecl _errno(
  52. void
  53. )
  54. {
  55. return & errno;
  56. }
  57. unsigned long * __cdecl __doserrno(
  58. void
  59. )
  60. {
  61. return & _doserrno;
  62. }
  63. #endif /* !_MT */