// ClockNanosleep implements linux syscall clock_nanosleep(2).
ClockNanosleep implements linux syscall clock_nanosleep(2).
// ClockNanosleep implements linux syscall clock_nanosleep ( 2 ) .
func ClockNanosleep(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {
	clockID := int32(args[0].Int())
	flags := args[1].Int()
	addr := args[2].Pointer()
	rem := args[3].Pointer()
	req, err := copyTimespecIn(t, addr)
	if err != nil {
		return 0, nil, err
	}
	if !req.Valid() {
		return 0, nil, syserror.EINVAL
	}
	if clockID > 0 {
		if clockID != linux.CLOCK_REALTIME &&
			clockID != linux.CLOCK_MONOTONIC &&
			clockID != linux.CLOCK_PROCESS_CPUTIME_ID {
			return 0, nil, syserror.EINVAL
		}
	}
	c, err := getClock(t, clockID)
	if err != nil {
		return 0, nil, err
	}
	if flags&linux.TIMER_ABSTIME != 0 {
		return 0, nil, clockNanosleepUntil(t, c, ktime.FromTimespec(req), 0, false)
	}
	dur := time.Duration(req.ToNsecCapped()) * time.Nanosecond
	return 0, nil, clockNanosleepUntil(t, c, c.Now().Add(dur), rem, true)
}
func ClockNanosleep ( t * kernel . Task , args arch . SyscallArguments ) ( uintptr , * kernel . SyscallControl , error ) { clockID := int32 ( args [ 0 ] . Int ( ) ) flags := args [ 1 ] . Int ( ) addr := args [ 2 ] . Pointer ( ) rem := args [ 3 ] . Pointer ( ) req , err := copyTimespecIn ( t , addr ) if err != nil { return 0 , nil , err } if ! req . Valid ( ) { return 0 , nil , syserror . EINVAL } if clockID > 0 { if clockID != linux . CLOCK_REALTIME && clockID != linux . CLOCK_MONOTONIC && clockID != linux . CLOCK_PROCESS_CPUTIME_ID { return 0 , nil , syserror . EINVAL } } c , err := getClock ( t , clockID ) if err != nil { return 0 , nil , err } if flags & linux . TIMER_ABSTIME != 0 { return 0 , nil , clockNanosleepUntil ( t , c , ktime . FromTimespec ( req ) , 0 , false ) } dur := time . Duration ( req . ToNsecCapped ( ) ) * time . Nanosecond return 0 , nil , clockNanosleepUntil ( t , c , c . Now ( ) . Add ( dur ) , rem , true ) }
ClockNanosleep implements linux syscall clock_nanosleep(2).
ClockNanosleep implements linux syscall clock_nanosleep ( 2 ) .
// Only allow clock constants also allowed by Linux.