random.h 625 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. #include <sys/types.h>
  6. #if !defined(SYS_getrandom)
  7. #if defined(__x86_64__)
  8. #define SYS_getrandom 318
  9. #elif defined(__i386__)
  10. #define SYS_getrandom 355
  11. #elif defined(__aarch64__)
  12. #define SYS_getrandom 278
  13. #elif defined(__arm__)
  14. #define SYS_getrandom 384
  15. #elif defined(__powerpc__)
  16. #define SYS_getrandom 359
  17. #else
  18. #error Unsupported platform
  19. #endif
  20. #endif
  21. #define GRND_NONBLOCK 0x0001
  22. #define GRND_RANDOM 0x0002
  23. #define GRND_INSECURE 0x0004
  24. ssize_t getrandom(void* buf, size_t buflen, unsigned int flags);
  25. #ifdef __cplusplus
  26. } // extern "C"
  27. #endif