Ignore:
Timestamp:
08/21/06 21:04:59 (7 years ago)
Author:
perry
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
  • trunk/lib/format_helper.c

    r898 r921  
    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.