blob: 0db7196c0eec09aa225ee4c91c601c859969ae94 [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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
18 */
19
Stefan Reinauer399486e2012-12-06 13:54:29 -080020#include <arch/cpu.h>
21
Stefan Reinauer5db685f2009-09-26 15:52:05 +000022/* GCC's libgcc handling is quite broken. While the libgcc functions
23 * are always regparm(0) the code that calls them uses whatever the
24 * compiler call specifies. Therefore we need a wrapper around those
25 * functions. See gcc bug PR41055 for more information.
26 */
David Hendricks421288d2012-11-28 20:19:23 -080027
Stefan Reinauer399486e2012-12-06 13:54:29 -080028/* TODO: maybe this code should move to arch/x86 as architecture
29 * specific implementations may vary
30 */
Stefan Reinauer5db685f2009-09-26 15:52:05 +000031#define WRAP_LIBGCC_CALL(type, name) \
Stefan Reinauer399486e2012-12-06 13:54:29 -080032 type __real_##name(type a, type b) asmlinkage; \
Myles Watsondc4ca9a2009-10-29 16:49:50 +000033 type __wrap_##name(type a, type b); \
Stefan Reinauer5db685f2009-09-26 15:52:05 +000034 type __wrap_##name(type a, type b) { return __real_##name(a, b); }
Stefan Reinauer5db685f2009-09-26 15:52:05 +000035
36WRAP_LIBGCC_CALL(long long, __divdi3)
37WRAP_LIBGCC_CALL(unsigned long long, __udivdi3)
38WRAP_LIBGCC_CALL(long long, __moddi3)
39WRAP_LIBGCC_CALL(unsigned long long, __umoddi3)