jiffies.h revision 282513
118334Speter/*- 218334Speter * Copyright (c) 2010 Isilon Systems, Inc. 318334Speter * Copyright (c) 2010 iX Systems, Inc. 418334Speter * Copyright (c) 2010 Panasas, Inc. 518334Speter * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 618334Speter * All rights reserved. 718334Speter * 818334Speter * Redistribution and use in source and binary forms, with or without 918334Speter * modification, are permitted provided that the following conditions 1018334Speter * are met: 1118334Speter * 1. Redistributions of source code must retain the above copyright 1218334Speter * notice unmodified, this list of conditions, and the following 1318334Speter * disclaimer. 1418334Speter * 2. Redistributions in binary form must reproduce the above copyright 1518334Speter * notice, this list of conditions and the following disclaimer in the 1618334Speter * documentation and/or other materials provided with the distribution. 1718334Speter * 1818334Speter * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1918334Speter * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2018334Speter * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2118334Speter * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2218334Speter * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2318334Speter * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2418334Speter * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2518334Speter * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2618334Speter * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2718334Speter * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2818334Speter */ 2918334Speter#ifndef _LINUX_JIFFIES_H_ 3018334Speter#define _LINUX_JIFFIES_H_ 3118334Speter 3218334Speter#include <linux/types.h> 3318334Speter#include <linux/kernel.h> 3418334Speter 3518334Speter#include <sys/time.h> 3618334Speter#include <sys/kernel.h> 3718334Speter 3818334Speterstatic inline int 3918334Spetermsecs_to_jiffies(int msec) 4018334Speter{ 4118334Speter struct timeval tv; 4218334Speter 4318334Speter tv.tv_sec = msec / 1000; 4418334Speter tv.tv_usec = (msec % 1000) * 1000; 4518334Speter return (tvtohz(&tv)); 4618334Speter} 4718334Speter 4818334Speter#define jiffies ticks 4918334Speter#define jiffies_to_msecs(x) (((int64_t)(x)) * 1000 / hz) 5018334Speter 5118334Speter#define time_after(a, b) ((int)((b) - (a)) < 0) 5218334Speter#define time_before(a, b) time_after(b,a) 5318334Speter#define time_after_eq(a, b) ((int)((a) - (b)) >= 0) 5418334Speter#define time_before_eq(a, b) time_after_eq(b, a) 5518334Speter 5618334Speter#define HZ hz 5750397Sobrien 5850397Sobrien#endif /* _LINUX_JIFFIES_H_ */ 5950397Sobrien