xref: /llvm-project/utils/bazel/llvm-project-overlay/libc/BUILD.bazel (revision 0510d4ea59a185db453b5910f307e1c6e9184589)
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
4
5# LLVM libc project.
6load("@bazel_skylib//lib:selects.bzl", "selects")
7load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
8load(
9    ":libc_build_rules.bzl",
10    "libc_function",
11    "libc_math_function",
12    "libc_support_library",
13)
14load(":platforms.bzl", "PLATFORM_CPU_ARM64", "PLATFORM_CPU_X86_64")
15
16package(
17    default_visibility = ["//visibility:public"],
18    features = [
19        "-use_header_modules",
20        "-layering_check",
21    ],
22)
23
24licenses(["notice"])
25
26# A flag to pick which `mpfr` to use for math tests.
27# Usage: `--@llvm-project//libc:mpfr=<disable|external|system>`.
28# Flag documentation: https://bazel.build/extending/config
29string_flag(
30    name = "mpfr",
31    build_setting_default = "external",
32    values = [
33        "disable",  # Skip tests that need mpfr
34        "external",  # Build mpfr from source
35        "system",  # Use system mpfr (non hermetic)
36    ],
37)
38
39config_setting(
40    name = "mpfr_disable",
41    flag_values = {":mpfr": "disable"},
42)
43
44config_setting(
45    name = "mpfr_external",
46    flag_values = {":mpfr": "external"},
47)
48
49config_setting(
50    name = "mpfr_system",
51    flag_values = {":mpfr": "system"},
52)
53
54################################## Base Config #################################
55
56libc_support_library(
57    name = "__support_macros_config",
58    hdrs = ["src/__support/macros/config.h"],
59)
60
61################################# Include Files ################################
62
63libc_support_library(
64    name = "llvm_libc_macros_math_macros",
65    hdrs = ["include/llvm-libc-macros/math-macros.h"],
66    deps = [":llvm_libc_macros_limits_macros"],
67)
68
69libc_support_library(
70    name = "llvm_libc_macros_limits_macros",
71    hdrs = ["include/llvm-libc-macros/limits-macros.h"],
72)
73
74libc_support_library(
75    name = "llvm_libc_macros_float_macros",
76    hdrs = ["include/llvm-libc-macros/float-macros.h"],
77)
78
79libc_support_library(
80    name = "llvm_libc_macros_float16_macros",
81    hdrs = ["include/llvm-libc-macros/float16-macros.h"],
82    deps = [":llvm_libc_types_float128"],
83)
84
85libc_support_library(
86    name = "llvm_libc_macros_stdint_macros",
87    hdrs = ["include/llvm-libc-macros/stdint-macros.h"],
88)
89
90libc_support_library(
91    name = "llvm_libc_macros_stdfix_macros",
92    hdrs = ["include/llvm-libc-macros/stdfix-macros.h"],
93    deps = [":llvm_libc_macros_float_macros"],
94)
95
96libc_support_library(
97    name = "llvm_libc_types_float128",
98    hdrs = ["include/llvm-libc-types/float128.h"],
99    target_compatible_with = select({
100        "@platforms//os:linux": [],
101        "//conditions:default": ["@platforms//:incompatible"],
102    }),
103    deps = [":llvm_libc_macros_float_macros"],
104)
105
106libc_support_library(
107    name = "llvm_libc_types_cfloat128",
108    hdrs = ["include/llvm-libc-types/cfloat128.h"],
109    deps = [":llvm_libc_macros_float_macros"],
110)
111
112libc_support_library(
113    name = "llvm_libc_types_cfloat16",
114    hdrs = ["include/llvm-libc-types/cfloat16.h"],
115)
116
117libc_support_library(
118    name = "llvm_libc_macros_fcntl_macros",
119    hdrs = ["include/llvm-libc-macros/linux/fcntl-macros.h"],
120)
121
122libc_support_library(
123    name = "llvm_libc_types_size_t",
124    hdrs = ["include/llvm-libc-types/size_t.h"],
125)
126
127########################### Macro Proxy Header Files ###########################
128
129libc_support_library(
130    name = "hdr_math_macros",
131    hdrs = ["hdr/math_macros.h"],
132)
133
134libc_support_library(
135    name = "hdr_fenv_macros",
136    hdrs = ["hdr/fenv_macros.h"],
137)
138
139libc_support_library(
140    name = "hdr_fcntl_macros",
141    hdrs = ["hdr/fcntl_macros.h"],
142    deps = [":hdr_fcntl_overlay"],
143)
144
145libc_support_library(
146    name = "hdr_fcntl_overlay",
147    hdrs = ["hdr/fcntl_overlay.h"],
148)
149
150libc_support_library(
151    name = "hdr_signal_macros",
152    hdrs = ["hdr/signal_macros.h"],
153)
154
155libc_support_library(
156    name = "hdr_sys_epoll_macros",
157    hdrs = ["hdr/sys_epoll_macros.h"],
158)
159
160libc_support_library(
161    name = "hdr_errno_macros",
162    hdrs = ["hdr/errno_macros.h"],
163)
164
165libc_support_library(
166    name = "hdr_time_macros",
167    hdrs = ["hdr/time_macros.h"],
168)
169
170libc_support_library(
171    name = "hdr_float_macros",
172    hdrs = ["hdr/float_macros.h"],
173)
174
175libc_support_library(
176    name = "hdr_stdio_macros",
177    hdrs = ["hdr/stdio_macros.h"],
178    deps = [
179        ":hdr_stdio_overlay",
180    ],
181)
182
183libc_support_library(
184    name = "hdr_unistd_macros",
185    hdrs = ["hdr/unistd_macros.h"],
186    deps = [
187        ":hdr_unistd_overlay",
188    ],
189)
190
191libc_support_library(
192    name = "hdr_limits_macros",
193    hdrs = ["hdr/limits_macros.h"],
194)
195
196libc_support_library(
197    name = "hdr_stdio_overlay",
198    hdrs = ["hdr/stdio_overlay.h"],
199)
200
201libc_support_library(
202    name = "hdr_stdlib_overlay",
203    hdrs = ["hdr/stdlib_overlay.h"],
204)
205
206libc_support_library(
207    name = "hdr_unistd_overlay",
208    hdrs = ["hdr/unistd_overlay.h"],
209)
210
211############################ Type Proxy Header Files ###########################
212
213libc_support_library(
214    name = "func_aligned_alloc",
215    hdrs = ["hdr/func/aligned_alloc.h"],
216    deps = [":hdr_stdlib_overlay"],
217)
218
219libc_support_library(
220    name = "func_free",
221    hdrs = ["hdr/func/free.h"],
222    deps = [":hdr_stdlib_overlay"],
223)
224
225libc_support_library(
226    name = "func_malloc",
227    hdrs = ["hdr/func/malloc.h"],
228    deps = [":hdr_stdlib_overlay"],
229)
230
231libc_support_library(
232    name = "func_realloc",
233    hdrs = ["hdr/func/realloc.h"],
234    deps = [":hdr_stdlib_overlay"],
235)
236
237libc_support_library(
238    name = "types_clockid_t",
239    hdrs = ["hdr/types/clockid_t.h"],
240)
241
242libc_support_library(
243    name = "types_clock_t",
244    hdrs = ["hdr/types/clock_t.h"],
245)
246
247libc_support_library(
248    name = "types_div_t",
249    hdrs = ["hdr/types/div_t.h"],
250    deps = [":hdr_stdlib_overlay"],
251)
252
253libc_support_library(
254    name = "types_fenv_t",
255    hdrs = ["hdr/types/fenv_t.h"],
256)
257
258libc_support_library(
259    name = "types_fexcept_t",
260    hdrs = ["hdr/types/fexcept_t.h"],
261)
262
263libc_support_library(
264    name = "types_ldiv_t",
265    hdrs = ["hdr/types/ldiv_t.h"],
266    deps = [":hdr_stdlib_overlay"],
267)
268
269libc_support_library(
270    name = "types_lldiv_t",
271    hdrs = ["hdr/types/lldiv_t.h"],
272    deps = [":hdr_stdlib_overlay"],
273)
274
275libc_support_library(
276    name = "types_mode_t",
277    hdrs = ["hdr/types/mode_t.h"],
278    deps = [":hdr_fcntl_overlay"],
279)
280
281libc_support_library(
282    name = "types_sigset_t",
283    hdrs = ["hdr/types/sigset_t.h"],
284)
285
286libc_support_library(
287    name = "types_size_t",
288    hdrs = ["hdr/types/size_t.h"],
289)
290
291libc_support_library(
292    name = "types_struct_epoll_event",
293    hdrs = ["hdr/types/struct_epoll_event.h"],
294)
295
296libc_support_library(
297    name = "types_struct_timespec",
298    hdrs = ["hdr/types/struct_timespec.h"],
299)
300
301libc_support_library(
302    name = "types_time_t",
303    hdrs = ["hdr/types/time_t.h"],
304)
305
306libc_support_library(
307    name = "types_struct_timeval",
308    hdrs = ["hdr/types/struct_timeval.h"],
309)
310
311libc_support_library(
312    name = "types_pid_t",
313    hdrs = ["hdr/types/pid_t.h"],
314)
315
316libc_support_library(
317    name = "types_uid_t",
318    hdrs = ["hdr/types/uid_t.h"],
319)
320
321libc_support_library(
322    name = "types_off_t",
323    hdrs = ["hdr/types/off_t.h"],
324    deps = [
325        ":hdr_stdio_overlay",
326    ],
327)
328
329libc_support_library(
330    name = "types_FILE",
331    hdrs = ["hdr/types/FILE.h"],
332    deps = [
333        ":hdr_stdio_overlay",
334    ],
335)
336
337libc_support_library(
338    name = "types_ssize_t",
339    hdrs = ["hdr/types/ssize_t.h"],
340)
341
342libc_support_library(
343    name = "types_socklen_t",
344    hdrs = ["hdr/types/socklen_t.h"],
345)
346
347libc_support_library(
348    name = "types_struct_sockaddr",
349    hdrs = ["hdr/types/struct_sockaddr.h"],
350)
351
352libc_support_library(
353    name = "types_struct_msghdr",
354    hdrs = ["hdr/types/struct_msghdr.h"],
355)
356
357############################### Support libraries ##############################
358
359libc_support_library(
360    name = "__support_macros_properties_architectures",
361    hdrs = ["src/__support/macros/properties/architectures.h"],
362)
363
364libc_support_library(
365    name = "__support_macros_properties_compiler",
366    hdrs = ["src/__support/macros/properties/compiler.h"],
367)
368
369libc_support_library(
370    name = "__support_macros_properties_os",
371    hdrs = ["src/__support/macros/properties/os.h"],
372)
373
374libc_support_library(
375    name = "__support_macros_properties_complex_types",
376    hdrs = ["src/__support/macros/properties/complex_types.h"],
377    deps = [
378        ":__support_macros_properties_types",
379        ":llvm_libc_types_cfloat128",
380        ":llvm_libc_types_cfloat16",
381    ],
382)
383
384libc_support_library(
385    name = "__support_macros_properties_types",
386    hdrs = ["src/__support/macros/properties/types.h"],
387    deps = [
388        ":__support_macros_properties_architectures",
389        ":__support_macros_properties_compiler",
390        ":__support_macros_properties_cpu_features",
391        ":__support_macros_properties_os",
392        ":hdr_float_macros",
393        ":llvm_libc_macros_float16_macros",
394        ":llvm_libc_types_float128",
395    ],
396)
397
398libc_support_library(
399    name = "__support_macros_properties_cpu_features",
400    hdrs = ["src/__support/macros/properties/cpu_features.h"],
401    deps = [
402        "__support_macros_properties_architectures",
403    ],
404)
405
406libc_support_library(
407    name = "__support_macros_attributes",
408    hdrs = ["src/__support/macros/attributes.h"],
409    deps = [
410        ":__support_macros_properties_architectures",
411    ],
412)
413
414libc_support_library(
415    name = "__support_macros_optimization",
416    hdrs = ["src/__support/macros/optimization.h"],
417    deps = [
418        ":__support_macros_attributes",
419        ":__support_macros_config",
420        ":__support_macros_properties_compiler",
421    ],
422)
423
424libc_support_library(
425    name = "__support_macros_sanitizer",
426    hdrs = ["src/__support/macros/sanitizer.h"],
427    deps = [
428        ":__support_macros_config",
429    ],
430)
431
432libc_support_library(
433    name = "__support_macros_null_check",
434    hdrs = ["src/__support/macros/null_check.h"],
435    deps = [
436        ":__support_macros_config",
437        ":__support_macros_optimization",
438        ":__support_macros_sanitizer",
439    ],
440)
441
442libc_support_library(
443    name = "__support_common",
444    hdrs = [
445        "src/__support/common.h",
446        "src/__support/endian_internal.h",
447    ],
448    deps = [
449        ":__support_macros_attributes",
450        ":__support_macros_config",
451        ":__support_macros_properties_architectures",
452    ],
453)
454
455libc_support_library(
456    name = "__support_cpp_algorithm",
457    hdrs = ["src/__support/CPP/algorithm.h"],
458    deps = [
459        ":__support_macros_attributes",
460        ":__support_macros_config",
461    ],
462)
463
464libc_support_library(
465    name = "__support_cpp_iterator",
466    hdrs = ["src/__support/CPP/iterator.h"],
467    deps = [
468        ":__support_cpp_type_traits",
469        ":__support_macros_attributes",
470    ],
471)
472
473libc_support_library(
474    name = "__support_cpp_array",
475    hdrs = ["src/__support/CPP/array.h"],
476    deps = [
477        ":__support_cpp_iterator",
478        ":__support_macros_attributes",
479    ],
480)
481
482libc_support_library(
483    name = "__support_cpp_bit",
484    hdrs = ["src/__support/CPP/bit.h"],
485    deps = [
486        ":__support_cpp_limits",
487        ":__support_cpp_type_traits",
488        ":__support_macros_attributes",
489        ":__support_macros_sanitizer",
490    ],
491)
492
493libc_support_library(
494    name = "__support_cpp_bitset",
495    hdrs = ["src/__support/CPP/bitset.h"],
496    deps = [
497        ":__support_macros_attributes",
498        ":__support_macros_config",
499    ],
500)
501
502libc_support_library(
503    name = "__support_cpp_cstddef",
504    hdrs = ["src/__support/CPP/cstddef.h"],
505    deps = [
506        ":__support_cpp_type_traits",
507        ":__support_macros_attributes",
508    ],
509)
510
511libc_support_library(
512    name = "__support_cpp_expected",
513    hdrs = ["src/__support/CPP/expected.h"],
514    deps = [
515        ":__support_macros_attributes",
516        ":__support_macros_config",
517    ],
518)
519
520libc_support_library(
521    name = "__support_cpp_functional",
522    hdrs = ["src/__support/CPP/functional.h"],
523    deps = [
524        "__support_cpp_type_traits",
525        "__support_cpp_utility",
526        "__support_macros_attributes",
527    ],
528)
529
530libc_support_library(
531    name = "__support_cpp_limits",
532    hdrs = ["src/__support/CPP/limits.h"],
533    deps = [
534        "__support_cpp_type_traits",
535        "__support_macros_attributes",
536        ":__support_macros_properties_types",
537        ":hdr_limits_macros",
538    ],
539)
540
541libc_support_library(
542    name = "__support_cpp_new",
543    srcs = ["src/__support/CPP/new.cpp"],
544    hdrs = ["src/__support/CPP/new.h"],
545    deps = [
546        ":__support_common",
547        ":__support_macros_properties_os",
548        ":func_aligned_alloc",
549        ":func_free",
550        ":func_malloc",
551    ],
552)
553
554libc_support_library(
555    name = "__support_cpp_optional",
556    hdrs = ["src/__support/CPP/optional.h"],
557    deps = [
558        ":__support_cpp_utility",
559    ],
560)
561
562libc_support_library(
563    name = "__support_cpp_span",
564    hdrs = ["src/__support/CPP/span.h"],
565    deps = [
566        ":__support_cpp_array",
567        ":__support_cpp_type_traits",
568    ],
569)
570
571libc_support_library(
572    name = "__support_cpp_string_view",
573    hdrs = ["src/__support/CPP/string_view.h"],
574    deps = [
575        ":__support_common",
576    ],
577)
578
579libc_support_library(
580    name = "__support_cpp_stringstream",
581    hdrs = ["src/__support/CPP/stringstream.h"],
582    deps = [
583        ":__support_cpp_span",
584        ":__support_cpp_string_view",
585        ":__support_cpp_type_traits",
586        ":__support_integer_to_string",
587    ],
588)
589
590libc_support_library(
591    name = "__support_cpp_string",
592    hdrs = ["src/__support/CPP/string.h"],
593    deps = [
594        ":__support_common",
595        ":__support_cpp_string_view",
596        ":__support_integer_to_string",
597        ":func_free",
598        ":func_malloc",
599        ":func_realloc",
600        ":string_memory_utils",
601        ":string_utils",
602    ],
603)
604
605libc_support_library(
606    name = "__support_cpp_type_traits",
607    hdrs = glob(["src/__support/CPP/type_traits/*.h"]) + [
608        "src/__support/CPP/type_traits.h",
609        "src/__support/CPP/utility/declval.h",
610        "src/__support/CPP/utility/forward.h",
611    ],
612    deps = [
613        ":__support_macros_attributes",
614        ":__support_macros_config",
615        ":__support_macros_properties_complex_types",
616        ":__support_macros_properties_types",
617        ":llvm_libc_macros_stdfix_macros",
618    ],
619)
620
621libc_support_library(
622    name = "__support_cpp_utility",
623    hdrs = glob(["src/__support/CPP/utility/*.h"]) + [
624        "src/__support/CPP/utility.h",
625    ],
626    deps = [
627        ":__support_cpp_type_traits",
628        ":__support_macros_attributes",
629    ],
630)
631
632libc_support_library(
633    name = "__support_cpp_atomic",
634    hdrs = ["src/__support/CPP/atomic.h"],
635    deps = [
636        ":__support_cpp_type_traits",
637        ":__support_macros_attributes",
638        ":__support_macros_properties_architectures",
639    ],
640)
641
642libc_support_library(
643    name = "__support_blockstore",
644    hdrs = ["src/__support/blockstore.h"],
645    deps = [
646        ":__support_cpp_new",
647        ":__support_libc_assert",
648    ],
649)
650
651libc_support_library(
652    name = "__support_arg_list",
653    hdrs = ["src/__support/arg_list.h"],
654    deps = [
655        ":__support_common",
656    ],
657)
658
659libc_support_library(
660    name = "__support_c_string",
661    hdrs = ["src/__support/c_string.h"],
662    deps = [
663        ":__support_cpp_string",
664    ],
665)
666
667libc_support_library(
668    name = "__support_fixedvector",
669    hdrs = ["src/__support/fixedvector.h"],
670    deps = [
671        ":__support_cpp_array",
672        ":__support_cpp_iterator",
673        ":__support_libc_assert",
674        ":string_memory_utils",
675    ],
676)
677
678libc_support_library(
679    name = "__support_char_vector",
680    hdrs = ["src/__support/char_vector.h"],
681    deps = [
682        ":__support_common",
683        ":func_free",
684        ":func_malloc",
685        ":func_realloc",
686    ],
687)
688
689libc_support_library(
690    name = "__support_error_or",
691    hdrs = ["src/__support/error_or.h"],
692    deps = [
693        ":__support_common",
694        ":__support_cpp_expected",
695    ],
696)
697
698libc_support_library(
699    name = "__support_float_to_string",
700    hdrs = [
701        "src/__support/float_to_string.h",
702        "src/__support/ryu_constants.h",
703        "src/__support/ryu_long_double_constants.h",
704    ],
705    deps = [
706        ":__support_big_int",
707        ":__support_common",
708        ":__support_cpp_type_traits",
709        ":__support_fputil_dyadic_float",
710        ":__support_fputil_fp_bits",
711        ":__support_libc_assert",
712    ],
713)
714
715libc_support_library(
716    name = "__support_number_pair",
717    hdrs = ["src/__support/number_pair.h"],
718    deps = [
719        ":__support_cpp_type_traits",
720    ],
721)
722
723libc_support_library(
724    name = "__support_big_int",
725    hdrs = ["src/__support/big_int.h"],
726    deps = [
727        ":__support_cpp_array",
728        ":__support_cpp_bit",
729        ":__support_cpp_limits",
730        ":__support_cpp_optional",
731        ":__support_cpp_type_traits",
732        ":__support_macros_attributes",
733        ":__support_macros_optimization",
734        ":__support_macros_properties_types",
735        ":__support_math_extras",
736        ":__support_number_pair",
737    ],
738)
739
740libc_support_library(
741    name = "__support_sign",
742    hdrs = ["src/__support/sign.h"],
743    deps = [
744        ":__support_macros_attributes",
745    ],
746)
747
748libc_support_library(
749    name = "__support_uint128",
750    hdrs = ["src/__support/uint128.h"],
751    deps = [
752        ":__support_big_int",
753        ":__support_macros_attributes",
754        ":__support_macros_properties_types",
755    ],
756)
757
758libc_support_library(
759    name = "__support_integer_literals",
760    hdrs = ["src/__support/integer_literals.h"],
761    deps = [
762        ":__support_cpp_limits",
763        ":__support_ctype_utils",
764        ":__support_uint128",
765    ],
766)
767
768libc_support_library(
769    name = "__support_str_to_num_result",
770    hdrs = ["src/__support/str_to_num_result.h"],
771    deps = [
772        ":__support_macros_attributes",
773        ":__support_macros_config",
774    ],
775)
776
777libc_support_library(
778    name = "__support_integer_operations",
779    hdrs = ["src/__support/integer_operations.h"],
780    deps = [":__support_cpp_type_traits"],
781)
782
783libc_support_library(
784    name = "__support_integer_to_string",
785    hdrs = ["src/__support/integer_to_string.h"],
786    deps = [
787        ":__support_big_int",
788        ":__support_common",
789        ":__support_cpp_algorithm",
790        ":__support_cpp_bit",
791        ":__support_cpp_limits",
792        ":__support_cpp_optional",
793        ":__support_cpp_span",
794        ":__support_cpp_string_view",
795        ":__support_cpp_type_traits",
796        ":__support_ctype_utils",
797    ],
798)
799
800libc_support_library(
801    name = "__support_libc_assert",
802    hdrs = ["src/__support/libc_assert.h"],
803    deps = [
804        ":__support_integer_to_string",
805        ":__support_macros_attributes",
806        ":__support_osutil_exit",
807        ":__support_osutil_io",
808    ],
809)
810
811libc_support_library(
812    name = "__support_ctype_utils",
813    hdrs = ["src/__support/ctype_utils.h"],
814    deps = [
815        ":__support_macros_attributes",
816        ":__support_macros_config",
817    ],
818)
819
820libc_support_library(
821    name = "__support_str_to_integer",
822    hdrs = ["src/__support/str_to_integer.h"],
823    deps = [
824        ":__support_common",
825        ":__support_cpp_limits",
826        ":__support_cpp_type_traits",
827        ":__support_ctype_utils",
828        ":__support_str_to_num_result",
829        ":__support_uint128",
830        ":errno",
831    ],
832)
833
834libc_support_library(
835    name = "__support_str_to_float",
836    hdrs = [
837        "src/__support/detailed_powers_of_ten.h",
838        "src/__support/high_precision_decimal.h",
839        "src/__support/str_to_float.h",
840    ],
841    deps = [
842        ":__support_common",
843        ":__support_cpp_bit",
844        ":__support_cpp_limits",
845        ":__support_cpp_optional",
846        ":__support_cpp_string_view",
847        ":__support_ctype_utils",
848        ":__support_fputil_fp_bits",
849        ":__support_fputil_rounding_mode",
850        ":__support_macros_null_check",
851        ":__support_str_to_integer",
852        ":__support_str_to_num_result",
853        ":__support_uint128",
854        ":errno",
855    ],
856)
857
858libc_support_library(
859    name = "__support_fputil_basic_operations",
860    hdrs = [
861        "src/__support/FPUtil/BasicOperations.h",
862        "src/__support/FPUtil/generic/add_sub.h",
863        "src/__support/FPUtil/generic/div.h",
864        "src/__support/FPUtil/generic/mul.h",
865    ],
866    deps = [
867        ":__support_common",
868        ":__support_cpp_type_traits",
869        ":__support_fputil_cast",
870        ":__support_fputil_dyadic_float",
871        ":__support_fputil_fenv_impl",
872        ":__support_fputil_fp_bits",
873        ":__support_fputil_rounding_mode",
874        ":__support_macros_optimization",
875        ":__support_uint128",
876    ],
877)
878
879libc_support_library(
880    name = "__support_file_file",
881    srcs = [
882        "include/llvm-libc-types/off_t.h",
883        "src/__support/File/file.cpp",
884    ],
885    hdrs = ["src/__support/File/file.h"],
886    deps = [
887        ":__support_cpp_new",
888        ":__support_cpp_span",
889        ":__support_error_or",
890        ":__support_threads_mutex",
891        ":errno",
892        ":func_aligned_alloc",
893        ":func_free",
894        ":func_malloc",
895        ":func_realloc",
896        ":hdr_stdio_macros",
897        ":hdr_stdio_overlay",
898        ":types_off_t",
899    ],
900)
901
902libc_support_library(
903    name = "__support_file_linux_lseekimpl",
904    hdrs = ["src/__support/File/linux/lseekImpl.h"],
905    deps = [
906        ":__support_common",
907        ":__support_error_or",
908        ":__support_osutil_syscall",
909        ":errno",
910        ":hdr_stdio_overlay",
911        ":types_off_t",
912    ],
913)
914
915libc_support_library(
916    name = "__support_math_extras",
917    hdrs = ["src/__support/math_extras.h"],
918    deps = [
919        ":__support_cpp_bit",
920        ":__support_cpp_limits",
921        ":__support_cpp_type_traits",
922        ":__support_macros_attributes",
923    ],
924)
925
926libc_support_library(
927    name = "__support_fixed_point",
928    hdrs = [
929        "src/__support/fixed_point/fx_bits.h",
930        "src/__support/fixed_point/fx_rep.h",
931    ],
932    deps = [
933        ":__support_cpp_bit",
934        ":__support_cpp_type_traits",
935        ":__support_macros_attributes",
936        ":__support_macros_optimization",
937        ":__support_math_extras",
938        ":llvm_libc_macros_stdfix_macros",
939    ],
940)
941
942libc_support_library(
943    name = "__support_fputil_generic_fmod",
944    hdrs = ["src/__support/FPUtil/generic/FMod.h"],
945    deps = [
946        ":__support_common",
947        ":__support_cpp_bit",
948        ":__support_cpp_limits",
949        ":__support_cpp_type_traits",
950        ":__support_fputil_fenv_impl",
951        ":__support_fputil_fp_bits",
952    ],
953)
954
955libc_support_library(
956    name = "__support_fputil_cast",
957    hdrs = ["src/__support/FPUtil/cast.h"],
958    deps = [
959        ":__support_cpp_algorithm",
960        ":__support_cpp_type_traits",
961        ":__support_fputil_dyadic_float",
962        ":__support_fputil_fp_bits",
963        ":__support_macros_properties_types",
964        ":hdr_fenv_macros",
965    ],
966)
967
968libc_support_library(
969    name = "__support_fputil_division_and_remainder_operations",
970    hdrs = ["src/__support/FPUtil/DivisionAndRemainderOperations.h"],
971    deps = [
972        ":__support_common",
973        ":__support_cpp_type_traits",
974        ":__support_fputil_fp_bits",
975        ":__support_fputil_manipulation_functions",
976        ":__support_fputil_normal_float",
977    ],
978)
979
980libc_support_library(
981    name = "__support_fputil_except_value_utils",
982    hdrs = ["src/__support/FPUtil/except_value_utils.h"],
983    deps = [
984        ":__support_cpp_optional",
985        ":__support_fputil_cast",
986        ":__support_fputil_fenv_impl",
987        ":__support_fputil_fp_bits",
988        ":__support_fputil_rounding_mode",
989        ":__support_macros_properties_cpu_features",
990        ":__support_macros_properties_types",
991    ],
992)
993
994libc_support_library(
995    name = "__support_fputil_fenv_impl",
996    hdrs = ["src/__support/FPUtil/FEnvImpl.h"],
997    textual_hdrs = [
998        "src/__support/FPUtil/x86_64/FEnvImpl.h",
999        "src/__support/FPUtil/aarch64/FEnvImpl.h",
1000        "src/__support/FPUtil/aarch64/fenv_darwin_impl.h",
1001    ],
1002    deps = [
1003        ":__support_fputil_fp_bits",
1004        ":__support_macros_attributes",
1005        ":__support_macros_properties_architectures",
1006        ":__support_macros_sanitizer",
1007        ":errno",
1008        ":hdr_fenv_macros",
1009        ":hdr_math_macros",
1010        ":types_fenv_t",
1011    ],
1012)
1013
1014libc_support_library(
1015    name = "__support_fputil_rounding_mode",
1016    hdrs = ["src/__support/FPUtil/rounding_mode.h"],
1017    deps = [
1018        ":__support_macros_attributes",
1019        ":__support_macros_config",
1020        ":hdr_fenv_macros",
1021    ],
1022)
1023
1024libc_support_library(
1025    name = "__support_fputil_fp_bits",
1026    hdrs = ["src/__support/FPUtil/FPBits.h"],
1027    deps = [
1028        ":__support_common",
1029        ":__support_cpp_bit",
1030        ":__support_cpp_type_traits",
1031        ":__support_libc_assert",
1032        ":__support_macros_attributes",
1033        ":__support_macros_properties_types",
1034        ":__support_math_extras",
1035        ":__support_sign",
1036        ":__support_uint128",
1037    ],
1038)
1039
1040libc_support_library(
1041    name = "__support_fputil_fpbits_str",
1042    hdrs = ["src/__support/FPUtil/fpbits_str.h"],
1043    deps = [
1044        ":__support_common",
1045        ":__support_cpp_string",
1046        ":__support_cpp_type_traits",
1047        ":__support_fputil_fp_bits",
1048        ":__support_integer_to_string",
1049        ":__support_uint128",
1050    ],
1051)
1052
1053libc_support_library(
1054    name = "__support_fputil_hypot",
1055    hdrs = ["src/__support/FPUtil/Hypot.h"],
1056    deps = [
1057        ":__support_common",
1058        ":__support_cpp_bit",
1059        ":__support_cpp_type_traits",
1060        ":__support_fputil_basic_operations",
1061        ":__support_fputil_fenv_impl",
1062        ":__support_fputil_fp_bits",
1063        ":__support_fputil_rounding_mode",
1064        ":__support_uint128",
1065    ],
1066)
1067
1068libc_support_library(
1069    name = "__support_fputil_manipulation_functions",
1070    hdrs = ["src/__support/FPUtil/ManipulationFunctions.h"],
1071    textual_hdrs = [
1072        "src/__support/FPUtil/x86_64/NextAfterLongDouble.h",
1073        "src/__support/FPUtil/x86_64/NextUpDownLongDouble.h",
1074    ],
1075    deps = [
1076        ":__support_common",
1077        ":__support_cpp_bit",
1078        ":__support_cpp_limits",
1079        ":__support_cpp_type_traits",
1080        ":__support_fputil_cast",
1081        ":__support_fputil_dyadic_float",
1082        ":__support_fputil_fp_bits",
1083        ":__support_fputil_nearest_integer_operations",
1084        ":__support_fputil_normal_float",
1085        ":__support_macros_optimization",
1086        ":__support_uint128",
1087        ":hdr_math_macros",
1088    ],
1089)
1090
1091libc_support_library(
1092    name = "__support_fputil_nearest_integer_operations",
1093    hdrs = ["src/__support/FPUtil/NearestIntegerOperations.h"],
1094    deps = [
1095        ":__support_common",
1096        ":__support_cpp_type_traits",
1097        ":__support_fputil_fenv_impl",
1098        ":__support_fputil_fp_bits",
1099        ":__support_fputil_rounding_mode",
1100        ":__support_macros_attributes",
1101        ":hdr_math_macros",
1102    ],
1103)
1104
1105libc_support_library(
1106    name = "__support_fputil_normal_float",
1107    hdrs = ["src/__support/FPUtil/NormalFloat.h"],
1108    deps = [
1109        ":__support_common",
1110        ":__support_cpp_type_traits",
1111        ":__support_fputil_fp_bits",
1112    ],
1113)
1114
1115sqrt_common_hdrs = [
1116    "src/__support/FPUtil/sqrt.h",
1117    "src/__support/FPUtil/generic/sqrt.h",
1118    "src/__support/FPUtil/generic/sqrt_80_bit_long_double.h",
1119]
1120
1121sqrt_hdrs = selects.with_or({
1122    "//conditions:default": sqrt_common_hdrs,
1123    PLATFORM_CPU_X86_64: sqrt_common_hdrs + [
1124        "src/__support/FPUtil/x86_64/sqrt.h",
1125    ],
1126    PLATFORM_CPU_ARM64: sqrt_common_hdrs + [
1127        "src/__support/FPUtil/aarch64/sqrt.h",
1128    ],
1129})
1130
1131libc_support_library(
1132    name = "__support_fputil_sqrt",
1133    hdrs = sqrt_hdrs,
1134    deps = [
1135        ":__support_common",
1136        ":__support_cpp_bit",
1137        ":__support_cpp_type_traits",
1138        ":__support_fputil_cast",
1139        ":__support_fputil_dyadic_float",
1140        ":__support_fputil_fenv_impl",
1141        ":__support_fputil_fp_bits",
1142        ":__support_fputil_rounding_mode",
1143        ":__support_uint128",
1144    ],
1145)
1146
1147fma_common_hdrs = [
1148    "src/__support/FPUtil/FMA.h",
1149    "src/__support/FPUtil/generic/FMA.h",
1150]
1151
1152libc_support_library(
1153    name = "__support_fputil_fma",
1154    hdrs = fma_common_hdrs,
1155    deps = [
1156        ":__support_cpp_bit",
1157        ":__support_cpp_type_traits",
1158        ":__support_fputil_basic_operations",
1159        ":__support_fputil_dyadic_float",
1160        ":__support_fputil_fenv_impl",
1161        ":__support_fputil_fp_bits",
1162        ":__support_fputil_rounding_mode",
1163        ":__support_macros_attributes",
1164        ":__support_macros_optimization",
1165        ":__support_macros_properties_cpu_features",
1166        ":__support_uint128",
1167    ],
1168)
1169
1170libc_support_library(
1171    name = "__support_fputil_multiply_add",
1172    hdrs = [
1173        "src/__support/FPUtil/multiply_add.h",
1174    ],
1175    deps = [
1176        ":__support_common",
1177        ":__support_cpp_type_traits",
1178    ],
1179)
1180
1181libc_support_library(
1182    name = "__support_fputil_polyeval",
1183    hdrs = [
1184        "src/__support/FPUtil/PolyEval.h",
1185    ],
1186    deps = [
1187        ":__support_common",
1188        ":__support_fputil_multiply_add",
1189    ],
1190)
1191
1192nearest_integer_common_hdrs = [
1193    "src/__support/FPUtil/nearest_integer.h",
1194]
1195
1196nearest_integer_platform_hdrs = [
1197    "src/__support/FPUtil/x86_64/nearest_integer.h",
1198    "src/__support/FPUtil/aarch64/nearest_integer.h",
1199]
1200
1201libc_support_library(
1202    name = "__support_fputil_nearest_integer",
1203    hdrs = nearest_integer_common_hdrs,
1204    # These are conditionally included and will #error out if the platform
1205    # doesn't support rounding instructions, so they can't be compiled on their
1206    # own.
1207    textual_hdrs = nearest_integer_platform_hdrs,
1208    deps = [
1209        ":__support_common",
1210        ":__support_macros_optimization",
1211        ":__support_macros_properties_architectures",
1212        ":__support_macros_properties_cpu_features",
1213    ],
1214)
1215
1216libc_support_library(
1217    name = "__support_fputil_double_double",
1218    hdrs = ["src/__support/FPUtil/double_double.h"],
1219    deps = [
1220        ":__support_common",
1221        ":__support_fputil_multiply_add",
1222        ":__support_number_pair",
1223    ],
1224)
1225
1226libc_support_library(
1227    name = "__support_fputil_triple_double",
1228    hdrs = ["src/__support/FPUtil/triple_double.h"],
1229    deps = [
1230        ":__support_common",
1231    ],
1232)
1233
1234libc_support_library(
1235    name = "__support_fputil_dyadic_float",
1236    hdrs = ["src/__support/FPUtil/dyadic_float.h"],
1237    deps = [
1238        ":__support_big_int",
1239        ":__support_common",
1240        ":__support_cpp_type_traits",
1241        ":__support_fputil_fenv_impl",
1242        ":__support_fputil_fp_bits",
1243        ":__support_fputil_multiply_add",
1244        ":__support_fputil_rounding_mode",
1245        ":__support_macros_optimization",
1246    ],
1247)
1248
1249libc_support_library(
1250    name = "__support_osutil_syscall",
1251    hdrs = ["src/__support/OSUtil/syscall.h"],
1252    textual_hdrs = select({
1253        "@platforms//os:macos": [
1254            "src/__support/OSUtil/darwin/syscall.h",
1255            "src/__support/OSUtil/darwin/arm/syscall.h",
1256        ],
1257        "@platforms//os:linux": [
1258            "src/__support/OSUtil/linux/syscall.h",
1259            "src/__support/OSUtil/linux/aarch64/syscall.h",
1260            "src/__support/OSUtil/linux/x86_64/syscall.h",
1261        ],
1262    }),
1263    deps = [
1264        ":__support_common",
1265        ":__support_cpp_bit",
1266        ":__support_macros_sanitizer",
1267    ],
1268)
1269
1270libc_support_library(
1271    name = "__support_osutil_vdso",
1272    hdrs = [
1273        "src/__support/OSUtil/linux/vdso.h",
1274        "src/__support/OSUtil/linux/vdso_sym.h",
1275    ],
1276    target_compatible_with = select({
1277        "@platforms//os:linux": [],
1278        "//conditions:default": ["@platforms//:incompatible"],
1279    }),
1280    textual_hdrs = [
1281        "src/__support/OSUtil/linux/riscv/vdso.h",
1282        "src/__support/OSUtil/linux/arm/vdso.h",
1283        "src/__support/OSUtil/linux/x86_64/vdso.h",
1284        "src/__support/OSUtil/linux/aarch64/vdso.h",
1285    ],
1286    deps = [
1287        ":__support_cpp_array",
1288        ":__support_cpp_optional",
1289        ":__support_cpp_string_view",
1290        ":__support_threads_callonce",
1291        ":types_clock_t",
1292        ":types_clockid_t",
1293        ":types_struct_timeval",
1294    ],
1295)
1296
1297libc_support_library(
1298    name = "__support_osutil_io",
1299    hdrs = ["src/__support/OSUtil/io.h"],
1300    textual_hdrs = select({
1301        "@platforms//os:macos": ["src/__support/OSUtil/darwin/io.h"],
1302        "@platforms//os:linux": ["src/__support/OSUtil/linux/io.h"],
1303    }),
1304    deps = [
1305        ":__support_common",
1306        ":__support_cpp_string_view",
1307        ":__support_osutil_syscall",
1308        ":string_utils",
1309    ],
1310)
1311
1312libc_support_library(
1313    name = "__support_osutil_exit",
1314    srcs = ["src/__support/OSUtil/linux/exit.cpp"],
1315    hdrs = ["src/__support/OSUtil/exit.h"],
1316    target_compatible_with = select({
1317        "@platforms//os:linux": [],
1318        "//conditions:default": ["@platforms//:incompatible"],
1319    }),
1320    deps = [
1321        ":__support_osutil_syscall",
1322    ],
1323)
1324
1325libc_support_library(
1326    name = "__support_stringutil",
1327    srcs = glob(["src/__support/StringUtil/tables/**/*.h"]) + [
1328        "src/__support/StringUtil/error_to_string.cpp",
1329        "src/__support/StringUtil/message_mapper.h",
1330        "src/__support/StringUtil/platform_errors.h",
1331        "src/__support/StringUtil/platform_signals.h",
1332        "src/__support/StringUtil/signal_to_string.cpp",
1333    ],
1334    hdrs = [
1335        "src/__support/StringUtil/error_to_string.h",
1336        "src/__support/StringUtil/signal_to_string.h",
1337    ],
1338    target_compatible_with = select({
1339        "@platforms//os:linux": [],
1340        "//conditions:default": ["@platforms//:incompatible"],
1341    }),
1342    deps = [
1343        ":__support_cpp_array",
1344        ":__support_cpp_span",
1345        ":__support_cpp_string_view",
1346        ":__support_cpp_stringstream",
1347        ":__support_integer_to_string",
1348        ":__support_macros_attributes",
1349        ":errno",
1350    ],
1351)
1352
1353libc_support_library(
1354    name = "__support_threads_linux_futex_word_type",
1355    hdrs = [
1356        "src/__support/threads/linux/futex_word.h",
1357    ],
1358    target_compatible_with = select({
1359        "@platforms//os:linux": [],
1360        "//conditions:default": ["@platforms//:incompatible"],
1361    }),
1362    deps = [
1363        ":__support_osutil_syscall",
1364    ],
1365)
1366
1367libc_support_library(
1368    name = "__support_threads_linux_futex_utils",
1369    hdrs = [
1370        "src/__support/threads/linux/futex_utils.h",
1371    ],
1372    target_compatible_with = select({
1373        "@platforms//os:linux": [],
1374        "//conditions:default": ["@platforms//:incompatible"],
1375    }),
1376    deps = [
1377        ":__support_cpp_atomic",
1378        ":__support_cpp_optional",
1379        ":__support_osutil_syscall",
1380        ":__support_threads_linux_futex_word_type",
1381        ":__support_time_linux_abs_timeout",
1382        ":types_struct_timespec",
1383    ],
1384)
1385
1386libc_support_library(
1387    name = "__support_threads_sleep",
1388    hdrs = ["src/__support/threads/sleep.h"],
1389    deps = [
1390        ":__support_macros_attributes",
1391        ":__support_macros_config",
1392    ],
1393)
1394
1395libc_support_library(
1396    name = "__support_threads_raw_mutex",
1397    hdrs = [
1398        "src/__support/threads/linux/raw_mutex.h",
1399    ],
1400    target_compatible_with = select({
1401        "@platforms//os:linux": [],
1402        "//conditions:default": ["@platforms//:incompatible"],
1403    }),
1404    deps = [
1405        ":__support_cpp_expected",
1406        ":__support_cpp_optional",
1407        ":__support_threads_linux_futex_utils",
1408        ":__support_threads_sleep",
1409        ":__support_time_linux_abs_timeout",
1410        ":__support_time_linux_monotonicity",
1411        ":types_pid_t",
1412    ],
1413)
1414
1415libc_support_library(
1416    name = "__support_threads_mutex",
1417    hdrs = [
1418        "src/__support/threads/mutex.h",
1419        "src/__support/threads/mutex_common.h",
1420    ],
1421    target_compatible_with = select({
1422        "@platforms//os:linux": [],
1423        "//conditions:default": ["@platforms//:incompatible"],
1424    }),
1425    textual_hdrs = [
1426        "src/__support/threads/linux/mutex.h",
1427    ],
1428    deps = [
1429        ":__support_cpp_atomic",
1430        ":__support_osutil_syscall",
1431        ":__support_threads_linux_futex_utils",
1432        ":__support_threads_raw_mutex",
1433        ":types_pid_t",
1434    ],
1435)
1436
1437libc_support_library(
1438    name = "__support_threads_callonce",
1439    hdrs = [
1440        "src/__support/threads/callonce.h",
1441    ],
1442    target_compatible_with = select({
1443        "@platforms//os:linux": [],
1444        "//conditions:default": ["@platforms//:incompatible"],
1445    }),
1446    textual_hdrs = [
1447        "src/__support/threads/linux/callonce.h",
1448    ],
1449    deps = [
1450        ":__support_macros_config",
1451        ":__support_macros_optimization",
1452        ":__support_threads_linux_futex_utils",
1453    ],
1454)
1455
1456libc_support_library(
1457    name = "__support_time",
1458    hdrs = glob(["src/__support/time/*.h"]),
1459    deps = [
1460        ":__support_common",
1461        ":__support_error_or",
1462        ":hdr_time_macros",
1463        ":types_clockid_t",
1464        ":types_struct_timespec",
1465        ":types_time_t",
1466    ],
1467)
1468
1469libc_support_library(
1470    name = "__support_time_linux_abs_timeout",
1471    hdrs = ["src/__support/time/linux/abs_timeout.h"],
1472    target_compatible_with = select({
1473        "@platforms//os:linux": [],
1474        "//conditions:default": ["@platforms//:incompatible"],
1475    }),
1476    deps = [
1477        ":__support_cpp_expected",
1478        ":__support_time",
1479        ":hdr_time_macros",
1480        ":types_struct_timespec",
1481    ],
1482)
1483
1484libc_support_library(
1485    name = "__support_time_linux_clock_conversion",
1486    hdrs = ["src/__support/time/linux/clock_conversion.h"],
1487    target_compatible_with = select({
1488        "@platforms//os:linux": [],
1489        "//conditions:default": ["@platforms//:incompatible"],
1490    }),
1491    deps = [
1492        ":__support_time",
1493        ":__support_time_clock_gettime",
1494    ],
1495)
1496
1497libc_support_library(
1498    name = "__support_time_clock_gettime",
1499    hdrs = ["src/__support/time/clock_gettime.h"],
1500    target_compatible_with = select({
1501        "@platforms//os:linux": [],
1502        "//conditions:default": ["@platforms//:incompatible"],
1503    }),
1504    deps = [
1505        ":__support_common",
1506        ":__support_error_or",
1507        ":__support_osutil_vdso",
1508        ":types_clockid_t",
1509        ":types_struct_timespec",
1510    ],
1511)
1512
1513libc_support_library(
1514    name = "__support_time_linux_monotonicity",
1515    hdrs = ["src/__support/time/linux/monotonicity.h"],
1516    target_compatible_with = select({
1517        "@platforms//os:linux": [],
1518        "//conditions:default": ["@platforms//:incompatible"],
1519    }),
1520    deps = [
1521        ":__support_libc_assert",
1522        ":__support_time_linux_abs_timeout",
1523        ":__support_time_linux_clock_conversion",
1524        ":hdr_time_macros",
1525    ],
1526)
1527
1528########################## externally shared targets ###########################
1529
1530libc_support_library(
1531    name = "libc_external_common",
1532    hdrs = glob(["shared/*.h"]),
1533    deps = [
1534        ":__support_common",
1535        ":__support_fputil_fp_bits",
1536        ":__support_str_to_float",
1537        ":__support_str_to_integer",
1538    ],
1539)
1540
1541############################### errno targets ################################
1542
1543libc_function(
1544    name = "errno",
1545    srcs = ["src/errno/libc_errno.cpp"],
1546    hdrs = ["src/errno/libc_errno.h"],
1547    deps = [
1548        ":__support_common",
1549        ":__support_cpp_atomic",
1550        ":__support_macros_attributes",
1551        ":__support_macros_properties_architectures",
1552        ":hdr_errno_macros",
1553    ],
1554)
1555
1556################################ fenv targets ################################
1557
1558libc_function(
1559    name = "fetestexcept",
1560    srcs = ["src/fenv/fetestexcept.cpp"],
1561    hdrs = ["src/fenv/fetestexcept.h"],
1562    deps = [
1563        ":__support_common",
1564        ":__support_fputil_fenv_impl",
1565    ],
1566)
1567
1568libc_function(
1569    name = "fetestexceptflag",
1570    srcs = ["src/fenv/fetestexceptflag.cpp"],
1571    hdrs = ["src/fenv/fetestexceptflag.h"],
1572    deps = [
1573        ":__support_common",
1574        ":__support_fputil_fenv_impl",
1575        ":types_fexcept_t",
1576    ],
1577)
1578
1579libc_function(
1580    name = "feclearexcept",
1581    srcs = ["src/fenv/feclearexcept.cpp"],
1582    hdrs = ["src/fenv/feclearexcept.h"],
1583    deps = [
1584        ":__support_common",
1585        ":__support_fputil_fenv_impl",
1586    ],
1587)
1588
1589libc_function(
1590    name = "feraiseexcept",
1591    srcs = ["src/fenv/feraiseexcept.cpp"],
1592    hdrs = ["src/fenv/feraiseexcept.h"],
1593    deps = [
1594        ":__support_common",
1595        ":__support_fputil_fenv_impl",
1596    ],
1597)
1598
1599libc_function(
1600    name = "fegetround",
1601    srcs = ["src/fenv/fegetround.cpp"],
1602    hdrs = ["src/fenv/fegetround.h"],
1603    deps = [
1604        ":__support_common",
1605        ":__support_fputil_fenv_impl",
1606    ],
1607)
1608
1609libc_function(
1610    name = "fesetround",
1611    srcs = ["src/fenv/fesetround.cpp"],
1612    hdrs = ["src/fenv/fesetround.h"],
1613    deps = [
1614        ":__support_common",
1615        ":__support_fputil_fenv_impl",
1616    ],
1617)
1618
1619libc_function(
1620    name = "fedisableexcept",
1621    srcs = ["src/fenv/fedisableexcept.cpp"],
1622    hdrs = ["src/fenv/fedisableexcept.h"],
1623    deps = [
1624        ":__support_common",
1625        ":__support_fputil_fenv_impl",
1626    ],
1627)
1628
1629libc_function(
1630    name = "feenableexcept",
1631    srcs = ["src/fenv/feenableexcept.cpp"],
1632    hdrs = ["src/fenv/feenableexcept.h"],
1633    deps = [
1634        ":__support_common",
1635        ":__support_fputil_fenv_impl",
1636    ],
1637)
1638
1639libc_function(
1640    name = "fegetexcept",
1641    srcs = ["src/fenv/fegetexcept.cpp"],
1642    hdrs = ["src/fenv/fegetexcept.h"],
1643    deps = [
1644        ":__support_common",
1645        ":__support_fputil_fenv_impl",
1646    ],
1647)
1648
1649libc_function(
1650    name = "fegetenv",
1651    srcs = ["src/fenv/fegetenv.cpp"],
1652    hdrs = ["src/fenv/fegetenv.h"],
1653    deps = [
1654        ":__support_common",
1655        ":__support_fputil_fenv_impl",
1656    ],
1657)
1658
1659libc_function(
1660    name = "fesetenv",
1661    srcs = ["src/fenv/fesetenv.cpp"],
1662    hdrs = ["src/fenv/fesetenv.h"],
1663    deps = [
1664        ":__support_common",
1665        ":__support_fputil_fenv_impl",
1666    ],
1667)
1668
1669libc_function(
1670    name = "feupdateenv",
1671    srcs = ["src/fenv/feupdateenv.cpp"],
1672    hdrs = ["src/fenv/feupdateenv.h"],
1673    deps = [
1674        ":__support_common",
1675        ":__support_fputil_fenv_impl",
1676    ],
1677)
1678
1679libc_function(
1680    name = "fesetexcept",
1681    srcs = ["src/fenv/fesetexcept.cpp"],
1682    hdrs = ["src/fenv/fesetexcept.h"],
1683    deps = [
1684        ":__support_common",
1685        ":__support_fputil_fenv_impl",
1686    ],
1687)
1688
1689libc_function(
1690    name = "fegetexceptflag",
1691    srcs = ["src/fenv/fegetexceptflag.cpp"],
1692    hdrs = ["src/fenv/fegetexceptflag.h"],
1693    deps = [
1694        ":__support_common",
1695        ":__support_fputil_fenv_impl",
1696        ":types_fexcept_t",
1697    ],
1698)
1699
1700libc_function(
1701    name = "fesetexceptflag",
1702    srcs = ["src/fenv/fesetexceptflag.cpp"],
1703    hdrs = ["src/fenv/fesetexceptflag.h"],
1704    deps = [
1705        ":__support_common",
1706        ":__support_fputil_fenv_impl",
1707        ":types_fexcept_t",
1708    ],
1709)
1710
1711libc_function(
1712    name = "feholdexcept",
1713    srcs = ["src/fenv/feholdexcept.cpp"],
1714    hdrs = ["src/fenv/feholdexcept.h"],
1715    deps = [
1716        ":__support_common",
1717        ":__support_fputil_fenv_impl",
1718    ],
1719)
1720
1721########################### math support library ###############################
1722
1723libc_support_library(
1724    name = "common_constants",
1725    srcs = ["src/math/generic/common_constants.cpp"],
1726    hdrs = ["src/math/generic/common_constants.h"],
1727    deps = [
1728        ":__support_fputil_triple_double",
1729        ":__support_number_pair",
1730    ],
1731)
1732
1733libc_support_library(
1734    name = "range_reduction",
1735    hdrs = [
1736        "src/math/generic/range_reduction.h",
1737        "src/math/generic/range_reduction_fma.h",
1738    ],
1739    deps = [
1740        ":__support_common",
1741        ":__support_fputil_fma",
1742        ":__support_fputil_fp_bits",
1743        ":__support_fputil_multiply_add",
1744        ":__support_fputil_nearest_integer",
1745    ],
1746)
1747
1748libc_support_library(
1749    name = "range_reduction_double",
1750    hdrs = [
1751        "src/math/generic/range_reduction_double_common.h",
1752        "src/math/generic/range_reduction_double_fma.h",
1753        "src/math/generic/range_reduction_double_nofma.h",
1754    ],
1755    deps = [
1756        ":__support_common",
1757        ":__support_fputil_double_double",
1758        ":__support_fputil_dyadic_float",
1759        ":__support_fputil_fp_bits",
1760        ":__support_fputil_multiply_add",
1761        ":__support_fputil_nearest_integer",
1762        ":__support_fputil_rounding_mode",
1763        ":__support_integer_literals",
1764    ],
1765)
1766
1767libc_support_library(
1768    name = "sincos_eval",
1769    hdrs = [
1770        "src/math/generic/sincos_eval.h",
1771    ],
1772    deps = [
1773        ":__support_common",
1774        ":__support_fputil_double_double",
1775        ":__support_fputil_dyadic_float",
1776        ":__support_fputil_fp_bits",
1777        ":__support_fputil_multiply_add",
1778        ":__support_fputil_polyeval",
1779        ":__support_integer_literals",
1780    ],
1781)
1782
1783libc_support_library(
1784    name = "sincosf_utils",
1785    hdrs = ["src/math/generic/sincosf_utils.h"],
1786    deps = [
1787        ":__support_fputil_fp_bits",
1788        ":__support_fputil_polyeval",
1789        ":range_reduction",
1790    ],
1791)
1792
1793libc_support_library(
1794    name = "sincosf16_utils",
1795    hdrs = ["src/math/generic/sincosf16_utils.h"],
1796    deps = [
1797        ":__support_common",
1798        ":__support_fputil_nearest_integer",
1799        ":__support_fputil_polyeval",
1800    ],
1801)
1802
1803libc_support_library(
1804    name = "explogxf",
1805    srcs = ["src/math/generic/explogxf.cpp"],
1806    hdrs = ["src/math/generic/explogxf.h"],
1807    deps = [
1808        ":__support_common",
1809        ":__support_fputil_fenv_impl",
1810        ":__support_fputil_fma",
1811        ":__support_fputil_fp_bits",
1812        ":__support_fputil_multiply_add",
1813        ":__support_fputil_nearest_integer",
1814        ":__support_fputil_polyeval",
1815        ":common_constants",
1816    ],
1817)
1818
1819libc_support_library(
1820    name = "inv_trigf_utils",
1821    srcs = ["src/math/generic/inv_trigf_utils.cpp"],
1822    hdrs = ["src/math/generic/inv_trigf_utils.h"],
1823    deps = [
1824        ":__support_common",
1825        ":__support_fputil_fma",
1826        ":__support_fputil_multiply_add",
1827        ":__support_fputil_polyeval",
1828    ],
1829)
1830
1831libc_support_library(
1832    name = "log_range_reduction",
1833    hdrs = ["src/math/generic/log_range_reduction.h"],
1834    deps = [
1835        ":__support_common",
1836        ":__support_fputil_dyadic_float",
1837        ":__support_uint128",
1838        ":common_constants",
1839    ],
1840)
1841
1842libc_support_library(
1843    name = "exp10f_impl",
1844    hdrs = ["src/math/generic/exp10f_impl.h"],
1845    deps = [
1846        ":__support_fputil_fma",
1847        ":__support_fputil_multiply_add",
1848        ":__support_fputil_rounding_mode",
1849        ":__support_macros_optimization",
1850        ":common_constants",
1851        ":explogxf",
1852    ],
1853)
1854
1855libc_support_library(
1856    name = "exp2f_impl",
1857    hdrs = ["src/math/generic/exp2f_impl.h"],
1858    deps = [
1859        ":__support_fputil_except_value_utils",
1860        ":__support_fputil_fma",
1861        ":__support_fputil_multiply_add",
1862        ":__support_fputil_nearest_integer",
1863        ":__support_fputil_polyeval",
1864        ":__support_fputil_rounding_mode",
1865        ":__support_macros_optimization",
1866        ":common_constants",
1867        ":explogxf",
1868    ],
1869)
1870
1871libc_support_library(
1872    name = "expxf16",
1873    hdrs = ["src/math/generic/expxf16.h"],
1874    deps = [
1875        ":__support_cpp_array",
1876        ":__support_fputil_cast",
1877        ":__support_fputil_fp_bits",
1878        ":__support_fputil_nearest_integer",
1879        ":__support_fputil_polyeval",
1880    ],
1881)
1882
1883################################ math targets ##################################
1884
1885libc_math_function(
1886    name = "acosf",
1887    additional_deps = [
1888        ":__support_fputil_fma",
1889        ":__support_fputil_multiply_add",
1890        ":__support_fputil_nearest_integer",
1891        ":__support_fputil_polyeval",
1892        ":__support_fputil_sqrt",
1893        ":__support_macros_optimization",
1894        ":inv_trigf_utils",
1895    ],
1896)
1897
1898libc_math_function(
1899    name = "acoshf",
1900    additional_deps = [
1901        ":__support_fputil_fma",
1902        ":__support_fputil_multiply_add",
1903        ":__support_fputil_nearest_integer",
1904        ":__support_fputil_polyeval",
1905        ":__support_fputil_sqrt",
1906        ":__support_macros_optimization",
1907        ":common_constants",
1908        ":explogxf",
1909    ],
1910)
1911
1912libc_math_function(
1913    name = "asinf",
1914    additional_deps = [
1915        ":__support_fputil_fma",
1916        ":__support_fputil_multiply_add",
1917        ":__support_fputil_nearest_integer",
1918        ":__support_fputil_polyeval",
1919        ":__support_fputil_sqrt",
1920        ":__support_macros_optimization",
1921        ":__support_macros_properties_cpu_features",
1922        ":inv_trigf_utils",
1923    ],
1924)
1925
1926libc_math_function(
1927    name = "asinhf",
1928    additional_deps = [
1929        ":__support_fputil_fma",
1930        ":__support_fputil_multiply_add",
1931        ":__support_fputil_nearest_integer",
1932        ":__support_fputil_polyeval",
1933        ":__support_fputil_sqrt",
1934        ":__support_macros_optimization",
1935        ":common_constants",
1936        ":explogxf",
1937    ],
1938)
1939
1940libc_math_function(
1941    name = "atanf",
1942    additional_deps = [
1943        ":__support_fputil_fma",
1944        ":__support_fputil_multiply_add",
1945        ":__support_fputil_nearest_integer",
1946        ":__support_fputil_polyeval",
1947        ":__support_fputil_rounding_mode",
1948        ":__support_macros_optimization",
1949        ":inv_trigf_utils",
1950    ],
1951)
1952
1953libc_math_function(
1954    name = "atan2f",
1955    additional_deps = [
1956        ":__support_fputil_double_double",
1957        ":__support_fputil_nearest_integer",
1958        ":inv_trigf_utils",
1959    ],
1960)
1961
1962libc_math_function(
1963    name = "atan2",
1964    additional_deps = [
1965        ":__support_fputil_double_double",
1966        ":__support_fputil_nearest_integer",
1967        ":inv_trigf_utils",
1968    ],
1969)
1970
1971libc_math_function(
1972    name = "atanhf",
1973    additional_deps = [
1974        ":__support_fputil_fma",
1975        ":__support_fputil_multiply_add",
1976        ":__support_fputil_nearest_integer",
1977        ":__support_fputil_polyeval",
1978        ":__support_macros_optimization",
1979        ":common_constants",
1980        ":explogxf",
1981    ],
1982)
1983
1984libc_math_function(name = "canonicalize")
1985
1986libc_math_function(name = "canonicalizef")
1987
1988libc_math_function(name = "canonicalizel")
1989
1990libc_math_function(name = "canonicalizef128")
1991
1992libc_math_function(name = "canonicalizef16")
1993
1994libc_math_function(
1995    name = "cbrt",
1996    additional_deps = [
1997        ":__support_fputil_double_double",
1998        ":__support_fputil_polyeval",
1999        ":__support_integer_literals",
2000    ],
2001)
2002
2003libc_math_function(
2004    name = "cbrtf",
2005    additional_deps = [
2006        ":__support_fputil_polyeval",
2007    ],
2008)
2009
2010libc_math_function(name = "ceil")
2011
2012libc_math_function(name = "ceilf")
2013
2014libc_math_function(name = "ceill")
2015
2016libc_math_function(name = "ceilf128")
2017
2018libc_math_function(name = "ceilf16")
2019
2020libc_math_function(name = "copysign")
2021
2022libc_math_function(name = "copysignf")
2023
2024libc_math_function(name = "copysignl")
2025
2026libc_math_function(name = "copysignf128")
2027
2028libc_math_function(name = "copysignf16")
2029
2030libc_math_function(
2031    name = "cos",
2032    additional_deps = [
2033        ":__support_fputil_multiply_add",
2034        ":__support_macros_optimization",
2035        ":__support_macros_properties_cpu_features",
2036        ":range_reduction_double",
2037        ":sincos_eval",
2038    ],
2039)
2040
2041libc_math_function(
2042    name = "cosf",
2043    additional_deps = [
2044        ":__support_fputil_fma",
2045        ":__support_fputil_multiply_add",
2046        ":__support_macros_optimization",
2047        ":__support_macros_properties_cpu_features",
2048        ":sincosf_utils",
2049    ],
2050)
2051
2052libc_math_function(
2053    name = "coshf",
2054    additional_deps = [
2055        ":__support_fputil_fma",
2056        ":__support_fputil_multiply_add",
2057        ":__support_fputil_nearest_integer",
2058        ":__support_fputil_polyeval",
2059        ":__support_fputil_rounding_mode",
2060        ":__support_macros_optimization",
2061        ":common_constants",
2062        ":explogxf",
2063    ],
2064)
2065
2066libc_math_function(
2067    name = "coshf16",
2068    additional_deps = [
2069        ":expxf16",
2070    ],
2071)
2072
2073libc_math_function(
2074    name = "cospif",
2075    additional_deps = [
2076        ":__support_fputil_fma",
2077        ":__support_fputil_multiply_add",
2078        ":__support_fputil_nearest_integer",
2079        ":__support_fputil_polyeval",
2080        ":__support_fputil_rounding_mode",
2081        ":__support_macros_optimization",
2082        ":common_constants",
2083        ":explogxf",
2084        ":sincosf_utils",
2085    ],
2086)
2087
2088libc_math_function(
2089    name = "cospif16",
2090    additional_deps = [
2091        ":__support_fputil_multiply_add",
2092        ":__support_macros_optimization",
2093        ":sincosf16_utils",
2094    ],
2095)
2096
2097libc_math_function(name = "daddl")
2098
2099libc_math_function(name = "daddf128")
2100
2101libc_math_function(name = "ddivl")
2102
2103libc_math_function(name = "ddivf128")
2104
2105libc_math_function(
2106    name = "dfmal",
2107    additional_deps = [
2108        ":__support_fputil_fma",
2109    ],
2110)
2111
2112libc_math_function(
2113    name = "dfmaf128",
2114    additional_deps = [
2115        ":__support_fputil_fma",
2116    ],
2117)
2118
2119libc_math_function(name = "dmull")
2120
2121libc_math_function(name = "dmulf128")
2122
2123libc_math_function(
2124    name = "dsqrtl",
2125    additional_deps = [
2126        ":__support_fputil_sqrt",
2127    ],
2128)
2129
2130libc_math_function(
2131    name = "dsqrtf128",
2132    additional_deps = [
2133        ":__support_fputil_sqrt",
2134    ],
2135)
2136
2137libc_math_function(name = "dsubl")
2138
2139libc_math_function(name = "dsubf128")
2140
2141libc_math_function(
2142    name = "erff",
2143    additional_deps = [
2144        ":__support_fputil_multiply_add",
2145        ":__support_fputil_polyeval",
2146        ":__support_macros_optimization",
2147    ],
2148)
2149
2150libc_math_function(
2151    name = "exp",
2152    additional_deps = [
2153        ":__support_fputil_double_double",
2154        ":__support_fputil_dyadic_float",
2155        ":__support_fputil_multiply_add",
2156        ":__support_fputil_nearest_integer",
2157        ":__support_fputil_polyeval",
2158        ":__support_fputil_rounding_mode",
2159        ":__support_fputil_triple_double",
2160        ":__support_integer_literals",
2161        ":__support_macros_optimization",
2162        ":common_constants",
2163        ":explogxf",
2164    ],
2165)
2166
2167libc_math_function(
2168    name = "expf",
2169    additional_deps = [
2170        ":__support_fputil_fma",
2171        ":__support_fputil_multiply_add",
2172        ":__support_fputil_nearest_integer",
2173        ":__support_fputil_polyeval",
2174        ":__support_fputil_rounding_mode",
2175        ":__support_macros_optimization",
2176        ":common_constants",
2177    ],
2178)
2179
2180libc_math_function(
2181    name = "expf16",
2182    additional_deps = [
2183        ":expxf16",
2184    ],
2185)
2186
2187libc_math_function(
2188    name = "exp10",
2189    additional_deps = [
2190        ":__support_fputil_double_double",
2191        ":__support_fputil_dyadic_float",
2192        ":__support_fputil_multiply_add",
2193        ":__support_fputil_nearest_integer",
2194        ":__support_fputil_polyeval",
2195        ":__support_fputil_rounding_mode",
2196        ":__support_fputil_triple_double",
2197        ":__support_integer_literals",
2198        ":__support_macros_optimization",
2199        ":common_constants",
2200        ":explogxf",
2201    ],
2202)
2203
2204libc_math_function(
2205    name = "exp10f",
2206    additional_deps = [
2207        ":exp10f_impl",
2208    ],
2209)
2210
2211libc_math_function(
2212    name = "exp10f16",
2213    additional_deps = [
2214        ":expxf16",
2215    ],
2216)
2217
2218libc_math_function(
2219    name = "exp10m1f16",
2220    additional_deps = [
2221        ":expxf16",
2222    ],
2223)
2224
2225libc_math_function(
2226    name = "exp10m1f",
2227    additional_deps = [
2228        ":explogxf",
2229    ],
2230)
2231
2232libc_math_function(
2233    name = "exp2",
2234    additional_deps = [
2235        ":__support_fputil_double_double",
2236        ":__support_fputil_dyadic_float",
2237        ":__support_fputil_multiply_add",
2238        ":__support_fputil_nearest_integer",
2239        ":__support_fputil_polyeval",
2240        ":__support_fputil_rounding_mode",
2241        ":__support_fputil_triple_double",
2242        ":__support_integer_literals",
2243        ":__support_macros_optimization",
2244        ":common_constants",
2245        ":explogxf",
2246    ],
2247)
2248
2249libc_math_function(
2250    name = "exp2f",
2251    additional_deps = [
2252        ":exp2f_impl",
2253    ],
2254)
2255
2256libc_math_function(
2257    name = "exp2f16",
2258    additional_deps = [
2259        ":expxf16",
2260    ],
2261)
2262
2263libc_math_function(
2264    name = "exp2m1f",
2265    additional_deps = [
2266        ":__support_fputil_polyeval",
2267        ":explogxf",
2268    ],
2269)
2270
2271libc_math_function(
2272    name = "exp2m1f16",
2273    additional_deps = [
2274        ":expxf16",
2275    ],
2276)
2277
2278libc_math_function(
2279    name = "expm1",
2280    additional_deps = [
2281        ":__support_fputil_double_double",
2282        ":__support_fputil_dyadic_float",
2283        ":__support_fputil_multiply_add",
2284        ":__support_fputil_nearest_integer",
2285        ":__support_fputil_polyeval",
2286        ":__support_fputil_rounding_mode",
2287        ":__support_fputil_triple_double",
2288        ":__support_integer_literals",
2289        ":__support_macros_optimization",
2290        ":common_constants",
2291        ":explogxf",
2292    ],
2293)
2294
2295libc_math_function(
2296    name = "expm1f",
2297    additional_deps = [
2298        ":__support_fputil_fma",
2299        ":__support_fputil_multiply_add",
2300        ":__support_fputil_nearest_integer",
2301        ":__support_fputil_polyeval",
2302        ":__support_fputil_rounding_mode",
2303        ":__support_macros_optimization",
2304        ":__support_macros_properties_cpu_features",
2305        ":common_constants",
2306    ],
2307)
2308
2309libc_math_function(
2310    name = "expm1f16",
2311    additional_deps = [
2312        ":expxf16",
2313    ],
2314)
2315
2316libc_math_function(name = "f16add")
2317
2318libc_math_function(name = "f16addf")
2319
2320libc_math_function(name = "f16addf128")
2321
2322libc_math_function(name = "f16addl")
2323
2324libc_math_function(name = "f16div")
2325
2326libc_math_function(name = "f16divf")
2327
2328libc_math_function(name = "f16divf128")
2329
2330libc_math_function(name = "f16divl")
2331
2332libc_math_function(
2333    name = "f16fma",
2334    additional_deps = [
2335        ":__support_fputil_fma",
2336    ],
2337)
2338
2339libc_math_function(
2340    name = "f16fmaf",
2341    additional_deps = [
2342        ":__support_fputil_fma",
2343    ],
2344)
2345
2346libc_math_function(
2347    name = "f16fmaf128",
2348    additional_deps = [
2349        ":__support_fputil_fma",
2350    ],
2351)
2352
2353libc_math_function(
2354    name = "f16fmal",
2355    additional_deps = [
2356        ":__support_fputil_fma",
2357    ],
2358)
2359
2360libc_math_function(name = "f16mul")
2361
2362libc_math_function(name = "f16mulf")
2363
2364libc_math_function(name = "f16mulf128")
2365
2366libc_math_function(name = "f16mull")
2367
2368libc_math_function(
2369    name = "f16sqrt",
2370    additional_deps = [
2371        ":__support_fputil_sqrt",
2372    ],
2373)
2374
2375libc_math_function(
2376    name = "f16sqrtf",
2377    additional_deps = [
2378        ":__support_fputil_sqrt",
2379    ],
2380)
2381
2382libc_math_function(
2383    name = "f16sqrtf128",
2384    additional_deps = [
2385        ":__support_fputil_sqrt",
2386    ],
2387)
2388
2389libc_math_function(
2390    name = "f16sqrtl",
2391    additional_deps = [
2392        ":__support_fputil_sqrt",
2393    ],
2394)
2395
2396libc_math_function(name = "f16sub")
2397
2398libc_math_function(name = "f16subf")
2399
2400libc_math_function(name = "f16subf128")
2401
2402libc_math_function(name = "f16subl")
2403
2404libc_math_function(name = "fabs")
2405
2406libc_math_function(name = "fabsf")
2407
2408libc_math_function(name = "fabsl")
2409
2410libc_math_function(name = "fabsf128")
2411
2412libc_math_function(name = "fabsf16")
2413
2414libc_math_function(name = "fadd")
2415
2416libc_math_function(name = "faddl")
2417
2418libc_math_function(name = "faddf128")
2419
2420libc_math_function(name = "fdim")
2421
2422libc_math_function(name = "fdimf")
2423
2424libc_math_function(name = "fdiml")
2425
2426libc_math_function(name = "fdimf128")
2427
2428libc_math_function(name = "fdimf16")
2429
2430libc_math_function(name = "fdiv")
2431
2432libc_math_function(name = "fdivl")
2433
2434libc_math_function(name = "fdivf128")
2435
2436libc_math_function(
2437    name = "ffma",
2438    additional_deps = [
2439        ":__support_fputil_fma",
2440    ],
2441)
2442
2443libc_math_function(
2444    name = "ffmal",
2445    additional_deps = [
2446        ":__support_fputil_fma",
2447    ],
2448)
2449
2450libc_math_function(
2451    name = "ffmaf128",
2452    additional_deps = [
2453        ":__support_fputil_fma",
2454    ],
2455)
2456
2457libc_math_function(name = "floor")
2458
2459libc_math_function(name = "floorf")
2460
2461libc_math_function(name = "floorl")
2462
2463libc_math_function(name = "floorf128")
2464
2465libc_math_function(name = "floorf16")
2466
2467# TODO: Add fma, fmaf, fmal, fmaf128 functions.
2468
2469libc_math_function(name = "fmax")
2470
2471libc_math_function(name = "fmaxf")
2472
2473libc_math_function(name = "fmaxl")
2474
2475libc_math_function(name = "fmaxf128")
2476
2477libc_math_function(name = "fmaxf16")
2478
2479libc_math_function(name = "fmaximum")
2480
2481libc_math_function(name = "fmaximumf")
2482
2483libc_math_function(name = "fmaximuml")
2484
2485libc_math_function(name = "fmaximumf128")
2486
2487libc_math_function(name = "fmaximumf16")
2488
2489libc_math_function(name = "fmaximum_mag")
2490
2491libc_math_function(name = "fmaximum_magf")
2492
2493libc_math_function(name = "fmaximum_magl")
2494
2495libc_math_function(name = "fmaximum_magf128")
2496
2497libc_math_function(name = "fmaximum_magf16")
2498
2499libc_math_function(name = "fmaximum_mag_num")
2500
2501libc_math_function(name = "fmaximum_mag_numf")
2502
2503libc_math_function(name = "fmaximum_mag_numl")
2504
2505libc_math_function(name = "fmaximum_mag_numf128")
2506
2507libc_math_function(name = "fmaximum_mag_numf16")
2508
2509libc_math_function(name = "fmaximum_num")
2510
2511libc_math_function(name = "fmaximum_numf")
2512
2513libc_math_function(name = "fmaximum_numl")
2514
2515libc_math_function(name = "fmaximum_numf128")
2516
2517libc_math_function(name = "fmaximum_numf16")
2518
2519libc_math_function(name = "fmin")
2520
2521libc_math_function(name = "fminf")
2522
2523libc_math_function(name = "fminl")
2524
2525libc_math_function(name = "fminf128")
2526
2527libc_math_function(name = "fminf16")
2528
2529libc_math_function(name = "fminimum")
2530
2531libc_math_function(name = "fminimumf")
2532
2533libc_math_function(name = "fminimuml")
2534
2535libc_math_function(name = "fminimumf128")
2536
2537libc_math_function(name = "fminimumf16")
2538
2539libc_math_function(name = "fminimum_mag")
2540
2541libc_math_function(name = "fminimum_magf")
2542
2543libc_math_function(name = "fminimum_magl")
2544
2545libc_math_function(name = "fminimum_magf128")
2546
2547libc_math_function(name = "fminimum_magf16")
2548
2549libc_math_function(name = "fminimum_mag_num")
2550
2551libc_math_function(name = "fminimum_mag_numf")
2552
2553libc_math_function(name = "fminimum_mag_numl")
2554
2555libc_math_function(name = "fminimum_mag_numf128")
2556
2557libc_math_function(name = "fminimum_mag_numf16")
2558
2559libc_math_function(name = "fminimum_num")
2560
2561libc_math_function(name = "fminimum_numf")
2562
2563libc_math_function(name = "fminimum_numl")
2564
2565libc_math_function(name = "fminimum_numf128")
2566
2567libc_math_function(name = "fminimum_numf16")
2568
2569libc_math_function(
2570    name = "fmod",
2571    additional_deps = [
2572        ":__support_fputil_generic_fmod",
2573    ],
2574)
2575
2576libc_math_function(
2577    name = "fmodf",
2578    additional_deps = [
2579        ":__support_fputil_generic_fmod",
2580    ],
2581)
2582
2583libc_math_function(
2584    name = "fmodl",
2585    additional_deps = [
2586        ":__support_fputil_generic_fmod",
2587    ],
2588)
2589
2590libc_math_function(
2591    name = "fmodf128",
2592    additional_deps = [
2593        ":__support_fputil_generic_fmod",
2594    ],
2595)
2596
2597libc_math_function(
2598    name = "fmodf16",
2599    additional_deps = [
2600        ":__support_fputil_generic_fmod",
2601    ],
2602)
2603
2604libc_math_function(
2605    name = "fmul",
2606    additional_deps = [
2607        ":__support_fputil_double_double",
2608    ],
2609)
2610
2611libc_math_function(name = "fmull")
2612
2613libc_math_function(name = "fmulf128")
2614
2615libc_math_function(name = "frexp")
2616
2617libc_math_function(name = "frexpf")
2618
2619libc_math_function(name = "frexpl")
2620
2621libc_math_function(name = "frexpf128")
2622
2623libc_math_function(name = "frexpf16")
2624
2625libc_math_function(name = "fromfp")
2626
2627libc_math_function(name = "fromfpf")
2628
2629libc_math_function(name = "fromfpl")
2630
2631libc_math_function(name = "fromfpf128")
2632
2633libc_math_function(name = "fromfpf16")
2634
2635libc_math_function(name = "fromfpx")
2636
2637libc_math_function(name = "fromfpxf")
2638
2639libc_math_function(name = "fromfpxl")
2640
2641libc_math_function(name = "fromfpxf128")
2642
2643libc_math_function(name = "fromfpxf16")
2644
2645libc_math_function(
2646    name = "fsqrt",
2647    additional_deps = [
2648        ":__support_fputil_sqrt",
2649    ],
2650)
2651
2652libc_math_function(
2653    name = "fsqrtl",
2654    additional_deps = [
2655        ":__support_fputil_sqrt",
2656    ],
2657)
2658
2659libc_math_function(
2660    name = "fsqrtf128",
2661    additional_deps = [
2662        ":__support_fputil_sqrt",
2663    ],
2664)
2665
2666libc_math_function(name = "fsub")
2667
2668libc_math_function(name = "fsubl")
2669
2670libc_math_function(name = "fsubf128")
2671
2672libc_math_function(name = "getpayload")
2673
2674libc_math_function(name = "getpayloadf")
2675
2676libc_math_function(name = "getpayloadl")
2677
2678libc_math_function(name = "getpayloadf128")
2679
2680libc_math_function(name = "getpayloadf16")
2681
2682libc_math_function(name = "hypot")
2683
2684libc_math_function(
2685    name = "hypotf",
2686    additional_deps = [
2687        ":__support_fputil_double_double",
2688        ":__support_fputil_sqrt",
2689    ],
2690)
2691
2692libc_math_function(name = "ilogb")
2693
2694libc_math_function(name = "ilogbf")
2695
2696libc_math_function(name = "ilogbl")
2697
2698libc_math_function(name = "ilogbf128")
2699
2700libc_math_function(name = "ilogbf16")
2701
2702libc_math_function(name = "ldexp")
2703
2704libc_math_function(name = "ldexpf")
2705
2706libc_math_function(name = "ldexpl")
2707
2708libc_math_function(name = "ldexpf128")
2709
2710libc_math_function(name = "ldexpf16")
2711
2712libc_math_function(name = "llogb")
2713
2714libc_math_function(name = "llogbf")
2715
2716libc_math_function(name = "llogbl")
2717
2718libc_math_function(name = "llogbf128")
2719
2720libc_math_function(name = "llogbf16")
2721
2722libc_math_function(name = "llrint")
2723
2724libc_math_function(name = "llrintf")
2725
2726libc_math_function(name = "llrintl")
2727
2728libc_math_function(name = "llrintf128")
2729
2730libc_math_function(name = "llrintf16")
2731
2732libc_math_function(name = "llround")
2733
2734libc_math_function(name = "llroundf")
2735
2736libc_math_function(name = "llroundl")
2737
2738libc_math_function(name = "llroundf128")
2739
2740libc_math_function(name = "llroundf16")
2741
2742libc_math_function(
2743    name = "log",
2744    additional_deps = [
2745        ":__support_fputil_double_double",
2746        ":__support_fputil_dyadic_float",
2747        ":__support_fputil_fma",
2748        ":__support_fputil_multiply_add",
2749        ":__support_fputil_polyeval",
2750        ":__support_integer_literals",
2751        ":__support_macros_optimization",
2752        ":__support_macros_properties_cpu_features",
2753        ":common_constants",
2754        ":log_range_reduction",
2755    ],
2756)
2757
2758libc_math_function(
2759    name = "logf",
2760    additional_deps = [
2761        ":__support_fputil_fma",
2762        ":__support_fputil_multiply_add",
2763        ":__support_fputil_polyeval",
2764        ":__support_macros_optimization",
2765        ":__support_macros_properties_cpu_features",
2766        ":common_constants",
2767    ],
2768)
2769
2770libc_math_function(
2771    name = "logf16",
2772    additional_deps = [
2773        ":expxf16",
2774    ],
2775)
2776
2777libc_math_function(
2778    name = "log10",
2779    additional_deps = [
2780        ":__support_fputil_double_double",
2781        ":__support_fputil_dyadic_float",
2782        ":__support_fputil_fma",
2783        ":__support_fputil_multiply_add",
2784        ":__support_fputil_polyeval",
2785        ":__support_integer_literals",
2786        ":__support_macros_optimization",
2787        ":__support_macros_properties_cpu_features",
2788        ":common_constants",
2789        ":log_range_reduction",
2790    ],
2791)
2792
2793libc_math_function(
2794    name = "log10f",
2795    additional_deps = [
2796        ":__support_fputil_fma",
2797        ":__support_fputil_multiply_add",
2798        ":__support_fputil_polyeval",
2799        ":__support_macros_optimization",
2800        ":__support_macros_properties_cpu_features",
2801        ":common_constants",
2802    ],
2803)
2804
2805libc_math_function(
2806    name = "log10f16",
2807    additional_deps = [
2808        ":expxf16",
2809    ],
2810)
2811
2812libc_math_function(
2813    name = "log1p",
2814    additional_deps = [
2815        ":__support_fputil_double_double",
2816        ":__support_fputil_dyadic_float",
2817        ":__support_fputil_fma",
2818        ":__support_fputil_multiply_add",
2819        ":__support_fputil_polyeval",
2820        ":__support_integer_literals",
2821        ":__support_macros_optimization",
2822        ":__support_macros_properties_cpu_features",
2823        ":common_constants",
2824    ],
2825)
2826
2827libc_math_function(
2828    name = "log1pf",
2829    additional_deps = [
2830        ":__support_fputil_fma",
2831        ":__support_fputil_multiply_add",
2832        ":__support_fputil_polyeval",
2833        ":__support_macros_optimization",
2834        ":__support_macros_properties_cpu_features",
2835        ":common_constants",
2836    ],
2837)
2838
2839libc_math_function(
2840    name = "log2",
2841    additional_deps = [
2842        ":__support_fputil_double_double",
2843        ":__support_fputil_dyadic_float",
2844        ":__support_fputil_fma",
2845        ":__support_fputil_multiply_add",
2846        ":__support_fputil_polyeval",
2847        ":__support_integer_literals",
2848        ":__support_macros_optimization",
2849        ":__support_macros_properties_cpu_features",
2850        ":common_constants",
2851        ":log_range_reduction",
2852    ],
2853)
2854
2855libc_math_function(
2856    name = "log2f",
2857    additional_deps = [
2858        ":__support_fputil_fma",
2859        ":__support_fputil_multiply_add",
2860        ":__support_fputil_polyeval",
2861        ":__support_macros_optimization",
2862        ":common_constants",
2863    ],
2864)
2865
2866libc_math_function(
2867    name = "log2f16",
2868    additional_deps = [
2869        ":expxf16",
2870    ],
2871)
2872
2873libc_math_function(name = "logb")
2874
2875libc_math_function(name = "logbf")
2876
2877libc_math_function(name = "logbl")
2878
2879libc_math_function(name = "logbf128")
2880
2881libc_math_function(name = "logbf16")
2882
2883libc_math_function(name = "lrint")
2884
2885libc_math_function(name = "lrintf")
2886
2887libc_math_function(name = "lrintl")
2888
2889libc_math_function(name = "lrintf128")
2890
2891libc_math_function(name = "lrintf16")
2892
2893libc_math_function(name = "lround")
2894
2895libc_math_function(name = "lroundf")
2896
2897libc_math_function(name = "lroundl")
2898
2899libc_math_function(name = "lroundf128")
2900
2901libc_math_function(name = "lroundf16")
2902
2903libc_math_function(name = "modf")
2904
2905libc_math_function(name = "modff")
2906
2907libc_math_function(name = "modfl")
2908
2909libc_math_function(name = "modff128")
2910
2911libc_math_function(name = "modff16")
2912
2913libc_math_function(
2914    name = "nan",
2915    additional_deps = [
2916        ":__support_str_to_float",
2917        ":errno",
2918    ],
2919)
2920
2921libc_math_function(
2922    name = "nanf",
2923    additional_deps = [
2924        ":__support_str_to_float",
2925        ":errno",
2926    ],
2927)
2928
2929libc_math_function(
2930    name = "nanl",
2931    additional_deps = [
2932        ":__support_str_to_float",
2933        ":errno",
2934    ],
2935)
2936
2937libc_math_function(
2938    name = "nanf128",
2939    additional_deps = [
2940        ":__support_str_to_float",
2941        ":errno",
2942    ],
2943)
2944
2945libc_math_function(
2946    name = "nanf16",
2947    additional_deps = [
2948        ":__support_str_to_float",
2949        ":errno",
2950    ],
2951)
2952
2953libc_math_function(name = "nearbyint")
2954
2955libc_math_function(name = "nearbyintf")
2956
2957libc_math_function(name = "nearbyintl")
2958
2959libc_math_function(name = "nearbyintf128")
2960
2961libc_math_function(name = "nearbyintf16")
2962
2963libc_math_function(name = "nextafter")
2964
2965libc_math_function(name = "nextafterf")
2966
2967libc_math_function(name = "nextafterl")
2968
2969libc_math_function(name = "nextafterf128")
2970
2971libc_math_function(name = "nextafterf16")
2972
2973libc_math_function(name = "nextdown")
2974
2975libc_math_function(name = "nextdownf")
2976
2977libc_math_function(name = "nextdownl")
2978
2979libc_math_function(name = "nextdownf128")
2980
2981libc_math_function(name = "nextdownf16")
2982
2983libc_math_function(name = "nexttoward")
2984
2985libc_math_function(name = "nexttowardf")
2986
2987libc_math_function(name = "nexttowardf16")
2988
2989libc_math_function(name = "nexttowardl")
2990
2991libc_math_function(name = "nextup")
2992
2993libc_math_function(name = "nextupf")
2994
2995libc_math_function(name = "nextupl")
2996
2997libc_math_function(name = "nextupf128")
2998
2999libc_math_function(name = "nextupf16")
3000
3001libc_math_function(
3002    name = "pow",
3003    additional_deps = [
3004        ":__support_fputil_double_double",
3005        ":__support_fputil_nearest_integer",
3006        ":__support_fputil_polyeval",
3007        ":__support_fputil_sqrt",
3008        ":common_constants",
3009    ],
3010)
3011
3012libc_math_function(
3013    name = "powf",
3014    additional_deps = [
3015        ":__support_fputil_double_double",
3016        ":__support_fputil_multiply_add",
3017        ":__support_fputil_nearest_integer",
3018        ":__support_fputil_polyeval",
3019        ":__support_fputil_rounding_mode",
3020        ":__support_fputil_sqrt",
3021        ":__support_fputil_triple_double",
3022        ":__support_macros_optimization",
3023        ":common_constants",
3024        ":explogxf",
3025        ":exp2f_impl",
3026        ":exp10f_impl",
3027    ],
3028)
3029
3030libc_math_function(name = "remainder")
3031
3032libc_math_function(name = "remainderf")
3033
3034libc_math_function(name = "remainderl")
3035
3036libc_math_function(name = "remainderf128")
3037
3038libc_math_function(name = "remainderf16")
3039
3040libc_math_function(name = "remquo")
3041
3042libc_math_function(name = "remquof")
3043
3044libc_math_function(name = "remquol")
3045
3046libc_math_function(name = "remquof128")
3047
3048libc_math_function(name = "remquof16")
3049
3050libc_math_function(name = "rint")
3051
3052libc_math_function(name = "rintf")
3053
3054libc_math_function(name = "rintl")
3055
3056libc_math_function(name = "rintf128")
3057
3058libc_math_function(name = "rintf16")
3059
3060libc_math_function(name = "round")
3061
3062libc_math_function(name = "roundf")
3063
3064libc_math_function(name = "roundl")
3065
3066libc_math_function(name = "roundf128")
3067
3068libc_math_function(name = "roundf16")
3069
3070libc_math_function(name = "roundeven")
3071
3072libc_math_function(name = "roundevenf")
3073
3074libc_math_function(name = "roundevenl")
3075
3076libc_math_function(name = "roundevenf128")
3077
3078libc_math_function(name = "roundevenf16")
3079
3080libc_math_function(name = "scalbln")
3081
3082libc_math_function(name = "scalblnf")
3083
3084libc_math_function(name = "scalblnl")
3085
3086libc_math_function(name = "scalblnf128")
3087
3088libc_math_function(name = "scalblnf16")
3089
3090libc_math_function(name = "scalbn")
3091
3092libc_math_function(name = "scalbnf")
3093
3094libc_math_function(name = "scalbnl")
3095
3096libc_math_function(name = "scalbnf128")
3097
3098libc_math_function(name = "scalbnf16")
3099
3100libc_math_function(name = "setpayload")
3101
3102libc_math_function(name = "setpayloadf")
3103
3104libc_math_function(name = "setpayloadl")
3105
3106libc_math_function(name = "setpayloadf128")
3107
3108libc_math_function(name = "setpayloadf16")
3109
3110libc_math_function(name = "setpayloadsig")
3111
3112libc_math_function(name = "setpayloadsigf")
3113
3114libc_math_function(name = "setpayloadsigl")
3115
3116libc_math_function(name = "setpayloadsigf128")
3117
3118libc_math_function(name = "setpayloadsigf16")
3119
3120libc_math_function(
3121    name = "sin",
3122    additional_deps = [
3123        ":__support_fputil_multiply_add",
3124        ":__support_macros_optimization",
3125        ":__support_macros_properties_cpu_features",
3126        ":range_reduction_double",
3127        ":sincos_eval",
3128    ],
3129)
3130
3131libc_math_function(
3132    name = "sinf",
3133    additional_deps = [
3134        ":__support_fputil_fma",
3135        ":__support_fputil_multiply_add",
3136        ":__support_fputil_polyeval",
3137        ":__support_fputil_rounding_mode",
3138        ":__support_macros_optimization",
3139        ":__support_macros_properties_cpu_features",
3140        ":range_reduction",
3141        ":sincosf_utils",
3142    ],
3143)
3144
3145libc_math_function(
3146    name = "sincos",
3147    additional_deps = [
3148        ":__support_fputil_multiply_add",
3149        ":__support_macros_optimization",
3150        ":__support_macros_properties_cpu_features",
3151        ":range_reduction_double",
3152        ":sincos_eval",
3153    ],
3154)
3155
3156libc_math_function(
3157    name = "sincosf",
3158    additional_deps = [
3159        ":__support_fputil_fma",
3160        ":__support_fputil_multiply_add",
3161        ":__support_fputil_rounding_mode",
3162        ":__support_macros_optimization",
3163        ":__support_macros_properties_cpu_features",
3164        ":sincosf_utils",
3165    ],
3166)
3167
3168libc_math_function(
3169    name = "sinhf",
3170    additional_deps = [
3171        ":__support_fputil_fma",
3172        ":__support_fputil_multiply_add",
3173        ":__support_fputil_nearest_integer",
3174        ":__support_fputil_polyeval",
3175        ":__support_fputil_rounding_mode",
3176        ":__support_macros_optimization",
3177        ":common_constants",
3178        ":explogxf",
3179    ],
3180)
3181
3182libc_math_function(
3183    name = "sinhf16",
3184    additional_deps = [
3185        ":expxf16",
3186    ],
3187)
3188
3189libc_math_function(
3190    name = "sinpif",
3191    additional_deps = [
3192        ":sincosf_utils",
3193    ],
3194)
3195
3196libc_math_function(
3197    name = "sinpif16",
3198    additional_deps = [
3199        ":__support_fputil_nearest_integer",
3200        ":__support_fputil_polyeval",
3201        ":sincosf16_utils",
3202    ],
3203)
3204
3205libc_math_function(
3206    name = "sqrt",
3207    additional_deps = [
3208        ":__support_fputil_sqrt",
3209    ],
3210)
3211
3212libc_math_function(
3213    name = "sqrtf",
3214    additional_deps = [
3215        ":__support_fputil_sqrt",
3216    ],
3217)
3218
3219libc_math_function(
3220    name = "sqrtl",
3221    additional_deps = [
3222        ":__support_fputil_sqrt",
3223    ],
3224)
3225
3226libc_math_function(
3227    name = "sqrtf128",
3228    additional_deps = [
3229        ":__support_fputil_sqrt",
3230    ],
3231)
3232
3233libc_math_function(
3234    name = "sqrtf16",
3235    additional_deps = [
3236        ":__support_fputil_sqrt",
3237    ],
3238)
3239
3240libc_math_function(
3241    name = "tan",
3242    additional_deps = [
3243        ":__support_fputil_multiply_add",
3244        ":__support_macros_optimization",
3245        ":__support_macros_properties_cpu_features",
3246        ":range_reduction_double",
3247        ":sincos_eval",
3248    ],
3249)
3250
3251libc_math_function(
3252    name = "tanf",
3253    additional_deps = [
3254        ":__support_fputil_fma",
3255        ":__support_fputil_multiply_add",
3256        ":__support_fputil_nearest_integer",
3257        ":__support_fputil_polyeval",
3258        ":__support_macros_optimization",
3259        ":__support_macros_properties_cpu_features",
3260        ":range_reduction",
3261        ":sincosf_utils",
3262    ],
3263)
3264
3265libc_math_function(
3266    name = "tanhf",
3267    additional_deps = [
3268        ":__support_fputil_fma",
3269        ":__support_fputil_multiply_add",
3270        ":__support_fputil_nearest_integer",
3271        ":__support_fputil_polyeval",
3272        ":__support_fputil_rounding_mode",
3273        ":__support_macros_optimization",
3274        ":__support_macros_properties_cpu_features",
3275        ":common_constants",
3276        ":explogxf",
3277    ],
3278)
3279
3280libc_math_function(
3281    name = "tanhf16",
3282    additional_deps = [
3283        ":expxf16",
3284    ],
3285)
3286
3287libc_math_function(name = "totalorder")
3288
3289libc_math_function(name = "totalorderf")
3290
3291libc_math_function(name = "totalorderl")
3292
3293libc_math_function(name = "totalorderf128")
3294
3295libc_math_function(name = "totalorderf16")
3296
3297libc_math_function(name = "totalordermag")
3298
3299libc_math_function(name = "totalordermagf")
3300
3301libc_math_function(name = "totalordermagl")
3302
3303libc_math_function(name = "totalordermagf128")
3304
3305libc_math_function(name = "totalordermagf16")
3306
3307libc_math_function(name = "trunc")
3308
3309libc_math_function(name = "truncf")
3310
3311libc_math_function(name = "truncl")
3312
3313libc_math_function(name = "truncf128")
3314
3315libc_math_function(name = "truncf16")
3316
3317libc_math_function(name = "ufromfp")
3318
3319libc_math_function(name = "ufromfpf")
3320
3321libc_math_function(name = "ufromfpl")
3322
3323libc_math_function(name = "ufromfpf128")
3324
3325libc_math_function(name = "ufromfpf16")
3326
3327libc_math_function(name = "ufromfpx")
3328
3329libc_math_function(name = "ufromfpxf")
3330
3331libc_math_function(name = "ufromfpxl")
3332
3333libc_math_function(name = "ufromfpxf128")
3334
3335libc_math_function(name = "ufromfpxf16")
3336
3337############################## inttypes targets ##############################
3338
3339libc_function(
3340    name = "imaxabs",
3341    srcs = ["src/inttypes/imaxabs.cpp"],
3342    hdrs = ["src/inttypes/imaxabs.h"],
3343    deps = [
3344        ":__support_common",
3345        ":__support_integer_operations",
3346    ],
3347)
3348
3349libc_function(
3350    name = "imaxdiv",
3351    srcs = ["src/inttypes/imaxdiv.cpp"],
3352    hdrs = ["src/inttypes/imaxdiv.h"],
3353    deps = [
3354        ":__support_common",
3355        ":__support_integer_operations",
3356    ],
3357)
3358
3359############################### stdlib targets ###############################
3360
3361libc_function(
3362    name = "abs",
3363    srcs = ["src/stdlib/abs.cpp"],
3364    hdrs = ["src/stdlib/abs.h"],
3365    deps = [
3366        ":__support_common",
3367        ":__support_integer_operations",
3368    ],
3369)
3370
3371libc_function(
3372    name = "labs",
3373    srcs = ["src/stdlib/labs.cpp"],
3374    hdrs = ["src/stdlib/labs.h"],
3375    deps = [
3376        ":__support_common",
3377        ":__support_integer_operations",
3378    ],
3379)
3380
3381libc_function(
3382    name = "llabs",
3383    srcs = ["src/stdlib/llabs.cpp"],
3384    hdrs = ["src/stdlib/llabs.h"],
3385    deps = [
3386        ":__support_common",
3387        ":__support_integer_operations",
3388    ],
3389)
3390
3391libc_function(
3392    name = "div",
3393    srcs = ["src/stdlib/div.cpp"],
3394    hdrs = ["src/stdlib/div.h"],
3395    deps = [
3396        ":__support_common",
3397        ":__support_integer_operations",
3398        ":types_div_t",
3399    ],
3400)
3401
3402libc_function(
3403    name = "ldiv",
3404    srcs = ["src/stdlib/ldiv.cpp"],
3405    hdrs = ["src/stdlib/ldiv.h"],
3406    deps = [
3407        ":__support_common",
3408        ":__support_integer_operations",
3409        ":types_ldiv_t",
3410    ],
3411)
3412
3413libc_function(
3414    name = "lldiv",
3415    srcs = ["src/stdlib/lldiv.cpp"],
3416    hdrs = ["src/stdlib/lldiv.h"],
3417    deps = [
3418        ":__support_common",
3419        ":__support_integer_operations",
3420        ":types_lldiv_t",
3421    ],
3422)
3423
3424libc_function(
3425    name = "atoi",
3426    srcs = ["src/stdlib/atoi.cpp"],
3427    hdrs = ["src/stdlib/atoi.h"],
3428    deps = [
3429        ":__support_common",
3430        ":__support_str_to_integer",
3431        ":errno",
3432    ],
3433)
3434
3435libc_function(
3436    name = "atol",
3437    srcs = ["src/stdlib/atol.cpp"],
3438    hdrs = ["src/stdlib/atol.h"],
3439    deps = [
3440        ":__support_common",
3441        ":__support_str_to_integer",
3442        ":errno",
3443    ],
3444)
3445
3446libc_function(
3447    name = "atoll",
3448    srcs = ["src/stdlib/atoll.cpp"],
3449    hdrs = ["src/stdlib/atoll.h"],
3450    deps = [
3451        ":__support_common",
3452        ":__support_str_to_integer",
3453        ":errno",
3454    ],
3455)
3456
3457libc_function(
3458    name = "atof",
3459    srcs = ["src/stdlib/atof.cpp"],
3460    hdrs = ["src/stdlib/atof.h"],
3461    deps = [
3462        ":__support_common",
3463        ":__support_str_to_float",
3464        ":errno",
3465    ],
3466)
3467
3468libc_function(
3469    name = "bsearch",
3470    srcs = ["src/stdlib/bsearch.cpp"],
3471    hdrs = ["src/stdlib/bsearch.h"],
3472    deps = [
3473        ":__support_common",
3474    ],
3475)
3476
3477libc_support_library(
3478    name = "qsort_util",
3479    hdrs = [
3480        "src/stdlib/heap_sort.h",
3481        "src/stdlib/qsort_data.h",
3482        "src/stdlib/qsort_pivot.h",
3483        "src/stdlib/qsort_util.h",
3484        "src/stdlib/quick_sort.h",
3485    ],
3486    deps = [
3487        ":__support_common",
3488        ":__support_cpp_bit",
3489        ":__support_cpp_cstddef",
3490        ":__support_macros_attributes",
3491    ],
3492)
3493
3494libc_function(
3495    name = "qsort",
3496    srcs = ["src/stdlib/qsort.cpp"],
3497    hdrs = ["src/stdlib/qsort.h"],
3498    deps = [
3499        ":__support_common",
3500        ":qsort_util",
3501        ":types_size_t",
3502    ],
3503)
3504
3505libc_function(
3506    name = "qsort_r",
3507    srcs = ["src/stdlib/qsort_r.cpp"],
3508    hdrs = ["src/stdlib/qsort_r.h"],
3509    deps = [
3510        ":__support_common",
3511        ":qsort_util",
3512        ":types_size_t",
3513    ],
3514)
3515
3516libc_function(
3517    name = "strtol",
3518    srcs = ["src/stdlib/strtol.cpp"],
3519    hdrs = ["src/stdlib/strtol.h"],
3520    deps = [
3521        ":__support_common",
3522        ":__support_str_to_integer",
3523        ":errno",
3524    ],
3525)
3526
3527libc_function(
3528    name = "strtoll",
3529    srcs = ["src/stdlib/strtoll.cpp"],
3530    hdrs = ["src/stdlib/strtoll.h"],
3531    deps = [
3532        ":__support_common",
3533        ":__support_str_to_integer",
3534        ":errno",
3535    ],
3536)
3537
3538libc_function(
3539    name = "strtoul",
3540    srcs = ["src/stdlib/strtoul.cpp"],
3541    hdrs = ["src/stdlib/strtoul.h"],
3542    deps = [
3543        ":__support_common",
3544        ":__support_str_to_integer",
3545        ":errno",
3546    ],
3547)
3548
3549libc_function(
3550    name = "strtoull",
3551    srcs = ["src/stdlib/strtoull.cpp"],
3552    hdrs = ["src/stdlib/strtoull.h"],
3553    deps = [
3554        ":__support_common",
3555        ":__support_str_to_integer",
3556        ":errno",
3557    ],
3558)
3559
3560libc_function(
3561    name = "strtof",
3562    srcs = ["src/stdlib/strtof.cpp"],
3563    hdrs = ["src/stdlib/strtof.h"],
3564    deps = [
3565        ":__support_common",
3566        ":__support_str_to_float",
3567        ":errno",
3568    ],
3569)
3570
3571libc_function(
3572    name = "strtod",
3573    srcs = ["src/stdlib/strtod.cpp"],
3574    hdrs = ["src/stdlib/strtod.h"],
3575    deps = [
3576        ":__support_common",
3577        ":__support_str_to_float",
3578        ":errno",
3579    ],
3580)
3581
3582libc_function(
3583    name = "strtold",
3584    srcs = ["src/stdlib/strtold.cpp"],
3585    hdrs = ["src/stdlib/strtold.h"],
3586    deps = [
3587        ":__support_common",
3588        ":__support_str_to_float",
3589        ":errno",
3590    ],
3591)
3592
3593############################### string targets ###############################
3594
3595libc_support_library(
3596    name = "string_memory_utils",
3597    hdrs = [
3598        "src/string/memory_utils/op_aarch64.h",
3599        "src/string/memory_utils/op_builtin.h",
3600        "src/string/memory_utils/op_generic.h",
3601        "src/string/memory_utils/op_riscv.h",
3602        "src/string/memory_utils/op_x86.h",
3603        "src/string/memory_utils/utils.h",
3604    ],
3605    textual_hdrs = [
3606        "src/string/memory_utils/aarch64/inline_bcmp.h",
3607        "src/string/memory_utils/aarch64/inline_memcmp.h",
3608        "src/string/memory_utils/aarch64/inline_memcpy.h",
3609        "src/string/memory_utils/aarch64/inline_memmove.h",
3610        "src/string/memory_utils/aarch64/inline_memset.h",
3611        "src/string/memory_utils/generic/aligned_access.h",
3612        "src/string/memory_utils/generic/byte_per_byte.h",
3613        "src/string/memory_utils/inline_bcmp.h",
3614        "src/string/memory_utils/inline_bzero.h",
3615        "src/string/memory_utils/inline_memcmp.h",
3616        "src/string/memory_utils/inline_memcpy.h",
3617        "src/string/memory_utils/inline_memmem.h",
3618        "src/string/memory_utils/inline_memmove.h",
3619        "src/string/memory_utils/inline_memset.h",
3620        "src/string/memory_utils/inline_strcmp.h",
3621        "src/string/memory_utils/inline_strstr.h",
3622        "src/string/memory_utils/riscv/inline_bcmp.h",
3623        "src/string/memory_utils/riscv/inline_memcmp.h",
3624        "src/string/memory_utils/riscv/inline_memcpy.h",
3625        "src/string/memory_utils/riscv/inline_memmove.h",
3626        "src/string/memory_utils/riscv/inline_memset.h",
3627        "src/string/memory_utils/x86_64/inline_bcmp.h",
3628        "src/string/memory_utils/x86_64/inline_memcmp.h",
3629        "src/string/memory_utils/x86_64/inline_memcpy.h",
3630        "src/string/memory_utils/x86_64/inline_memmove.h",
3631        "src/string/memory_utils/x86_64/inline_memset.h",
3632    ],
3633    deps = [
3634        ":__support_common",
3635        ":__support_cpp_array",
3636        ":__support_cpp_bit",
3637        ":__support_cpp_cstddef",
3638        ":__support_cpp_type_traits",
3639        ":__support_macros_attributes",
3640        ":__support_macros_optimization",
3641        ":__support_macros_properties_architectures",
3642        ":__support_macros_properties_cpu_features",
3643    ],
3644)
3645
3646libc_support_library(
3647    name = "string_utils",
3648    hdrs = ["src/string/string_utils.h"],
3649    deps = [
3650        ":__support_common",
3651        ":__support_cpp_bitset",
3652        ":__support_macros_optimization",
3653        ":llvm_libc_types_size_t",
3654        ":string_memory_utils",
3655        ":types_size_t",
3656    ],
3657)
3658
3659libc_function(
3660    name = "memchr",
3661    srcs = ["src/string/memchr.cpp"],
3662    hdrs = ["src/string/memchr.h"],
3663    deps = [
3664        ":__support_common",
3665        ":string_utils",
3666    ],
3667)
3668
3669libc_function(
3670    name = "memcpy",
3671    srcs = ["src/string/memcpy.cpp"],
3672    hdrs = ["src/string/memcpy.h"],
3673    weak = True,
3674    deps = [
3675        ":__support_common",
3676        ":string_memory_utils",
3677    ],
3678)
3679
3680libc_function(
3681    name = "memset",
3682    srcs = ["src/string/memset.cpp"],
3683    hdrs = ["src/string/memset.h"],
3684    weak = True,
3685    deps = [
3686        ":__support_common",
3687        ":string_memory_utils",
3688    ],
3689)
3690
3691libc_function(
3692    name = "memmove",
3693    srcs = ["src/string/memmove.cpp"],
3694    hdrs = ["src/string/memmove.h"],
3695    weak = True,
3696    deps = [
3697        ":__support_common",
3698        ":string_memory_utils",
3699    ],
3700)
3701
3702libc_function(
3703    name = "mempcpy",
3704    srcs = ["src/string/mempcpy.cpp"],
3705    hdrs = ["src/string/mempcpy.h"],
3706    weak = True,
3707    deps = [
3708        ":__support_common",
3709        ":string_memory_utils",
3710    ],
3711)
3712
3713libc_function(
3714    name = "bcopy",
3715    srcs = ["src/strings/bcopy.cpp"],
3716    hdrs = ["src/strings/bcopy.h"],
3717    deps = [
3718        ":__support_common",
3719        ":string_memory_utils",
3720    ],
3721)
3722
3723libc_function(
3724    name = "memcmp",
3725    srcs = ["src/string/memcmp.cpp"],
3726    hdrs = ["src/string/memcmp.h"],
3727    weak = True,
3728    deps = [
3729        ":__support_common",
3730        ":__support_integer_operations",
3731        ":string_memory_utils",
3732    ],
3733)
3734
3735libc_function(
3736    name = "bcmp",
3737    srcs = ["src/strings/bcmp.cpp"],
3738    hdrs = ["src/strings/bcmp.h"],
3739    weak = True,
3740    deps = [
3741        ":__support_common",
3742        ":string_memory_utils",
3743    ],
3744)
3745
3746libc_function(
3747    name = "bzero",
3748    srcs = ["src/strings/bzero.cpp"],
3749    hdrs = ["src/strings/bzero.h"],
3750    weak = True,
3751    deps = [
3752        ":__support_common",
3753        ":string_memory_utils",
3754    ],
3755)
3756
3757libc_function(
3758    name = "memrchr",
3759    srcs = ["src/string/memrchr.cpp"],
3760    hdrs = ["src/string/memrchr.h"],
3761    deps = [
3762        ":__support_common",
3763        ":string_utils",
3764    ],
3765)
3766
3767libc_function(
3768    name = "strlen",
3769    srcs = ["src/string/strlen.cpp"],
3770    hdrs = ["src/string/strlen.h"],
3771    deps = [
3772        ":__support_common",
3773        ":string_utils",
3774    ],
3775)
3776
3777libc_function(
3778    name = "strcpy",
3779    srcs = ["src/string/strcpy.cpp"],
3780    hdrs = ["src/string/strcpy.h"],
3781    deps = [
3782        ":__support_common",
3783        ":memcpy",
3784        ":string_memory_utils",
3785        ":string_utils",
3786    ],
3787)
3788
3789libc_function(
3790    name = "strncpy",
3791    srcs = ["src/string/strncpy.cpp"],
3792    hdrs = ["src/string/strncpy.h"],
3793    deps = [
3794        ":__support_common",
3795    ],
3796)
3797
3798libc_function(
3799    name = "strcmp",
3800    srcs = ["src/string/strcmp.cpp"],
3801    hdrs = ["src/string/strcmp.h"],
3802    deps = [
3803        ":__support_common",
3804        ":string_memory_utils",
3805        ":string_utils",
3806    ],
3807)
3808
3809libc_function(
3810    name = "strchr",
3811    srcs = ["src/string/strchr.cpp"],
3812    hdrs = ["src/string/strchr.h"],
3813    deps = [
3814        ":__support_common",
3815        ":string_utils",
3816    ],
3817)
3818
3819libc_function(
3820    name = "strrchr",
3821    srcs = ["src/string/strrchr.cpp"],
3822    hdrs = ["src/string/strrchr.h"],
3823    deps = [
3824        ":__support_common",
3825        ":string_utils",
3826    ],
3827)
3828
3829libc_function(
3830    name = "strstr",
3831    srcs = ["src/string/strstr.cpp"],
3832    hdrs = ["src/string/strstr.h"],
3833    deps = [
3834        ":__support_common",
3835        ":string_memory_utils",
3836        ":string_utils",
3837    ],
3838)
3839
3840libc_function(
3841    name = "strnlen",
3842    srcs = ["src/string/strnlen.cpp"],
3843    hdrs = ["src/string/strnlen.h"],
3844    deps = [
3845        ":__support_common",
3846        ":string_utils",
3847    ],
3848)
3849
3850libc_function(
3851    name = "strcspn",
3852    srcs = ["src/string/strcspn.cpp"],
3853    hdrs = ["src/string/strcspn.h"],
3854    deps = [
3855        ":__support_common",
3856        ":string_utils",
3857    ],
3858)
3859
3860libc_function(
3861    name = "strspn",
3862    srcs = ["src/string/strspn.cpp"],
3863    hdrs = ["src/string/strspn.h"],
3864    deps = [
3865        ":__support_common",
3866        ":__support_cpp_bitset",
3867        ":string_utils",
3868    ],
3869)
3870
3871libc_function(
3872    name = "strpbrk",
3873    srcs = ["src/string/strpbrk.cpp"],
3874    hdrs = ["src/string/strpbrk.h"],
3875    deps = [
3876        ":__support_common",
3877        ":string_utils",
3878    ],
3879)
3880
3881libc_function(
3882    name = "strtok",
3883    srcs = ["src/string/strtok.cpp"],
3884    hdrs = ["src/string/strtok.h"],
3885    deps = [
3886        ":__support_common",
3887        ":string_utils",
3888    ],
3889)
3890
3891################################ fcntl targets #################################
3892
3893libc_function(
3894    name = "open",
3895    srcs = ["src/fcntl/linux/open.cpp"],
3896    hdrs = ["src/fcntl/open.h"],
3897    target_compatible_with = select({
3898        "@platforms//os:linux": [],
3899        "//conditions:default": ["@platforms//:incompatible"],
3900    }),
3901    deps = [
3902        ":__support_common",
3903        ":__support_osutil_syscall",
3904        ":errno",
3905        ":hdr_fcntl_macros",
3906        ":types_mode_t",
3907    ],
3908)
3909
3910libc_function(
3911    name = "openat",
3912    srcs = ["src/fcntl/linux/openat.cpp"],
3913    hdrs = ["src/fcntl/openat.h"],
3914    target_compatible_with = select({
3915        "@platforms//os:linux": [],
3916        "//conditions:default": ["@platforms//:incompatible"],
3917    }),
3918    deps = [
3919        ":__support_common",
3920        ":__support_osutil_syscall",
3921        ":errno",
3922        ":hdr_fcntl_macros",
3923        ":types_mode_t",
3924    ],
3925)
3926
3927libc_function(
3928    name = "creat",
3929    srcs = ["src/fcntl/linux/creat.cpp"],
3930    hdrs = ["src/fcntl/creat.h"],
3931    deps = [
3932        ":__support_common",
3933        ":__support_osutil_syscall",
3934        ":errno",
3935        ":hdr_fcntl_macros",
3936    ],
3937)
3938
3939################################ unistd targets ################################
3940
3941libc_function(
3942    name = "access",
3943    srcs = ["src/unistd/linux/access.cpp"],
3944    hdrs = ["src/unistd/access.h"],
3945    deps = [
3946        ":__support_common",
3947        ":__support_osutil_syscall",
3948        ":errno",
3949        ":hdr_fcntl_macros",
3950    ],
3951)
3952
3953libc_function(
3954    name = "chdir",
3955    srcs = ["src/unistd/linux/chdir.cpp"],
3956    hdrs = ["src/unistd/chdir.h"],
3957    deps = [
3958        ":__support_common",
3959        ":__support_osutil_syscall",
3960        ":errno",
3961    ],
3962)
3963
3964libc_function(
3965    name = "close",
3966    srcs = ["src/unistd/linux/close.cpp"],
3967    hdrs = ["src/unistd/close.h"],
3968    deps = [
3969        ":__support_common",
3970        ":__support_osutil_syscall",
3971        ":errno",
3972    ],
3973)
3974
3975libc_function(
3976    name = "dup",
3977    srcs = ["src/unistd/linux/dup.cpp"],
3978    hdrs = ["src/unistd/dup.h"],
3979    deps = [
3980        ":__support_common",
3981        ":__support_osutil_syscall",
3982        ":errno",
3983        ":hdr_unistd_macros",
3984    ],
3985)
3986
3987libc_function(
3988    name = "dup2",
3989    srcs = ["src/unistd/linux/dup2.cpp"],
3990    hdrs = ["src/unistd/dup2.h"],
3991    deps = [
3992        ":__support_common",
3993        ":__support_osutil_syscall",
3994        ":errno",
3995        ":hdr_fcntl_macros",
3996        ":hdr_unistd_macros",
3997    ],
3998)
3999
4000libc_function(
4001    name = "dup3",
4002    srcs = ["src/unistd/linux/dup3.cpp"],
4003    hdrs = ["src/unistd/dup3.h"],
4004    target_compatible_with = select({
4005        "@platforms//os:linux": [],
4006        "//conditions:default": ["@platforms//:incompatible"],
4007    }),
4008    deps = [
4009        ":__support_common",
4010        ":__support_osutil_syscall",
4011        ":errno",
4012        ":hdr_unistd_macros",
4013    ],
4014)
4015
4016libc_function(
4017    name = "environ",
4018    srcs = ["src/unistd/environ.cpp"],
4019    hdrs = ["src/unistd/environ.h"],
4020    deps = [
4021        ":__support_common",
4022        ":__support_osutil_syscall",
4023        ":errno",
4024    ],
4025)
4026
4027libc_function(
4028    name = "fchdir",
4029    srcs = ["src/unistd/linux/fchdir.cpp"],
4030    hdrs = ["src/unistd/fchdir.h"],
4031    deps = [
4032        ":__support_common",
4033        ":__support_osutil_syscall",
4034        ":errno",
4035    ],
4036)
4037
4038libc_function(
4039    name = "fsync",
4040    srcs = ["src/unistd/linux/fsync.cpp"],
4041    hdrs = ["src/unistd/fsync.h"],
4042    deps = [
4043        ":__support_common",
4044        ":__support_osutil_syscall",
4045        ":errno",
4046    ],
4047)
4048
4049libc_function(
4050    name = "ftruncate",
4051    srcs = ["src/unistd/linux/ftruncate.cpp"],
4052    hdrs = ["src/unistd/ftruncate.h"],
4053    deps = [
4054        ":__support_common",
4055        ":__support_osutil_syscall",
4056        ":errno",
4057        ":hdr_unistd_macros",
4058        ":types_off_t",
4059    ],
4060)
4061
4062# libc_function(
4063#     name = "getcwd",
4064#     srcs = ["src/unistd/linux/getcwd.cpp"],
4065#     hdrs = ["src/unistd/getcwd.h"],
4066#     deps = [
4067#         ":__support_common",
4068#         ":__support_osutil_syscall",
4069#         ":errno",
4070#         ":hdr_unistd_macros",
4071#         ":types_size_t",
4072#     ],
4073# )
4074
4075libc_function(
4076    name = "geteuid",
4077    srcs = ["src/unistd/linux/geteuid.cpp"],
4078    hdrs = ["src/unistd/geteuid.h"],
4079    deps = [
4080        ":__support_common",
4081        ":__support_osutil_syscall",
4082        ":errno",
4083        ":hdr_unistd_macros",
4084        ":types_size_t",
4085        ":types_uid_t",
4086    ],
4087)
4088
4089libc_function(
4090    name = "getppid",
4091    srcs = ["src/unistd/linux/getppid.cpp"],
4092    hdrs = ["src/unistd/getppid.h"],
4093    deps = [
4094        ":__support_common",
4095        ":__support_osutil_syscall",
4096        ":errno",
4097        ":hdr_unistd_macros",
4098        ":types_pid_t",
4099    ],
4100)
4101
4102libc_function(
4103    name = "getuid",
4104    srcs = ["src/unistd/linux/getuid.cpp"],
4105    hdrs = ["src/unistd/getuid.h"],
4106    deps = [
4107        ":__support_common",
4108        ":__support_osutil_syscall",
4109        ":errno",
4110        ":hdr_unistd_macros",
4111        ":types_uid_t",
4112    ],
4113)
4114
4115# libc_function(
4116#     name = "getopt",
4117#     srcs = ["src/unistd/getopt.cpp"],
4118#     hdrs = ["src/unistd/getopt.h"],
4119#     deps = [
4120#         ":__support_common",
4121#         ":__support_cpp_optional",
4122#         ":__support_cpp_string_view",
4123#         ":__support_file_file",
4124#         ":__support_osutil_syscall",
4125#         ":errno",
4126#         ":hdr_unistd_macros",
4127#     ],
4128# )
4129
4130libc_function(
4131    name = "isatty",
4132    srcs = ["src/unistd/linux/isatty.cpp"],
4133    hdrs = ["src/unistd/isatty.h"],
4134    deps = [
4135        ":__support_common",
4136        ":__support_osutil_syscall",
4137        ":errno",
4138        ":hdr_unistd_macros",
4139    ],
4140)
4141
4142libc_function(
4143    name = "link",
4144    srcs = ["src/unistd/linux/link.cpp"],
4145    hdrs = ["src/unistd/link.h"],
4146    deps = [
4147        ":__support_common",
4148        ":__support_osutil_syscall",
4149        ":errno",
4150        ":hdr_fcntl_macros",
4151        ":hdr_unistd_macros",
4152    ],
4153)
4154
4155libc_function(
4156    name = "linkat",
4157    srcs = ["src/unistd/linux/linkat.cpp"],
4158    hdrs = ["src/unistd/linkat.h"],
4159    deps = [
4160        ":__support_common",
4161        ":__support_osutil_syscall",
4162        ":errno",
4163        ":hdr_fcntl_macros",
4164        ":hdr_unistd_macros",
4165    ],
4166)
4167
4168libc_function(
4169    name = "pipe",
4170    srcs = ["src/unistd/linux/pipe.cpp"],
4171    hdrs = ["src/unistd/pipe.h"],
4172    deps = [
4173        ":__support_common",
4174        ":__support_macros_sanitizer",
4175        ":__support_osutil_syscall",
4176        ":errno",
4177    ],
4178)
4179
4180libc_function(
4181    name = "lseek",
4182    srcs = ["src/unistd/linux/lseek.cpp"],
4183    hdrs = ["src/unistd/lseek.h"],
4184    deps = [
4185        ":__support_common",
4186        ":__support_file_linux_lseekimpl",
4187        ":__support_osutil_syscall",
4188        ":errno",
4189        ":hdr_unistd_macros",
4190        ":types_off_t",
4191    ],
4192)
4193
4194libc_function(
4195    name = "pread",
4196    srcs = ["src/unistd/linux/pread.cpp"],
4197    hdrs = ["src/unistd/pread.h"],
4198    target_compatible_with = select({
4199        "@platforms//os:linux": [],
4200        "//conditions:default": ["@platforms//:incompatible"],
4201    }),
4202    deps = [
4203        ":__support_common",
4204        ":__support_macros_sanitizer",
4205        ":__support_osutil_syscall",
4206        ":errno",
4207        ":hdr_unistd_macros",
4208        ":types_off_t",
4209        ":types_size_t",
4210        ":types_ssize_t",
4211    ],
4212)
4213
4214libc_function(
4215    name = "pwrite",
4216    srcs = ["src/unistd/linux/pwrite.cpp"],
4217    hdrs = ["src/unistd/pwrite.h"],
4218    target_compatible_with = select({
4219        "@platforms//os:linux": [],
4220        "//conditions:default": ["@platforms//:incompatible"],
4221    }),
4222    deps = [
4223        ":__support_common",
4224        ":__support_osutil_syscall",
4225        ":errno",
4226        ":hdr_unistd_macros",
4227        ":types_off_t",
4228        ":types_size_t",
4229        ":types_ssize_t",
4230    ],
4231)
4232
4233libc_function(
4234    name = "read",
4235    srcs = ["src/unistd/linux/read.cpp"],
4236    hdrs = ["src/unistd/read.h"],
4237    weak = True,
4238    deps = [
4239        ":__support_common",
4240        ":__support_macros_sanitizer",
4241        ":__support_osutil_syscall",
4242        ":errno",
4243        ":hdr_unistd_macros",
4244        ":types_size_t",
4245        ":types_ssize_t",
4246    ],
4247)
4248
4249libc_function(
4250    name = "readlink",
4251    srcs = ["src/unistd/linux/readlink.cpp"],
4252    hdrs = ["src/unistd/readlink.h"],
4253    deps = [
4254        ":__support_common",
4255        ":__support_osutil_syscall",
4256        ":errno",
4257        ":hdr_fcntl_macros",
4258        ":hdr_unistd_macros",
4259        ":types_size_t",
4260        ":types_ssize_t",
4261    ],
4262)
4263
4264libc_function(
4265    name = "readlinkat",
4266    srcs = ["src/unistd/linux/readlinkat.cpp"],
4267    hdrs = ["src/unistd/readlinkat.h"],
4268    deps = [
4269        ":__support_common",
4270        ":__support_osutil_syscall",
4271        ":errno",
4272        ":hdr_fcntl_macros",
4273        ":hdr_unistd_macros",
4274        ":types_size_t",
4275        ":types_ssize_t",
4276    ],
4277)
4278
4279libc_function(
4280    name = "rmdir",
4281    srcs = ["src/unistd/linux/rmdir.cpp"],
4282    hdrs = ["src/unistd/rmdir.h"],
4283    deps = [
4284        ":__support_common",
4285        ":__support_osutil_syscall",
4286        ":errno",
4287        ":hdr_fcntl_macros",
4288    ],
4289)
4290
4291libc_function(
4292    name = "symlink",
4293    srcs = ["src/unistd/linux/symlink.cpp"],
4294    hdrs = ["src/unistd/symlink.h"],
4295    deps = [
4296        ":__support_common",
4297        ":__support_osutil_syscall",
4298        ":errno",
4299        ":hdr_fcntl_macros",
4300        ":hdr_unistd_macros",
4301    ],
4302)
4303
4304libc_function(
4305    name = "symlinkat",
4306    srcs = ["src/unistd/linux/symlinkat.cpp"],
4307    hdrs = ["src/unistd/symlinkat.h"],
4308    deps = [
4309        ":__support_common",
4310        ":__support_osutil_syscall",
4311        ":errno",
4312        ":hdr_fcntl_macros",
4313        ":hdr_unistd_macros",
4314    ],
4315)
4316
4317#TODO: Enable once fullbuild is added to bazel, since this depends on a macro
4318# definition in the public header
4319
4320# libc_function(
4321#     name = "syscall",
4322#     srcs = ["src/unistd/linux/syscall.cpp"],
4323#     hdrs = ["src/unistd/syscall.h"],
4324#     deps = [
4325#         ":__support_common",
4326#         ":__support_osutil_syscall",
4327#         ":errno",
4328#         ":hdr_unistd_macros",
4329#     ],
4330# )
4331
4332libc_function(
4333    name = "swab",
4334    srcs = ["src/unistd/swab.cpp"],
4335    hdrs = ["src/unistd/swab.h"],
4336    deps = [
4337        ":__support_common",
4338        ":__support_osutil_syscall",
4339        ":errno",
4340        ":hdr_unistd_macros",
4341        ":types_ssize_t",
4342    ],
4343)
4344
4345libc_function(
4346    name = "truncate",
4347    srcs = ["src/unistd/linux/truncate.cpp"],
4348    hdrs = ["src/unistd/truncate.h"],
4349    deps = [
4350        ":__support_common",
4351        ":__support_osutil_syscall",
4352        ":errno",
4353        ":hdr_unistd_macros",
4354        ":types_off_t",
4355    ],
4356)
4357
4358libc_function(
4359    name = "unlink",
4360    srcs = ["src/unistd/linux/unlink.cpp"],
4361    hdrs = ["src/unistd/unlink.h"],
4362    deps = [
4363        ":__support_common",
4364        ":__support_osutil_syscall",
4365        ":errno",
4366        ":hdr_fcntl_macros",
4367    ],
4368)
4369
4370libc_function(
4371    name = "unlinkat",
4372    srcs = ["src/unistd/linux/unlinkat.cpp"],
4373    hdrs = ["src/unistd/unlinkat.h"],
4374    deps = [
4375        ":__support_common",
4376        ":__support_osutil_syscall",
4377        ":errno",
4378        ":hdr_fcntl_macros",
4379    ],
4380)
4381
4382libc_function(
4383    name = "write",
4384    srcs = ["src/unistd/linux/write.cpp"],
4385    hdrs = ["src/unistd/write.h"],
4386    weak = True,
4387    deps = [
4388        ":__support_common",
4389        ":__support_osutil_syscall",
4390        ":errno",
4391        ":hdr_unistd_macros",
4392        ":types_size_t",
4393        ":types_ssize_t",
4394    ],
4395)
4396
4397################################ stdio targets #################################
4398
4399libc_support_library(
4400    name = "printf_config",
4401    hdrs = ["src/stdio/printf_core/printf_config.h"],
4402    deps = [
4403    ],
4404)
4405
4406libc_support_library(
4407    name = "printf_core_structs",
4408    hdrs = ["src/stdio/printf_core/core_structs.h"],
4409    deps = [
4410        ":__support_cpp_string_view",
4411        ":__support_fputil_fp_bits",
4412        ":printf_config",
4413    ],
4414)
4415
4416libc_support_library(
4417    name = "printf_parser",
4418    hdrs = ["src/stdio/printf_core/parser.h"],
4419    deps = [
4420        ":__support_arg_list",
4421        ":__support_common",
4422        ":__support_cpp_algorithm",
4423        ":__support_cpp_bit",
4424        ":__support_cpp_optional",
4425        ":__support_cpp_string_view",
4426        ":__support_cpp_type_traits",
4427        ":__support_ctype_utils",
4428        ":__support_fputil_fp_bits",
4429        ":__support_str_to_integer",
4430        ":errno",
4431        ":printf_config",
4432        ":printf_core_structs",
4433    ],
4434)
4435
4436libc_support_library(
4437    name = "printf_writer",
4438    srcs = ["src/stdio/printf_core/writer.cpp"],
4439    hdrs = ["src/stdio/printf_core/writer.h"],
4440    deps = [
4441        ":__support_cpp_string_view",
4442        ":__support_macros_optimization",
4443        ":printf_core_structs",
4444        ":string_memory_utils",
4445    ],
4446)
4447
4448libc_support_library(
4449    name = "printf_converter",
4450    srcs = ["src/stdio/printf_core/converter.cpp"],
4451    hdrs = [
4452        "src/stdio/printf_core/char_converter.h",
4453        "src/stdio/printf_core/converter.h",
4454        "src/stdio/printf_core/converter_atlas.h",
4455        "src/stdio/printf_core/converter_utils.h",
4456        "src/stdio/printf_core/float_dec_converter.h",
4457        "src/stdio/printf_core/float_hex_converter.h",
4458        "src/stdio/printf_core/float_inf_nan_converter.h",
4459        "src/stdio/printf_core/int_converter.h",
4460        "src/stdio/printf_core/ptr_converter.h",
4461        "src/stdio/printf_core/strerror_converter.h",
4462        "src/stdio/printf_core/string_converter.h",
4463        "src/stdio/printf_core/write_int_converter.h",
4464    ],
4465    deps = [
4466        ":__support_big_int",
4467        ":__support_common",
4468        ":__support_cpp_limits",
4469        ":__support_cpp_span",
4470        ":__support_cpp_string_view",
4471        ":__support_ctype_utils",
4472        ":__support_float_to_string",
4473        ":__support_fputil_fenv_impl",
4474        ":__support_fputil_fp_bits",
4475        ":__support_fputil_rounding_mode",
4476        ":__support_integer_to_string",
4477        ":__support_libc_assert",
4478        ":__support_stringutil",
4479        ":__support_uint128",
4480        ":printf_config",
4481        ":printf_core_structs",
4482        ":printf_writer",
4483    ],
4484)
4485
4486libc_support_library(
4487    name = "printf_main",
4488    srcs = ["src/stdio/printf_core/printf_main.cpp"],
4489    hdrs = ["src/stdio/printf_core/printf_main.h"],
4490    deps = [
4491        ":__support_arg_list",
4492        ":printf_converter",
4493        ":printf_core_structs",
4494        ":printf_parser",
4495        ":printf_writer",
4496    ],
4497)
4498
4499libc_support_library(
4500    name = "vfprintf_internal",
4501    hdrs = ["src/stdio/printf_core/vfprintf_internal.h"],
4502    deps = [
4503        ":__support_arg_list",
4504        ":__support_file_file",
4505        ":__support_macros_attributes",
4506        ":printf_main",
4507        ":printf_writer",
4508        ":types_FILE",
4509    ],
4510)
4511
4512libc_function(
4513    name = "sprintf",
4514    srcs = ["src/stdio/sprintf.cpp"],
4515    hdrs = ["src/stdio/sprintf.h"],
4516    deps = [
4517        ":__support_arg_list",
4518        ":__support_cpp_limits",
4519        ":errno",
4520        ":printf_main",
4521        ":printf_writer",
4522    ],
4523)
4524
4525libc_function(
4526    name = "snprintf",
4527    srcs = ["src/stdio/snprintf.cpp"],
4528    hdrs = ["src/stdio/snprintf.h"],
4529    deps = [
4530        ":__support_arg_list",
4531        ":errno",
4532        ":printf_main",
4533        ":printf_writer",
4534    ],
4535)
4536
4537libc_function(
4538    name = "printf",
4539    srcs = ["src/stdio/generic/printf.cpp"],
4540    hdrs = ["src/stdio/printf.h"],
4541    deps = [
4542        ":__support_arg_list",
4543        ":__support_file_file",
4544        ":errno",
4545        ":types_FILE",
4546        ":vfprintf_internal",
4547    ],
4548)
4549
4550libc_function(
4551    name = "fprintf",
4552    srcs = ["src/stdio/generic/fprintf.cpp"],
4553    hdrs = ["src/stdio/fprintf.h"],
4554    deps = [
4555        ":__support_arg_list",
4556        ":__support_file_file",
4557        ":errno",
4558        ":types_FILE",
4559        ":vfprintf_internal",
4560    ],
4561)
4562
4563libc_function(
4564    name = "vsprintf",
4565    srcs = ["src/stdio/vsprintf.cpp"],
4566    hdrs = ["src/stdio/vsprintf.h"],
4567    deps = [
4568        ":__support_arg_list",
4569        ":__support_cpp_limits",
4570        ":errno",
4571        ":printf_main",
4572        ":printf_writer",
4573    ],
4574)
4575
4576libc_function(
4577    name = "vsnprintf",
4578    srcs = ["src/stdio/vsnprintf.cpp"],
4579    hdrs = ["src/stdio/vsnprintf.h"],
4580    deps = [
4581        ":__support_arg_list",
4582        ":errno",
4583        ":printf_main",
4584        ":printf_writer",
4585    ],
4586)
4587
4588libc_function(
4589    name = "vprintf",
4590    srcs = ["src/stdio/generic/vprintf.cpp"],
4591    hdrs = ["src/stdio/vprintf.h"],
4592    deps = [
4593        ":__support_arg_list",
4594        ":__support_file_file",
4595        ":errno",
4596        ":types_FILE",
4597        ":vfprintf_internal",
4598    ],
4599)
4600
4601libc_function(
4602    name = "vfprintf",
4603    srcs = ["src/stdio/generic/vfprintf.cpp"],
4604    hdrs = ["src/stdio/vfprintf.h"],
4605    deps = [
4606        ":__support_arg_list",
4607        ":__support_file_file",
4608        ":errno",
4609        ":types_FILE",
4610        ":vfprintf_internal",
4611    ],
4612)
4613
4614libc_function(
4615    name = "remove",
4616    srcs = ["src/stdio/linux/remove.cpp"],
4617    hdrs = ["src/stdio/remove.h"],
4618    deps = [
4619        ":__support_common",
4620        ":__support_osutil_syscall",
4621        ":errno",
4622        ":hdr_fcntl_macros",
4623        ":hdr_stdio_overlay",
4624        ":types_FILE",
4625    ],
4626)
4627
4628libc_function(
4629    name = "rename",
4630    srcs = ["src/stdio/linux/rename.cpp"],
4631    hdrs = ["src/stdio/rename.h"],
4632    target_compatible_with = select({
4633        "@platforms//os:linux": [],
4634        "//conditions:default": ["@platforms//:incompatible"],
4635    }),
4636    deps = [
4637        ":__support_common",
4638        ":__support_osutil_syscall",
4639        ":errno",
4640        ":hdr_fcntl_macros",
4641        ":llvm_libc_macros_fcntl_macros",
4642    ],
4643)
4644
4645############################### sys/stat targets ###############################
4646
4647libc_function(
4648    name = "mkdir",
4649    srcs = ["src/sys/stat/linux/mkdir.cpp"],
4650    hdrs = ["src/sys/stat/mkdir.h"],
4651    deps = [
4652        ":__support_common",
4653        ":__support_osutil_syscall",
4654        ":errno",
4655        ":hdr_fcntl_macros",
4656        ":types_mode_t",
4657    ],
4658)
4659
4660libc_function(
4661    name = "mkdirat",
4662    srcs = ["src/sys/stat/linux/mkdirat.cpp"],
4663    hdrs = ["src/sys/stat/mkdirat.h"],
4664    deps = [
4665        ":__support_common",
4666        ":__support_osutil_syscall",
4667        ":errno",
4668    ],
4669)
4670
4671############################## sys/socket targets ##############################
4672
4673libc_function(
4674    name = "socket",
4675    srcs = ["src/sys/socket/linux/socket.cpp"],
4676    hdrs = ["src/sys/socket/socket.h"],
4677    weak = True,
4678    deps = [
4679        ":__support_common",
4680        ":__support_osutil_syscall",
4681        ":errno",
4682    ],
4683)
4684
4685libc_function(
4686    name = "socketpair",
4687    srcs = ["src/sys/socket/linux/socketpair.cpp"],
4688    hdrs = ["src/sys/socket/socketpair.h"],
4689    weak = True,
4690    deps = [
4691        ":__support_common",
4692        ":__support_osutil_syscall",
4693        ":errno",
4694    ],
4695)
4696
4697libc_function(
4698    name = "send",
4699    srcs = ["src/sys/socket/linux/send.cpp"],
4700    hdrs = ["src/sys/socket/send.h"],
4701    weak = True,
4702    deps = [
4703        ":__support_common",
4704        ":__support_osutil_syscall",
4705        ":errno",
4706        ":types_socklen_t",
4707        ":types_ssize_t",
4708        ":types_struct_sockaddr",
4709    ],
4710)
4711
4712libc_function(
4713    name = "sendto",
4714    srcs = ["src/sys/socket/linux/sendto.cpp"],
4715    hdrs = ["src/sys/socket/sendto.h"],
4716    weak = True,
4717    deps = [
4718        ":__support_common",
4719        ":__support_osutil_syscall",
4720        ":errno",
4721        ":types_socklen_t",
4722        ":types_ssize_t",
4723        ":types_struct_sockaddr",
4724    ],
4725)
4726
4727libc_function(
4728    name = "sendmsg",
4729    srcs = ["src/sys/socket/linux/sendmsg.cpp"],
4730    hdrs = ["src/sys/socket/sendmsg.h"],
4731    weak = True,
4732    deps = [
4733        ":__support_common",
4734        ":__support_osutil_syscall",
4735        ":errno",
4736        ":types_ssize_t",
4737        ":types_struct_msghdr",
4738    ],
4739)
4740
4741libc_function(
4742    name = "recv",
4743    srcs = ["src/sys/socket/linux/recv.cpp"],
4744    hdrs = ["src/sys/socket/recv.h"],
4745    weak = True,
4746    deps = [
4747        ":__support_common",
4748        ":__support_osutil_syscall",
4749        ":errno",
4750        ":types_socklen_t",
4751        ":types_ssize_t",
4752        ":types_struct_sockaddr",
4753    ],
4754)
4755
4756libc_function(
4757    name = "recvfrom",
4758    srcs = ["src/sys/socket/linux/recvfrom.cpp"],
4759    hdrs = ["src/sys/socket/recvfrom.h"],
4760    weak = True,
4761    deps = [
4762        ":__support_common",
4763        ":__support_osutil_syscall",
4764        ":errno",
4765        ":types_socklen_t",
4766        ":types_ssize_t",
4767        ":types_struct_sockaddr",
4768    ],
4769)
4770
4771libc_function(
4772    name = "recvmsg",
4773    srcs = ["src/sys/socket/linux/recvmsg.cpp"],
4774    hdrs = ["src/sys/socket/recvmsg.h"],
4775    weak = True,
4776    deps = [
4777        ":__support_common",
4778        ":__support_osutil_syscall",
4779        ":errno",
4780        ":types_ssize_t",
4781        ":types_struct_msghdr",
4782    ],
4783)
4784
4785############################## sys/epoll targets ###############################
4786
4787libc_function(
4788    name = "epoll_create",
4789    srcs = ["src/sys/epoll/linux/epoll_create.cpp"],
4790    hdrs = ["src/sys/epoll/epoll_create.h"],
4791    target_compatible_with = select({
4792        "@platforms//os:linux": [],
4793        "//conditions:default": ["@platforms//:incompatible"],
4794    }),
4795    weak = True,
4796    deps = [
4797        ":__support_osutil_syscall",
4798        ":errno",
4799    ],
4800)
4801
4802libc_function(
4803    name = "epoll_create1",
4804    srcs = ["src/sys/epoll/linux/epoll_create1.cpp"],
4805    hdrs = ["src/sys/epoll/epoll_create1.h"],
4806    target_compatible_with = select({
4807        "@platforms//os:linux": [],
4808        "//conditions:default": ["@platforms//:incompatible"],
4809    }),
4810    weak = True,
4811    deps = [
4812        ":__support_osutil_syscall",
4813        ":errno",
4814    ],
4815)
4816
4817libc_function(
4818    name = "epoll_ctl",
4819    srcs = ["src/sys/epoll/linux/epoll_ctl.cpp"],
4820    hdrs = ["src/sys/epoll/epoll_ctl.h"],
4821    target_compatible_with = select({
4822        "@platforms//os:linux": [],
4823        "//conditions:default": ["@platforms//:incompatible"],
4824    }),
4825    weak = True,
4826    deps = [
4827        ":__support_osutil_syscall",
4828        ":errno",
4829        ":hdr_sys_epoll_macros",
4830        ":types_struct_epoll_event",
4831    ],
4832)
4833
4834libc_function(
4835    name = "epoll_wait",
4836    srcs = ["src/sys/epoll/linux/epoll_wait.cpp"],
4837    hdrs = ["src/sys/epoll/epoll_wait.h"],
4838    target_compatible_with = select({
4839        "@platforms//os:linux": [],
4840        "//conditions:default": ["@platforms//:incompatible"],
4841    }),
4842    weak = True,
4843    deps = [
4844        ":__support_macros_sanitizer",
4845        ":__support_osutil_syscall",
4846        ":errno",
4847        ":hdr_signal_macros",
4848        ":hdr_sys_epoll_macros",
4849        ":types_sigset_t",
4850        ":types_struct_epoll_event",
4851    ],
4852)
4853
4854libc_function(
4855    name = "epoll_pwait",
4856    srcs = ["src/sys/epoll/linux/epoll_pwait.cpp"],
4857    hdrs = ["src/sys/epoll/epoll_pwait.h"],
4858    target_compatible_with = select({
4859        "@platforms//os:linux": [],
4860        "//conditions:default": ["@platforms//:incompatible"],
4861    }),
4862    weak = True,
4863    deps = [
4864        ":__support_macros_sanitizer",
4865        ":__support_osutil_syscall",
4866        ":errno",
4867        ":hdr_signal_macros",
4868        ":hdr_sys_epoll_macros",
4869        ":types_sigset_t",
4870        ":types_struct_epoll_event",
4871    ],
4872)
4873
4874libc_function(
4875    name = "epoll_pwait2",
4876    srcs = ["src/sys/epoll/linux/epoll_pwait2.cpp"],
4877    hdrs = ["src/sys/epoll/epoll_pwait2.h"],
4878    target_compatible_with = select({
4879        "@platforms//os:linux": [],
4880        "//conditions:default": ["@platforms//:incompatible"],
4881    }),
4882    weak = True,
4883    deps = [
4884        ":__support_macros_sanitizer",
4885        ":__support_osutil_syscall",
4886        ":errno",
4887        ":hdr_signal_macros",
4888        ":hdr_sys_epoll_macros",
4889        ":types_sigset_t",
4890        ":types_struct_epoll_event",
4891        ":types_struct_timespec",
4892    ],
4893)
4894