#include "veil_funcs.h"
-
+#ifdef USE_64_BIT
+/**
+ * Array of bit positions for int64, indexed by bitno.
+ */
+static
+uint64 bitmasks[64] = {
+ 0x00000001, 0x00000002, 0x00000004, 0x00000008,
+ 0x00000010, 0x00000020, 0x00000040, 0x00000080,
+ 0x00000100, 0x00000200, 0x00000400, 0x00000800,
+ 0x00001000, 0x00002000, 0x00004000, 0x00008000,
+ 0x00010000, 0x00020000, 0x00040000, 0x00080000,
+ 0x00100000, 0x00200000, 0x00400000, 0x00800000,
+ 0x01000000, 0x02000000, 0x04000000, 0x08000000,
+ 0x10000000, 0x20000000, 0x40000000, 0x80000000,
+ 0x0000000100000000, 0x0000000200000000,
+ 0x0000000400000000, 0x0000000800000000,
+ 0x0000001000000000, 0x0000002000000000,
+ 0x0000004000000000, 0x0000008000000000,
+ 0x0000010000000000, 0x0000020000000000,
+ 0x0000040000000000, 0x0000080000000000,
+ 0x0000100000000000, 0x0000200000000000,
+ 0x0000400000000000, 0x0000800000000000,
+ 0x0001000000000000, 0x0002000000000000,
+ 0x0004000000000000, 0x0008000000000000,
+ 0x0010000000000000, 0x0020000000000000,
+ 0x0040000000000000, 0x0080000000000000,
+ 0x0100000000000000, 0x0200000000000000,
+ 0x0400000000000000, 0x0800000000000000,
+ 0x1000000000000000, 0x2000000000000000,
+ 0x4000000000000000, 0x8000000000000000};
+
+#else
/**
* Array of bit positions for int32, indexed by bitno.
*/
0x01000000, 0x02000000, 0x04000000, 0x08000000,
0x10000000, 0x20000000, 0x40000000, 0x80000000};
+#endif
/**
* Clear all bits in a ::Bitmap.
if (!bitmap) {
/* We need a new bitmap */
if (shared) {
- bitmap = vl_shmalloc(sizeof(Bitmap) + (sizeof(int32) * elems));
+ bitmap = vl_shmalloc(sizeof(Bitmap) + (sizeof(bm_int) * elems));
}
else {
- bitmap = vl_malloc(sizeof(Bitmap) + (sizeof(int32) * elems));
+ bitmap = vl_malloc(sizeof(Bitmap) + (sizeof(bm_int) * elems));
}
}
(void) hash_search(bmhash->hash, hashelem, HASH_FIND, &found);
return found;
}
+
+
create or replace
-function veil.init_range(name text, min int4, max int4) returns int4
+function veil.init_range(name text, min int, max int) returns int
as '@LIBPATH@', 'veil_init_range'
language C stable strict;
-comment on function veil.init_range(text, int4, int4) is
+comment on function veil.init_range(text, int, int) is
'Initialise a Range variable called NAME constrained by MIN and MAX.
Return the number of elements in the range.
create or replace
-function veil.bitmap_setbit(bitmap_name text, bit_number int4) returns bool
+function veil.bitmap_setbit(bitmap_name text, bit_number int) returns bool
as '@LIBPATH@', 'veil_bitmap_setbit'
language C stable strict;
-comment on function veil.bitmap_setbit(text, int4) is
+comment on function veil.bitmap_setbit(text, int) is
'In the Bitmap or BitmapRef identified by BITMAP_NAME, set the bit given by
BIT_NUMBER.
create or replace
-function veil.bitmap_clearbit(bitmap_name text, bit_number int4) returns bool
+function veil.bitmap_clearbit(bitmap_name text, bit_number int) returns bool
as '@LIBPATH@', 'veil_bitmap_clearbit'
language C stable strict;
-comment on function veil.bitmap_clearbit(text, int4) is
+comment on function veil.bitmap_clearbit(text, int) is
'In the Bitmap or BitmapRef identified by BITMAP_NAME, clear the bit given by
BIT_NUMBER.
create or replace
-function veil.bitmap_testbit(bitmap_name text, bit_number int4) returns bool
+function veil.bitmap_testbit(bitmap_name text, bit_number int) returns bool
as '@LIBPATH@', 'veil_bitmap_testbit'
language C stable strict;
-comment on function veil.bitmap_testbit(text, int4) is
+comment on function veil.bitmap_testbit(text, int) is
'In the Bitmap or BitmapRef identified by BITMAP_NAME, test the bit given by
BIT_NUMBER.
create or replace
-function veil.bitmap_bits(bitmap_name text) returns setof int4
+function veil.bitmap_bits(bitmap_name text) returns setof int
as '@LIBPATH@', 'veil_bitmap_bits'
language C stable strict;
create or replace
function veil.bitmap_from_array(bmref_name text, bmarray text,
- index int4) returns text
+ index int) returns text
as '@LIBPATH@',
'veil_bitmap_from_array'
language C stable strict;
-comment on function veil.bitmap_from_array(text, text, int4) is
+comment on function veil.bitmap_from_array(text, text, int) is
'Set BitmapRef BMREF_NAME to the bitmap from BMARRAY indexed by INDEX.
Return the name of the BitmapRef.
create or replace
function veil.bitmap_array_testbit(
- bmarray text, arr_idx int4, bitno int4) returns bool
+ bmarray text, arr_idx int, bitno int) returns bool
as '@LIBPATH@',
'veil_bitmap_array_testbit'
language C stable strict;
-comment on function veil.bitmap_array_testbit(text, int4, int4) is
+comment on function veil.bitmap_array_testbit(text, int, int) is
'Test a bit in BMARRAY, from the bitmap indexed by ARR_IDX, checking the
bit identified by BITNO.
create or replace
function veil.bitmap_array_setbit(
- bmarray text, arr_idx int4, bitno int4) returns bool
+ bmarray text, arr_idx int, bitno int) returns bool
as '@LIBPATH@',
'veil_bitmap_array_setbit'
language C stable strict;
-comment on function veil.bitmap_array_setbit(text, int4, int4) is
+comment on function veil.bitmap_array_setbit(text, int, int) is
'Set a bit in BMARRAY, from the bitmap indexed by ARR_IDX, setting the
bit identified by BITNO.
create or replace
function veil.bitmap_array_clearbit(
- bmarray text, arr_idx int4, bitno int4) returns bool
+ bmarray text, arr_idx int, bitno int) returns bool
as '@LIBPATH@',
'veil_bitmap_array_clearbit'
language C stable strict;
-comment on function veil.bitmap_array_clearbit(text, int4, int4) is
+comment on function veil.bitmap_array_clearbit(text, int, int) is
'Clear a bit in BMARRAY, from the bitmap indexed by ARR_IDX, clearing the
bit identified by BITNO.
create or replace
function veil.union_from_bitmap_array(
- bitmap text, bmarray text, arr_idx int4) returns bool
+ bitmap text, bmarray text, arr_idx int) returns bool
as '@LIBPATH@',
'veil_union_from_bitmap_array'
language C stable strict;
-comment on function veil.union_from_bitmap_array(text, text, int4) is
+comment on function veil.union_from_bitmap_array(text, text, int) is
'Union BITMAP with BMARRAY[ARR_IDX], with the result going into bitmap.
Return TRUE';
create or replace
function veil.intersect_from_bitmap_array(
- bitmap text, bmarray text, arr_idx int4) returns bool
+ bitmap text, bmarray text, arr_idx int) returns bool
as '@LIBPATH@',
'veil_intersect_from_bitmap_array'
language C stable strict;
-comment on function veil.intersect_from_bitmap_array(text, text, int4) is
+comment on function veil.intersect_from_bitmap_array(text, text, int) is
'Intersect BITMAP with BMARRAY[ARR_IDX], with the result going into bitmap.
Return TRUE';
create or replace
-function veil.bitmap_array_bits(bmarray text, arr_idx int4) returns setof int4
+function veil.bitmap_array_bits(bmarray text, arr_idx int) returns setof int4
as '@LIBPATH@',
'veil_bitmap_array_bits'
language C stable strict;
-comment on function veil.bitmap_array_bits(text, int4) is
+comment on function veil.bitmap_array_bits(text, int) is
'Return all bits in the bitmap given by BMARRAY[ARR_IDX].
This is primarily intended for interactive use: for debugging, etc.';
create or replace
-function veil.bitmap_hash_testbit(bmhash text, key text, bitno int4) returns bool
+function veil.bitmap_hash_testbit(bmhash text, key text, bitno int) returns bool
as '@LIBPATH@',
'veil_bitmap_hash_testbit'
language C stable strict;
-comment on function veil.bitmap_hash_testbit(text, text, int4) is
+comment on function veil.bitmap_hash_testbit(text, text, int) is
'Test the bit, in the bitmap from BMHASH identified by KEY, given by
BITNO.
create or replace
-function veil.bitmap_hash_setbit(bmhash text, key text, bitno int4) returns bool
+function veil.bitmap_hash_setbit(bmhash text, key text, bitno int) returns bool
as '@LIBPATH@',
'veil_bitmap_hash_setbit'
language C stable strict;
-comment on function veil.bitmap_hash_setbit(text, text, int4) is
+comment on function veil.bitmap_hash_setbit(text, text, int) is
'Set the bit, in the bitmap from BMHASH identified by KEY, given by
BITNO to TRUE.
create or replace
-function veil.bitmap_hash_clearbit(bmhash text, key text, bitno int4) returns bool
+function veil.bitmap_hash_clearbit(bmhash text, key text, bitno int) returns bool
as '@LIBPATH@',
'veil_bitmap_hash_clearbit'
language C stable strict;
-comment on function veil.bitmap_hash_clearbit(text, text, int4) is
+comment on function veil.bitmap_hash_clearbit(text, text, int) is
'Set the bit, in the bitmap from BMHASH identified by KEY, given by
BITNO to FALSE.
create or replace
-function veil.bitmap_hash_bits(bmhash text, key text) returns setof int4
+function veil.bitmap_hash_bits(bmhash text, key text) returns setof int
as '@LIBPATH@',
'veil_bitmap_hash_bits'
language C stable strict;
create or replace
-function veil.int4_set(name text, value int4) returns int4
+function veil.int4_set(name text, value int) returns int
as '@LIBPATH@',
'veil_int4_set'
language C stable;
-comment on function veil.int4_set(text, int4) is
-'Set the int4 variable NAME to VALUE.
+comment on function veil.int4_set(text, int) is
+'Set the int variable NAME to VALUE.
Return the new value';
create or replace
-function veil.int4_get(name text) returns int4
+function veil.int4_get(name text) returns int
as '@LIBPATH@',
'veil_int4_get'
language C stable strict;
comment on function veil.int4_get(text) is
-'Return the value of int4 variable NAME.';
+'Return the value of int variable NAME.';
create or replace
language C stable strict;
comment on function veil.init_int4array(text, text) is
-'Initialise the int4 array ARRAYNAME, with an index range of RANGE.
+'Initialise the int array ARRAYNAME, with an index range of RANGE.
Each entry in the array is set to zero.
create or replace
-function veil.int4array_set(arrayname text, idx int4, value int4) returns int4
+function veil.int4array_set(arrayname text, idx int, value int) returns int
as '@LIBPATH@',
'veil_int4array_set'
language C stable;
-comment on function veil.int4array_set(text, int4, int4) is
+comment on function veil.int4array_set(text, int, int) is
'Set the ARRAYNAME element IDX to VALUE.
Return the new value.';
create or replace
-function veil.int4array_get(arrayname text, idx int4) returns int4
+function veil.int4array_get(arrayname text, idx int) returns int
as '@LIBPATH@',
'veil_int4array_get'
language C stable strict;
-comment on function veil.int4array_get(text, int4) is
+comment on function veil.int4array_get(text, int) is
'Return the value of ARRAYNAME element IDX.';
create or replace
-function veil.deserialise(stream text) returns int4
+function veil.deserialise(stream text) returns int
as '@LIBPATH@',
'veil_deserialise'
language C stable strict;
-- Ditto for victims of webster.
create or replace
-function veil.deserialize(stream text) returns int4
+function veil.deserialize(stream text) returns int
as '@LIBPATH@',
'veil_deserialise'
language C stable strict;
revoke execute on function veil.share(text) from public;
revoke execute on function veil.veil_variables() from public;
-revoke execute on function veil.init_range(text, int4, int4) from public;
+revoke execute on function veil.init_range(text, int, int) from public;
revoke execute on function veil.range(text) from public;
revoke execute on function veil.init_bitmap(text, text) from public;
revoke execute on function veil.clear_bitmap(text) from public;
-revoke execute on function veil.bitmap_setbit(text, int4) from public;
-revoke execute on function veil.bitmap_testbit(text, int4) from public;
+revoke execute on function veil.bitmap_setbit(text, int) from public;
+revoke execute on function veil.bitmap_testbit(text, int) from public;
revoke execute on function veil.bitmap_bits(text) from public;
revoke execute on function veil.bitmap_range(text) from public;
revoke execute on function veil.init_bitmap_array(text, text, text)
from public;
revoke execute on function veil.clear_bitmap_array(text) from public;
-revoke execute on function veil.bitmap_from_array(text, text, int4)
+revoke execute on function veil.bitmap_from_array(text, text, int)
from public;
-revoke execute on function veil.bitmap_array_setbit(text, int4, int4)
+revoke execute on function veil.bitmap_array_setbit(text, int, int)
from public;
-revoke execute on function veil.bitmap_array_testbit(text, int4, int4)
+revoke execute on function veil.bitmap_array_testbit(text, int, int)
from public;
-revoke execute on function veil.union_from_bitmap_array(text, text, int4)
+revoke execute on function veil.union_from_bitmap_array(text, text, int)
from public;
-revoke execute on function veil.intersect_from_bitmap_array(text, text, int4)
+revoke execute on function veil.intersect_from_bitmap_array(text, text, int)
from public;
-revoke execute on function veil.bitmap_array_bits(text, int4) from public;
+revoke execute on function veil.bitmap_array_bits(text, int) from public;
revoke execute on function veil.bitmap_array_arange(text) from public;
revoke execute on function veil.bitmap_array_brange(text) from public;
from public;
revoke execute on function veil.bitmap_from_hash(text, text, text)
from public;
-revoke execute on function veil.bitmap_hash_setbit(text, text, int4)
+revoke execute on function veil.bitmap_hash_setbit(text, text, int)
from public;
-revoke execute on function veil.bitmap_hash_testbit(text, text, int4)
+revoke execute on function veil.bitmap_hash_testbit(text, text, int)
from public;
revoke execute on function veil.union_into_bitmap_hash(text, text, text)
from public;
revoke execute on function veil.init_int4array(text, text) from public;
revoke execute on function veil.clear_int4array(text) from public;
-revoke execute on function veil.int4array_set(text, int4, int4) from public;
-revoke execute on function veil.int4array_get(text, int4) from public;
+revoke execute on function veil.int4array_set(text, int, int) from public;
+revoke execute on function veil.int4array_get(text, int) from public;
revoke execute on function veil.veil_init(bool) from public;
revoke execute on function veil.veil_perform_reset() from public;