From owner-svn-src-head@freebsd.org Tue Aug 8 04:34:03 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C0F7ADBFE4B; Tue, 8 Aug 2017 04:34:03 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9CE016E390; Tue, 8 Aug 2017 04:34:03 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v784Y2I3081105; Tue, 8 Aug 2017 04:34:02 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v784Y2ph081103; Tue, 8 Aug 2017 04:34:02 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201708080434.v784Y2ph081103@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 8 Aug 2017 04:34:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322213 - head/sys/compat/linuxkpi/common/include/linux X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/compat/linuxkpi/common/include/linux X-SVN-Commit-Revision: 322213 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Aug 2017 04:34:03 -0000 Author: markj Date: Tue Aug 8 04:34:02 2017 New Revision: 322213 URL: https://svnweb.freebsd.org/changeset/base/322213 Log: Add round_jiffies_up(), local_clock() and __setup_timer() to the LinuxKPI. Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D11871 Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h head/sys/compat/linuxkpi/common/include/linux/timer.h Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/sched.h Tue Aug 8 04:30:22 2017 (r322212) +++ head/sys/compat/linuxkpi/common/include/linux/sched.h Tue Aug 8 04:34:02 2017 (r322213) @@ -36,14 +36,16 @@ #include #include #include +#include +#include #include #include +#include #include #include -#include #include -#include +#include #include @@ -149,5 +151,14 @@ int linux_schedule_timeout(int timeout); #define io_schedule() schedule() #define io_schedule_timeout(timeout) schedule_timeout(timeout) + +static inline uint64_t +local_clock(void) +{ + struct timespec ts; + + nanotime(&ts); + return ((uint64_t)ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec); +} #endif /* _LINUX_SCHED_H_ */ Modified: head/sys/compat/linuxkpi/common/include/linux/timer.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/timer.h Tue Aug 8 04:30:22 2017 (r322212) +++ head/sys/compat/linuxkpi/common/include/linux/timer.h Tue Aug 8 04:34:02 2017 (r322213) @@ -46,15 +46,20 @@ struct timer_list { extern unsigned long linux_timer_hz_mask; -#define setup_timer(timer, func, dat) \ -do { \ +#define TIMER_IRQSAFE 0x0001 + +#define setup_timer(timer, func, dat) do { \ (timer)->function = (func); \ (timer)->data = (dat); \ callout_init(&(timer)->timer_callout, 1); \ } while (0) -#define init_timer(timer) \ -do { \ +#define __setup_timer(timer, func, dat, flags) do { \ + CTASSERT(((flags) & ~TIMER_IRQSAFE) == 0); \ + setup_timer(timer, func, dat); \ +} while (0) + +#define init_timer(timer) do { \ (timer)->function = NULL; \ (timer)->data = 0; \ callout_init(&(timer)->timer_callout, 1); \ @@ -67,9 +72,10 @@ extern void add_timer_on(struct timer_list *, int cpu) #define del_timer(timer) callout_stop(&(timer)->timer_callout) #define del_timer_sync(timer) callout_drain(&(timer)->timer_callout) #define timer_pending(timer) callout_pending(&(timer)->timer_callout) -#define round_jiffies(j) \ +#define round_jiffies(j) \ ((unsigned long)(((j) + linux_timer_hz_mask) & ~linux_timer_hz_mask)) -#define round_jiffies_relative(j) \ - round_jiffies(j) +#define round_jiffies_relative(j) round_jiffies(j) +#define round_jiffies_up(j) round_jiffies(j) +#define round_jiffies_up_relative(j) round_jiffies_up(j) #endif /* _LINUX_TIMER_H_ */