]> git.saurik.com Git - cydia.git/blob - CyteKit/UCPlatform.h
For progress JS on iOS 10 to solve race and flash.
[cydia.git] / CyteKit / UCPlatform.h
1 /* Cydia - iPhone UIKit Front-End for Debian APT
2 * Copyright (C) 2008-2015 Jay Freeman (saurik)
3 */
4
5 /* GNU General Public License, Version 3 {{{ */
6 /*
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.
11 *
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.
16 *
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 **/
20 /* }}} */
21
22 #ifndef CyteKit_UCPlatform_H
23 #define CyteKit_UCPlatform_H
24
25 #define __STDC_LIMIT_MACROS
26 #include <stdint.h>
27
28 #include <objc/objc.h>
29
30 #include <sys/time.h>
31 #include <time.h>
32
33 #define _forever \
34 for (;;)
35
36 extern struct timeval _ltv;
37 extern 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 } \
59 while (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