home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume24 / mkid2 / part01 / bitops.c < prev    next >
C/C++ Source or Header  |  1991-10-09  |  992b  |  85 lines

  1. /* Copyright (c) 1986, Greg McGary */
  2. static char sccsid[] = "@(#)bitops.c    1.1 86/10/09";
  3.  
  4. #include    <bitops.h>
  5.  
  6. char *bitsset();
  7. char *bitsclr();
  8. char *bitsand();
  9. char *bitsxor();
  10. int bitstst();
  11. int bitsany();
  12.  
  13. char *
  14. bitsset(s1, s2, n)
  15.     register char    *s1;
  16.     register char    *s2;
  17.     register int    n;
  18. {
  19.     while (n--)
  20.         *s1++ |= *s2++;
  21.  
  22.     return s1;
  23. }
  24.  
  25. char *
  26. bitsclr(s1, s2, n)
  27.     register char    *s1;
  28.     register char    *s2;
  29.     register int    n;
  30. {
  31.     while (n--)
  32.         *s1++ &= ~*s2++;
  33.  
  34.     return s1;
  35. }
  36.  
  37. char *
  38. bitsand(s1, s2, n)
  39.     register char    *s1;
  40.     register char    *s2;
  41.     register int    n;
  42. {
  43.     while (n--)
  44.         *s1++ &= *s2++;
  45.  
  46.     return s1;
  47. }
  48.  
  49. char *
  50. bitsxor(s1, s2, n)
  51.     register char    *s1;
  52.     register char    *s2;
  53.     register int    n;
  54. {
  55.     while (n--)
  56.         *s1++ ^= *s2++;
  57.  
  58.     return s1;
  59. }
  60.  
  61. int
  62. bitstst(s1, s2, n)
  63.     register char    *s1;
  64.     register char    *s2;
  65.     register int    n;
  66. {
  67.     while (n--)
  68.         if (*s1++ & *s2++)
  69.             return 1;
  70.  
  71.     return 0;
  72. }
  73.  
  74. int
  75. bitsany(s, n)
  76.     register char    *s;
  77.     register int    n;
  78. {
  79.     while (n--)
  80.         if (*s++)
  81.             return 1;
  82.  
  83.     return 0;
  84. }
  85.