Hi,

AFAICS ntoh[ls] and hton[ls] defined as asm instructions. This prevents
using them in const variables initialisation.
I need to create a const unsigned char array[] (C source file) from quite
a big network byte ordered binary data. Although the data consists mainly
of bytes and 16- and 32-bit words, it is difficult in my case to use
u_char, u_int16_t and u_int32_t, as the order and the number of each type
does not fit to any possible C struct declaration.
Well, I can just create a network ordered byte array C declaration like
const unsigned char array[] = { <byte0>, <byte1>, ... };
But for more efficient processing I would like to have something like
const unsigned char array[] = {
_4bytes(<b0>, <b1>, <b2>, <b3>)
_1long(<b4>, <b5>, <b6>, <b7>)
_2shorts(<b8>, <b9>, <b10>, <b11>)
_1long(<b12>, <b13>, <b14>, <b15>)
_4bytes(<b16>, <b17>, <b18>, <b19>)
...
};
... i.e. platform independent source code which would compile into
platform dependent object file. _4bytes, _2shorts and _1long are macros
produced for byte sequence in appropriate byte order. The macros need to
know the platform byte order, theoretically it can be one of 1234, 4321,
2143.
In endian.h I can see just huge line of comparisons to *_386 et. al., but
I cannot find any macros clearly decsribing the byte order. Am I wrong?

Thanks,
    Konstantin.


--
          * *        Konstantin Chuguev - Application Engineer
       *      *              Francis House, 112 Hills Road
     *                       Cambridge CB2 1PQ, United Kingdom
 D  A  N  T  E       WWW:    http://www.dante.net





To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to