[libc-commits] [PATCH] D74652: [libc] Add support library for use with tests.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Feb 19 00:59:00 PST 2020


sivachandra added inline comments.


================
Comment at: libc/utils/testutils/Support.h:6
+int sleep(unsigned int seconds);
+void abort();
+
----------------
abrachet wrote:
> We could just do (outside of the namespaces) `extern "C" void abort();` instead of providing this wrapper ourselves. 
> 
> I'm assuming because `sleep`s implementation is in a linux directory that it's called something else on Windows?
Agree about `abort`.

I added `sleep` so that I can write a stop and go test for a mutex implementation. I think on Windows it is this: https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-sleep?redirectedfrom=MSDN


================
Comment at: libc/utils/testutils/Thread.h:13-14
+
+  explicit Thread(FuncTypeNoArg &&F);
+  explicit Thread(FuncTypeOneArg &&F, void *Arg);
+
----------------
abrachet wrote:
> I think these are not very ergonomic because they cannot be instantiated with lambdas. See my top level comment how I think we can do this better.
Inspired by your change, I have updated this now. I did not see a reason to support all possible forms of a callable so I have limited my changes to just that I require for now.


================
Comment at: libc/utils/testutils/linux/sleep.cpp:7
+
+int sleep(unsigned int Seconds) { return ::sleep(Seconds); }
+
----------------
abrachet wrote:
> Out of curiosity, why have you added sleep? Where do you think it will be useful?
> 
Answered above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74652





More information about the libc-commits mailing list