ReactOS 0.4.15-dev-8339-g4028de8
common.h
Go to the documentation of this file.
1/* common.h - Common functions
2
3 Copyright (C) 1993 Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
4 Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 The complete text of the GNU General Public License
20 can be found in /usr/share/common-licenses/GPL-3 file.
21*/
22
23#ifndef _COMMON_H
24#define _COMMON_H
25
26#ifndef __REACTOS__
27void die(const char *msg, ...)
28 __attribute((noreturn, format(printf, 1, 2)));
29#else
30DECLSPEC_NORETURN // __attribute((noreturn))
31void die_func(const char *msg, ...);
32#define die(msg, ...) \
33do { \
34 die_func("DIE! (%s:%d) " msg "\n", __RELFILE__, __LINE__, ##__VA_ARGS__); \
35} while (0)
36#endif
37
38/* Displays a prinf-style message and terminates the program. */
39
40#ifndef __REACTOS__
41void pdie(const char *msg, ...)
42 __attribute((noreturn, format(printf, 1, 2)));
43#else
44DECLSPEC_NORETURN // __attribute((noreturn))
45void pdie_func(const char *msg, ...);
46#define pdie(msg, ...) \
47do { \
48 pdie_func("P-DIE! (%s:%d) " msg "\n", __RELFILE__, __LINE__, ##__VA_ARGS__); \
49} while (0)
50#endif
51
52/* Like die, but appends an error message according to the state of errno. */
53
54#ifndef __REACTOS__
55void *alloc(int size);
56#else
57void *vfalloc(int size);
58void *vfcalloc(int size, int count);
59void vffree(void *ptr);
60#endif
61
62/* mallocs SIZE bytes and returns a pointer to the data. Terminates the program
63 if malloc fails. */
64
65void *qalloc(void **root, int size);
66
67/* Like alloc, but registers the data area in a list described by ROOT. */
68
69void qfree(void **root);
70
71/* Deallocates all qalloc'ed data areas described by ROOT. */
72
73#ifndef __REACTOS__
74int min(int a, int b);
75#endif
76
77/* Returns the smaller integer value of a and b. */
78
79char get_key(const char *valid, const char *prompt);
80
81/* Displays PROMPT and waits for user input. Only characters in VALID are
82 accepted. Terminates the program on EOF. Returns the character. */
83
84#endif
#define msg(x)
Definition: auth_time.c:54
#define printf
Definition: freeldr.h:97
BOOLEAN valid
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define die(str)
Definition: mkdosfs.c:347
static PVOID ptr
Definition: dispmode.c:27
#define min(a, b)
Definition: monoChain.cc:55
#define DECLSPEC_NORETURN
Definition: ntbasedef.h:176
#define alloc
Definition: rosglue.h:13
void * qalloc(void **root, int size)
Definition: common.c:139
void pdie(const char *msg,...) __attribute((noreturn
void qfree(void **root)
Definition: common.c:157
char get_key(const char *valid, const char *prompt)
Definition: common.c:184