summaryrefslogtreecommitdiffstats
path: root/douint.c
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2010-07-09 12:32:17 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2010-07-09 12:32:17 +0200
commit6c027b4de25a529908be895e7ff19236f4002a57 (patch)
treef70d3a400bbb9ba8a83e9d4ffcaa4b6e367fc8bb /douint.c
downloadcrypto-6c027b4de25a529908be895e7ff19236f4002a57.zip
crypto-6c027b4de25a529908be895e7ff19236f4002a57.tar.gz
initial commit, resurrect one of my realy old projects
Diffstat (limited to 'douint.c')
-rw-r--r--douint.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/douint.c b/douint.c
new file mode 100644
index 0000000..bccf4a9
--- /dev/null
+++ b/douint.c
@@ -0,0 +1,76 @@
+#include <stdio.h>
+int main(void)
+{
+ unsigned char us; /* using short makes twofish colapse */
+ unsigned int ui;
+ unsigned long ul;
+ unsigned long long ull;
+
+ printf("#ifndef _UINT_H\n#define _UINT_H\n\n");
+ printf(" /* This file was auto-generated. Do not edit! */\n\n");
+ /* u8 */
+ us = 1<<6;
+ us += us;
+ if(us)printf("typedef unsigned char u8;\n\n");
+ else{
+ ui = 1<<6;
+ ui += ui;
+ if(ui) printf("typedef unsigned int u8;\n\n");
+ }
+ printf("#define U8_MAX 0xFF\n\n");
+
+ /* u16 */
+ ui = 1<<14;
+ ui += ui;
+ if(ui)printf("typedef unsigned int u16;\n\n");
+ else{
+ ul = 1<<14;
+ ul += ul;
+ if(ul) printf("typedef unsigned long u16;\n\n");
+ }
+ printf("#define U16_MAX 0xFFFF\n\n");
+
+ /* u32 */
+ ui = 1<<30;
+ ui += ui;
+ if(ui)printf("typedef unsigned int u32;\n\n");
+ else{
+ ul = 1<<30;
+ ul += ul;
+ if(ul) printf("typedef unsigned long u32;\n\n");
+ else{
+ ull = 1<<30;
+ ull += ull;
+ if(ull) printf("typedef unsigned long long u32;\n\n");
+ }
+ }
+ printf("#define U32_MAX 0xFFFFFFFF\n\n");
+
+ /* u64 */
+ ui = 1<<31;
+ ui += ui; ui += ui; ui += ui; ui += ui; ui += ui; ui += ui; ui += ui; ui += ui;
+ ui += ui; ui += ui; ui += ui; ui += ui; ui += ui; ui += ui; ui += ui; ui += ui;
+ ui += ui; ui += ui; ui += ui; ui += ui; ui += ui; ui += ui; ui += ui; ui += ui;
+ ui += ui; ui += ui; ui += ui; ui += ui; ui += ui; ui += ui; ui += ui; ui += ui;
+ if(ui)printf("typedef unsigned int u64;\n\n");
+ else{
+ ul = 1<<31;
+ ul += ul; ul += ul; ul += ul; ul += ul; ul += ul; ul += ul; ul += ul; ul += ul;
+ ul += ul; ul += ul; ul += ul; ul += ul; ul += ul; ul += ul; ul += ul; ul += ul;
+ ul += ul; ul += ul; ul += ul; ul += ul; ul += ul; ul += ul; ul += ul; ul += ul;
+ ul += ul; ul += ul; ul += ul; ul += ul; ul += ul; ul += ul; ul += ul; ul += ul;
+ if(ul) printf("typedef unsigned long u64;\n\n");
+ else{
+ ull = 1<<31;
+ ull += ull; ull += ull; ull += ull; ull += ull; ull += ull; ull += ull; ull += ull; ull += ull;
+ ull += ull; ull += ull; ull += ull; ull += ull; ull += ull; ull += ull; ull += ull; ull += ull;
+ ull += ull; ull += ull; ull += ull; ull += ull; ull += ull; ull += ull; ull += ull; ull += ull;
+ ull += ull; ull += ull; ull += ull; ull += ull; ull += ull; ull += ull; ull += ull; ull += ull;
+ if(ull) printf("typedef unsigned long long u64;\n\n");
+ else printf(" * no u64 available !! *\n\n");
+ }
+ }
+ printf("#define U64_MAX 0xFFFFFFFFFFFFFFFF\n\n");
+ printf("#endif\n");
+ return 0;
+}