blob: 1e20506d8090c3dbcd090a275e8cd7f90f56fdbf [file] [log] [blame]
Angel Pons118a9c72020-04-02 23:48:34 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer5db685f2009-09-26 15:52:05 +00002
Stefan Reinauer399486e2012-12-06 13:54:29 -08003#include <arch/cpu.h>
4
Stefan Reinauer5db685f2009-09-26 15:52:05 +00005/* GCC's libgcc handling is quite broken. While the libgcc functions
6 * are always regparm(0) the code that calls them uses whatever the
7 * compiler call specifies. Therefore we need a wrapper around those
8 * functions. See gcc bug PR41055 for more information.
9 */
David Hendricks421288d2012-11-28 20:19:23 -080010
Stefan Reinauer399486e2012-12-06 13:54:29 -080011/* TODO: maybe this code should move to arch/x86 as architecture
12 * specific implementations may vary
13 */
Stefan Reinauer5db685f2009-09-26 15:52:05 +000014#define WRAP_LIBGCC_CALL(type, name) \
Lee Leahy696ced62017-03-10 15:42:55 -080015 asmlinkage type __real_##name(type a, type b); \
Myles Watsondc4ca9a2009-10-29 16:49:50 +000016 type __wrap_##name(type a, type b); \
Stefan Reinauer5db685f2009-09-26 15:52:05 +000017 type __wrap_##name(type a, type b) { return __real_##name(a, b); }
Stefan Reinauer5db685f2009-09-26 15:52:05 +000018
19WRAP_LIBGCC_CALL(long long, __divdi3)
20WRAP_LIBGCC_CALL(unsigned long long, __udivdi3)
21WRAP_LIBGCC_CALL(long long, __moddi3)
22WRAP_LIBGCC_CALL(unsigned long long, __umoddi3)