Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
5e84eb9a
Commit
5e84eb9a
authored
Sep 13, 2007
by
Dan Hipschman
Committed by
Alexandre Julliard
Sep 14, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widl: Add padding to the end of complex structures.
parent
1ca74357
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
0 deletions
+59
-0
server.c
dlls/rpcrt4/tests/server.c
+11
-0
server.idl
dlls/rpcrt4/tests/server.idl
+8
-0
parser.y
tools/widl/parser.y
+3
-0
typegen.c
tools/widl/typegen.c
+36
-0
typegen.h
tools/widl/typegen.h
+1
-0
No files found.
dlls/rpcrt4/tests/server.c
View file @
5e84eb9a
...
...
@@ -344,6 +344,12 @@ s_sum_aligns(aligns_t *a)
return
a
->
c
+
a
->
i
+
a
->
s
+
a
->
d
;
}
int
s_sum_padded
(
padded_t
*
p
)
{
return
p
->
i
+
p
->
c
;
}
void
s_stop
(
void
)
{
...
...
@@ -392,6 +398,7 @@ basic_tests(void)
static
aligns_t
aligns
=
{
3
,
4
,
5
,
6
.
0
};
pints_t
pints
;
ptypes_t
ptypes
;
padded_t
padded
;
int
i1
,
i2
,
i3
,
*
pi2
,
*
pi3
,
**
ppi3
;
double
u
,
v
;
float
s
,
t
;
...
...
@@ -465,6 +472,10 @@ basic_tests(void)
ok
(
enum_ord
(
E4
)
==
4
,
"RPC enum_ord
\n
"
);
ok
(
sum_aligns
(
&
aligns
)
==
18
.
0
,
"RPC sum_aligns
\n
"
);
padded
.
i
=
-
3
;
padded
.
c
=
8
;
ok
(
sum_padded
(
&
padded
)
==
5
,
"RPC sum_padded
\n
"
);
}
static
void
...
...
dlls/rpcrt4/tests/server.idl
View file @
5e84eb9a
...
...
@@ -200,5 +200,13 @@ interface IServer
double sum_aligns(aligns_t *a);
typedef struct
{
int i;
char c;
} padded_t;
int sum_padded(padded_t *p);
void stop(void);
}
tools/widl/parser.y
View file @
5e84eb9a
...
...
@@ -1679,6 +1679,9 @@ static int get_struct_type(var_list_t *fields)
int has_variance = 0;
var_t *field;
if (get_padding(fields))
return RPC_FC_BOGUS_STRUCT;
if (fields) LIST_FOR_EACH_ENTRY( field, fields, var_t, entry )
{
type_t *t = field->type;
...
...
tools/widl/typegen.c
View file @
5e84eb9a
...
...
@@ -726,6 +726,29 @@ static size_t union_memsize(const var_list_t *fields, unsigned int *pmaxa)
return
maxs
;
}
int
get_padding
(
const
var_list_t
*
fields
)
{
unsigned
short
offset
=
0
;
int
salign
=
-
1
;
const
var_t
*
f
;
if
(
!
fields
)
return
0
;
LIST_FOR_EACH_ENTRY
(
f
,
fields
,
const
var_t
,
entry
)
{
type_t
*
ft
=
f
->
type
;
unsigned
int
align
=
0
;
size_t
size
=
type_memsize
(
ft
,
&
align
);
if
(
salign
==
-
1
)
salign
=
align
;
offset
=
(
offset
+
(
align
-
1
))
&
~
(
align
-
1
);
offset
+=
size
;
}
return
((
offset
+
(
salign
-
1
))
&
~
(
salign
-
1
))
-
offset
;
}
size_t
type_memsize
(
const
type_t
*
t
,
unsigned
int
*
align
)
{
size_t
size
=
0
;
...
...
@@ -1518,6 +1541,8 @@ static void write_struct_members(FILE *file, const type_t *type,
{
const
var_t
*
field
;
unsigned
short
offset
=
0
;
int
salign
=
-
1
;
int
padding
;
if
(
type
->
fields
)
LIST_FOR_EACH_ENTRY
(
field
,
type
->
fields
,
const
var_t
,
entry
)
{
...
...
@@ -1526,6 +1551,8 @@ static void write_struct_members(FILE *file, const type_t *type,
{
unsigned
int
align
=
0
;
size_t
size
=
type_memsize
(
ft
,
&
align
);
if
(
salign
==
-
1
)
salign
=
align
;
if
((
align
-
1
)
&
offset
)
{
unsigned
char
fc
=
0
;
...
...
@@ -1549,6 +1576,15 @@ static void write_struct_members(FILE *file, const type_t *type,
}
}
padding
=
((
offset
+
(
salign
-
1
))
&
~
(
salign
-
1
))
-
offset
;
if
(
padding
)
{
print_file
(
file
,
2
,
"0x%x,
\t
/* FC_STRUCTPAD%d */
\n
"
,
RPC_FC_STRUCTPAD1
+
padding
-
1
,
padding
);
*
typestring_offset
+=
1
;
}
write_end
(
file
,
typestring_offset
);
}
...
...
tools/widl/typegen.h
View file @
5e84eb9a
...
...
@@ -55,3 +55,4 @@ size_t type_memsize(const type_t *t, unsigned int *align);
int
decl_indirect
(
const
type_t
*
t
);
void
write_parameters_init
(
FILE
*
file
,
int
indent
,
const
func_t
*
func
);
void
print
(
FILE
*
file
,
int
indent
,
const
char
*
format
,
va_list
ap
);
int
get_padding
(
const
var_list_t
*
fields
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment