busybox/libbb/ptr_to_globals.c
<<
>>
Prefs
   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 source tree.
   6 */
   7#include <errno.h>
   8
   9struct globals;
  10
  11#ifndef GCC_COMBINE
  12
  13/* We cheat here. It is declared as const ptr in libbb.h,
  14 * but here we make it live in R/W memory */
  15struct globals *ptr_to_globals;
  16
  17#ifdef errno
  18int *bb_errno;
  19#endif
  20
  21
  22#else
  23
  24
  25/* gcc -combine will see through and complain */
  26/* Using alternative method which is more likely to break
  27 * on weird architectures, compilers, linkers and so on */
  28struct globals *const ptr_to_globals __attribute__ ((section (".data")));
  29
  30#ifdef errno
  31int *const bb_errno __attribute__ ((section (".data")));
  32#endif
  33
  34#endif
  35