File: minmax.h

package info (click to toggle)
notion 4.0.2%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,676 kB
  • sloc: ansic: 47,508; sh: 2,096; makefile: 603; perl: 270
file content (29 lines) | stat: -rw-r--r-- 683 bytes parent folder | download | duplicates (4)
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
/*
 * libtu/minmax.h
 *
 * Copyright (c) Tuomo Valkonen 1999-2004.
 *
 * You may distribute and modify this library under the terms of either
 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
 */

#ifndef LIBTU_MINMAX_H
#define LIBTU_MINMAX_H

#if defined(__GNUC__) || defined(__clang__)

#define MINOF(a, b) __extension__ ({  \
	__typeof(a) a_ = (a); __typeof(b) b_ = (b); \
	((a_) < (b_) ? (a_) : (b_)); })
#define MAXOF(a, b) __extension__ ({  \
	__typeof(a) a_ = (a); __typeof(b) b_ = (b); \
	((a_) > (b_) ? (a_) : (b_)); })

#else

#define MINOF(X,Y) ((X) < (Y) ? (X) : (Y))
#define MAXOF(X,Y) ((X) > (Y) ? (X) : (Y))
#endif

#endif /* LIBTU_MINMAX_H */