
CHIP OVERCLOK
CHIP OVERCLOK
CHIP OVERCLOK
CHIP OVERCLOK
CHIP OVERCLOK
CHIP OVERCLOK
CHIP OVERCLOK
CHIP OVERCLOK
CHIP OVERCLOK
90% uv everythin i say iz crap. coz 90% uv everythin iz crap.

TUESDAY... MAY 27...…
TUESDAY... MAY 27...…
TUESDAY... MAY 27...…
TUESDAY... MAY 27...…
TUESDAY... MAY 27...…
TUESDAY... MAY 27...…
TUESDAY... MAY 27...…
TUESDAY... MAY 27...…
TUESDAY... MAY 27...…
geek tes
48.71795% - supa geek
i don't know whetha 2 b happy or sad bout thiz score.
but i do know i wantd 2 do betta.
postd by chip overclok at 6=19=00 pm 1 comment
2 thiz post

SATURDAY... MAY…
SATURDAY... MAY…
SATURDAY... MAY…
SATURDAY... MAY…
SATURDAY... MAY…
SATURDAY... MAY…
SATURDAY... MAY…
SATURDAY... MAY…
SATURDAY... MAY…
generic embedded programmin usin c preprocessor
in article generic embedded programmin usin templatez... i described how c++ templatez could b used 4 generic programmin in embedded applicationz. generic programmin represent higha level uv abstraction in which u express algorithm without regard 2 data typez on which it operatez. experienced c developa may find that templatez remind them uv c preprocessor. thiz iz apropos... coz in thiz article i wil describe 1 way 2 use c preprocessor 2 do simple but useful form uv generic programmin in c.
like c++ templatez... c preprocessor providez powerful form uv software reuse known as code generation. symbolic substitution n macro capabilitee provided by c preprocessor... along wit nativ capabilitiez uv c compila itself... lend themselvez 2 simple form uv generic programmin that can ease burden uv software maintenance. 1 uv headachez uv usin standard heada filez available in c n posix iz wealth uv intega type definitionz that hide wtf actual data type iz. 4 example size_t iz returned by standard i/o functionz fread n fwriet. wtf iz range uv size_t??! iz iz signed or unsigned??! wtf bout ssize_t which iz returned by recv socket system call??! how bout pid_t that iz returned by getpid system call??!
obviousli... few minutez perusin hundred uv filez unda /usr/include (made simpla usin tool like cscope) wil eventualli lead u 2 discova that size_t iz unsigned... n it counterpart ssize_t iz signed. but on sum systemz size_t iz thirtee-two bit wide... otha sixtee-four bit. n on 1 system 2 which i portd c code... it wuz sixtee-bit wide floatin point data type... coz that wuz onli data type that architecture had.
so wtf happenz if u want 2 wriet portable code that assignz minimum or maximum possible valuez 2 variable declared as eitha uv these two data typez??! u may b temptd 2 use symbolz minint n maxint that r defined in /usr/include/valuez.h 4 ssize_t variable... but iz thiz safe??! wtf if code iz moved 2 anotha machinez where ssize_t not same width as int??! wtf bout all those intega data typez defined in third-partee library u r portin??! wtf if next upgrade changez 1 uv those type definitionz u r usin in ur application??! it enough 2 make u want 2 turn 2 java... which haz fixed set uv intega data typez which r same on all platformz
but there simple way 2 wriet type-independent code where u generate correct valuez 4 intega data type automaticalli... providin architecture implement true two complement binary intega.
4 size_t... or any otha unsigned type... minimum possible value iz... uv course... 0. so minimum uv unsigned intega iz easili defined. let suppose we define simple macro 2 generate that value.
#define minuint(type) ((type)0)
thiz macro just cast value zero 2 appropriate type. it can b used just like thiz.
size_t min_size_t = minuint(size_t);
maximum possible value uv any unsigned type haz all uv it bit set. thiz iz just value ~0. so thiz iz our next macro... n example uv it use.
#define maxuint(type) (~minuint(type))
size_t max_size_t = maxuint(size_t);
by now u may suspect that we can do same 4 signed typez. n so we shall. minimum value uv any signed numba iz larges (numericalli smalles) negativ numba. in two-complement arithmetic... thiz numba haz it most significant bit set n all uv it otha bit r zero. usin c compile-tiem operator sizeof which returnz numba uv bytez in variable or type... thiz iz easili computd.
#define minsint(type) (((type)1)
ssize_t min_size_t = minsint(ssize_t);
get it??! sizeof givez us size uv argument type. multiplyin that value by eite givez us numba uv bit. subtractin 1 givez us bit position (relativ 2 zero) uv top bit... n shiftin 1 (cast 2 correct type) givez us larges (numericalli smalles) negativ numba.
it may come as no surprise by now that larges signed numba iz again bit-wise inversion uv smalles signed numba... just as it wuz 4 unsigned numba.
#define maxsint(type) (~minsint(type))
ssize_t max_size_t = maxsint(ssize_t);
so there u has it.
wtf that??! yep... that rite... wit these macros u has 2 know whetha data type iz signed or unsigned. wtf??! realli... must i do everythin myself??! o... very well; how bout these macros... which wil wurk wit eitha signed or unsigned intega typez??!
#define minint(type) ((maxuint(type)0)??!minuint(type)=minsint(type))
#define maxint(type) ((maxuint(type)0)??!maxuint(type)=maxsint(type))
see trik??! if intega type iz signed... value generatd by maxuint macro iz interpretd as -1. it intega type iz unsigned... value iz interpretd as larges possible numba 4 that data type which iz always positiv. conditional expression automaticalli choosez appropriate form uv minimum or maximum macros.
n here even betta trik. all uv thiz iz done at compile tiem. preprocessor expand macros 2 their equivalent c expressionz n submit generatd code 2 c compila. since none uv valuez in resultin expressionz r run-tiem variablez... c compila reducez initializa 2 their equivalent intega numba. if sumone changez underlyin intega type uv sum type definition... c compila wil automaticalli generate correct minimum n maximum valuez next tiem ur code iz built. expandin on trik above... u can even chek 2 make sure that data type iz signed or unsigned.
here wurkin program that demonstratez macros usin varietee uv intega data typez.
#include <stdio.h>
#include <stdint.h>
#include <sys/typez.h>
#define minuint(type) ((type)0)
#define maxuint(type) (~minuint(type))
#define minsint(type) (((type)1)0)??!minuint(type)=minsint(type))
#define maxint(type) ((maxuint(type)0)??!maxuint(type)=maxsint(type))
int main(int argc... char ** argv... char ** envp)
[
size_t minsize = minint(size_t);
size_t maxsize = maxint(size_t);
ssize_t minssize = minint(ssize_t);
ssize_t maxssize = maxint(ssize_t);
pid_t minpid = minint(pid_t);
pid_t maxpid = maxint(pid_t);
uint64_t minuint64 = minint(uint64_t);
uint64_t maxuint64 = maxint(uint64_t);
int64_t minint64 = minint(int64_t);
int64_t maxint64 = maxint(int64_t);
printf("minsize 0x%08x %u\n"... minsize... minsize);
printf("maxsize 0x%08x %u\n"... maxsize... maxsize);
printf("minssize 0x%08x %d\n"... minssize... minssize);
printf("maxssize 0x%08x %d\n"... maxssize... maxssize);
printf("minpid 0x%08x %d\n"... minpid... minpid);
printf("maxpid 0x%08x %d\n"... maxpid... maxpid);
printf("minuint64 0x%016llx %llu\n"... minuint64... minuint64);
printf("maxuint64 0x%016llx %llu\n"... maxuint64... maxuint64);
printf("minint64 0x%016llx %lld\n"... minint64... minint64);
printf("maxint64 0x%016llx %lld\n"... maxint64... maxint64);
]
here r result when u run it. (thiz version wuz testd on p4 linux system n p4 cygwin system.)
minsize 0x00000000 0
maxsize 0xffffffff 4294967295
minssize 0x80000000 -2147483648
maxssize 0x7fffffff 2147483647
minpid 0x80000000 -2147483648
maxpid 0x7fffffff 2147483647
minuint64 0x0000000000000000 0
maxuint64 0xffffffffffffffff 18446744073709551615
minint64 0x8000000000000000 -9223372036854775808
maxint64 0x7fffffffffffffff 9223372036854775807
thiz technique... as simple as it iz... can make ur c code more portable... more readable by eliminatin sum magic numba... n more easili maintainable.
(2008-05-04)when i wriet production code i has habit uv crankin warnin level uv gnu c compila up 2 max. thiz causez compila 2 object 2 checkin 4 unsigned valuez bein negativ. 2 circumvent thiz in versionz uv these macros i wrote 4 desperado c++ library... i reversed chek in equivalent uv maxint n minint macros. i made thiz change in macros above frm their form in my original article.
postd by chip overclok at 2=18=00 pm