/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <strings.h>
#include <string.h>
#include "ndrgen.h"
#include "y.tab.h"
#define ALLOW_NOTHING 0
struct tup {
};
static void analyze_typeinfo_list(void);
static void analyze_typeinfo_typedef(ndr_typeinfo_t *);
static void analyze_typeinfo_struct(ndr_typeinfo_t *);
static void analyze_typeinfo_union(ndr_typeinfo_t *);
static void analyze_typeinfo_aggregate_finish(ndr_typeinfo_t *);
static void seed_basic_types(void);
static void seed_construct_types(void);
static void append_typeinfo(ndr_typeinfo_t *);
void
analyze(void)
{
}
void
show_typeinfo_list(void)
{
int i;
char *p;
case STRUCT_KW:
p = "struct";
break;
case UNION_KW:
p = "union";
break;
case TYPEDEF_KW:
p = "typedef";
break;
case STRING_KW:
case STAR:
case LB:
case BASIC_TYPE:
(void) printf("extern ndr_%s()\n",
} else if (!ti->is_referenced) {
}
continue;
default:
(void) printf("show_typeinfo skipping %d\n",
continue;
}
(void) printf("\n\n");
(void) printf(" %-16s ndr_%-13s",
(void) printf(" fsiz=%d vsiz=%d algn=%d off=%d\n",
mem->pdu_offset);
}
(void) printf("} fsiz=%d vsiz=%d algn=%d comp=%d ptrs=%d\n",
ti->has_pointers);
}
}
void
{
*p_fb = 0;
case BASIC_TYPE:
case STRUCT_KW:
case TYPEDEF_KW:
case UNION_KW:
break;
case STAR:
break;
case LB:
} else {
}
break;
case STRING_KW:
break;
default:
break;
}
while (*p_fb)
p_fb++;
}
}
static void
{
char *p;
if (!tup) {
return;
}
case BASIC_TYPE:
case TYPEDEF_KW:
break;
case STRUCT_KW:
break;
case UNION_KW:
break;
case STAR:
*funcbuf = '*';
break;
case LB:
p = fb;
*p++ = '(';
if (*p == '*') {
p = fb;
}
} else {
"%s[NDR_ANYSIZE_DIM]", p);
}
break;
case STRING_KW:
p = fb;
*p++ = '(';
if (*p == '*') {
p = fb;
}
break;
default:
break;
}
}
static void
{
int n_tt = 0;
}
}
void
{
funcbuf[0] = '(';
}
void
{
}
void
{
int i;
int n = 0;
for (i = 0; i < N_ADVICE; i++) {
continue;
if (n++ == 0)
else
(void) printf(" ");
}
if (n)
(void) printf("]\n");
}
static void
analyze_typeinfo_list(void)
{
case STRUCT_KW:
break;
case UNION_KW:
break;
case TYPEDEF_KW:
break;
}
}
}
static void
{
int i;
int allow;
unsigned long offset;
/*
* Snarf the advice.
*/
/*
* Convert the members to table.
* Determine layout metrics along the way.
*/
i = 0;
offset = 0;
&offset, /* progress offset */
allow); /* see above */
/* Align offset to determine overall size */
offset++;
}
static void
{
int i;
int allow;
unsigned long offset;
/*
* Snarf the advice. Only recognize [operation()] for
* struct definitions.
*/
/*
* Convert the members from list to table.
* Determine layout metrics along the way.
*/
i = 0;
offset = 0;
else
allow = 0;
}
/* Align offset to determine overall size */
offset++;
/* If last member is var-sized, so is this struct */
if (ti->size_variable_part)
}
static void
{
int i;
unsigned long offset;
unsigned long size;
/*
* Snarf the advice. None supported for union definitions.
* Only [switch_is()] supported for union instances.
*/
/*
* Convert the members from list to table.
* Determine layout metrics along the way.
*/
i = 0;
size = 0;
offset = 0; /* all members offset=0 */
&offset,
}
/* align size to determine overall size */
size++;
}
static void
{
int i;
int has_pointers = 0;
}
}
static void
{
int i, n_decl_ops;
/*
* Set line_number for error reporting (so we know where to look)
*/
/*
* Simple parts of member
*/
/*
* The node list for the declarator is in outside-to-inside
* order. It is also decorated with the LP nodes for
* precedence, which are in our way at this point.
*
* These two loops reverse the list, which is easier
* to analyze. For example, the declaration:
*
* ulong * (id[100]);
*
* will have the node list (=> indicates n_d_descend):
*
* ulong => STAR => LP => LB[100] => id
*
* and the conversion will result in type info (=> indicates
* type_down):
*
* id => LB[100] => STAR => ulong
*
* which is closer to how you would pronounce the declaration:
*
* id is an array size 100 of pointers to ulong.
*/
/* first pass -- turn the list into a table */
n_decl_ops = 0;
break; /* done */
}
continue; /* ignore precedence nodes */
}
if (!np) {
compile_error("declaration error");
(void) printf("\n");
} else {
}
/* second pass -- turn the table into push-back list */
}
for (i = n_decl_ops; i-- > 0; ) {
case LB:
break;
}
/*
* bind_typeinfo() reuses (interns) typeinfo's to
* make later code generation easier. It will report
* some errors.
*/
}
/* bind the member to its type info */
/*
* Now, apply the type info to the member layout metrics.
*/
/* alignment */
++*offsetp;
compile_error("[length_is()] is not supported");
compile_error("[transmit_as()] is not supported");
compile_error("[arg_is()] is not supported");
/*
* Disallow
* [case(x)] TYPE xxx;
* [default] TYPE xxx;
*
* These only make sense within unions.
*/
if (allow & ALLOW_CASE) {
int n = 0;
n++;
n++;
if (n == 0)
compile_error("no [case/default] advice");
else if (n > 1)
compile_error("too many [case/default] advice");
} else {
compile_error("[case/default] advice not allowed");
}
/*
* Disallow
* [operation(x)] TYPE foo;
* [interface(x)] TYPE foo;
* [uuid(x)] TYPE foo;
*
* The [operation()] advice may only appear on a struct to
* indicate that the structure is a top-most (parameter)
* structure, and the opcode associated with the parameters.
*/
compile_error("[operation()] advice not allowed");
compile_error("[interface()] advice not allowed");
compile_error("[uuid()] advice not allowed");
/*
* Allow
* [switch_is(x)] union foo xxx;
*
* Disallow [switch_is] on anything which is not a union.
*/
compile_error("[switch_is()] advice not allowed");
}
/*
* Allow
* [size_is(x)] TYPE * ptr;
* [size_is(x)] TYPE arr[];
*
* Disallow [size_is()] on anything other than pointer and
* variable length array.
*/
compile_error("[size_is()] advice not allowed");
}
/*
* Allow
* [string] char * ptr_string;
*
* Disallow [string] on anything else. The determination
* of size (for the outer header) on anything else is
* impossible.
*/
compile_error("[string] advice not allowed");
}
int n = 0;
/*
* Requires [size_is()] directive
* [size_is(x)] TYPE array[]
*/
n++;
if (!n)
compile_error("var-size missing sizing directive");
else if (n > 1)
compile_error("var-size too many sizing directives");
}
/*
* Nested unions and struct members, other than the last one,
* cannot contain variable sized members.
*/
compile_error("var-size member not allowed");
}
/*
* Disallow unions in operations (i.e. [operation()] struct ...),
* automatically synthesizes an encapsulated union for
* these situations, which we have to do by hand:
*
* struct { long switch_value; union foo x; } synth;
*
* We also can not allow unions within unions because
* there is no way to pass the separate [switch_is(x)] selector.
*/
if (allow & ALLOW_NO_UNIONS) {
compile_error("unencapsulated union not allowed");
!(allow & ALLOW_NO_SWITCH)) {
compile_error("union instance without selector");
}
}
}
static void
seed_basic_types(void)
{
continue;
continue;
}
}
static void
seed_construct_types(void)
{
unsigned n_member;
case TYPEDEF_KW:
case STRUCT_KW:
case UNION_KW:
n_member = 0;
n_member++;
if (n_member > 0)
sizeof (ndr_member_t));
break;
default:
break;
}
}
}
static void
{
;
}
static ndr_typeinfo_t *
{
continue;
case STAR:
continue;
break;
case STRING_KW:
continue;
break;
case LB:
continue;
continue;
break;
case BASIC_TYPE:
case STRUCT_KW:
case TYPEDEF_KW:
case UNION_KW:
continue;
break;
default:
break;
}
return (ti);
}
case STAR:
break;
case STRING_KW:
case LB:
if (tdti->size_variable_part) {
compile_error("array of var-size type");
} else {
}
} else {
compile_error("array of incomplete type");
}
break;
default:
break;
}
/*
* Disallow
* union foo *ptrfoo;
* There is no way to pass the selector (switch_is)in
*/
compile_error("pointers to unions not allowed");
}
/*
* Disallow
* union foo fooarr[n];
* Each element needs a distinct selector
*/
compile_error("arrays of unions not allowed");
}
return (ti);
}
static ndr_typeinfo_t *
{
return (ti);
}
/* fake BASIC_TYPE */
ti->size_fixed_part = 0;
return (ti);
}
static void
{
/* alias for basic types */
/* arg used for size, union, or generic purpose */
/* size stuff */
/* union stuff */
/* interface stuff */
}
static ndr_node_t *
{
break;
return (np);
}
void
{
break;
}
void
{
}