9
9
* Portions Copyright (c) 1994, Regents of the University of California
10
10
*
11
11
* IDENTIFICATION
12
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.8 2000/08/21 04:48:50 tgl Exp $
12
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.9 2000/08/26 21:53:41 tgl Exp $
13
13
*
14
14
*-------------------------------------------------------------------------
15
15
*/
@@ -161,7 +161,7 @@ zpbit_in(PG_FUNCTION_ARGS)
161
161
* The bottom ipad bits of the byte pointed to by r need to be
162
162
* zero
163
163
*/
164
- if (((* r << (BITSPERBYTE - ipad )) & BITMASK ) != 0 )
164
+ if (((* r << (BITS_PER_BYTE - ipad )) & BITMASK ) != 0 )
165
165
elog (ERROR , "zpbit_in: bit string too long for bit(%d)" ,
166
166
atttypmod );
167
167
}
@@ -387,7 +387,7 @@ varbit_in(PG_FUNCTION_ARGS)
387
387
* The bottom ipad bits of the byte pointed to by r need to be
388
388
* zero
389
389
*/
390
- if (((* r << (BITSPERBYTE - ipad )) & BITMASK ) != 0 )
390
+ if (((* r << (BITS_PER_BYTE - ipad )) & BITMASK ) != 0 )
391
391
elog (ERROR , "varbit_in: bit string too long for bit varying(%d)" ,
392
392
atttypmod );
393
393
}
@@ -415,10 +415,10 @@ varbit_out(PG_FUNCTION_ARGS)
415
415
sp = VARBITS (s );
416
416
r = result ;
417
417
* r ++ = 'B' ;
418
- for (i = 0 ; i < len - BITSPERBYTE ; i += BITSPERBYTE , sp ++ )
418
+ for (i = 0 ; i < len - BITS_PER_BYTE ; i += BITS_PER_BYTE , sp ++ )
419
419
{
420
420
x = * sp ;
421
- for (k = 0 ; k < BITSPERBYTE ; k ++ )
421
+ for (k = 0 ; k < BITS_PER_BYTE ; k ++ )
422
422
{
423
423
* r ++ = (x & BITHIGH ) ? '1' : '0' ;
424
424
x <<= 1 ;
@@ -704,7 +704,7 @@ bitcat(PG_FUNCTION_ARGS)
704
704
else if (bitlen2 > 0 )
705
705
{
706
706
/* We need to shift all the bits to fit */
707
- bit2shift = BITSPERBYTE - bit1pad ;
707
+ bit2shift = BITS_PER_BYTE - bit1pad ;
708
708
pr = VARBITS (result ) + VARBITBYTES (arg1 ) - 1 ;
709
709
for (pa = VARBITS (arg2 ); pa < VARBITEND (arg2 ); pa ++ )
710
710
{
@@ -768,23 +768,23 @@ bitsubstr(PG_FUNCTION_ARGS)
768
768
VARBITLEN (result ) = rbitlen ;
769
769
len -= VARHDRSZ + VARBITHDRSZ ;
770
770
/* Are we copying from a byte boundary? */
771
- if ((s1 - 1 ) % BITSPERBYTE == 0 )
771
+ if ((s1 - 1 ) % BITS_PER_BYTE == 0 )
772
772
{
773
773
/* Yep, we are copying bytes */
774
- memcpy (VARBITS (result ), VARBITS (arg ) + (s1 - 1 ) / BITSPERBYTE ,
774
+ memcpy (VARBITS (result ), VARBITS (arg ) + (s1 - 1 ) / BITS_PER_BYTE ,
775
775
len );
776
776
}
777
777
else
778
778
{
779
779
/* Figure out how much we need to shift the sequence by */
780
- ishift = (s1 - 1 ) % BITSPERBYTE ;
780
+ ishift = (s1 - 1 ) % BITS_PER_BYTE ;
781
781
r = VARBITS (result );
782
- ps = VARBITS
10000
span>(arg ) + (s1 - 1 ) / BITSPERBYTE ;
782
+ ps = VARBITS (arg ) + (s1 - 1 ) / BITS_PER_BYTE ;
783
783
for (i = 0 ; i < len ; i ++ )
784
784
{
785
785
* r = (* ps << ishift ) & BITMASK ;
786
786
if ((++ ps ) < VARBITEND (arg ))
787
- * r |= * ps >> (BITSPERBYTE - ishift );
787
+ * r |= * ps >> (BITS_PER_BYTE - ishift );
788
788
r ++ ;
789
789
}
790
790
}
@@ -1009,8 +1009,8 @@ bitshiftleft(PG_FUNCTION_ARGS)
1009
1009
PG_RETURN_VARBIT_P (result );
1010
1010
}
1011
1011
1012
- byte_shift = shft / BITSPERBYTE ;
1013
- ishift = shft % BITSPERBYTE ;
1012
+ byte_shift = shft / BITS_PER_BYTE ;
1013
+ ishift = shft % BITS_PER_BYTE ;
1014
1014
p = VARBITS (arg ) + byte_shift ;
1015
1015
1016
1016
if (ishift == 0 )
@@ -1026,7 +1026,7 @@ bitshiftleft(PG_FUNCTION_ARGS)
1026
1026
{
1027
1027
* r = * p << ishift ;
1028
1028
if ((++ p ) < VARBITEND (arg ))
1029
- * r |= * p >> (BITSPERBYTE - ishift );
1029
+ * r |= * p >> (BITS_PER_BYTE - ishift );
1030
1030
}
1031
1031
for (; r < VARBITEND (result ); r ++ )
1032
1032
* r = 0 ;
@@ -1068,8 +1068,8 @@ bitshiftright(PG_FUNCTION_ARGS)
1068
1068
PG_RETURN_VARBIT_P (result );
1069
1069
}
1070
1070
1071
- byte_shift = shft / BITSPERBYTE ;
1072
- ishift = shft % BITSPERBYTE ;
1071
+ byte_shift = shft / BITS_PER_BYTE ;
1072
+ ishift = shft % BITS_PER_BYTE ;
1073
1073
p = VARBITS (arg );
1074
1074
1075
1075
/* Set the first part of the result to 0 */
@@ -1090,7 +1090,7 @@ bitshiftright(PG_FUNCTION_ARGS)
1090
1090
{
1091
1091
* r |= * p >> ishift ;
1092
1092
if ((++ r ) < VARBITEND (result ))
1093
- * r = (* p << (BITSPERBYTE - ishift )) & BITMASK ;
1093
+ * r = (* p << (BITS_PER_BYTE - ishift )) & BITMASK ;
1094
1094
}
1095
1095
}
1096
1096
@@ -1109,17 +1109,17 @@ bitfromint4(PG_FUNCTION_ARGS)
1109
1109
int len ;
1110
1110
1111
1111
/* allocate enough space for the bits in an int4 */
1112
- len = VARBITTOTALLEN (sizeof (int4 )* BITSPERBYTE );
1112
+ len = VARBITTOTALLEN (sizeof (int4 )* BITS_PER_BYTE );
1113
1113
result = (VarBit * ) palloc (len );
1114
1114
VARATT_SIZEP (result ) = len ;
1115
- VARBITLEN (result ) = sizeof (int4 )* BITSPERBYTE ;
1115
+ VARBITLEN (result ) = sizeof (int4 )* BITS_PER_BYTE ;
1116
1116
/* masks and shifts here are just too painful and we know that an int4 has
1117
1117
* got 4 bytes
1118
1118
*/
1119
1119
r = VARBITS (result );
1120
- r [0 ] = (bits8 ) ((a >> (3 * BITSPERBYTE )) & BITMASK );
1121
- r [1 ] = (bits8 ) ((a >> (2 * BITSPERBYTE )) & BITMASK );
1122
- r [2 ] = (bits8 ) ((a >> (1 * BITSPERBYTE )) & BITMASK );
1120
+ r [0 ] = (bits8 ) ((a >> (3 * BITS_PER_BYTE )) & BITMASK );
1121
+ r [1 ] = (bits8 ) ((a >> (2 * BITS_PER_BYTE )) & BITMASK );
1122
+ r [2 ] = (bits8 ) ((a >> (1 * BITS_PER_BYTE )) & BITMASK );
1123
1123
r [3 ] = (bits8 ) (a & BITMASK );
1124
1124
1125
1125
PG_RETURN_VARBIT_P (result );
@@ -1133,12 +1133,12 @@ bittoint4(PG_FUNCTION_ARGS)
1133
1133
bits8 * r ;
1134
1134
1135
1135
/* Check that the bit string is not too long */
1136
- if (VARBITLEN (arg ) > sizeof (int4 )* BITSPERBYTE )
1136
+ if (VARBITLEN (arg ) > sizeof (int4 )* BITS_PER_BYTE )
1137
1137
elog (ERROR , "Bit string is too large to fit in an int4" );
1138
1138
result = 0 ;
1139
1139
for (r = VARBITS (arg ); r < VARBITEND (arg ); r ++ )
1140
1140
{
1141
- result <<= BITSPERBYTE ;
1141
+ result <<= BITS_PER_BYTE ;
1142
1142
result |= * r ;
1143
1143
}
1144
1144
/* Now shift the result to take account of the padding at the end */
0 commit comments