Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F5078236
mprotector.c
dougm (Doug Moore)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
dougm
Aug 23 2019, 3:11 AM
2019-08-23 03:11:24 (UTC+0)
Size
752 B
Referenced Files
None
Subscribers
None
mprotector.c
View Options
#include
<sys/mman.h>
#include
<sys/time.h>
#include
<stdlib.h>
#include
<stdio.h>
enum
{
MAX_MAPS
=
16384
,
PAGE_SIZE
=
4096
};
int
main
(
int
argc
,
const
char
*
argv
[])
{
void
*
mapping
;
struct
timeval
beg
,
end
;
struct
timezone
tz
=
{
0
,
0
};
enum
{
GIGA
=
1
<<
20
,
PAGE
=
1
<<
12
};
mapping
=
mmap
(
0
,
GIGA
,
PROT_WRITE
,
MAP_ALIGNED
(
14
)
|
MAP_ANON
,
-1
,
0
);
int
i
;
for
(
i
=
0
;
i
<
GIGA
;
i
+=
2
*
PAGE
)
mprotect
(
mapping
+
i
,
PAGE
,
PROT_READ
);
gettimeofday
(
&
beg
,
&
tz
);
mprotect
(
mapping
,
GIGA
,
PROT_EXEC
);
gettimeofday
(
&
end
,
&
tz
);
end
.
tv_sec
-=
beg
.
tv_sec
;
end
.
tv_usec
-=
beg
.
tv_usec
;
if
(
end
.
tv_usec
<
0
)
{
end
.
tv_usec
+=
1000000
;
end
.
tv_sec
--
;
}
printf
(
"time %ld.%ld
\n
"
,
(
long
)
end
.
tv_sec
,
(
long
)
end
.
tv_usec
);
return
0
;
}
File Metadata
Details
Attached
Mime Type
text/x-c
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2145275
Default Alt Text
mprotector.c (752 B)
Attached To
Mode
D20814: Make entry simplification one-way
Attached
Detach File
Event Timeline
Log In to Comment