This is an archive of the discontinued LLVM Phabricator instance.

[libc] Fix printing on the GPU when given a `cpp::string_ref`
ClosedPublic

Authored by jhuber6 on Apr 28 2023, 3:46 PM.

Details

Summary

The implementation of the test printing currently expects a null
terminated C-string. However, the write_to_stderr interface uses a
string view, which doesn't need to be null terminated. This patch
changes the printing interface to directly use fwrite instead rather
than relying on a null terminator.

Diff Detail

Event Timeline

jhuber6 created this revision.Apr 28 2023, 3:46 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 28 2023, 3:46 PM
jhuber6 requested review of this revision.Apr 28 2023, 3:46 PM
sivachandra accepted this revision.Apr 28 2023, 4:27 PM
sivachandra added inline comments.
libc/utils/gpu/loader/Server.h
34

Why not new and delete?

This revision is now accepted and ready to land.Apr 28 2023, 4:27 PM
jhuber6 added inline comments.Apr 28 2023, 4:28 PM
libc/utils/gpu/loader/Server.h
34

Good point, just more used to using malloc and free. I'll change it before landing.

This revision was landed with ongoing or failed builds.Apr 28 2023, 7:32 PM
This revision was automatically updated to reflect the committed changes.