This is an archive of the discontinued LLVM Phabricator instance.

[flang] Implement GET_ENVIRONMENT_VARIABLE(VALUE)
ClosedPublic

Authored by rovka on Oct 28 2021, 2:30 AM.

Details

Summary

Implement the second entry point for GET_ENVIRONMENT_VARIABLE. Reuse
existing bits and pieces wherever possible.

This patch also increases CFI_* error codes in order to avoid conflicts.
GET_ENVIRONMENT_VARIABLE is required to return a status of 1 if an
environment variable does not exist and 2 if environment variables are
not supported. However, if we add status codes for that they will
conflict with CFI_ERROR_BASE_ADDR_NULL and CFI_ERROR_BASE_ADDR_NOT_NULL,
which are also 1 and 2 at the moment. We therefore move all CFI error
codes up (an arbitrary) 10 spots to make room. Hopefully this isn't
a problem, since we weren't matching the CFI error codes that gfortran
uses anyway. It may still be an issue if any other runtime functions
will need to return a status of 1 or 2, but we should probably deal with
that when/if it occurs.

Diff Detail

Event Timeline

rovka created this revision.Oct 28 2021, 2:30 AM
rovka requested review of this revision.Oct 28 2021, 2:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 28 2021, 2:30 AM
klausler added inline comments.Oct 28 2021, 12:07 PM
flang/include/flang/ISO_Fortran_binding.h
87

Please add a comment that explains why the error code numbers now start where they do.

flang/runtime/command.cpp
61

Please use RUNTIME_CHECK, not assert.

84

Please use braces for initializers.

rovka updated this revision to Diff 383247.Oct 29 2021, 12:29 AM

Address review comments.

rovka added inline comments.Oct 29 2021, 12:32 AM
flang/runtime/command.cpp
61

We don't have a terminator around, so I just removed the assert. It's just a small static function anyway, probably won't cause that kind of trouble.

84

Sorry! Muscle memory...

klausler accepted this revision.Oct 29 2021, 10:55 AM
This revision is now accepted and ready to land.Oct 29 2021, 10:55 AM
This revision was automatically updated to reflect the committed changes.