Add a -M flag, for generating thread-safe stubs, per RedHat.

Also clean up some KNF and ANSI C glitches in -Sc and -Ss output.
This commit is contained in:
mycroft 2001-03-21 00:30:39 +00:00
parent 08e4590096
commit b1bad8f693
8 changed files with 332 additions and 159 deletions

View File

@ -1,7 +1,8 @@
# $NetBSD: Makefile,v 1.7 1997/10/23 22:48:26 lukem Exp $
# $NetBSD: Makefile,v 1.8 2001/03/21 00:30:39 mycroft Exp $
PROG= rpcgen
SRCS= rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c rpc_parse.c rpc_scan.c \
rpc_svcout.c rpc_util.c rpc_sample.c rpc_tblout.c
CFLAGS= -g
.include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpc_clntout.c,v 1.8 1997/10/18 10:53:37 lukem Exp $ */
/* $NetBSD: rpc_clntout.c,v 1.9 2001/03/21 00:30:39 mycroft Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)rpc_clntout.c 1.11 89/02/22 (C) 1987 SMI";
#else
__RCSID("$NetBSD: rpc_clntout.c,v 1.8 1997/10/18 10:53:37 lukem Exp $");
__RCSID("$NetBSD: rpc_clntout.c,v 1.9 2001/03/21 00:30:39 mycroft Exp $");
#endif
#endif
@ -51,6 +51,7 @@ __RCSID("$NetBSD: rpc_clntout.c,v 1.8 1997/10/18 10:53:37 lukem Exp $");
static void write_program __P((definition *));
static char *ampr __P((char *));
static char *aster __P((char *));
static void printbody __P((proc_list *));
#define DEFAULT_TIMEOUT 25 /* in seconds */
@ -85,10 +86,14 @@ write_program(def)
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
for (proc = vp->procs; proc != NULL; proc = proc->next) {
f_print(fout, "\n");
if (Mflag)
f_print(fout, "enum clnt_stat\n");
else {
ptype(proc->res_prefix, proc->res_type, 1);
f_print(fout, "*\n");
}
pvname(proc->proc_name, vp->vers_num);
printarglist(proc, "clnt", "CLIENT *");
printarglist(proc, RESULT, "clnt", "CLIENT *");
f_print(fout, "{\n");
printbody(proc);
f_print(fout, "}\n");
@ -103,9 +108,9 @@ write_program(def)
/* sample addargname = "clnt"; sample addargtype = "CLIENT * " */
void
printarglist(proc, addargname, addargtype)
printarglist(proc, result, addargname, addargtype)
proc_list *proc;
char *addargname, *addargtype;
char *result, *addargname, *addargtype;
{
decl_list *l;
@ -115,12 +120,33 @@ printarglist(proc, addargname, addargtype)
if (Cflag) { /* C++ style heading */
f_print(fout, "(");
ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
f_print(fout, "*argp, %s%s)\n", addargtype, addargname);
f_print(fout, "*argp, ");
if (Mflag) {
if (streq(proc->res_type, "void"))
f_print(fout, "char ");
else
ptype(proc->res_prefix, proc->res_type, 0);
f_print(fout, "%s%s, ", aster(proc->res_type),
result);
}
f_print(fout, "%s%s)\n", addargtype, addargname);
} else {
f_print(fout, "(argp, %s)\n", addargname);
f_print(fout, "(argp, ");
if (Mflag)
f_print(fout, "%s, ", result);
f_print(fout, "%s)\n", addargname);
f_print(fout, "\t");
ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
f_print(fout, "*argp;\n");
if (Mflag) {
f_print(fout, "\t");
if (streq(proc->res_type, "void"))
f_print(fout, "char ");
else
ptype(proc->res_prefix, proc->res_type, 0);
f_print(fout, "%s%s;\n", aster(proc->res_type),
result);
}
}
} else
if (streq(proc->args.decls->decl.type, "void")) {
@ -153,7 +179,6 @@ printarglist(proc, addargname, addargtype)
}
static char *
ampr(type)
char *type;
@ -165,6 +190,17 @@ ampr(type)
}
}
static char *
aster(type)
char *type;
{
if (isvectordef(type, REL_ALIAS)) {
return ("");
} else {
return ("*");
}
}
static void
printbody(proc)
proc_list *proc;
@ -178,25 +214,34 @@ printbody(proc)
f_print(fout, "\t%s", proc->args.argname);
f_print(fout, " arg;\n");
}
if (!Mflag) {
f_print(fout, "\tstatic ");
if (streq(proc->res_type, "void")) {
if (streq(proc->res_type, "void"))
f_print(fout, "char ");
} else {
else
ptype(proc->res_prefix, proc->res_type, 0);
}
f_print(fout, "%s;\n", RESULT);
}
f_print(fout, "\n");
if (!Mflag)
f_print(fout, "\tmemset((char *)%s%s, 0, sizeof(%s));\n",
ampr(proc->res_type), RESULT, RESULT);
if (newstyle && !args2 && (streq(proc->args.decls->decl.type, "void"))) {
/* newstyle, 0 arguments */
if (Mflag) {
f_print(fout, "\treturn (clnt_call(clnt, %s, xdr_void",
proc->proc_name);
f_print(fout, ", NULL, xdr_%s, %s, TIMEOUT));\n",
stringfix(proc->res_type), RESULT);
} else {
f_print(fout, "\tif (clnt_call(clnt, %s, xdr_void, ",
proc->proc_name);
f_print(fout,
"\tif (clnt_call(clnt, %s, xdr_void", proc->proc_name);
f_print(fout,
", NULL, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
stringfix(proc->res_type), ampr(proc->res_type), RESULT);
} else
"NULL, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
stringfix(proc->res_type), ampr(proc->res_type),
RESULT);
}
} else {
if (newstyle && args2) {
/* newstyle, multiple arguments: stuff arguments into
* structure */
@ -204,13 +249,28 @@ printbody(proc)
f_print(fout, "\targ.%s = %s;\n",
l->decl.name, l->decl.name);
}
if (Mflag) {
f_print(fout,
"\treturn (clnt_call(clnt, %s, xdr_%s, &arg, xdr_%s, %s, TIMEOUT));\n",
proc->proc_name, proc->args.argname,
stringfix(proc->res_type), RESULT);
} else {
f_print(fout,
"\tif (clnt_call(clnt, %s, xdr_%s, &arg, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS)\n",
proc->proc_name,
proc->args.argname,
proc->proc_name, proc->args.argname,
stringfix(proc->res_type),
ampr(proc->res_type), RESULT);
}
} else { /* single argument, new or old style */
if (Mflag) {
f_print(fout,
"\treturn (clnt_call(clnt, %s, xdr_%s, %s%s, xdr_%s, %s, TIMEOUT));\n",
proc->proc_name,
stringfix(proc->args.decls->decl.type),
(newstyle ? "&" : ""),
(newstyle ? proc->args.decls->decl.name : "argp"),
stringfix(proc->res_type), RESULT);
} else {
f_print(fout,
"\tif (clnt_call(clnt, %s, xdr_%s, %s%s, xdr_%s, %s%s, TIMEOUT) != RPC_SUCCESS)\n",
proc->proc_name,
@ -220,11 +280,15 @@ printbody(proc)
stringfix(proc->res_type),
ampr(proc->res_type), RESULT);
}
}
}
if (!Mflag) {
f_print(fout, "\t\treturn (NULL);\n");
if (streq(proc->res_type, "void")) {
if (streq(proc->res_type, "void"))
f_print(fout, "\treturn ((void *)%s%s);\n",
ampr(proc->res_type), RESULT);
} else {
f_print(fout, "\treturn (%s%s);\n", ampr(proc->res_type), RESULT);
else
f_print(fout, "\treturn (%s%s);\n",
ampr(proc->res_type), RESULT);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpc_hout.c,v 1.14 2000/10/11 14:46:17 is Exp $ */
/* $NetBSD: rpc_hout.c,v 1.15 2001/03/21 00:30:39 mycroft Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI";
#else
__RCSID("$NetBSD: rpc_hout.c,v 1.14 2000/10/11 14:46:17 is Exp $");
__RCSID("$NetBSD: rpc_hout.c,v 1.15 2001/03/21 00:30:39 mycroft Exp $");
#endif
#endif
@ -56,7 +56,6 @@ static void pdefine __P((char *, char *));
static void puldefine __P((char *, char *));
static int define_printed __P((proc_list *, version_list *));
static void pprogramdef __P((definition *));
static void parglist __P((proc_list *, char *));
static void penumdef __P((definition *));
static void ptypedef __P((definition *));
static int undefined2 __P((char *, char *));
@ -329,9 +328,17 @@ pprocdef(proc, vp, addargtype, server_p, mode)
int server_p;
int mode;
{
decl_list *dl;
if (Mflag) {
if (server_p)
f_print(fout, "bool_t ");
else
f_print(fout, "enum clnt_stat ");
} else {
ptype(proc->res_prefix, proc->res_type, 1);
f_print(fout, "*");
}
if (server_p)
pvname_svc(proc->proc_name, vp->vers_num);
else
@ -340,23 +347,8 @@ pprocdef(proc, vp, addargtype, server_p, mode)
/*
* mode 0 == cplusplus, mode 1 = ANSI-C, mode 2 = old style C
*/
if (mode == 0 || mode == 1)
parglist(proc, addargtype);
else
f_print(fout, "();\n");
}
/* print out argument list of procedure */
static void
parglist(proc, addargtype)
proc_list *proc;
char *addargtype;
{
decl_list *dl;
if (mode == 0 || mode == 1) {
f_print(fout, "(");
if (proc->arg_num < 2 && newstyle &&
streq(proc->args.decls->decl.type, "void")) {
/* 0 argument in new style: do nothing */
@ -364,15 +356,25 @@ parglist(proc, addargtype)
for (dl = proc->args.decls; dl != NULL; dl = dl->next) {
ptype(dl->decl.prefix, dl->decl.type, 1);
if (!newstyle)
f_print(fout, "*"); /* old style passes by
* reference */
f_print(fout, "*");
f_print(fout, ", ");
}
}
if (Mflag) {
if (streq(proc->res_type, "void"))
f_print(fout, "char");
else
ptype(proc->res_prefix, proc->res_type, 0);
if (!isvectordef(proc->res_type, REL_ALIAS))
f_print(fout, "*");
f_print(fout, ", ");
}
f_print(fout, "%s);\n", addargtype);
}
else
f_print(fout, "();\n");
}
static void
penumdef(def)

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpc_main.c,v 1.18 2001/02/21 00:11:12 cgd Exp $ */
/* $NetBSD: rpc_main.c,v 1.19 2001/03/21 00:30:39 mycroft Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -35,7 +35,7 @@
#if 0
static char sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI";
#else
__RCSID("$NetBSD: rpc_main.c,v 1.18 2001/02/21 00:11:12 cgd Exp $");
__RCSID("$NetBSD: rpc_main.c,v 1.19 2001/03/21 00:30:39 mycroft Exp $");
#endif
#endif
@ -129,6 +129,7 @@ int exitnow; /* If started by port monitors, exit after the
int timerflag; /* TRUE if !indefinite && !exitnow */
int newstyle; /* newstyle of passing arguments (by value) */
int Cflag = 0; /* ANSI C syntax */
int Mflag = 0; /* multithread safe */
static int allfiles; /* generate all files */
int tirpcflag = 1; /* generating code for tirpc, by default */
@ -1005,6 +1006,9 @@ parseargs(argc, argv, cmd)
case 'I':
inetdflag = 1;
break;
case 'M':
Mflag = 1;
break;
case 'N':
newstyle = 1;
break;
@ -1128,9 +1132,9 @@ static void
usage()
{
f_print(stderr, "usage: %s infile\n", cmdname);
f_print(stderr, "\t%s [-a][-b][-C][-Dname[=value]] -i size [-I [-K seconds]] [-A][-L][-M toolkit][-N][-T] infile\n",
f_print(stderr, "\t%s [-a][-b][-C][-Dname[=value]] -i size [-I [-K seconds]] [-A] [-M] [-N] [-T] infile\n",
cmdname);
f_print(stderr, "\t%s [-c | -h | -l | -m | -t | -Sc | -Ss] [-o outfile] [infile]\n",
f_print(stderr, "\t%s [-L] [-M] [-c | -h | -l | -m | -t | -Sc | -Ss] [-o outfile] [infile]\n",
cmdname);
f_print(stderr, "\t%s [-s nettype]* [-o outfile] [infile]\n", cmdname);
f_print(stderr, "\t%s [-n netid]* [-o outfile] [infile]\n", cmdname);
@ -1155,6 +1159,7 @@ options_usage()
f_print(stderr, "-l\t\tgenerate client side stubs\n");
f_print(stderr, "-L\t\tserver errors will be printed to syslog\n");
f_print(stderr, "-m\t\tgenerate server side stubs\n");
f_print(stderr, "-M\t\tgenerate thread-safe stubs\n");
f_print(stderr, "-n netid\tgenerate server code that supports named netid\n");
f_print(stderr, "-N\t\tsupports multiple arguments and call-by-value\n");
f_print(stderr, "-o outfile\tname of the output file\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpc_sample.c,v 1.5 1997/10/18 10:54:01 lukem Exp $ */
/* $NetBSD: rpc_sample.c,v 1.6 2001/03/21 00:30:39 mycroft Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)rpc_sample.c 1.1 90/08/30 (C) 1987 SMI";
#else
__RCSID("$NetBSD: rpc_sample.c,v 1.5 1997/10/18 10:54:01 lukem Exp $");
__RCSID("$NetBSD: rpc_sample.c,v 1.6 2001/03/21 00:30:39 mycroft Exp $");
#endif
#endif
@ -97,26 +97,22 @@ write_sample_client(program_name, vp)
if (Cflag)
f_print(fout, "(char *host)\n{\n");
else
f_print(fout, "(host)\nchar *host;\n{\n");
f_print(fout, "(host)\n\tchar *host;\n{\n");
f_print(fout, "\tCLIENT *clnt;\n");
i = 0;
for (proc = vp->procs; proc != NULL; proc = proc->next) {
f_print(fout, "\t");
ptype(proc->res_prefix, proc->res_type, 1);
f_print(fout, " *result_%d;\n", ++i);
/* print out declarations for arguments */
if (proc->arg_num < 2 && !newstyle) {
f_print(fout, "\t");
if (!streq(proc->args.decls->decl.type, "void"))
ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
else
f_print(fout, "char* "); /* cannot have "void"
if (streq(proc->args.decls->decl.type, "void"))
f_print(fout, "char"); /* cannot have "void"
* type */
f_print(fout, " ");
else
ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
pvname(proc->proc_name, vp->vers_num);
f_print(fout, "_arg;\n");
} else
} else {
if (!streq(proc->args.decls->decl.type, "void")) {
for (l = proc->args.decls; l != NULL; l = l->next) {
f_print(fout, "\t");
@ -128,6 +124,19 @@ write_sample_client(program_name, vp)
}
}
}
/* print out declarations for results */
f_print(fout, "\t");
if (streq(proc->res_type, "void"))
f_print(fout, "char"); /* cannot have "void"
* type */
else
ptype(proc->res_prefix, proc->res_type, 1);
if (!Mflag)
f_print(fout, "*");
pvname(proc->proc_name, vp->vers_num);
f_print(fout, "_res;\n");
}
f_print(fout, "\n");
/* generate creation of client handle */
f_print(fout, "\tclnt = clnt_create(host, %s, %s, \"%s\");\n",
@ -137,9 +146,14 @@ write_sample_client(program_name, vp)
f_print(fout, "\t\texit(1);\n\t}\n");
/* generate calls to procedures */
i = 0;
for (proc = vp->procs; proc != NULL; proc = proc->next) {
f_print(fout, "\tresult_%d = ", ++i);
if (Mflag)
f_print(fout, "\tif (");
else {
f_print(fout, "\t");
pvname(proc->proc_name, vp->vers_num);
f_print(fout, "_res = ");
}
pvname(proc->proc_name, vp->vers_num);
if (proc->arg_num < 2 && !newstyle) {
f_print(fout, "(");
@ -147,8 +161,8 @@ write_sample_client(program_name, vp)
f_print(fout, "(void *)");
f_print(fout, "&");
pvname(proc->proc_name, vp->vers_num);
f_print(fout, "_arg, clnt);\n");
} else
f_print(fout, "_arg, ");
} else {
if (streq(proc->args.decls->decl.type, "void")) {
f_print(fout, "(clnt);\n");
} else {
@ -157,11 +171,19 @@ write_sample_client(program_name, vp)
pvname(proc->proc_name, vp->vers_num);
f_print(fout, "_%s, ", l->decl.name);
}
f_print(fout, "clnt);\n");
}
f_print(fout, "\tif (result_%d == NULL) {\n", i);
}
if (Mflag) {
f_print(fout, "&");
pvname(proc->proc_name, vp->vers_num);
f_print(fout, "_res, clnt) != RPC_SUCCESS)\n");
} else {
f_print(fout, "clnt);\n");
f_print(fout, "\tif (");
pvname(proc->proc_name, vp->vers_num);
f_print(fout, "_res == NULL)\n", i);
}
f_print(fout, "\t\tclnt_perror(clnt, \"call failed:\");\n");
f_print(fout, "\t}\n");
}
f_print(fout, "\tclnt_destroy(clnt);\n");
@ -178,34 +200,40 @@ write_sample_server(def)
for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
for (proc = vp->procs; proc != NULL; proc = proc->next) {
f_print(fout, "\n");
/* if( Cflag )
f_print( fout, "extern \"C\"{\n");
*/
if (Mflag)
f_print(fout, "bool_t\n");
else {
return_type(proc);
f_print(fout, "*\n");
}
if (Cflag)
pvname_svc(proc->proc_name, vp->vers_num);
else
pvname(proc->proc_name, vp->vers_num);
printarglist(proc, RQSTP, "struct svc_req *");
printarglist(proc, "result", RQSTP, "struct svc_req *");
f_print(fout, "{\n");
f_print(fout, "\n\tstatic ");
if (!streq(proc->res_type, "void"))
return_type(proc);
if (Mflag) {
f_print(fout, "\tbool_t retval;\n");
} else {
f_print(fout, "\tstatic ");
if (streq(proc->res_type, "void"))
f_print(fout, "char"); /* cannot have void type */
else
f_print(fout, "char*"); /* cannot have void type */
return_type(proc);
f_print(fout, " result;\n");
}
f_print(fout,
"\n\t/*\n\t * insert server code here\n\t */\n\n");
if (!streq(proc->res_type, "void"))
f_print(fout, "\treturn(&result);\n}\n");
else /* cast back to void * */
f_print(fout, "\treturn((void*) &result);\n}\n");
/* if( Cflag)
f_print( fout, "};\n");
*/
if (Mflag) {
f_print(fout, "\treturn (retval);\n");
} else {
if (streq(proc->res_type, "void"))
f_print(fout, "\treturn ((void *)&result);\n");
else
f_print(fout, "\treturn (&result);\n");
}
f_print(fout, "}\n");
}
}
}
@ -236,9 +264,9 @@ write_sample_clnt_main()
f_print(fout, "\n\n");
if (Cflag)
f_print(fout, "main( int argc, char* argv[] )\n{\n");
f_print(fout, "int\nmain(int argc, char *argv[])\n{\n");
else
f_print(fout, "main(argc, argv)\nint argc;\nchar *argv[];\n{\n");
f_print(fout, "int\nmain(argc, argv)\n\tint argc;\n\tchar *argv[];\n{\n");
f_print(fout, "\tchar *host;");
f_print(fout, "\n\n\tif (argc < 2) {");
@ -257,5 +285,6 @@ write_sample_clnt_main()
f_print(fout, "(host);\n");
}
}
f_print(fout, "\texit(0);\n");
f_print(fout, "}\n");
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpc_svcout.c,v 1.11 2000/10/11 14:46:17 is Exp $ */
/* $NetBSD: rpc_svcout.c,v 1.12 2001/03/21 00:30:39 mycroft Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)rpc_svcout.c 1.29 89/03/30 (C) 1987 SMI";
#else
__RCSID("$NetBSD: rpc_svcout.c,v 1.11 2000/10/11 14:46:17 is Exp $");
__RCSID("$NetBSD: rpc_svcout.c,v 1.12 2001/03/21 00:30:39 mycroft Exp $");
#endif
#endif
@ -420,15 +420,38 @@ write_program(def, storage)
f_print(fout, "\t\tint fill;\n");
}
f_print(fout, "\t} %s;\n", ARG);
if (Mflag) {
f_print(fout, "\tunion {\n");
for (proc = vp->procs; proc != NULL; proc = proc->next) {
f_print(fout, "\t\t");
if (streq(proc->res_type, "void"))
f_print(fout, "char ");
else
ptype(proc->res_prefix, proc->res_type,
1);
pvname(proc->proc_name, vp->vers_num);
f_print(fout, "_res;\n");
}
f_print(fout, "\t} %s;\n", RESULT);
f_print(fout, "\tbool_t retval;\n");
} else
f_print(fout, "\tchar *%s;\n", RESULT);
if (Cflag) {
f_print(fout, "\txdrproc_t xdr_%s, xdr_%s;\n", ARG, RESULT);
if (Mflag)
f_print(fout,
"\tbool_t (*%s)(char *, void *, struct svc_req *);\n",
ROUTINE);
else
f_print(fout,
"\tchar *(*%s)(char *, struct svc_req *);\n",
ROUTINE);
} else {
f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT);
if (Mflag)
f_print(fout, "\tbool_t (*%s)();\n", ROUTINE);
else
f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
}
@ -460,12 +483,21 @@ write_program(def, storage)
p_xdrfunc(ARG, proc->args.argname);
}
p_xdrfunc(RESULT, proc->res_type);
if (Cflag)
if (Cflag) {
if (Mflag)
f_print(fout,
"\t\t%s = (bool_t (*)(char *, void *, struct svc_req *))",
ROUTINE);
else
f_print(fout,
"\t\t%s = (char *(*)(char *, struct svc_req *))",
ROUTINE);
} else {
if (Mflag)
f_print(fout, "\t\t%s = (bool_t (*)())", ROUTINE);
else
f_print(fout, "\t\t%s = (char *(*)())", ROUTINE);
}
if (newstyle) { /* new style: calls internal routine */
f_print(fout, "_");
@ -488,12 +520,26 @@ write_program(def, storage)
print_return("\t\t");
f_print(fout, "\t}\n");
if (Cflag)
if (Cflag) {
if (Mflag)
f_print(fout, "\tretval = (*%s)((char *)&%s, (void *)&%s, %s);\n",
ROUTINE, ARG, RESULT, RQSTP);
else
f_print(fout, "\t%s = (*%s)((char *)&%s, %s);\n",
RESULT, ROUTINE, ARG, RQSTP);
} else {
if (Mflag)
f_print(fout, "\tretval = (*%s)(&%s, &%s, %s);\n",
ROUTINE, ARG, RESULT, RQSTP);
else
f_print(fout, "\t%s = (*%s)(&%s, %s);\n",
RESULT, ROUTINE, ARG, RQSTP);
}
if (Mflag)
f_print(fout,
"\tif (retval > 0 && !svc_sendreply(%s, xdr_%s, (char *)&%s)) {\n",
TRANSP, RESULT, RESULT);
else
f_print(fout,
"\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n",
RESULT, TRANSP, RESULT, RESULT);
@ -505,6 +551,17 @@ write_program(def, storage)
print_err_message("\t\t");
f_print(fout, "\t\texit(1);\n");
f_print(fout, "\t}\n");
f_print(fout, "\tif (!");
pvname(def->def_name, vp->vers_num);
f_print(fout, "_freeresult");
f_print(fout, "(%s, xdr_%s, (caddr_t)&%s)) {\n", TRANSP, RESULT,
RESULT);
(void) sprintf(_errbuf, "unable to free results");
print_err_message("\t\t");
f_print(fout, "\t\texit(1);\n");
f_print(fout, "\t}\n");
print_return("\t");
f_print(fout, "}\n");
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpc_util.h,v 1.4 1997/10/11 21:01:58 christos Exp $ */
/* $NetBSD: rpc_util.h,v 1.5 2001/03/21 00:30:39 mycroft Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@ -77,6 +77,7 @@ extern int tblflag;
extern int logflag;
extern int newstyle;
extern int Cflag; /* C++ flag */
extern int Mflag; /* multithread flag */
extern int tirpcflag; /* flag for generating tirpc code */
extern int doinline; /* if this is 0, then do not generate inline code */
extern int callerflag;
@ -157,7 +158,7 @@ void write_inetd_register __P((char *));
* rpc_clntout routines
*/
void write_stubs __P((void));
void printarglist __P((proc_list *, char *, char *));
void printarglist __P((proc_list *, char *, char *, char *));
/*

View File

@ -1,4 +1,4 @@
.\" $NetBSD: rpcgen.1,v 1.8 1998/04/28 07:19:29 fair Exp $
.\" $NetBSD: rpcgen.1,v 1.9 2001/03/21 00:30:39 mycroft Exp $
.\" from: @(#)rpcgen.new.1 1.1 90/11/09 TIRPC 1.0; from 40.10 of 10/10/89
.\" Copyright (c) 1988,1990 Sun Microsystems, Inc. - All Rights Reserved.
.Dd June 11, 1995
@ -18,13 +18,14 @@
.Ar infile
.Nm ""
.Op Fl L
.Op Fl M
.Fl c Li |
.Fl h Li |
.Fl l Li |
.Fl m Li |
.Fl t Li |
.Fl S\&c Li |
.Fl S\&s Li |
.Fl S\&s
.Op Fl o Ar outfile
.Op Ar infile
.Nm ""
@ -296,6 +297,13 @@ This option is useful for doing callback-routines
and for users who need to write their own
.Fn main
routine to do initialization.
.It Fl M
Generate thread-safe stubs. This alters the calling pattern of client and
server stubs so that storage for results is allocated by the caller. Note
that all components for a particular service (stubs, client and service
wrappers, etc.) must be built either with or without the
.Fl M
flag.
.It Fl n Ar netid
Compile into server-side stubs for the transport
specified by
@ -448,5 +456,11 @@ use:
.Bd -literal -offset indent
$ rpcgen -n tcp -o prot_svc.c prot.x
.Ed
.Sh HISTORY
The
.Fl M
option was first implemented in RedHat Linux, and was reimplemented by
Charles M. Hannum in
.Nx 1.6 .
.Sh SEE ALSO
.Xr cpp 1