diff --git a/src/provider/provider_devdax_memory.c b/src/provider/provider_devdax_memory.c index 8d1c4bc9e..0507463c0 100644 --- a/src/provider/provider_devdax_memory.c +++ b/src/provider/provider_devdax_memory.c @@ -14,7 +14,6 @@ #include #include "base_alloc_global.h" -#include "provider_devdax_memory_internal.h" #include "provider_os_memory_internal.h" #include "utils_common.h" #include "utils_concurrency.h" @@ -28,6 +27,15 @@ #define TLS_MSG_BUF_LEN 1024 +typedef struct devdax_memory_provider_t { + char path[PATH_MAX]; // a path to the device DAX + size_t size; // size of the file used for memory mapping + void *base; // base address of memory mapping + size_t offset; // offset in the file used for memory mapping + os_mutex_t lock; // lock of ptr and offset + unsigned protection; // combination of OS-specific protection flags +} devdax_memory_provider_t; + typedef struct devdax_last_native_error_t { int32_t native_error; int errno_value; diff --git a/src/provider/provider_devdax_memory_internal.h b/src/provider/provider_devdax_memory_internal.h deleted file mode 100644 index 981089e08..000000000 --- a/src/provider/provider_devdax_memory_internal.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2024 Intel Corporation - * - * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -*/ - -#ifndef UMF_DEVDAX_MEMORY_PROVIDER_INTERNAL_H -#define UMF_DEVDAX_MEMORY_PROVIDER_INTERNAL_H - -#include - -#include "utils_concurrency.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct devdax_memory_provider_t { - char path[PATH_MAX]; // a path to the device DAX - size_t size; // size of the file used for memory mapping - void *base; // base address of memory mapping - size_t offset; // offset in the file used for memory mapping - os_mutex_t lock; // lock of ptr and offset - unsigned protection; // combination of OS-specific protection flags -} devdax_memory_provider_t; - -#ifdef __cplusplus -} -#endif - -#endif /* UMF_DEVDAX_MEMORY_PROVIDER_INTERNAL_H */ diff --git a/src/provider/provider_file_memory.c b/src/provider/provider_file_memory.c index fd8d04371..b67d52d32 100644 --- a/src/provider/provider_file_memory.c +++ b/src/provider/provider_file_memory.c @@ -15,7 +15,6 @@ #include "base_alloc_global.h" #include "critnib.h" -#include "provider_file_memory_internal.h" #include "provider_os_memory_internal.h" #include "utils_common.h" #include "utils_concurrency.h" @@ -27,6 +26,32 @@ #define TLS_MSG_BUF_LEN 1024 +typedef struct file_memory_provider_t { + os_mutex_t lock; // lock for file parameters (size and offsets) + + char path[PATH_MAX]; // a path to the file + int fd; // file descriptor for memory mapping + size_t size_fd; // size of the file used for memory mappings + size_t offset_fd; // offset in the file used for memory mappings + + void *base_mmap; // base address of the current memory mapping + size_t size_mmap; // size of the current memory mapping + size_t offset_mmap; // data offset in the current memory mapping + + unsigned protection; // combination of OS-specific protection flags + unsigned visibility; // memory visibility mode + size_t page_size; // minimum page size + + critnib *mmaps; // a critnib map storing mmap mappings (addr, size) + + // A critnib map storing (ptr, fd_offset + 1) pairs. We add 1 to fd_offset + // in order to be able to store fd_offset equal 0, because + // critnib_get() returns value or NULL, so a value cannot equal 0. + // It is needed mainly in the get_ipc_handle and open_ipc_handle hooks + // to mmap a specific part of a file. + critnib *fd_offset_map; +} file_memory_provider_t; + typedef struct file_last_native_error_t { int32_t native_error; int errno_value; diff --git a/src/provider/provider_file_memory_internal.h b/src/provider/provider_file_memory_internal.h deleted file mode 100644 index ce77719d5..000000000 --- a/src/provider/provider_file_memory_internal.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2024 Intel Corporation - * - * Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -*/ - -#ifndef UMF_FILE_MEMORY_PROVIDER_INTERNAL_H -#define UMF_FILE_MEMORY_PROVIDER_INTERNAL_H - -#include - -#include "critnib.h" -#include "utils_concurrency.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct file_memory_provider_t { - os_mutex_t lock; // lock for file parameters (size and offsets) - - char path[PATH_MAX]; // a path to the file - int fd; // file descriptor for memory mapping - size_t size_fd; // size of the file used for memory mappings - size_t offset_fd; // offset in the file used for memory mappings - - void *base_mmap; // base address of the current memory mapping - size_t size_mmap; // size of the current memory mapping - size_t offset_mmap; // data offset in the current memory mapping - - unsigned protection; // combination of OS-specific protection flags - unsigned visibility; // memory visibility mode - size_t page_size; // minimum page size - - critnib *mmaps; // a critnib map storing mmap mappings (addr, size) - - // A critnib map storing (ptr, fd_offset + 1) pairs. We add 1 to fd_offset - // in order to be able to store fd_offset equal 0, because - // critnib_get() returns value or NULL, so a value cannot equal 0. - // It is needed mainly in the get_ipc_handle and open_ipc_handle hooks - // to mmap a specific part of a file. - critnib *fd_offset_map; -} file_memory_provider_t; - -#ifdef __cplusplus -} -#endif - -#endif /* UMF_FILE_MEMORY_PROVIDER_INTERNAL_H */