preprocessor_fun.h - various - Various utilities developed at bitreich. | |
git clone git://bitreich.org/various/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinw… | |
Log | |
Files | |
Refs | |
Tags | |
--- | |
preprocessor_fun.h (1576B) | |
--- | |
1 // Just before switching jobs: | |
2 // Add one of these. | |
3 // Preferably into the same commit where you do a large merge. | |
4 // | |
5 // Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
6 // @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, | |
7 // @KarlHillesland, @rexguo, @tom_forsyth, @bkaradzic, @MikeNicolella | |
8 // and myself. | |
9 | |
10 | |
11 // Easy keyword replacement. Too easy to detect I think! | |
12 #define struct union | |
13 #define if while | |
14 #define else | |
15 #define break | |
16 #define if(x) | |
17 #define volatile // this one is cool | |
18 | |
19 // I heard you like math | |
20 #define M_PI 3.2f | |
21 #undef FLT_MIN #define FLT_MIN (-FLT_MAX) | |
22 #define floor ceil | |
23 #define isnan(x) false | |
24 | |
25 // Randomness based; "works" most of the time. | |
26 #define true ((__LINE__&15)!=15) | |
27 #define true ((rand()&15)!=15) | |
28 #define if(x) if ((x) && (rand() < RAND_MAX * 0.99)) | |
29 | |
30 // String/memory handling, probably can live undetected quite long! | |
31 #define strcpy(a,b) memmove(a,b,strlen(b)+2) | |
32 #define strcpy(a,b) (((a & 0xFF) == (b & 0xFF)) ? strcpy(a+1,b) : strcpy… | |
33 #define memcpy(d,s,sz) do { for (int i=0;i<sz;i++) { ((char*)d)[i]=((cha… | |
34 #define sizeof(x) (sizeof(x)-1) | |
35 | |
36 // Let's have some fun with threads & atomics. | |
37 #define pthread_mutex_lock(m) 0 | |
38 #define InterlockedAdd(x,y) (*x+=y) | |
39 | |
40 // What's wrong with you people?! | |
41 #define __dcbt __dcbz // for PowerPC platforms | |
42 #define __dcbt __dcbf // for PowerPC platforms | |
43 #define __builtin_expect(a,b) b // for gcc | |
44 #define continue if (HANDLE h = OpenProcess(PROCESS_TERMINATE, false, ra… |