getrandom.patch 911 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. --- a/include/random/sys/random.h (index)
  2. +++ b/include/random/sys/random.h (working tree)
  3. @@ -4,9 +4,9 @@
  4. extern "C" {
  5. #endif
  6. -#define __NEED_size_t
  7. -#define __NEED_ssize_t
  8. -#include <bits/alltypes.h>
  9. +#include <sys/types.h>
  10. +
  11. +#if !defined(SYS_getrandom)
  12. +#if defined(__x86_64__)
  13. + #define SYS_getrandom 318
  14. +#elif defined(__i386__)
  15. + #define SYS_getrandom 355
  16. +#elif defined(__aarch64__)
  17. + #define SYS_getrandom 278
  18. +#elif defined(__arm__)
  19. + #define SYS_getrandom 384
  20. +#elif defined(__powerpc__)
  21. + #define SYS_getrandom 359
  22. +#else
  23. +#error Unsupported platform
  24. +#endif
  25. +#endif
  26. #define GRND_NONBLOCK 0x0001
  27. #define GRND_RANDOM 0x0002
  28. --- a/getrandom.c (index)
  29. +++ b/getrandom.c (working tree)
  30. @@ -3,5 +3,5 @@
  31. ssize_t getrandom(void *buf, size_t buflen, unsigned flags)
  32. {
  33. - return syscall_cp(SYS_getrandom, buf, buflen, flags);
  34. + return syscall(SYS_getrandom, buf, buflen, flags);
  35. }