Wine-devel
Threads by month
- ----- 2026 -----
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
February 2020
- 80 participants
- 745 discussions
15 Feb '20
Signed-off-by: Vijay Kiran Kamuju <infyquest(a)gmail.com>
1
0
15 Feb '20
based on patch from Qian Hong
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=44812
Signed-off-by: Vijay Kiran Kamuju <infyquest(a)gmail.com>
1
0
[PATCH v4 1/5] d3dcompiler: Return an instruction list instead of a single instruction from nodes representing expressions.
by Zebediah Figura 15 Feb '20
by Zebediah Figura 15 Feb '20
15 Feb '20
From: Zebediah Figura <zfigura(a)codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/d3dcompiler_43/d3dcompiler_private.h | 6 +
dlls/d3dcompiler_43/hlsl.y | 326 +++++++++++-----------
dlls/d3dcompiler_43/utils.c | 46 +--
3 files changed, 183 insertions(+), 195 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 5fc3161f5f0..9c58830ffe2 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -984,6 +984,7 @@ struct parse_initializer
{
struct hlsl_ir_node **args;
unsigned int args_count;
+ struct list *instrs;
};
struct parse_variable_def
@@ -1120,6 +1121,11 @@ static inline struct hlsl_ir_loop *loop_from_node(const struct hlsl_ir_node *nod
return CONTAINING_RECORD(node, struct hlsl_ir_loop, node);
}
+static inline struct hlsl_ir_node *node_from_list(struct list *list)
+{
+ return LIST_ENTRY(list_tail(list), struct hlsl_ir_node, entry);
+}
+
BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN;
struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN;
void free_declaration(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN;
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index d81d6afa9cc..87a5273d2d8 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -255,56 +255,49 @@ static void declare_predefined_types(struct hlsl_scope *scope)
add_type_to_scope(scope, type);
}
-static struct hlsl_ir_if *loop_condition(struct list *cond_list)
+static BOOL append_conditional_break(struct list *cond_list)
{
- struct hlsl_ir_node *cond, *not_cond;
- struct hlsl_ir_if *out_cond;
+ struct hlsl_ir_node *condition, *not;
struct hlsl_ir_jump *jump;
- unsigned int count = list_count(cond_list);
+ struct hlsl_ir_if *iff;
- if (!count)
- return NULL;
- if (count != 1)
- ERR("Got multiple expressions in a for condition.\n");
+ /* E.g. "for (i = 0; ; ++i)". */
+ if (!list_count(cond_list))
+ return TRUE;
- cond = LIST_ENTRY(list_head(cond_list), struct hlsl_ir_node, entry);
- out_cond = d3dcompiler_alloc(sizeof(*out_cond));
- if (!out_cond)
+ condition = node_from_list(cond_list);
+ if (!(not = new_unary_expr(HLSL_IR_UNOP_LOGIC_NOT, condition, condition->loc)))
{
ERR("Out of memory.\n");
- return NULL;
+ return FALSE;
}
- out_cond->node.type = HLSL_IR_IF;
- if (!(not_cond = new_unary_expr(HLSL_IR_UNOP_LOGIC_NOT, cond, cond->loc)))
+ list_add_tail(cond_list, ¬->entry);
+
+ if (!(iff = d3dcompiler_alloc(sizeof(*iff))))
{
ERR("Out of memory.\n");
- d3dcompiler_free(out_cond);
- return NULL;
+ return FALSE;
}
- out_cond->condition = not_cond;
- jump = d3dcompiler_alloc(sizeof(*jump));
- if (!jump)
+ iff->node.type = HLSL_IR_IF;
+ iff->condition = not;
+ list_add_tail(cond_list, &iff->node.entry);
+
+ if (!(iff->then_instrs = d3dcompiler_alloc(sizeof(*iff->then_instrs))))
{
ERR("Out of memory.\n");
- d3dcompiler_free(out_cond);
- d3dcompiler_free(not_cond);
- return NULL;
+ return FALSE;
}
- jump->node.type = HLSL_IR_JUMP;
- jump->type = HLSL_IR_JUMP_BREAK;
- out_cond->then_instrs = d3dcompiler_alloc(sizeof(*out_cond->then_instrs));
- if (!out_cond->then_instrs)
+ list_init(iff->then_instrs);
+
+ if (!(jump = d3dcompiler_alloc(sizeof(*jump))))
{
ERR("Out of memory.\n");
- d3dcompiler_free(out_cond);
- d3dcompiler_free(not_cond);
- d3dcompiler_free(jump);
- return NULL;
+ return FALSE;
}
- list_init(out_cond->then_instrs);
- list_add_head(out_cond->then_instrs, &jump->node.entry);
-
- return out_cond;
+ jump->node.type = HLSL_IR_JUMP;
+ jump->type = HLSL_IR_JUMP_BREAK;
+ list_add_head(iff->then_instrs, &jump->node.entry);
+ return TRUE;
}
enum loop_type
@@ -315,7 +308,7 @@ enum loop_type
};
static struct list *create_loop(enum loop_type type, struct list *init, struct list *cond,
- struct hlsl_ir_node *iter, struct list *body, struct source_location *loc)
+ struct list *iter, struct list *body, struct source_location *loc)
{
struct list *list = NULL;
struct hlsl_ir_loop *loop = NULL;
@@ -340,20 +333,19 @@ static struct list *create_loop(enum loop_type type, struct list *init, struct l
goto oom;
list_init(loop->body);
- cond_jump = loop_condition(cond);
- if (!cond_jump)
+ if (!append_conditional_break(cond))
goto oom;
if (type != LOOP_DO_WHILE)
- list_add_tail(loop->body, &cond_jump->node.entry);
+ list_move_tail(loop->body, cond);
list_move_tail(loop->body, body);
if (iter)
- list_add_tail(loop->body, &iter->entry);
+ list_move_tail(loop->body, iter);
if (type == LOOP_DO_WHILE)
- list_add_tail(loop->body, &cond_jump->node.entry);
+ list_move_tail(loop->body, cond);
d3dcompiler_free(init);
d3dcompiler_free(cond);
@@ -369,7 +361,7 @@ oom:
d3dcompiler_free(list);
free_instr_list(init);
free_instr_list(cond);
- free_instr(iter);
+ free_instr_list(iter);
free_instr_list(body);
return NULL;
}
@@ -388,9 +380,7 @@ static unsigned int initializer_size(const struct parse_initializer *initializer
static void free_parse_initializer(struct parse_initializer *initializer)
{
- unsigned int i;
- for (i = 0; i < initializer->args_count; ++i)
- free_instr(initializer->args[i]);
+ free_instr_list(initializer->instrs);
d3dcompiler_free(initializer->args);
}
@@ -508,6 +498,9 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
return;
}
+ list_move_tail(list, initializer->instrs);
+ d3dcompiler_free(initializer->instrs);
+
LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry)
{
struct hlsl_ir_node *node = initializer->args[i];
@@ -526,6 +519,7 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
break;
}
deref->node.loc = node->loc;
+ list_add_tail(list, &deref->node.entry);
assignment = make_assignment(&deref->node, ASSIGN_OP_ASSIGN, BWRITERSP_WRITEMASK_ALL, node);
list_add_tail(list, &assignment->entry);
}
@@ -533,9 +527,6 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
FIXME("Initializing with \"mismatched\" fields is not supported yet.\n");
}
- /* Free initializer elements in excess. */
- for (; i < initializer->args_count; ++i)
- free_instr(initializer->args[i]);
d3dcompiler_free(initializer->args);
}
@@ -609,6 +600,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
if (v->initializer.args_count)
{
unsigned int size = initializer_size(&v->initializer);
+ struct hlsl_ir_deref *deref;
TRACE("Variable with initializer.\n");
if (type->type <= HLSL_CLASS_LAST_NUMERIC
@@ -661,7 +653,10 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
continue;
}
- assignment = make_assignment(&new_var_deref(var)->node, ASSIGN_OP_ASSIGN,
+ deref = new_var_deref(var);
+ list_add_tail(statements_list, &deref->node.entry);
+ list_add_tail(statements_list, &v->initializer.args[0]->entry);
+ assignment = make_assignment(&deref->node, ASSIGN_OP_ASSIGN,
BWRITERSP_WRITEMASK_ALL, v->initializer.args[0]);
d3dcompiler_free(v->initializer.args);
list_add_tail(statements_list, &assignment->entry);
@@ -880,6 +875,35 @@ static const struct hlsl_ir_function_decl *get_overloaded_func(struct wine_rb_tr
return NULL;
}
+static struct list *append_unop(struct list *list, struct hlsl_ir_node *node)
+{
+ list_add_tail(list, &node->entry);
+ return list;
+}
+
+static struct list *append_binop(struct list *first, struct list *second, struct hlsl_ir_node *node)
+{
+ list_move_tail(first, second);
+ d3dcompiler_free(second);
+ list_add_tail(first, &node->entry);
+ return first;
+}
+
+static struct list *make_list(struct hlsl_ir_node *node)
+{
+ struct list *list;
+
+ if (!(list = d3dcompiler_alloc(sizeof(*list))))
+ {
+ ERR("Out of memory.\n");
+ free_instr(node);
+ return NULL;
+ }
+ list_init(list);
+ list_add_tail(list, &node->entry);
+ return list;
+}
+
%}
%locations
@@ -1024,12 +1048,12 @@ static const struct hlsl_ir_function_decl *get_overloaded_func(struct wine_rb_tr
%type <variable_def> type_spec
%type <initializer> complex_initializer
%type <initializer> initializer_expr_list
-%type <instr> initializer_expr
+%type <list> initializer_expr
%type <modifiers> var_modifiers
%type <list> field
%type <list> parameters
%type <list> param_list
-%type <instr> expr
+%type <list> expr
%type <intval> array
%type <list> statement
%type <list> statement_list
@@ -1048,21 +1072,21 @@ static const struct hlsl_ir_function_decl *get_overloaded_func(struct wine_rb_tr
%type <list> variables_def
%type <list> variables_def_optional
%type <if_body> if_body
-%type <instr> primary_expr
-%type <instr> postfix_expr
-%type <instr> unary_expr
-%type <instr> mul_expr
-%type <instr> add_expr
-%type <instr> shift_expr
-%type <instr> relational_expr
-%type <instr> equality_expr
-%type <instr> bitand_expr
-%type <instr> bitxor_expr
-%type <instr> bitor_expr
-%type <instr> logicand_expr
-%type <instr> logicor_expr
-%type <instr> conditional_expr
-%type <instr> assignment_expr
+%type <list> primary_expr
+%type <list> postfix_expr
+%type <list> unary_expr
+%type <list> mul_expr
+%type <list> add_expr
+%type <list> shift_expr
+%type <list> relational_expr
+%type <list> equality_expr
+%type <list> bitand_expr
+%type <list> bitxor_expr
+%type <list> bitor_expr
+%type <list> logicand_expr
+%type <list> logicor_expr
+%type <list> conditional_expr
+%type <list> assignment_expr
%type <list> expr_statement
%type <unary_op> unary_op
%type <assign_op> assign_op
@@ -1615,7 +1639,7 @@ array: /* Empty */
{
FIXME("Array.\n");
$$ = 0;
- free_instr($2);
+ free_instr_list($2);
}
var_modifiers: /* Empty */
@@ -1672,7 +1696,8 @@ complex_initializer: initializer_expr
$$.args_count = 1;
if (!($$.args = d3dcompiler_alloc(sizeof(*$$.args))))
YYABORT;
- $$.args[0] = $1;
+ $$.args[0] = node_from_list($1);
+ $$.instrs = $1;
}
| '{' initializer_expr_list '}'
{
@@ -1693,14 +1718,17 @@ initializer_expr_list: initializer_expr
$$.args_count = 1;
if (!($$.args = d3dcompiler_alloc(sizeof(*$$.args))))
YYABORT;
- $$.args[0] = $1;
+ $$.args[0] = node_from_list($1);
+ $$.instrs = $1;
}
| initializer_expr_list ',' initializer_expr
{
$$ = $1;
if (!($$.args = d3dcompiler_realloc($$.args, ($$.args_count + 1) * sizeof(*$$.args))))
YYABORT;
- $$.args[$$.args_count++] = $3;
+ $$.args[$$.args_count++] = node_from_list($3);
+ list_move_tail($$.instrs, $3);
+ d3dcompiler_free($3);
}
boolean: KW_TRUE
@@ -1742,15 +1770,14 @@ jump_statement: KW_RETURN expr ';'
jump->node.type = HLSL_IR_JUMP;
set_location(&jump->node.loc, &@1);
jump->type = HLSL_IR_JUMP_RETURN;
- jump->node.data_type = $2->data_type;
- jump->return_value = $2;
+ jump->node.data_type = node_from_list($2)->data_type;
+ jump->return_value = node_from_list($2);
FIXME("Check for valued return on void function.\n");
FIXME("Implicit conversion to the return type if needed, "
"error out if conversion not possible.\n");
- $$ = d3dcompiler_alloc(sizeof(*$$));
- list_init($$);
+ $$ = $2;
list_add_tail($$, &jump->node.entry);
}
@@ -1764,18 +1791,17 @@ selection_statement: KW_IF '(' expr ')' if_body
}
instr->node.type = HLSL_IR_IF;
set_location(&instr->node.loc, &@1);
- instr->condition = $3;
+ instr->condition = node_from_list($3);
instr->then_instrs = $5.then_instrs;
instr->else_instrs = $5.else_instrs;
- if ($3->data_type->dimx > 1 || $3->data_type->dimy > 1)
+ if (instr->condition->data_type->dimx > 1 || instr->condition->data_type->dimy > 1)
{
hlsl_report_message(instr->node.loc.file, instr->node.loc.line,
instr->node.loc.col, HLSL_LEVEL_ERROR,
"if condition requires a scalar");
}
- $$ = d3dcompiler_alloc(sizeof(*$$));
- list_init($$);
- list_add_head($$, &instr->node.entry);
+ $$ = $3;
+ list_add_tail($$, &instr->node.entry);
}
if_body: statement
@@ -1792,32 +1818,14 @@ if_body: statement
loop_statement: KW_WHILE '(' expr ')' statement
{
struct source_location loc;
- struct list *cond = d3dcompiler_alloc(sizeof(*cond));
-
- if (!cond)
- {
- ERR("Out of memory.\n");
- YYABORT;
- }
- list_init(cond);
- list_add_head(cond, &$3->entry);
set_location(&loc, &@1);
- $$ = create_loop(LOOP_WHILE, NULL, cond, NULL, $5, &loc);
+ $$ = create_loop(LOOP_WHILE, NULL, $3, NULL, $5, &loc);
}
| KW_DO statement KW_WHILE '(' expr ')' ';'
{
struct source_location loc;
- struct list *cond = d3dcompiler_alloc(sizeof(*cond));
-
- if (!cond)
- {
- ERR("Out of memory.\n");
- YYABORT;
- }
- list_init(cond);
- list_add_head(cond, &$5->entry);
set_location(&loc, &@1);
- $$ = create_loop(LOOP_DO_WHILE, NULL, cond, NULL, $2, &loc);
+ $$ = create_loop(LOOP_DO_WHILE, NULL, $5, NULL, $2, &loc);
}
| KW_FOR '(' scope_start expr_statement expr_statement expr ')' statement
{
@@ -1846,10 +1854,7 @@ expr_statement: ';'
}
| expr ';'
{
- $$ = d3dcompiler_alloc(sizeof(*$$));
- list_init($$);
- if ($1)
- list_add_head($$, &$1->entry);
+ $$ = $1;
}
primary_expr: C_FLOAT
@@ -1864,7 +1869,8 @@ primary_expr: C_FLOAT
set_location(&c->node.loc, &yylloc);
c->node.data_type = new_hlsl_type(d3dcompiler_strdup("float"), HLSL_CLASS_SCALAR, HLSL_TYPE_FLOAT, 1, 1);
c->v.value.f[0] = $1;
- $$ = &c->node;
+ if (!($$ = make_list(&c->node)))
+ YYABORT;
}
| C_INTEGER
{
@@ -1878,7 +1884,8 @@ primary_expr: C_FLOAT
set_location(&c->node.loc, &yylloc);
c->node.data_type = new_hlsl_type(d3dcompiler_strdup("int"), HLSL_CLASS_SCALAR, HLSL_TYPE_INT, 1, 1);
c->v.value.i[0] = $1;
- $$ = &c->node;
+ if (!($$ = make_list(&c->node)))
+ YYABORT;
}
| boolean
{
@@ -1892,7 +1899,8 @@ primary_expr: C_FLOAT
set_location(&c->node.loc, &yylloc);
c->node.data_type = new_hlsl_type(d3dcompiler_strdup("bool"), HLSL_CLASS_SCALAR, HLSL_TYPE_BOOL, 1, 1);
c->v.value.b[0] = $1;
- $$ = &c->node;
+ if (!($$ = make_list(&c->node)))
+ YYABORT;
}
| VAR_IDENTIFIER
{
@@ -1908,8 +1916,9 @@ primary_expr: C_FLOAT
}
if ((deref = new_var_deref(var)))
{
- $$ = &deref->node;
- set_location(&$$->loc, &@1);
+ set_location(&deref->node.loc, &@1);
+ if (!($$ = make_list(&deref->node)))
+ YYABORT;
}
else
$$ = NULL;
@@ -1926,43 +1935,48 @@ postfix_expr: primary_expr
| postfix_expr OP_INC
{
struct source_location loc;
+ struct hlsl_ir_node *inc;
set_location(&loc, &@2);
- if ($1->data_type->modifiers & HLSL_MODIFIER_CONST)
+ if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"modifying a const expression");
YYABORT;
}
- $$ = new_unary_expr(HLSL_IR_UNOP_POSTINC, $1, loc);
+ inc = new_unary_expr(HLSL_IR_UNOP_POSTINC, node_from_list($1), loc);
/* Post increment/decrement expressions are considered const */
- $$->data_type = clone_hlsl_type($$->data_type);
- $$->data_type->modifiers |= HLSL_MODIFIER_CONST;
+ inc->data_type = clone_hlsl_type(inc->data_type);
+ inc->data_type->modifiers |= HLSL_MODIFIER_CONST;
+ $$ = append_unop($1, inc);
}
| postfix_expr OP_DEC
{
struct source_location loc;
+ struct hlsl_ir_node *inc;
set_location(&loc, &@2);
- if ($1->data_type->modifiers & HLSL_MODIFIER_CONST)
+ if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"modifying a const expression");
YYABORT;
}
- $$ = new_unary_expr(HLSL_IR_UNOP_POSTDEC, $1, loc);
+ inc = new_unary_expr(HLSL_IR_UNOP_POSTDEC, node_from_list($1), loc);
/* Post increment/decrement expressions are considered const */
- $$->data_type = clone_hlsl_type($$->data_type);
- $$->data_type->modifiers |= HLSL_MODIFIER_CONST;
+ inc->data_type = clone_hlsl_type(inc->data_type);
+ inc->data_type->modifiers |= HLSL_MODIFIER_CONST;
+ $$ = append_unop($1, inc);
}
| postfix_expr '.' any_identifier
{
+ struct hlsl_ir_node *node = node_from_list($1);
struct source_location loc;
set_location(&loc, &@2);
- if ($1->data_type->type == HLSL_CLASS_STRUCT)
+ if (node->data_type->type == HLSL_CLASS_STRUCT)
{
- struct hlsl_type *type = $1->data_type;
+ struct hlsl_type *type = node->data_type;
struct hlsl_struct_field *field;
$$ = NULL;
@@ -1970,7 +1984,7 @@ postfix_expr: primary_expr
{
if (!strcmp($3, field->name))
{
- struct hlsl_ir_deref *deref = new_record_deref($1, field);
+ struct hlsl_ir_deref *deref = new_record_deref(node, field);
if (!deref)
{
@@ -1978,7 +1992,7 @@ postfix_expr: primary_expr
YYABORT;
}
deref->node.loc = loc;
- $$ = &deref->node;
+ $$ = append_unop($1, &deref->node);
break;
}
}
@@ -1989,18 +2003,18 @@ postfix_expr: primary_expr
YYABORT;
}
}
- else if ($1->data_type->type <= HLSL_CLASS_LAST_NUMERIC)
+ else if (node->data_type->type <= HLSL_CLASS_LAST_NUMERIC)
{
struct hlsl_ir_swizzle *swizzle;
- swizzle = get_swizzle($1, $3, &loc);
+ swizzle = get_swizzle(node, $3, &loc);
if (!swizzle)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"invalid swizzle %s", debugstr_a($3));
YYABORT;
}
- $$ = &swizzle->node;
+ $$ = append_unop($1, &swizzle->node);
}
else
{
@@ -2015,7 +2029,7 @@ postfix_expr: primary_expr
* subcomponent access.
* We store it as an array dereference in any case. */
struct hlsl_ir_deref *deref = d3dcompiler_alloc(sizeof(*deref));
- struct hlsl_type *expr_type = $1->data_type;
+ struct hlsl_type *expr_type = node_from_list($1)->data_type;
struct source_location loc;
TRACE("Array dereference from type %s\n", debug_hlsl_type(expr_type));
@@ -2048,24 +2062,24 @@ postfix_expr: primary_expr
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"expression is not array-indexable");
d3dcompiler_free(deref);
- free_instr($1);
- free_instr($3);
+ free_instr_list($1);
+ free_instr_list($3);
YYABORT;
}
- if ($3->data_type->type != HLSL_CLASS_SCALAR)
+ if (node_from_list($3)->data_type->type != HLSL_CLASS_SCALAR)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"array index is not scalar");
d3dcompiler_free(deref);
- free_instr($1);
- free_instr($3);
+ free_instr_list($1);
+ free_instr_list($3);
YYABORT;
}
deref->type = HLSL_IR_DEREF_ARRAY;
- deref->v.array.array = $1;
- deref->v.array.index = $3;
+ deref->v.array.array = node_from_list($1);
+ deref->v.array.index = node_from_list($3);
- $$ = &deref->node;
+ $$ = append_binop($1, $3, &deref->node);
}
/* "var_modifiers" doesn't make sense in this case, but it's needed
in the grammar to avoid shift/reduce conflicts. */
@@ -2104,7 +2118,7 @@ postfix_expr: primary_expr
constructor->args_count = $4.args_count;
memcpy(constructor->args, $4.args, $4.args_count * sizeof(*$4.args));
d3dcompiler_free($4.args);
- $$ = &constructor->node;
+ $$ = append_unop($4.instrs, &constructor->node);
}
unary_expr: postfix_expr
@@ -2116,26 +2130,26 @@ unary_expr: postfix_expr
struct source_location loc;
set_location(&loc, &@1);
- if ($2->data_type->modifiers & HLSL_MODIFIER_CONST)
+ if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"modifying a const expression");
YYABORT;
}
- $$ = new_unary_expr(HLSL_IR_UNOP_PREINC, $2, loc);
+ $$ = append_unop($2, new_unary_expr(HLSL_IR_UNOP_PREINC, node_from_list($2), loc));
}
| OP_DEC unary_expr
{
struct source_location loc;
set_location(&loc, &@1);
- if ($2->data_type->modifiers & HLSL_MODIFIER_CONST)
+ if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"modifying a const expression");
YYABORT;
}
- $$ = new_unary_expr(HLSL_IR_UNOP_PREDEC, $2, loc);
+ $$ = append_unop($2, new_unary_expr(HLSL_IR_UNOP_PREDEC, node_from_list($2), loc));
}
| unary_op unary_expr
{
@@ -2150,14 +2164,13 @@ unary_expr: postfix_expr
else
{
set_location(&loc, &@1);
- $$ = new_unary_expr(ops[$1], $2, loc);
+ $$ = append_unop($2, new_unary_expr(ops[$1], node_from_list($2), loc));
}
}
/* var_modifiers just to avoid shift/reduce conflicts */
| '(' var_modifiers type array ')' unary_expr
{
- struct hlsl_ir_expr *expr;
- struct hlsl_type *src_type = $6->data_type;
+ struct hlsl_type *src_type = node_from_list($6)->data_type;
struct hlsl_type *dst_type;
struct source_location loc;
@@ -2182,8 +2195,7 @@ unary_expr: postfix_expr
YYABORT;
}
- expr = new_cast($6, dst_type, &loc);
- $$ = expr ? &expr->node : NULL;
+ $$ = append_unop($6, &new_cast(node_from_list($6), dst_type, &loc)->node);
}
unary_op: '+'
@@ -2212,21 +2224,21 @@ mul_expr: unary_expr
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_MUL, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_MUL, node_from_list($1), node_from_list($3), loc));
}
| mul_expr '/' unary_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_DIV, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_DIV, node_from_list($1), node_from_list($3), loc));
}
| mul_expr '%' unary_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_MOD, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_MOD, node_from_list($1), node_from_list($3), loc));
}
add_expr: mul_expr
@@ -2238,14 +2250,14 @@ add_expr: mul_expr
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_ADD, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_ADD, node_from_list($1), node_from_list($3), loc));
}
| add_expr '-' mul_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_SUB, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_SUB, node_from_list($1), node_from_list($3), loc));
}
shift_expr: add_expr
@@ -2270,28 +2282,28 @@ relational_expr: shift_expr
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_LESS, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_LESS, node_from_list($1), node_from_list($3), loc));
}
| relational_expr '>' shift_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_GREATER, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_GREATER, node_from_list($1), node_from_list($3), loc));
}
| relational_expr OP_LE shift_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_LEQUAL, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_LEQUAL, node_from_list($1), node_from_list($3), loc));
}
| relational_expr OP_GE shift_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_GEQUAL, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_GEQUAL, node_from_list($1), node_from_list($3), loc));
}
equality_expr: relational_expr
@@ -2303,14 +2315,14 @@ equality_expr: relational_expr
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_EQUAL, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_EQUAL, node_from_list($1), node_from_list($3), loc));
}
| equality_expr OP_NE relational_expr
{
struct source_location loc;
set_location(&loc, &@2);
- $$ = new_binary_expr(HLSL_IR_BINOP_NEQUAL, $1, $3, loc);
+ $$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_NEQUAL, node_from_list($1), node_from_list($3), loc));
}
bitand_expr: equality_expr
@@ -2374,18 +2386,20 @@ assignment_expr: conditional_expr
| unary_expr assign_op assignment_expr
{
struct source_location loc;
+ struct hlsl_ir_node *instr;
set_location(&loc, &@2);
- if ($1->data_type->modifiers & HLSL_MODIFIER_CONST)
+ if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
hlsl_report_message(loc.file, loc.line, loc.col, HLSL_LEVEL_ERROR,
"l-value is const");
YYABORT;
}
- $$ = make_assignment($1, $2, BWRITERSP_WRITEMASK_ALL, $3);
- if (!$$)
+ if (!(instr = make_assignment(node_from_list($1), $2,
+ BWRITERSP_WRITEMASK_ALL, node_from_list($3))))
YYABORT;
- $$->loc = loc;
+ instr->loc = loc;
+ $$ = append_binop($3, $1, instr);
}
assign_op: '='
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index 0cae62b60fc..3f5a57ffa40 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -1278,10 +1278,14 @@ static struct hlsl_type *expr_common_type(struct hlsl_type *t1, struct hlsl_type
static struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_type *type,
struct source_location *loc)
{
+ struct hlsl_ir_expr *cast;
+
if (compare_hlsl_types(node->data_type, type))
return node;
TRACE("Implicit conversion of expression to %s\n", debug_hlsl_type(type));
- return &new_cast(node, type, loc)->node;
+ if ((cast = new_cast(node, type, loc)))
+ list_add_after(&node->entry, &cast->node.entry);
+ return &cast->node;
}
struct hlsl_ir_expr *new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **operands,
@@ -1468,8 +1472,6 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assig
hlsl_report_message(rhs->loc.file, rhs->loc.line, rhs->loc.col, HLSL_LEVEL_ERROR,
"can't implicitly convert %s to %s",
debug_hlsl_type(rhs->data_type), debug_hlsl_type(type));
- free_instr(lhs);
- free_instr(rhs);
d3dcompiler_free(assign);
return NULL;
}
@@ -1481,8 +1483,6 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assig
if (!converted_rhs)
{
ERR("Couldn't implicitly convert expression to %s.\n", debug_hlsl_type(type));
- free_instr(lhs);
- free_instr(rhs);
d3dcompiler_free(assign);
return NULL;
}
@@ -1502,11 +1502,9 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assig
}
else
{
- struct hlsl_ir_deref *lhs_deref = deref_from_node(lhs), *new_deref;
-
TRACE("Adding an expression for the compound assignment.\n");
- new_deref = new_var_deref(lhs_deref->v.var);
- expr = new_binary_expr(op, &new_deref->node, rhs, left->loc);
+ expr = new_binary_expr(op, lhs, rhs, lhs->loc);
+ list_add_after(&rhs->entry, &expr->entry);
assign->rhs = expr;
}
}
@@ -2173,60 +2171,32 @@ static void free_ir_constant(struct hlsl_ir_constant *constant)
static void free_ir_deref(struct hlsl_ir_deref *deref)
{
- switch (deref->type)
- {
- case HLSL_IR_DEREF_VAR:
- /* Variables are shared among nodes in the tree. */
- break;
- case HLSL_IR_DEREF_ARRAY:
- free_instr(deref->v.array.array);
- free_instr(deref->v.array.index);
- break;
- case HLSL_IR_DEREF_RECORD:
- free_instr(deref->v.record.record);
- break;
- }
d3dcompiler_free(deref);
}
static void free_ir_swizzle(struct hlsl_ir_swizzle *swizzle)
{
- free_instr(swizzle->val);
d3dcompiler_free(swizzle);
}
static void free_ir_constructor(struct hlsl_ir_constructor *constructor)
{
- unsigned int i;
- for (i = 0; i < constructor->args_count; ++i)
- free_instr(constructor->args[i]);
d3dcompiler_free(constructor);
}
static void free_ir_expr(struct hlsl_ir_expr *expr)
{
- unsigned int i;
-
- for (i = 0; i < 3; ++i)
- {
- if (!expr->operands[i])
- break;
- free_instr(expr->operands[i]);
- }
free_instr_list(expr->subexpressions);
d3dcompiler_free(expr);
}
static void free_ir_assignment(struct hlsl_ir_assignment *assignment)
{
- free_instr(assignment->lhs);
- free_instr(assignment->rhs);
d3dcompiler_free(assignment);
}
static void free_ir_if(struct hlsl_ir_if *if_node)
{
- free_instr(if_node->condition);
free_instr_list(if_node->then_instrs);
free_instr_list(if_node->else_instrs);
d3dcompiler_free(if_node);
@@ -2234,8 +2204,6 @@ static void free_ir_if(struct hlsl_ir_if *if_node)
static void free_ir_jump(struct hlsl_ir_jump *jump)
{
- if (jump->type == HLSL_IR_JUMP_RETURN)
- free_instr(jump->return_value);
d3dcompiler_free(jump);
}
--
2.25.0
5
10
The target address is relative to the RIP of the next instruction, not
the current RIP.
Signed-off-by: Brendan Shanks <bshanks(a)codeweavers.com>
---
dlls/ntoskrnl.exe/instr.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/dlls/ntoskrnl.exe/instr.c b/dlls/ntoskrnl.exe/instr.c
index 05bdd23e82..77803f07d7 100644
--- a/dlls/ntoskrnl.exe/instr.c
+++ b/dlls/ntoskrnl.exe/instr.c
@@ -522,7 +522,7 @@ static void store_reg_byte( CONTEXT *context, BYTE regmodrm, const BYTE *addr, i
*
* Return the address of an instruction operand (from the mod/rm byte).
*/
-static BYTE *INSTR_GetOperandAddr( CONTEXT *context, BYTE *instr,
+static BYTE *INSTR_GetOperandAddr( CONTEXT *context, BYTE *instr, int addl_instr_len,
int long_addr, int rex, int segprefix, int *len )
{
int mod, rm, ss = 0, off, have_sib = 0;
@@ -566,6 +566,7 @@ static BYTE *INSTR_GetOperandAddr( CONTEXT *context, BYTE *instr,
if (!long_addr) base &= 0xffffffff;
GET_VAL( &off, DWORD );
base += (signed long)off;
+ base += (signed long)*len + (signed long)addl_instr_len;
}
break;
@@ -793,7 +794,7 @@ static DWORD emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context )
case 0xb6: /* movzx Eb, Gv */
case 0xb7: /* movzx Ew, Gv */
{
- BYTE *data = INSTR_GetOperandAddr( context, instr + 2, long_addr,
+ BYTE *data = INSTR_GetOperandAddr( context, instr + 2, prefixlen + 2, long_addr,
rex, segprefix, &len );
unsigned int data_size = (instr[1] == 0xb7) ? 2 : 1;
SIZE_T offset = data - user_shared_data;
@@ -815,7 +816,7 @@ static DWORD emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context )
case 0x8a: /* mov Eb, Gb */
case 0x8b: /* mov Ev, Gv */
{
- BYTE *data = INSTR_GetOperandAddr( context, instr + 1, long_addr,
+ BYTE *data = INSTR_GetOperandAddr( context, instr + 1, prefixlen + 1, long_addr,
rex, segprefix, &len );
unsigned int data_size = (*instr == 0x8b) ? get_op_size( long_op, rex ) : 1;
SIZE_T offset = data - user_shared_data;
--
2.24.1
1
0
This patch adds emulation for instructions protected by User-Mode
Instruction Prevention (currently implemented by AMD Ryzen 3000 CPUs and
some rare Intel CPUs).
Changes from previous patch:
Switch the return values of emulate_umip_instr() to make is_privileged_instr() simpler
Brendan Shanks (2):
ntdll: Add emulation for UMIP instructions.
ntdll/tests: Add tests for UMIP instructions.
dlls/ntdll/signal_i386.c | 307 +++++++++++++++++++++++++++-
dlls/ntdll/signal_x86_64.c | 346 +++++++++++++++++++++++++++++++-
dlls/ntdll/tests/exception.c | 375 +++++++++++++++++++++++++++++++++++
3 files changed, 1012 insertions(+), 16 deletions(-)
--
2.24.1
1
3
[PATCH] wincodecs: Return WINCODEC_ERR_PALETTEUNAVAILABLE for jpeg decoder frame.
by Nikolay Sivov 14 Feb '20
by Nikolay Sivov 14 Feb '20
14 Feb '20
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/windowscodecs/jpegformat.c | 5 +++--
dlls/windowscodecs/tests/jpegformat.c | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/windowscodecs/jpegformat.c b/dlls/windowscodecs/jpegformat.c
index 1df898f28c..0ecbbf48fc 100644
--- a/dlls/windowscodecs/jpegformat.c
+++ b/dlls/windowscodecs/jpegformat.c
@@ -635,8 +635,9 @@ static HRESULT WINAPI JpegDecoder_Frame_GetResolution(IWICBitmapFrameDecode *ifa
static HRESULT WINAPI JpegDecoder_Frame_CopyPalette(IWICBitmapFrameDecode *iface,
IWICPalette *pIPalette)
{
- FIXME("(%p,%p): stub\n", iface, pIPalette);
- return E_NOTIMPL;
+ TRACE("(%p,%p)\n", iface, pIPalette);
+
+ return WINCODEC_ERR_PALETTEUNAVAILABLE;
}
static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
diff --git a/dlls/windowscodecs/tests/jpegformat.c b/dlls/windowscodecs/tests/jpegformat.c
index c1e46c4869..341e42c28c 100644
--- a/dlls/windowscodecs/tests/jpegformat.c
+++ b/dlls/windowscodecs/tests/jpegformat.c
@@ -47,6 +47,8 @@ static void test_decode_adobe_cmyk(void)
{
IWICBitmapDecoder *decoder;
IWICBitmapFrameDecode *framedecode;
+ IWICImagingFactory *factory;
+ IWICPalette *palette;
HRESULT hr;
HGLOBAL hjpegdata;
char *jpegdata;
@@ -77,6 +79,10 @@ static void test_decode_adobe_cmyk(void)
ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
if (FAILED(hr)) return;
+ hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IWICImagingFactory, (void **)&factory);
+ ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
+
hjpegdata = GlobalAlloc(GMEM_MOVEABLE, sizeof(jpeg_adobe_cmyk_1x5));
ok(hjpegdata != 0, "GlobalAlloc failed\n");
if (hjpegdata)
@@ -125,13 +131,27 @@ static void test_decode_adobe_cmyk(void)
broken(!memcmp(imagedata, expected_imagedata_24bpp, sizeof(expected_imagedata))), /* xp/2003 */
"unexpected image data\n");
}
+
+ hr = IWICImagingFactory_CreatePalette(factory, &palette);
+ ok(SUCCEEDED(hr), "CreatePalette failed, hr=%x\n", hr);
+
+ hr = IWICBitmapDecoder_CopyPalette(decoder, palette);
+ ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "Unexpected hr %#x.\n", hr);
+
+ hr = IWICBitmapFrameDecode_CopyPalette(framedecode, palette);
+ ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "Unexpected hr %#x.\n", hr);
+
+ IWICPalette_Release(palette);
+
IWICBitmapFrameDecode_Release(framedecode);
}
IStream_Release(jpegstream);
}
GlobalFree(hjpegdata);
}
+
IWICBitmapDecoder_Release(decoder);
+ IWICImagingFactory_Release(factory);
}
--
2.25.0
3
2
14 Feb '20
Signed-off-by: Jeff Smith <whydoubt(a)gmail.com>
---
dlls/gdiplus/pen.c | 5 +----
dlls/gdiplus/tests/pen.c | 3 +++
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c
index 8bcb91819a..156f90a19d 100644
--- a/dlls/gdiplus/pen.c
+++ b/dlls/gdiplus/pen.c
@@ -598,13 +598,10 @@ GpStatus WINGDIPAPI GdipSetPenDashArray(GpPen *pen, GDIPCONST REAL *dash,
for(i = 0; i < count; i++){
sum += dash[i];
- if(dash[i] < 0.0)
+ if(dash[i] <= 0.0)
return InvalidParameter;
}
- if(sum == 0.0 && count)
- return InvalidParameter;
-
heap_free(pen->dashes);
pen->dashes = NULL;
diff --git a/dlls/gdiplus/tests/pen.c b/dlls/gdiplus/tests/pen.c
index ceab92acff..3c4507f9d5 100644
--- a/dlls/gdiplus/tests/pen.c
+++ b/dlls/gdiplus/tests/pen.c
@@ -222,6 +222,9 @@ static void test_dasharray(void)
dashes[9] = -1.0;
status = GdipSetPenDashArray(pen, &dashes[7], 5);
expect(InvalidParameter, status);
+ dashes[9] = 1.0;
+ status = GdipSetPenDashArray(pen, &dashes[7], 5);
+ expect(InvalidParameter, status);
/* Try to set with count = 0. */
GdipSetPenDashStyle(pen, DashStyleDot);
--
2.23.0
2
1
[PATCH 1/2] d3dcompiler: Free variable definitions data on allocation errors.
by Matteo Bruni 14 Feb '20
by Matteo Bruni 14 Feb '20
14 Feb '20
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
---
dlls/d3dcompiler_43/hlsl.y | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index 52b2b6310b6..b6478bf3fed 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -530,6 +530,15 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
d3dcompiler_free(initializer->args);
}
+static void free_parse_variable_def(struct parse_variable_def *v)
+{
+ free_parse_initializer(&v->initializer);
+ d3dcompiler_free(v->name);
+ d3dcompiler_free((void *)v->semantic);
+ d3dcompiler_free(v->reg_reservation);
+ d3dcompiler_free(v);
+}
+
static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, struct list *var_list)
{
struct hlsl_type *type;
@@ -543,7 +552,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
{
ERR("Out of memory.\n");
LIST_FOR_EACH_ENTRY_SAFE(v, v_next, var_list, struct parse_variable_def, entry)
- d3dcompiler_free(v);
+ free_parse_variable_def(v);
d3dcompiler_free(var_list);
return NULL;
}
@@ -558,7 +567,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
if (!var)
{
ERR("Out of memory.\n");
- d3dcompiler_free(v);
+ free_parse_variable_def(v);
continue;
}
if (v->array_size)
--
2.24.1
1
1
14 Feb '20
All of the strings produced by the semi-stub are valid IPv6 addresses,
though not necessarily in the same format that Windows would give them
in.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46788
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
v2: Remove always-false if statement from RtlIpv6AddressToStringA
---
dlls/ntdll/ntdll.spec | 4 +-
dlls/ntdll/rtl.c | 77 +++++++++++++++++
dlls/ntdll/tests/rtl.c | 189 +++++++++++++++++++++--------------------
3 files changed, 177 insertions(+), 93 deletions(-)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 7aa953ca6c..db7949044c 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -774,8 +774,8 @@
@ stdcall RtlIpv4StringToAddressExA(str long ptr ptr)
@ stdcall RtlIpv4StringToAddressExW(wstr long ptr ptr)
@ stdcall RtlIpv4StringToAddressW(wstr long ptr ptr)
-# @ stub RtlIpv6AddressToStringA
-# @ stub RtlIpv6AddressToStringExA
+@ stdcall RtlIpv6AddressToStringA(ptr ptr)
+@ stdcall RtlIpv6AddressToStringExA(ptr long long ptr ptr)
# @ stub RtlIpv6AddressToStringExW
# @ stub RtlIpv6AddressToStringW
# @ stub RtlIpv6StringToAddressA
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c
index 15ff037fef..b6cb02be04 100644
--- a/dlls/ntdll/rtl.c
+++ b/dlls/ntdll/rtl.c
@@ -1196,6 +1196,83 @@ CHAR * WINAPI RtlIpv4AddressToStringA(const IN_ADDR *pin, LPSTR buffer)
return buffer + size - 1;
}
+/***********************************************************************
+ * RtlIpv6AddressToStringExA [NTDLL.@]
+ */
+NTSTATUS WINAPI RtlIpv6AddressToStringExA(const IN6_ADDR *address, ULONG scope, USHORT port, char *str, ULONG *size)
+{
+ char buffer[60];
+ ULONG needed;
+ NTSTATUS ret;
+
+ FIXME("(%p %u %u %p %p): semi-stub\n", address, scope, port, str, size);
+
+ if (!address || !str || !size)
+ return STATUS_INVALID_PARAMETER;
+
+ if (scope && port)
+ {
+ needed = sprintf(buffer, "[%x:%x:%x:%x:%x:%x:%x:%x%%%u]:%u",
+ ntohs(address->u.Word[0]), ntohs(address->u.Word[1]),
+ ntohs(address->u.Word[2]), ntohs(address->u.Word[3]),
+ ntohs(address->u.Word[4]), ntohs(address->u.Word[5]),
+ ntohs(address->u.Word[6]), ntohs(address->u.Word[7]),
+ scope, ntohs(port));
+ }
+ else if (scope)
+ {
+ needed = sprintf(buffer, "%x:%x:%x:%x:%x:%x:%x:%x%%%u",
+ ntohs(address->u.Word[0]), ntohs(address->u.Word[1]),
+ ntohs(address->u.Word[2]), ntohs(address->u.Word[3]),
+ ntohs(address->u.Word[4]), ntohs(address->u.Word[5]),
+ ntohs(address->u.Word[6]), ntohs(address->u.Word[7]),
+ scope);
+ }
+ else if (port)
+ {
+ needed = sprintf(buffer, "[%x:%x:%x:%x:%x:%x:%x:%x]:%u",
+ ntohs(address->u.Word[0]), ntohs(address->u.Word[1]),
+ ntohs(address->u.Word[2]), ntohs(address->u.Word[3]),
+ ntohs(address->u.Word[4]), ntohs(address->u.Word[5]),
+ ntohs(address->u.Word[6]), ntohs(address->u.Word[7]),
+ ntohs(port));
+ }
+ else
+ {
+ needed = sprintf(buffer, "%x:%x:%x:%x:%x:%x:%x:%x",
+ ntohs(address->u.Word[0]), ntohs(address->u.Word[1]),
+ ntohs(address->u.Word[2]), ntohs(address->u.Word[3]),
+ ntohs(address->u.Word[4]), ntohs(address->u.Word[5]),
+ ntohs(address->u.Word[6]), ntohs(address->u.Word[7]));
+ }
+ needed++;
+
+ if (*size >= needed)
+ {
+ strcpy(str, buffer);
+ ret = STATUS_SUCCESS;
+ }
+ else
+ {
+ ret = STATUS_INVALID_PARAMETER;
+ }
+
+ *size = needed;
+ return ret;
+}
+
+/***********************************************************************
+ * RtlIpv6AddressToStringA [NTDLL.@]
+ */
+char * WINAPI RtlIpv6AddressToStringA(const IN6_ADDR *address, char *str)
+{
+ ULONG size = 46;
+ if (!address || !str) return str - 1;
+ str[45] = 0; /* this byte is set even though the string is always shorter */
+ RtlIpv6AddressToStringExA(address, 0, 0, str, &size);
+ return str + size - 1;
+}
+
/***********************************************************************
* get_pointer_obfuscator (internal)
*/
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c
index 559a7d625c..c7470258fb 100644
--- a/dlls/ntdll/tests/rtl.c
+++ b/dlls/ntdll/tests/rtl.c
@@ -1791,80 +1791,81 @@ static void test_RtlIpv6AddressToString(void)
LPCSTR result;
IN6_ADDR ip;
DWORD_PTR len;
- struct
+ static const struct
{
PCSTR address;
int ip[8];
+ BOOL todo;
} tests[] =
{
/* ipv4 addresses & ISATAP addresses */
- { "::13.1.68.3", { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
- { "::ffff:13.1.68.3", { 0, 0, 0, 0, 0, 0xffff, 0x10d, 0x344 } },
- { "::feff:d01:4403", { 0, 0, 0, 0, 0, 0xfffe, 0x10d, 0x344 } },
- { "::fffe:d01:4403", { 0, 0, 0, 0, 0, 0xfeff, 0x10d, 0x344 } },
- { "::100:d01:4403", { 0, 0, 0, 0, 0, 1, 0x10d, 0x344 } },
- { "::1:d01:4403", { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
- { "::ffff:0:4403", { 0, 0, 0, 0, 0, 0xffff, 0, 0x344 } },
- { "::ffff:13.1.0.0", { 0, 0, 0, 0, 0, 0xffff, 0x10d, 0 } },
- { "::ffff:0:0", { 0, 0, 0, 0, 0, 0xffff, 0, 0 } },
- { "::ffff:0:13.1.68.3", { 0, 0, 0, 0, 0xffff, 0, 0x10d, 0x344 } },
- { "::ffff:ffff:d01:4403", { 0, 0, 0, 0, 0xffff, 0xffff, 0x10d, 0x344 } },
- { "::ffff:0:0:d01:4403", { 0, 0, 0, 0xffff, 0, 0, 0x10d, 0x344 } },
- { "::ffff:255.255.255.255", { 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff } },
- { "::ffff:129.144.52.38", { 0, 0, 0, 0, 0, 0xffff, 0x9081, 0x2634 } },
- { "::5efe:129.144.52.38", { 0, 0, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "1111:2222:3333:4444:0:5efe:129.144.52.38", { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "1111:2222:3333::5efe:129.144.52.38", { 0x1111, 0x2222, 0x3333, 0, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "1111:2222::5efe:129.144.52.38", { 0x1111, 0x2222, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "1111::5efe:129.144.52.38", { 0x1111, 0, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "::200:5efe:129.144.52.38", { 0, 0, 0, 0, 2, 0xfe5e, 0x9081, 0x2634 } },
- { "::100:5efe:8190:3426", { 0, 0, 0, 0, 1, 0xfe5e, 0x9081, 0x2634 } },
+ { "::13.1.68.3", { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "::ffff:13.1.68.3", { 0, 0, 0, 0, 0, 0xffff, 0x10d, 0x344 }, TRUE },
+ { "::feff:d01:4403", { 0, 0, 0, 0, 0, 0xfffe, 0x10d, 0x344 }, TRUE },
+ { "::fffe:d01:4403", { 0, 0, 0, 0, 0, 0xfeff, 0x10d, 0x344 }, TRUE },
+ { "::100:d01:4403", { 0, 0, 0, 0, 0, 1, 0x10d, 0x344 }, TRUE },
+ { "::1:d01:4403", { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+ { "::ffff:0:4403", { 0, 0, 0, 0, 0, 0xffff, 0, 0x344 }, TRUE },
+ { "::ffff:13.1.0.0", { 0, 0, 0, 0, 0, 0xffff, 0x10d, 0 }, TRUE },
+ { "::ffff:0:0", { 0, 0, 0, 0, 0, 0xffff, 0, 0 }, TRUE },
+ { "::ffff:0:13.1.68.3", { 0, 0, 0, 0, 0xffff, 0, 0x10d, 0x344 }, TRUE },
+ { "::ffff:ffff:d01:4403", { 0, 0, 0, 0, 0xffff, 0xffff, 0x10d, 0x344 }, TRUE },
+ { "::ffff:0:0:d01:4403", { 0, 0, 0, 0xffff, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "::ffff:255.255.255.255", { 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff }, TRUE },
+ { "::ffff:129.144.52.38", { 0, 0, 0, 0, 0, 0xffff, 0x9081, 0x2634 }, TRUE },
+ { "::5efe:129.144.52.38", { 0, 0, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "1111:2222:3333:4444:0:5efe:129.144.52.38", { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "1111:2222:3333::5efe:129.144.52.38", { 0x1111, 0x2222, 0x3333, 0, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "1111:2222::5efe:129.144.52.38", { 0x1111, 0x2222, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "1111::5efe:129.144.52.38", { 0x1111, 0, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "::200:5efe:129.144.52.38", { 0, 0, 0, 0, 2, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "::100:5efe:8190:3426", { 0, 0, 0, 0, 1, 0xfe5e, 0x9081, 0x2634 }, TRUE },
/* 'normal' addresses */
- { "::1", { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
+ { "::1", { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
{ "0:1:2:3:4:5:6:7", { 0, 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700 } },
- { "1080::8:800:200c:417a", { 0x8010, 0, 0, 0, 0x800, 0x8, 0x0c20, 0x7a41 } },
+ { "1080::8:800:200c:417a", { 0x8010, 0, 0, 0, 0x800, 0x8, 0x0c20, 0x7a41 }, TRUE },
{ "1111:2222:3333:4444:5555:6666:7b7b:7b7b", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
{ "1111:2222:3333:4444:5555:6666:7777:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
- { "1111:2222:3333:4444:5555:6666::", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0, 0 } },
+ { "1111:2222:3333:4444:5555:6666::", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0, 0 }, TRUE },
{ "1111:2222:3333:4444:5555:6666:0:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0, 0x8888 } },
- { "1111:2222:3333:4444:5555::", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0 } },
+ { "1111:2222:3333:4444:5555::", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0 }, TRUE },
{ "1111:2222:3333:4444:5555:0:7b7b:7b7b", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0x7b7b, 0x7b7b } },
{ "1111:2222:3333:4444:5555:0:7777:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0x7777, 0x8888 } },
- { "1111:2222:3333:4444:5555::8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0x8888 } },
- { "1111::", { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
- { "1111::7b7b:7b7b", { 0x1111, 0, 0, 0, 0, 0, 0x7b7b, 0x7b7b } },
+ { "1111:2222:3333:4444:5555::8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0x8888 }, TRUE },
+ { "1111::", { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "1111::7b7b:7b7b", { 0x1111, 0, 0, 0, 0, 0, 0x7b7b, 0x7b7b }, TRUE },
{ "1111:0:3333:4444:5555:6666:7b7b:7b7b", { 0x1111, 0, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
{ "1111:0:3333:4444:5555:6666:7777:8888", { 0x1111, 0, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
- { "1111::4444:5555:6666:7b7b:7b7b", { 0x1111, 0, 0, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
- { "1111::4444:5555:6666:7777:8888", { 0x1111, 0, 0, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
- { "1111::5555:6666:7b7b:7b7b", { 0x1111, 0, 0, 0, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
- { "1111::5555:6666:7777:8888", { 0x1111, 0, 0, 0, 0x5555, 0x6666, 0x7777, 0x8888 } },
- { "1111::6666:7b7b:7b7b", { 0x1111, 0, 0, 0, 0, 0x6666, 0x7b7b, 0x7b7b } },
- { "1111::6666:7777:8888", { 0x1111, 0, 0, 0, 0, 0x6666, 0x7777, 0x8888 } },
- { "1111::7777:8888", { 0x1111, 0, 0, 0, 0, 0, 0x7777, 0x8888 } },
- { "1111::8888", { 0x1111, 0, 0, 0, 0, 0, 0, 0x8888 } },
+ { "1111::4444:5555:6666:7b7b:7b7b", { 0x1111, 0, 0, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b }, TRUE },
+ { "1111::4444:5555:6666:7777:8888", { 0x1111, 0, 0, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 }, TRUE },
+ { "1111::5555:6666:7b7b:7b7b", { 0x1111, 0, 0, 0, 0x5555, 0x6666, 0x7b7b, 0x7b7b }, TRUE },
+ { "1111::5555:6666:7777:8888", { 0x1111, 0, 0, 0, 0x5555, 0x6666, 0x7777, 0x8888 }, TRUE },
+ { "1111::6666:7b7b:7b7b", { 0x1111, 0, 0, 0, 0, 0x6666, 0x7b7b, 0x7b7b }, TRUE },
+ { "1111::6666:7777:8888", { 0x1111, 0, 0, 0, 0, 0x6666, 0x7777, 0x8888 }, TRUE },
+ { "1111::7777:8888", { 0x1111, 0, 0, 0, 0, 0, 0x7777, 0x8888 }, TRUE },
+ { "1111::8888", { 0x1111, 0, 0, 0, 0, 0, 0, 0x8888 }, TRUE },
{ "1:2:3:4:5:6:102:304", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x201, 0x403 } },
{ "1:2:3:4:5:6:7:8", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700, 0x800 } },
- { "1:2:3:4:5:6::", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0, 0 } },
+ { "1:2:3:4:5:6::", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0, 0 }, TRUE },
{ "1:2:3:4:5:6:0:8", { 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0, 0x800 } },
- { "2001:0:1234::c1c0:abcd:876", { 0x120, 0, 0x3412, 0, 0, 0xc0c1, 0xcdab, 0x7608 } },
+ { "2001:0:1234::c1c0:abcd:876", { 0x120, 0, 0x3412, 0, 0, 0xc0c1, 0xcdab, 0x7608 }, TRUE },
{ "2001:0:4136:e378:8000:63bf:3fff:fdd2", { 0x120, 0, 0x3641, 0x78e3, 0x80, 0xbf63, 0xff3f, 0xd2fd } },
- { "2001:db8::1428:57ab", { 0x120, 0xb80d, 0, 0, 0, 0, 0x2814, 0xab57 } },
+ { "2001:db8::1428:57ab", { 0x120, 0xb80d, 0, 0, 0, 0, 0x2814, 0xab57 }, TRUE },
{ "2001:db8:1234:ffff:ffff:ffff:ffff:ffff", { 0x120, 0xb80d, 0x3412, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff } },
{ "2001:0:ce49:7601:2cad:dfff:7c94:fffe", { 0x120, 0, 0x49ce, 0x176, 0xad2c, 0xffdf, 0x947c, 0xfeff } },
- { "2001:db8:85a3::8a2e:370:7334", { 0x120, 0xb80d, 0xa385, 0, 0, 0x2e8a, 0x7003, 0x3473 } },
- { "3ffe:b00::1:0:0:a", { 0xfe3f, 0xb, 0, 0, 0x100, 0, 0, 0xa00 } },
- { "::a:b:c:d:e", { 0, 0, 0, 0xa00, 0xb00, 0xc00, 0xd00, 0xe00 } },
- { "::123.123.123.123", { 0, 0, 0, 0, 0, 0, 0x7b7b, 0x7b7b } },
+ { "2001:db8:85a3::8a2e:370:7334", { 0x120, 0xb80d, 0xa385, 0, 0, 0x2e8a, 0x7003, 0x3473 }, TRUE },
+ { "3ffe:b00::1:0:0:a", { 0xfe3f, 0xb, 0, 0, 0x100, 0, 0, 0xa00 }, TRUE },
+ { "::a:b:c:d:e", { 0, 0, 0, 0xa00, 0xb00, 0xc00, 0xd00, 0xe00 }, TRUE },
+ { "::123.123.123.123", { 0, 0, 0, 0, 0, 0, 0x7b7b, 0x7b7b }, TRUE },
{ "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff } },
{ "1111:2222:3333:4444:5555:6666:7777:1", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x100 } },
{ "1111:2222:3333:4444:5555:6666:7777:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
- { "1111:2222::", { 0x1111, 0x2222, 0, 0, 0, 0, 0, 0 } },
- { "1111::3333:4444:5555:6666:7777", { 0x1111, 0, 0, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777 } },
- { "1111:2222::", { 0x1111, 0x2222, 0, 0, 0, 0, 0, 0 } },
- { "1111::3333", { 0x1111, 0, 0, 0, 0, 0, 0, 0x3333 } },
- { "2001:0:1234::c1c0:abcd:876", { 0x120, 0, 0x3412, 0, 0, 0xc0c1, 0xcdab, 0x7608 } },
- { "2001::ffd3", { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
+ { "1111:2222::", { 0x1111, 0x2222, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "1111::3333:4444:5555:6666:7777", { 0x1111, 0, 0, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777 }, TRUE },
+ { "1111:2222::", { 0x1111, 0x2222, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "1111::3333", { 0x1111, 0, 0, 0, 0, 0, 0, 0x3333 }, TRUE },
+ { "2001:0:1234::c1c0:abcd:876", { 0x120, 0, 0x3412, 0, 0, 0xc0c1, 0xcdab, 0x7608 }, TRUE },
+ { "2001::ffd3", { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
};
unsigned int i;
@@ -1880,6 +1881,7 @@ static void test_RtlIpv6AddressToString(void)
result = pRtlIpv6AddressToStringA(&ip, buffer);
len = strlen(buffer);
+todo_wine
ok(result == (buffer + len) && !strcmp(buffer, "::"),
"got %p with '%s' (expected %p with '::')\n", result, buffer, buffer + len);
@@ -1895,6 +1897,7 @@ static void test_RtlIpv6AddressToString(void)
result = pRtlIpv6AddressToStringA(&ip, buffer);
len = strlen(buffer);
+todo_wine_if(tests[i].todo)
ok(result == (buffer + len) && !strcmp(buffer, tests[i].address),
"got %p with '%s' (expected %p with '%s')\n", result, buffer, buffer + len, tests[i].address);
@@ -1910,42 +1913,43 @@ static void test_RtlIpv6AddressToStringEx(void)
NTSTATUS res;
IN6_ADDR ip;
ULONG len;
- struct
+ static const struct
{
PCSTR address;
ULONG scopeid;
USHORT port;
int ip[8];
+ BOOL todo;
} tests[] =
{
/* ipv4 addresses & ISATAP addresses */
- { "::13.1.68.3", 0, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
- { "::13.1.68.3%1", 1, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
- { "::13.1.68.3%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
- { "[::13.1.68.3%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
- { "[::13.1.68.3%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
- { "[::13.1.68.3]:256", 0, 1, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } },
-
- { "::1:d01:4403", 0, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
- { "::1:d01:4403%1", 1, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
- { "::1:d01:4403%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
- { "[::1:d01:4403%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
- { "[::1:d01:4403%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
- { "[::1:d01:4403]:256", 0, 1, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } },
-
- { "1111:2222:3333:4444:0:5efe:129.144.52.38", 0, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "1111:2222:3333:4444:0:5efe:129.144.52.38%1", 1, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819", 0xffffbbbb, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "[1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819]:65518",0xffffbbbb, 0xeeff, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "[1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
- { "[1111:2222:3333:4444:0:5efe:129.144.52.38]:256", 0, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } },
-
- { "::1", 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
- { "::1%1", 1, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
- { "::1%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
- { "[::1%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
- { "[::1%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
- { "[::1]:256", 0, 1, { 0, 0, 0, 0, 0, 0, 0, 0x100 } },
+ { "::13.1.68.3", 0, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "::13.1.68.3%1", 1, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "::13.1.68.3%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "[::13.1.68.3%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "[::13.1.68.3%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+ { "[::13.1.68.3]:256", 0, 1, { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 }, TRUE },
+
+ { "::1:d01:4403", 0, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+ { "::1:d01:4403%1", 1, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+ { "::1:d01:4403%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+ { "[::1:d01:4403%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+ { "[::1:d01:4403%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+ { "[::1:d01:4403]:256", 0, 1, { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 }, TRUE },
+
+ { "1111:2222:3333:4444:0:5efe:129.144.52.38", 0, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "1111:2222:3333:4444:0:5efe:129.144.52.38%1", 1, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819", 0xffffbbbb, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "[1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819]:65518",0xffffbbbb, 0xeeff, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "[1111:2222:3333:4444:0:5efe:129.144.52.38%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+ { "[1111:2222:3333:4444:0:5efe:129.144.52.38]:256", 0, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 }, TRUE },
+
+ { "::1", 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
+ { "::1%1", 1, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
+ { "::1%4294949819", 0xffffbbbb, 0, { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
+ { "[::1%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
+ { "[::1%4294949819]:256", 0xffffbbbb, 1, { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
+ { "[::1]:256", 0, 1, { 0, 0, 0, 0, 0, 0, 0, 0x100 }, TRUE },
{ "1111:2222:3333:4444:5555:6666:7b7b:7b7b", 0, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
{ "1111:2222:3333:4444:5555:6666:7b7b:7b7b%1", 1, 0, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
@@ -1954,19 +1958,19 @@ static void test_RtlIpv6AddressToStringEx(void)
{ "[1111:2222:3333:4444:5555:6666:7b7b:7b7b%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
{ "[1111:2222:3333:4444:5555:6666:7b7b:7b7b]:256", 0, 1, { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } },
- { "1111::", 0, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
- { "1111::%1", 1, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
- { "1111::%4294949819", 0xffffbbbb, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
- { "[1111::%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
- { "[1111::%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
- { "[1111::]:256", 0, 1, { 0x1111, 0, 0, 0, 0, 0, 0, 0 } },
-
- { "2001::ffd3", 0, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
- { "2001::ffd3%1", 1, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
- { "2001::ffd3%4294949819", 0xffffbbbb, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
- { "[2001::ffd3%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
- { "[2001::ffd3%4294949819]:256", 0xffffbbbb, 1, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
- { "[2001::ffd3]:256", 0, 1, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff } },
+ { "1111::", 0, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "1111::%1", 1, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "1111::%4294949819", 0xffffbbbb, 0, { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "[1111::%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "[1111::%4294949819]:256", 0xffffbbbb, 1, { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+ { "[1111::]:256", 0, 1, { 0x1111, 0, 0, 0, 0, 0, 0, 0 }, TRUE },
+
+ { "2001::ffd3", 0, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
+ { "2001::ffd3%1", 1, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
+ { "2001::ffd3%4294949819", 0xffffbbbb, 0, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
+ { "[2001::ffd3%4294949819]:65518", 0xffffbbbb, 0xeeff, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
+ { "[2001::ffd3%4294949819]:256", 0xffffbbbb, 1, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
+ { "[2001::ffd3]:256", 0, 1, { 0x120, 0, 0, 0, 0, 0, 0, 0xd3ff }, TRUE },
};
unsigned int i;
@@ -1983,6 +1987,7 @@ static void test_RtlIpv6AddressToStringEx(void)
res = pRtlIpv6AddressToStringExA(&ip, 0, 0, buffer, &len);
ok(res == STATUS_SUCCESS, "[validate] res = 0x%08x, expected STATUS_SUCCESS\n", res);
+todo_wine
ok(len == 3 && !strcmp(buffer, "::"),
"got len %d with '%s' (expected 3 with '::')\n", len, buffer);
@@ -2006,6 +2011,7 @@ static void test_RtlIpv6AddressToStringEx(void)
res = pRtlIpv6AddressToStringExA(&ip, 0, 0, buffer, &len);
ok(res == STATUS_INVALID_PARAMETER, "[null length] res = 0x%08x, expected STATUS_INVALID_PARAMETER\n", res);
ok(buffer[0] == '#', "got first char %c (expected '#')\n", buffer[0]);
+todo_wine
ok(len == 3, "got len %d (expected len 3)\n", len);
for (i = 0; i < ARRAY_SIZE(tests); i++)
@@ -2018,6 +2024,7 @@ static void test_RtlIpv6AddressToStringEx(void)
res = pRtlIpv6AddressToStringExA(&ip, tests[i].scopeid, tests[i].port, buffer, &len);
ok(res == STATUS_SUCCESS, "[validate] res = 0x%08x, expected STATUS_SUCCESS\n", res);
+todo_wine_if(tests[i].todo)
ok(len == (strlen(tests[i].address) + 1) && !strcmp(buffer, tests[i].address),
"got len %d with '%s' (expected %d with '%s')\n", len, buffer, (int)strlen(tests[i].address), tests[i].address);
}
--
2.25.0
1
0
Otherwise widl crashes while generating a typelib for
typedef struct _s
{
int type;
union
{
int field;
} u;
} s;
Signed-off-by: Dmitry Timoshkov <dmitry(a)baikal.ru>
---
tools/widl/write_msft.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
index 3a11d2ddd7..b70057eda1 100644
--- a/tools/widl/write_msft.c
+++ b/tools/widl/write_msft.c
@@ -2208,6 +2208,9 @@ static void add_union_typeinfo(msft_typelib_t *typelib, type_t *tunion)
if (-1 < tunion->typelib_idx)
return;
+ if (!tunion->name)
+ tunion->name = gen_name();
+
tunion->typelib_idx = typelib->typelib_header.nrtypeinfos;
msft_typeinfo = create_msft_typeinfo(typelib, TKIND_UNION, tunion->name, tunion->attrs);
msft_typeinfo->typeinfo->size = 0;
--
2.20.1
2
3