nanogui: Cross-compilation of microwindows


Previous by date: 24 Aug 2005 22:40:11 +0100 Re: Cross-compilation of microwindows, Andrew Hannam
Next by date: 24 Aug 2005 22:40:11 +0100 Re: multi-threaded app: problem and suggestion; patch, Greg Haerr
Previous in thread: 24 Aug 2005 22:40:11 +0100 Re: Cross-compilation of microwindows, Andrew Hannam
Next in thread: 24 Aug 2005 22:40:11 +0100 Re: Cross-compilation of microwindows, Greg Haerr

Subject: Re: [nanogui] Cross-compilation of microwindows
From: Peter Barada ####@####.####
Date: 24 Aug 2005 22:40:11 +0100
Message-Id: <20050824214008.9AD2498428@baradas.org>

>The problem with using hton and ntoh macros is that this is unnecessary
>overhead for an embedded micro if it doesn't happen to fir the standard
>network endian model. The solution I guess is to define our own macros that
>allow use to specify what the network order is for your client/server
>(either BIG_ENDIAN or LITTLE_ENDIAN).
>
>Then a little endian embedded micro could talk to a big endian host  most
>efficently by using little endian on the wire.
>Conversely, a big endian embedded micro could talk to a little endian host
>most efficiently by using big endian on the wire.

I think the order should be defined by the server and the client is
forced to put the data into order for the server.  Then it looks like
only the code in nxproto.c(I think) has to be hacked up to put the
data into the order the server wants.

I'd suggest that we create a set of 'ctos' ordering macros for "client
to server" byteorder that refer to a global that holds the server's
byteorder, something like:

typedef enum {
	big_endian,
	little_endian
} endianess;

extern endianess client_order;
extern endianess server_order;

static inline unsigned short ctoss(unsigned short x)
{
	if (server_order != client_order) {
	   x = (((x & 0x00ff) >> 8) | ((x & 0xff00) << 8));
	}
	return x;
}

Thoughts?

-- 
Peter Barada
####@####.####

Previous by date: 24 Aug 2005 22:40:11 +0100 Re: Cross-compilation of microwindows, Andrew Hannam
Next by date: 24 Aug 2005 22:40:11 +0100 Re: multi-threaded app: problem and suggestion; patch, Greg Haerr
Previous in thread: 24 Aug 2005 22:40:11 +0100 Re: Cross-compilation of microwindows, Andrew Hannam
Next in thread: 24 Aug 2005 22:40:11 +0100 Re: Cross-compilation of microwindows, Greg Haerr


Powered by ezmlm-browse 0.20.