Thread: byte order change

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    25

    byte order change

    Is there any API in Linux for changing the byte order of a 64 -bit (long long) variable?

    Please comment....

    thanks

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    There are several implementations of "byteswapping" in Linux, but it very much depends on several things which is the best solution:
    - what you are actually trying to achieve.
    - are you actually just swapping the bytes, or is it dependant on the host?
    - is this part of a user-mode application or kernel mode code?

    One of the first hits in google shows this:
    http://www.digipedia.pl/man/bswap16.9.html

    Whilst this page talks about BSD, it appears (from the google search) that the same functionality is implemented in Linux too.

    --
    Mats

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do you order your game code?
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 02-05-2006, 06:26 PM
  2. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 08:55 AM
  3. error: identifier "byte" is undefined.
    By Hulag in forum C++ Programming
    Replies: 4
    Last Post: 12-10-2003, 05:46 PM
  4. Byte confusion!!! HELP!
    By MrDoomMaster in forum C++ Programming
    Replies: 10
    Last Post: 11-12-2003, 04:54 PM
  5. Replies: 2
    Last Post: 09-04-2001, 02:12 PM