blob: 3c70d790d49d79a4b8394c642f31e20f90d96404 [file] [log] [blame]
Gabe Black36b24092011-11-16 23:01:37 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2009 coresystems GmbH
5 *
Tom Rini5b8031c2016-01-14 22:05:13 -05006 * SPDX-License-Identifier: GPL-2.0
Gabe Black36b24092011-11-16 23:01:37 +00007 */
8
9#ifdef __GNUC__
10
11/*
12 * GCC's libgcc handling is quite broken. While the libgcc functions
13 * are always regparm(0) the code that calls them uses whatever the
14 * compiler call specifies. Therefore we need a wrapper around those
15 * functions. See gcc bug PR41055 for more information.
16 */
17#define WRAP_LIBGCC_CALL(type, name) \
18 type __normal_##name(type a, type b) __attribute__((regparm(0))); \
19 type __wrap_##name(type a, type b); \
Simon Glassd8819f92013-06-11 11:14:52 -070020 type __attribute__((no_instrument_function)) \
21 __wrap_##name(type a, type b) \
22 { return __normal_##name(a, b); }
Gabe Black36b24092011-11-16 23:01:37 +000023
24WRAP_LIBGCC_CALL(long long, __divdi3)
25WRAP_LIBGCC_CALL(unsigned long long, __udivdi3)
26WRAP_LIBGCC_CALL(long long, __moddi3)
27WRAP_LIBGCC_CALL(unsigned long long, __umoddi3)
28
29#endif