Libbpf eBPF macro __long
The __long
macros is used to define unsigned long properties of BTF maps.
Definition
#define __ulong(name, val) enum { ___bpf_concat(__unique_value, __COUNTER__) = val } name
Usage
This macro is used to encode unsigned long properties in BTF map definitions. BTF does not have a notion of literal values, we encode them as enum with value X
, were X
is the actual number we want to communicate.
The __ulong
supports up to 64-bit values, unlike the __uint
macro which only supports 32-bit values.
Example
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
struct {
__uint(type, BPF_MAP_TYPE_ARENA);
__uint(map_flags, BPF_F_MMAPABLE);
__uint(max_entries, 10); /* number of pages */
#ifdef __TARGET_ARCH_arm64
__ulong(map_extra, 0x1ull << 32); /* start of mmap() region */
#else
__ulong(map_extra, 0x1ull << 44); /* start of mmap() region */
#endif
} arena SEC(".maps");