1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-21 01:57:49 +00:00
Interlisp.maiko/inc/byteswapdefs.h
Nick Briggs 6e38d50829
Improve implementation of word_swap_page() and remove unused code (#447)
word_swap_page() should only touch each 32-bit word once to change
  the byte order from ABCD to DCBA rather than twice doing a transform
  of the entire region from ABCD to BADC and then again to DCBA

  The compiler provided ntohl() usually gets favorable optimizations
  applied, so use it for the byte reordering.

  With word_swap_page() rewritten, byte_swap_word() is superfluous.
2022-10-30 15:49:32 -07:00

19 lines
747 B
C

#ifndef BYTESWAPDEFS_H
#define BYTESWAPDEFS_H 1
/****************************************************************/
/* */
/* swap halves of a single 4-byte word */
/* */
/****************************************************************/
static inline unsigned int swapx(unsigned int word) {
return (((word >> 16) & 0xffff) | ((word & 0xffff) << 16));
}
void word_swap_page(unsigned short *page, int longwordcount);
void bit_reverse_region(unsigned short *top, int width, int height, int rasterwidth);
#ifdef RESWAPPEDCODESTREAM
unsigned int byte_swap_code_block(unsigned int *base);
#endif
#endif