Skip to content

Commit 9fdc8bf

Browse files
committed
TurboPFor: Config/Platform
1 parent a0013ce commit 9fdc8bf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/include_/conf.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static ALWAYS_INLINE unsigned ror64(unsigned x, int s) { return x >> s | x << (6
103103
#define ALIGNED(t,v,n) __declspec(align(n)) t v
104104
#define ALWAYS_INLINE __forceinline
105105
#define NOINLINE __declspec(noinline)
106+
#define _PACKED __attribute__ ((packed))
106107
#define THREADLOCAL __declspec(thread)
107108
#define likely(x) (x)
108109
#define unlikely(x) (x)
@@ -168,13 +169,15 @@ static ALWAYS_INLINE unsigned short ctou16(const void *cp) { unsigned short
168169
static ALWAYS_INLINE unsigned ctou32(const void *cp) { unsigned x; memcpy(&x, cp, sizeof(x)); return x; }
169170
static ALWAYS_INLINE unsigned long long ctou64(const void *cp) { unsigned long long x; memcpy(&x, cp, sizeof(x)); return x; }
170171
static ALWAYS_INLINE size_t ctousz(const void *cp) { size_t x; memcpy(&x, cp, sizeof(x)); return x; }
172+
static ALWAYS_INLINE _Float16 ctof16(const void *cp) { _Float16 x; memcpy(&x, cp, sizeof(x)); return x; }
171173
static ALWAYS_INLINE float ctof32(const void *cp) { float x; memcpy(&x, cp, sizeof(x)); return x; }
172174
static ALWAYS_INLINE double ctof64(const void *cp) { double x; memcpy(&x, cp, sizeof(x)); return x; }
173175

174176
static ALWAYS_INLINE void stou16( void *cp, unsigned short x) { memcpy(cp, &x, sizeof(x)); } // ua write
175177
static ALWAYS_INLINE void stou32( void *cp, unsigned x) { memcpy(cp, &x, sizeof(x)); }
176178
static ALWAYS_INLINE void stou64( void *cp, unsigned long long x) { memcpy(cp, &x, sizeof(x)); }
177179
static ALWAYS_INLINE void stousz( void *cp, size_t x) { memcpy(cp, &x, sizeof(x)); }
180+
static ALWAYS_INLINE void stof16( void *cp, _Float16 x) { memcpy(cp, &x, sizeof(x)); }
178181
static ALWAYS_INLINE void stof32( void *cp, float x) { memcpy(cp, &x, sizeof(x)); }
179182
static ALWAYS_INLINE void stof64( void *cp, double x) { memcpy(cp, &x, sizeof(x)); }
180183

@@ -190,10 +193,12 @@ static ALWAYS_INLINE void ltou64(unsigned long long *x, const void
190193
defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__)
191194
#define ctou16(_cp_) (*(unsigned short *)(_cp_))
192195
#define ctou32(_cp_) (*(unsigned *)(_cp_))
196+
#define ctof16(_cp_) (*(_Float16 *)(_cp_))
193197
#define ctof32(_cp_) (*(float *)(_cp_))
194198

195199
#define stou16(_cp_, _x_) (*(unsigned short *)(_cp_) = _x_)
196200
#define stou32(_cp_, _x_) (*(unsigned *)(_cp_) = _x_)
201+
#define stof16(_cp_, _x_) (*(_Float16 *)(_cp_) = _x_)
197202
#define stof32(_cp_, _x_) (*(float *)(_cp_) = _x_)
198203

199204
#define ltou32(_px_, _cp_) *(_px_) = *(unsigned *)(_cp_)
@@ -222,18 +227,21 @@ struct _PACKED doubleu { double d; };
222227
struct _PACKED shortu { unsigned short s; };
223228
struct _PACKED unsignedu { unsigned u; };
224229
struct _PACKED longu { uint64_t l; };
230+
struct _PACKED float16u { _Float16 g; };
225231
struct _PACKED floatu { float f; };
226232
struct _PACKED doubleu { double d; };
227233

228234
#define ctou16(_cp_) ((struct shortu *)(_cp_))->s
229235
#define ctou32(_cp_) ((struct unsignedu *)(_cp_))->u
230236
#define ctou64(_cp_) ((struct longu *)(_cp_))->l
237+
#define ctof16(_cp_) ((struct float16u *)(_cp_))->g
231238
#define ctof32(_cp_) ((struct floatu *)(_cp_))->f
232239
#define ctof64(_cp_) ((struct doubleu *)(_cp_))->d
233240

234241
#define stou16(_cp_, _x_) ((struct shortu *)(_cp_))->s = _x_
235242
#define stou32(_cp_, _x_) ((struct unsignedu *)(_cp_))->u = _x_
236243
#define stou64(_cp_, _x_) ((struct longu *)(_cp_))->l = _x_
244+
#define stof16(_cp_, _x_) ((struct float16u *)(_cp_))->g = _x_
237245
#define stof32(_cp_, _x_) ((struct floatu *)(_cp_))->f = _x_
238246
#define stof64(_cp_, _x_) ((struct doubleu *)(_cp_))->d = _x_
239247

0 commit comments

Comments
 (0)