mirror of
https://github.com/herumi/xbyak
synced 2024-11-21 16:09:11 -07:00
sample/memfd shows /proc/self/maps
This commit is contained in:
parent
2861517f25
commit
615b665cc2
1 changed files with 11 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
/*
|
||||
a sample to use MmapAllocator with an user-defined name
|
||||
cat /proc/`psidof ./memfd`/maps
|
||||
|
||||
7fca70b44000-7fca70b4a000 rw-p 00000000 00:00 0
|
||||
|
@ -9,6 +10,7 @@
|
|||
*/
|
||||
#define XBYAK_USE_MEMFD
|
||||
#include <xbyak/xbyak.h>
|
||||
#include <fstream>
|
||||
|
||||
class Code : Xbyak::MmapAllocator, public Xbyak::CodeGenerator {
|
||||
public:
|
||||
|
@ -23,9 +25,15 @@ public:
|
|||
|
||||
int main()
|
||||
{
|
||||
Code c1("abc", 123);
|
||||
Code c2("xyz", 456);
|
||||
Code c1("Xbyak::abc", 123);
|
||||
Code c2("Xbyak::xyz", 456);
|
||||
printf("c1 %d\n", c1.getCode<int (*)()>()());
|
||||
printf("c2 %d\n", c2.getCode<int (*)()>()());
|
||||
getchar();
|
||||
std::ifstream ifs("/proc/self/maps", std::ios::binary);
|
||||
if (ifs) {
|
||||
std::string line;
|
||||
while (std::getline(ifs, line)) {
|
||||
printf("%s\n", line.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue