]> git.saurik.com Git - cydia.git/blame - CyteKit/UCPlatform.h
Cydia no longer runs as root. (WE FINALLY DID IT!)
[cydia.git] / CyteKit / UCPlatform.h
CommitLineData
449ef9d5 1/* Cydia - iPhone UIKit Front-End for Debian APT
6fa0bb60 2 * Copyright (C) 2008-2014 Jay Freeman (saurik)
449ef9d5
JF
3*/
4
6d9696a5 5/* GNU General Public License, Version 3 {{{ */
449ef9d5 6/*
6d9696a5
JF
7 * Cydia is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
449ef9d5 11 *
6d9696a5
JF
12 * Cydia is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
449ef9d5 16 *
6d9696a5
JF
17 * You should have received a copy of the GNU General Public License
18 * along with Cydia. If not, see <http://www.gnu.org/licenses/>.
19**/
449ef9d5
JF
20/* }}} */
21
819a0ab1
JF
22#ifndef CyteKit_UCPlatform_H
23#define CyteKit_UCPlatform_H
449ef9d5 24
819a0ab1
JF
25#define __STDC_LIMIT_MACROS
26#include <stdint.h>
449ef9d5 27
819a0ab1
JF
28#include <objc/objc.h>
29
30#include <sys/time.h>
31#include <time.h>
32
33#define _forever \
34 for (;;)
35
36extern struct timeval _ltv;
37extern bool _itv;
38
39#define _trace() do { \
40 struct timeval _ctv; \
41 gettimeofday(&_ctv, NULL); \
42 if (!_itv) { \
43 _itv = true; \
44 _ltv = _ctv; \
45 } \
46 fprintf(stderr, "%lu.%.6u[%f]:_trace()@%s:%u[%s]\n", \
47 _ctv.tv_sec, _ctv.tv_usec, \
48 (_ctv.tv_sec - _ltv.tv_sec) + (_ctv.tv_usec - _ltv.tv_usec) / 1000000.0, \
49 __FILE__, __LINE__, __FUNCTION__\
50 ); \
51 _ltv = _ctv; \
52} while (false)
53
54#define _assert(test) do \
55 if (!(test)) { \
56 fprintf(stderr, "_assert(%d:%s)@%s:%u[%s]\n", errno, #test, __FILE__, __LINE__, __FUNCTION__); \
57 exit(-1); \
58 } \
59while (false)
60
61#define _not(type) ((type) ~ (type) 0)
62
63#define _transient
64
65#define _label__(x) _label ## x
66#define _label_(y) _label__(y)
67#define _label _label_(__LINE__)
68
69#define _packed \
70 __attribute__((__packed__))
71#define _finline \
72 inline __attribute__((__always_inline__))
73
74#define _assume(e) \
75 _assert(e)
76
77#define _nodefault \
78 default: \
79 _assume(false); \
80 throw;
81
82#define _likely(expr) \
83 __builtin_expect(expr, 1)
84
85#define _unlikely(expr) \
86 __builtin_expect(expr, 0)
87
88#endif//CyteKit_UCPlatform_H