Bump bpf-tools to v1.20
- Fix C standard library to include only reentrant versions of functions - Use a version of solana_rbpf with fixed relocations handling - Add a test of using C standard library functions in on-chain program
This commit is contained in:
committed by
Dmitri Makarov
parent
c24e30f689
commit
bae5dae61d
20
programs/bpf/c/src/stdlib/stdlib.c
Normal file
20
programs/bpf/c/src/stdlib/stdlib.c
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @brief Example C based BPF program that uses C standard
|
||||
* library functions. The test fails if the C standard
|
||||
* library is not available.
|
||||
*
|
||||
* Only re-entrant versions of standard C library functions are
|
||||
* available. We have to use the _reent structure and pass a pointer
|
||||
* to it as a parameter to a re-entrant function. In this test
|
||||
* _atoi_r is a re-entrant version of the standard atoi function.
|
||||
*/
|
||||
#include <sol/assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern uint64_t entrypoint(const uint8_t *input) {
|
||||
struct _reent reent;
|
||||
int value = _atoi_r(&reent, "137");
|
||||
sol_assert(value == 137);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
@ -441,6 +441,7 @@ fn test_program_bpf_sanity() {
|
||||
("sanity++", true),
|
||||
("secp256k1_recover", true),
|
||||
("sha", true),
|
||||
("stdlib", true),
|
||||
("struct_pass", true),
|
||||
("struct_ret", true),
|
||||
]);
|
||||
|
Reference in New Issue
Block a user