Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/base_alloc/base_alloc_linux.c
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
/*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2024-2025 Intel Corporation
*
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/

#include <assert.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <unistd.h>

#include "base_alloc.h"
#include "base_alloc_global.h"
#include "utils_concurrency.h"

static UTIL_ONCE_FLAG Page_size_is_initialized = UTIL_ONCE_FLAG_INIT;
static size_t Page_size;

void *ba_os_alloc(size_t size) {
void *ptr = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
void *ptr = utils_mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
// this should be unnecessary but pairs of mmap/munmap do not reset
// asan's user-poisoning flags, leading to invalid error reports
// Bug 81619: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81619
Expand All @@ -29,7 +25,7 @@ void *ba_os_alloc(size_t size) {
}

void ba_os_free(void *ptr, size_t size) {
int ret = munmap(ptr, size);
int ret = utils_munmap(ptr, size);
assert(ret == 0);
(void)ret; // unused
}
Expand Down
Loading