Module Name: src Committed By: riastradh Date: Sun Sep 8 15:38:05 UTC 2013
Modified Files: src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: jiffies.h log2.h pagemap.h time.h timer.h types.h Log Message: More miscellaneous Linux header cruft. See patch for details. To generate a diff of this commit: cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \ src/sys/external/bsd/drm2/include/linux/jiffies.h \ src/sys/external/bsd/drm2/include/linux/timer.h cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \ src/sys/external/bsd/drm2/include/linux/log2.h cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \ src/sys/external/bsd/drm2/include/linux/pagemap.h \ src/sys/external/bsd/drm2/include/linux/time.h cvs rdiff -u -r1.1.2.7 -r1.1.2.8 \ src/sys/external/bsd/drm2/include/linux/types.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/include/linux/jiffies.h diff -u src/sys/external/bsd/drm2/include/linux/jiffies.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/jiffies.h:1.1.2.4 --- src/sys/external/bsd/drm2/include/linux/jiffies.h:1.1.2.3 Wed Jul 24 03:03:23 2013 +++ src/sys/external/bsd/drm2/include/linux/jiffies.h Sun Sep 8 15:38:04 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: jiffies.h,v 1.1.2.3 2013/07/24 03:03:23 riastradh Exp $ */ +/* $NetBSD: jiffies.h,v 1.1.2.4 2013/09/08 15:38:04 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -49,6 +49,12 @@ usecs_to_jiffies(unsigned int usec) return mstohz((usec + (1000 / hz) - 1) / (1000 / hz)); } +static inline unsigned int +timespec_to_jiffies(const struct timespec *ts) +{ + return tstohz(ts); +} + /* XXX long is the wrong type here times... */ #define __linux_time_compare(A, OP, B) (((long)(A) - (long)(B)) OP 0) Index: src/sys/external/bsd/drm2/include/linux/timer.h diff -u src/sys/external/bsd/drm2/include/linux/timer.h:1.1.2.3 src/sys/external/bsd/drm2/include/linux/timer.h:1.1.2.4 --- src/sys/external/bsd/drm2/include/linux/timer.h:1.1.2.3 Wed Jul 24 03:50:16 2013 +++ src/sys/external/bsd/drm2/include/linux/timer.h Sun Sep 8 15:38:04 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: timer.h,v 1.1.2.3 2013/07/24 03:50:16 riastradh Exp $ */ +/* $NetBSD: timer.h,v 1.1.2.4 2013/09/08 15:38:04 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -78,4 +78,10 @@ round_jiffies_up(unsigned long j) return roundup(j, hz); } +static inline unsigned long +round_jiffies_up_relative(unsigned long j) +{ + return roundup(j, hz); +} + #endif /* _LINUX_TIMER_H_ */ Index: src/sys/external/bsd/drm2/include/linux/log2.h diff -u src/sys/external/bsd/drm2/include/linux/log2.h:1.1.2.2 src/sys/external/bsd/drm2/include/linux/log2.h:1.1.2.3 --- src/sys/external/bsd/drm2/include/linux/log2.h:1.1.2.2 Wed Jul 24 02:03:00 2013 +++ src/sys/external/bsd/drm2/include/linux/log2.h Sun Sep 8 15:38:04 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: log2.h,v 1.1.2.2 2013/07/24 02:03:00 riastradh Exp $ */ +/* $NetBSD: log2.h,v 1.1.2.3 2013/09/08 15:38:04 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -34,4 +34,10 @@ #include <sys/bitops.h> +static inline bool +is_power_of_2(unsigned long x) +{ + return ((x != 0) && (((x - 1) & x) == 0)); +} + #endif /* _LINUX_LOG2_H_ */ Index: src/sys/external/bsd/drm2/include/linux/pagemap.h diff -u src/sys/external/bsd/drm2/include/linux/pagemap.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/pagemap.h:1.1.2.2 --- src/sys/external/bsd/drm2/include/linux/pagemap.h:1.1.2.1 Wed Jul 24 00:33:12 2013 +++ src/sys/external/bsd/drm2/include/linux/pagemap.h Sun Sep 8 15:38:04 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: pagemap.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $ */ +/* $NetBSD: pagemap.h,v 1.1.2.2 2013/09/08 15:38:04 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -32,4 +32,16 @@ #ifndef _LINUX_PAGEMAP_H_ #define _LINUX_PAGEMAP_H_ +static inline int +fault_in_multipages_readable(const char *uaddr __unused, size_t len __unused) +{ + return 0; +} + +static inline int +fault_in_multipages_writeable(char *uaddr __unused, size_t len __unused) +{ + return 0; +} + #endif /* _LINUX_PAGEMAP_H_ */ Index: src/sys/external/bsd/drm2/include/linux/time.h diff -u src/sys/external/bsd/drm2/include/linux/time.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/time.h:1.1.2.2 --- src/sys/external/bsd/drm2/include/linux/time.h:1.1.2.1 Wed Jul 24 03:18:46 2013 +++ src/sys/external/bsd/drm2/include/linux/time.h Sun Sep 8 15:38:04 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: time.h,v 1.1.2.1 2013/07/24 03:18:46 riastradh Exp $ */ +/* $NetBSD: time.h,v 1.1.2.2 2013/09/08 15:38:04 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -48,4 +48,66 @@ get_seconds(void) return time_second; } +static inline void +getrawmonotonic(struct timespec *ts) +{ + getnanouptime(ts); +} + +static inline bool +timespec_valid(const struct timespec *ts) +{ + if (ts->tv_sec < 0) + return false; + if (1000000000L <= ts->tv_nsec) + return false; + return true; +} + +static inline struct timespec +ns_to_timespec(const int64_t nsec) +{ + struct timespec ts; + + ts.tv_sec = (nsec / 1000000000L); + ts.tv_nsec = (nsec % 1000000000L); + if (ts.tv_nsec < 0) { + ts.tv_sec -= 1; + ts.tv_nsec += 1000000000L; + } + + return ts; +} + +static inline int64_t +timespec_to_ns(const struct timespec *ts) +{ + return (((int64_t)ts->tv_sec * 1000000000LL) + ts->tv_nsec); +} + +static inline struct timespec +timespec_sub(struct timespec a, struct timespec b) +{ + struct timespec d; + + timespecsub(&a, &b, &d); + + return d; +} + +static inline void +set_normalized_timespec(struct timespec *ts, time_t sec, int64_t nsec) +{ + while (nsec >= 1000000000L) { + nsec -= 1000000000L; + sec += 1; + } + while (nsec < 0) { + nsec += 1000000000L; + sec -= 1; + } + ts->tv_sec = sec; + ts->tv_nsec = nsec; +} + #endif /* _LINUX_TIME_H_ */ Index: src/sys/external/bsd/drm2/include/linux/types.h diff -u src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.7 src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.8 --- src/sys/external/bsd/drm2/include/linux/types.h:1.1.2.7 Wed Jul 24 02:50:51 2013 +++ src/sys/external/bsd/drm2/include/linux/types.h Sun Sep 8 15:38:04 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.1.2.7 2013/07/24 02:50:51 riastradh Exp $ */ +/* $NetBSD: types.h,v 1.1.2.8 2013/09/08 15:38:04 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -60,4 +60,7 @@ typedef paddr_t phys_addr_t; /* XXX Is this the right type? */ typedef unsigned long long cycles_t; +/* XXX Not sure this is correct. */ +typedef off_t loff_t; + #endif /* _LINUX_TYPES_H_ */