[clang-tools-extra] [flang] [clang] [llvm] [flang ]GETLOG runtime and extension implementation: get login username (PR #70917)
@@ -9,6 +9,17 @@ // Defines the API between compiled code and the implementations of time-related // intrinsic subroutines in the runtime library. +// time-intrinsic.h +#ifndef TIME_INTRINSIC_H +#define TIME_INTRINSIC_H + +#include + +void copyBufferAndPad( +char *dest, std::size_t destChars, char *buffer, std::size_t len); yi-wu-arm wrote: Thanks for pointing this out! https://github.com/llvm/llvm-project/pull/70917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [flang] [clang] [llvm] [flang ]GETLOG runtime and extension implementation: get login username (PR #70917)
https://github.com/DavidTruby edited https://github.com/llvm/llvm-project/pull/70917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [flang] [clang] [llvm] [flang ]GETLOG runtime and extension implementation: get login username (PR #70917)
@@ -37,5 +75,19 @@ void FORTRAN_PROCEDURE_NAME(getarg)( (void)RTNAME(GetCommandArgument)( n, , nullptr, nullptr, __FILE__, __LINE__); } + +void FORTRAN_PROCEDURE_NAME(getlog)(std::int8_t *arg, std::int64_t length) { + std::array str; + int error = getlogin_r(str.data(), str.size()); + assert(error == 0 && "getlogin_r returned an error"); + + // Trim space from right/end + int i = str.size(); + while (' ' == str[--i]) { +str[i] = 0; + } + strncpy(reinterpret_cast(arg), str.data(), length); DavidTruby wrote: `std::strncpy` https://github.com/llvm/llvm-project/pull/70917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits