]> git.saurik.com Git - minimal.git/blame - stdlib.h
Adding Pamphlet for Brian.
[minimal.git] / stdlib.h
CommitLineData
ee9c93b9
JF
1/* Minimal - the simplest thing that could possibly work
2 * Copyright (C) 2007 Jay Freeman (saurik)
3*/
4
5/*
6 * Redistribution and use in source and binary
7 * forms, with or without modification, are permitted
8 * provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the
11 * above copyright notice, this list of conditions
12 * and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the
14 * above copyright notice, this list of conditions
15 * and the following disclaimer in the documentation
16 * and/or other materials provided with the
17 * distribution.
18 * 3. The name of the author may not be used to endorse
19 * or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
24 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
33 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36*/
37
64c5d5aa
JF
38#ifndef MINIMAL_STDLIB_H
39#define MINIMAL_STDLIB_H
40
d4987f7d
JF
41#define _assert(expr) \
42 do if (!(expr)) { \
3ed54889 43 fprintf(stderr, "%s(%u): _assert(%u:%s)\n", __FILE__, __LINE__, errno, #expr); \
d4987f7d
JF
44 exit(1); \
45 } while (false)
46
47#define _syscall(expr) \
48 do if ((long) (expr) != -1) \
49 break; \
50 else switch (errno) { \
51 case EINTR: \
52 continue; \
53 default: \
54 _assert(false); \
55 } while (true)
56
57#define _forever \
58 for (;;)
59
60#define _trace() \
a75f8a40 61 printf("_trace(%s:%u): %s\n", __FILE__, __LINE__, __FUNCTION__)
d4987f7d 62
3ed54889
JF
63#define _not(type) \
64 ((type) ~ (type) 0)
65
2b559b76
JF
66#define _breakpoint() \
67 __asm__ { int 0x3 }
68
64c5d5aa 69#define _disused \
2b559b76
JF
70 __attribute__((unused))
71
20363569 72#include <errno.h>
d4987f7d
JF
73#include <stdio.h>
74#include <stdbool.h>
75#include <stdlib.h>
76#include <stdint.h>
64c5d5aa
JF
77
78#endif/*MINIMAL_STDLIB_H*/