[WIDL 2/2] Fix base type alignments (resend)
Eric Kohl
eric.kohl at t-online.de
Wed Mar 22 08:22:12 CST 2006
ChangeLog:
Eric Kohl <eric.kohl at t-online.de>
Generate aligned marshal and unmarshal code for base type
arguments and return values.
-------------- next part --------------
Index: tools/widl/server.c
===================================================================
RCS file: /home/wine/wine/tools/widl/server.c,v
retrieving revision 1.28
diff -u -r1.28 server.c
--- tools/widl/server.c 18 Mar 2006 18:52:38 -0000 1.28
+++ tools/widl/server.c 19 Mar 2006 02:17:54 -0000
@@ -306,6 +306,10 @@
/* marshall the return value */
if (!is_void(def->type, NULL))
{
+ unsigned int alignment;
+ unsigned int size = get_required_buffer_size(def, &alignment);
+ print_server("_StubMsg.Buffer += (unsigned char *)(((long)_StubMsg.Buffer + %u) & ~0x%x);\n",
+ size - 1, size - 1);
print_server("*(");
write_type(server, def->type, def, def->tname);
fprintf(server, " *)_StubMsg.Buffer = _RetVal;\n");
Index: tools/widl/typegen.c
===================================================================
RCS file: /home/wine/wine/tools/widl/typegen.c,v
retrieving revision 1.63
diff -u -r1.63 typegen.c
--- tools/widl/typegen.c 22 Feb 2006 21:31:54 -0000 1.63
+++ tools/widl/typegen.c 19 Mar 2006 02:17:57 -0000
@@ -1285,12 +1285,13 @@
case RPC_FC_CHAR:
case RPC_FC_USMALL:
case RPC_FC_SMALL:
+ *alignment = 4;
return 1;
case RPC_FC_WCHAR:
case RPC_FC_USHORT:
case RPC_FC_SHORT:
- *alignment = 2;
+ *alignment = 4;
return 2;
case RPC_FC_ULONG:
@@ -1358,7 +1359,6 @@
unsigned int *type_offset, enum pass pass,
enum remoting_phase phase)
{
- unsigned int last_size = 0;
var_t *var;
if (!func->args)
@@ -1398,7 +1398,6 @@
print_file(file, indent,
"NdrConformantString%s(&_StubMsg, (unsigned char *)%s, &__MIDL_TypeFormatString.Format[%d]);\n",
function_from_phase(phase), var->name, *type_offset);
- last_size = 1;
}
else if (is_array_type(var->attrs, var->ptr_level, var->array))
{
@@ -1455,7 +1454,6 @@
"Ndr%s%s(&_StubMsg, (unsigned char *)%s, &__MIDL_TypeFormatString.Format[%d]);\n",
array_type, function_from_phase(phase), var->name,
*type_offset);
- last_size = 1;
}
else if (var->ptr_level == 0 && is_base_type(var->type->type))
{
@@ -1468,15 +1466,14 @@
case RPC_FC_SMALL:
case RPC_FC_USMALL:
size = 1;
- alignment = 0;
+ alignment = 1;
break;
case RPC_FC_WCHAR:
case RPC_FC_USHORT:
case RPC_FC_SHORT:
size = 2;
- if (last_size != 0 && last_size < 2)
- alignment = (2 - last_size);
+ alignment = 2;
break;
case RPC_FC_ULONG:
@@ -1484,15 +1481,13 @@
case RPC_FC_FLOAT:
case RPC_FC_ERROR_STATUS_T:
size = 4;
- if (last_size != 0 && last_size < 4)
- alignment = (4 - last_size);
+ alignment = 4;
break;
case RPC_FC_HYPER:
case RPC_FC_DOUBLE:
size = 8;
- if (last_size != 0 && last_size < 4)
- alignment = (4 - last_size);
+ alignment = 8;
break;
case RPC_FC_IGNORE:
@@ -1505,8 +1500,8 @@
size = 0;
}
- if (alignment != 0)
- print_file(file, indent, "_StubMsg.Buffer += %u;\n", alignment);
+ print_file(file, indent, "_StubMsg.Buffer += (unsigned char *)(((long)_StubMsg.Buffer + %u) & ~0x%x);\n",
+ alignment - 1, alignment - 1);
if (phase == PHASE_MARSHAL)
{
@@ -1523,17 +1518,13 @@
fprintf(file, " = *(");
write_type(file, var->type, var, var->tname);
fprintf(file, " *)_StubMsg.Buffer;\n");
- print_file(file, indent, "_StubMsg.Buffer += sizeof(");
- write_type(file, var->type, var, var->tname);
- fprintf(file, ");\n");
}
else
error("write_remoting_arguments: Unimplemented for base types for phase %d\n", phase);
+
print_file(file, indent, "_StubMsg.Buffer += sizeof(");
write_type(file, var->type, var, var->tname);
fprintf(file, ");\n");
-
- last_size = size;
}
else if (var->ptr_level == 0)
{
@@ -1563,14 +1554,12 @@
print_file(file, indent,
"Ndr%s%s(&_StubMsg, (unsigned char *)%s, &__MIDL_TypeFormatString.Format[%d]);\n",
ndrtype, function_from_phase(phase), var->name, *type_offset);
- last_size = 1;
}
else
{
print_file(file, indent,
"NdrPointer%s(&_StubMsg, (unsigned char *)%s, &__MIDL_TypeFormatString.Format[%d]);\n",
function_from_phase(phase), var->name, *type_offset);
- last_size = 1;
}
fprintf(file, "\n");
}
More information about the wine-patches
mailing list