util.h (ea8c5356d39048bc94bae068228f51ddbecc6b89) | util.h (6f10f7d1b02b1bbc305f88d7696445dd38b13881) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0 */ 2 3#ifndef _BCACHE_UTIL_H 4#define _BCACHE_UTIL_H 5 6#include <linux/blkdev.h> 7#include <linux/errno.h> 8#include <linux/kernel.h> --- 333 unchanged lines hidden (view full) --- 342 var = clamp_t(typeof(var), _v, min, max); \ 343 _r; \ 344}) 345 346#define snprint(buf, size, var) \ 347 snprintf(buf, size, \ 348 __builtin_types_compatible_p(typeof(var), int) \ 349 ? "%i\n" : \ | 1/* SPDX-License-Identifier: GPL-2.0 */ 2 3#ifndef _BCACHE_UTIL_H 4#define _BCACHE_UTIL_H 5 6#include <linux/blkdev.h> 7#include <linux/errno.h> 8#include <linux/kernel.h> --- 333 unchanged lines hidden (view full) --- 342 var = clamp_t(typeof(var), _v, min, max); \ 343 _r; \ 344}) 345 346#define snprint(buf, size, var) \ 347 snprintf(buf, size, \ 348 __builtin_types_compatible_p(typeof(var), int) \ 349 ? "%i\n" : \ |
350 __builtin_types_compatible_p(typeof(var), unsigned) \ | 350 __builtin_types_compatible_p(typeof(var), unsigned int) \ |
351 ? "%u\n" : \ 352 __builtin_types_compatible_p(typeof(var), long) \ 353 ? "%li\n" : \ 354 __builtin_types_compatible_p(typeof(var), unsigned long)\ 355 ? "%lu\n" : \ 356 __builtin_types_compatible_p(typeof(var), int64_t) \ 357 ? "%lli\n" : \ 358 __builtin_types_compatible_p(typeof(var), uint64_t) \ --- 15 unchanged lines hidden (view full) --- 374 uint64_t max_duration; 375 uint64_t average_duration; 376 uint64_t average_frequency; 377 uint64_t last; 378}; 379 380void bch_time_stats_update(struct time_stats *stats, uint64_t time); 381 | 351 ? "%u\n" : \ 352 __builtin_types_compatible_p(typeof(var), long) \ 353 ? "%li\n" : \ 354 __builtin_types_compatible_p(typeof(var), unsigned long)\ 355 ? "%lu\n" : \ 356 __builtin_types_compatible_p(typeof(var), int64_t) \ 357 ? "%lli\n" : \ 358 __builtin_types_compatible_p(typeof(var), uint64_t) \ --- 15 unchanged lines hidden (view full) --- 374 uint64_t max_duration; 375 uint64_t average_duration; 376 uint64_t average_frequency; 377 uint64_t last; 378}; 379 380void bch_time_stats_update(struct time_stats *stats, uint64_t time); 381 |
382static inline unsigned local_clock_us(void) | 382static inline unsigned int local_clock_us(void) |
383{ 384 return local_clock() >> 10; 385} 386 387#define NSEC_PER_ns 1L 388#define NSEC_PER_us NSEC_PER_USEC 389#define NSEC_PER_ms NSEC_PER_MSEC 390#define NSEC_PER_sec NSEC_PER_SEC --- 147 unchanged lines hidden (view full) --- 538 539#define RB_NEXT(ptr, member) \ 540 container_of_or_null(rb_next(&(ptr)->member), typeof(*ptr), member) 541 542#define RB_PREV(ptr, member) \ 543 container_of_or_null(rb_prev(&(ptr)->member), typeof(*ptr), member) 544 545/* Does linear interpolation between powers of two */ | 383{ 384 return local_clock() >> 10; 385} 386 387#define NSEC_PER_ns 1L 388#define NSEC_PER_us NSEC_PER_USEC 389#define NSEC_PER_ms NSEC_PER_MSEC 390#define NSEC_PER_sec NSEC_PER_SEC --- 147 unchanged lines hidden (view full) --- 538 539#define RB_NEXT(ptr, member) \ 540 container_of_or_null(rb_next(&(ptr)->member), typeof(*ptr), member) 541 542#define RB_PREV(ptr, member) \ 543 container_of_or_null(rb_prev(&(ptr)->member), typeof(*ptr), member) 544 545/* Does linear interpolation between powers of two */ |
546static inline unsigned fract_exp_two(unsigned x, unsigned fract_bits) | 546static inline unsigned int fract_exp_two(unsigned int x, 547 unsigned int fract_bits) |
547{ | 548{ |
548 unsigned fract = x & ~(~0 << fract_bits); | 549 unsigned int fract = x & ~(~0 << fract_bits); |
549 550 x >>= fract_bits; 551 x = 1 << x; 552 x += (x * fract) >> fract_bits; 553 554 return x; 555} 556 --- 12 unchanged lines hidden --- | 550 551 x >>= fract_bits; 552 x = 1 << x; 553 x += (x * fract) >> fract_bits; 554 555 return x; 556} 557 --- 12 unchanged lines hidden --- |