3
0

ptr_to_globals.c 747 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Copyright (C) 2008 by Denys Vlasenko <vda.linux@googlemail.com>
  4. *
  5. * Licensed under GPLv2, see file LICENSE in this tarball for details.
  6. */
  7. #include <errno.h>
  8. struct globals;
  9. #ifndef GCC_COMBINE
  10. /* We cheat here. It is declared as const ptr in libbb.h,
  11. * but here we make it live in R/W memory */
  12. struct globals *ptr_to_globals;
  13. #ifdef __GLIBC__
  14. int *bb_errno;
  15. #endif
  16. #else
  17. /* gcc -combine will see through and complain */
  18. /* Using alternative method which is more likely to break
  19. * on weird architectures, compilers, linkers and so on */
  20. struct globals *const ptr_to_globals __attribute__ ((section (".data")));
  21. #ifdef __GLIBC__
  22. int *const bb_errno __attribute__ ((section (".data")));
  23. #endif
  24. #endif