⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jiffies.h

📁 这是leon3处理器的交叉编译链
💻 H
字号:
#ifndef _LINUX_JIFFIES_H#define _LINUX_JIFFIES_H#include <asm-leon/types.h>#include <asm-leon/clock.h>#include <asm-leon/linkage.h>/* Suppose we want to devide two numbers NOM and DEN: NOM/DEN, the we can * improve accuracy by shifting LSH bits, hence calculating: *     (NOM << LSH) / DEN * This however means trouble for large NOM, because (NOM << LSH) may no * longer fit in 32 bits. The following way of calculating this gives us * some slack, under the following conditions: *   - (NOM / DEN) fits in (32 - LSH) bits. *   - (NOM % DEN) fits in (32 - LSH) bits. */#define SH_DIV(NOM,DEN,LSH) (   ((NOM / DEN) << LSH)                    \                             + (((NOM % DEN) << LSH) + DEN / 2) / DEN)/* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */#define TICK_NSEC (SH_DIV (1000000UL * 1000, (HZ<<8), 8))/* * The 64-bit value is not volatile - you MUST NOT read it * without sampling the sequence number in xtime_lock. */extern u64 jiffies_64;extern struct timespec xtime __attribute__ ((aligned (16)));#define jiffies (*((unsigned long *)(((unsigned long)(&jiffies_64))+4)))/* *	These inlines deal with timer wrapping correctly. You are  *	strongly encouraged to use them *	1. Because people otherwise forget *	2. Because if the timer wrap changes in future you won't have to *	   alter your driver code. * * time_after(a,b) returns true if the time a is after time b. * * Do this with "<0" and ">=0" to only test the sign of the result. A * good compiler would generate better code (and a really good compiler * wouldn't care). Gcc is currently neither. */#define time_after(a,b)		\	(typecheck(unsigned long, a) && \	 typecheck(unsigned long, b) && \	 ((long)(b) - (long)(a) < 0))#define time_before(a,b)	time_after(b,a)#define time_after_eq(a,b)	\	(typecheck(unsigned long, a) && \	 typecheck(unsigned long, b) && \	 ((long)(a) - (long)(b) >= 0))#define time_before_eq(a,b)	time_after_eq(b,a)/* * Have the 32 bit jiffies value wrap 5 minutes after boot * so jiffies wrap bugs show up earlier. */#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))static inline voidset_normalized_timespec (struct timespec *ts, time_t sec, long nsec){	while (nsec > NSEC_PER_SEC) {		nsec -= NSEC_PER_SEC;		++sec;	}	while (nsec < 0) {		nsec += NSEC_PER_SEC;		--sec;	}	ts->tv_sec = sec;	ts->tv_nsec = nsec;}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -