/[ascend]/trunk/ascend/utilities/bit.c
ViewVC logotype

Diff of /trunk/ascend/utilities/bit.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3262 by jpye, Wed Nov 15 12:32:11 2017 UTC revision 3263 by jpye, Wed Nov 15 22:27:25 2017 UTC
# Line 44  struct BitList *CreateBList(unsigned lon Line 44  struct BitList *CreateBList(unsigned lon
44    register char *ptr;    register char *ptr;
45    num_bytes = len >> 3;     /* divide by 8 */    num_bytes = len >> 3;     /* divide by 8 */
46    if(len & 0x07)num_bytes++;    if(len & 0x07)num_bytes++;
47    CONSOLE_DEBUG("num_bytes = %lu",num_bytes);    //CONSOLE_DEBUG("num_bytes = %lu",num_bytes);
48    result =    result =
49      (struct BitList *)ascmalloc((unsigned)(sizeof(struct BitList)+num_bytes));      (struct BitList *)ascmalloc((unsigned)(sizeof(struct BitList)+num_bytes));
50    result->length = len;    result->length = len;
# Line 155  unsigned long BitListBytes(CONST struct Line 155  unsigned long BitListBytes(CONST struct
155  void SetBit(struct BitList *bl, unsigned long int pos){  void SetBit(struct BitList *bl, unsigned long int pos){
156    register byte *ptr;    register byte *ptr;
157    register unsigned bit;    register unsigned bit;
158      asc_assert(pos < bl->length);
159    AssertContainedMemory(bl,sizeof(struct BitList));    AssertContainedMemory(bl,sizeof(struct BitList));
160    ptr = (byte *)((asc_intptr_t)bl+sizeof(struct BitList)+(pos >> 3));    ptr = (byte *)((asc_intptr_t)bl+sizeof(struct BitList)+(pos >> 3));
161    AssertContainedIn(bl,ptr);    AssertContainedIn(bl,ptr);
# Line 195  int ReadBit(CONST struct BitList *bl, un Line 196  int ReadBit(CONST struct BitList *bl, un
196    ptr = (byte *)((asc_intptr_t)bl+sizeof(struct BitList)+(pos >> 3));    ptr = (byte *)((asc_intptr_t)bl+sizeof(struct BitList)+(pos >> 3));
197    AssertContainedIn(bl,ptr);    AssertContainedIn(bl,ptr);
198    bit = pos & 0x07;    bit = pos & 0x07;
199      //CONSOLE_DEBUG("--->reading pos = %lu (byte %lu, bit %u)",pos,(pos>>3),bit);
200      //CONSOLE_DEBUG("value = %d",(*ptr & (1<<bit)));
201    return (*ptr & (1 << bit));    return (*ptr & (1 << bit));
202  }  }
203    

Legend:
Removed from v.3262  
changed lines
  Added in v.3263

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22