# clock_adjtime ______________________________________________
# SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock,
#                 struct timex __user *, utx)
# long compat_sys_clock_adjtime(clockid_t which_clock,
#                               struct compat_timex __user *utp)
#

@define _SYSCALL_CLOCK_ADJTIME_NAME
%(
	name = "clock_adjtime"
%)

@define _SYSCALL_CLOCK_ADJTIME_ARGSTR
%(
	argstr = sprintf("%s, %s", clk_id_str, tx_uaddr_str)
%)

probe syscall.clock_adjtime = dw_syscall.clock_adjtime !, nd_syscall.clock_adjtime ? {}
probe syscall.clock_adjtime.return = dw_syscall.clock_adjtime.return !, nd_syscall.clock_adjtime.return ? {}

# dw_clock_adjtime _____________________________________________________

probe dw_syscall.clock_adjtime = __syscall.clock_adjtime ?,
	__syscall.compat_clock_adjtime ?
{
	@_SYSCALL_CLOCK_ADJTIME_NAME
}
probe __syscall.clock_adjtime = kernel.function("sys_clock_adjtime").call
{
	@__syscall_gate_compat_simple
	clk_id = __int32($which_clock)
	clk_id_str = _get_wc_str(clk_id)
	tx_uaddr = @choose_defined($utx, $ktx)
	tx_uaddr_str = _struct_timex_u(tx_uaddr)
	@_SYSCALL_CLOCK_ADJTIME_ARGSTR
}
probe __syscall.compat_clock_adjtime =
	kernel.function("compat_sys_clock_adjtime").call ?
{
	clk_id = __int32($which_clock)
	clk_id_str = _get_wc_str(clk_id)
	tx_uaddr = $utp
	tx_uaddr_str = _struct_compat_timex_u(tx_uaddr)
	@_SYSCALL_CLOCK_ADJTIME_ARGSTR
}
probe dw_syscall.clock_adjtime.return = __syscall.clock_adjtime.return ?,
	kernel.function("compat_sys_clock_adjtime").return ?
{
	@_SYSCALL_CLOCK_ADJTIME_NAME
	retstr = return_str(1, $return)
}
probe __syscall.clock_adjtime.return =
	kernel.function("sys_clock_adjtime").return
{
	@__syscall_gate_compat_simple
}

# nd_clock_adjtime _____________________________________________________

probe nd_syscall.clock_adjtime = __nd_syscall.clock_adjtime ?,
	__nd_syscall.compat_clock_adjtime ?
{
	@_SYSCALL_CLOCK_ADJTIME_NAME
}
probe __nd_syscall.clock_adjtime = kprobe.function("sys_clock_adjtime").call
{
	@__syscall_gate_compat_simple
	asmlinkage()
	clk_id = int_arg(1)
	clk_id_str = _get_wc_str(clk_id)
	tx_uaddr = pointer_arg(2)
	tx_uaddr_str = _struct_timex_u(tx_uaddr)
	@_SYSCALL_CLOCK_ADJTIME_ARGSTR
}
probe __nd_syscall.compat_clock_adjtime =
	kprobe.function("compat_sys_clock_adjtime").call ?
{
	asmlinkage()
	clk_id = int_arg(1)
	clk_id_str = _get_wc_str(clk_id)
	tx_uaddr = pointer_arg(2)
	tx_uaddr_str = _struct_compat_timex_u(tx_uaddr)
	@_SYSCALL_CLOCK_ADJTIME_ARGSTR
}
probe nd_syscall.clock_adjtime.return = __nd_syscall.clock_adjtime.return ?,
	kprobe.function("compat_sys_clock_adjtime").return ?
{
	@_SYSCALL_CLOCK_ADJTIME_NAME
	retstr = returnstr(1)
}
probe __nd_syscall.clock_adjtime.return =
	kprobe.function("sys_clock_adjtime").return
{
	@__syscall_gate_compat_simple
}
