xref: /rk3399_rockchip-uboot/arch/x86/lib/gcc.c (revision 5b8031ccb4ed6e84457d883198d77efc307085dc)
136b2409aSGabe Black /*
236b2409aSGabe Black  * This file is part of the coreboot project.
336b2409aSGabe Black  *
436b2409aSGabe Black  * Copyright (C) 2009 coresystems GmbH
536b2409aSGabe Black  *
6*5b8031ccSTom Rini  * SPDX-License-Identifier:	GPL-2.0
736b2409aSGabe Black  */
836b2409aSGabe Black 
936b2409aSGabe Black #ifdef __GNUC__
1036b2409aSGabe Black 
1136b2409aSGabe Black /*
1236b2409aSGabe Black  * GCC's libgcc handling is quite broken. While the libgcc functions
1336b2409aSGabe Black  * are always regparm(0) the code that calls them uses whatever the
1436b2409aSGabe Black  * compiler call specifies. Therefore we need a wrapper around those
1536b2409aSGabe Black  * functions. See gcc bug PR41055 for more information.
1636b2409aSGabe Black  */
1736b2409aSGabe Black #define WRAP_LIBGCC_CALL(type, name) \
1836b2409aSGabe Black 	type __normal_##name(type a, type b) __attribute__((regparm(0))); \
1936b2409aSGabe Black 	type __wrap_##name(type a, type b); \
20d8819f94SSimon Glass 	type __attribute__((no_instrument_function)) \
21d8819f94SSimon Glass 		__wrap_##name(type a, type b) \
22d8819f94SSimon Glass 		 { return __normal_##name(a, b); }
2336b2409aSGabe Black 
2436b2409aSGabe Black WRAP_LIBGCC_CALL(long long, __divdi3)
2536b2409aSGabe Black WRAP_LIBGCC_CALL(unsigned long long, __udivdi3)
2636b2409aSGabe Black WRAP_LIBGCC_CALL(long long, __moddi3)
2736b2409aSGabe Black WRAP_LIBGCC_CALL(unsigned long long, __umoddi3)
2836b2409aSGabe Black 
2936b2409aSGabe Black #endif
30