[vox-tech] wierd u_int32

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Mon Jun 28 22:15:13 PDT 2010


Looks like a nonstandard typedef for an unsigned 32-bit integer.  The actual typedef would generally be compiler-specific, but

typedef unsigned int u_int32;

would probably work on any linux computer.

"Brian Lavender" <brian at brie.com> wrote:

>I have some code that has the following snippet, but it has this
>u_int32. What the heck is u_int32?
>
>brian
>
>
>/*
>  Courtesy of http://ettercap.sourceforge.net/
>*/
>#ifndef CFG_LITTLE_ENDIAN
>#define ptohs(x) ( (u_int16_t)                       \
>                      ((u_int16_t)*((u_int8_t *)x+1)<<8|  \
>                      (u_int16_t)*((u_int8_t *)x+0)<<0)   \
>                    )
>
>#define ptohl(x) ( (u_int32)*((u_int8_t *)x+3)<<24|  \
>                      (u_int32)*((u_int8_t *)x+2)<<16|  \
>                      (u_int32)*((u_int8_t *)x+1)<<8|   \
>                      (u_int32)*((u_int8_t *)x+0)<<0    \
>                    )
>#else
>#define ptohs(x) *(u_int16_t *)(x)
>#define ptohl(x) *(u_int32 *)(x)
>#endif
>-- 
>Brian Lavender
>http://www.brie.com/brian/
>
>"There are two ways of constructing a software design. One way is to
>make it so simple that there are obviously no deficiencies. And the other
>way is to make it so complicated that there are no obvious deficiencies."
>
>Professor C. A. R. Hoare
>The 1980 Turing award lecture
>_______________________________________________
>vox-tech mailing list
>vox-tech at lists.lugod.org
>http://lists.lugod.org/mailman/listinfo/vox-tech

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.


More information about the vox-tech mailing list