Reland [libc++] Move abs and div into stdlib.h to fix header cycle.
This commit should will break libc++ without local submodule visibility, but the LLVM+modules bots are now all using this mode. Before the Green Dragon LLDB bot was failing to compile with a libc++ built with this commit as LSV was disabled on macOS. Original summary: libc++ is careful to not fracture overload sets. When one overload is visible to a user, all of them should be. Anything less causes subtle bugs and ODR violations. Previously, in order to support ::abs and ::div being supplied by both <cmath> and <cstdlib> we had to do awful things that make <math.h> and <stdlib.h> have header cycles and be non-modular. This really breaks with modules. Specifically the problem was that in C++ ::abs introduces overloads for floating point numbers, these overloads forward to ::fabs, which are defined in math.h. Therefore ::abs needed to be in math.h too. But this required stdlib.h to include math.h and math.h to include stdlib.h. To avoid these problems the definitions have been moved to stddef.h (which math includes), and the floating point overloads of ::abs have been changed to call __builtin_fabs, which both Clang and GCC support.
Loading
Please register or sign in to comment