Skip to content

Commit

Permalink
Merge pull request #107 from Dr-Emann/new_funcs_from_upstream
Browse files Browse the repository at this point in the history
Port `get_index` and the bitset functions
  • Loading branch information
saulius committed Jun 20, 2023
2 parents 16720b5 + 40b4660 commit 46b6d62
Show file tree
Hide file tree
Showing 19 changed files with 980 additions and 62 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ download_croaring:
bindgen:
cd '$(croaring_source)' && \
bindgen --generate-inline-functions \
--allowlist-function 'roaring.*' \
--allowlist-type 'roaring.*' \
--allowlist-var '(?i:roaring).*' \
--allowlist-function 'roaring.*|bitset.*' \
--allowlist-type 'roaring.*|bitset.*' \
--allowlist-var '(?i:roaring|bitset).*' \
-o bindgen_bundled_version.rs \
roaring.h

Expand Down
72 changes: 70 additions & 2 deletions croaring-sys/CRoaring/bindgen_bundled_version.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* automatically generated by rust-bindgen 0.65.1 */

pub const ROARING_VERSION: &[u8; 6usize] = b"1.2.0\0";
pub const ROARING_VERSION: &[u8; 6usize] = b"1.3.0\0";
pub const ROARING_VERSION_MAJOR: _bindgen_ty_1 = 1;
pub const ROARING_VERSION_MINOR: _bindgen_ty_1 = 2;
pub const ROARING_VERSION_MINOR: _bindgen_ty_1 = 3;
pub const ROARING_VERSION_REVISION: _bindgen_ty_1 = 0;
pub type _bindgen_ty_1 = ::std::os::raw::c_uint;
#[doc = " Roaring arrays are array-based key-value pairs having containers as values\n and 16-bit integer keys. A roaring bitmap might be implemented as such."]
Expand Down Expand Up @@ -349,6 +349,15 @@ extern "C" {
extern "C" {
pub fn bitset_resize(bitset: *mut bitset_t, newarraysize: usize, padwithzeroes: bool) -> bool;
}
extern "C" {
pub fn bitset_size_in_bytes(bitset: *const bitset_t) -> usize;
}
extern "C" {
pub fn bitset_size_in_bits(bitset: *const bitset_t) -> usize;
}
extern "C" {
pub fn bitset_size_in_words(bitset: *const bitset_t) -> usize;
}
extern "C" {
pub fn bitset_grow(bitset: *mut bitset_t, newarraysize: usize) -> bool;
}
Expand All @@ -361,6 +370,15 @@ extern "C" {
extern "C" {
pub fn bitset_shift_right(bitset: *mut bitset_t, s: usize);
}
extern "C" {
pub fn bitset_set(bitset: *mut bitset_t, i: usize);
}
extern "C" {
pub fn bitset_set_to_value(bitset: *mut bitset_t, i: usize, flag: bool);
}
extern "C" {
pub fn bitset_get(bitset: *const bitset_t, i: usize) -> bool;
}
extern "C" {
pub fn bitset_count(bitset: *const bitset_t) -> usize;
}
Expand Down Expand Up @@ -403,9 +421,30 @@ extern "C" {
extern "C" {
pub fn bitset_symmetric_difference_count(b1: *const bitset_t, b2: *const bitset_t) -> usize;
}
extern "C" {
pub fn bitset_next_set_bit(bitset: *const bitset_t, i: *mut usize) -> bool;
}
extern "C" {
pub fn bitset_next_set_bits(
bitset: *const bitset_t,
buffer: *mut usize,
capacity: usize,
startfrom: *mut usize,
) -> usize;
}
pub type bitset_iterator = ::std::option::Option<
unsafe extern "C" fn(value: usize, param: *mut ::std::os::raw::c_void) -> bool,
>;
extern "C" {
pub fn bitset_for_each(
b: *const bitset_t,
iterator: bitset_iterator,
ptr: *mut ::std::os::raw::c_void,
) -> bool;
}
extern "C" {
pub fn bitset_print(b: *const bitset_t);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct roaring_bitmap_s {
Expand Down Expand Up @@ -441,10 +480,18 @@ extern "C" {
#[doc = " Dynamically allocates a new bitmap (initially empty).\n Returns NULL if the allocation fails.\n Capacity is a performance hint for how many \"containers\" the data will need.\n Client is responsible for calling `roaring_bitmap_free()`."]
pub fn roaring_bitmap_create_with_capacity(cap: u32) -> *mut roaring_bitmap_t;
}
extern "C" {
#[doc = " Dynamically allocates a new bitmap (initially empty).\n Returns NULL if the allocation fails.\n Client is responsible for calling `roaring_bitmap_free()`."]
pub fn roaring_bitmap_create() -> *mut roaring_bitmap_t;
}
extern "C" {
#[doc = " Initialize a roaring bitmap structure in memory controlled by client.\n Capacity is a performance hint for how many \"containers\" the data will need.\n Can return false if auxiliary allocations fail when capacity greater than 0."]
pub fn roaring_bitmap_init_with_capacity(r: *mut roaring_bitmap_t, cap: u32) -> bool;
}
extern "C" {
#[doc = " Initialize a roaring bitmap structure in memory controlled by client.\n The bitmap will be in a \"clear\" state, with no auxiliary allocations.\n Since this performs no allocations, the function will not fail."]
pub fn roaring_bitmap_init_cleared(r: *mut roaring_bitmap_t);
}
extern "C" {
#[doc = " Add all the values between min (included) and max (excluded) that are at a\n distance k*step from min."]
pub fn roaring_bitmap_from_range(min: u64, max: u64, step: u32) -> *mut roaring_bitmap_t;
Expand All @@ -453,6 +500,12 @@ extern "C" {
#[doc = " Creates a new bitmap from a pointer of uint32_t integers"]
pub fn roaring_bitmap_of_ptr(n_args: usize, vals: *const u32) -> *mut roaring_bitmap_t;
}
extern "C" {
pub fn roaring_bitmap_get_copy_on_write(r: *const roaring_bitmap_t) -> bool;
}
extern "C" {
pub fn roaring_bitmap_set_copy_on_write(r: *mut roaring_bitmap_t, cow: bool);
}
extern "C" {
pub fn roaring_bitmap_add_offset(
bm: *const roaring_bitmap_t,
Expand Down Expand Up @@ -689,6 +742,10 @@ extern "C" {
#[doc = " Add all values in range [min, max]"]
pub fn roaring_bitmap_add_range_closed(r: *mut roaring_bitmap_t, min: u32, max: u32);
}
extern "C" {
#[doc = " Add all values in range [min, max)"]
pub fn roaring_bitmap_add_range(r: *mut roaring_bitmap_t, min: u64, max: u64);
}
extern "C" {
#[doc = " Remove value x"]
pub fn roaring_bitmap_remove(r: *mut roaring_bitmap_t, x: u32);
Expand All @@ -697,6 +754,10 @@ extern "C" {
#[doc = " Remove all values in range [min, max]"]
pub fn roaring_bitmap_remove_range_closed(r: *mut roaring_bitmap_t, min: u32, max: u32);
}
extern "C" {
#[doc = " Remove all values in range [min, max)"]
pub fn roaring_bitmap_remove_range(r: *mut roaring_bitmap_t, min: u64, max: u64);
}
extern "C" {
#[doc = " Remove multiple values"]
pub fn roaring_bitmap_remove_many(r: *mut roaring_bitmap_t, n_args: usize, vals: *const u32);
Expand Down Expand Up @@ -785,6 +846,13 @@ extern "C" {
#[doc = " Use with `roaring_bitmap_serialize()`.\n\n (See `roaring_bitmap_portable_deserialize()` if you want a format that's\n compatible with Java and Go implementations).\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a mainframe IBM s390x),\n the data format is going to be big-endian and not compatible with little-endian systems."]
pub fn roaring_bitmap_deserialize(buf: *const ::std::os::raw::c_void) -> *mut roaring_bitmap_t;
}
extern "C" {
#[doc = " Use with `roaring_bitmap_serialize()`.\n\n (See `roaring_bitmap_portable_deserialize_safe()` if you want a format that's\n compatible with Java and Go implementations).\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a mainframe IBM s390x),\n the data format is going to be big-endian and not compatible with little-endian systems.\n\n The difference with `roaring_bitmap_deserialize()` is that this function checks that the input buffer\n is a valid bitmap. If the buffer is too small, NULL is returned."]
pub fn roaring_bitmap_deserialize_safe(
buf: *const ::std::os::raw::c_void,
maxbytes: usize,
) -> *mut roaring_bitmap_t;
}
extern "C" {
#[doc = " How many bytes are required to serialize this bitmap (NOT compatible\n with Java and Go versions)"]
pub fn roaring_bitmap_size_in_bytes(r: *const roaring_bitmap_t) -> usize;
Expand Down
Loading

0 comments on commit 46b6d62

Please sign in to comment.