Tor 0.4.9.2-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
program.h
1/* Copyright (c) 2020 tevador <tevador@gmail.com> */
2/* See LICENSE for licensing information */
3
4#ifndef PROGRAM_H
5#define PROGRAM_H
6
7#include <stdint.h>
8#include <stdbool.h>
9#include <hashx.h>
10#include "instruction.h"
11#include "siphash.h"
12#include "blake2.h"
13
14#define HASHX_PROGRAM_MAX_SIZE 512
15
16typedef struct hashx_program {
17 instruction code[HASHX_PROGRAM_MAX_SIZE];
18 size_t code_size;
19#ifdef HASHX_PROGRAM_STATS
20 unsigned counter;
21 double ipc;
22 int x86_size;
23 int cpu_latency;
24 int asic_latency;
25 int mul_count;
26 int wide_mul_count;
27 int cpu_latencies[8];
28 int asic_latencies[8];
29 int branch_count;
30 int branches[16];
31#endif
32#ifdef HASHX_RNG_CALLBACK
33 void (*rng_callback)(uint64_t *buffer, void *user_data);
34 void *rng_callback_user_data;
35#endif
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42HASHX_PRIVATE bool hashx_program_generate(const siphash_state* key, hashx_program* program);
43
44HASHX_PRIVATE void hashx_program_execute(const hashx_program* program, uint64_t r[8]);
45
46HASHX_PRIVATE void hashx_program_asm_x86(const hashx_program* program);
47
48#ifdef __cplusplus
49}
50#endif
51
52#endif