Multi-file BPF C builds (#2393)
This commit is contained in:
11
programs/bpf/c/src/bench_alu/test_bench_alu.c
Normal file
11
programs/bpf/c/src/bench_alu/test_bench_alu.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <criterion/criterion.h>
|
||||
#include "bench_alu.c"
|
||||
|
||||
Test(bench_alu, sanity) {
|
||||
uint64_t input[] = {500, 0};
|
||||
|
||||
cr_assert(entrypoint((uint8_t *) input));
|
||||
|
||||
cr_assert_eq(input[0], 500);
|
||||
cr_assert_eq(input[1], 5);
|
||||
}
|
14
programs/bpf/c/src/multiple_file/entrypoint.c
Normal file
14
programs/bpf/c/src/multiple_file/entrypoint.c
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @brief Example C-based BPF program that prints out the parameters
|
||||
* passed to it
|
||||
*/
|
||||
#include <solana_sdk.h>
|
||||
|
||||
#include "helper.h"
|
||||
|
||||
extern bool entrypoint(const uint8_t *input) {
|
||||
sol_log(__FILE__);
|
||||
helper_function();
|
||||
sol_log(__FILE__);
|
||||
return true;
|
||||
}
|
11
programs/bpf/c/src/multiple_file/helper.c
Normal file
11
programs/bpf/c/src/multiple_file/helper.c
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @brief Example C-based BPF program that prints out the parameters
|
||||
* passed to it
|
||||
*/
|
||||
#include <solana_sdk.h>
|
||||
|
||||
#include "helper.h"
|
||||
|
||||
void helper_function(void) {
|
||||
sol_log(__FILE__);
|
||||
}
|
7
programs/bpf/c/src/multiple_file/helper.h
Normal file
7
programs/bpf/c/src/multiple_file/helper.h
Normal file
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* @brief Example C-based BPF program that prints out the parameters
|
||||
* passed to it
|
||||
*/
|
||||
#include <solana_sdk.h>
|
||||
|
||||
void helper_function(void);
|
@ -28,3 +28,4 @@ extern bool entrypoint(const uint8_t *input) {
|
||||
sol_log_params(ka, ka_len, data, data_len);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user