Blender V5.0
BLI_mmap.cc File Reference
#include "BLI_mmap.h"
#include "BLI_assert.h"
#include "BLI_fileops.h"
#include "BLI_mutex.hh"
#include "BLI_string_utils.hh"
#include "BLI_vector.hh"
#include "MEM_guardedalloc.h"
#include <atomic>
#include <cstring>
#include <csignal>
#include <cstdlib>
#include <sys/mman.h>
#include <unistd.h>

Go to the source code of this file.

Classes

struct  BLI_mmap_file

Functions

static blender::Vector< BLI_mmap_file * > & open_mmaps_vector ()
static void print_error (const char *message)
static bool try_map_zeros (BLI_mmap_file *file)
static bool try_handle_error_for_address (const void *address)
static void sigbus_handler (int sig, siginfo_t *siginfo, void *ptr) noexcept
static bool ensure_mmap_initialized ()
static void error_handler_add (BLI_mmap_file *file)
static void error_handler_remove (BLI_mmap_file *file)
BLI_mmap_fileBLI_mmap_open (int fd)
bool BLI_mmap_read (BLI_mmap_file *file, void *dest, size_t offset, size_t length)
void * BLI_mmap_get_pointer (BLI_mmap_file *file)
size_t BLI_mmap_get_length (const BLI_mmap_file *file)
bool BLI_mmap_any_io_error (const BLI_mmap_file *file)
void BLI_mmap_free (BLI_mmap_file *file)

Variables

static blender::Mutex mmap_mutex
static struct sigaction next_handler = {}

Function Documentation

◆ BLI_mmap_any_io_error()

◆ BLI_mmap_free()

◆ BLI_mmap_get_length()

◆ BLI_mmap_get_pointer()

◆ BLI_mmap_open()

◆ BLI_mmap_read()

bool BLI_mmap_read ( BLI_mmap_file * file,
void * dest,
size_t offset,
size_t length )

◆ ensure_mmap_initialized()

bool ensure_mmap_initialized ( )
static

Definition at line 325 of file BLI_mmap.cc.

References initialized, lock, mmap_mutex, next_handler, and sigbus_handler().

Referenced by BLI_mmap_open().

◆ error_handler_add()

void error_handler_add ( BLI_mmap_file * file)
static

Definition at line 354 of file BLI_mmap.cc.

References lock, mmap_mutex, and open_mmaps_vector().

Referenced by BLI_mmap_open().

◆ error_handler_remove()

void error_handler_remove ( BLI_mmap_file * file)
static

Definition at line 361 of file BLI_mmap.cc.

References lock, mmap_mutex, and open_mmaps_vector().

Referenced by BLI_mmap_free().

◆ open_mmaps_vector()

blender::Vector< BLI_mmap_file * > & open_mmaps_vector ( )
static

◆ print_error()

void print_error ( const char * message)
static

Definition at line 274 of file BLI_mmap.cc.

References BLI_string_join, and length().

Referenced by sigbus_handler(), and try_handle_error_for_address().

◆ sigbus_handler()

void sigbus_handler ( int sig,
siginfo_t * siginfo,
void * ptr )
staticnoexcept

Definition at line 297 of file BLI_mmap.cc.

References BLI_assert, ELEM, next_handler, print_error(), ptr, and try_handle_error_for_address().

Referenced by ensure_mmap_initialized().

◆ try_handle_error_for_address()

bool try_handle_error_for_address ( const void * address)
static

◆ try_map_zeros()

bool try_map_zeros ( BLI_mmap_file * file)
static

Definition at line 283 of file BLI_mmap.cc.

References BLI_mmap_file::length, and BLI_mmap_file::memory.

Referenced by try_handle_error_for_address().

Variable Documentation

◆ mmap_mutex

◆ next_handler

struct sigaction next_handler = {}
static

Definition at line 295 of file BLI_mmap.cc.

Referenced by ensure_mmap_initialized(), and sigbus_handler().