• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 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
15load(
16    "//pw_build:pigweed.bzl",
17    "pw_cc_library",
18    "pw_cc_test",
19)
20
21package(default_visibility = ["//visibility:public"])
22
23licenses(["notice"])
24
25pw_cc_library(
26    name = "headers",
27    hdrs = [
28        "public/pw_malloc_freelist/freelist_malloc.h",
29    ],
30    includes = [
31        "public",
32    ],
33)
34
35pw_cc_library(
36    name = "pw_malloc_freelist",
37    srcs = [
38        "freelist_malloc.cc",
39    ],
40    linkopts = [
41        # Link options that replace dynamic memory operations in standard
42        # library with the pigweed malloc.
43        "-Wl,--wrap=malloc",
44        "-Wl,--wrap=free",
45        "-Wl,--wrap=realloc",
46        "-Wl,--wrap=calloc",
47        "-Wl,--wrap=_malloc_r",
48        "-Wl,--wrap=_realloc_r",
49        "-Wl,--wrap=_free_r",
50        "-Wl,--wrap=_calloc_r",
51    ],
52    deps = [
53        ":headers",
54        "//pw_allocator:block",
55        "//pw_allocator:freelist_heap",
56        "//pw_malloc:facade",
57        "//pw_preprocessor",
58    ],
59)
60
61pw_cc_test(
62    name = "freelist_malloc_test",
63    srcs = [
64        "freelist_malloc_test.cc",
65    ],
66    # TODO(b/257530518): Get this test to work with Bazel.
67    tags = ["manual"],
68    deps = [
69        ":headers",
70        ":pw_malloc_freelist",
71        "//pw_unit_test",
72    ],
73)
74