File tree Expand file tree Collapse file tree 4 files changed +26
-9
lines changed Expand file tree Collapse file tree 4 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ static mode_t g_umask = S_IWGRP | S_IWOTH;
35
35
#define REPORT (name )
36
36
#else
37
37
#define REPORT (name ) \
38
- emscripten_err("warning: unsupported syscall: __syscall_" #name "\n" );
38
+ emscripten_err("warning: unsupported syscall: __syscall_" #name);
39
39
#endif
40
40
41
41
#define UNIMPLEMENTED (name , args ) \
@@ -127,14 +127,20 @@ weak int __syscall_umask(int mask) {
127
127
return old ;
128
128
}
129
129
130
+ struct kusage {
131
+ long utime_tv_sec ;
132
+ long utime_tv_usec ;
133
+ long stime_tv_sec ;
134
+ long stime_tv_usec ;
135
+ };
136
+
130
137
weak int __syscall_getrusage (int who , intptr_t usage ) {
131
138
REPORT (getrusage );
132
- struct rusage * u = (struct rusage * )usage ;
133
- memset (u , 0 , sizeof (* u ));
134
- u -> ru_utime .tv_sec = 1 ;
135
- u -> ru_utime .tv_usec = 2 ;
136
- u -> ru_stime .tv_sec = 3 ;
137
- u -> ru_stime .tv_usec = 4 ;
139
+ struct kusage * u = (struct kusage * )usage ;
140
+ u -> utime_tv_sec = 1 ;
141
+ u -> utime_tv_usec = 2 ;
142
+ u -> stime_tv_sec = 3 ;
143
+ u -> stime_tv_usec = 4 ;
138
144
return 0 ;
139
145
}
140
146
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
1
2
#include <sys/time.h>
2
3
#include <sys/resource.h>
3
4
4
5
int main () {
5
6
struct rusage u ;
6
- getrusage (0 , & u );
7
+ getrusage (RUSAGE_SELF , & u );
8
+ printf ("ru_utime.tv_sec: %lld\n" , u .ru_utime .tv_sec );
9
+ printf ("ru_utime.tv_usec: %d\n" , u .ru_utime .tv_usec );
10
+ printf ("ru_stime.tv_sec: %lld\n" , u .ru_stime .tv_sec );
11
+ printf ("ru_stime.tv_usec: %d\n" , u .ru_stime .tv_usec );
7
12
return 0 ;
8
13
}
Original file line number Diff line number Diff line change
1
+ warning: unsupported syscall: __syscall_getrusage
2
+ ru_utime.tv_sec: 1
3
+ ru_utime.tv_usec: 2
4
+ ru_stime.tv_sec: 3
5
+ ru_stime.tv_usec: 4
Original file line number Diff line number Diff line change @@ -13381,8 +13381,9 @@ def test_missing_malloc_export(self):
13381
13381
'malloc() called but not included in the build - add `_malloc` to EXPORTED_FUNCTIONS',
13382
13382
'free() called but not included in the build - add `_free` to EXPORTED_FUNCTIONS'), assert_all=True)
13383
13383
13384
+ @also_with_asan
13384
13385
def test_getrusage(self):
13385
- self.do_runf('other/ test_getrusage.c')
13386
+ self.do_other_test(' test_getrusage.c')
13386
13387
13387
13388
@with_env_modify({'EMMAKEN_COMPILER': shared.CLANG_CC})
13388
13389
def test_emmaken_compiler(self):
You can’t perform that action at this time.
0 commit comments