Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F127258092
syscalltest.c
jmg (John-Mark Gurney)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
jmg
Aug 29 2025, 5:27 PM
2025-08-29 17:27:57 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
syscalltest.c
View Options
#include
<sys/mman.h>
#include
<sys/syscall.h>
#include
<signal.h>
#include
<stdlib.h>
#include
<unistd.h>
sig_atomic_t
gotsigsys
;
void
sigsys_handler
(
int
sig
)
{
gotsigsys
=
1
;
}
int
main
()
{
int
pipefds
[
2
];
int
wfd
,
rfd
;
char
p
[]
=
"V"
;
char
readchar
;
int
r
;
if
(
pipe
(
pipefds
)
==
-1
)
exit
(
1
);
rfd
=
pipefds
[
0
];
wfd
=
pipefds
[
1
];
if
(
write
(
wfd
,
p
,
1
)
!=
1
)
exit
(
1
);
if
(
read
(
rfd
,
&
readchar
,
1
)
!=
1
)
exit
(
1
);
if
(
readchar
!=
p
[
0
])
exit
(
1
);
if
(
syscall
(
SYS_write
,
wfd
,
p
,
1
)
!=
1
)
exit
(
1
);
if
(
read
(
rfd
,
&
readchar
,
1
)
!=
1
)
exit
(
1
);
if
(
readchar
!=
p
[
0
])
exit
(
1
);
signal
(
SIGSYS
,
sigsys_handler
);
/* check for bug in arm64 32-bit compat code */
gotsigsys
=
0
;
r
=
__syscall
((
quad_t
)
SYS_write
<<
32
,
wfd
,
p
,
1
);
if
(
!
gotsigsys
)
exit
(
1
);
gotsigsys
=
0
;
r
=
__syscall
((
quad_t
)
SYS_write
,
wfd
,
p
,
1
);
if
(
gotsigsys
)
exit
(
1
);
if
(
r
!=
1
)
exit
(
1
);
if
(
read
(
rfd
,
&
readchar
,
1
)
!=
1
)
exit
(
1
);
if
(
readchar
!=
p
[
0
])
exit
(
1
);
void
*
addr
;
/* xxx would be better to map a real file with an offset to make sure off_t is endian clean */
addr
=
mmap
(
NULL
,
8192
,
PROT_READ
|
PROT_WRITE
,
MAP_ANON
,
-1
,
0
);
if
(
gotsigsys
)
exit
(
1
);
if
(
addr
==
NULL
)
exit
(
1
);
if
(
sizeof
(
void
*
)
<=
sizeof
(
int
))
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast"
addr
=
(
void
*
)
syscall
(
SYS_mmap
,
NULL
,
8192
,
PROT_READ
|
PROT_WRITE
,
MAP_ANON
,
-1
,
0
);
#pragma clang diagnostic pop
if
(
addr
==
NULL
)
exit
(
1
);
}
addr
=
(
void
*
)
__syscall
(
SYS_mmap
,
NULL
,
8192
,
PROT_READ
|
PROT_WRITE
,
MAP_ANON
,
-1
,
0
);
if
(
gotsigsys
)
exit
(
1
);
if
(
addr
==
NULL
)
exit
(
1
);
return
0
;
}
File Metadata
Details
Attached
Mime Type
text/x-c
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21964636
Default Alt Text
syscalltest.c (1 KB)
Attached To
Mode
D52243: arm64: 32-bit compat is little endian, read the correct word
Attached
Detach File
Event Timeline
Log In to Comment