573 lines · plain
1# Helper to only add the generic implementations if they aren't handled by a2# more specific implementation.3# TODO: This should probably be cleaned up and formalized.4function(add_generic_entrypoint_object name)5 if(NOT TARGET libc.src.stdio.${LIBC_TARGET_OS}.${name})6 add_entrypoint_object(7 ${name}8 ${ARGN}9 )10 endif()11endfunction(add_generic_entrypoint_object)12 13add_generic_entrypoint_object(14 clearerr15 SRCS16 clearerr.cpp17 HDRS18 ../clearerr.h19 DEPENDS20 libc.hdr.types.FILE21 libc.src.__support.File.file22 libc.src.__support.File.platform_file23)24 25add_generic_entrypoint_object(26 clearerr_unlocked27 SRCS28 clearerr_unlocked.cpp29 HDRS30 ../clearerr_unlocked.h31 DEPENDS32 libc.hdr.types.FILE33 libc.src.__support.File.file34 libc.src.__support.File.platform_file35)36 37add_generic_entrypoint_object(38 feof39 SRCS40 feof.cpp41 HDRS42 ../feof.h43 DEPENDS44 libc.hdr.types.FILE45 libc.src.__support.File.file46 libc.src.__support.File.platform_file47)48 49add_generic_entrypoint_object(50 feof_unlocked51 SRCS52 feof_unlocked.cpp53 HDRS54 ../feof_unlocked.h55 DEPENDS56 libc.hdr.types.FILE57 libc.src.__support.File.file58 libc.src.__support.File.platform_file59)60 61add_generic_entrypoint_object(62 ferror63 SRCS64 ferror.cpp65 HDRS66 ../ferror.h67 DEPENDS68 libc.hdr.types.FILE69 libc.src.__support.File.file70 libc.src.__support.File.platform_file71)72 73add_generic_entrypoint_object(74 ferror_unlocked75 SRCS76 ferror_unlocked.cpp77 HDRS78 ../ferror_unlocked.h79 DEPENDS80 libc.hdr.types.FILE81 libc.src.__support.File.file82 libc.src.__support.File.platform_file83)84 85add_generic_entrypoint_object(86 fileno87 SRCS88 fileno.cpp89 HDRS90 ../fileno.h91 DEPENDS92 libc.hdr.types.FILE93 libc.src.__support.File.file94 libc.src.__support.File.platform_file95)96 97add_generic_entrypoint_object(98 fflush99 SRCS100 fflush.cpp101 HDRS102 ../fflush.h103 DEPENDS104 libc.src.errno.errno105 libc.hdr.types.FILE106 libc.src.__support.File.file107 libc.src.__support.File.platform_file108)109 110add_generic_entrypoint_object(111 fseek112 SRCS113 fseek.cpp114 HDRS115 ../fseek.h116 DEPENDS117 libc.src.errno.errno118 libc.src.__support.File.file119 libc.src.__support.File.platform_file120)121 122add_generic_entrypoint_object(123 ftell124 SRCS125 ftell.cpp126 HDRS127 ../ftell.h128 DEPENDS129 libc.src.errno.errno130 libc.src.__support.File.file131 libc.src.__support.File.platform_file132)133 134add_generic_entrypoint_object(135 fseeko136 SRCS137 fseeko.cpp138 HDRS139 ../fseeko.h140 DEPENDS141 libc.src.errno.errno142 libc.src.__support.File.file143 libc.src.__support.File.platform_file144)145 146add_generic_entrypoint_object(147 ftello148 SRCS149 ftello.cpp150 HDRS151 ../ftello.h152 DEPENDS153 libc.src.errno.errno154 libc.src.__support.File.file155 libc.src.__support.File.platform_file156)157 158add_generic_entrypoint_object(159 fopen160 SRCS161 fopen.cpp162 HDRS163 ../fopen.h164 DEPENDS165 libc.hdr.types.FILE166 libc.src.__support.File.file167 libc.src.__support.File.platform_file168)169 170add_generic_entrypoint_object(171 fclose172 SRCS173 fclose.cpp174 HDRS175 ../fclose.h176 DEPENDS177 libc.hdr.types.FILE178 libc.src.errno.errno179 libc.src.__support.File.file180 libc.src.__support.File.platform_file181)182 183add_generic_entrypoint_object(184 fread_unlocked185 SRCS186 fread_unlocked.cpp187 HDRS188 ../fread_unlocked.h189 DEPENDS190 libc.src.errno.errno191 libc.hdr.types.FILE192 libc.src.__support.File.file193 libc.src.__support.File.platform_file194)195 196add_generic_entrypoint_object(197 fread198 SRCS199 fread.cpp200 HDRS201 ../fread.h202 DEPENDS203 libc.src.errno.errno204 libc.hdr.types.FILE205 libc.src.__support.File.file206 libc.src.__support.File.platform_file207)208 209add_generic_entrypoint_object(210 perror211 SRCS212 perror.cpp213 HDRS214 ../perror.h215 DEPENDS216 libc.src.errno.errno217 libc.src.__support.StringUtil.error_to_string218 libc.src.__support.CPP.string_view219 libc.src.__support.File.file220 libc.src.__support.File.platform_file221 libc.src.__support.File.platform_stderr222)223 224add_generic_entrypoint_object(225 fputs226 SRCS227 fputs.cpp228 HDRS229 ../fputs.h230 DEPENDS231 libc.src.errno.errno232 libc.hdr.types.FILE233 libc.src.__support.File.file234 libc.src.__support.File.platform_file235)236 237add_generic_entrypoint_object(238 puts239 SRCS240 puts.cpp241 HDRS242 ../puts.h243 DEPENDS244 libc.src.errno.errno245 libc.hdr.types.FILE246 libc.src.__support.File.file247 libc.src.__support.File.platform_stdout248)249 250add_generic_entrypoint_object(251 fwrite_unlocked252 SRCS253 fwrite_unlocked.cpp254 HDRS255 ../fwrite_unlocked.h256 DEPENDS257 libc.src.errno.errno258 libc.hdr.types.FILE259 libc.src.__support.File.file260 libc.src.__support.File.platform_file261)262 263add_generic_entrypoint_object(264 fwrite265 SRCS266 fwrite.cpp267 HDRS268 ../fwrite.h269 DEPENDS270 libc.src.errno.errno271 libc.hdr.types.FILE272 libc.src.__support.File.file273 libc.src.__support.File.platform_file274)275 276add_generic_entrypoint_object(277 fputc278 SRCS279 fputc.cpp280 HDRS281 ../fputc.h282 DEPENDS283 libc.src.errno.errno284 libc.hdr.types.FILE285 libc.src.__support.File.file286 libc.src.__support.File.platform_file287)288 289add_generic_entrypoint_object(290 putc291 SRCS292 putc.cpp293 HDRS294 ../putc.h295 DEPENDS296 libc.src.errno.errno297 libc.hdr.types.FILE298 libc.src.__support.File.file299 libc.src.__support.File.platform_file300)301 302add_generic_entrypoint_object(303 putchar304 SRCS305 putchar.cpp306 HDRS307 ../putchar.h308 DEPENDS309 libc.src.errno.errno310 libc.hdr.types.FILE311 libc.src.__support.File.file312 libc.src.__support.File.platform_file313)314 315add_generic_entrypoint_object(316 fgetc317 SRCS318 fgetc.cpp319 HDRS320 ../fgetc.h321 DEPENDS322 libc.src.errno.errno323 libc.hdr.types.FILE324 libc.src.__support.File.file325 libc.src.__support.File.platform_file326)327 328add_generic_entrypoint_object(329 fgetc_unlocked330 SRCS331 fgetc_unlocked.cpp332 HDRS333 ../fgetc_unlocked.h334 DEPENDS335 libc.src.errno.errno336 libc.hdr.types.FILE337 libc.src.__support.File.file338 libc.src.__support.File.platform_file339)340 341add_generic_entrypoint_object(342 getc343 SRCS344 getc.cpp345 HDRS346 ../getc.h347 DEPENDS348 libc.src.errno.errno349 libc.hdr.types.FILE350 libc.src.__support.File.file351 libc.src.__support.File.platform_file352)353 354add_generic_entrypoint_object(355 getc_unlocked356 SRCS357 getc_unlocked.cpp358 HDRS359 ../getc_unlocked.h360 DEPENDS361 libc.src.errno.errno362 libc.hdr.types.FILE363 libc.src.__support.File.file364 libc.src.__support.File.platform_file365)366 367add_generic_entrypoint_object(368 getchar369 SRCS370 getchar.cpp371 HDRS372 ../getchar.h373 DEPENDS374 libc.src.errno.errno375 libc.hdr.types.FILE376 libc.src.__support.File.file377 libc.src.__support.File.platform_file378)379 380add_generic_entrypoint_object(381 getchar_unlocked382 SRCS383 getchar_unlocked.cpp384 HDRS385 ../getchar_unlocked.h386 DEPENDS387 libc.src.errno.errno388 libc.hdr.types.FILE389 libc.src.__support.File.file390 libc.src.__support.File.platform_file391)392 393list(APPEND fprintf_deps394 libc.hdr.types.FILE395 libc.src.__support.arg_list396 libc.src.__support.CPP.limits397 libc.src.__support.libc_errno398 libc.src.stdio.printf_core.vfprintf_internal399 libc.src.stdio.printf_core.core_structs400 libc.src.stdio.printf_core.error_mapper401)402 403if(LLVM_LIBC_FULL_BUILD)404 list(APPEND fprintf_deps405 libc.src.__support.File.file406 libc.src.__support.File.platform_file407 )408endif()409 410# Copy the deps for printf_deps411set(printf_deps ${fprintf_deps})412 413if(LLVM_LIBC_FULL_BUILD)414 list(APPEND printf_deps415 libc.src.__support.File.platform_stdout416 )417endif()418 419add_generic_entrypoint_object(420 printf421 SRCS422 printf.cpp423 HDRS424 ../printf.h425 DEPENDS426 ${printf_deps}427)428 429add_generic_entrypoint_object(430 vprintf431 SRCS432 vprintf.cpp433 HDRS434 ../vprintf.h435 DEPENDS436 ${printf_deps}437)438 439add_generic_entrypoint_object(440 fprintf441 SRCS442 fprintf.cpp443 HDRS444 ../fprintf.h445 DEPENDS446 ${fprintf_deps}447)448 449add_generic_entrypoint_object(450 vfprintf451 SRCS452 vfprintf.cpp453 HDRS454 ../vfprintf.h455 DEPENDS456 ${fprintf_deps}457)458 459list(APPEND scanf_deps460 libc.src.__support.arg_list461 libc.src.stdio.scanf_core.vfscanf_internal462 libc.hdr.types.FILE463)464 465if(LLVM_LIBC_FULL_BUILD AND NOT LIBC_TARGET_OS_IS_GPU)466 list(APPEND scanf_deps467 libc.src.__support.File.file468 libc.src.__support.File.platform_file469 libc.src.__support.File.platform_stdin470 )471endif()472 473add_generic_entrypoint_object(474 fscanf475 SRCS476 fscanf.cpp477 HDRS478 ../fscanf.h479 DEPENDS480 ${scanf_deps}481)482 483add_generic_entrypoint_object(484 vfscanf485 SRCS486 vfscanf.cpp487 HDRS488 ../vfscanf.h489 DEPENDS490 ${scanf_deps}491)492 493add_generic_entrypoint_object(494 scanf495 SRCS496 scanf.cpp497 HDRS498 ../scanf.h499 DEPENDS500 ${scanf_deps}501)502 503add_generic_entrypoint_object(504 vscanf505 SRCS506 vscanf.cpp507 HDRS508 ../vscanf.h509 DEPENDS510 ${scanf_deps}511)512 513add_generic_entrypoint_object(514 fgets515 SRCS516 fgets.cpp517 HDRS518 ../fgets.h519 DEPENDS520 libc.src.errno.errno521 libc.hdr.types.FILE522 libc.src.__support.File.file523 libc.src.__support.File.platform_file524)525 526add_generic_entrypoint_object(527 ungetc528 SRCS529 ungetc.cpp530 HDRS531 ../ungetc.h532 DEPENDS533 libc.hdr.types.FILE534 libc.src.__support.File.file535 libc.src.__support.File.platform_file536)537 538add_generic_entrypoint_object(539 stdin540 SRCS541 stdin.cpp542 HDRS543 ../stdin.h544 DEPENDS545 libc.hdr.types.FILE546 libc.src.__support.File.file547 libc.src.__support.File.platform_stdin548)549 550add_generic_entrypoint_object(551 stdout552 SRCS553 stdout.cpp554 HDRS555 ../stdout.h556 DEPENDS557 libc.hdr.types.FILE558 libc.src.__support.File.file559 libc.src.__support.File.platform_stdout560)561 562add_generic_entrypoint_object(563 stderr564 SRCS565 stderr.cpp566 HDRS567 ../stderr.h568 DEPENDS569 libc.hdr.types.FILE570 libc.src.__support.File.file571 libc.src.__support.File.platform_stderr572)573