1
2
3
/* automatically generated by rust-bindgen */

pub const RANDOMX_HASH_SIZE : u32 = 32 ; pub const RANDOMX_DATASET_ITEM_SIZE : u32 = 64 ; pub type wchar_t = :: std :: os :: raw :: c_int ; pub type max_align_t = u128 ; pub const randomx_flags_RANDOMX_FLAG_DEFAULT : randomx_flags = 0 ; pub const randomx_flags_RANDOMX_FLAG_LARGE_PAGES : randomx_flags = 1 ; pub const randomx_flags_RANDOMX_FLAG_HARD_AES : randomx_flags = 2 ; pub const randomx_flags_RANDOMX_FLAG_FULL_MEM : randomx_flags = 4 ; pub const randomx_flags_RANDOMX_FLAG_JIT : randomx_flags = 8 ; pub const randomx_flags_RANDOMX_FLAG_SECURE : randomx_flags = 16 ; pub type randomx_flags = u32 ; # [ repr ( C ) ] # [ derive ( Debug , Copy , Clone ) ] pub struct randomx_dataset { _unused : [ u8 ; 0 ] , } # [ repr ( C ) ] # [ derive ( Debug , Copy , Clone ) ] pub struct randomx_cache { _unused : [ u8 ; 0 ] , } # [ repr ( C ) ] # [ derive ( Debug , Copy , Clone ) ] pub struct randomx_vm { _unused : [ u8 ; 0 ] , } extern "C" { # [ doc = " Creates a randomx_cache structure and allocates memory for RandomX Cache." ] # [ doc = "" ] # [ doc = " @param flags is any combination of these 2 flags (each flag can be set or not set):" ] # [ doc = "        RANDOMX_FLAG_LARGE_PAGES - allocate memory in large pages" ] # [ doc = "        RANDOMX_FLAG_JIT - create cache structure with JIT compilation support; this makes" ] # [ doc = "                           subsequent Dataset initialization faster" ] # [ doc = "" ] # [ doc = " @return Pointer to an allocated randomx_cache structure." ] # [ doc = "         NULL is returned if memory allocation fails or if the RANDOMX_FLAG_JIT" ] # [ doc = "         is set and JIT compilation is not supported on the current platform." ] pub fn randomx_alloc_cache ( flags : randomx_flags ) -> * mut randomx_cache ; } extern "C" { # [ doc = " Initializes the cache memory and SuperscalarHash using the provided key value." ] # [ doc = "" ] # [ doc = " @param cache is a pointer to a previously allocated randomx_cache structure. Must not be NULL." ] # [ doc = " @param key is a pointer to memory which contains the key value. Must not be NULL." ] # [ doc = " @param keySize is the number of bytes of the key." ] pub fn randomx_init_cache ( cache : * mut randomx_cache , key : * const :: std :: os :: raw :: c_void , keySize : usize ) ; } extern "C" { # [ doc = " Releases all memory occupied by the randomx_cache structure." ] # [ doc = "" ] # [ doc = " @param cache is a pointer to a previously allocated randomx_cache structure." ] pub fn randomx_release_cache ( cache : * mut randomx_cache ) ; } extern "C" { # [ doc = " Creates a randomx_dataset structure and allocates memory for RandomX Dataset." ] # [ doc = "" ] # [ doc = " @param flags is the initialization flags. Only one flag is supported (can be set or not set):" ] # [ doc = "        RANDOMX_FLAG_LARGE_PAGES - allocate memory in large pages" ] # [ doc = "" ] # [ doc = " @return Pointer to an allocated randomx_dataset structure." ] # [ doc = "         NULL is returned if memory allocation fails." ] pub fn randomx_alloc_dataset ( flags : randomx_flags ) -> * mut randomx_dataset ; } extern "C" { # [ doc = " Gets the number of items contained in the dataset." ] # [ doc = "" ] # [ doc = " @return the number of items contained in the dataset." ] pub fn randomx_dataset_item_count ( ) -> :: std :: os :: raw :: c_ulong ; } extern "C" { # [ doc = " Initializes dataset items." ] # [ doc = "" ] # [ doc = " Note: In order to use the Dataset, all items from 0 to (randomx_dataset_item_count() - 1) must be initialized." ] # [ doc = " This may be done by several calls to this function using non-overlapping item sequences." ] # [ doc = "" ] # [ doc = " @param dataset is a pointer to a previously allocated randomx_dataset structure. Must not be NULL." ] # [ doc = " @param cache is a pointer to a previously allocated and initialized randomx_cache structure. Must not be NULL." ] # [ doc = " @param startItem is the item number where intialization should start." ] # [ doc = " @param itemCount is the number of items that should be initialized." ] pub fn randomx_init_dataset ( dataset : * mut randomx_dataset , cache : * mut randomx_cache , startItem : :: std :: os :: raw :: c_ulong , itemCount : :: std :: os :: raw :: c_ulong ) ; } extern "C" { # [ doc = " Returns a pointer to the internal memory buffer of the dataset structure. The size" ] # [ doc = " of the internal memory buffer is randomx_dataset_item_count() * RANDOMX_DATASET_ITEM_SIZE." ] # [ doc = "" ] # [ doc = " @param dataset is dataset is a pointer to a previously allocated randomx_dataset structure. Must not be NULL." ] # [ doc = "" ] # [ doc = " @return Pointer to the internal memory buffer of the dataset structure." ] pub fn randomx_get_dataset_memory ( dataset : * mut randomx_dataset ) -> * mut :: std :: os :: raw :: c_void ; } extern "C" { # [ doc = " Releases all memory occupied by the randomx_dataset structure." ] # [ doc = "" ] # [ doc = " @param dataset is a pointer to a previously allocated randomx_dataset structure." ] pub fn randomx_release_dataset ( dataset : * mut randomx_dataset ) ; } extern "C" { # [ doc = " Creates and initializes a RandomX virtual machine." ] # [ doc = "" ] # [ doc = " @param flags is any combination of these 5 flags (each flag can be set or not set):" ] # [ doc = "        RANDOMX_FLAG_LARGE_PAGES - allocate scratchpad memory in large pages" ] # [ doc = "        RANDOMX_FLAG_HARD_AES - virtual machine will use hardware accelerated AES" ] # [ doc = "        RANDOMX_FLAG_FULL_MEM - virtual machine will use the full dataset" ] # [ doc = "        RANDOMX_FLAG_JIT - virtual machine will use a JIT compiler" ] # [ doc = "        RANDOMX_FLAG_SECURE - when combined with RANDOMX_FLAG_JIT, the JIT pages are never" ] # [ doc = "                              writable and executable at the same time (W^X policy)" ] # [ doc = "        The numeric values of the first 4 flags are ordered so that a higher value will provide" ] # [ doc = "        faster hash calculation and a lower numeric value will provide higher portability." ] # [ doc = "        Using RANDOMX_FLAG_DEFAULT (all flags not set) works on all platforms, but is the slowest." ] # [ doc = " @param cache is a pointer to an initialized randomx_cache structure. Can be" ] # [ doc = "        NULL if RANDOMX_FLAG_FULL_MEM is set." ] # [ doc = " @param dataset is a pointer to a randomx_dataset structure. Can be NULL" ] # [ doc = "        if RANDOMX_FLAG_FULL_MEM is not set." ] # [ doc = "" ] # [ doc = " @return Pointer to an initialized randomx_vm structure." ] # [ doc = "         Returns NULL if:" ] # [ doc = "         (1) Scratchpad memory allocation fails." ] # [ doc = "         (2) The requested initialization flags are not supported on the current platform." ] # [ doc = "         (3) cache parameter is NULL and RANDOMX_FLAG_FULL_MEM is not set" ] # [ doc = "         (4) dataset parameter is NULL and RANDOMX_FLAG_FULL_MEM is set" ] pub fn randomx_create_vm ( flags : randomx_flags , cache : * mut randomx_cache , dataset : * mut randomx_dataset ) -> * mut randomx_vm ; } extern "C" { # [ doc = " Reinitializes a virtual machine with a new Cache. This function should be called anytime" ] # [ doc = " the Cache is reinitialized with a new key." ] # [ doc = "" ] # [ doc = " @param machine is a pointer to a randomx_vm structure that was initialized" ] # [ doc = "        without RANDOMX_FLAG_FULL_MEM. Must not be NULL." ] # [ doc = " @param cache is a pointer to an initialized randomx_cache structure. Must not be NULL." ] pub fn randomx_vm_set_cache ( machine : * mut randomx_vm , cache : * mut randomx_cache ) ; } extern "C" { # [ doc = " Reinitializes a virtual machine with a new Dataset." ] # [ doc = "" ] # [ doc = " @param machine is a pointer to a randomx_vm structure that was initialized" ] # [ doc = "        with RANDOMX_FLAG_FULL_MEM. Must not be NULL." ] # [ doc = " @param dataset is a pointer to an initialized randomx_dataset structure. Must not be NULL." ] pub fn randomx_vm_set_dataset ( machine : * mut randomx_vm , dataset : * mut randomx_dataset ) ; } extern "C" { # [ doc = " Releases all memory occupied by the randomx_vm structure." ] # [ doc = "" ] # [ doc = " @param machine is a pointer to a previously created randomx_vm structure." ] pub fn randomx_destroy_vm ( machine : * mut randomx_vm ) ; } extern "C" { # [ doc = " Calculates a RandomX hash value." ] # [ doc = "" ] # [ doc = " @param machine is a pointer to a randomx_vm structure. Must not be NULL." ] # [ doc = " @param input is a pointer to memory to be hashed. Must not be NULL." ] # [ doc = " @param inputSize is the number of bytes to be hashed." ] # [ doc = " @param output is a pointer to memory where the hash will be stored. Must not" ] # [ doc = "        be NULL and at least RANDOMX_HASH_SIZE bytes must be available for writing." ] pub fn randomx_calculate_hash ( machine : * mut randomx_vm , input : * const :: std :: os :: raw :: c_void , inputSize : usize , output : * mut :: std :: os :: raw :: c_void ) ; }