File: linux_mm.h

package info (click to toggle)
xlunzip 0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 276 kB
  • sloc: ansic: 2,063; sh: 430; makefile: 109
file content (36 lines) | stat: -rw-r--r-- 747 bytes parent folder | download | duplicates (2)
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
#ifndef DECOMPR_MM_H
#define DECOMPR_MM_H

#define large_malloc(a) malloc(a)
#define large_free(a) free(a)

#define INIT
#define STATIC

#define _FILE_OFFSET_BITS 64

#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

/*
 * min()/max() macros that also do strict type-checking.. See the
 * "unnecessary" pointer comparison.
 */
#define min(x, y) ({				\
	__typeof__(x) _min1 = (x);		\
	__typeof__(y) _min2 = (y);		\
	(void) (&_min1 == &_min2);		\
	_min1 < _min2 ? _min1 : _min2; })

#define max(x, y) ({				\
	__typeof__(x) _max1 = (x);		\
	__typeof__(y) _max2 = (y);		\
	(void) (&_max1 == &_max2);		\
	_max1 > _max2 ? _max1 : _max2; })

#define min_t(type, x, y) min((type) x, (type) y)

#endif