mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Add mmap() wrapper.
This commit is contained in:
parent
fa1747bdb2
commit
cc805b7b74
@ -134,6 +134,7 @@
|
|||||||
<ClCompile Include="..\..\..\common\tracy_lz4.cpp" />
|
<ClCompile Include="..\..\..\common\tracy_lz4.cpp" />
|
||||||
<ClCompile Include="..\..\..\common\tracy_lz4hc.cpp" />
|
<ClCompile Include="..\..\..\common\tracy_lz4hc.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyMemory.cpp" />
|
<ClCompile Include="..\..\..\server\TracyMemory.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\server\TracyMmap.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyPrint.cpp" />
|
<ClCompile Include="..\..\..\server\TracyPrint.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyTaskDispatch.cpp" />
|
<ClCompile Include="..\..\..\server\TracyTaskDispatch.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyThreadCompress.cpp" />
|
<ClCompile Include="..\..\..\server\TracyThreadCompress.cpp" />
|
||||||
@ -181,8 +182,10 @@
|
|||||||
<ClInclude Include="..\..\..\common\tracy_sema.h" />
|
<ClInclude Include="..\..\..\common\tracy_sema.h" />
|
||||||
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp" />
|
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyEvent.hpp" />
|
<ClInclude Include="..\..\..\server\TracyEvent.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\server\TracyFileRead.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyFileWrite.hpp" />
|
<ClInclude Include="..\..\..\server\TracyFileWrite.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyMemory.hpp" />
|
<ClInclude Include="..\..\..\server\TracyMemory.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\server\TracyMmap.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyPopcnt.hpp" />
|
<ClInclude Include="..\..\..\server\TracyPopcnt.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyPrint.hpp" />
|
<ClInclude Include="..\..\..\server\TracyPrint.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracySlab.hpp" />
|
<ClInclude Include="..\..\..\server\TracySlab.hpp" />
|
||||||
|
@ -123,6 +123,9 @@
|
|||||||
<ClCompile Include="..\..\..\zstd\zstdmt_compress.c">
|
<ClCompile Include="..\..\..\zstd\zstdmt_compress.c">
|
||||||
<Filter>zstd</Filter>
|
<Filter>zstd</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\server\TracyMmap.cpp">
|
||||||
|
<Filter>server</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
||||||
@ -284,5 +287,11 @@
|
|||||||
<ClInclude Include="..\..\..\zstd\zstdmt_compress.h">
|
<ClInclude Include="..\..\..\zstd\zstdmt_compress.h">
|
||||||
<Filter>zstd</Filter>
|
<Filter>zstd</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\server\TracyFileRead.hpp">
|
||||||
|
<Filter>server</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\server\TracyMmap.hpp">
|
||||||
|
<Filter>server</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -134,6 +134,7 @@
|
|||||||
<ClCompile Include="..\..\..\common\tracy_lz4.cpp" />
|
<ClCompile Include="..\..\..\common\tracy_lz4.cpp" />
|
||||||
<ClCompile Include="..\..\..\common\tracy_lz4hc.cpp" />
|
<ClCompile Include="..\..\..\common\tracy_lz4hc.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyMemory.cpp" />
|
<ClCompile Include="..\..\..\server\TracyMemory.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\server\TracyMmap.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyTaskDispatch.cpp" />
|
<ClCompile Include="..\..\..\server\TracyTaskDispatch.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyThreadCompress.cpp" />
|
<ClCompile Include="..\..\..\server\TracyThreadCompress.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyWorker.cpp" />
|
<ClCompile Include="..\..\..\server\TracyWorker.cpp" />
|
||||||
@ -179,8 +180,10 @@
|
|||||||
<ClInclude Include="..\..\..\common\tracy_sema.h" />
|
<ClInclude Include="..\..\..\common\tracy_sema.h" />
|
||||||
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp" />
|
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyEvent.hpp" />
|
<ClInclude Include="..\..\..\server\TracyEvent.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\server\TracyFileRead.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyFileWrite.hpp" />
|
<ClInclude Include="..\..\..\server\TracyFileWrite.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyMemory.hpp" />
|
<ClInclude Include="..\..\..\server\TracyMemory.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\server\TracyMmap.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyPopcnt.hpp" />
|
<ClInclude Include="..\..\..\server\TracyPopcnt.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracySlab.hpp" />
|
<ClInclude Include="..\..\..\server\TracySlab.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyTaskDispatch.hpp" />
|
<ClInclude Include="..\..\..\server\TracyTaskDispatch.hpp" />
|
||||||
|
@ -117,6 +117,9 @@
|
|||||||
<ClCompile Include="..\..\..\zstd\zstdmt_compress.c">
|
<ClCompile Include="..\..\..\zstd\zstdmt_compress.c">
|
||||||
<Filter>zstd</Filter>
|
<Filter>zstd</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\server\TracyMmap.cpp">
|
||||||
|
<Filter>server</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
||||||
@ -272,5 +275,11 @@
|
|||||||
<ClInclude Include="..\..\..\zstd\zstdmt_compress.h">
|
<ClInclude Include="..\..\..\zstd\zstdmt_compress.h">
|
||||||
<Filter>zstd</Filter>
|
<Filter>zstd</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\server\TracyFileRead.hpp">
|
||||||
|
<Filter>server</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\server\TracyMmap.hpp">
|
||||||
|
<Filter>server</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -114,6 +114,7 @@
|
|||||||
<ClCompile Include="..\..\..\nfd\nfd_win.cpp" />
|
<ClCompile Include="..\..\..\nfd\nfd_win.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyBadVersion.cpp" />
|
<ClCompile Include="..\..\..\server\TracyBadVersion.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyMemory.cpp" />
|
<ClCompile Include="..\..\..\server\TracyMemory.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\server\TracyMmap.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyPrint.cpp" />
|
<ClCompile Include="..\..\..\server\TracyPrint.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyStorage.cpp" />
|
<ClCompile Include="..\..\..\server\TracyStorage.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyTaskDispatch.cpp" />
|
<ClCompile Include="..\..\..\server\TracyTaskDispatch.cpp" />
|
||||||
@ -193,6 +194,7 @@
|
|||||||
<ClInclude Include="..\..\..\server\TracyFileWrite.hpp" />
|
<ClInclude Include="..\..\..\server\TracyFileWrite.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyImGui.hpp" />
|
<ClInclude Include="..\..\..\server\TracyImGui.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyMemory.hpp" />
|
<ClInclude Include="..\..\..\server\TracyMemory.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\server\TracyMmap.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyPopcnt.hpp" />
|
<ClInclude Include="..\..\..\server\TracyPopcnt.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyPrint.hpp" />
|
<ClInclude Include="..\..\..\server\TracyPrint.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyShortPtr.hpp" />
|
<ClInclude Include="..\..\..\server\TracyShortPtr.hpp" />
|
||||||
|
@ -189,6 +189,9 @@
|
|||||||
<ClCompile Include="..\..\..\zstd\zstdmt_compress.c">
|
<ClCompile Include="..\..\..\zstd\zstdmt_compress.c">
|
||||||
<Filter>zstd</Filter>
|
<Filter>zstd</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\server\TracyMmap.cpp">
|
||||||
|
<Filter>server</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
||||||
@ -473,6 +476,9 @@
|
|||||||
<ClInclude Include="..\..\..\zstd\zstdmt_compress.h">
|
<ClInclude Include="..\..\..\zstd\zstdmt_compress.h">
|
||||||
<Filter>zstd</Filter>
|
<Filter>zstd</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\server\TracyMmap.hpp">
|
||||||
|
<Filter>server</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Natvis Include="DebugVis.natvis" />
|
<Natvis Include="DebugVis.natvis" />
|
||||||
|
38
server/TracyMmap.cpp
Normal file
38
server/TracyMmap.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#include "TracyMmap.hpp"
|
||||||
|
|
||||||
|
#if defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__
|
||||||
|
# include <io.h>
|
||||||
|
# include <windows.h>
|
||||||
|
|
||||||
|
void* mmap( void* addr, size_t length, int prot, int flags, int fd, off_t offset )
|
||||||
|
{
|
||||||
|
HANDLE hnd;
|
||||||
|
void* map = nullptr;
|
||||||
|
|
||||||
|
switch( prot )
|
||||||
|
{
|
||||||
|
case PROT_READ:
|
||||||
|
if( hnd = CreateFileMapping( HANDLE( _get_osfhandle( fd ) ), nullptr, PAGE_READONLY, 0, 0, nullptr ) )
|
||||||
|
{
|
||||||
|
map = MapViewOfFile( hnd, FILE_MAP_READ, 0, 0, length );
|
||||||
|
CloseHandle( hnd );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PROT_WRITE:
|
||||||
|
if( hnd = CreateFileMapping( HANDLE( _get_osfhandle( fd ) ), nullptr, PAGE_READWRITE, 0, 0, nullptr ) )
|
||||||
|
{
|
||||||
|
map = MapViewOfFile( hnd, FILE_MAP_WRITE, 0, 0, length );
|
||||||
|
CloseHandle( hnd );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return map ? (char*)map + offset : (void*)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int munmap( void* addr, size_t length )
|
||||||
|
{
|
||||||
|
return UnmapViewOfFile( addr ) != 0 ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
19
server/TracyMmap.hpp
Normal file
19
server/TracyMmap.hpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef __TRACYMMAP_HPP__
|
||||||
|
#define __TRACYMMAP_HPP__
|
||||||
|
|
||||||
|
#if !defined _MSC_VER && !defined __MINGW32__ && !defined __CYGWIN__
|
||||||
|
# include <sys/mman.h>
|
||||||
|
#else
|
||||||
|
# include <string.h>
|
||||||
|
# include <sys/types.h>
|
||||||
|
|
||||||
|
# define PROT_READ 1
|
||||||
|
# define PROT_WRITE 2
|
||||||
|
# define MAP_SHARED 0
|
||||||
|
|
||||||
|
void* mmap( void* addr, size_t length, int prot, int flags, int fd, off_t offset );
|
||||||
|
int munmap( void* addr, size_t length );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -134,6 +134,7 @@
|
|||||||
<ClCompile Include="..\..\..\common\tracy_lz4.cpp" />
|
<ClCompile Include="..\..\..\common\tracy_lz4.cpp" />
|
||||||
<ClCompile Include="..\..\..\common\tracy_lz4hc.cpp" />
|
<ClCompile Include="..\..\..\common\tracy_lz4hc.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyMemory.cpp" />
|
<ClCompile Include="..\..\..\server\TracyMemory.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\server\TracyMmap.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyPrint.cpp" />
|
<ClCompile Include="..\..\..\server\TracyPrint.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyTaskDispatch.cpp" />
|
<ClCompile Include="..\..\..\server\TracyTaskDispatch.cpp" />
|
||||||
<ClCompile Include="..\..\..\server\TracyThreadCompress.cpp" />
|
<ClCompile Include="..\..\..\server\TracyThreadCompress.cpp" />
|
||||||
@ -180,8 +181,10 @@
|
|||||||
<ClInclude Include="..\..\..\common\tracy_sema.h" />
|
<ClInclude Include="..\..\..\common\tracy_sema.h" />
|
||||||
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp" />
|
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyEvent.hpp" />
|
<ClInclude Include="..\..\..\server\TracyEvent.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\server\TracyFileRead.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyFileWrite.hpp" />
|
<ClInclude Include="..\..\..\server\TracyFileWrite.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyMemory.hpp" />
|
<ClInclude Include="..\..\..\server\TracyMemory.hpp" />
|
||||||
|
<ClInclude Include="..\..\..\server\TracyMmap.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyPopcnt.hpp" />
|
<ClInclude Include="..\..\..\server\TracyPopcnt.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracyPrint.hpp" />
|
<ClInclude Include="..\..\..\server\TracyPrint.hpp" />
|
||||||
<ClInclude Include="..\..\..\server\TracySlab.hpp" />
|
<ClInclude Include="..\..\..\server\TracySlab.hpp" />
|
||||||
|
@ -120,6 +120,9 @@
|
|||||||
<ClCompile Include="..\..\..\zstd\zstdmt_compress.c">
|
<ClCompile Include="..\..\..\zstd\zstdmt_compress.c">
|
||||||
<Filter>zstd</Filter>
|
<Filter>zstd</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\server\TracyMmap.cpp">
|
||||||
|
<Filter>server</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
||||||
@ -278,5 +281,11 @@
|
|||||||
<ClInclude Include="..\..\..\zstd\zstdmt_compress.h">
|
<ClInclude Include="..\..\..\zstd\zstdmt_compress.h">
|
||||||
<Filter>zstd</Filter>
|
<Filter>zstd</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\server\TracyFileRead.hpp">
|
||||||
|
<Filter>server</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\server\TracyMmap.hpp">
|
||||||
|
<Filter>server</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user