10 #define MAXINT INT_MAX
17 #include "utils/builtins.h"
20 #define HEXDIG(z) (z)<10 ? ((z)+'0') : ((z)-10+'A')
22 /* Modeled on struct varlena from postgres.h, bu data type is bits8 */
30 #define VARBITHDRSZ sizeof(int32)
31 /* Number of bits in this bit string */
32 #define VARBITLEN(PTR) (((struct varbita *)VARDATA(PTR))->vl_len)
33 /* Pointer tp the first byte containing bit string data */
34 #define VARBITS(PTR) (((struct varbita *)VARDATA(PTR))->vl_dat)
35 /* Number of bytes in the data section of a bit string */
36 #define VARBITBYTES(PTR) (VARSIZE(PTR) - VARHDRSZ - VARBITHDRSZ)
37 /* Padding of the bit string at the end */
38 #define VARBITPAD(PTR) (VARBITBYTES(PTR)*BITSPERBYTE - VARBITLEN(PTR))
39 /* Number of bytes needed to store a bit string of a given length */
40 #define VARBITDATALEN(BITLEN) ((BITLEN)/BITSPERBYTE + \
41 ((BITLEN)%BITSPERBYTE > 0 ? 1 : 0) + \
42 VARHDRSZ + VARBITHDRSZ)
43 /* pointer beyond the end of the bit string (like end() in STL containers) */
44 #define VARBITEND(PTR) ((bits8 *) (PTR + VARSIZE(PTR)))
45 /* Mask that will cover exactly one byte, i.e. BITSPERBYTE bits */
50 bits8 *zpbit_in(char *s, int dummy, int32 atttypmod);
51 char *zpbit_out(bits8 *s);
52 char *zpbits_out(bits8 *s);
53 bits8 *varbit_in(char *s, int dummy, int32 atttypmod);
54 char *varbit_out(bits8 *s);
55 bool biteq(bits8 *arg1, bits8 *arg2);
56 bool bitne(bits8 *arg1, bits8 *arg2);
57 bool bitge(bits8 *arg1, bits8 *arg2);
58 bool bitgt(bits8 *arg1, bits8 *arg2);
59 bool bitle(bits8 *arg1, bits8 *arg2);
60 bool bitlt(bits8 *arg1, bits8 *arg2);
61 int bitcmp(bits8 *arg1, bits8 *arg2);
62 bits8 *bitand(bits8 *arg1, bits8 *arg2);
63 bits8 *bitor(bits8 *arg1, bits8 *arg2);
64 bits8 *bitxor(bits8 *arg1, bits8 *arg2);
65 bits8 *bitnot(bits8 *arg);
66 bits8 *bitshiftright(bits8 *arg, int shft);
67 bits8 *bitshiftleft(bits8 *arg, int shft);
68 bits8 *bitcat(bits8 *arg1, bits8 *arg2);
69 bits8 *bitsubstr(bits8 *arg, int32 s, int32 l);
71 bool varbiteq(bits8 *arg1, bits8 *arg2);
72 bool varbitne(bits8 *arg1, bits8 *arg2);
73 bool varbitge(bits8 *arg1, bits8 *arg2);
74 bool varbitgt(bits8 *arg1, bits8 *arg2);
75 bool varbitle(bits8 *arg1, bits8 *arg2);
76 bool varbitlt(bits8 *arg1, bits8 *arg2);
77 int varbitcmp(bits8 *arg1, bits8 *arg2);
78 bits8 *varbitand(bits8 *arg1, bits8 *arg2);
79 bits8 *varbitor(bits8 *arg1, bits8 *arg2);
80 bits8 *varbitxor(bits8 *arg1, bits8 *arg2);
81 bits8 *varbitnot(bits8 *arg);
82 bits8 *varbitshiftright(bits8 *arg, int shft);
83 bits8 *varbitshiftleft(bits8 *arg, int shft);
84 bits8 *varbitcat(bits8 *arg1, bits8 *arg2);
85 bits8 *varbitsubstr(bits8 *arg, int32 s, int32 l);