diff --git a/programs/bpf/c/sdk/inc/solana_sdk.h b/programs/bpf/c/sdk/inc/solana_sdk.h index 9ecf4c8b26..f283529dc9 100644 --- a/programs/bpf/c/sdk/inc/solana_sdk.h +++ b/programs/bpf/c/sdk/inc/solana_sdk.h @@ -32,6 +32,8 @@ typedef signed int int32_t; typedef unsigned int uint32_t; typedef signed long int int64_t; typedef unsigned long int uint64_t; +typedef int64_t ssize_t; +typedef uint64_t size_t; #if defined (__cplusplus) || defined(static_assert) static_assert(sizeof(int8_t) == 1); @@ -136,6 +138,30 @@ SOL_FN_PREFIX int sol_memcmp(const void *s1, const void *s2, int n) { return 0; } +/** + * Fill a byte string with a byte value + */ +SOL_FN_PREFIX void *sol_memset(void *b, int c, size_t len) { + uint8_t *a = (uint8_t *) b; + while (len > 0) { + *a = c; + a++; + len--; + } +} + +/** + * Find length of string + */ +SOL_FN_PREFIX size_t sol_strlen(const char *s) { + size_t len = 0; + while (*s) { + len++; + s++; + } + return len; +} + /** * Computes the number of elements in an array */