1# Copyright 2023 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_bloat/bloat.gni") 18import("$dir_pw_build/module_config.gni") 19import("$dir_pw_build/target_types.gni") 20import("$dir_pw_docgen/docs.gni") 21import("$dir_pw_fuzzer/fuzz_test.gni") 22import("$dir_pw_sync/backend.gni") 23import("$dir_pw_thread/backend.gni") 24import("$dir_pw_unit_test/test.gni") 25 26# The core target of this module. 27 28pw_source_set("pw_allocator") { 29 public_configs = [ ":public_include_path" ] 30 public = [ 31 "public/pw_allocator/allocator.h", 32 "public/pw_allocator/capability.h", 33 "public/pw_allocator/deallocator.h", 34 "public/pw_allocator/internal/managed_ptr.h", 35 "public/pw_allocator/layout.h", 36 "public/pw_allocator/pool.h", 37 "public/pw_allocator/unique_ptr.h", 38 ] 39 public_deps = [ 40 ":config", 41 ":hardening", 42 "$dir_pw_numeric:checked_arithmetic", 43 dir_pw_bytes, 44 dir_pw_preprocessor, 45 dir_pw_result, 46 dir_pw_status, 47 ] 48 deps = [ 49 "$dir_pw_bytes:alignment", 50 "$dir_pw_third_party/fuchsia:stdcompat", 51 dir_pw_assert, 52 ] 53 sources = [ 54 "allocator.cc", 55 "managed_ptr.cc", 56 ] 57} 58 59# Module configuration 60 61declare_args() { 62 # The build target that overrides the default configuration options for this 63 # module. This should point to a source set that provides defines through a 64 # public config (which may -include a file or add defines directly). 65 pw_allocator_CONFIG = pw_build_DEFAULT_MODULE_CONFIG 66} 67 68config("public_include_path") { 69 include_dirs = [ "public" ] 70 visibility = [ ":*" ] 71} 72 73pw_source_set("config") { 74 public = [ "public/pw_allocator/config.h" ] 75 public_configs = [ ":public_include_path" ] 76 public_deps = [ pw_allocator_CONFIG ] 77} 78 79config("hardening_basic") { 80 defines = [ "PW_ALLOCATOR_HARDENING=PW_ALLOCATOR_HARDENING_BASIC" ] 81} 82 83config("hardening_robust") { 84 defines = [ "PW_ALLOCATOR_HARDENING=PW_ALLOCATOR_HARDENING_ROBUST" ] 85} 86 87config("hardening_debug") { 88 defines = [ "PW_ALLOCATOR_HARDENING=PW_ALLOCATOR_HARDENING_DEBUG" ] 89} 90 91config("test_config") { 92 defines = [ 93 "PW_ALLOCATOR_HARDENING=PW_ALLOCATOR_HARDENING_DEBUG", 94 "PW_ALLOCATOR_BLOCK_POISON_INTERVAL=4", 95 ] 96} 97 98# Libraries 99 100# TODO(b/376730645): Remove deprecated alias. 101group("allocator") { 102 public_deps = [ dir_pw_allocator ] 103} 104 105pw_source_set("allocator_as_pool") { 106 public_configs = [ ":public_include_path" ] 107 public = [ "public/pw_allocator/allocator_as_pool.h" ] 108 public_deps = [ 109 ":pw_allocator", 110 dir_pw_status, 111 ] 112 sources = [ "allocator_as_pool.cc" ] 113} 114 115pw_source_set("best_fit") { 116 public_configs = [ ":public_include_path" ] 117 public = [ "public/pw_allocator/best_fit.h" ] 118 public_deps = [ 119 ":block_allocator", 120 ":config", 121 "block:detailed_block", 122 "bucket:fast_sorted", 123 "bucket:sorted", 124 ] 125} 126 127# TODO(b/376730645): Remove deprecated interfaces. 128pw_source_set("best_fit_block_allocator") { 129 public_configs = [ ":public_include_path" ] 130 public = [ "public/pw_allocator/best_fit_block_allocator.h" ] 131 public_deps = [ ":best_fit" ] 132} 133 134pw_source_set("block_allocator") { 135 public_configs = [ ":public_include_path" ] 136 public = [ "public/pw_allocator/block_allocator.h" ] 137 public_deps = [ 138 ":config", 139 ":fragmentation", 140 ":hardening", 141 ":pw_allocator", 142 "block:allocatable", 143 "block:basic", 144 "block:iterable", 145 "block:poisonable", 146 "block:result", 147 "block:with_layout", 148 dir_pw_bytes, 149 dir_pw_result, 150 dir_pw_status, 151 ] 152 deps = [ dir_pw_assert ] 153 sources = [ "block_allocator.cc" ] 154} 155 156pw_source_set("bucket_allocator") { 157 public_configs = [ ":public_include_path" ] 158 public = [ "public/pw_allocator/bucket_allocator.h" ] 159 public_deps = [ 160 ":block_allocator", 161 "block:detailed_block", 162 "bucket:unordered", 163 dir_pw_status, 164 ] 165} 166 167# TODO(b/376730645): Remove deprecated interfaces. 168pw_source_set("bucket_block_allocator") { 169 public_configs = [ ":public_include_path" ] 170 public = [ "public/pw_allocator/bucket_block_allocator.h" ] 171 public_deps = [ ":bucket_allocator" ] 172} 173 174pw_source_set("buddy_allocator") { 175 public_configs = [ ":public_include_path" ] 176 public = [ "public/pw_allocator/buddy_allocator.h" ] 177 public_deps = [ 178 ":hardening", 179 ":pw_allocator", 180 "$dir_pw_containers:vector", 181 "block:basic", 182 "bucket:unordered", 183 dir_pw_bytes, 184 dir_pw_status, 185 ] 186 deps = [ 187 "$dir_pw_bytes:alignment", 188 "$dir_pw_third_party/fuchsia:stdcompat", 189 dir_pw_assert, 190 ] 191 sources = [ "buddy_allocator.cc" ] 192} 193 194pw_source_set("buffer") { 195 public_configs = [ ":public_include_path" ] 196 public = [ "public/pw_allocator/buffer.h" ] 197 public_deps = [ 198 dir_pw_bytes, 199 dir_pw_result, 200 ] 201 deps = [ 202 "$dir_pw_bytes:alignment", 203 dir_pw_assert, 204 ] 205} 206 207pw_source_set("bump_allocator") { 208 public_configs = [ ":public_include_path" ] 209 public = [ "public/pw_allocator/bump_allocator.h" ] 210 public_deps = [ 211 ":pw_allocator", 212 "$dir_pw_bytes:alignment", 213 dir_pw_bytes, 214 ] 215 deps = [ ":buffer" ] 216 sources = [ "bump_allocator.cc" ] 217} 218 219pw_source_set("chunk_pool") { 220 public_configs = [ ":public_include_path" ] 221 public = [ "public/pw_allocator/chunk_pool.h" ] 222 public_deps = [ 223 ":pw_allocator", 224 dir_pw_bytes, 225 dir_pw_result, 226 dir_pw_status, 227 ] 228 deps = [ 229 ":buffer", 230 "$dir_pw_assert:check", 231 "$dir_pw_bytes:alignment", 232 "$dir_pw_third_party/fuchsia:stdcompat", 233 ] 234 sources = [ "chunk_pool.cc" ] 235} 236 237# TODO(b/376730645): Remove deprecated alias. 238group("deallocator") { 239 public_deps = [ dir_pw_allocator ] 240} 241 242pw_source_set("dl_allocator") { 243 public_configs = [ ":public_include_path" ] 244 public = [ "public/pw_allocator/dl_allocator.h" ] 245 public_deps = [ 246 ":block_allocator", 247 ":config", 248 "$dir_pw_third_party/fuchsia:stdcompat", 249 "block:detailed_block", 250 "bucket:fast_sorted", 251 "bucket:unordered", 252 ] 253} 254 255# TODO(b/376730645): Remove deprecated interfaces. 256pw_source_set("dual_first_fit_block_allocator") { 257 public_configs = [ ":public_include_path" ] 258 public = [ "public/pw_allocator/dual_first_fit_block_allocator.h" ] 259 public_deps = [ ":first_fit" ] 260} 261 262pw_source_set("fallback_allocator") { 263 public_configs = [ ":public_include_path" ] 264 public = [ "public/pw_allocator/fallback_allocator.h" ] 265 public_deps = [ 266 ":pw_allocator", 267 dir_pw_result, 268 dir_pw_status, 269 ] 270 sources = [ "fallback_allocator.cc" ] 271 deps = [ "$dir_pw_assert:check" ] 272} 273 274pw_source_set("first_fit") { 275 public_configs = [ ":public_include_path" ] 276 public = [ "public/pw_allocator/first_fit.h" ] 277 public_deps = [ 278 ":block_allocator", 279 ":config", 280 "block:detailed_block", 281 "bucket:sequenced", 282 ] 283} 284 285# TODO(b/376730645): Remove deprecated interfaces. 286pw_source_set("first_fit_block_allocator") { 287 public_configs = [ ":public_include_path" ] 288 public = [ "public/pw_allocator/first_fit_block_allocator.h" ] 289 public_deps = [ ":first_fit" ] 290} 291 292pw_source_set("fragmentation") { 293 public_configs = [ ":public_include_path" ] 294 public = [ "public/pw_allocator/fragmentation.h" ] 295 sources = [ "fragmentation.cc" ] 296} 297 298pw_source_set("freelist_heap") { 299 public_configs = [ ":public_include_path" ] 300 public = [ "public/pw_allocator/freelist_heap.h" ] 301 public_deps = [ 302 ":bucket_allocator", 303 ":hardening", 304 dir_pw_bytes, 305 ] 306} 307 308pw_source_set("hardening") { 309 public_configs = [ ":public_include_path" ] 310 public = [ "public/pw_allocator/hardening.h" ] 311 public_deps = [ 312 ":config", 313 dir_pw_assert, 314 dir_pw_preprocessor, 315 ] 316} 317 318# TODO(b/376730645): Remove deprecated interfaces. 319pw_source_set("last_fit_block_allocator") { 320 public_configs = [ ":public_include_path" ] 321 public = [ "public/pw_allocator/last_fit_block_allocator.h" ] 322 public_deps = [ ":first_fit" ] 323} 324 325pw_source_set("libc_allocator") { 326 public_configs = [ ":public_include_path" ] 327 public = [ "public/pw_allocator/libc_allocator.h" ] 328 public_deps = [ ":pw_allocator" ] 329 sources = [ "libc_allocator.cc" ] 330} 331 332pw_source_set("null_allocator") { 333 public_configs = [ ":public_include_path" ] 334 public = [ "public/pw_allocator/null_allocator.h" ] 335 public_deps = [ ":pw_allocator" ] 336 sources = [ "null_allocator.cc" ] 337} 338 339pw_source_set("metrics") { 340 public_configs = [ ":public_include_path" ] 341 public = [ "public/pw_allocator/metrics.h" ] 342 public_deps = [ 343 ":pw_allocator", 344 dir_pw_metric, 345 ] 346} 347 348pw_source_set("pmr_allocator") { 349 public_configs = [ ":public_include_path" ] 350 public = [ "public/pw_allocator/pmr_allocator.h" ] 351 public_deps = [ 352 ":config", 353 ":pw_allocator", 354 dir_pw_assert, 355 dir_pw_status, 356 ] 357 sources = [ "pmr_allocator.cc" ] 358} 359 360# TODO(b/376730645): Remove deprecated alias. 361group("pool") { 362 public_deps = [ dir_pw_allocator ] 363} 364 365pw_source_set("synchronized_allocator") { 366 public_configs = [ ":public_include_path" ] 367 public = [ "public/pw_allocator/synchronized_allocator.h" ] 368 public_deps = [ 369 ":pw_allocator", 370 "$dir_pw_sync:borrow", 371 "$dir_pw_sync:lock_annotations", 372 ] 373} 374 375pw_source_set("tlsf_allocator") { 376 public_configs = [ ":public_include_path" ] 377 public = [ "public/pw_allocator/tlsf_allocator.h" ] 378 public_deps = [ 379 ":block_allocator", 380 ":config", 381 "$dir_pw_third_party/fuchsia:stdcompat", 382 "block:detailed_block", 383 "bucket:fast_sorted", 384 "bucket:sorted", 385 ] 386} 387 388pw_source_set("tracking_allocator") { 389 public_configs = [ ":public_include_path" ] 390 public = [ "public/pw_allocator/tracking_allocator.h" ] 391 public_deps = [ 392 ":metrics", 393 ":pw_allocator", 394 dir_pw_status, 395 ] 396 deps = [ dir_pw_assert ] 397} 398 399pw_source_set("typed_pool") { 400 public_configs = [ ":public_include_path" ] 401 public = [ "public/pw_allocator/typed_pool.h" ] 402 public_deps = [ 403 ":chunk_pool", 404 ":hardening", 405 dir_pw_bytes, 406 ] 407} 408 409pw_source_set("worst_fit") { 410 public_configs = [ ":public_include_path" ] 411 public = [ "public/pw_allocator/worst_fit.h" ] 412 public_deps = [ 413 ":block_allocator", 414 ":config", 415 "block:detailed_block", 416 "bucket:fast_sorted", 417 "bucket:sorted", 418 ] 419} 420 421# TODO(b/376730645): Remove deprecated interfaces. 422pw_source_set("worst_fit_block_allocator") { 423 public_configs = [ ":public_include_path" ] 424 public = [ "public/pw_allocator/worst_fit_block_allocator.h" ] 425 public_deps = [ ":worst_fit" ] 426} 427 428# Test support 429 430pw_source_set("testing") { 431 public_configs = [ ":test_config" ] 432 public = [ "public/pw_allocator/testing.h" ] 433 public_deps = [ 434 ":buffer", 435 ":first_fit", 436 ":hardening", 437 ":pw_allocator", 438 ":tracking_allocator", 439 dir_pw_bytes, 440 dir_pw_result, 441 dir_pw_status, 442 dir_pw_unit_test, 443 ] 444 deps = [ dir_pw_assert ] 445} 446 447pw_source_set("block_allocator_testing") { 448 public_configs = [ ":public_include_path" ] 449 public = [ "public/pw_allocator/block_allocator_testing.h" ] 450 public_deps = [ 451 ":block_allocator", 452 ":buffer", 453 ":fuzzing", 454 ":pw_allocator", 455 ":test_harness", 456 "block:detailed_block", 457 "block:testing", 458 dir_pw_unit_test, 459 ] 460 deps = [ 461 "$dir_pw_bytes:alignment", 462 "$dir_pw_third_party/fuchsia:stdcompat", 463 dir_pw_assert, 464 dir_pw_status, 465 ] 466 sources = [ "block_allocator_testing.cc" ] 467} 468 469pw_source_set("managed_ptr_testing") { 470 public_configs = [ ":public_include_path" ] 471 public = [ "public/pw_allocator/internal/managed_ptr_testing.h" ] 472 public_deps = [ 473 ":pw_allocator", 474 ":testing", 475 dir_pw_unit_test, 476 ] 477 sources = [ "managed_ptr_testing.cc" ] 478} 479 480pw_source_set("test_harness") { 481 public_configs = [ ":public_include_path" ] 482 public = [ "public/pw_allocator/test_harness.h" ] 483 public_deps = [ 484 ":pw_allocator", 485 "$dir_pw_containers:intrusive_list", 486 "$dir_pw_containers:vector", 487 dir_pw_random, 488 ] 489 deps = [ 490 "$dir_pw_third_party/fuchsia:stdcompat", 491 dir_pw_assert, 492 ] 493 sources = [ "test_harness.cc" ] 494} 495 496pw_source_set("fuzzing") { 497 public_configs = [ ":public_include_path" ] 498 public = [ "public/pw_allocator/fuzzing.h" ] 499 public_deps = [ 500 ":pw_allocator", 501 ":test_harness", 502 "$dir_pw_fuzzer:fuzztest", 503 ] 504 sources = [ "fuzzing.cc" ] 505} 506 507# Tests 508 509pw_test("allocator_as_pool_test") { 510 deps = [ 511 ":allocator_as_pool", 512 ":pw_allocator", 513 ":testing", 514 ] 515 sources = [ "allocator_as_pool_test.cc" ] 516} 517 518pw_test("allocator_test") { 519 deps = [ 520 ":pw_allocator", 521 ":testing", 522 ] 523 sources = [ "allocator_test.cc" ] 524} 525 526pw_test("best_fit_test") { 527 deps = [ 528 ":best_fit", 529 ":best_fit_block_allocator", 530 ":block_allocator_testing", 531 ":buffer", 532 ] 533 sources = [ "best_fit_test.cc" ] 534} 535 536pw_test("bucket_allocator_test") { 537 deps = [ 538 ":block_allocator_testing", 539 ":bucket_allocator", 540 ":bucket_block_allocator", 541 ":pw_allocator", 542 ] 543 sources = [ "bucket_allocator_test.cc" ] 544} 545 546pw_test("buddy_allocator_test") { 547 deps = [ 548 ":buddy_allocator", 549 ":fuzzing", 550 ":testing", 551 ] 552 sources = [ "buddy_allocator_test.cc" ] 553} 554 555pw_test("buffer_test") { 556 deps = [ 557 ":buffer", 558 ":testing", 559 "$dir_pw_third_party/fuchsia:stdcompat", 560 dir_pw_bytes, 561 dir_pw_result, 562 ] 563 sources = [ "buffer_test.cc" ] 564} 565 566pw_test("bump_allocator_test") { 567 deps = [ 568 ":bump_allocator", 569 ":testing", 570 "$dir_pw_third_party/fuchsia:stdcompat", 571 ] 572 sources = [ "bump_allocator_test.cc" ] 573} 574 575pw_test("chunk_pool_test") { 576 deps = [ 577 ":chunk_pool", 578 ":testing", 579 ] 580 sources = [ "chunk_pool_test.cc" ] 581} 582 583pw_test("dl_allocator_test") { 584 deps = [ 585 ":block_allocator_testing", 586 ":dl_allocator", 587 ] 588 sources = [ "dl_allocator_test.cc" ] 589} 590 591pw_test("fallback_allocator_test") { 592 deps = [ 593 ":fallback_allocator", 594 ":testing", 595 dir_pw_status, 596 ] 597 sources = [ "fallback_allocator_test.cc" ] 598} 599 600pw_test("first_fit_test") { 601 deps = [ 602 ":block_allocator_testing", 603 ":buffer", 604 ":dual_first_fit_block_allocator", 605 ":first_fit", 606 ":first_fit_block_allocator", 607 ":last_fit_block_allocator", 608 "$dir_pw_third_party/fuchsia:stdcompat", 609 "block:detailed_block", 610 ] 611 sources = [ "first_fit_test.cc" ] 612} 613 614pw_test("fragmentation_test") { 615 deps = [ 616 ":fragmentation", 617 ":testing", 618 ] 619 sources = [ "fragmentation_test.cc" ] 620} 621 622pw_test("freelist_heap_test") { 623 deps = [ 624 ":freelist_heap", 625 "$dir_pw_bytes:alignment", 626 "$dir_pw_third_party/fuchsia:stdcompat", 627 "block:testing", 628 ] 629 sources = [ "freelist_heap_test.cc" ] 630} 631 632pw_test("layout_test") { 633 deps = [ 634 ":pw_allocator", 635 ":testing", 636 dir_pw_result, 637 dir_pw_status, 638 ] 639 sources = [ "layout_test.cc" ] 640} 641 642pw_test("libc_allocator_test") { 643 deps = [ 644 ":libc_allocator", 645 ":testing", 646 ] 647 sources = [ "libc_allocator_test.cc" ] 648} 649 650pw_test("metrics_test") { 651 deps = [ ":metrics" ] 652 sources = [ "metrics_test.cc" ] 653} 654 655pw_test("null_allocator_test") { 656 deps = [ 657 ":null_allocator", 658 ":testing", 659 ] 660 sources = [ "null_allocator_test.cc" ] 661} 662 663pw_test("pmr_allocator_test") { 664 deps = [ 665 ":pmr_allocator", 666 ":testing", 667 ] 668 sources = [ "pmr_allocator_test.cc" ] 669} 670 671pw_test("synchronized_allocator_test") { 672 enable_if = 673 pw_sync_BINARY_SEMAPHORE_BACKEND != "" && pw_sync_MUTEX_BACKEND != "" && 674 pw_sync_INTERRUPT_SPIN_LOCK_BACKEND != "" && 675 pw_thread_YIELD_BACKEND != "" && 676 pw_thread_TEST_THREAD_CONTEXT_BACKEND != "" 677 deps = [ 678 ":synchronized_allocator", 679 ":test_harness", 680 ":testing", 681 "$dir_pw_containers:vector", 682 "$dir_pw_sync:binary_semaphore", 683 "$dir_pw_sync:interrupt_spin_lock", 684 "$dir_pw_sync:mutex", 685 "$dir_pw_sync:virtual_basic_lockable", 686 "$dir_pw_thread:test_thread_context", 687 "$dir_pw_thread:thread", 688 "$dir_pw_thread:thread_core", 689 "$dir_pw_thread:yield", 690 dir_pw_random, 691 dir_pw_status, 692 ] 693 sources = [ "synchronized_allocator_test.cc" ] 694} 695 696pw_test("tlsf_allocator_test") { 697 deps = [ 698 ":block_allocator_testing", 699 ":tlsf_allocator", 700 ] 701 sources = [ "tlsf_allocator_test.cc" ] 702} 703 704pw_test("tracking_allocator_test") { 705 deps = [ 706 ":first_fit", 707 ":metrics", 708 ":pw_allocator", 709 ":testing", 710 ":tracking_allocator", 711 dir_pw_log, 712 dir_pw_metric, 713 ] 714 sources = [ "tracking_allocator_test.cc" ] 715} 716 717pw_test("typed_pool_test") { 718 deps = [ 719 ":pw_allocator", 720 ":testing", 721 ":typed_pool", 722 "$dir_pw_bytes:alignment", 723 ] 724 sources = [ "typed_pool_test.cc" ] 725} 726 727pw_test("unique_ptr_test") { 728 deps = [ 729 ":managed_ptr_testing", 730 ":pw_allocator", 731 ] 732 sources = [ "unique_ptr_test.cc" ] 733} 734 735pw_test("worst_fit_test") { 736 deps = [ 737 ":block_allocator_testing", 738 ":worst_fit", 739 ":worst_fit_block_allocator", 740 ] 741 sources = [ "worst_fit_test.cc" ] 742} 743 744pw_test_group("tests") { 745 tests = [ 746 ":allocator_as_pool_test", 747 ":allocator_test", 748 ":best_fit_test", 749 ":bucket_allocator_test", 750 ":buddy_allocator_test", 751 ":buffer_test", 752 ":bump_allocator_test", 753 ":chunk_pool_test", 754 ":dl_allocator_test", 755 ":fallback_allocator_test", 756 ":first_fit_test", 757 ":fragmentation_test", 758 ":freelist_heap_test", 759 ":layout_test", 760 ":libc_allocator_test", 761 ":metrics_test", 762 ":null_allocator_test", 763 ":pmr_allocator_test", 764 ":synchronized_allocator_test", 765 ":tlsf_allocator_test", 766 ":tracking_allocator_test", 767 ":typed_pool_test", 768 ":unique_ptr_test", 769 ":worst_fit_test", 770 ] 771 group_deps = [ 772 "benchmarks:tests", 773 "block:tests", 774 "bucket:tests", 775 "examples", 776 ] 777} 778 779# Docs 780 781pw_size_diff("allocator_api_size_report") { 782 title = "Size of an empty implmentation of the Allocator interface" 783 binaries = [ 784 { 785 target = "size_report:null_allocator" 786 base = "size_report:base" 787 label = "NullAllocator" 788 }, 789 ] 790} 791 792pw_size_diff("blocks_size_report") { 793 title = "Sizes of various block implementations" 794 binaries = [ 795 { 796 target = "size_report:detailed_block" 797 base = "size_report:base" 798 label = "DetailedBlock" 799 }, 800 { 801 target = "size_report:small_block_basic" 802 base = "size_report:base" 803 label = "SmallBlock" 804 }, 805 { 806 target = "size_report:small_alignable_block" 807 base = "size_report:base" 808 label = "SmallAlignableBlock" 809 }, 810 { 811 target = "size_report:tiny_block" 812 base = "size_report:base" 813 label = "TinyBlock" 814 }, 815 ] 816} 817 818pw_size_diff("hardening_size_report") { 819 title = "Size impact of various levels of pw_allocator hardening" 820 binaries = [ 821 { 822 target = "size_report:small_block_basic" 823 base = "size_report:base" 824 label = "DetailedBlock with basic assertions enabled" 825 }, 826 { 827 target = "size_report:small_block_robust" 828 base = "size_report:base" 829 label = "DetailedBlock with robust assertions enabled" 830 }, 831 { 832 target = "size_report:small_block_debug" 833 base = "size_report:base" 834 label = "DetailedBlock with debug assertions enabled" 835 }, 836 ] 837} 838 839pw_size_diff("buckets_size_report") { 840 title = "Sizes of various bucket implementations" 841 binaries = [ 842 { 843 target = "size_report:fast_sorted" 844 base = "size_report:fast_sorted_base" 845 label = "FastSortedBucket, which uses IntrusiveMultiMap" 846 }, 847 { 848 target = "size_report:sequenced" 849 base = "size_report:sequenced_base" 850 label = "SequencedBucket, which uses IntrusiveList" 851 }, 852 { 853 target = "size_report:sorted" 854 base = "size_report:sorted_base" 855 label = "SortedBucket, which uses IntrusiveForwardList" 856 }, 857 { 858 target = "size_report:unordered" 859 base = "size_report:unordered_base" 860 label = "UnorderedBucket, which uses IntrusiveForwardList" 861 }, 862 ] 863} 864 865pw_size_diff("block_allocators_size_report") { 866 title = "Sizes of various block allocator implementations" 867 binaries = [ 868 { 869 target = "size_report:best_fit" 870 base = "size_report:detailed_block" 871 label = "BestFitAllocator" 872 }, 873 { 874 target = "size_report:bucket_allocator" 875 base = "size_report:detailed_block" 876 label = "BucketAllocator" 877 }, 878 { 879 target = "size_report:dl_allocator" 880 base = "size_report:detailed_block" 881 label = "DlAllocator" 882 }, 883 { 884 target = "size_report:first_fit" 885 base = "size_report:detailed_block" 886 label = "FirstFitAllocator" 887 }, 888 { 889 target = "size_report:tlsf_allocator" 890 base = "size_report:detailed_block" 891 label = "TlsfAllocator" 892 }, 893 { 894 target = "size_report:worst_fit" 895 base = "size_report:detailed_block" 896 label = "WorstFitAllocator" 897 }, 898 ] 899} 900 901pw_size_diff("concrete_allocators_size_report") { 902 title = "Sizes of other concrete allocator implementations" 903 binaries = [ 904 { 905 target = "size_report:buddy_allocator" 906 base = "size_report:base" 907 label = "BuddyAllocator" 908 }, 909 { 910 target = "size_report:bump_allocator" 911 base = "size_report:base" 912 label = "BumpAllocator" 913 }, 914 { 915 target = "size_report:libc_allocator" 916 base = "size_report:base" 917 label = "LibCAllocator" 918 }, 919 ] 920} 921 922pw_size_diff("forwarding_allocators_size_report") { 923 title = "Sizes of various forwarding allocator implementations" 924 binaries = [ 925 { 926 target = "size_report:fallback_allocator" 927 base = "size_report:best_fit" 928 label = "FallbackAllocator" 929 }, 930 { 931 target = "size_report:pmr_allocator" 932 base = "size_report:pmr_allocator_base" 933 label = "AsPmrAllocator" 934 }, 935 { 936 target = "size_report:synchronized_allocator_isl" 937 base = "size_report:best_fit" 938 label = "SynchronizedAllocator<sync::InterruptSpinLock>" 939 }, 940 { 941 target = "size_report:synchronized_allocator_mutex" 942 base = "size_report:best_fit" 943 label = "SynchronizedAllocator<sync::Mutex>" 944 }, 945 { 946 target = "size_report:tracking_allocator_all_metrics" 947 base = "size_report:best_fit" 948 label = "TrackingAllocator<AllMetrics>" 949 }, 950 { 951 target = "size_report:tracking_allocator_no_metrics" 952 base = "size_report:best_fit" 953 label = "TrackingAllocator<NoMetrics>" 954 }, 955 ] 956} 957 958pw_size_diff("allocator_utilities_size_report") { 959 title = "Sizes of various allocator utility classes" 960 binaries = [ 961 { 962 target = "size_report:unique_ptr" 963 base = "size_report:first_fit" 964 label = "UniquePtr" 965 }, 966 ] 967} 968 969pw_doc_group("docs") { 970 inputs = [ 971 "doc_resources/pw_allocator_heap_visualizer_demo.png", 972 "examples/basic.cc", 973 "examples/block_allocator.cc", 974 "examples/custom_allocator_perf_test.cc", 975 "examples/custom_allocator_test.cc", 976 "examples/custom_allocator.cc", 977 "examples/linker_sections.cc", 978 "examples/metrics.cc", 979 "examples/pmr.cc", 980 "examples/public/examples/custom_allocator.h", 981 "examples/public/examples/custom_allocator_test_harness.h", 982 "examples/size_report.cc", 983 "examples/spin_lock.cc", 984 ] 985 sources = [ 986 "api.rst", 987 "code_size.rst", 988 "design.rst", 989 "docs.rst", 990 "guide.rst", 991 ] 992 report_deps = [ 993 ":allocator_api_size_report", 994 ":block_allocators_size_report", 995 ":blocks_size_report", 996 ":buckets_size_report", 997 ":concrete_allocators_size_report", 998 ":forwarding_allocators_size_report", 999 ":hardening_size_report", 1000 "examples:custom_allocator_size_report", 1001 ] 1002} 1003