Last active
December 9, 2018 17:27
-
-
Save untodesu/d52b69dee3f4975686ac2a2c57fda847 to your computer and use it in GitHub Desktop.
Usual typedefs collections. Git fun, m8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************** | |
Simple Integer/etc nums types definition header for C/C++ | |
Git fun, m8. Made by UND85D in 2018 | |
***********************************************************************/ | |
#ifndef SNTYPES_HEADER | |
#define SNTYPES_HEADER | |
#if (('1234' >> 24) == '1') /* If system IS Little Endian aka Low Endian aka Intel's shit | |
(Thousand two hundred thirty four is 4321) */ | |
#define LOW_ENDIAN /* We shall define this small constant | |
which signals the programmer that | |
the machine has a Low(Little, Intel)-Endian architecture */ | |
#elif (('4321' >> 24) == '1') /* But if system IS High Endian aka kosher endian aka Inteln't shit | |
(Thousand two hundred thirty four is 1234) */ | |
#define HIGH_ENDIAN /* We shall define this small constant | |
which signals the programmer that | |
the machine has a High(Big, Inteln't)-Endian architecture */ | |
#else /* What is this? IDK. You just compile program with this header on | |
machine with WhatTheFeck-Endian architecture*/ | |
#error Low or big endian? IDK :D | |
#endif | |
#include <stdint.h> | |
/* | |
* Standart type definitions | |
*/ | |
/* The 8-bit(On AMD64/x86) integer aka byte */ | |
typedef unsigned char u8_t; /* Unsigned value */ | |
typedef signed char s8_t; /* Signed value */ | |
/* The 16-bit(On AMD64/x86) integer aka short */ | |
typedef unsigned short int u16_t; /* Unsigned value */ | |
typedef signed short int s16_t; /* Signed value */ | |
/* The 32-bit(On AMD64/x86) integer aka int */ | |
typedef unsigned int u32_t; /* Unsigned value */ | |
typedef signed int s32_t; /* Signed value */ | |
/* The 64-bit(On AMD64/x86) integer aka long */ | |
typedef unsigned long int u64_t; /* Unsigned value */ | |
typedef signed long int s64_t; /* Signed value */ | |
/* The floating point types */ | |
typedef float f32_t; /* Regular float 32-bit number */ | |
typedef double f64_t; /* Double precision 64-bit type */ | |
typedef long double f80_t; /* More bits and more precision! */ | |
/* | |
* Union types | |
*/ | |
/* The word type */ | |
typedef union { | |
u16_t whole; /* Usual number */ | |
struct { | |
#if defined(HIGH_ENDIAN) /* If system IS Big Endian | |
(One Hundred Two Thousand Four is 1234) */ | |
u8_t hi; /* Higher byte will stay first */ | |
u8_t lo; /* And lower byte will stay second */ | |
#elif defined(LOW_ENDIAN) /* But if system IS Little Endian! | |
(One Hundred Two Thousand Four is 4321) */ | |
u8_t lo; /* Lower byte will stay first */ | |
u8_t hi; /* And higher byte will stay second */ | |
#endif | |
} split; /* Lower and higher bytes of u16 */ | |
} word_t; | |
/* The double-word type */ | |
typedef union { | |
u32_t whole; /* Usual number */ | |
struct { | |
#if defined(HIGH_ENDIAN) /* If system IS Big Endian | |
(One Hundred Two Thousand Four is 1234) */ | |
word_t hi; /* Higher word will stay first */ | |
word_t lo; /* And lower word will stay second */ | |
#elif defined(LOW_ENDIAN) /* But if system IS Little Endian! | |
(One Hundred Two Thousand Four is 4321) */ | |
word_t lo; /* Lower word will stay first */ | |
word_t hi; /* And higher word will stay second */ | |
#endif | |
} split; /* Lower and higher words of u32 */ | |
} dword_t; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
аффтар маладец, спасибо за проделанную работу!