@@ -529,6 +529,15 @@ static int sys_inotify_init1(int flags)
529
529
#undef TARGET_NR_inotify_rm_watch
530
530
#endif /* CONFIG_INOTIFY */
531
531
532
+ #if defined(TARGET_NR_ppoll )
533
+ #ifndef __NR_ppoll
534
+ # define __NR_ppoll -1
535
+ #endif
536
+ #define __NR_sys_ppoll __NR_ppoll
537
+ _syscall5 (int , sys_ppoll , struct pollfd * , fds , nfds_t , nfds ,
538
+ struct timespec * , timeout , const __sigset_t * , sigmask ,
539
+ size_t , sigsetsize )
540
+ #endif
532
541
533
542
extern int personality (int );
534
543
extern int flock (int , int );
@@ -6230,8 +6239,13 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
6230
6239
ret = do_select (arg1 , arg2 , arg3 , arg4 , arg5 );
6231
6240
break ;
6232
6241
#endif
6233
- #ifdef TARGET_NR_poll
6242
+ #if defined(TARGET_NR_poll ) || defined(TARGET_NR_ppoll )
6243
+ # ifdef TARGET_NR_poll
6234
6244
case TARGET_NR_poll :
6245
+ # endif
6246
+ # ifdef TARGET_NR_ppoll
6247
+ case TARGET_NR_ppoll :
6248
+ # endif
6235
6249
{
6236
6250
struct target_pollfd * target_pfd ;
6237
6251
unsigned int nfds = arg2 ;
@@ -6242,12 +6256,51 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
6242
6256
target_pfd = lock_user (VERIFY_WRITE , arg1 , sizeof (struct target_pollfd ) * nfds , 1 );
6243
6257
if (!target_pfd )
6244
6258
goto efault ;
6259
+
6245
6260
pfd = alloca (sizeof (struct pollfd ) * nfds );
6246
6261
for (i = 0 ; i < nfds ; i ++ ) {
6247
6262
pfd [i ].fd = tswap32 (target_pfd [i ].fd );
6248
6263
pfd [i ].events = tswap16 (target_pfd [i ].events );
6249
6264
}
6250
- ret = get_errno (poll (pfd , nfds , timeout ));
6265
+
6266
+ # ifdef TARGET_NR_ppoll
6267
+ if (num == TARGET_NR_ppoll ) {
6268
+ struct timespec _timeout_ts , * timeout_ts = & _timeout_ts ;
6269
+ target_sigset_t * target_set ;
6270
+ sigset_t _set , * set = & _set ;
6271
+
6272
+ if (arg3 ) {
6273
+ if (target_to_host_timespec (timeout_ts , arg3 )) {
6274
+ unlock_user (target_pfd , arg1 , 0 );
6275
+ goto efault ;
6276
+ }
6277
+ } else {
6278
+ timeout_ts = NULL ;
6279
+ }
6280
+
6281
+ if (arg4 ) {
6282
+ target_set = lock_user (VERIFY_READ , arg4 , sizeof (target_sigset_t ), 1 );
6283
+ if (!target_set ) {
6284
+ unlock_user (target_pfd , arg1 , 0 );
6285
+ goto efault ;
6286
+ }
6287
+ target_to_host_sigset (set , target_set );
6288
+ } else {
6289
+ set = NULL ;
6290
+ }
6291
+
6292
+ ret = get_errno (sys_ppoll (pfd , nfds , timeout_ts , set , _NSIG /8 ));
6293
+
6294
+ if (!is_error (ret ) && arg3 ) {
6295
+ host_to_target_timespec (arg3 , timeout_ts );
6296
+ }
6297
+ if (arg4 ) {
6298
+ unlock_user (target_set , arg4 , 0 );
6299
+ }
6300
+ } else
6301
+ # endif
6302
+ ret = get_errno (poll (pfd , nfds , timeout ));
6303
+
6251
6304
if (!is_error (ret )) {
6252
6305
for (i = 0 ; i < nfds ; i ++ ) {
6253
6306
target_pfd [i ].revents = tswap16 (pfd [i ].revents );
0 commit comments