Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  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.   const char* fromc = from;
  9.   char* toc = to;
  10.  
  11.   n >>= 1; n++;
  12. #define STEP    temp = *fromc++,*toc++ = *fromc++,*toc++ = temp
  13.   /* round to multiple of 8 */
  14.   while ((--n) & 07)
  15.     STEP;
  16.   n >>= 3;
  17.   while (--n >= 0) {
  18.     STEP; STEP; STEP; STEP;
  19.     STEP; STEP; STEP; STEP;
  20.   }
  21. }
  22.