From c382ed06d35be80a9a42b8012cfe9165d916fbf2 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 7 Sep 2005 13:31:37 +0000 Subject: [PATCH] Added a bit of framework for future x86_64 support. --- tools/winebuild/build.h | 4 +++- tools/winebuild/import.c | 3 +++ tools/winebuild/main.c | 3 +++ tools/winebuild/spec32.c | 2 ++ tools/winebuild/utils.c | 31 +++++++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 09bc6fd82ad..ed5bb2a4451 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -110,7 +110,7 @@ typedef struct enum target_cpu { - CPU_x86, CPU_SPARC, CPU_ALPHA, CPU_POWERPC + CPU_x86, CPU_x86_64, CPU_SPARC, CPU_ALPHA, CPU_POWERPC }; enum target_platform @@ -180,9 +180,11 @@ extern void free_dll_spec( DLLSPEC *spec ); extern const char *make_c_identifier( const char *str ); extern unsigned int get_alignment(unsigned int align); extern unsigned int get_page_size(void); +extern unsigned int get_ptr_size(void); extern const char *asm_name( const char *func ); extern const char *func_declaration( const char *func ); extern const char *func_size( const char *func ); +extern const char *get_asm_ptr_keyword(void); extern const char *get_asm_string_keyword(void); extern const char *get_asm_short_keyword(void); diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 4a14a643f8a..d3cb54a6582 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -632,6 +632,7 @@ static void output_import_thunk( FILE *outfile, const char *name, const char *ta switch(target_cpu) { + case CPU_x86_64: /* FIXME */ case CPU_x86: if (!UsePIC) { @@ -976,6 +977,7 @@ static void output_delayed_import_thunks( FILE *outfile, const DLLSPEC *spec ) fprintf( outfile, " \"%s:\\n\"\n", asm_name("__wine_delay_load_asm") ); switch(target_cpu) { + case CPU_x86_64: /* FIXME */ case CPU_x86: fprintf( outfile, " \"\\tpushl %%ecx\\n\\tpushl %%edx\\n\\tpushl %%eax\\n\"\n" ); fprintf( outfile, " \"\\tcall %s\\n\"\n", asm_name("__wine_spec_delay_load") ); @@ -1054,6 +1056,7 @@ static void output_delayed_import_thunks( FILE *outfile, const DLLSPEC *spec ) fprintf( outfile, " \".L__wine_delay_imp_%d_%s:\\n\"\n", i, name ); switch(target_cpu) { + case CPU_x86_64: /* FIXME */ case CPU_x86: fprintf( outfile, " \"\\tmovl $%d, %%eax\\n\"\n", (idx << 16) | j ); fprintf( outfile, " \"\\tjmp %s\\n\"\n", asm_name("__wine_delay_load_asm") ); diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index aaba9194837..8b85266f590 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -49,6 +49,8 @@ int kill_at = 0; #ifdef __i386__ enum target_cpu target_cpu = CPU_x86; +#elif defined(__x86_64__) +enum target_cpu target_cpu = CPU_x86_64; #elif defined(__sparc__) enum target_cpu target_cpu = CPU_SPARC; #elif defined(__ALPHA__) @@ -109,6 +111,7 @@ static const struct { "i586", CPU_x86 }, { "i686", CPU_x86 }, { "i786", CPU_x86 }, + { "x86_64", CPU_x86_64 }, { "sparc", CPU_SPARC }, { "alpha", CPU_ALPHA }, { "powerpc", CPU_POWERPC } diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index b23d639907a..a5cc915434b 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -375,6 +375,7 @@ void output_dll_init( FILE *outfile, const char *constructor, const char *destru else switch(target_cpu) { case CPU_x86: + case CPU_x86_64: if (constructor) { fprintf( outfile, "asm(\"\\t.section\\t\\\".init\\\" ,\\\"ax\\\"\\n\"\n" ); @@ -502,6 +503,7 @@ void BuildSpec32File( FILE *outfile, DLLSPEC *spec ) switch(target_cpu) { case CPU_x86: machine = IMAGE_FILE_MACHINE_I386; break; + case CPU_x86_64: machine = IMAGE_FILE_MACHINE_AMD64; break; case CPU_POWERPC: machine = IMAGE_FILE_MACHINE_POWERPC; break; case CPU_ALPHA: machine = IMAGE_FILE_MACHINE_ALPHA; break; case CPU_SPARC: machine = IMAGE_FILE_MACHINE_UNKNOWN; break; diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 19a8c7b4ca1..0b5bc7dbcd7 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -349,6 +349,7 @@ unsigned int get_alignment(unsigned int align) switch(target_cpu) { case CPU_x86: + case CPU_x86_64: case CPU_SPARC: if (target_platform != PLATFORM_APPLE) return align; /* fall through */ @@ -369,6 +370,7 @@ unsigned int get_page_size(void) switch(target_cpu) { case CPU_x86: return 4096; + case CPU_x86_64: return 4096; case CPU_POWERPC: return 4096; case CPU_SPARC: return 8192; case CPU_ALPHA: return 8192; @@ -378,6 +380,24 @@ unsigned int get_page_size(void) return 0; } +/* return the size of a pointer on the target CPU */ +unsigned int get_ptr_size(void) +{ + switch(target_cpu) + { + case CPU_x86: + case CPU_POWERPC: + case CPU_SPARC: + case CPU_ALPHA: + return 4; + case CPU_x86_64: + return 8; + } + /* unreached */ + assert(0); + return 0; +} + /* return the assembly name for a C symbol */ const char *asm_name( const char *sym ) { @@ -433,6 +453,17 @@ const char *func_size( const char *func ) } } +const char *get_asm_ptr_keyword(void) +{ + switch(get_ptr_size()) + { + case 4: return ".long"; + case 8: return ".quad"; + } + assert(0); + return NULL; +} + const char *get_asm_string_keyword(void) { switch (target_platform) -- 2.11.4.GIT