Electroneum
CryptonightR_JIT.h
Go to the documentation of this file.
1 #ifndef CRYPTONIGHTR_JIT_H
2 #define CRYPTONIGHTR_JIT_H
3 
4 // Minimalistic JIT code generator for random math sequence in CryptonightR
5 //
6 // Usage:
7 // - Allocate writable and executable memory
8 // - Call v4_generate_JIT_code with "buf" pointed to memory allocated on previous step
9 // - Call the generated code instead of "v4_random_math(code, r)", omit the "code" parameter
10 
11 typedef void (*v4_random_math_JIT_func)(uint32_t* r)
12 #if defined __i386 || defined __x86_64__
13 __attribute__((sysv_abi))
14 #endif
15 ;
16 
17 // Given the random math sequence, generates machine code (x86-64) for it
18 // Returns 0 if code was generated successfully
19 // Returns -1 if provided buffer was too small
20 int v4_generate_JIT_code(const struct V4_Instruction* code, v4_random_math_JIT_func buf, const size_t buf_size);
21 
22 #endif // CRYPTONIGHTR_JIT_H
unsigned int uint32_t
Definition: stdint.h:126
void(* v4_random_math_JIT_func)(uint32_t *r)
const char * buf
Definition: slow_memmem.cpp:74
__attribute__((noreturn)) void CXA_THROW(void *ex
int v4_generate_JIT_code(const struct V4_Instruction *code, v4_random_math_JIT_func buf, const size_t buf_size)