238 |
*(uint8_t *)ptr = v; |
*(uint8_t *)ptr = v; |
239 |
} |
} |
240 |
|
|
241 |
#ifdef WORDS_BIGENDIAN |
/* NOTE: on arm, putting 2 in /proc/sys/debug/alignment so that the |
242 |
|
kernel handles unaligned load/stores may give better results, but |
243 |
|
it is a system wide setting : bad */ |
244 |
|
#if defined(WORDS_BIGENDIAN) || defined(__arm__) |
245 |
|
|
246 |
/* conservative code for little endian unaligned accesses */ |
/* conservative code for little endian unaligned accesses */ |
247 |
static inline int lduw(void *ptr) |
static inline int lduw(void *ptr) |
332 |
return u.f; |
return u.f; |
333 |
} |
} |
334 |
|
|
335 |
|
static inline void stfl(void *ptr, float v) |
336 |
|
{ |
337 |
|
union { |
338 |
|
float f; |
339 |
|
uint32_t i; |
340 |
|
} u; |
341 |
|
u.f = v; |
342 |
|
stl(ptr, u.i); |
343 |
|
} |
344 |
|
|
345 |
|
#if defined(__arm__) && !defined(WORDS_BIGENDIAN) |
346 |
|
|
347 |
|
/* NOTE: arm is horrible as double 32 bit words are stored in big endian ! */ |
348 |
static inline double ldfq(void *ptr) |
static inline double ldfq(void *ptr) |
349 |
{ |
{ |
350 |
union { |
union { |
351 |
double d; |
double d; |
352 |
uint64_t i; |
uint32_t tab[2]; |
353 |
} u; |
} u; |
354 |
u.i = ldq(ptr); |
u.tab[1] = ldl(ptr); |
355 |
|
u.tab[0] = ldl(ptr + 4); |
356 |
return u.d; |
return u.d; |
357 |
} |
} |
358 |
|
|
359 |
static inline void stfl(void *ptr, float v) |
static inline void stfq(void *ptr, double v) |
360 |
{ |
{ |
361 |
union { |
union { |
362 |
float f; |
double d; |
363 |
uint32_t i; |
uint32_t tab[2]; |
364 |
} u; |
} u; |
365 |
u.f = v; |
u.d = v; |
366 |
stl(ptr, u.i); |
stl(ptr, u.tab[1]); |
367 |
|
stl(ptr + 4, u.tab[0]); |
368 |
|
} |
369 |
|
|
370 |
|
#else |
371 |
|
static inline double ldfq(void *ptr) |
372 |
|
{ |
373 |
|
union { |
374 |
|
double d; |
375 |
|
uint64_t i; |
376 |
|
} u; |
377 |
|
u.i = ldq(ptr); |
378 |
|
return u.d; |
379 |
} |
} |
380 |
|
|
381 |
static inline void stfq(void *ptr, double v) |
static inline void stfq(void *ptr, double v) |
387 |
u.d = v; |
u.d = v; |
388 |
stq(ptr, u.i); |
stq(ptr, u.i); |
389 |
} |
} |
390 |
|
#endif |
391 |
|
|
392 |
#else |
#else |
393 |
|
|