Changeset 868cd24d in rtems for cpukit/include/sys/endian.h


Ignore:
Timestamp:
Apr 19, 2016, 8:22:06 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
dfcc8bb
Parents:
cb2651d
git-author:
Sebastian Huber <sebastian.huber@…> (04/19/16 08:22:06)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/30/16 06:11:39)
Message:

score: Use Newlib provided <machine/endian.h>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/sys/endian.h

    rcb2651d r868cd24d  
    3131
    3232#include <sys/cdefs.h>
    33 #include <rtems/endian.h>
     33#include <sys/_types.h>
     34#include <machine/endian.h>
     35
     36#ifndef _UINT8_T_DECLARED
     37typedef __uint8_t       uint8_t;
     38#define _UINT8_T_DECLARED
     39#endif
     40 
     41#ifndef _UINT16_T_DECLARED
     42typedef __uint16_t      uint16_t;
     43#define _UINT16_T_DECLARED
     44#endif
     45 
     46#ifndef _UINT32_T_DECLARED
     47typedef __uint32_t      uint32_t;
     48#define _UINT32_T_DECLARED
     49#endif
     50 
     51#ifndef _UINT64_T_DECLARED
     52typedef __uint64_t      uint64_t;
     53#define _UINT64_T_DECLARED
     54#endif
    3455 
    3556/*
    3657 * General byte order swapping functions.
    3758 */
    38 #define bswap16(x)      CPU_swap_u16(x)
    39 #define bswap32(x)      CPU_swap_u32(x)
    40 static __inline uint64_t
    41 bswap64(uint64_t v)
    42 {
    43 #ifdef __GNUC__
    44         return __builtin_bswap64(v);
    45 #else
    46         return ((v >> 56) | ((v >> 40) & 0xff00) | ((v >> 24) & 0xff0000) |
    47             ((v >> 8) & 0xff000000) | ((v << 8) & ((uint64_t)0xff << 32)) |
    48             ((v << 24) & ((uint64_t)0xff << 40)) |
    49             ((v << 40) & ((uint64_t)0xff << 48)) | ((v << 56)));
    50 #endif
    51 }
     59#define bswap16(x)      __bswap16(x)
     60#define bswap32(x)      __bswap32(x)
     61#define bswap64(x)      __bswap64(x)
    5262
    5363/*
     
    5565 * endian to host byte order functions as detailed in byteorder(9).
    5666 */
    57 #if BYTE_ORDER == LITTLE_ENDIAN
     67#if _BYTE_ORDER == _LITTLE_ENDIAN
    5868#define htobe16(x)      bswap16((x))
    5969#define htobe32(x)      bswap32((x))
     
    6979#define le32toh(x)      ((uint32_t)(x))
    7080#define le64toh(x)      ((uint64_t)(x))
    71 #else /* BYTE_ORDER != LITTLE_ENDIAN */
     81#else /* _BYTE_ORDER != _LITTLE_ENDIAN */
    7282#define htobe16(x)      ((uint16_t)(x))
    7383#define htobe32(x)      ((uint32_t)(x))
     
    8393#define le32toh(x)      bswap32((x))
    8494#define le64toh(x)      bswap64((x))
    85 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
     95#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
    8696
    8797/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
Note: See TracChangeset for help on using the changeset viewer.