[flang-commits] [flang] [Flang] Implement RENAME intrinsic (code-gen + runtime entry point) (PR #98359)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Thu Jul 11 02:45:20 PDT 2024


================
@@ -55,6 +55,30 @@ static RT_API_ATTRS void TransferImpl(Descriptor &result,
 extern "C" {
 RT_EXT_API_GROUP_BEGIN
 
+void RTDECL(Rename)(const Descriptor &path1, const Descriptor &path2,
+    const Descriptor *status, const char *sourceFile, int line) {
+  Terminator terminator{sourceFile, line};
+
+  char *pathSrc{EnsureNullTerminated(
+      path1.OffsetElement(), path1.ElementBytes(), terminator)};
+  char *pathDst{EnsureNullTerminated(
+      path2.OffsetElement(), path2.ElementBytes(), terminator)};
+
+  // We simply call rename(2) from POSIX
+  int result = rename(pathSrc, pathDst);
+  if (status) {
+    StoreIntToDescriptor(status, result, terminator);
----------------
tblah wrote:

Just a suggestion, feel free to ignore:

If the result is non-zero it would be more useful to return `errno` to indicate what went wrong instead of just `-1` (glibc) or an implementation defined non-zero value (Windows)

https://github.com/llvm/llvm-project/pull/98359


More information about the flang-commits mailing list