github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/sentry/pgalloc/BUILD (about)

     1  load("//tools:defs.bzl", "go_library", "go_test")
     2  load("//tools/go_generics:defs.bzl", "go_template_instance")
     3  
     4  package(licenses = ["notice"])
     5  
     6  go_template_instance(
     7      name = "evictable_range",
     8      out = "evictable_range.go",
     9      package = "pgalloc",
    10      prefix = "Evictable",
    11      template = "//pkg/segment:generic_range",
    12      types = {
    13          "T": "uint64",
    14      },
    15  )
    16  
    17  go_template_instance(
    18      name = "evictable_range_set",
    19      out = "evictable_range_set.go",
    20      package = "pgalloc",
    21      prefix = "evictableRange",
    22      template = "//pkg/segment:generic_set",
    23      types = {
    24          "Key": "uint64",
    25          "Range": "EvictableRange",
    26          "Value": "evictableRangeSetValue",
    27          "Functions": "evictableRangeSetFunctions",
    28      },
    29  )
    30  
    31  go_template_instance(
    32      name = "usage_set",
    33      out = "usage_set.go",
    34      consts = {
    35          "minDegree": "10",
    36          "trackGaps": "1",
    37      },
    38      imports = {
    39          "memmap": "gvisor.dev/gvisor/pkg/sentry/memmap",
    40      },
    41      package = "pgalloc",
    42      prefix = "usage",
    43      template = "//pkg/segment:generic_set",
    44      types = {
    45          "Key": "uint64",
    46          "Range": "memmap.FileRange",
    47          "Value": "usageInfo",
    48          "Functions": "usageSetFunctions",
    49      },
    50  )
    51  
    52  go_template_instance(
    53      name = "reclaim_set",
    54      out = "reclaim_set.go",
    55      consts = {
    56          "minDegree": "10",
    57      },
    58      imports = {
    59          "memmap": "gvisor.dev/gvisor/pkg/sentry/memmap",
    60      },
    61      package = "pgalloc",
    62      prefix = "reclaim",
    63      template = "//pkg/segment:generic_set",
    64      types = {
    65          "Key": "uint64",
    66          "Range": "memmap.FileRange",
    67          "Value": "reclaimSetValue",
    68          "Functions": "reclaimSetFunctions",
    69      },
    70  )
    71  
    72  go_library(
    73      name = "pgalloc",
    74      srcs = [
    75          "context.go",
    76          "evictable_range.go",
    77          "evictable_range_set.go",
    78          "pgalloc.go",
    79          "pgalloc_unsafe.go",
    80          "reclaim_set.go",
    81          "save_restore.go",
    82          "usage_set.go",
    83      ],
    84      visibility = ["//pkg/sentry:internal"],
    85      deps = [
    86          "//pkg/abi/linux",
    87          "//pkg/context",
    88          "//pkg/errors/linuxerr",
    89          "//pkg/hostarch",
    90          "//pkg/log",
    91          "//pkg/memutil",
    92          "//pkg/safemem",
    93          "//pkg/sentry/arch",
    94          "//pkg/sentry/hostmm",
    95          "//pkg/sentry/memmap",
    96          "//pkg/sentry/usage",
    97          "//pkg/state",
    98          "//pkg/state/wire",
    99          "//pkg/sync",
   100          "//pkg/syserror",
   101          "//pkg/usermem",
   102          "@org_golang_x_sys//unix:go_default_library",
   103      ],
   104  )
   105  
   106  go_test(
   107      name = "pgalloc_test",
   108      size = "small",
   109      srcs = ["pgalloc_test.go"],
   110      library = ":pgalloc",
   111      deps = ["//pkg/hostarch"],
   112  )