github.com/cilium/cilium@v1.16.2/bpf/lib/utils.h (about)

     1  /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
     2  /* Copyright Authors of Cilium */
     3  
     4  #pragma once
     5  
     6  #include <bpf/ctx/ctx.h>
     7  #include <bpf/api.h>
     8  
     9  #include "endian.h"
    10  #include "time.h"
    11  #include "static_data.h"
    12  
    13  #define __min(t_x, t_y, x, y)		\
    14  ({					\
    15  	t_x _x = (x);			\
    16  	t_y _y = (y);			\
    17  	(void) (&_x == &_y);		\
    18  	_x < _y ? _x : _y;		\
    19  })
    20  
    21  #define __max(t_x, t_y, x, y)		\
    22  ({					\
    23  	t_x _x = (x);			\
    24  	t_y _y = (y);			\
    25  	(void) (&_x == &_y);		\
    26  	_x > _y ? _x : _y;		\
    27  })
    28  
    29  #define min(x, y)			\
    30  	__min(typeof(x), typeof(y), x, y)
    31  
    32  #define max(x, y)			\
    33  	__max(typeof(x), typeof(y), x, y)
    34  
    35  #define min_t(t, x, y)			\
    36  	__min(t, t, x, y)
    37  
    38  #define max_t(t, x, y)			\
    39  	__max(t, t, x, y)