flintlib / flint

FLINT (Fast Library for Number Theory)
http://www.flintlib.org
GNU Lesser General Public License v3.0
401 stars 235 forks source link

Reduce more headers #1984

Closed albinahlback closed 1 month ago

albinahlback commented 1 month ago
fredrik-johansson commented 1 month ago

It's annoying to have to include specific system headers before header files to use standard functions, e.g. <string.h> before <mpoly.h> for mpoly_copy_monomials. We might as well deinline, or replace memcpy with a loop.

albinahlback commented 1 month ago

It's annoying to have to include specific system headers before header files to use standard functions, e.g. <string.h> before <mpoly.h> for mpoly_copy_monomials. We might as well deinline, or replace memcpy with a loop.

How about something like

#if BUILDING_FLINT
# define mpoly_copy_monomials(bla...) ...
#else
/* Declare symbol */
#endif

So that it actually evaluate to memcpy when building the library?

fredrik-johansson commented 1 month ago

-1 to BUILDING_FLINT.

If the string.h inclusion is a problem, not inlining this function seems like the easiest solution.

albinahlback commented 1 month ago

I think this is the best solution. If the compiler is GCC compatible, it will provide __builtin_memcpy, and so we simply expand to that. Otherwise, just use the symbol.