[libc][NFC] Integrate `FloatProperties` into `FPBits` (#76506)
[llvm-project.git] / utils / bazel / llvm-project-overlay / libc / BUILD.bazel
blobb5238f7686e5f4653cd19edbde1ccc4e9323afc9
1 # This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2 # See https://llvm.org/LICENSE.txt for license information.
3 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 # LLVM libc project.
6 load("@bazel_skylib//lib:selects.bzl", "selects")
7 load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
8 load(
9     ":libc_build_rules.bzl",
10     "libc_function",
11     "libc_math_function",
12     "libc_support_library",
14 load(":platforms.bzl", "PLATFORM_CPU_ARM64", "PLATFORM_CPU_X86_64")
16 package(
17     default_visibility = ["//visibility:public"],
18     features = [
19         "-use_header_modules",
20         "-layering_check",
21     ],
24 licenses(["notice"])
26 PRINTF_COPTS = [
27     "LIBC_COPT_STDIO_USE_SYSTEM_FILE",
28     "LIBC_COPT_PRINTF_DISABLE_INDEX_MODE",
29     "LIBC_COPT_PRINTF_DISABLE_WRITE_INT",
32 MEMORY_COPTS = [
33     # "LIBC_COPT_MEMCPY_X86_USE_REPMOVSB_FROM_SIZE=0",
34     # "LIBC_COPT_MEMCPY_X86_USE_SOFTWARE_PREFETCHING",
35     # "LIBC_COPT_MEMSET_X86_USE_SOFTWARE_PREFETCHING",
38 # A flag to pick which `mpfr` to use for math tests.
39 # Usage: `--@llvm-project//libc:mpfr=<disable|external|system>`.
40 # Flag documentation: https://bazel.build/extending/config
41 string_flag(
42     name = "mpfr",
43     build_setting_default = "external",
44     values = [
45         "disable",  # Skip tests that need mpfr
46         "external",  # Build mpfr from source
47         "system",  # Use system mpfr (non hermetic)
48     ],
51 config_setting(
52     name = "mpfr_disable",
53     flag_values = {":mpfr": "disable"},
56 config_setting(
57     name = "mpfr_external",
58     flag_values = {":mpfr": "external"},
61 config_setting(
62     name = "mpfr_system",
63     flag_values = {":mpfr": "system"},
66 ############################## Support libraries #############################
68 libc_support_library(
69     name = "__support_macros_properties_architectures",
70     hdrs = ["src/__support/macros/properties/architectures.h"],
73 libc_support_library(
74     name = "__support_macros_properties_compiler",
75     hdrs = ["src/__support/macros/properties/compiler.h"],
78 libc_support_library(
79     name = "__support_macros_properties_os",
80     hdrs = ["src/__support/macros/properties/os.h"],
83 libc_support_library(
84     name = "__support_macros_properties_float",
85     hdrs = ["src/__support/macros/properties/float.h"],
86     deps = [
87         ":__support_macros_properties_architectures",
88         ":__support_macros_properties_compiler",
89         ":__support_macros_properties_cpu_features",
90         ":__support_macros_properties_os",
91     ],
94 libc_support_library(
95     name = "__support_macros_properties_cpu_features",
96     hdrs = ["src/__support/macros/properties/cpu_features.h"],
97     deps = [
98         "__support_macros_properties_architectures",
99     ],
102 libc_support_library(
103     name = "__support_macros_config",
104     hdrs = ["src/__support/macros/config.h"],
107 libc_support_library(
108     name = "__support_macros_attributes",
109     hdrs = ["src/__support/macros/attributes.h"],
110     deps = [
111         ":__support_macros_properties_architectures",
112     ],
115 libc_support_library(
116     name = "__support_macros_optimization",
117     hdrs = ["src/__support/macros/optimization.h"],
118     deps = [
119         ":__support_macros_attributes",
120         ":__support_macros_config",
121         ":__support_macros_properties_compiler",
122     ],
125 libc_support_library(
126     name = "__support_macros_sanitizer",
127     hdrs = ["src/__support/macros/sanitizer.h"],
128     deps = [
129         ":__support_macros_config",
130     ],
133 libc_support_library(
134     name = "__support_common",
135     hdrs = [
136         "src/__support/common.h",
137         "src/__support/endian.h",
138     ],
139     deps = [
140         ":__support_macros_attributes",
141         ":__support_macros_properties_architectures",
142     ],
145 libc_support_library(
146     name = "__support_cpp_algorithm",
147     hdrs = ["src/__support/CPP/algorithm.h"],
148     deps = [
149         ":__support_macros_attributes",
150     ],
153 libc_support_library(
154     name = "__support_cpp_array",
155     hdrs = ["src/__support/CPP/array.h"],
156     deps = [
157         ":__support_macros_attributes",
158     ],
161 libc_support_library(
162     name = "__support_cpp_bit",
163     hdrs = ["src/__support/CPP/bit.h"],
164     deps = [
165         ":__support_cpp_limits",
166         ":__support_cpp_type_traits",
167         ":__support_macros_attributes",
168         ":__support_macros_config",
169         ":__support_macros_sanitizer",
170     ],
173 libc_support_library(
174     name = "__support_cpp_bitset",
175     hdrs = ["src/__support/CPP/bitset.h"],
176     deps = [
177         ":__support_macros_attributes",
178     ],
181 libc_support_library(
182     name = "__support_cpp_cstddef",
183     hdrs = ["src/__support/CPP/cstddef.h"],
184     deps = [
185         ":__support_cpp_type_traits",
186         ":__support_macros_attributes",
187     ],
190 libc_support_library(
191     name = "__support_cpp_expected",
192     hdrs = ["src/__support/CPP/expected.h"],
193     deps = [
194     ],
197 libc_support_library(
198     name = "__support_cpp_functional",
199     hdrs = ["src/__support/CPP/functional.h"],
200     deps = [
201         "__support_cpp_type_traits",
202         "__support_cpp_utility",
203         "__support_macros_attributes",
204     ],
207 libc_support_library(
208     name = "__support_cpp_limits",
209     hdrs = ["src/__support/CPP/limits.h"],
210     deps = [
211         "__support_cpp_type_traits",
212         "__support_macros_attributes",
213     ],
216 libc_support_library(
217     name = "__support_cpp_new",
218     srcs = ["src/__support/CPP/new.cpp"],
219     hdrs = ["src/__support/CPP/new.h"],
220     deps = [
221         ":__support_common",
222     ],
225 libc_support_library(
226     name = "__support_cpp_optional",
227     hdrs = ["src/__support/CPP/optional.h"],
228     deps = [
229         ":__support_cpp_utility",
230     ],
233 libc_support_library(
234     name = "__support_cpp_span",
235     hdrs = ["src/__support/CPP/span.h"],
236     deps = [
237         ":__support_cpp_array",
238         ":__support_cpp_type_traits",
239     ],
242 libc_support_library(
243     name = "__support_cpp_string_view",
244     hdrs = ["src/__support/CPP/string_view.h"],
245     deps = [
246         ":__support_common",
247     ],
250 libc_support_library(
251     name = "__support_cpp_stringstream",
252     hdrs = ["src/__support/CPP/stringstream.h"],
253     deps = [
254         ":__support_cpp_span",
255         ":__support_cpp_string_view",
256         ":__support_cpp_type_traits",
257         ":__support_integer_to_string",
258     ],
261 libc_support_library(
262     name = "__support_cpp_string",
263     hdrs = ["src/__support/CPP/string.h"],
264     deps = [
265         ":__support_common",
266         ":__support_cpp_string_view",
267         ":__support_integer_to_string",
268         ":string_memory_utils",
269         ":string_utils",
270     ],
273 libc_support_library(
274     name = "__support_cpp_type_traits",
275     hdrs = [
276         "src/__support/CPP/type_traits.h",
277         "src/__support/CPP/type_traits/add_lvalue_reference.h",
278         "src/__support/CPP/type_traits/add_pointer.h",
279         "src/__support/CPP/type_traits/add_rvalue_reference.h",
280         "src/__support/CPP/type_traits/always_false.h",
281         "src/__support/CPP/type_traits/bool_constant.h",
282         "src/__support/CPP/type_traits/conditional.h",
283         "src/__support/CPP/type_traits/decay.h",
284         "src/__support/CPP/type_traits/enable_if.h",
285         "src/__support/CPP/type_traits/false_type.h",
286         "src/__support/CPP/type_traits/integral_constant.h",
287         "src/__support/CPP/type_traits/invoke.h",
288         "src/__support/CPP/type_traits/invoke_result.h",
289         "src/__support/CPP/type_traits/is_arithmetic.h",
290         "src/__support/CPP/type_traits/is_array.h",
291         "src/__support/CPP/type_traits/is_base_of.h",
292         "src/__support/CPP/type_traits/is_class.h",
293         "src/__support/CPP/type_traits/is_const.h",
294         "src/__support/CPP/type_traits/is_convertible.h",
295         "src/__support/CPP/type_traits/is_destructible.h",
296         "src/__support/CPP/type_traits/is_enum.h",
297         "src/__support/CPP/type_traits/is_floating_point.h",
298         "src/__support/CPP/type_traits/is_function.h",
299         "src/__support/CPP/type_traits/is_integral.h",
300         "src/__support/CPP/type_traits/is_lvalue_reference.h",
301         "src/__support/CPP/type_traits/is_member_pointer.h",
302         "src/__support/CPP/type_traits/is_null_pointer.h",
303         "src/__support/CPP/type_traits/is_object.h",
304         "src/__support/CPP/type_traits/is_pointer.h",
305         "src/__support/CPP/type_traits/is_reference.h",
306         "src/__support/CPP/type_traits/is_rvalue_reference.h",
307         "src/__support/CPP/type_traits/is_same.h",
308         "src/__support/CPP/type_traits/is_scalar.h",
309         "src/__support/CPP/type_traits/is_signed.h",
310         "src/__support/CPP/type_traits/is_trivially_constructible.h",
311         "src/__support/CPP/type_traits/is_trivially_copyable.h",
312         "src/__support/CPP/type_traits/is_trivially_destructible.h",
313         "src/__support/CPP/type_traits/is_union.h",
314         "src/__support/CPP/type_traits/is_unsigned.h",
315         "src/__support/CPP/type_traits/is_void.h",
316         "src/__support/CPP/type_traits/make_signed.h",
317         "src/__support/CPP/type_traits/make_unsigned.h",
318         "src/__support/CPP/type_traits/remove_all_extents.h",
319         "src/__support/CPP/type_traits/remove_cv.h",
320         "src/__support/CPP/type_traits/remove_cvref.h",
321         "src/__support/CPP/type_traits/remove_extent.h",
322         "src/__support/CPP/type_traits/remove_reference.h",
323         "src/__support/CPP/type_traits/true_type.h",
324         "src/__support/CPP/type_traits/type_identity.h",
325         "src/__support/CPP/type_traits/void_t.h",
326         "src/__support/CPP/utility/declval.h",
327         "src/__support/CPP/utility/forward.h",
328     ],
329     deps = [
330         ":__support_macros_attributes",
331         ":__support_macros_config",
332         ":__support_macros_properties_float",
333     ],
336 libc_support_library(
337     name = "__support_cpp_utility",
338     hdrs = [
339         "src/__support/CPP/utility.h",
340         "src/__support/CPP/utility/declval.h",
341         "src/__support/CPP/utility/forward.h",
342         "src/__support/CPP/utility/in_place.h",
343         "src/__support/CPP/utility/integer_sequence.h",
344         "src/__support/CPP/utility/move.h",
345     ],
346     deps = [
347         ":__support_cpp_type_traits",
348         ":__support_macros_attributes",
349     ],
352 libc_support_library(
353     name = "__support_cpp_atomic",
354     hdrs = ["src/__support/CPP/atomic.h"],
355     deps = [
356         ":__support_cpp_type_traits",
357         ":__support_macros_attributes",
358         ":__support_macros_properties_architectures",
359     ],
362 libc_support_library(
363     name = "__support_blockstore",
364     hdrs = ["src/__support/blockstore.h"],
365     deps = [
366         ":__support_cpp_new",
367         ":__support_libc_assert",
368     ],
371 libc_support_library(
372     name = "__support_arg_list",
373     hdrs = ["src/__support/arg_list.h"],
374     deps = [
375         ":__support_common",
376     ],
379 libc_support_library(
380     name = "__support_c_string",
381     hdrs = ["src/__support/c_string.h"],
382     deps = [
383         ":__support_cpp_string",
384     ],
387 libc_support_library(
388     name = "__support_fixedvector",
389     hdrs = ["src/__support/fixedvector.h"],
390     deps = [
391         ":__support_cpp_array",
392     ],
395 libc_support_library(
396     name = "__support_char_vector",
397     hdrs = ["src/__support/char_vector.h"],
398     deps = [
399         ":__support_common",
400     ],
403 libc_support_library(
404     name = "__support_error_or",
405     hdrs = ["src/__support/error_or.h"],
406     deps = [
407         ":__support_common",
408         ":__support_cpp_expected",
409     ],
412 libc_support_library(
413     name = "__support_float_to_string",
414     hdrs = [
415         "src/__support/float_to_string.h",
416         "src/__support/ryu_constants.h",
417         "src/__support/ryu_long_double_constants.h",
418     ],
419     defines = ["LIBC_COPT_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE"],
420     deps = [
421         ":__support_common",
422         ":__support_cpp_type_traits",
423         ":__support_fputil_dyadic_float",
424         ":__support_fputil_fp_bits",
425         ":__support_libc_assert",
426         ":__support_uint",
427     ],
430 libc_support_library(
431     name = "__support_number_pair",
432     hdrs = ["src/__support/number_pair.h"],
433     deps = [
434         ":__support_cpp_type_traits",
435     ],
438 libc_support_library(
439     name = "__support_integer_utils",
440     hdrs = ["src/__support/integer_utils.h"],
441     deps = [
442         ":__support_common",
443         ":__support_cpp_type_traits",
444         ":__support_math_extras",
445         ":__support_number_pair",
446     ],
449 libc_support_library(
450     name = "__support_uint",
451     hdrs = ["src/__support/UInt.h"],
452     deps = [
453         ":__support_cpp_array",
454         ":__support_cpp_bit",
455         ":__support_cpp_limits",
456         ":__support_cpp_optional",
457         ":__support_cpp_type_traits",
458         ":__support_integer_utils",
459         ":__support_macros_attributes",
460         ":__support_macros_optimization",
461         ":__support_math_extras",
462         ":__support_number_pair",
463     ],
466 libc_support_library(
467     name = "__support_uint128",
468     hdrs = ["src/__support/UInt128.h"],
469     deps = [
470         ":__support_uint",
471     ],
474 libc_support_library(
475     name = "__support_str_to_num_result",
476     hdrs = ["src/__support/str_to_num_result.h"],
477     deps = [":__support_macros_attributes"],
480 libc_support_library(
481     name = "__support_integer_operations",
482     hdrs = ["src/__support/integer_operations.h"],
483     deps = [":__support_cpp_type_traits"],
486 libc_support_library(
487     name = "__support_integer_to_string",
488     hdrs = ["src/__support/integer_to_string.h"],
489     deps = [
490         ":__support_common",
491         ":__support_cpp_algorithm",
492         ":__support_cpp_bit",
493         ":__support_cpp_limits",
494         ":__support_cpp_optional",
495         ":__support_cpp_span",
496         ":__support_cpp_string_view",
497         ":__support_cpp_type_traits",
498     ],
501 libc_support_library(
502     name = "__support_libc_assert",
503     hdrs = ["src/__support/libc_assert.h"],
504     deps = [
505         ":__support_integer_to_string",
506         ":__support_macros_attributes",
507         ":__support_osutil_io",
508         ":__support_osutil_quick_exit",
509     ],
512 libc_support_library(
513     name = "__support_ctype_utils",
514     hdrs = ["src/__support/ctype_utils.h"],
515     deps = [":__support_macros_attributes"],
518 libc_support_library(
519     name = "__support_str_to_integer",
520     hdrs = ["src/__support/str_to_integer.h"],
521     deps = [
522         ":__support_common",
523         ":__support_cpp_limits",
524         ":__support_cpp_type_traits",
525         ":__support_ctype_utils",
526         ":__support_str_to_num_result",
527         ":errno",
528     ],
531 libc_support_library(
532     name = "__support_str_to_float",
533     hdrs = [
534         "src/__support/detailed_powers_of_ten.h",
535         "src/__support/high_precision_decimal.h",
536         "src/__support/str_to_float.h",
537     ],
538     deps = [
539         ":__support_common",
540         ":__support_cpp_bit",
541         ":__support_cpp_limits",
542         ":__support_cpp_optional",
543         ":__support_ctype_utils",
544         ":__support_fputil_dyadic_float",
545         ":__support_fputil_fenv_impl",
546         ":__support_fputil_fp_bits",
547         ":__support_fputil_rounding_mode",
548         ":__support_str_to_integer",
549         ":__support_str_to_num_result",
550         ":__support_uint128",
551         ":errno",
552     ],
555 libc_support_library(
556     name = "__support_fputil_basic_operations",
557     hdrs = ["src/__support/FPUtil/BasicOperations.h"],
558     deps = [
559         ":__support_common",
560         ":__support_cpp_type_traits",
561         ":__support_fputil_fp_bits",
562     ],
565 libc_support_library(
566     name = "__support_file_file",
567     srcs = ["src/__support/File/file.cpp"],
568     hdrs = ["src/__support/File/file.h"],
569     deps = [
570         ":__support_cpp_new",
571         ":__support_cpp_span",
572         ":__support_error_or",
573         ":__support_threads_mutex",
574         ":errno",
575     ],
578 libc_support_library(
579     name = "__support_file_linux_lseekimpl",
580     hdrs = ["src/__support/File/linux/lseekImpl.h"],
581     deps = [
582         ":__support_common",
583         ":__support_error_or",
584         ":__support_osutil_syscall",
585         ":errno",
586     ],
589 libc_support_library(
590     name = "__support_math_extras",
591     hdrs = ["src/__support/math_extras.h"],
592     deps = [
593         ":__support_cpp_type_traits",
594         ":__support_macros_attributes",
595         ":__support_macros_config",
596     ],
599 libc_support_library(
600     name = "__support_fputil_generic_fmod",
601     hdrs = ["src/__support/FPUtil/generic/FMod.h"],
602     deps = [
603         ":__support_common",
604         ":__support_cpp_bit",
605         ":__support_cpp_limits",
606         ":__support_cpp_type_traits",
607         ":__support_fputil_fenv_impl",
608         ":__support_fputil_fp_bits",
609         ":math_utils",
610     ],
613 libc_support_library(
614     name = "__support_fputil_division_and_remainder_operations",
615     hdrs = ["src/__support/FPUtil/DivisionAndRemainderOperations.h"],
616     deps = [
617         ":__support_common",
618         ":__support_cpp_type_traits",
619         ":__support_fputil_fp_bits",
620         ":__support_fputil_manipulation_functions",
621         ":__support_fputil_normal_float",
622     ],
625 libc_support_library(
626     name = "__support_fputil_except_value_utils",
627     hdrs = ["src/__support/FPUtil/except_value_utils.h"],
628     deps = [
629         ":__support_cpp_optional",
630         ":__support_fputil_fenv_impl",
631         ":__support_fputil_fp_bits",
632         ":__support_fputil_rounding_mode",
633     ],
636 libc_support_library(
637     name = "__support_fputil_fenv_impl",
638     hdrs = ["src/__support/FPUtil/FEnvImpl.h"],
639     textual_hdrs = [
640         "src/__support/FPUtil/x86_64/FEnvImpl.h",
641         "src/__support/FPUtil/aarch64/FEnvImpl.h",
642         "src/__support/FPUtil/aarch64/fenv_darwin_impl.h",
643     ],
644     deps = [
645         ":__support_fputil_fp_bits",
646         ":__support_macros_attributes",
647         ":__support_macros_properties_architectures",
648         ":__support_macros_sanitizer",
649         ":errno",
650     ],
653 libc_support_library(
654     name = "__support_fputil_rounding_mode",
655     hdrs = ["src/__support/FPUtil/rounding_mode.h"],
656     deps = [
657         ":__support_macros_attributes",
658     ],
661 libc_support_library(
662     name = "__support_fputil_fp_bits",
663     hdrs = ["src/__support/FPUtil/FPBits.h"],
664     textual_hdrs = ["src/__support/FPUtil/x86_64/LongDoubleBits.h"],
665     deps = [
666         ":__support_common",
667         ":__support_cpp_bit",
668         ":__support_cpp_type_traits",
669         ":__support_macros_attributes",
670         ":__support_macros_properties_float",
671         ":__support_math_extras",
672         ":__support_uint128",
673     ],
676 libc_support_library(
677     name = "__support_fputil_fpbits_str",
678     hdrs = ["src/__support/FPUtil/fpbits_str.h"],
679     deps = [
680         ":__support_common",
681         ":__support_cpp_string",
682         ":__support_cpp_type_traits",
683         ":__support_fputil_fp_bits",
684         ":__support_integer_to_string",
685         ":__support_uint128",
686     ],
689 libc_support_library(
690     name = "__support_fputil_hypot",
691     hdrs = ["src/__support/FPUtil/Hypot.h"],
692     deps = [
693         ":__support_common",
694         ":__support_cpp_bit",
695         ":__support_cpp_type_traits",
696         ":__support_fputil_basic_operations",
697         ":__support_fputil_fenv_impl",
698         ":__support_fputil_fp_bits",
699         ":__support_fputil_rounding_mode",
700         ":__support_uint128",
701     ],
704 libc_support_library(
705     name = "__support_fputil_manipulation_functions",
706     hdrs = ["src/__support/FPUtil/ManipulationFunctions.h"],
707     textual_hdrs = ["src/__support/FPUtil/x86_64/NextAfterLongDouble.h"],
708     deps = [
709         ":__support_common",
710         ":__support_cpp_bit",
711         ":__support_cpp_type_traits",
712         ":__support_fputil_fp_bits",
713         ":__support_fputil_nearest_integer_operations",
714         ":__support_fputil_normal_float",
715         ":__support_macros_optimization",
716         ":__support_uint128",
717     ],
720 libc_support_library(
721     name = "__support_fputil_nearest_integer_operations",
722     hdrs = ["src/__support/FPUtil/NearestIntegerOperations.h"],
723     deps = [
724         ":__support_common",
725         ":__support_cpp_type_traits",
726         ":__support_fputil_fenv_impl",
727         ":__support_fputil_fp_bits",
728         ":__support_fputil_rounding_mode",
729         ":__support_macros_attributes",
730     ],
733 libc_support_library(
734     name = "__support_fputil_normal_float",
735     hdrs = ["src/__support/FPUtil/NormalFloat.h"],
736     deps = [
737         ":__support_common",
738         ":__support_cpp_type_traits",
739         ":__support_fputil_fp_bits",
740     ],
743 sqrt_common_hdrs = [
744     "src/__support/FPUtil/sqrt.h",
745     "src/__support/FPUtil/generic/sqrt.h",
746     "src/__support/FPUtil/generic/sqrt_80_bit_long_double.h",
749 sqrt_hdrs = selects.with_or({
750     "//conditions:default": sqrt_common_hdrs,
751     PLATFORM_CPU_X86_64: sqrt_common_hdrs + [
752         "src/__support/FPUtil/x86_64/sqrt.h",
753     ],
754     PLATFORM_CPU_ARM64: sqrt_common_hdrs + [
755         "src/__support/FPUtil/aarch64/sqrt.h",
756     ],
759 libc_support_library(
760     name = "__support_fputil_sqrt",
761     hdrs = sqrt_hdrs,
762     deps = [
763         ":__support_common",
764         ":__support_cpp_bit",
765         ":__support_cpp_type_traits",
766         ":__support_fputil_fenv_impl",
767         ":__support_fputil_fp_bits",
768         ":__support_fputil_rounding_mode",
769         ":__support_uint128",
770     ],
773 fma_common_hdrs = [
774     "src/__support/FPUtil/FMA.h",
775     "src/__support/FPUtil/generic/FMA.h",
778 fma_platform_hdrs = [
779     "src/__support/FPUtil/x86_64/FMA.h",
780     "src/__support/FPUtil/aarch64/FMA.h",
783 libc_support_library(
784     name = "__support_fputil_fma",
785     hdrs = fma_common_hdrs,
786     # These are conditionally included and will #error out if the platform
787     # doesn't support FMA, so they can't be compiled on their own.
788     textual_hdrs = fma_platform_hdrs,
789     deps = [
790         ":__support_cpp_bit",
791         ":__support_cpp_type_traits",
792         ":__support_fputil_fenv_impl",
793         ":__support_fputil_fp_bits",
794         ":__support_fputil_rounding_mode",
795         ":__support_macros_attributes",
796         ":__support_macros_optimization",
797         ":__support_macros_properties_cpu_features",
798         ":__support_uint128",
799     ],
802 libc_support_library(
803     name = "__support_fputil_multiply_add",
804     hdrs = [
805         "src/__support/FPUtil/multiply_add.h",
806     ],
807     deps = [
808         ":__support_common",
809         ":__support_fputil_fma",
810     ],
813 libc_support_library(
814     name = "__support_fputil_polyeval",
815     hdrs = [
816         "src/__support/FPUtil/PolyEval.h",
817     ],
818     deps = [
819         ":__support_common",
820         ":__support_fputil_multiply_add",
821     ],
824 nearest_integer_common_hdrs = [
825     "src/__support/FPUtil/nearest_integer.h",
828 nearest_integer_platform_hdrs = [
829     "src/__support/FPUtil/x86_64/nearest_integer.h",
830     "src/__support/FPUtil/aarch64/nearest_integer.h",
833 libc_support_library(
834     name = "__support_fputil_nearest_integer",
835     hdrs = nearest_integer_common_hdrs,
836     # These are conditionally included and will #error out if the platform
837     # doesn't support rounding instructions, so they can't be compiled on their
838     # own.
839     textual_hdrs = nearest_integer_platform_hdrs,
840     deps = [
841         ":__support_common",
842         ":__support_macros_optimization",
843         ":__support_macros_properties_architectures",
844         ":__support_macros_properties_cpu_features",
845     ],
848 libc_support_library(
849     name = "__support_fputil_double_double",
850     hdrs = ["src/__support/FPUtil/double_double.h"],
851     deps = [
852         ":__support_common",
853         ":__support_fputil_multiply_add",
854         ":__support_number_pair",
855     ],
858 libc_support_library(
859     name = "__support_fputil_triple_double",
860     hdrs = ["src/__support/FPUtil/triple_double.h"],
861     deps = [
862         ":__support_common",
863     ],
866 libc_support_library(
867     name = "__support_fputil_dyadic_float",
868     hdrs = ["src/__support/FPUtil/dyadic_float.h"],
869     deps = [
870         ":__support_common",
871         ":__support_fputil_fp_bits",
872         ":__support_fputil_multiply_add",
873         ":__support_macros_optimization",
874         ":__support_uint",
875     ],
878 libc_support_library(
879     name = "__support_osutil_syscall",
880     hdrs = ["src/__support/OSUtil/syscall.h"],
881     textual_hdrs = [
882         "src/__support/OSUtil/linux/syscall.h",
883         "src/__support/OSUtil/linux/aarch64/syscall.h",
884         "src/__support/OSUtil/linux/x86_64/syscall.h",
885     ],
886     deps = [
887         ":__support_common",
888         ":__support_cpp_bit",
889     ],
892 libc_support_library(
893     name = "__support_osutil_io",
894     hdrs = ["src/__support/OSUtil/io.h"],
895     textual_hdrs = [
896         "src/__support/OSUtil/linux/io.h",
897     ],
898     deps = [
899         ":__support_common",
900         ":__support_cpp_string_view",
901         ":__support_osutil_syscall",
902         ":string_utils",
903     ],
906 libc_support_library(
907     name = "__support_osutil_quick_exit",
908     hdrs = ["src/__support/OSUtil/quick_exit.h"],
909     textual_hdrs = [
910         "src/__support/OSUtil/linux/quick_exit.h",
911         #TODO: add support for GPU quick_exit (isn't just in a header.)
912     ],
913     deps = [
914         ":__support_osutil_syscall",
915     ],
918 libc_support_library(
919     name = "__support_stringutil",
920     srcs = glob(["src/__support/StringUtil/tables/**/*.h"]) + [
921         "src/__support/StringUtil/error_to_string.cpp",
922         "src/__support/StringUtil/message_mapper.h",
923         "src/__support/StringUtil/platform_errors.h",
924         "src/__support/StringUtil/platform_signals.h",
925         "src/__support/StringUtil/signal_to_string.cpp",
926     ],
927     hdrs = [
928         "src/__support/StringUtil/error_to_string.h",
929         "src/__support/StringUtil/signal_to_string.h",
930     ],
931     deps = [
932         ":__support_cpp_array",
933         ":__support_cpp_span",
934         ":__support_cpp_string_view",
935         ":__support_cpp_stringstream",
936         ":__support_integer_to_string",
937         ":__support_macros_attributes",
938         ":errno",
939     ],
942 libc_support_library(
943     name = "__support_threads_mutex",
944     hdrs = [
945         "src/__support/threads/mutex.h",
946         "src/__support/threads/mutex_common.h",
947     ],
948     textual_hdrs = [
949         "src/__support/threads/linux/mutex.h",
950         "src/__support/threads/linux/futex_word.h",
951     ],
952     deps = [
953         ":__support_cpp_atomic",
954         ":__support_osutil_syscall",
955     ],
958 ############################### errno targets ################################
960 libc_function(
961     name = "errno",
962     srcs = ["src/errno/libc_errno.cpp"],
963     hdrs = ["src/errno/libc_errno.h"],
964     deps = [
965         ":__support_common",
966         ":__support_macros_attributes",
967         ":__support_macros_properties_architectures",
968     ],
971 ################################ fenv targets ################################
973 libc_function(
974     name = "fetestexcept",
975     srcs = ["src/fenv/fetestexcept.cpp"],
976     hdrs = ["src/fenv/fetestexcept.h"],
977     deps = [
978         ":__support_common",
979         ":__support_fputil_fenv_impl",
980     ],
983 libc_function(
984     name = "feclearexcept",
985     srcs = ["src/fenv/feclearexcept.cpp"],
986     hdrs = ["src/fenv/feclearexcept.h"],
987     deps = [
988         ":__support_common",
989         ":__support_fputil_fenv_impl",
990     ],
993 libc_function(
994     name = "feraiseexcept",
995     srcs = ["src/fenv/feraiseexcept.cpp"],
996     hdrs = ["src/fenv/feraiseexcept.h"],
997     deps = [
998         ":__support_common",
999         ":__support_fputil_fenv_impl",
1000     ],
1003 libc_function(
1004     name = "fegetround",
1005     srcs = ["src/fenv/fegetround.cpp"],
1006     hdrs = ["src/fenv/fegetround.h"],
1007     deps = [
1008         ":__support_common",
1009         ":__support_fputil_fenv_impl",
1010     ],
1013 libc_function(
1014     name = "fesetround",
1015     srcs = ["src/fenv/fesetround.cpp"],
1016     hdrs = ["src/fenv/fesetround.h"],
1017     deps = [
1018         ":__support_common",
1019         ":__support_fputil_fenv_impl",
1020     ],
1023 libc_function(
1024     name = "fedisableexcept",
1025     srcs = ["src/fenv/fedisableexcept.cpp"],
1026     hdrs = ["src/fenv/fedisableexcept.h"],
1027     deps = [
1028         ":__support_common",
1029         ":__support_fputil_fenv_impl",
1030     ],
1033 libc_function(
1034     name = "feenableexcept",
1035     srcs = ["src/fenv/feenableexcept.cpp"],
1036     hdrs = ["src/fenv/feenableexcept.h"],
1037     deps = [
1038         ":__support_common",
1039         ":__support_fputil_fenv_impl",
1040     ],
1043 libc_function(
1044     name = "fegetexcept",
1045     srcs = ["src/fenv/fegetexcept.cpp"],
1046     hdrs = ["src/fenv/fegetexcept.h"],
1047     deps = [
1048         ":__support_common",
1049         ":__support_fputil_fenv_impl",
1050     ],
1053 libc_function(
1054     name = "fegetenv",
1055     srcs = ["src/fenv/fegetenv.cpp"],
1056     hdrs = ["src/fenv/fegetenv.h"],
1057     deps = [
1058         ":__support_common",
1059         ":__support_fputil_fenv_impl",
1060     ],
1063 libc_function(
1064     name = "fesetenv",
1065     srcs = ["src/fenv/fesetenv.cpp"],
1066     hdrs = ["src/fenv/fesetenv.h"],
1067     deps = [
1068         ":__support_common",
1069         ":__support_fputil_fenv_impl",
1070     ],
1073 libc_function(
1074     name = "feupdateenv",
1075     srcs = ["src/fenv/feupdateenv.cpp"],
1076     hdrs = ["src/fenv/feupdateenv.h"],
1077     deps = [
1078         ":__support_common",
1079         ":__support_fputil_fenv_impl",
1080     ],
1083 libc_function(
1084     name = "fegetexceptflag",
1085     srcs = ["src/fenv/fegetexceptflag.cpp"],
1086     hdrs = ["src/fenv/fegetexceptflag.h"],
1087     deps = [
1088         ":__support_common",
1089         ":__support_fputil_fenv_impl",
1090     ],
1093 libc_function(
1094     name = "fesetexceptflag",
1095     srcs = ["src/fenv/fesetexceptflag.cpp"],
1096     hdrs = ["src/fenv/fesetexceptflag.h"],
1097     deps = [
1098         ":__support_common",
1099         ":__support_fputil_fenv_impl",
1100     ],
1103 libc_function(
1104     name = "feholdexcept",
1105     srcs = ["src/fenv/feholdexcept.cpp"],
1106     hdrs = ["src/fenv/feholdexcept.h"],
1107     deps = [
1108         ":__support_common",
1109         ":__support_fputil_fenv_impl",
1110     ],
1113 ################################ math targets ################################
1115 libc_support_library(
1116     name = "math_utils",
1117     srcs = ["src/math/generic/math_utils.cpp"],
1118     hdrs = ["src/math/generic/math_utils.h"],
1119     deps = [
1120         "__support_cpp_bit",
1121         "__support_cpp_type_traits",
1122         ":__support_common",
1123         ":errno",
1124     ],
1127 libc_support_library(
1128     name = "common_constants",
1129     srcs = ["src/math/generic/common_constants.cpp"],
1130     hdrs = ["src/math/generic/common_constants.h"],
1131     deps = [
1132         ":__support_fputil_triple_double",
1133         ":__support_number_pair",
1134     ],
1137 libc_support_library(
1138     name = "range_reduction",
1139     hdrs = [
1140         "src/math/generic/range_reduction.h",
1141         "src/math/generic/range_reduction_fma.h",
1142     ],
1143     deps = [
1144         ":__support_common",
1145         ":__support_fputil_fma",
1146         ":__support_fputil_fp_bits",
1147         ":__support_fputil_multiply_add",
1148         ":__support_fputil_nearest_integer",
1149     ],
1152 libc_support_library(
1153     name = "sincosf_utils",
1154     hdrs = ["src/math/generic/sincosf_utils.h"],
1155     deps = [
1156         ":__support_fputil_fp_bits",
1157         ":__support_fputil_polyeval",
1158         ":range_reduction",
1159     ],
1162 libc_support_library(
1163     name = "explogxf",
1164     srcs = ["src/math/generic/explogxf.cpp"],
1165     hdrs = ["src/math/generic/explogxf.h"],
1166     deps = [
1167         ":__support_common",
1168         ":__support_fputil_fenv_impl",
1169         ":__support_fputil_fma",
1170         ":__support_fputil_fp_bits",
1171         ":__support_fputil_multiply_add",
1172         ":__support_fputil_nearest_integer",
1173         ":__support_fputil_polyeval",
1174         ":common_constants",
1175         ":math_utils",
1176     ],
1179 libc_support_library(
1180     name = "inv_trigf_utils",
1181     srcs = ["src/math/generic/inv_trigf_utils.cpp"],
1182     hdrs = ["src/math/generic/inv_trigf_utils.h"],
1183     deps = [
1184         ":__support_common",
1185         ":__support_fputil_fenv_impl",
1186         ":__support_fputil_fma",
1187         ":__support_fputil_fp_bits",
1188         ":__support_fputil_multiply_add",
1189         ":__support_fputil_nearest_integer",
1190         ":__support_fputil_polyeval",
1191         ":math_utils",
1192     ],
1195 libc_support_library(
1196     name = "log_range_reduction",
1197     hdrs = ["src/math/generic/log_range_reduction.h"],
1198     deps = [
1199         ":__support_common",
1200         ":__support_fputil_dyadic_float",
1201         ":__support_uint128",
1202         ":common_constants",
1203     ],
1206 libc_support_library(
1207     name = "exp10f_impl",
1208     hdrs = ["src/math/generic/exp10f_impl.h"],
1209     deps = [
1210         ":__support_fputil_basic_operations",
1211         ":__support_fputil_fma",
1212         ":__support_fputil_multiply_add",
1213         ":__support_fputil_nearest_integer",
1214         ":__support_fputil_polyeval",
1215         ":__support_fputil_rounding_mode",
1216         ":__support_macros_optimization",
1217         ":common_constants",
1218         ":explogxf",
1219     ],
1222 libc_support_library(
1223     name = "exp2f_impl",
1224     hdrs = ["src/math/generic/exp2f_impl.h"],
1225     deps = [
1226         ":__support_fputil_except_value_utils",
1227         ":__support_fputil_fma",
1228         ":__support_fputil_multiply_add",
1229         ":__support_fputil_nearest_integer",
1230         ":__support_fputil_polyeval",
1231         ":__support_fputil_rounding_mode",
1232         ":__support_macros_optimization",
1233         ":common_constants",
1234         ":explogxf",
1235     ],
1238 libc_math_function(
1239     name = "erff",
1240     additional_deps = [
1241         ":__support_fputil_multiply_add",
1242         ":__support_fputil_polyeval",
1243         ":__support_macros_optimization",
1244     ],
1247 libc_math_function(
1248     name = "expm1",
1249     additional_deps = [
1250         ":__support_fputil_double_double",
1251         ":__support_fputil_dyadic_float",
1252         ":__support_fputil_multiply_add",
1253         ":__support_fputil_nearest_integer",
1254         ":__support_fputil_polyeval",
1255         ":__support_fputil_rounding_mode",
1256         ":__support_fputil_triple_double",
1257         ":__support_macros_optimization",
1258         ":common_constants",
1259         ":explogxf",
1260     ],
1263 libc_math_function(
1264     name = "expm1f",
1265     additional_deps = [
1266         ":__support_fputil_fma",
1267         ":__support_fputil_multiply_add",
1268         ":__support_fputil_nearest_integer",
1269         ":__support_fputil_polyeval",
1270         ":__support_fputil_rounding_mode",
1271         ":__support_macros_optimization",
1272         ":__support_macros_properties_cpu_features",
1273         ":common_constants",
1274     ],
1277 libc_math_function(
1278     name = "exp",
1279     additional_deps = [
1280         ":__support_fputil_double_double",
1281         ":__support_fputil_dyadic_float",
1282         ":__support_fputil_multiply_add",
1283         ":__support_fputil_nearest_integer",
1284         ":__support_fputil_polyeval",
1285         ":__support_fputil_rounding_mode",
1286         ":__support_fputil_triple_double",
1287         ":__support_macros_optimization",
1288         ":common_constants",
1289         ":explogxf",
1290     ],
1293 libc_math_function(
1294     name = "expf",
1295     additional_deps = [
1296         ":__support_fputil_fma",
1297         ":__support_fputil_multiply_add",
1298         ":__support_fputil_nearest_integer",
1299         ":__support_fputil_polyeval",
1300         ":__support_fputil_rounding_mode",
1301         ":__support_macros_optimization",
1302         ":common_constants",
1303     ],
1306 libc_math_function(
1307     name = "exp10",
1308     additional_deps = [
1309         ":__support_fputil_double_double",
1310         ":__support_fputil_dyadic_float",
1311         ":__support_fputil_multiply_add",
1312         ":__support_fputil_nearest_integer",
1313         ":__support_fputil_polyeval",
1314         ":__support_fputil_rounding_mode",
1315         ":__support_fputil_triple_double",
1316         ":__support_macros_optimization",
1317         ":common_constants",
1318         ":explogxf",
1319     ],
1322 libc_math_function(
1323     name = "exp10f",
1324     additional_deps = [
1325         ":exp10f_impl",
1326     ],
1329 libc_math_function(
1330     name = "exp2",
1331     additional_deps = [
1332         ":__support_fputil_double_double",
1333         ":__support_fputil_dyadic_float",
1334         ":__support_fputil_multiply_add",
1335         ":__support_fputil_nearest_integer",
1336         ":__support_fputil_polyeval",
1337         ":__support_fputil_rounding_mode",
1338         ":__support_fputil_triple_double",
1339         ":__support_macros_optimization",
1340         ":common_constants",
1341         ":explogxf",
1342     ],
1345 libc_math_function(
1346     name = "exp2f",
1347     additional_deps = [
1348         ":exp2f_impl",
1349     ],
1352 libc_math_function(
1353     name = "logf",
1354     additional_deps = [
1355         ":__support_fputil_fma",
1356         ":__support_fputil_multiply_add",
1357         ":__support_fputil_polyeval",
1358         ":__support_macros_optimization",
1359         ":__support_macros_properties_cpu_features",
1360         ":common_constants",
1361     ],
1364 libc_math_function(
1365     name = "log2f",
1366     additional_deps = [
1367         ":__support_fputil_fma",
1368         ":__support_fputil_multiply_add",
1369         ":__support_fputil_polyeval",
1370         ":__support_macros_optimization",
1371         ":common_constants",
1372     ],
1375 libc_math_function(
1376     name = "log10f",
1377     additional_deps = [
1378         ":__support_fputil_fma",
1379         ":__support_fputil_multiply_add",
1380         ":__support_fputil_polyeval",
1381         ":__support_macros_optimization",
1382         ":__support_macros_properties_cpu_features",
1383         ":common_constants",
1384     ],
1387 libc_math_function(
1388     name = "log1pf",
1389     additional_deps = [
1390         ":__support_fputil_fma",
1391         ":__support_fputil_multiply_add",
1392         ":__support_fputil_polyeval",
1393         ":__support_macros_optimization",
1394         ":__support_macros_properties_cpu_features",
1395         ":common_constants",
1396     ],
1399 libc_math_function(
1400     name = "log",
1401     additional_deps = [
1402         ":__support_fputil_fma",
1403         ":__support_fputil_multiply_add",
1404         ":__support_fputil_polyeval",
1405         ":__support_fputil_double_double",
1406         ":__support_fputil_dyadic_float",
1407         ":__support_macros_optimization",
1408         ":__support_macros_properties_cpu_features",
1409         ":common_constants",
1410         ":log_range_reduction",
1411     ],
1414 libc_math_function(
1415     name = "log2",
1416     additional_deps = [
1417         ":__support_fputil_fma",
1418         ":__support_fputil_multiply_add",
1419         ":__support_fputil_polyeval",
1420         ":__support_fputil_double_double",
1421         ":__support_fputil_dyadic_float",
1422         ":__support_macros_optimization",
1423         ":__support_macros_properties_cpu_features",
1424         ":common_constants",
1425         ":log_range_reduction",
1426     ],
1429 libc_math_function(
1430     name = "log10",
1431     additional_deps = [
1432         ":__support_fputil_fma",
1433         ":__support_fputil_multiply_add",
1434         ":__support_fputil_polyeval",
1435         ":__support_fputil_double_double",
1436         ":__support_fputil_dyadic_float",
1437         ":__support_macros_optimization",
1438         ":__support_macros_properties_cpu_features",
1439         ":common_constants",
1440         ":log_range_reduction",
1441     ],
1444 libc_math_function(
1445     name = "log1p",
1446     additional_deps = [
1447         ":__support_fputil_fma",
1448         ":__support_fputil_multiply_add",
1449         ":__support_fputil_polyeval",
1450         ":__support_fputil_double_double",
1451         ":__support_fputil_dyadic_float",
1452         ":__support_macros_optimization",
1453         ":__support_macros_properties_cpu_features",
1454         ":common_constants",
1455     ],
1458 libc_math_function(
1459     name = "sinhf",
1460     additional_deps = [
1461         ":__support_fputil_fma",
1462         ":__support_fputil_multiply_add",
1463         ":__support_fputil_nearest_integer",
1464         ":__support_fputil_polyeval",
1465         ":__support_fputil_rounding_mode",
1466         ":__support_macros_optimization",
1467         ":common_constants",
1468         ":explogxf",
1469     ],
1472 libc_math_function(
1473     name = "coshf",
1474     additional_deps = [
1475         ":__support_fputil_fma",
1476         ":__support_fputil_multiply_add",
1477         ":__support_fputil_nearest_integer",
1478         ":__support_fputil_polyeval",
1479         ":__support_fputil_rounding_mode",
1480         ":__support_macros_optimization",
1481         ":common_constants",
1482         ":explogxf",
1483     ],
1486 libc_math_function(
1487     name = "tanhf",
1488     additional_deps = [
1489         ":__support_fputil_fma",
1490         ":__support_fputil_multiply_add",
1491         ":__support_fputil_nearest_integer",
1492         ":__support_fputil_polyeval",
1493         ":__support_fputil_rounding_mode",
1494         ":__support_macros_optimization",
1495         ":__support_macros_properties_cpu_features",
1496         ":common_constants",
1497         ":explogxf",
1498     ],
1501 libc_math_function(
1502     name = "asinhf",
1503     additional_deps = [
1504         ":__support_fputil_fma",
1505         ":__support_fputil_multiply_add",
1506         ":__support_fputil_nearest_integer",
1507         ":__support_fputil_polyeval",
1508         ":__support_fputil_sqrt",
1509         ":__support_macros_optimization",
1510         ":common_constants",
1511         ":explogxf",
1512     ],
1515 libc_math_function(
1516     name = "acoshf",
1517     additional_deps = [
1518         ":__support_fputil_fma",
1519         ":__support_fputil_multiply_add",
1520         ":__support_fputil_nearest_integer",
1521         ":__support_fputil_polyeval",
1522         ":__support_fputil_sqrt",
1523         ":__support_macros_optimization",
1524         ":common_constants",
1525         ":explogxf",
1526     ],
1529 libc_math_function(
1530     name = "atanhf",
1531     additional_deps = [
1532         ":__support_fputil_fma",
1533         ":__support_fputil_multiply_add",
1534         ":__support_fputil_nearest_integer",
1535         ":__support_fputil_polyeval",
1536         ":__support_macros_optimization",
1537         ":common_constants",
1538         ":explogxf",
1539     ],
1542 libc_math_function(
1543     name = "asinf",
1544     additional_deps = [
1545         ":__support_fputil_fma",
1546         ":__support_fputil_multiply_add",
1547         ":__support_fputil_nearest_integer",
1548         ":__support_fputil_polyeval",
1549         ":__support_fputil_sqrt",
1550         ":__support_macros_optimization",
1551         ":__support_macros_properties_cpu_features",
1552         ":inv_trigf_utils",
1553     ],
1556 libc_math_function(
1557     name = "acosf",
1558     additional_deps = [
1559         ":__support_fputil_fma",
1560         ":__support_fputil_multiply_add",
1561         ":__support_fputil_nearest_integer",
1562         ":__support_fputil_polyeval",
1563         ":__support_fputil_sqrt",
1564         ":__support_macros_optimization",
1565         ":inv_trigf_utils",
1566     ],
1569 libc_math_function(
1570     name = "atanf",
1571     additional_deps = [
1572         ":__support_fputil_fma",
1573         ":__support_fputil_multiply_add",
1574         ":__support_fputil_nearest_integer",
1575         ":__support_fputil_polyeval",
1576         ":__support_fputil_rounding_mode",
1577         ":__support_macros_optimization",
1578         ":inv_trigf_utils",
1579         ":math_utils",
1580     ],
1583 libc_math_function(
1584     name = "powf",
1585     additional_deps = [
1586         ":__support_fputil_double_double",
1587         ":__support_fputil_multiply_add",
1588         ":__support_fputil_nearest_integer",
1589         ":__support_fputil_polyeval",
1590         ":__support_fputil_rounding_mode",
1591         ":__support_fputil_sqrt",
1592         ":__support_fputil_triple_double",
1593         ":__support_macros_optimization",
1594         ":common_constants",
1595         ":explogxf",
1596         ":exp2f_impl",
1597         ":exp10f_impl",
1598     ],
1601 libc_math_function(name = "fabs")
1603 libc_math_function(name = "fabsf")
1605 libc_math_function(name = "fabsl")
1607 libc_math_function(name = "fdim")
1609 libc_math_function(name = "fdimf")
1611 libc_math_function(name = "fdiml")
1613 libc_math_function(
1614     name = "ceil",
1615     specializations = [
1616         "aarch64",
1617         "generic",
1618     ],
1621 libc_math_function(
1622     name = "ceilf",
1623     specializations = [
1624         "aarch64",
1625         "generic",
1626     ],
1629 libc_math_function(
1630     name = "ceill",
1631     specializations = [
1632         "generic",
1633     ],
1636 libc_math_function(
1637     name = "floor",
1638     specializations = [
1639         "aarch64",
1640         "generic",
1641     ],
1644 libc_math_function(
1645     name = "floorf",
1646     specializations = [
1647         "aarch64",
1648         "generic",
1649     ],
1652 libc_math_function(name = "floorl")
1654 libc_math_function(name = "ldexp")
1656 libc_math_function(name = "ldexpf")
1658 libc_math_function(name = "ldexpl")
1660 libc_math_function(
1661     name = "trunc",
1662     specializations = [
1663         "aarch64",
1664         "generic",
1665     ],
1668 libc_math_function(
1669     name = "truncf",
1670     specializations = [
1671         "aarch64",
1672         "generic",
1673     ],
1676 libc_math_function(name = "truncl")
1678 libc_math_function(
1679     name = "round",
1680     specializations = [
1681         "aarch64",
1682         "generic",
1683     ],
1686 libc_math_function(
1687     name = "roundf",
1688     specializations = [
1689         "aarch64",
1690         "generic",
1691     ],
1694 libc_math_function(name = "roundl")
1696 libc_math_function(
1697     name = "fmod",
1698     additional_deps = [
1699         ":__support_fputil_generic_fmod",
1700     ],
1703 libc_math_function(
1704     name = "fmodf",
1705     additional_deps = [
1706         ":__support_fputil_generic_fmod",
1707     ],
1710 libc_math_function(name = "frexp")
1712 libc_math_function(name = "frexpf")
1714 libc_math_function(name = "frexpl")
1716 libc_math_function(name = "hypot")
1718 libc_math_function(
1719     name = "hypotf",
1720     additional_deps = [
1721         ":__support_fputil_sqrt",
1722     ],
1725 libc_math_function(name = "logb")
1727 libc_math_function(name = "logbf")
1729 libc_math_function(name = "logbl")
1731 libc_math_function(name = "modf")
1733 libc_math_function(name = "modff")
1735 libc_math_function(name = "modfl")
1737 libc_math_function(name = "remquo")
1739 libc_math_function(name = "remquof")
1741 libc_math_function(name = "remquol")
1743 libc_math_function(name = "remainder")
1745 libc_math_function(name = "remainderf")
1747 libc_math_function(name = "remainderl")
1749 libc_math_function(name = "fmin")
1751 libc_math_function(name = "fminf")
1753 libc_math_function(name = "fminl")
1755 libc_math_function(name = "fmax")
1757 libc_math_function(name = "fmaxf")
1759 libc_math_function(name = "fmaxl")
1761 libc_math_function(
1762     name = "cosf",
1763     additional_deps = [
1764         ":__support_fputil_fma",
1765         ":__support_fputil_multiply_add",
1766         ":__support_macros_optimization",
1767         ":__support_macros_properties_cpu_features",
1768         ":sincosf_utils",
1769     ],
1772 libc_math_function(
1773     name = "sincosf",
1774     additional_deps = [
1775         ":__support_fputil_fma",
1776         ":__support_fputil_multiply_add",
1777         ":__support_fputil_rounding_mode",
1778         ":__support_macros_optimization",
1779         ":__support_macros_properties_cpu_features",
1780         ":sincosf_utils",
1781     ],
1784 libc_math_function(
1785     name = "sinf",
1786     additional_deps = [
1787         ":__support_fputil_fma",
1788         ":__support_fputil_multiply_add",
1789         ":__support_fputil_polyeval",
1790         ":__support_fputil_rounding_mode",
1791         ":__support_macros_optimization",
1792         ":__support_macros_properties_cpu_features",
1793         ":range_reduction",
1794         ":sincosf_utils",
1795     ],
1798 libc_math_function(
1799     name = "tanf",
1800     additional_deps = [
1801         ":__support_fputil_fma",
1802         ":__support_fputil_multiply_add",
1803         ":__support_fputil_nearest_integer",
1804         ":__support_fputil_polyeval",
1805         ":__support_macros_optimization",
1806         ":__support_macros_properties_cpu_features",
1807         ":range_reduction",
1808         ":sincosf_utils",
1809     ],
1812 libc_math_function(
1813     name = "sqrt",
1814     additional_deps = [
1815         ":__support_fputil_sqrt",
1816     ],
1819 libc_math_function(
1820     name = "sqrtf",
1821     additional_deps = [
1822         ":__support_fputil_sqrt",
1823     ],
1826 libc_math_function(
1827     name = "sqrtl",
1828     additional_deps = [
1829         ":__support_fputil_sqrt",
1830     ],
1833 libc_math_function(name = "copysign")
1835 libc_math_function(name = "copysignf")
1837 libc_math_function(name = "copysignl")
1839 libc_math_function(name = "copysignf128")
1841 libc_math_function(name = "ilogb")
1843 libc_math_function(name = "ilogbf")
1845 libc_math_function(name = "ilogbl")
1847 libc_math_function(name = "rint")
1849 libc_math_function(name = "rintf")
1851 libc_math_function(name = "rintl")
1853 libc_math_function(name = "lrint")
1855 libc_math_function(name = "lrintf")
1857 libc_math_function(name = "lrintl")
1859 libc_math_function(name = "llrint")
1861 libc_math_function(name = "llrintf")
1863 libc_math_function(name = "llrintl")
1865 libc_math_function(name = "lround")
1867 libc_math_function(name = "lroundf")
1869 libc_math_function(name = "lroundl")
1871 libc_math_function(name = "llround")
1873 libc_math_function(name = "llroundf")
1875 libc_math_function(name = "llroundl")
1877 libc_math_function(name = "nearbyint")
1879 libc_math_function(name = "nearbyintf")
1881 libc_math_function(name = "nearbyintl")
1883 libc_math_function(name = "nextafter")
1885 libc_math_function(name = "nextafterf")
1887 libc_math_function(name = "nextafterl")
1889 libc_math_function(name = "nexttoward")
1891 libc_math_function(name = "nexttowardf")
1893 libc_math_function(name = "nexttowardl")
1895 libc_math_function(name = "scalbn")
1897 libc_math_function(name = "scalbnf")
1899 libc_math_function(name = "scalbnl")
1901 ############################## inttypes targets ##############################
1903 libc_function(
1904     name = "imaxabs",
1905     srcs = ["src/inttypes/imaxabs.cpp"],
1906     hdrs = ["src/inttypes/imaxabs.h"],
1907     deps = [
1908         ":__support_common",
1909         ":__support_integer_operations",
1910     ],
1913 libc_function(
1914     name = "imaxdiv",
1915     srcs = ["src/inttypes/imaxdiv.cpp"],
1916     hdrs = ["src/inttypes/imaxdiv.h"],
1917     deps = [
1918         ":__support_common",
1919         ":__support_integer_operations",
1920     ],
1923 ############################### stdlib targets ###############################
1925 libc_function(
1926     name = "abs",
1927     srcs = ["src/stdlib/abs.cpp"],
1928     hdrs = ["src/stdlib/abs.h"],
1929     deps = [
1930         ":__support_common",
1931         ":__support_integer_operations",
1932     ],
1935 libc_function(
1936     name = "labs",
1937     srcs = ["src/stdlib/labs.cpp"],
1938     hdrs = ["src/stdlib/labs.h"],
1939     deps = [
1940         ":__support_common",
1941         ":__support_integer_operations",
1942     ],
1945 libc_function(
1946     name = "llabs",
1947     srcs = ["src/stdlib/llabs.cpp"],
1948     hdrs = ["src/stdlib/llabs.h"],
1949     deps = [
1950         ":__support_common",
1951         ":__support_integer_operations",
1952     ],
1955 libc_function(
1956     name = "div",
1957     srcs = ["src/stdlib/div.cpp"],
1958     hdrs = ["src/stdlib/div.h"],
1959     deps = [
1960         ":__support_common",
1961         ":__support_integer_operations",
1962     ],
1965 libc_function(
1966     name = "ldiv",
1967     srcs = ["src/stdlib/ldiv.cpp"],
1968     hdrs = ["src/stdlib/ldiv.h"],
1969     deps = [
1970         ":__support_common",
1971         ":__support_integer_operations",
1972     ],
1975 libc_function(
1976     name = "lldiv",
1977     srcs = ["src/stdlib/lldiv.cpp"],
1978     hdrs = ["src/stdlib/lldiv.h"],
1979     deps = [
1980         ":__support_common",
1981         ":__support_integer_operations",
1982     ],
1985 libc_function(
1986     name = "atoi",
1987     srcs = ["src/stdlib/atoi.cpp"],
1988     hdrs = ["src/stdlib/atoi.h"],
1989     deps = [
1990         ":__support_common",
1991         ":__support_str_to_integer",
1992         ":errno",
1993     ],
1996 libc_function(
1997     name = "atol",
1998     srcs = ["src/stdlib/atol.cpp"],
1999     hdrs = ["src/stdlib/atol.h"],
2000     deps = [
2001         ":__support_common",
2002         ":__support_str_to_integer",
2003         ":errno",
2004     ],
2007 libc_function(
2008     name = "atoll",
2009     srcs = ["src/stdlib/atoll.cpp"],
2010     hdrs = ["src/stdlib/atoll.h"],
2011     deps = [
2012         ":__support_common",
2013         ":__support_str_to_integer",
2014         ":errno",
2015     ],
2018 libc_function(
2019     name = "atof",
2020     srcs = ["src/stdlib/atof.cpp"],
2021     hdrs = ["src/stdlib/atof.h"],
2022     deps = [
2023         ":__support_common",
2024         ":__support_str_to_float",
2025         ":errno",
2026     ],
2029 libc_function(
2030     name = "bsearch",
2031     srcs = ["src/stdlib/bsearch.cpp"],
2032     hdrs = ["src/stdlib/bsearch.h"],
2033     deps = [
2034         ":__support_common",
2035     ],
2038 libc_support_library(
2039     name = "qsort_util",
2040     hdrs = ["src/stdlib/qsort_util.h"],
2041     deps = [
2042         ":__support_common",
2043         ":__support_macros_attributes",
2044     ],
2047 libc_function(
2048     name = "qsort",
2049     srcs = ["src/stdlib/qsort.cpp"],
2050     hdrs = ["src/stdlib/qsort.h"],
2051     deps = [
2052         ":__support_common",
2053         ":qsort_util",
2054     ],
2057 libc_function(
2058     name = "qsort_r",
2059     srcs = ["src/stdlib/qsort_r.cpp"],
2060     hdrs = ["src/stdlib/qsort_r.h"],
2061     deps = [
2062         ":__support_common",
2063         ":qsort_util",
2064     ],
2067 libc_function(
2068     name = "strtol",
2069     srcs = ["src/stdlib/strtol.cpp"],
2070     hdrs = ["src/stdlib/strtol.h"],
2071     deps = [
2072         ":__support_common",
2073         ":__support_str_to_integer",
2074         ":errno",
2075     ],
2078 libc_function(
2079     name = "strtoll",
2080     srcs = ["src/stdlib/strtoll.cpp"],
2081     hdrs = ["src/stdlib/strtoll.h"],
2082     deps = [
2083         ":__support_common",
2084         ":__support_str_to_integer",
2085         ":errno",
2086     ],
2089 libc_function(
2090     name = "strtoul",
2091     srcs = ["src/stdlib/strtoul.cpp"],
2092     hdrs = ["src/stdlib/strtoul.h"],
2093     deps = [
2094         ":__support_common",
2095         ":__support_str_to_integer",
2096         ":errno",
2097     ],
2100 libc_function(
2101     name = "strtoull",
2102     srcs = ["src/stdlib/strtoull.cpp"],
2103     hdrs = ["src/stdlib/strtoull.h"],
2104     deps = [
2105         ":__support_common",
2106         ":__support_str_to_integer",
2107         ":errno",
2108     ],
2111 libc_function(
2112     name = "strtof",
2113     srcs = ["src/stdlib/strtof.cpp"],
2114     hdrs = ["src/stdlib/strtof.h"],
2115     deps = [
2116         ":__support_common",
2117         ":__support_str_to_float",
2118         ":errno",
2119     ],
2122 libc_function(
2123     name = "strtod",
2124     srcs = ["src/stdlib/strtod.cpp"],
2125     hdrs = ["src/stdlib/strtod.h"],
2126     deps = [
2127         ":__support_common",
2128         ":__support_str_to_float",
2129         ":errno",
2130     ],
2133 libc_function(
2134     name = "strtold",
2135     srcs = ["src/stdlib/strtold.cpp"],
2136     hdrs = ["src/stdlib/strtold.h"],
2137     deps = [
2138         ":__support_common",
2139         ":__support_str_to_float",
2140         ":errno",
2141     ],
2144 ############################### string targets ###############################
2146 no_sanitize_features = [
2147     "-asan",
2148     "-msan",
2149     "-tsan",
2150     "-ubsan",
2153 libc_support_library(
2154     name = "string_memory_utils",
2155     hdrs = [
2156         "src/string/memory_utils/op_aarch64.h",
2157         "src/string/memory_utils/op_builtin.h",
2158         "src/string/memory_utils/op_generic.h",
2159         "src/string/memory_utils/op_riscv.h",
2160         "src/string/memory_utils/op_x86.h",
2161         "src/string/memory_utils/utils.h",
2162     ],
2163     defines = MEMORY_COPTS,
2164     textual_hdrs = [
2165         "src/string/memory_utils/aarch64/inline_bcmp.h",
2166         "src/string/memory_utils/aarch64/inline_memcmp.h",
2167         "src/string/memory_utils/aarch64/inline_memcpy.h",
2168         "src/string/memory_utils/aarch64/inline_memmove.h",
2169         "src/string/memory_utils/aarch64/inline_memset.h",
2170         "src/string/memory_utils/generic/aligned_access.h",
2171         "src/string/memory_utils/generic/byte_per_byte.h",
2172         "src/string/memory_utils/inline_bcmp.h",
2173         "src/string/memory_utils/inline_bzero.h",
2174         "src/string/memory_utils/inline_memcmp.h",
2175         "src/string/memory_utils/inline_memcpy.h",
2176         "src/string/memory_utils/inline_memmem.h",
2177         "src/string/memory_utils/inline_memmove.h",
2178         "src/string/memory_utils/inline_memset.h",
2179         "src/string/memory_utils/inline_strcmp.h",
2180         "src/string/memory_utils/inline_strstr.h",
2181         "src/string/memory_utils/riscv/inline_bcmp.h",
2182         "src/string/memory_utils/riscv/inline_memcmp.h",
2183         "src/string/memory_utils/riscv/inline_memcpy.h",
2184         "src/string/memory_utils/riscv/inline_memmove.h",
2185         "src/string/memory_utils/riscv/inline_memset.h",
2186         "src/string/memory_utils/x86_64/inline_bcmp.h",
2187         "src/string/memory_utils/x86_64/inline_memcmp.h",
2188         "src/string/memory_utils/x86_64/inline_memcpy.h",
2189         "src/string/memory_utils/x86_64/inline_memmove.h",
2190         "src/string/memory_utils/x86_64/inline_memset.h",
2191     ],
2192     deps = [
2193         ":__support_common",
2194         ":__support_cpp_array",
2195         ":__support_cpp_bit",
2196         ":__support_cpp_cstddef",
2197         ":__support_cpp_type_traits",
2198         ":__support_macros_attributes",
2199         ":__support_macros_config",
2200         ":__support_macros_optimization",
2201         ":__support_macros_properties_architectures",
2202         ":__support_macros_properties_cpu_features",
2203     ],
2206 libc_support_library(
2207     name = "string_utils",
2208     hdrs = ["src/string/string_utils.h"],
2209     deps = [
2210         ":__support_common",
2211         ":__support_cpp_bitset",
2212         ":__support_macros_optimization",
2213         ":string_memory_utils",
2214     ],
2217 libc_function(
2218     name = "memchr",
2219     srcs = ["src/string/memchr.cpp"],
2220     hdrs = ["src/string/memchr.h"],
2221     deps = [
2222         ":__support_common",
2223         ":string_utils",
2224     ],
2227 libc_function(
2228     name = "memcpy",
2229     srcs = ["src/string/memcpy.cpp"],
2230     hdrs = ["src/string/memcpy.h"],
2231     copts = ["-mllvm --tail-merge-threshold=0"],
2232     features = no_sanitize_features,
2233     weak = True,
2234     deps = [
2235         ":__support_common",
2236         ":string_memory_utils",
2237     ],
2240 libc_function(
2241     name = "memset",
2242     srcs = ["src/string/memset.cpp"],
2243     hdrs = ["src/string/memset.h"],
2244     features = no_sanitize_features,
2245     weak = True,
2246     deps = [
2247         ":__support_common",
2248         ":string_memory_utils",
2249     ],
2252 libc_function(
2253     name = "memmove",
2254     srcs = ["src/string/memmove.cpp"],
2255     hdrs = ["src/string/memmove.h"],
2256     features = no_sanitize_features,
2257     weak = True,
2258     deps = [
2259         ":__support_common",
2260         ":string_memory_utils",
2261     ],
2264 libc_function(
2265     name = "mempcpy",
2266     srcs = ["src/string/mempcpy.cpp"],
2267     hdrs = ["src/string/mempcpy.h"],
2268     copts = ["-mllvm --tail-merge-threshold=0"],
2269     features = no_sanitize_features,
2270     weak = True,
2271     deps = [
2272         ":__support_common",
2273         ":string_memory_utils",
2274     ],
2277 libc_function(
2278     name = "bcopy",
2279     srcs = ["src/string/bcopy.cpp"],
2280     hdrs = ["src/string/bcopy.h"],
2281     features = no_sanitize_features,
2282     deps = [
2283         ":__support_common",
2284         ":string_memory_utils",
2285     ],
2288 libc_function(
2289     name = "memcmp",
2290     srcs = ["src/string/memcmp.cpp"],
2291     hdrs = ["src/string/memcmp.h"],
2292     features = no_sanitize_features,
2293     weak = True,
2294     deps = [
2295         ":__support_common",
2296         ":__support_integer_operations",
2297         ":string_memory_utils",
2298     ],
2301 libc_function(
2302     name = "bcmp",
2303     srcs = ["src/string/bcmp.cpp"],
2304     hdrs = ["src/string/bcmp.h"],
2305     features = no_sanitize_features,
2306     weak = True,
2307     deps = [
2308         ":__support_common",
2309         ":string_memory_utils",
2310     ],
2313 libc_function(
2314     name = "bzero",
2315     srcs = ["src/string/bzero.cpp"],
2316     hdrs = ["src/string/bzero.h"],
2317     features = no_sanitize_features,
2318     weak = True,
2319     deps = [
2320         ":__support_common",
2321         ":string_memory_utils",
2322     ],
2325 libc_function(
2326     name = "memrchr",
2327     srcs = ["src/string/memrchr.cpp"],
2328     hdrs = ["src/string/memrchr.h"],
2329     deps = [
2330         ":__support_common",
2331         ":string_utils",
2332     ],
2335 libc_function(
2336     name = "strlen",
2337     srcs = ["src/string/strlen.cpp"],
2338     hdrs = ["src/string/strlen.h"],
2339     features = no_sanitize_features,
2340     deps = [
2341         ":__support_common",
2342         ":string_utils",
2343     ],
2346 libc_function(
2347     name = "strcpy",
2348     srcs = ["src/string/strcpy.cpp"],
2349     hdrs = ["src/string/strcpy.h"],
2350     features = no_sanitize_features,
2351     deps = [
2352         ":__support_common",
2353         ":memcpy",
2354         ":string_memory_utils",
2355         ":string_utils",
2356     ],
2359 # A sanitizer instrumented flavor of strcpy to be used with unittests.
2360 libc_function(
2361     name = "strcpy_sanitized",
2362     testonly = 1,
2363     srcs = ["src/string/strcpy.cpp"],
2364     hdrs = ["src/string/strcpy.h"],
2365     deps = [
2366         ":__support_common",
2367         ":memcpy",
2368         ":string_memory_utils",
2369         ":string_utils",
2370     ],
2373 libc_function(
2374     name = "strncpy",
2375     srcs = ["src/string/strncpy.cpp"],
2376     hdrs = ["src/string/strncpy.h"],
2377     deps = [
2378         ":__support_common",
2379     ],
2382 libc_function(
2383     name = "strcmp",
2384     srcs = ["src/string/strcmp.cpp"],
2385     hdrs = ["src/string/strcmp.h"],
2386     deps = [
2387         ":__support_common",
2388         ":string_memory_utils",
2389         ":string_utils",
2390     ],
2393 libc_function(
2394     name = "strchr",
2395     srcs = ["src/string/strchr.cpp"],
2396     hdrs = ["src/string/strchr.h"],
2397     deps = [
2398         ":__support_common",
2399         ":string_utils",
2400     ],
2403 libc_function(
2404     name = "strrchr",
2405     srcs = ["src/string/strrchr.cpp"],
2406     hdrs = ["src/string/strrchr.h"],
2407     deps = [
2408         ":__support_common",
2409         ":string_utils",
2410     ],
2413 libc_function(
2414     name = "strstr",
2415     srcs = ["src/string/strstr.cpp"],
2416     hdrs = ["src/string/strstr.h"],
2417     deps = [
2418         ":__support_common",
2419         ":string_memory_utils",
2420         ":string_utils",
2421     ],
2424 libc_function(
2425     name = "strnlen",
2426     srcs = ["src/string/strnlen.cpp"],
2427     hdrs = ["src/string/strnlen.h"],
2428     deps = [
2429         ":__support_common",
2430         ":string_utils",
2431     ],
2434 libc_function(
2435     name = "strcspn",
2436     srcs = ["src/string/strcspn.cpp"],
2437     hdrs = ["src/string/strcspn.h"],
2438     deps = [
2439         ":__support_common",
2440         ":string_utils",
2441     ],
2444 libc_function(
2445     name = "strspn",
2446     srcs = ["src/string/strspn.cpp"],
2447     hdrs = ["src/string/strspn.h"],
2448     deps = [
2449         ":__support_common",
2450         ":__support_cpp_bitset",
2451         ":string_utils",
2452     ],
2455 libc_function(
2456     name = "strpbrk",
2457     srcs = ["src/string/strpbrk.cpp"],
2458     hdrs = ["src/string/strpbrk.h"],
2459     deps = [
2460         ":__support_common",
2461         ":string_utils",
2462     ],
2465 libc_function(
2466     name = "strtok",
2467     srcs = ["src/string/strtok.cpp"],
2468     hdrs = ["src/string/strtok.h"],
2469     deps = [
2470         ":__support_common",
2471         ":string_utils",
2472     ],
2475 ############################### unistd targets ###############################
2477 libc_function(
2478     name = "chdir",
2479     srcs = ["src/unistd/linux/chdir.cpp"],
2480     hdrs = ["src/unistd/chdir.h"],
2481     deps = [
2482         ":__support_common",
2483         ":__support_osutil_syscall",
2484         ":errno",
2485     ],
2488 libc_function(
2489     name = "close",
2490     srcs = ["src/unistd/linux/close.cpp"],
2491     hdrs = ["src/unistd/close.h"],
2492     deps = [
2493         ":__support_common",
2494         ":__support_osutil_syscall",
2495         ":errno",
2496     ],
2499 libc_function(
2500     name = "fchdir",
2501     srcs = ["src/unistd/linux/fchdir.cpp"],
2502     hdrs = ["src/unistd/fchdir.h"],
2503     deps = [
2504         ":__support_common",
2505         ":__support_osutil_syscall",
2506         ":errno",
2507     ],
2510 libc_function(
2511     name = "fsync",
2512     srcs = ["src/unistd/linux/fsync.cpp"],
2513     hdrs = ["src/unistd/fsync.h"],
2514     deps = [
2515         ":__support_common",
2516         ":__support_osutil_syscall",
2517         ":errno",
2518     ],
2521 libc_function(
2522     name = "ftruncate",
2523     srcs = ["src/unistd/linux/ftruncate.cpp"],
2524     hdrs = ["src/unistd/ftruncate.h"],
2525     deps = [
2526         ":__support_common",
2527         ":__support_osutil_syscall",
2528         ":errno",
2529     ],
2532 libc_function(
2533     name = "link",
2534     srcs = ["src/unistd/linux/link.cpp"],
2535     hdrs = ["src/unistd/link.h"],
2536     deps = [
2537         ":__support_common",
2538         ":__support_osutil_syscall",
2539         ":errno",
2540     ],
2543 libc_function(
2544     name = "linkat",
2545     srcs = ["src/unistd/linux/linkat.cpp"],
2546     hdrs = ["src/unistd/linkat.h"],
2547     deps = [
2548         ":__support_common",
2549         ":__support_osutil_syscall",
2550         ":errno",
2551     ],
2554 libc_function(
2555     name = "lseek",
2556     srcs = ["src/unistd/linux/lseek.cpp"],
2557     hdrs = ["src/unistd/lseek.h"],
2558     deps = [
2559         ":__support_common",
2560         ":__support_file_linux_lseekimpl",
2561         ":__support_osutil_syscall",
2562         ":errno",
2563     ],
2566 libc_function(
2567     name = "read",
2568     srcs = ["src/unistd/linux/read.cpp"],
2569     hdrs = ["src/unistd/read.h"],
2570     deps = [
2571         ":__support_common",
2572         ":__support_osutil_syscall",
2573         ":errno",
2574     ],
2577 libc_function(
2578     name = "readlink",
2579     srcs = ["src/unistd/linux/readlink.cpp"],
2580     hdrs = ["src/unistd/readlink.h"],
2581     deps = [
2582         ":__support_common",
2583         ":__support_osutil_syscall",
2584         ":errno",
2585     ],
2588 libc_function(
2589     name = "readlinkat",
2590     srcs = ["src/unistd/linux/readlinkat.cpp"],
2591     hdrs = ["src/unistd/readlinkat.h"],
2592     deps = [
2593         ":__support_common",
2594         ":__support_osutil_syscall",
2595         ":errno",
2596     ],
2599 libc_function(
2600     name = "rmdir",
2601     srcs = ["src/unistd/linux/rmdir.cpp"],
2602     hdrs = ["src/unistd/rmdir.h"],
2603     deps = [
2604         ":__support_common",
2605         ":__support_osutil_syscall",
2606         ":errno",
2607     ],
2610 libc_function(
2611     name = "symlink",
2612     srcs = ["src/unistd/linux/symlink.cpp"],
2613     hdrs = ["src/unistd/symlink.h"],
2614     deps = [
2615         ":__support_common",
2616         ":__support_osutil_syscall",
2617         ":errno",
2618     ],
2621 libc_function(
2622     name = "symlinkat",
2623     srcs = ["src/unistd/linux/symlinkat.cpp"],
2624     hdrs = ["src/unistd/symlinkat.h"],
2625     deps = [
2626         ":__support_common",
2627         ":__support_osutil_syscall",
2628         ":errno",
2629     ],
2632 libc_function(
2633     name = "truncate",
2634     srcs = ["src/unistd/linux/truncate.cpp"],
2635     hdrs = ["src/unistd/truncate.h"],
2636     deps = [
2637         ":__support_common",
2638         ":__support_osutil_syscall",
2639         ":errno",
2640     ],
2643 libc_function(
2644     name = "unlink",
2645     srcs = ["src/unistd/linux/unlink.cpp"],
2646     hdrs = ["src/unistd/unlink.h"],
2647     deps = [
2648         ":__support_common",
2649         ":__support_osutil_syscall",
2650         ":errno",
2651     ],
2654 libc_function(
2655     name = "unlinkat",
2656     srcs = ["src/unistd/linux/unlinkat.cpp"],
2657     hdrs = ["src/unistd/unlinkat.h"],
2658     deps = [
2659         ":__support_common",
2660         ":__support_osutil_syscall",
2661         ":errno",
2662     ],
2665 libc_function(
2666     name = "write",
2667     srcs = ["src/unistd/linux/write.cpp"],
2668     hdrs = ["src/unistd/write.h"],
2669     deps = [
2670         ":__support_common",
2671         ":__support_osutil_syscall",
2672         ":errno",
2673     ],
2676 ################################ stdio targets #################################
2678 libc_support_library(
2679     name = "printf_core_structs",
2680     hdrs = ["src/stdio/printf_core/core_structs.h"],
2681     defines = PRINTF_COPTS,
2682     deps = [
2683         ":__support_cpp_string_view",
2684         ":__support_fputil_fp_bits",
2685     ],
2688 libc_support_library(
2689     name = "printf_config",
2690     hdrs = ["src/stdio/printf_core/printf_config.h"],
2691     defines = PRINTF_COPTS,
2692     deps = [
2693     ],
2696 libc_support_library(
2697     name = "printf_parser",
2698     hdrs = ["src/stdio/printf_core/parser.h"],
2699     defines = PRINTF_COPTS,
2700     deps = [
2701         ":__support_arg_list",
2702         ":__support_common",
2703         ":__support_cpp_bit",
2704         ":__support_cpp_optional",
2705         ":__support_cpp_string_view",
2706         ":__support_cpp_type_traits",
2707         ":__support_ctype_utils",
2708         ":__support_fputil_fp_bits",
2709         ":__support_str_to_integer",
2710         ":printf_config",
2711         ":printf_core_structs",
2712     ],
2715 # Only used for testing.
2716 libc_support_library(
2717     name = "printf_mock_parser",
2718     hdrs = ["src/stdio/printf_core/parser.h"],
2719     defines = PRINTF_COPTS + ["LIBC_COPT_MOCK_ARG_LIST"],
2720     deps = [
2721         ":__support_arg_list",
2722         ":__support_common",
2723         ":__support_cpp_bit",
2724         ":__support_cpp_optional",
2725         ":__support_cpp_string_view",
2726         ":__support_cpp_type_traits",
2727         ":__support_ctype_utils",
2728         ":__support_fputil_fp_bits",
2729         ":__support_str_to_integer",
2730         ":printf_config",
2731         ":printf_core_structs",
2732     ],
2735 libc_support_library(
2736     name = "printf_writer",
2737     srcs = ["src/stdio/printf_core/writer.cpp"],
2738     hdrs = ["src/stdio/printf_core/writer.h"],
2739     defines = PRINTF_COPTS,
2740     deps = [
2741         ":__support_cpp_string_view",
2742         ":__support_macros_optimization",
2743         ":printf_core_structs",
2744         ":string_memory_utils",
2745     ],
2748 libc_support_library(
2749     name = "printf_converter",
2750     srcs = ["src/stdio/printf_core/converter.cpp"],
2751     hdrs = [
2752         "src/stdio/printf_core/char_converter.h",
2753         "src/stdio/printf_core/converter.h",
2754         "src/stdio/printf_core/converter_atlas.h",
2755         "src/stdio/printf_core/converter_utils.h",
2756         "src/stdio/printf_core/float_dec_converter.h",
2757         "src/stdio/printf_core/float_hex_converter.h",
2758         "src/stdio/printf_core/float_inf_nan_converter.h",
2759         "src/stdio/printf_core/int_converter.h",
2760         "src/stdio/printf_core/ptr_converter.h",
2761         "src/stdio/printf_core/string_converter.h",
2762         "src/stdio/printf_core/write_int_converter.h",
2763     ],
2764     defines = PRINTF_COPTS,
2765     deps = [
2766         ":__support_common",
2767         ":__support_cpp_limits",
2768         ":__support_cpp_span",
2769         ":__support_cpp_string_view",
2770         ":__support_float_to_string",
2771         ":__support_fputil_fenv_impl",
2772         ":__support_fputil_fp_bits",
2773         ":__support_fputil_rounding_mode",
2774         ":__support_integer_to_string",
2775         ":__support_libc_assert",
2776         ":__support_uint",
2777         ":__support_uint128",
2778         ":printf_core_structs",
2779         ":printf_writer",
2780     ],
2783 libc_support_library(
2784     name = "printf_main",
2785     srcs = ["src/stdio/printf_core/printf_main.cpp"],
2786     hdrs = ["src/stdio/printf_core/printf_main.h"],
2787     defines = PRINTF_COPTS,
2788     deps = [
2789         ":__support_arg_list",
2790         ":printf_converter",
2791         ":printf_core_structs",
2792         ":printf_parser",
2793         ":printf_writer",
2794     ],
2797 libc_support_library(
2798     name = "vfprintf_internal",
2799     hdrs = ["src/stdio/printf_core/vfprintf_internal.h"],
2800     defines = PRINTF_COPTS,
2801     deps = [
2802         ":__support_arg_list",
2803         ":__support_file_file",
2804         ":__support_macros_attributes",
2805         ":printf_main",
2806         ":printf_writer",
2807     ],
2810 libc_function(
2811     name = "sprintf",
2812     srcs = ["src/stdio/sprintf.cpp"],
2813     hdrs = ["src/stdio/sprintf.h"],
2814     defines = PRINTF_COPTS,
2815     deps = [
2816         ":__support_arg_list",
2817         ":__support_cpp_limits",
2818         ":errno",
2819         ":printf_main",
2820         ":printf_writer",
2821     ],
2824 libc_function(
2825     name = "snprintf",
2826     srcs = ["src/stdio/snprintf.cpp"],
2827     hdrs = ["src/stdio/snprintf.h"],
2828     defines = PRINTF_COPTS,
2829     deps = [
2830         ":__support_arg_list",
2831         ":errno",
2832         ":printf_main",
2833         ":printf_writer",
2834     ],
2837 libc_function(
2838     name = "printf",
2839     srcs = ["src/stdio/printf.cpp"],
2840     hdrs = ["src/stdio/printf.h"],
2841     defines = PRINTF_COPTS,
2842     deps = [
2843         ":__support_arg_list",
2844         ":__support_file_file",
2845         ":errno",
2846         ":vfprintf_internal",
2847     ],
2850 libc_function(
2851     name = "fprintf",
2852     srcs = ["src/stdio/fprintf.cpp"],
2853     hdrs = ["src/stdio/fprintf.h"],
2854     defines = PRINTF_COPTS,
2855     deps = [
2856         ":__support_arg_list",
2857         ":__support_file_file",
2858         ":errno",
2859         ":vfprintf_internal",
2860     ],
2863 libc_function(
2864     name = "vsprintf",
2865     srcs = ["src/stdio/vsprintf.cpp"],
2866     hdrs = ["src/stdio/vsprintf.h"],
2867     defines = PRINTF_COPTS,
2868     deps = [
2869         ":__support_arg_list",
2870         ":__support_cpp_limits",
2871         ":errno",
2872         ":printf_main",
2873         ":printf_writer",
2874     ],
2877 libc_function(
2878     name = "vsnprintf",
2879     srcs = ["src/stdio/vsnprintf.cpp"],
2880     hdrs = ["src/stdio/vsnprintf.h"],
2881     defines = PRINTF_COPTS,
2882     deps = [
2883         ":__support_arg_list",
2884         ":errno",
2885         ":printf_main",
2886         ":printf_writer",
2887     ],
2890 libc_function(
2891     name = "vprintf",
2892     srcs = ["src/stdio/vprintf.cpp"],
2893     hdrs = ["src/stdio/vprintf.h"],
2894     defines = PRINTF_COPTS,
2895     deps = [
2896         ":__support_arg_list",
2897         ":__support_file_file",
2898         ":errno",
2899         ":vfprintf_internal",
2900     ],
2903 libc_function(
2904     name = "vfprintf",
2905     srcs = ["src/stdio/vfprintf.cpp"],
2906     hdrs = ["src/stdio/vfprintf.h"],
2907     defines = PRINTF_COPTS,
2908     deps = [
2909         ":__support_arg_list",
2910         ":__support_file_file",
2911         ":errno",
2912         ":vfprintf_internal",
2913     ],