source: trunk/Softwares/MiBench/src/include/bitcount-bitops.h @ 141

Last change on this file since 141 was 117, checked in by rosiere, 15 years ago

1) Platforms : add new organization for test
2) Load_Store_Unit : add array to count nb_check in store_queue
3) Issue_queue and Core_Glue : rewrite the issue network
4) Special_Register_Unit : add reset value to register CID
5) Softwares : add multicontext test
6) Softwares : add SPECINT
7) Softwares : add MiBench?
7) Read_queue : inhib access for r0
8) Change Core_Glue (network) - dont yet support priority and load balancing scheme

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1/* +++Date last modified: 05-Jul-1997 */
2
3/*
4**  Macros and prototypes for bit operations
5**
6**  public domain for SNIPPETS by:
7**    Scott Dudley
8**    Auke Reitsma
9**    Ratko Tomic
10**    Aare Tali
11**    J. Blauth
12**    Bruce Wedding
13**    Bob Stout
14*/
15
16#ifndef BITOPS__H
17#define BITOPS__H
18
19#include <stdio.h>
20#include <stdlib.h>                             /* For size_t           */
21#include <limits.h>                             /* For CHAR_BIT         */
22#include "bitcount-sniptype.h"                           /* For TOBOOL()         */
23#include "bitcount-extkword.h"                           /* For CDECL            */
24
25/*
26**  Macros to manipulate bits in any integral data type.
27*/
28
29#define BitSet(arg,posn) ((arg) | (1L << (posn)))
30#define BitClr(arg,posn) ((arg) & ~(1L << (posn)))
31#define BitFlp(arg,posn) ((arg) ^ (1L << (posn)))
32#define BitTst(arg,posn) TOBOOL((arg) & (1L << (posn)))
33
34/*
35**  Macros to manipulate bits in an array of char.
36**  These macros assume CHAR_BIT is one of either 8, 16, or 32.
37*/
38
39#define MASK  CHAR_BIT-1
40#define SHIFT ((CHAR_BIT==8)?3:(CHAR_BIT==16)?4:8)
41
42#define BitOff(a,x)  ((void)((a)[(x)>>SHIFT] &= ~(1 << ((x)&MASK))))
43#define BitOn(a,x)   ((void)((a)[(x)>>SHIFT] |=  (1 << ((x)&MASK))))
44#define BitFlip(a,x) ((void)((a)[(x)>>SHIFT] ^=  (1 << ((x)&MASK))))
45#define IsBit(a,x)   ((a)[(x)>>SHIFT]        &   (1 << ((x)&MASK)))
46
47/*
48**  BITARRAY.C
49*/
50
51char *alloc_bit_array(size_t bits);
52int   getbit(char *set, int number);
53void  setbit(char *set, int number, int value);
54void  flipbit(char *set, int number);
55
56/*
57**  BITFILES.C
58*/
59
60typedef struct  {
61      FILE *  file;       /* for stream I/O   */
62      char    rbuf;       /* read bit buffer  */
63      char    rcnt;       /* read bit count   */
64      char    wbuf;       /* write bit buffer */
65      char    wcnt;       /* write bit count  */
66} bfile;
67
68bfile * bfopen(char *name, char *mode);
69int     bfread(bfile *bf);
70void    bfwrite(int bit, bfile *bf);
71void    bfclose(bfile *bf);
72
73/*
74** BITSTRNG.C
75*/
76
77void bitstring(char *str, long byze, int biz, int strwid);
78
79/*
80**  BSTR_I.C
81*/
82
83unsigned int bstr_i(char *cptr);
84
85/*
86**  BITCNT_1.C
87*/
88
89int CDECL bit_count(long x);
90
91/*
92**  BITCNT_2.C
93*/
94
95int CDECL bitcount(long i);
96
97/*
98**  BITCNT_3.C
99*/
100
101int CDECL ntbl_bitcount(long int x);
102int CDECL BW_btbl_bitcount(long int x);
103int CDECL AR_btbl_bitcount(long int x);
104
105/*
106**  BITCNT_4.C
107*/
108
109int CDECL ntbl_bitcnt(long x);
110int CDECL btbl_bitcnt(long x);
111
112#endif /*  BITOPS__H */
Note: See TracBrowser for help on using the repository browser.