Ignore:
Timestamp:
08/21/06 21:04:59 (15 years ago)
Author:
Perry Lorier <perry@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
c0cd256
Parents:
1034a10
Message:

Add new API for dealing with Big endian or Little Endian numbers on the
wrong endian machine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_helper.c

    r306f91c r94af885  
    272272}
    273273
     274uint64_t byteswap64(uint64_t num)
     275{
     276        return (byteswap32((num&0xFFFFFFFF00000000ULL)>>32))
     277              |((uint64_t)byteswap32(num&0x00000000FFFFFFFFULL)<<32);
     278}
     279
     280uint32_t byteswap32(uint32_t num)
     281{
     282        return ((num&0x000000FFU)<<24)
     283                | ((num&0x0000FF00U)<<8)
     284                | ((num&0x00FF0000U)>>8)
     285                | ((num&0xFF000000U)>>24);
     286}
     287
     288uint16_t byteswap16(uint16_t num)
     289{
     290        return ((num<<8)&0xFF00)|((num>>8)&0x00FF);
     291}
     292
Note: See TracChangeset for help on using the changeset viewer.