Skip to content

Commit 345db35

Browse files
authored
Merge pull request #357 from shawn-willden-ai/no_std
Add no_std feature to lmdb-master-sys
2 parents 1262931 + 5734bcf commit 345db35

8 files changed

Lines changed: 18 additions & 12 deletions

File tree

lmdb-master-sys/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ cstr = "0.2.12"
3838

3939
[features]
4040
default = []
41+
no_std = []
4142
asan = []
4243
fuzzer = []
4344
fuzzer-no-link = []

lmdb-master-sys/bindgen.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub fn generate() {
6060
.allowlist_function("^(MDB|mdb)_.*")
6161
.size_t_is_usize(true)
6262
.ctypes_prefix("::libc")
63+
.use_core()
6364
.blocklist_item("mode_t")
6465
.blocklist_item("mdb_mode_t")
6566
.blocklist_item("mdb_filehandle_t")

lmdb-master-sys/src/bindings.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ pub struct MDB_val {
8585
pub mv_data: *mut ::libc::c_void,
8686
}
8787
#[doc = "A callback function used to compare two keys in a database"]
88-
pub type MDB_cmp_func = ::std::option::Option<
88+
pub type MDB_cmp_func = ::core::option::Option<
8989
unsafe extern "C" fn(a: *const MDB_val, b: *const MDB_val) -> ::libc::c_int,
9090
>;
9191
#[doc = "A callback function used to relocate a position-dependent data item\n in a fixed-address database.\n\n The **newptr** gives the item's desired address in\n the memory map, and **oldptr** gives its previous address. The item's actual\n data resides at the address in **item.** This callback is expected to walk\n through the fields of the record in **item** and modify any\n values based at the **oldptr** address to be relative to the **newptr** address.\n # Arguments\n\n* `item` (direction in, out) - The item that is to be relocated.\n * `oldptr` (direction in) - The previous address.\n * `newptr` (direction in) - The new address to relocate to.\n * `relctx` (direction in) - An application-provided context, set by #mdb_set_relctx().\n This feature is currently unimplemented."]
92-
pub type MDB_rel_func = ::std::option::Option<
92+
pub type MDB_rel_func = ::core::option::Option<
9393
unsafe extern "C" fn(
9494
item: *mut MDB_val,
9595
oldptr: *mut ::libc::c_void,
@@ -287,7 +287,7 @@ extern "C" {
287287
}
288288
#[doc = "A callback function for most LMDB assert() failures,\n called before printing the message and aborting.\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create().\n * `msg` (direction in) - The assertion message, not including newline."]
289289
pub type MDB_assert_func =
290-
::std::option::Option<unsafe extern "C" fn(env: *mut MDB_env, msg: *const ::libc::c_char)>;
290+
::core::option::Option<unsafe extern "C" fn(env: *mut MDB_env, msg: *const ::libc::c_char)>;
291291
extern "C" {
292292
#[doc = "Set or reset the assert() callback of the environment.\n Disabled if liblmdb is built with NDEBUG.\n > **Note:** This hack should become obsolete as lmdb's error handling matures.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create().\n * `func` (direction in) - An #MDB_assert_func function, or 0.\n # Returns\n\nA non-zero error value on failure and 0 on success."]
293293
pub fn mdb_env_set_assert(env: *mut MDB_env, func: MDB_assert_func) -> ::libc::c_int;
@@ -471,7 +471,7 @@ extern "C" {
471471
) -> ::libc::c_int;
472472
}
473473
#[doc = "A callback function used to print a message from the library.\n\n # Arguments\n\n* `msg` (direction in) - The string to be printed.\n * `ctx` (direction in) - An arbitrary context pointer for the callback.\n # Returns\n\n< 0 on failure, >= 0 on success."]
474-
pub type MDB_msg_func = ::std::option::Option<
474+
pub type MDB_msg_func = ::core::option::Option<
475475
unsafe extern "C" fn(msg: *const ::libc::c_char, ctx: *mut ::libc::c_void) -> ::libc::c_int,
476476
>;
477477
extern "C" {

lmdb-master-sys/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_camel_case_types)]
55
#![allow(clippy::all)]
66
#![doc(html_root_url = "https://docs.rs/lmdb-master-sys/0.2.5")]
7+
#![cfg_attr(feature = "no_std", no_std)]
78

89
extern crate libc;
910

lmdb-master3-sys/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ cstr = "0.2.12"
3838

3939
[features]
4040
default = []
41+
no_std = []
4142
asan = []
4243
fuzzer = []
4344
fuzzer-no-link = []

lmdb-master3-sys/bindgen.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub fn generate() {
6060
.allowlist_function("^(MDB|mdb)_.*")
6161
.size_t_is_usize(true)
6262
.ctypes_prefix("::libc")
63+
.use_core()
6364
.blocklist_item("mode_t")
6465
.blocklist_item("mdb_mode_t")
6566
.blocklist_item("mdb_filehandle_t")

lmdb-master3-sys/src/bindings.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ pub struct MDB_val {
9191
pub mv_data: *mut ::libc::c_void,
9292
}
9393
#[doc = "A callback function used to compare two keys in a database"]
94-
pub type MDB_cmp_func = ::std::option::Option<
94+
pub type MDB_cmp_func = ::core::option::Option<
9595
unsafe extern "C" fn(a: *const MDB_val, b: *const MDB_val) -> ::libc::c_int,
9696
>;
9797
#[doc = "A callback function used to relocate a position-dependent data item\n in a fixed-address database.\n\n The **newptr** gives the item's desired address in\n the memory map, and **oldptr** gives its previous address. The item's actual\n data resides at the address in **item.** This callback is expected to walk\n through the fields of the record in **item** and modify any\n values based at the **oldptr** address to be relative to the **newptr** address.\n # Arguments\n\n* `item` (direction in, out) - The item that is to be relocated.\n * `oldptr` (direction in) - The previous address.\n * `newptr` (direction in) - The new address to relocate to.\n * `relctx` (direction in) - An application-provided context, set by #mdb_set_relctx().\n This feature is currently unimplemented."]
98-
pub type MDB_rel_func = ::std::option::Option<
98+
pub type MDB_rel_func = ::core::option::Option<
9999
unsafe extern "C" fn(
100100
item: *mut MDB_val,
101101
oldptr: *mut ::libc::c_void,
@@ -104,7 +104,7 @@ pub type MDB_rel_func = ::std::option::Option<
104104
),
105105
>;
106106
#[doc = "A callback function used to encrypt/decrypt pages in the env.\n\n Encrypt or decrypt the data in src and store the result in dst using the\n provided key. The result must be the same number of bytes as the input.\n # Arguments\n\n* `src` (direction in) - The input data to be transformed.\n * `dst` (direction out) - Storage for the result.\n * `key` (direction in) - An array of three values: key[0] is the encryption key,\n key[1] is the initialization vector, and key[2] is the authentication\n data, if any.\n * `encdec` (direction in) - 1 to encrypt, 0 to decrypt.\n # Returns\n\nA non-zero error value on failure and 0 on success."]
107-
pub type MDB_enc_func = ::std::option::Option<
107+
pub type MDB_enc_func = ::core::option::Option<
108108
unsafe extern "C" fn(
109109
src: *const MDB_val,
110110
dst: *mut MDB_val,
@@ -113,7 +113,7 @@ pub type MDB_enc_func = ::std::option::Option<
113113
) -> ::libc::c_int,
114114
>;
115115
#[doc = "A callback function used to checksum pages in the env.\n\n Compute the checksum of the data in src and store the result in dst,\n An optional key may be used with keyed hash algorithms.\n # Arguments\n\n* `src` (direction in) - The input data to be transformed.\n * `dst` (direction out) - Storage for the result.\n * `key` (direction in) - An encryption key, if encryption was configured. This\n parameter will be NULL if there is no key."]
116-
pub type MDB_sum_func = ::std::option::Option<
116+
pub type MDB_sum_func = ::core::option::Option<
117117
unsafe extern "C" fn(src: *const MDB_val, dst: *mut MDB_val, key: *const MDB_val),
118118
>;
119119
#[doc = "< Position at first key/data item"]
@@ -310,7 +310,7 @@ extern "C" {
310310
}
311311
#[doc = "A callback function for most LMDB assert() failures,\n called before printing the message and aborting.\n\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create().\n * `msg` (direction in) - The assertion message, not including newline."]
312312
pub type MDB_assert_func =
313-
::std::option::Option<unsafe extern "C" fn(env: *mut MDB_env, msg: *const ::libc::c_char)>;
313+
::core::option::Option<unsafe extern "C" fn(env: *mut MDB_env, msg: *const ::libc::c_char)>;
314314
extern "C" {
315315
#[doc = "Set or reset the assert() callback of the environment.\n Disabled if liblmdb is built with NDEBUG.\n > **Note:** This hack should become obsolete as lmdb's error handling matures.\n # Arguments\n\n* `env` (direction in) - An environment handle returned by #mdb_env_create().\n * `func` (direction in) - An #MDB_assert_func function, or 0.\n # Returns\n\nA non-zero error value on failure and 0 on success."]
316316
pub fn mdb_env_set_assert(env: *mut MDB_env, func: MDB_assert_func) -> ::libc::c_int;
@@ -515,7 +515,7 @@ extern "C" {
515515
) -> ::libc::c_int;
516516
}
517517
#[doc = "A callback function used to print a message from the library.\n\n # Arguments\n\n* `msg` (direction in) - The string to be printed.\n * `ctx` (direction in) - An arbitrary context pointer for the callback.\n # Returns\n\n< 0 on failure, >= 0 on success."]
518-
pub type MDB_msg_func = ::std::option::Option<
518+
pub type MDB_msg_func = ::core::option::Option<
519519
unsafe extern "C" fn(msg: *const ::libc::c_char, ctx: *mut ::libc::c_void) -> ::libc::c_int,
520520
>;
521521
extern "C" {
@@ -531,7 +531,7 @@ extern "C" {
531531
pub fn mdb_reader_check(env: *mut MDB_env, dead: *mut ::libc::c_int) -> ::libc::c_int;
532532
}
533533
#[doc = "A function for converting a string into an encryption key.\n\n # Arguments\n\n* `passwd` (direction in) - The string to be converted.\n * `key` (direction in, out) - The resulting key. The caller must\n provide the space for the key.\n # Returns\n\n0 on success, non-zero on failure."]
534-
pub type MDB_str2key_func = ::std::option::Option<
534+
pub type MDB_str2key_func = ::core::option::Option<
535535
unsafe extern "C" fn(passwd: *const ::libc::c_char, key: *mut MDB_val) -> ::libc::c_int,
536536
>;
537537
#[doc = "A structure for dynamically loaded crypto modules.\n\n This is the information that the command line tools expect\n in order to operate on encrypted or checksummed environments."]
@@ -549,4 +549,4 @@ pub struct MDB_crypto_funcs {
549549
pub mcf_sumsize: ::libc::c_int,
550550
}
551551
#[doc = "The function that returns the #MDB_crypto_funcs structure.\n\n The command line tools expect this function to be named \"MDB_crypto\".\n It must be exported by the dynamic module so that the tools can use it.\n # Returns\n\nA pointer to a #MDB_crypto_funcs structure."]
552-
pub type MDB_crypto_hooks = ::std::option::Option<unsafe extern "C" fn() -> *mut MDB_crypto_funcs>;
552+
pub type MDB_crypto_hooks = ::core::option::Option<unsafe extern "C" fn() -> *mut MDB_crypto_funcs>;

lmdb-master3-sys/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_camel_case_types)]
55
#![allow(clippy::all)]
66
#![doc(html_root_url = "https://docs.rs/lmdb-master-sys/0.2.5")]
7+
#![cfg_attr(feature = "no_std", no_std)]
78

89
extern crate libc;
910

0 commit comments

Comments
 (0)