From 36ee028f497c82eaab7531258baa4f21bbd5ff43 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 8 Jun 2011 12:14:47 +0200 Subject: [PATCH] widl: Don't generate old-style interpreted stubs on 64-bit. --- tools/widl/client.c | 9 +++------ tools/widl/proxy.c | 40 +++++++++++++++++++++------------------- tools/widl/server.c | 4 ++-- tools/widl/typegen.c | 10 +++++----- tools/widl/widl.c | 9 ++++++++- tools/widl/widl.h | 2 +- 6 files changed, 40 insertions(+), 34 deletions(-) diff --git a/tools/widl/client.c b/tools/widl/client.c index 27093a5f336..0ea8cbc9e0d 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -109,7 +109,7 @@ static void write_function_stub( const type_t *iface, const var_t *func, if (has_ret) print_client( "%s", "CLIENT_CALL_RETURN _RetVal;\n\n" ); print_client( "%s%s( &%s_StubDesc, &__MIDL_ProcFormatString.Format[%u]", has_ret ? "_RetVal = " : "", - stub_mode == MODE_Oif ? "NdrClientCall2" : "NdrClientCall", + get_stub_mode() == MODE_Oif ? "NdrClientCall2" : "NdrClientCall", iface->name, proc_offset ); if (args) { @@ -395,7 +395,7 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines) print_client("0,\n"); print_client("__MIDL_TypeFormatString.Format,\n"); print_client("1, /* -error bounds_check flag */\n"); - print_client("0x%x, /* Ndr library version */\n", stub_mode == MODE_Oif ? 0x50002 : 0x10001); + print_client("0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001); print_client("0,\n"); print_client("0x50100a4, /* MIDL Version 5.1.164 */\n"); print_client("0,\n"); @@ -474,10 +474,7 @@ static void init_client(void) print_client("/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name); print_client("#include \n"); - print_client("#ifdef _ALPHA_\n"); - print_client("#include \n"); - print_client("#endif\n"); - fprintf(client, "\n"); + print_client( "\n"); print_client("#include \"%s\"\n", header_name); print_client( "\n"); print_client( "#ifndef DECLSPEC_HIDDEN\n"); diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c index 7d4ebe85fdf..0a677b7bf24 100644 --- a/tools/widl/proxy.c +++ b/tools/widl/proxy.c @@ -73,7 +73,7 @@ static void write_stubdesc(int expr_eval_routines) print_proxy( "{0}, 0, 0, %s, 0,\n", expr_eval_routines ? "ExprEvalRoutines" : "0"); print_proxy( "__MIDL_TypeFormatString.Format,\n"); print_proxy( "1, /* -error bounds_check flag */\n"); - print_proxy( "0x%x, /* Ndr library version */\n", stub_mode == MODE_Oif ? 0x50002 : 0x10001); + print_proxy( "0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001); print_proxy( "0,\n"); print_proxy( "0x50100a4, /* MIDL Version 5.1.164 */\n"); print_proxy( "0,\n"); @@ -95,19 +95,8 @@ static void init_proxy(const statement_list_t *stmts) error("Could not open %s for output\n", proxy_name); print_proxy( "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name); print_proxy( "\n"); - print_proxy( "#ifndef __REDQ_RPCPROXY_H_VERSION__\n"); - print_proxy( "#define __REQUIRED_RPCPROXY_H_VERSION__ 440\n"); - print_proxy( "#endif /* __REDQ_RPCPROXY_H_VERSION__ */\n"); - print_proxy( "\n"); print_proxy( "#define __midl_proxy\n"); - if (stub_mode == MODE_Oif) print_proxy( "#define USE_STUBLESS_PROXY\n"); print_proxy( "#include \"objbase.h\"\n"); - print_proxy( "#include \"rpcproxy.h\"\n"); - print_proxy( "#ifndef __RPCPROXY_H_VERSION__\n"); - print_proxy( "#error This code needs a newer version of rpcproxy.h\n"); - print_proxy( "#endif /* __RPCPROXY_H_VERSION__ */\n"); - print_proxy( "\n"); - print_proxy( "#include \"%s\"\n", header_name); print_proxy( "\n"); print_proxy( "#ifndef DECLSPEC_HIDDEN\n"); print_proxy( "#define DECLSPEC_HIDDEN\n"); @@ -272,7 +261,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx, indent = 0; if (is_interpreted_func( iface, func )) { - if (stub_mode == MODE_Oif && !is_callas( func->attrs )) return; + if (get_stub_mode() == MODE_Oif && !is_callas( func->attrs )) return; write_type_decl_left(proxy, type_function_get_rettype(func->type)); print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func)); write_args(proxy, args, iface->name, 1, TRUE); @@ -282,7 +271,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx, if (has_ret) print_proxy( "%s", "CLIENT_CALL_RETURN _RetVal;\n\n" ); print_proxy( "%s%s( &Object_StubDesc, &__MIDL_ProcFormatString.Format[%u],", has_ret ? "_RetVal = " : "", - stub_mode == MODE_Oif ? "NdrClientCall2" : "NdrClientCall", + get_stub_mode() == MODE_Oif ? "NdrClientCall2" : "NdrClientCall", proc_offset ); if (pointer_size == 8) { @@ -637,7 +626,7 @@ static int write_stub_methods(type_t *iface, int skip) if (i) fprintf(proxy,",\n"); if (skip || missing) print_proxy("STUB_FORWARDING_FUNCTION"); else if (is_interpreted_func( iface, func )) - print_proxy( "(PRPC_STUB_FUNCTION)%s", stub_mode == MODE_Oif ? "NdrStubCall2" : "NdrStubCall" ); + print_proxy( "(PRPC_STUB_FUNCTION)%s", get_stub_mode() == MODE_Oif ? "NdrStubCall2" : "NdrStubCall" ); else print_proxy( "%s_%s_Stub", iface->name, fname); i++; } @@ -714,7 +703,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) write_procformatstring_offsets( proxy, iface ); /* proxy info */ - if (stub_mode == MODE_Oif) + if (get_stub_mode() == MODE_Oif) { print_proxy( "static const MIDL_STUBLESS_PROXY_INFO %s_ProxyInfo =\n", iface->name ); print_proxy( "{\n" ); @@ -736,7 +725,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) indent++; print_proxy( "{\n"); indent++; - if (stub_mode == MODE_Oif) print_proxy( "&%s_ProxyInfo,\n", iface->name ); + if (get_stub_mode() == MODE_Oif) print_proxy( "&%s_ProxyInfo,\n", iface->name ); print_proxy( "&IID_%s,\n", iface->name); indent--; print_proxy( "},\n"); @@ -856,7 +845,7 @@ int need_inline_stubs(const type_t *iface) { const statement_t *stmt; - if (stub_mode == MODE_Os) return 1; + if (get_stub_mode() == MODE_Os) return 1; STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) ) { @@ -940,6 +929,19 @@ static void write_proxy_routines(const statement_list_t *stmts) type_t **interfaces; const type_t * delegate_to; + print_proxy( "#ifndef __REDQ_RPCPROXY_H_VERSION__\n"); + print_proxy( "#define __REQUIRED_RPCPROXY_H_VERSION__ %u\n", get_stub_mode() == MODE_Oif ? 475 : 440); + print_proxy( "#endif\n"); + print_proxy( "\n"); + if (get_stub_mode() == MODE_Oif) print_proxy( "#define USE_STUBLESS_PROXY\n"); + print_proxy( "#include \"rpcproxy.h\"\n"); + print_proxy( "#ifndef __RPCPROXY_H_VERSION__\n"); + print_proxy( "#error This code needs a newer version of rpcproxy.h\n"); + print_proxy( "#endif /* __RPCPROXY_H_VERSION__ */\n"); + print_proxy( "\n"); + print_proxy( "#include \"%s\"\n", header_name); + print_proxy( "\n"); + if (need_inline_stubs_file( stmts )) { write_exceptions( proxy ); @@ -1041,7 +1043,7 @@ static void write_proxy_routines(const statement_list_t *stmts) else fprintf(proxy, " 0,\n"); fprintf(proxy, " _%s_IID_Lookup,\n", file_id); fprintf(proxy, " %d,\n", count); - fprintf(proxy, " %d,\n", stub_mode == MODE_Oif ? 2 : 1); + fprintf(proxy, " %d,\n", get_stub_mode() == MODE_Oif ? 2 : 1); fprintf(proxy, " 0,\n"); fprintf(proxy, " 0,\n"); fprintf(proxy, " 0,\n"); diff --git a/tools/widl/server.c b/tools/widl/server.c index 1c1bc496162..19293ae621b 100644 --- a/tools/widl/server.c +++ b/tools/widl/server.c @@ -270,7 +270,7 @@ static void write_dispatchtable(type_t *iface) { var_t *func = stmt->u.var; if (is_interpreted_func( iface, func )) - print_server("%s,\n", stub_mode == MODE_Oif ? "NdrServerCall2" : "NdrServerCall"); + print_server("%s,\n", get_stub_mode() == MODE_Oif ? "NdrServerCall2" : "NdrServerCall"); else print_server("%s_%s,\n", iface->name, get_name(func)); method_count++; @@ -354,7 +354,7 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines) print_server("0,\n"); print_server("__MIDL_TypeFormatString.Format,\n"); print_server("1, /* -error bounds_check flag */\n"); - print_server("0x%x, /* Ndr library version */\n", stub_mode == MODE_Oif ? 0x50002 : 0x10001); + print_server("0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001); print_server("0,\n"); print_server("0x50100a4, /* MIDL Version 5.1.164 */\n"); print_server("0,\n"); diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index b41abd0ff2c..3f5847b268e 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -1231,7 +1231,7 @@ int is_interpreted_func( const type_t *iface, const var_t *func ) } } /* unions passed by value are not supported in Oi mode */ - if (stub_mode != MODE_Oif && args) + if (get_stub_mode() != MODE_Oif && args) LIST_FOR_EACH_ENTRY( var, args, const var_t, entry ) { if (type_get_type( var->type ) == TYPE_UNION || @@ -1241,7 +1241,7 @@ int is_interpreted_func( const type_t *iface, const var_t *func ) if ((str = get_attrp( func->attrs, ATTR_OPTIMIZE ))) return !strcmp( str, "i" ); if ((str = get_attrp( iface->attrs, ATTR_OPTIMIZE ))) return !strcmp( str, "i" ); - return (stub_mode != MODE_Os); + return (get_stub_mode() != MODE_Os); } static void write_proc_func_header( FILE *file, int indent, const type_t *iface, @@ -1265,7 +1265,7 @@ static void write_proc_func_header( FILE *file, int indent, const type_t *iface, if (is_object( iface )) { oi_flags |= RPC_FC_PROC_OIF_OBJECT; - if (stub_mode == MODE_Oif) oi_flags |= RPC_FC_PROC_OIF_OBJ_V2; + if (get_stub_mode() == MODE_Oif) oi_flags |= RPC_FC_PROC_OIF_OBJ_V2; stack_size += pointer_size; } @@ -1330,7 +1330,7 @@ static void write_proc_func_header( FILE *file, int indent, const type_t *iface, } } - if (stub_mode == MODE_Oif) + if (get_stub_mode() == MODE_Oif) { unsigned char oi2_flags = get_func_oi2_flags( func ); unsigned char ext_flags = 0; @@ -1382,7 +1382,7 @@ static void write_procformatstring_func( FILE *file, int indent, const type_t *i { unsigned int stack_offset = is_object( iface ) ? pointer_size : 0; int is_interpreted = is_interpreted_func( iface, func ); - int is_new_style = is_interpreted && (stub_mode == MODE_Oif); + int is_new_style = is_interpreted && (get_stub_mode() == MODE_Oif); if (is_interpreted) write_proc_func_header( file, indent, iface, func, offset, num_proc ); diff --git a/tools/widl/widl.c b/tools/widl/widl.c index 29547e7e9f4..88d2d78b940 100644 --- a/tools/widl/widl.c +++ b/tools/widl/widl.c @@ -111,7 +111,7 @@ int do_win32 = 1; int do_win64 = 1; int win32_packing = 8; int win64_packing = 8; -enum stub_mode stub_mode = MODE_Os; +static enum stub_mode stub_mode = MODE_Os; char *input_name; char *header_name; @@ -176,6 +176,13 @@ static const struct option long_options[] = { static void rm_tempfile(void); +enum stub_mode get_stub_mode(void) +{ + /* old-style interpreted stubs are not supported on 64-bit */ + if (stub_mode == MODE_Oi && pointer_size == 8) return MODE_Oif; + return stub_mode; +} + static char *make_token(const char *name) { char *token; diff --git a/tools/widl/widl.h b/tools/widl/widl.h index a793bfc29a8..20be1f3cbd4 100644 --- a/tools/widl/widl.h +++ b/tools/widl/widl.h @@ -78,7 +78,7 @@ enum stub_mode MODE_Oi, /* old-style interpreted stubs */ MODE_Oif /* new-style fully interpreted stubs */ }; -extern enum stub_mode stub_mode; +extern enum stub_mode get_stub_mode(void); extern void write_header(const statement_list_t *stmts); extern void write_id_data(const statement_list_t *stmts); -- 2.11.4.GIT