MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / mapObject

Method mapObject

src/common/isc_sync.cpp:1964–2001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1962#ifdef HAVE_MMAP
1963
1964UCHAR* SharedMemoryBase::mapObject(CheckStatusWrapper* statusVector, ULONG object_offset, ULONG object_length)
1965{
1966/**************************************
1967 *
1968 * I S C _ m a p _ o b j e c t
1969 *
1970 **************************************
1971 *
1972 * Functional description
1973 * Try to map an object given a file mapping.
1974 *
1975 **************************************/
1976
1977 const ULONG page_size = getSystemPageSize(statusVector);
1978 if (!page_size)
1979 return NULL;
1980
1981 // Compute the start and end page-aligned offsets which contain the object being mapped.
1982
1983 const ULONG start = (object_offset / page_size) * page_size;
1984 const ULONG end = FB_ALIGN(object_offset + object_length, page_size);
1985 const ULONG length = end - start;
1986
1987 UCHAR* address = (UCHAR*) os_utils::mmap(0, length,
1988 PROT_READ | PROT_WRITE, MAP_SHARED, mainLock->getFd(), start);
1989
1990 if ((U_IPTR) address == (U_IPTR) -1)
1991 {
1992 error(statusVector, "mmap", errno);
1993 return NULL;
1994 }
1995
1996 // Return the virtual address of the mapped object.
1997
1998 IPC_TRACE(("ISC_map_object in %p to %p %p\n", shmem_data->sh_mem_address, address, address + length));
1999
2000 return address + (object_offset - start);
2001}
2002
2003
2004void SharedMemoryBase::unmapObject(CheckStatusWrapper* statusVector, UCHAR** object_pointer, ULONG object_length)

Callers

nothing calls this directly

Calls 4

FB_ALIGNFunction · 0.85
mmapFunction · 0.85
getFdMethod · 0.80
errorFunction · 0.70

Tested by

no test coverage detected