[libc-commits] [libc] [libc] Lock the output stream for the 'puts' call (PR #76513)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Thu Dec 28 11:13:51 PST 2023
================
@@ -15,8 +15,21 @@
namespace LIBC_NAMESPACE {
+// Simple helper to unlock the file once destroyed.
+struct ScopedLock {
+ ScopedLock(LIBC_NAMESPACE::File *stream) : stream(stream) { stream->lock(); }
+ ~ScopedLock() { stream->unlock(); }
+
+private:
+ LIBC_NAMESPACE::File *stream;
+};
+
LLVM_LIBC_FUNCTION(int, puts, (const char *__restrict str)) {
----------------
SchrodingerZhu wrote:
why this is marked as `__restrict`?
https://github.com/llvm/llvm-project/pull/76513
More information about the libc-commits
mailing list