Collection of miscellaneous portable C snippets.
µnit has some, like `munit_rand_int_range`. @jibsen, IIRC you did some work on those functions, would you mind if I relicensed them to public domain (CC0) and merged them into psnip? It would probably also be a good idea to provide `psnip_random_int`, `psnip_random_double`… Ideally I'd like to just have a macro like ```c #define psnip_random_value(source, T) \ ({ T psinp_random__tmp; \ psnip_random_bytes(src, sizeof(T), &tmp); \ psnip_random__tmp; }) ``` But that's a GCC extension; IIRC clang and icc support it, but I don't think there is a way to implement it with MSVC. I think the best we'll be able to do is something like ```c #define PSNIP_RANDOM_DEFINE_VALUE_FUNC(T, func_name) \ __attribute__((__unused__)) \ static inline T func_name (enum PSnipRandomSource source) { \ T tmpval_; \ psnip_random_bytes(source, sizeof(T), &tmpval_); \ return tmpval_; \ } PSNIP_RANDOM_DEFINE_VALUE_FUNC(char, psnip_random_char) PSNIP_RANDOM_DEFINE_VALUE_FUNC(short, psnip_random_short) PSNIP_RANDOM_DEFINE_VALUE_FUNC(int, psnip_random_int) ... ``` With appropriate macros for the unused attribute and the inline keyword, of course.
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be still under discussion. The issue was opened by nemequ and has received 1 comments.