logo

utils-std

Collection of commonly available Unix tools

getentropy.c (529B)


  1. // utils-std: Collection of commonly available Unix tools
  2. // SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. // SPDX-License-Identifier: MPL-2.0
  4. #define _POSIX_C_SOURCE 202405L
  5. #ifndef HAS_POSIX_2024
  6. #define _DEFAULT_SOURCE // getentropy
  7. #endif
  8. #include <unistd.h> // getentropy
  9. int
  10. main(int argc, char *argv[])
  11. {
  12. // Silence unused warnings
  13. (void)argc;
  14. (void)argv;
  15. #define BUFLEN 42
  16. size_t buflen = BUFLEN;
  17. char buf[BUFLEN] = "";
  18. int res = getentropy(buf, buflen);
  19. return res;
  20. }