blob: 2232c6864011c0b8191a3ca0e54ab932050a0cfe [file] [log] [blame]
Denis Vlasenko574f2f42008-02-27 18:41:59 +00001/* vi: set sw=4 ts=4: */
2/*
3 * Copyright (C) 2008 by Denys Vlasenko <vda.linux@googlemail.com>
4 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02005 * Licensed under GPLv2, see file LICENSE in this source tree.
Denis Vlasenko574f2f42008-02-27 18:41:59 +00006 */
Denis Vlasenko5d89fba2008-04-22 00:08:27 +00007#include <errno.h>
8
Denis Vlasenko93b82632008-04-11 11:27:29 +00009struct globals;
10
11#ifndef GCC_COMBINE
12
Denis Vlasenko574f2f42008-02-27 18:41:59 +000013/* We cheat here. It is declared as const ptr in libbb.h,
14 * but here we make it live in R/W memory */
Denis Vlasenko574f2f42008-02-27 18:41:59 +000015struct globals *ptr_to_globals;
Denis Vlasenko93b82632008-04-11 11:27:29 +000016
Denys Vlasenkob1c7a662020-10-01 00:34:44 +020017#ifdef errno
Denis Vlasenko5d89fba2008-04-22 00:08:27 +000018int *bb_errno;
19#endif
20
21
Denis Vlasenko93b82632008-04-11 11:27:29 +000022#else
23
Denis Vlasenko5d89fba2008-04-22 00:08:27 +000024
Denis Vlasenko93b82632008-04-11 11:27:29 +000025/* 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
Denys Vlasenkob1c7a662020-10-01 00:34:44 +020030#ifdef errno
Denis Vlasenko5d89fba2008-04-22 00:08:27 +000031int *const bb_errno __attribute__ ((section (".data")));
Denis Vlasenko93b82632008-04-11 11:27:29 +000032#endif
33
Denis Vlasenko5d89fba2008-04-22 00:08:27 +000034#endif