Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

simple riddle about macro

Name: Anonymous 2011-05-18 16:01

Bellow is a macro from Perl source code (perl.h).

# define _swab_32_(x) ((U32)( \
         (((U32)(x) & U32_CONST(0x000000ff)) << 24) | \
         (((U32)(x) & U32_CONST(0x0000ff00)) <<  8) | \
         (((U32)(x) & U32_CONST(0x00ff0000)) >>  8) | \
         (((U32)(x) & U32_CONST(0xff000000)) >> 24) ))


Provide at least 3 ideas, how this may be reused in other projects.

Name: Anonymous 2011-05-18 17:10

It's to change the endianess of an integer. It's quite common in all kinds of binary parsing code such as code accessing binary files, network protocols and so on.
>>3
In Lisp you still have to write similar code, even if I usually just autogenerate the code, that way it can be reused regardless of the size and shape of the data.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List