blob: 5a93f45e34979fc810f874118d8290217996d2c2 [file] [log] [blame]
Stefan Reinauer5db685f2009-09-26 15:52:05 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2009 coresystems GmbH
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Stefan Reinauer5db685f2009-09-26 15:52:05 +000014 */
15
Stefan Reinauer399486e2012-12-06 13:54:29 -080016#include <arch/cpu.h>
17
Stefan Reinauer5db685f2009-09-26 15:52:05 +000018/* GCC's libgcc handling is quite broken. While the libgcc functions
19 * are always regparm(0) the code that calls them uses whatever the
20 * compiler call specifies. Therefore we need a wrapper around those
21 * functions. See gcc bug PR41055 for more information.
22 */
David Hendricks421288d2012-11-28 20:19:23 -080023
Stefan Reinauer399486e2012-12-06 13:54:29 -080024/* TODO: maybe this code should move to arch/x86 as architecture
25 * specific implementations may vary
26 */
Stefan Reinauer5db685f2009-09-26 15:52:05 +000027#define WRAP_LIBGCC_CALL(type, name) \
Lee Leahy696ced62017-03-10 15:42:55 -080028 asmlinkage type __real_##name(type a, type b); \
Myles Watsondc4ca9a2009-10-29 16:49:50 +000029 type __wrap_##name(type a, type b); \
Stefan Reinauer5db685f2009-09-26 15:52:05 +000030 type __wrap_##name(type a, type b) { return __real_##name(a, b); }
Stefan Reinauer5db685f2009-09-26 15:52:05 +000031
32WRAP_LIBGCC_CALL(long long, __divdi3)
33WRAP_LIBGCC_CALL(unsigned long long, __udivdi3)
34WRAP_LIBGCC_CALL(long long, __moddi3)
35WRAP_LIBGCC_CALL(unsigned long long, __umoddi3)