1
0
mirror of https://github.com/opa334/TrollStore.git synced 2025-02-19 03:55:39 +08:00
TrollStore/RootHelper/external/include/choma/Util.h

34 lines
1.0 KiB
C
Raw Normal View History

2024-01-12 22:40:20 +08:00
#ifndef UTIL_H
#define UTIL_H
#include <stdint.h>
#include <stdlib.h>
2024-01-12 22:40:20 +08:00
#include <stdbool.h>
typedef struct s_optional_uint64 {
bool isSet;
uint64_t value;
} optional_uint64_t;
#define OPT_UINT64_IS_SET(x) (x.isSet)
#define OPT_UINT64_GET_VAL(x) (x.value)
#define OPT_UINT64_NONE (optional_uint64_t){.isSet = false, .value = 0}
#define OPT_UINT64(x) (optional_uint64_t){.isSet = true, .value = x}
2024-01-12 22:40:20 +08:00
typedef struct s_optional_bool {
bool isSet;
bool value;
} optional_bool;
#define OPT_BOOL_IS_SET(x) (x.isSet)
#define OPT_BOOL_GET_VAL(x) (x.value)
#define OPT_BOOL_NONE (optional_bool){.isSet = false, .value = false}
#define OPT_BOOL(x) (optional_bool){.isSet = true, .value = x}
int64_t sxt64(int64_t value, uint8_t bits);
int memcmp_masked(const void *str1, const void *str2, unsigned char* mask, size_t n);
uint64_t align_to_size(int size, int alignment);
int count_digits(int64_t num);
2024-01-12 22:40:20 +08:00
void print_hash(uint8_t *hash, size_t size);
void enumerate_range(uint64_t start, uint64_t end, uint16_t alignment, size_t nbytes, bool (^enumerator)(uint64_t cur));
#endif