forked from mischasan/hx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.h
73 lines (63 loc) · 2.16 KB
/
util.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
70
71
72
73
// Copyright (C) 2009-2013 Mischa Sandberg <mischasan@gmail.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License Version 2 as
// published by the Free Software Foundation. You may not use, modify or
// distribute this program under any other version of the GNU General
// Public License.
//
// This program is distributed in the hope that it will 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 to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// IF YOU ARE UNABLE TO WORK WITH GPL2, CONTACT ME.
//-------------------------------------------------------------------
// This is a subset of util/msutil.h
#ifndef UTIL_H
#define UTIL_H
// Convenient format strings for intptr_t etc
// The strings do NOT include the "%", so that the user can specify
// width/justification etc.
#ifdef __x86_64__
# define FPTR "l"
#elif __SIZEOF_POINTER__ == __SIZEOF_INT__
# define FPTR
#elif __SIZEOF_POINTER__ == __SIZEOF_LONG__
# define FPTR "l"
#else
# error need to define FPTR
#endif
// This does not work on gcc 4.1 (64)
#if __LONG_LONG_MAX__ == __LONG_MAX__
# define FSIZE "l"
#elif __SIZEOF_SIZE_T__ == __SIZEOF_INT__
# define FSIZE
#elif __SIZEOF_SIZE_T__ == __SIZEOF_LONG__
# define FSIZE "l"
#else
# error need to define FSIZE
#endif
#if __LONG_MAX__ == 9223372036854775807L
# define F64 "l"
#elif __LONG_MAX__ == 2147483647L
# define F64 "ll"
#else
# error need to defined F64
#endif
#define FOFF FPTR
extern char const *errname[];
char* acstr(char const *buf, int len);
void die(char const *fmt, ...);
void dx(FILE *fp, char const *buf, int len);
#if defined(__linux__)
char const *getprogname(void); // BSD-equivalent
#endif
int systemf(char const *fmt, ...);
double tick(void);
void usage(char const *str);
#endif//UTIL_H