This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Support Newlib as libc++'s C library [cstdio part, part 2]
ClosedPublic

Authored by jroelofs on Sep 19 2014, 2:41 PM.

Details

Summary

Shims for lib2l and logbl.
Wrappers for clearerr, feof, ferror (which newlib implements as macros).

Edit: fix title. This one isn't ARM specific.
Edit: fix title again. This one no longer has to do with cmath.

Diff Detail

Event Timeline

jroelofs updated this revision to Diff 13893.Sep 19 2014, 2:41 PM
jroelofs retitled this revision from to [libc++] Support Newlib as libc++'s C library (on ARM) [cmath part, part 2].
jroelofs updated this object.
jroelofs edited the test plan for this revision. (Show Details)
jroelofs added reviewers: EricWF, jfb, danalbert.
jroelofs added a subscriber: Unknown Object (MLST).
jroelofs retitled this revision from [libc++] Support Newlib as libc++'s C library (on ARM) [cmath part, part 2] to [libc++] Support Newlib as libc++'s C library [cmath part, part 2].Sep 19 2014, 2:43 PM
jroelofs updated this object.
jfb edited edge metadata.Sep 22 2014, 11:47 AM

I looked at this again, and it seems like they should be in newlib because of C99. Should this be fixed in newlib instead?

There was a thread about this on the newlib mailing list:

https://sourceware.org/ml/newlib/2014/msg00349.html

These two functions are mentioned later.

mclow.lists added inline comments.
include/cstdio
175 ↗(On Diff #13893)

I think that these will cause warnings/errors if clearerr is not defined as a macro.

Should they be wrapped in #ifdef xxx ??

cmath has a pattern for this; should that be used here?

#ifdef isunordered
template <class _A1, class _A2>
_LIBCPP_ALWAYS_INLINE
bool
__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
    return isunordered(__lcpp_x, __lcpp_y);
}

#undef isunordered
bool isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
    return __libcpp_isunordered(__lcpp_x, __lcpp_y);
}
#endif
jroelofs updated this revision to Diff 13995.Sep 23 2014, 7:56 AM
jroelofs edited edge metadata.

Yes, it does make sense to use that pattern, for the case of REENT_SMALL.

@jfb do we lose anything by implementing these shims here, and then later pushing them into newlib?

jfb added a comment.Sep 23 2014, 9:10 AM
In D5420#10, @jroelofs wrote:

@jfb do we lose anything by implementing these shims here, and then later pushing them into newlib?

There may be a combination of newlib + libc++ where the functions are defined twice, once in newlib and once in libc++. That seems like a bad idea.

jroelofs added inline comments.Sep 23 2014, 1:36 PM
include/support/newlib/math.h
26 ↗(On Diff #13995)
jroelofs updated this revision to Diff 17955.Jan 9 2015, 3:43 PM
jroelofs retitled this revision from [libc++] Support Newlib as libc++'s C library [cmath part, part 2] to [libc++] Support Newlib as libc++'s C library [cstdio part, part 2].
jroelofs updated this object.

Updating the diff to reflect the parts of this that have already made it into newlib itself. Now the title is a little misleading, so renaming that at the same time.

danalbert accepted this revision.Jan 9 2015, 3:49 PM
danalbert edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Jan 9 2015, 3:49 PM
jroelofs closed this revision.Jan 9 2015, 4:12 PM

r225563