2008-06-25 03:33:36 -04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2009-10-10 07:08:31 -04:00
|
|
|
#include <string.h>
|
2008-06-25 03:33:36 -04:00
|
|
|
|
|
|
|
char *add =
|
|
|
|
"#if ! defined (__GMP_WITHIN_CONFIGURE)\n"
|
|
|
|
"# if defined( _MSC_VER )\n"
|
|
|
|
"# if defined( _WIN64 )\n"
|
|
|
|
"# define SIZEOF_MP_LIMB_T 8\n"
|
|
|
|
"# define _LONG_LONG_LIMB 1\n"
|
|
|
|
"# elif defined( _WIN32 )\n"
|
|
|
|
"# define SIZEOF_MP_LIMB_T 4\n"
|
|
|
|
"# ifdef _LONG_LONG_LIMB\n"
|
|
|
|
"# undef _LONG_LONG_LIMB\n"
|
|
|
|
"# endif\n"
|
|
|
|
"# else\n"
|
2009-03-02 15:03:30 -05:00
|
|
|
"# error This is the wrong version of mpir.h\n"
|
2008-06-25 03:33:36 -04:00
|
|
|
"# endif\n"
|
|
|
|
"# endif\n"
|
2008-09-09 11:17:29 -04:00
|
|
|
"# define GMP_LIMB_BITS (SIZEOF_MP_LIMB_T << 3)\n"
|
|
|
|
"# define __GMP_BITS_PER_MP_LIMB (SIZEOF_MP_LIMB_T << 3)\n"
|
|
|
|
"# define GMP_NAIL_BITS 0\n"
|
2008-06-25 03:33:36 -04:00
|
|
|
"#endif\n";
|
|
|
|
|
2009-05-01 14:33:21 -04:00
|
|
|
#define GMP_IN_FILE "..\\..\\gmp-h.in"
|
|
|
|
#define MPIR_IN_FILE "..\\..\\mpir-h.in"
|
2009-05-01 10:30:27 -04:00
|
|
|
#define MPIR_OUT_FILE "..\\..\\mpir.h"
|
|
|
|
#define GMP_OUT_FILE "..\\..\\gmp.h"
|
2008-06-25 03:33:36 -04:00
|
|
|
|
2009-05-01 10:30:27 -04:00
|
|
|
int gen_file(char *in_file, char *out_file)
|
2008-06-25 03:33:36 -04:00
|
|
|
{ FILE *fin, *fout;
|
|
|
|
char buf[1000];
|
|
|
|
int first = 0;
|
|
|
|
|
2009-05-01 10:30:27 -04:00
|
|
|
if(fin = fopen(in_file, "r"))
|
2008-06-25 03:33:36 -04:00
|
|
|
{
|
2009-05-01 10:30:27 -04:00
|
|
|
if(fout = fopen(out_file, "w"))
|
2008-06-25 03:33:36 -04:00
|
|
|
{
|
|
|
|
while(fgets(buf, 1000, fin))
|
2009-04-14 12:39:30 -04:00
|
|
|
if(!strncmp(buf, "#if ! defined (__GMP_WITHIN_CONFIGURE)", 38))
|
2008-06-25 03:33:36 -04:00
|
|
|
{
|
|
|
|
while(fgets(buf, 1000, fin))
|
|
|
|
{
|
|
|
|
if(!strncmp(buf, "#endif", 6))
|
|
|
|
{
|
|
|
|
if(!first)
|
|
|
|
fputs(add, fout);
|
|
|
|
first = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fputs(buf, fout);
|
|
|
|
fclose(fout);
|
|
|
|
}
|
|
|
|
fclose(fin);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2009-05-01 10:30:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2009-05-01 14:33:21 -04:00
|
|
|
gen_file(GMP_IN_FILE, MPIR_OUT_FILE);
|
2009-05-01 10:30:27 -04:00
|
|
|
return 0;
|
|
|
|
}
|