mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-21 18:27:22 +00:00
LinuxKPI: Add min_not_zero() to linux/minmax.h
It returns the minimum that is not zero, except both equals to zero. Sponsored by: Serenity Cyber Security, LLC MFC after: 1 week Reviewed by: bz, emaste, ssaxena Differential Revision: https://reviews.freebsd.org/D45450 Differential Revision: https://reviews.freebsd.org/D45451
This commit is contained in:
parent
f79474c4e3
commit
07c7c41ca1
|
@ -7,6 +7,7 @@
|
||||||
* Copyright (c) 2014-2015 François Tigeot
|
* Copyright (c) 2014-2015 François Tigeot
|
||||||
* Copyright (c) 2015 Hans Petter Selasky <hselasky@FreeBSD.org>
|
* Copyright (c) 2015 Hans Petter Selasky <hselasky@FreeBSD.org>
|
||||||
* Copyright (c) 2016 Matt Macy <mmacy@FreeBSD.org>
|
* Copyright (c) 2016 Matt Macy <mmacy@FreeBSD.org>
|
||||||
|
* Copyright (c) 2023 Serenity Cyber Security, LLC.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
@ -43,6 +44,12 @@
|
||||||
#define min3(a, b, c) min(a, min(b, c))
|
#define min3(a, b, c) min(a, min(b, c))
|
||||||
#define max3(a, b, c) max(a, max(b, c))
|
#define max3(a, b, c) max(a, max(b, c))
|
||||||
|
|
||||||
|
#define min_not_zero(x, y) ({ \
|
||||||
|
__typeof(x) __min1 = (x); \
|
||||||
|
__typeof(y) __min2 = (y); \
|
||||||
|
__min1 == 0 ? __min2 : ((__min2 == 0) ? __min1 : min(__min1, __min2));\
|
||||||
|
})
|
||||||
|
|
||||||
#define min_t(type, x, y) ({ \
|
#define min_t(type, x, y) ({ \
|
||||||
type __min1 = (x); \
|
type __min1 = (x); \
|
||||||
type __min2 = (y); \
|
type __min2 = (y); \
|
||||||
|
|
|
@ -100,10 +100,12 @@
|
||||||
* @x: value1
|
* @x: value1
|
||||||
* @y: value2
|
* @y: value2
|
||||||
*/
|
*/
|
||||||
|
#ifndef min_not_zero
|
||||||
#define min_not_zero(x, y) ({ \
|
#define min_not_zero(x, y) ({ \
|
||||||
typeof(x) __x = (x); \
|
typeof(x) __x = (x); \
|
||||||
typeof(y) __y = (y); \
|
typeof(y) __y = (y); \
|
||||||
__x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
|
__x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ib_mr_init_attr {
|
struct ib_mr_init_attr {
|
||||||
int max_reg_descriptors;
|
int max_reg_descriptors;
|
||||||
|
|
Loading…
Reference in a new issue