File: minmax.h

package info (click to toggle)
bladerf 0.2024.05-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 245,984 kB
  • sloc: ansic: 361,923; vhdl: 28,167; tcl: 14,424; python: 3,668; sh: 1,811; makefile: 1,255; xml: 1,020; cpp: 473; asm: 158; csh: 18
file content (65 lines) | stat: -rw-r--r-- 1,124 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
 * @file minmax.h
 *
 * @brief These static inline routines are preferred over the use of macros,
 *        as they provide type safety.
 */

#ifndef MINMAX_H__
#define MINMAX_H__

#include <stdlib.h>
#include <stdint.h>
#include "host_config.h"

static inline size_t min_sz(size_t x, size_t y)
{
    return x < y ? x : y;
}

static inline size_t max_sz(size_t x, size_t y)
{
    return x > y ? x : y;
}

static inline unsigned int uint_min(unsigned int x, unsigned int y)
{
    return x < y ? x : y;
}

static inline unsigned int uint_max(unsigned int x, unsigned int y)
{
    return x > y ? x : y;
}

static inline uint32_t u32_min(uint32_t x, uint32_t y)
{
    return x < y ? x : y;
}

static inline uint32_t u32_max(uint32_t x, uint32_t y)
{
    return x > y ? x : y;
}

static inline int64_t i64_min(int64_t x, int64_t y)
{
    return x < y ? x : y;
}

static inline uint64_t u64_min(uint64_t x, uint64_t y)
{
    return x < y ? x : y;
}

static inline int64_t i64_max(int64_t x, int64_t y)
{
    return x > y ? x : y;
}

static inline uint64_t u64_max(uint64_t x, uint64_t y)
{
    return x > y ? x : y;
}

#endif