Added unsigned short endian swap

This commit is contained in:
Michiel Broek 2006-01-22 19:52:33 +00:00
parent c360a801cf
commit ea90ffba3a
2 changed files with 12 additions and 2 deletions

View File

@ -4,7 +4,7 @@
* Purpose ...............: Change integer value CPU endian independant * Purpose ...............: Change integer value CPU endian independant
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2004 * Copyright (C) 1997-2006
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -47,4 +47,13 @@ int le_int(int val)
} }
unsigned short le_us(unsigned short val)
{
#ifdef WORDS_BIGENDIAN
return ((val & 0xff) << 8) | ((val >> 8) & 0xff);
#else
return val;
#endif
}

View File

@ -4,7 +4,7 @@
* Purpose ...............: MBSE BBS main library header * Purpose ...............: MBSE BBS main library header
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2005 * Copyright (C) 1997-2006
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -2203,6 +2203,7 @@ struct termios tbufs, tbufsavs; /* Structure for raw mode */
* From endian.c * From endian.c
*/ */
int le_int(int); int le_int(int);
unsigned short le_us(unsigned short);