Rename BITSPERBYTE to BITS_PER_BYTE to avoid conflict with <values.h>
on some platforms.
This commit is contained in:
parent
662f6a557c
commit
d70bf0dd35
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/lib/Attic/bit.c,v 1.10 2000/08/20 19:31:37 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/lib/Attic/bit.c,v 1.11 2000/08/26 21:53:42 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -21,21 +21,21 @@
|
||||||
void
|
void
|
||||||
BitArraySetBit(BitArray bitArray, BitIndex bitIndex)
|
BitArraySetBit(BitArray bitArray, BitIndex bitIndex)
|
||||||
{
|
{
|
||||||
bitArray[bitIndex / BITSPERBYTE] |=
|
bitArray[bitIndex / BITS_PER_BYTE] |=
|
||||||
(1 << (BITSPERBYTE - 1 - (bitIndex % BITSPERBYTE)));
|
(1 << (BITS_PER_BYTE - 1 - (bitIndex % BITS_PER_BYTE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BitArrayClearBit(BitArray bitArray, BitIndex bitIndex)
|
BitArrayClearBit(BitArray bitArray, BitIndex bitIndex)
|
||||||
{
|
{
|
||||||
bitArray[bitIndex / BITSPERBYTE] &=
|
bitArray[bitIndex / BITS_PER_BYTE] &=
|
||||||
~(1 << (BITSPERBYTE - 1 - (bitIndex % BITSPERBYTE)));
|
~(1 << (BITS_PER_BYTE - 1 - (bitIndex % BITS_PER_BYTE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BitArrayBitIsSet(BitArray bitArray, BitIndex bitIndex)
|
BitArrayBitIsSet(BitArray bitArray, BitIndex bitIndex)
|
||||||
{
|
{
|
||||||
return ((bitArray[bitIndex / BITSPERBYTE] &
|
return ((bitArray[bitIndex / BITS_PER_BYTE] &
|
||||||
(1 << (BITSPERBYTE - 1 - (bitIndex % BITSPERBYTE)))
|
(1 << (BITS_PER_BYTE - 1 - (bitIndex % BITS_PER_BYTE)))
|
||||||
) != 0);
|
) != 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.186 2000/08/12 05:15:21 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.187 2000/08/26 21:53:43 tgl Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
|
@ -4163,9 +4163,9 @@ Bit: bit '(' Iconst ')'
|
||||||
if ($3 < 1)
|
if ($3 < 1)
|
||||||
elog(ERROR,"length for type '%s' must be at least 1",
|
elog(ERROR,"length for type '%s' must be at least 1",
|
||||||
$1);
|
$1);
|
||||||
else if ($3 > (MaxAttrSize * BITSPERBYTE))
|
else if ($3 > (MaxAttrSize * BITS_PER_BYTE))
|
||||||
elog(ERROR,"length for type '%s' cannot exceed %d",
|
elog(ERROR,"length for type '%s' cannot exceed %d",
|
||||||
$1, (MaxAttrSize * BITSPERBYTE));
|
$1, (MaxAttrSize * BITS_PER_BYTE));
|
||||||
$$->typmod = $3;
|
$$->typmod = $3;
|
||||||
}
|
}
|
||||||
| bit
|
| bit
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.4 2000/08/25 18:05:54 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.5 2000/08/26 21:53:41 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -254,7 +254,7 @@ type_maximum_size(Oid type_oid, int32 typemod)
|
||||||
case VARBITOID:
|
case VARBITOID:
|
||||||
case ZPBITOID:
|
case ZPBITOID:
|
||||||
/* typemod is the (max) number of bits */
|
/* typemod is the (max) number of bits */
|
||||||
return (typemod + (BITSPERBYTE-1)) / BITSPERBYTE
|
return (typemod + (BITS_PER_BYTE-1)) / BITS_PER_BYTE
|
||||||
+ 2 * sizeof(int32);
|
+ 2 * sizeof(int32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.8 2000/08/21 04:48:50 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.9 2000/08/26 21:53:41 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -161,7 +161,7 @@ zpbit_in(PG_FUNCTION_ARGS)
|
||||||
* The bottom ipad bits of the byte pointed to by r need to be
|
* The bottom ipad bits of the byte pointed to by r need to be
|
||||||
* zero
|
* zero
|
||||||
*/
|
*/
|
||||||
if (((*r << (BITSPERBYTE - ipad)) & BITMASK) != 0)
|
if (((*r << (BITS_PER_BYTE - ipad)) & BITMASK) != 0)
|
||||||
elog(ERROR, "zpbit_in: bit string too long for bit(%d)",
|
elog(ERROR, "zpbit_in: bit string too long for bit(%d)",
|
||||||
atttypmod);
|
atttypmod);
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,7 @@ varbit_in(PG_FUNCTION_ARGS)
|
||||||
* The bottom ipad bits of the byte pointed to by r need to be
|
* The bottom ipad bits of the byte pointed to by r need to be
|
||||||
* zero
|
* zero
|
||||||
*/
|
*/
|
||||||
if (((*r << (BITSPERBYTE - ipad)) & BITMASK) != 0)
|
if (((*r << (BITS_PER_BYTE - ipad)) & BITMASK) != 0)
|
||||||
elog(ERROR, "varbit_in: bit string too long for bit varying(%d)",
|
elog(ERROR, "varbit_in: bit string too long for bit varying(%d)",
|
||||||
atttypmod);
|
atttypmod);
|
||||||
}
|
}
|
||||||
|
@ -415,10 +415,10 @@ varbit_out(PG_FUNCTION_ARGS)
|
||||||
sp = VARBITS(s);
|
sp = VARBITS(s);
|
||||||
r = result;
|
r = result;
|
||||||
*r++ = 'B';
|
*r++ = 'B';
|
||||||
for (i = 0; i < len - BITSPERBYTE; i += BITSPERBYTE, sp++)
|
for (i = 0; i < len - BITS_PER_BYTE; i += BITS_PER_BYTE, sp++)
|
||||||
{
|
{
|
||||||
x = *sp;
|
x = *sp;
|
||||||
for (k = 0; k < BITSPERBYTE; k++)
|
for (k = 0; k < BITS_PER_BYTE; k++)
|
||||||
{
|
{
|
||||||
*r++ = (x & BITHIGH) ? '1' : '0';
|
*r++ = (x & BITHIGH) ? '1' : '0';
|
||||||
x <<= 1;
|
x <<= 1;
|
||||||
|
@ -704,7 +704,7 @@ bitcat(PG_FUNCTION_ARGS)
|
||||||
else if (bitlen2 > 0)
|
else if (bitlen2 > 0)
|
||||||
{
|
{
|
||||||
/* We need to shift all the bits to fit */
|
/* We need to shift all the bits to fit */
|
||||||
bit2shift = BITSPERBYTE - bit1pad;
|
bit2shift = BITS_PER_BYTE - bit1pad;
|
||||||
pr = VARBITS(result) + VARBITBYTES(arg1) - 1;
|
pr = VARBITS(result) + VARBITBYTES(arg1) - 1;
|
||||||
for (pa = VARBITS(arg2); pa < VARBITEND(arg2); pa++)
|
for (pa = VARBITS(arg2); pa < VARBITEND(arg2); pa++)
|
||||||
{
|
{
|
||||||
|
@ -768,23 +768,23 @@ bitsubstr(PG_FUNCTION_ARGS)
|
||||||
VARBITLEN(result) = rbitlen;
|
VARBITLEN(result) = rbitlen;
|
||||||
len -= VARHDRSZ + VARBITHDRSZ;
|
len -= VARHDRSZ + VARBITHDRSZ;
|
||||||
/* Are we copying from a byte boundary? */
|
/* Are we copying from a byte boundary? */
|
||||||
if ((s1 - 1) % BITSPERBYTE == 0)
|
if ((s1 - 1) % BITS_PER_BYTE == 0)
|
||||||
{
|
{
|
||||||
/* Yep, we are copying bytes */
|
/* Yep, we are copying bytes */
|
||||||
memcpy(VARBITS(result), VARBITS(arg) + (s1 - 1) / BITSPERBYTE,
|
memcpy(VARBITS(result), VARBITS(arg) + (s1 - 1) / BITS_PER_BYTE,
|
||||||
len);
|
len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Figure out how much we need to shift the sequence by */
|
/* Figure out how much we need to shift the sequence by */
|
||||||
ishift = (s1 - 1) % BITSPERBYTE;
|
ishift = (s1 - 1) % BITS_PER_BYTE;
|
||||||
r = VARBITS(result);
|
r = VARBITS(result);
|
||||||
ps = VARBITS(arg) + (s1 - 1) / BITSPERBYTE;
|
ps = VARBITS(arg) + (s1 - 1) / BITS_PER_BYTE;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
*r = (*ps << ishift) & BITMASK;
|
*r = (*ps << ishift) & BITMASK;
|
||||||
if ((++ps) < VARBITEND(arg))
|
if ((++ps) < VARBITEND(arg))
|
||||||
*r |= *ps >> (BITSPERBYTE - ishift);
|
*r |= *ps >> (BITS_PER_BYTE - ishift);
|
||||||
r++;
|
r++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1009,8 +1009,8 @@ bitshiftleft(PG_FUNCTION_ARGS)
|
||||||
PG_RETURN_VARBIT_P(result);
|
PG_RETURN_VARBIT_P(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte_shift = shft / BITSPERBYTE;
|
byte_shift = shft / BITS_PER_BYTE;
|
||||||
ishift = shft % BITSPERBYTE;
|
ishift = shft % BITS_PER_BYTE;
|
||||||
p = VARBITS(arg) + byte_shift;
|
p = VARBITS(arg) + byte_shift;
|
||||||
|
|
||||||
if (ishift == 0)
|
if (ishift == 0)
|
||||||
|
@ -1026,7 +1026,7 @@ bitshiftleft(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
*r = *p << ishift;
|
*r = *p << ishift;
|
||||||
if ((++p) < VARBITEND(arg))
|
if ((++p) < VARBITEND(arg))
|
||||||
*r |= *p >> (BITSPERBYTE - ishift);
|
*r |= *p >> (BITS_PER_BYTE - ishift);
|
||||||
}
|
}
|
||||||
for (; r < VARBITEND(result); r++)
|
for (; r < VARBITEND(result); r++)
|
||||||
*r = 0;
|
*r = 0;
|
||||||
|
@ -1068,8 +1068,8 @@ bitshiftright(PG_FUNCTION_ARGS)
|
||||||
PG_RETURN_VARBIT_P(result);
|
PG_RETURN_VARBIT_P(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte_shift = shft / BITSPERBYTE;
|
byte_shift = shft / BITS_PER_BYTE;
|
||||||
ishift = shft % BITSPERBYTE;
|
ishift = shft % BITS_PER_BYTE;
|
||||||
p = VARBITS(arg);
|
p = VARBITS(arg);
|
||||||
|
|
||||||
/* Set the first part of the result to 0 */
|
/* Set the first part of the result to 0 */
|
||||||
|
@ -1090,7 +1090,7 @@ bitshiftright(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
*r |= *p >> ishift;
|
*r |= *p >> ishift;
|
||||||
if ((++r) < VARBITEND(result))
|
if ((++r) < VARBITEND(result))
|
||||||
*r = (*p << (BITSPERBYTE - ishift)) & BITMASK;
|
*r = (*p << (BITS_PER_BYTE - ishift)) & BITMASK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1109,17 +1109,17 @@ bitfromint4(PG_FUNCTION_ARGS)
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* allocate enough space for the bits in an int4 */
|
/* allocate enough space for the bits in an int4 */
|
||||||
len = VARBITTOTALLEN(sizeof(int4)*BITSPERBYTE);
|
len = VARBITTOTALLEN(sizeof(int4)*BITS_PER_BYTE);
|
||||||
result = (VarBit *) palloc(len);
|
result = (VarBit *) palloc(len);
|
||||||
VARATT_SIZEP(result) = len;
|
VARATT_SIZEP(result) = len;
|
||||||
VARBITLEN(result) = sizeof(int4)*BITSPERBYTE;
|
VARBITLEN(result) = sizeof(int4)*BITS_PER_BYTE;
|
||||||
/* masks and shifts here are just too painful and we know that an int4 has
|
/* masks and shifts here are just too painful and we know that an int4 has
|
||||||
* got 4 bytes
|
* got 4 bytes
|
||||||
*/
|
*/
|
||||||
r = VARBITS(result);
|
r = VARBITS(result);
|
||||||
r[0] = (bits8) ((a >> (3*BITSPERBYTE)) & BITMASK);
|
r[0] = (bits8) ((a >> (3*BITS_PER_BYTE)) & BITMASK);
|
||||||
r[1] = (bits8) ((a >> (2*BITSPERBYTE)) & BITMASK);
|
r[1] = (bits8) ((a >> (2*BITS_PER_BYTE)) & BITMASK);
|
||||||
r[2] = (bits8) ((a >> (1*BITSPERBYTE)) & BITMASK);
|
r[2] = (bits8) ((a >> (1*BITS_PER_BYTE)) & BITMASK);
|
||||||
r[3] = (bits8) (a & BITMASK);
|
r[3] = (bits8) (a & BITMASK);
|
||||||
|
|
||||||
PG_RETURN_VARBIT_P(result);
|
PG_RETURN_VARBIT_P(result);
|
||||||
|
@ -1133,12 +1133,12 @@ bittoint4(PG_FUNCTION_ARGS)
|
||||||
bits8 *r;
|
bits8 *r;
|
||||||
|
|
||||||
/* Check that the bit string is not too long */
|
/* Check that the bit string is not too long */
|
||||||
if (VARBITLEN(arg) > sizeof(int4)*BITSPERBYTE)
|
if (VARBITLEN(arg) > sizeof(int4)*BITS_PER_BYTE)
|
||||||
elog(ERROR, "Bit string is too large to fit in an int4");
|
elog(ERROR, "Bit string is too large to fit in an int4");
|
||||||
result = 0;
|
result = 0;
|
||||||
for (r = VARBITS(arg); r < VARBITEND(arg); r++)
|
for (r = VARBITS(arg); r < VARBITEND(arg); r++)
|
||||||
{
|
{
|
||||||
result <<= BITSPERBYTE;
|
result <<= BITS_PER_BYTE;
|
||||||
result |= *r;
|
result |= *r;
|
||||||
}
|
}
|
||||||
/* Now shift the result to take account of the padding at the end */
|
/* Now shift the result to take account of the padding at the end */
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* or in config.h afterwards. Of course, if you edit config.h, then your
|
* or in config.h afterwards. Of course, if you edit config.h, then your
|
||||||
* changes will be overwritten the next time you run configure.
|
* changes will be overwritten the next time you run configure.
|
||||||
*
|
*
|
||||||
* $Id: config.h.in,v 1.131 2000/08/20 10:55:34 petere Exp $
|
* $Id: config.h.in,v 1.132 2000/08/26 21:53:40 tgl Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CONFIG_H
|
#ifndef CONFIG_H
|
||||||
|
@ -221,7 +221,7 @@
|
||||||
* You can try changing this if you have a machine with bytes of another
|
* You can try changing this if you have a machine with bytes of another
|
||||||
* size, but no guarantee...
|
* size, but no guarantee...
|
||||||
*/
|
*/
|
||||||
#define BITSPERBYTE 8
|
#define BITS_PER_BYTE 8
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define this is your operating system kernel supports AF_UNIX family
|
* Define this is your operating system kernel supports AF_UNIX family
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: varbit.h,v 1.6 2000/08/21 04:48:54 tgl Exp $
|
* $Id: varbit.h,v 1.7 2000/08/26 21:53:40 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -49,13 +49,13 @@ typedef struct
|
||||||
/* Number of bytes in the data section of a bit string */
|
/* Number of bytes in the data section of a bit string */
|
||||||
#define VARBITBYTES(PTR) (VARSIZE(PTR) - VARHDRSZ - VARBITHDRSZ)
|
#define VARBITBYTES(PTR) (VARSIZE(PTR) - VARHDRSZ - VARBITHDRSZ)
|
||||||
/* Padding of the bit string at the end (in bits) */
|
/* Padding of the bit string at the end (in bits) */
|
||||||
#define VARBITPAD(PTR) (VARBITBYTES(PTR)*BITSPERBYTE - VARBITLEN(PTR))
|
#define VARBITPAD(PTR) (VARBITBYTES(PTR)*BITS_PER_BYTE - VARBITLEN(PTR))
|
||||||
/* Number of bytes needed to store a bit string of a given length */
|
/* Number of bytes needed to store a bit string of a given length */
|
||||||
#define VARBITTOTALLEN(BITLEN) (((BITLEN) + BITSPERBYTE-1)/BITSPERBYTE + \
|
#define VARBITTOTALLEN(BITLEN) (((BITLEN) + BITS_PER_BYTE-1)/BITS_PER_BYTE + \
|
||||||
VARHDRSZ + VARBITHDRSZ)
|
VARHDRSZ + VARBITHDRSZ)
|
||||||
/* pointer beyond the end of the bit string (like end() in STL containers) */
|
/* pointer beyond the end of the bit string (like end() in STL containers) */
|
||||||
#define VARBITEND(PTR) (((bits8 *) (PTR)) + VARSIZE(PTR))
|
#define VARBITEND(PTR) (((bits8 *) (PTR)) + VARSIZE(PTR))
|
||||||
/* Mask that will cover exactly one byte, i.e. BITSPERBYTE bits */
|
/* Mask that will cover exactly one byte, i.e. BITS_PER_BYTE bits */
|
||||||
#define BITMASK 0xFF
|
#define BITMASK 0xFF
|
||||||
#define BITHIGH 0x80
|
#define BITHIGH 0x80
|
||||||
|
|
||||||
|
|
|
@ -3116,10 +3116,10 @@ Bit: bit '(' Iconst ')'
|
||||||
sprintf(errortext,"length for type '%s' must be at least 1",$1);
|
sprintf(errortext,"length for type '%s' must be at least 1",$1);
|
||||||
mmerror(ET_ERROR, errortext);
|
mmerror(ET_ERROR, errortext);
|
||||||
}
|
}
|
||||||
else if (atol($3) > (MaxAttrSize * BITSPERBYTE))
|
else if (atol($3) > (MaxAttrSize * BITS_PER_BYTE))
|
||||||
{
|
{
|
||||||
sprintf(errortext, "length for type '%s' cannot exceed %d", $1,
|
sprintf(errortext, "length for type '%s' cannot exceed %d", $1,
|
||||||
(MaxAttrSize * BITSPERBYTE));
|
(MaxAttrSize * BITS_PER_BYTE));
|
||||||
mmerror(ET_ERROR, errortext);
|
mmerror(ET_ERROR, errortext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue