Changeset 438 for trunk/psLib/src/collections/psBitMask.c
- Timestamp:
- Apr 16, 2004, 4:43:59 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psBitMask.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psBitMask.c
r437 r438 1 #include "psBitMask.h" 1 /** @file psBitMask.c 2 * 3 * @brief Creates an array of bits of arbitrary length. 4 * 5 * Bit masks are useful for turning options on and off. This module provides functions to create an array of 6 * bits of arbitrary length and manipulate them with basic binary operations. A print function is also 7 * provided to display the entire set of bits in binary form. 8 * 9 * @author Ross Harman, MHPCC 10 * 11 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-04-17 02:43:59 $ 13 * 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 15 */ 2 16 17 /******************************************************************************/ 18 /* INCLUDE FILES */ 19 /******************************************************************************/ 3 20 #include <stdlib.h> 4 21 #include <string.h> … … 6 23 #include <ctype.h> 7 24 8 static char* getByte(int bit, const psBitMask* inMask); 9 static char mask(int bit); 25 #include "psBitMask.h" 26 //#include "psMemory.h" 10 27 28 /*****************************************************************************/ 29 /* FUNCTION IMPLEMENTATION - LOCAL */ 30 /*****************************************************************************/ 31 static char* getByte(int bit, const psBitMask *restrict inMask) 32 { 33 int index = 0; 34 char *byte = 0; 35 index = bit/8; 36 byte = inMask->bits+index; 37 38 return byte; 39 } 40 41 static char mask(int bit) 42 { 43 char mask = 0x01; 44 mask = mask << (bit%8); 45 46 return mask; 47 } 48 49 /*****************************************************************************/ 50 /* FUNCTION IMPLEMENTATION - PUBLIC */ 51 /*****************************************************************************/ 11 52 psBitMask* psBitMaskAlloc(int n) 12 53 { 54 // psBitMask *newObj = (psBitMask*)psAlloc(sizeof(psBitMask)); 13 55 psBitMask *newObj = (psBitMask*)malloc(sizeof(psBitMask)); 14 56 newObj->n = n; … … 43 85 } 44 86 45 psBitMask* psBitMaskOp(psBitMask *outMask, const psBitMask *restrict inMask1, char *operator, const psBitMask *restrict inMask2) 87 psBitMask* psBitMaskOp(psBitMask *outMask, const psBitMask *restrict inMask1, char *operator, 88 const psBitMask *restrict inMask2) 46 89 { 47 90 int i = 0; … … 118 161 return outString; 119 162 } 120 121 /* 0 based index of byte array's byte that contains containing bit */122 static char* getByte(int bit, const psBitMask* inMask)123 {124 int index = 0;125 char *byte = 0;126 index = bit/8;127 byte = inMask->bits+index;128 129 return byte;130 }131 132 static char mask(int bit)133 {134 char mask = 0x01;135 mask = mask << (bit%8);136 137 return mask;138 }
Note:
See TracChangeset
for help on using the changeset viewer.
