pre
Precompute_16bit.c
Precompute_8bit.c
-------------------------------
Precompute_16bit.c
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "../lib/ut.h" //int main(void) { int Precompute_16bit(void) { int max = 0x1u << 16; FILE * pFile; pFile = fopen ("src/lib/pre16.h","w"); int i; fprintf(pFile, "#ifndef PRE16_H_\n"); fprintf(pFile, "#define PRE16_H_\n\n"); fprintf(pFile, "static int bits_in_16bits [%d]={\n", max); for (i = 0; i < max; i++) { if (i > 0) { if(i%32==0){ fprintf(pFile, "\n"); } fprintf(pFile, ", "); } int rlt = a2_bitcount(i); fprintf(pFile, "%d", rlt); } fprintf(pFile, "\n};\n\n"); fprintf(pFile, "#endif /* PRE16_H_ */\n"); fclose (pFile); return EXIT_SUCCESS; }
Precompute_8bit.c
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "../lib/ut.h" //int main(void) { int Precompute_8bit(void) { int max = 256; FILE * pFile; pFile = fopen ("src/lib/pre8.h","w"); int i; fprintf(pFile, "#ifndef PRE8_H_\n"); fprintf(pFile, "#define PRE8_H_\n\n"); fprintf(pFile, "static int bits_in_char [%d]={\n", max); for (i = 0; i < max; i++) { if (i > 0) { if(i%32==0){ fprintf(pFile, "\n"); } fprintf(pFile, ", "); } int rlt = a2_bitcount(i); fprintf(pFile, "%d", rlt); } fprintf(pFile, "\n};\n\n"); fprintf(pFile, "#endif /* PRE8_H_ */\n"); fclose (pFile); return EXIT_SUCCESS; }