Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
345834ec
Commit
345834ec
authored
Nov 03, 2011
by
Cyrill Gorcunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: Add prints out in static test
Signed-off-by:
Cyrill Gorcunov
<
gorcunov@gmail.com
>
parent
489745f2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
2 deletions
+27
-2
testee-static-syssleep.c
test/testee-static-syssleep.c
+27
-2
No files found.
test/testee-static-syssleep.c
View file @
345834ec
...
...
@@ -16,6 +16,7 @@
# define always_inline __always_inline
#endif
#define __NR_write 1
#define __NR_nanosleep 35
static
always_inline
long
syscall2
(
int
nr
,
unsigned
long
arg0
,
unsigned
long
arg1
)
...
...
@@ -28,11 +29,33 @@ static always_inline long syscall2(int nr, unsigned long arg0, unsigned long arg
return
ret
;
}
static
always_inline
long
syscall3
(
int
nr
,
unsigned
long
arg0
,
unsigned
long
arg1
,
unsigned
long
arg2
)
{
long
ret
;
asm
volatile
(
"movl %1, %%eax
\t\n
"
"movq %2, %%rdi
\t\n
"
"movq %3, %%rsi
\t\n
"
"movq %4, %%rdx
\t\n
"
"syscall
\t\n
"
"movq %%rax, %0
\t\n
"
:
"=r"
(
ret
)
:
"g"
((
int
)
nr
),
"g"
(
arg0
),
"g"
(
arg1
),
"g"
(
arg2
)
:
"rax"
,
"rdi"
,
"rsi"
,
"rdx"
,
"memory"
);
return
ret
;
}
static
always_inline
long
sys_nanosleep
(
struct
timespec
*
req
,
struct
timespec
*
rem
)
{
return
syscall2
(
__NR_nanosleep
,
(
unsigned
long
)
req
,
(
unsigned
long
)
rem
);
}
static
always_inline
long
sys_write
(
unsigned
long
fd
,
const
void
*
buf
,
unsigned
long
count
)
{
return
syscall3
(
__NR_write
,
fd
,
(
unsigned
long
)
buf
,
count
);
}
static
void
always_inline
local_sleep
(
long
seconds
)
{
struct
timespec
req
,
rem
;
...
...
@@ -45,11 +68,13 @@ static void always_inline local_sleep(long seconds)
sys_nanosleep
(
&
req
,
&
rem
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
for
(;;)
const
char
msg
[]
=
"I'm alive
\n
"
;
for
(;;)
{
sys_write
(
1
,
msg
,
sizeof
(
msg
));
local_sleep
(
5
);
}
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment