errno.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Linuxthreads - a simple clone()-based implementation of Posix */
  2. /* threads for Linux. */
  3. /* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
  4. /* */
  5. /* This program is free software; you can redistribute it and/or */
  6. /* modify it under the terms of the GNU Library General Public License */
  7. /* as published by the Free Software Foundation; either version 2 */
  8. /* of the License, or (at your option) any later version. */
  9. /* */
  10. /* This program is distributed in the hope that it will be useful, */
  11. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  12. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  13. /* GNU Library General Public License for more details. */
  14. /* Define the location of errno for the remainder of the C library */
  15. #define __FORCE_GLIBC
  16. #include <features.h>
  17. #include <errno.h>
  18. #include <netdb.h>
  19. #include "pthread.h"
  20. #include "internals.h"
  21. #include <stdio.h>
  22. extern int _errno;
  23. extern int _h_errno;
  24. int * __errno_location()
  25. {
  26. /* check, if the library is initilize */
  27. if (__pthread_initial_thread_bos != NULL)
  28. {
  29. pthread_descr self = thread_self();
  30. return THREAD_GETMEM (self, p_errnop);
  31. }
  32. return &_errno;
  33. }
  34. int * __h_errno_location()
  35. {
  36. /* check, if the library is initilize */
  37. if (__pthread_initial_thread_bos != NULL)
  38. {
  39. pthread_descr self = thread_self();
  40. return THREAD_GETMEM (self, p_h_errnop);
  41. }
  42. return &_h_errno;
  43. }