[libc-commits] [PATCH] D155762: [libc] Remove global constructors on File type
Joseph Huber via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Jul 20 06:11:37 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc92212d75df: [libc] Remove global constructors on File type (authored by jhuber6).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155762/new/
https://reviews.llvm.org/D155762
Files:
libc/src/__support/File/file.h
Index: libc/src/__support/File/file.h
===================================================================
--- libc/src/__support/File/file.h
+++ libc/src/__support/File/file.h
@@ -151,15 +151,6 @@
static_cast<ModeFlags>(OpenMode::PLUS));
}
- // The GPU build should not emit a destructor because we do not support global
- // destructors in all cases and it is unneccessary without buffering.
-#if !defined(LIBC_TARGET_ARCH_IS_GPU)
- ~File() {
- if (own_buf)
- delete buf;
- }
-#endif
-
public:
// We want this constructor to be constexpr so that global file objects
// like stdout do not require invocation of the constructor which can
@@ -234,6 +225,13 @@
}
}
}
+
+ // If we own the buffer, delete it before calling the platform close
+ // implementation. The platform close should not need to access the buffer
+ // and we need to clean it up before the entire structure is removed.
+ if (own_buf)
+ delete buf;
+
// Platform close is expected to cleanup the file data structure which
// includes the file mutex. Hence, we call platform_close after releasing
// the file lock. Another thread doing file operations while a thread is
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155762.542479.patch
Type: text/x-patch
Size: 1232 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230720/619cffad/attachment.bin>
More information about the libc-commits
mailing list