forked from hisilicon/overlayfs-progs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.h
69 lines (58 loc) · 1.91 KB
/
common.h
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
66
67
68
69
/*
* Copyright (c) 2017 Huawei. All Rights Reserved.
* Author: zhangyi (F) <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef OVL_COMMON_H
#define OVL_COMMON_H
#ifndef __attribute__
# if !defined __GNUC__ || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
# define __attribute__(x)
# endif
#endif
#ifdef USE_GETTEXT
#include <libintl.h>
#define _(x) gettext((x))
#else
#define _(x) (x)
#endif
#ifndef max
#define max(x, y) ({ \
typeof(x) _max1 = (x); \
typeof(y) _max2 = (y); \
(void) (&_max1 == &_max2); \
_max1 > _max2 ? _max1 : _max2; })
#endif
#ifndef min
#define min(x, y) ({ \
typeof(x) _min1 = (x); \
typeof(y) _min2 = (y); \
(void) (&_min1 == &_min2); \
_min1 < _min2 ? _min1 : _min2; })
#endif
/* Print an error message */
void print_err(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
/* Print an info message */
void print_info(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
/* Print an debug message */
void print_debug(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
/* Safety wrapper */
void *smalloc(size_t size);
void *srealloc(void *addr, size_t size);
char *sstrdup(const char *src);
char *sstrndup(const char *src, size_t num);
/* Print program version */
void version(void);
#endif /* OVL_COMMON_H */