@@ -364,6 +364,13 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
364
364
#ifdef __NR_exit_group
365
365
_syscall1 (int ,exit_group ,int ,error_code )
366
366
#endif
367
+ #if defined(__NR_close_range ) && defined(TARGET_NR_close_range )
368
+ #define __NR_sys_close_range __NR_close_range
369
+ _syscall3 (int ,sys_close_range ,int ,first ,int ,last ,int ,flags )
370
+ #ifndef CLOSE_RANGE_CLOEXEC
371
+ #define CLOSE_RANGE_CLOEXEC (1U << 2)
372
+ #endif
373
+ #endif
367
374
#if defined(__NR_futex )
368
375
_syscall6 (int ,sys_futex ,int * ,uaddr ,int ,op ,int ,val ,
369
376
const struct timespec * ,timeout ,int * ,uaddr2 ,int ,val3 )
@@ -8756,6 +8763,18 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
8756
8763
case TARGET_NR_close :
8757
8764
fd_trans_unregister (arg1 );
8758
8765
return get_errno (close (arg1 ));
8766
+ #if defined(__NR_close_range ) && defined(TARGET_NR_close_range )
8767
+ case TARGET_NR_close_range :
8768
+ ret = get_errno (sys_close_range (arg1 , arg2 , arg3 ));
8769
+ if (ret == 0 && !(arg3 & CLOSE_RANGE_CLOEXEC )) {
8770
+ abi_long fd , maxfd ;
8771
+ maxfd = MIN (arg2 , target_fd_max );
8772
+ for (fd = arg1 ; fd < maxfd ; fd ++ ) {
8773
+ fd_trans_unregister (fd );
8774
+ }
8775
+ }
8776
+ return ret ;
8777
+ #endif
8759
8778
8760
8779
case TARGET_NR_brk :
8761
8780
return do_brk (arg1 );
0 commit comments