Skip to content

Commit cc51cd1

Browse files
committed
[NFC][libclc] Define _CLC_DEF_WEAK and replace _CLC_DEF_ldexp with it
_CLC_DEF_WEAK can be used in our downstream libclc to allow overriding generic __clc_tgamma implementation.
1 parent a7d1a65 commit cc51cd1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

libclc/clc/include/clc/clcfunc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#define _CLC_DEF __attribute__((always_inline))
2525
#endif
2626

27+
#define _CLC_DEF_WEAK _CLC_DEF __attribute__((weak))
28+
2729
#if __OPENCL_C_VERSION__ == CL_VERSION_2_0 || \
2830
(__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \
2931
defined(__opencl_c_generic_address_space))

libclc/clc/lib/generic/math/clc_ldexp.cl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
#include <clc/relational/clc_isnan.h>
1616
#include <clc/shared/clc_clamp.h>
1717

18-
#define _CLC_DEF_ldexp _CLC_DEF __attribute__((weak))
19-
20-
_CLC_DEF_ldexp _CLC_OVERLOAD float __clc_ldexp(float x, int n) {
18+
_CLC_DEF_WEAK _CLC_OVERLOAD float __clc_ldexp(float x, int n) {
2119

2220
if (!__clc_fp32_subnormals_supported()) {
2321
// This treats subnormals as zeros
@@ -90,7 +88,7 @@ _CLC_DEF_ldexp _CLC_OVERLOAD float __clc_ldexp(float x, int n) {
9088

9189
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
9290

93-
_CLC_DEF_ldexp _CLC_OVERLOAD double __clc_ldexp(double x, int n) {
91+
_CLC_DEF_WEAK _CLC_OVERLOAD double __clc_ldexp(double x, int n) {
9492
long l = __clc_as_ulong(x);
9593
int e = (l >> 52) & 0x7ff;
9694
long s = l & 0x8000000000000000;
@@ -125,14 +123,14 @@ _CLC_DEF_ldexp _CLC_OVERLOAD double __clc_ldexp(double x, int n) {
125123

126124
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
127125

128-
_CLC_OVERLOAD _CLC_DEF_ldexp half __clc_ldexp(half x, int n) {
126+
_CLC_OVERLOAD _CLC_DEF_WEAK half __clc_ldexp(half x, int n) {
129127
return (half)__clc_ldexp((float)x, n);
130128
}
131129

132130
#endif
133131

134132
#define __CLC_FUNCTION __clc_ldexp
135-
#define __CLC_DEF_SPEC _CLC_DEF_ldexp
133+
#define __CLC_DEF_SPEC _CLC_DEF_WEAK
136134
#define __CLC_ARG2_TYPE int
137135
#define __CLC_BODY <clc/shared/binary_def_scalarize.inc>
138136
#include <clc/math/gentype.inc>

0 commit comments

Comments
 (0)