[libc-commits] [PATCH] D134665: Implement `getrandom` function for linux targets.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Sep 26 21:42:35 PDT 2022


sivachandra added a comment.

Thanks for the patch and working through all the details. Overall LGTM but needs one code policy related change.



================
Comment at: libc/include/llvm-libc-macros/linux/sys-random-macros.h:15
+#define GRND_NONBLOCK 0x0002
+#define GRND_INSECURE 0x0004
+#endif // __LLVM_LIBC_MACROS_LINUX_SYS_STAT_MACROS_H
----------------
An empty line between 15 and 16?


================
Comment at: libc/test/src/sys/random/linux/getrandom_test.cpp:5
+
+#include <cmath>
+#include <sys/random.h>
----------------
We don't include C++ headers from unit tests. Also, for functions like `fabs`, we use internal functions. So:

1. Either add `M_PI` definition to `math.h` or use a constant for this test.
2. Instead of `::fabs`, use `__llvm_libc::fabs`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134665/new/

https://reviews.llvm.org/D134665



More information about the libc-commits mailing list