home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / compat / stdlib / swab.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-01  |  455 b   |  20 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #include <stdlib.h>
  3.  
  4. void
  5. swab(const void *from, void *to, int n)
  6. {
  7.   unsigned long temp;
  8.  
  9.   n >>= 1; n++;
  10. #define    STEP    temp = *((const char *)from)++,*((char *)to)++ = *((const char *)from)++,*((char *)to)++ = temp
  11.   /* round to multiple of 8 */
  12.   while ((--n) & 07)
  13.     STEP;
  14.   n >>= 3;
  15.   while (--n >= 0) {
  16.     STEP; STEP; STEP; STEP;
  17.     STEP; STEP; STEP; STEP;
  18.   }
  19. }
  20.