// clockNanosleepUntil blocks until a specified time.
//
// If blocking is interrupted, the syscall is restarted with the original
// arguments.
clockNanosleepUntil blocks until a specified time.

If blocking is interrupted, the syscall is restarted with the original
arguments.
// clockNanosleepUntil blocks until a specified time . // // If blocking is interrupted the syscall is restarted with the original // arguments .
func clockNanosleepUntil(t *kernel.Task, c ktime.Clock, end ktime.Time, rem hostarch.Addr, needRestartBlock bool) error {
	notifier, tchan := ktime.NewChannelNotifier()
	timer := ktime.NewTimer(c, notifier)
	timer.Swap(ktime.Setting{
		Period:  0,
		Enabled: true,
		Next:    end,
	})
	err := t.BlockWithTimer(nil, tchan)
	timer.Destroy()
	switch err {
	case syserror.ETIMEDOUT:
		return nil
	case syserror.ErrInterrupted:
		remaining := end.Sub(c.Now())
		if remaining <= 0 {
			return nil
		}
		if rem != 0 {
			timeleft := linux.NsecToTimespec(remaining.Nanoseconds())
			if err := copyTimespecOut(t, rem, &timeleft); err != nil {
				return err
			}
		}
		if needRestartBlock {
			t.SetSyscallRestartBlock(&clockNanosleepRestartBlock{
				c:   c,
				end: end,
				rem: rem,
			})
			return syserror.ERESTART_RESTARTBLOCK
		}
		return syserror.ERESTARTNOHAND
	default:
		panic(fmt.Sprintf("Impossible BlockWithTimer error %v", err))
	}
}
func clockNanosleepUntil ( t * kernel . Task , c ktime . Clock , end ktime . Time , rem hostarch . Addr , needRestartBlock bool ) error { notifier , tchan := ktime . NewChannelNotifier ( ) timer := ktime . NewTimer ( c , notifier ) timer . Swap ( ktime . Setting { Period : 0 , Enabled : true , Next : end , } ) err := t . BlockWithTimer ( nil , tchan ) timer . Destroy ( ) switch err { case syserror . ETIMEDOUT : return nil case syserror . ErrInterrupted : remaining := end . Sub ( c . Now ( ) ) if remaining <= 0 { return nil } if rem != 0 { timeleft := linux . NsecToTimespec ( remaining . Nanoseconds ( ) ) if err := copyTimespecOut ( t , rem , & timeleft ) ; err != nil { return err } } if needRestartBlock { t . SetSyscallRestartBlock ( & clockNanosleepRestartBlock { c : c , end : end , rem : rem , } ) return syserror . ERESTART_RESTARTBLOCK } return syserror . ERESTARTNOHAND default : panic ( fmt . Sprintf ( " " , err ) ) } }
clockNanosleepUntil blocks until a specified time.
clockNanosleepUntil blocks until a specified time .
// Turn on the timer. // Slept for entire timeout. // Interrupted. // Copy out remaining time. // Arrange for a restart with the remaining duration.