5757#include " src/stdio/printf_core/float_inf_nan_converter.h"
5858#include " src/stdio/printf_core/writer.h"
5959
60- #include < inttypes.h>
61- #include < stddef.h>
62- #include < string.h>
63-
6460namespace LIBC_NAMESPACE_DECL {
6561namespace printf_core {
6662
@@ -140,7 +136,7 @@ DigitsOutput decimal_digits(DigitsInput input, int precision, bool e_mode) {
140136 output.exponent = -precision - 1 ;
141137 } else {
142138 // In E mode, generate a string containing the expected number of 0s.
143- memset (output.digits , ' 0' , precision);
139+ __builtin_memset (output.digits , ' 0' , precision);
144140 output.ndigits = precision;
145141 output.exponent = 0 ;
146142 }
@@ -252,7 +248,7 @@ DigitsOutput decimal_digits(DigitsInput input, int precision, bool e_mode) {
252248 // digit that we already calculated.
253249 DigitsOutput output;
254250 output.ndigits = view.size ();
255- memcpy (output.digits , view.data (), output.ndigits );
251+ __builtin_memcpy (output.digits , view.data (), output.ndigits );
256252 output.exponent = log10_input;
257253 return output;
258254 } else {
@@ -270,7 +266,7 @@ DigitsOutput decimal_digits(DigitsInput input, int precision, bool e_mode) {
270266 // the exponent of the first digit by adding view.size().
271267 DigitsOutput output;
272268 output.ndigits = view.size ();
273- memcpy (output.digits , view.data (), output.ndigits );
269+ __builtin_memcpy (output.digits , view.data (), output.ndigits );
274270 output.exponent = int (view.size ()) - precision - 1 ;
275271 return output;
276272 }
@@ -453,7 +449,7 @@ LIBC_INLINE int convert_float_inner(Writer *writer,
453449 cpp::string_view expview = expcvt.view ();
454450 expbuf[0 ] = (to_conv.conv_name & 32 ) | ' E' ;
455451 explen = expview.size () + 1 ;
456- memcpy (expbuf + 1 , expview.data (), expview.size ());
452+ __builtin_memcpy (expbuf + 1 , expview.data (), expview.size ());
457453 }
458454
459455 // Now we know enough to work out the length of the unpadded output:
@@ -488,7 +484,7 @@ LIBC_INLINE int convert_float_inner(Writer *writer,
488484
489485 // Sign, if any
490486 if (sign_char)
491- RET_IF_RESULT_NEGATIVE (writer->write (sign_char, 1 ));
487+ RET_IF_RESULT_NEGATIVE (writer->write (sign_char));
492488
493489 // Zero padding, if any
494490 if (padding == Padding::Zero)
@@ -498,15 +494,15 @@ LIBC_INLINE int convert_float_inner(Writer *writer,
498494 for (int pos = start; pos < limit; ++pos) {
499495 if (pos >= 0 && pos < int (output.ndigits )) {
500496 // Fetch a digit from the buffer
501- RET_IF_RESULT_NEGATIVE (writer->write (output.digits [pos], 1 ));
497+ RET_IF_RESULT_NEGATIVE (writer->write (output.digits [pos]));
502498 } else {
503499 // This digit is outside the buffer, so write a zero
504- RET_IF_RESULT_NEGATIVE (writer->write (' 0' , 1 ));
500+ RET_IF_RESULT_NEGATIVE (writer->write (' 0' ));
505501 }
506502
507503 // Show the decimal point, if this is the digit it comes after
508504 if (show_point && pos == pointpos)
509- RET_IF_RESULT_NEGATIVE (writer->write (DECIMAL_POINT, 1 ));
505+ RET_IF_RESULT_NEGATIVE (writer->write (DECIMAL_POINT));
510506 }
511507
512508 // Exponent
0 commit comments