/ src / lib / gcc.c
gcc.c
 1  /* SPDX-License-Identifier: GPL-2.0-only */
 2  
 3  #include <arch/cpu.h>
 4  
 5  /* 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   */
10  
11  /* TODO: maybe this code should move to arch/x86 as architecture
12   * specific implementations may vary
13   */
14  #define WRAP_LIBGCC_CALL(type, name) \
15  	asmlinkage type __real_##name(type a, type b); \
16  	type __wrap_##name(type a, type b); \
17  	type __wrap_##name(type a, type b) { return __real_##name(a, b); }
18  
19  WRAP_LIBGCC_CALL(long long, __divdi3)
20  WRAP_LIBGCC_CALL(unsigned long long, __udivdi3)
21  WRAP_LIBGCC_CALL(long long, __moddi3)
22  WRAP_LIBGCC_CALL(unsigned long long, __umoddi3)