#include "u.h" /* * read big-endian short s */ ushort beswab(ushort s) { uchar *p; p = (uchar*)&s; return (p[0]<<8) | p[1]; } /* * read big-endian long l */ long beswal(long l) { uchar *p; p = (uchar*)&l; return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; } /* * read little-endian short s */ ushort leswab(ushort s) { uchar *p; p = (uchar*)&s; return (p[1]<<8) | p[0]; } /* * read little-endian long l */ long leswal(long l) { uchar *p; p = (uchar*)&l; return (p[3]<<24) | (p[2]<<16) | (p[1]<<8) | p[0]; } long _round(long a, long b) { long w; w = (a/b)*b; if (a!=w) w += b; return(w); }