Clean up warnings for round() function declaration.
[iverilog.git] / libveriuser / putp.c
blob9752356c61d23607e97347c52e12c003dcace039
1 /* vi:sw=6
2 * Copyright (c) 2002,2003 Michael Ruff (mruff at chiaro.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 #ifdef HAVE_CVS_IDENT
20 #ident "$Id: putp.c,v 1.7 2004/09/10 23:13:05 steve Exp $"
21 #endif
23 # include <assert.h>
24 # include <veriuser.h>
25 # include <vpi_user.h>
26 # include "priv.h"
29 * tf_putp and friends implemented using VPI interface
31 PLI_INT32 tf_iputp(PLI_INT32 n, PLI_INT32 value, void *obj)
33 vpiHandle sys_h, sys_i, arg_h = 0;
34 s_vpi_value val;
35 int rtn = 0, type;
37 assert(n >= 0);
39 /* get task/func handle */
40 sys_h = (vpiHandle)obj;
41 type = vpi_get(vpiType, sys_h);
43 /* Special case, we are putting the return value. */
44 if ((type == vpiSysFuncCall) && (n == 0)) {
45 val.format = vpiIntVal;
46 val.value.integer = value;
47 vpi_put_value(sys_h, &val, 0, vpiNoDelay);
49 if (pli_trace) {
50 fprintf(pli_trace, "tf_iputp(<return>, value=%d, func=%s) "
51 "--> %d\n", value, vpi_get_str(vpiName, obj), 0);
54 return 0;
57 if ((n == 0) && (type != vpiSysFuncCall)) {
58 if (pli_trace) {
59 fprintf(pli_trace, "tf_iputp(<ERROR>, value=%d, func=%s) "
60 "--> %d\n", value, vpi_get_str(vpiName, obj), 1);
63 return 1;
66 sys_i = vpi_iterate(vpiArgument, sys_h);
68 /* find nth arg */
69 while (n > 0) {
70 if (!(arg_h = vpi_scan(sys_i))) { rtn = 1; goto out; }
71 n--;
74 /* fill in vpi_value */
75 val.format = vpiIntVal;
76 val.value.integer = value;
77 vpi_put_value(arg_h, &val, 0, vpiNoDelay);
79 if (arg_h)
80 vpi_free_object(sys_i);
82 out:
83 if (pli_trace) {
84 fprintf(pli_trace, "tf_iputp(n=%d, value=%d, obj=%p) --> %d\n",
85 n, value, obj, rtn);
88 return rtn;
91 PLI_INT32 tf_putp(PLI_INT32 n, PLI_INT32 value)
93 int rtn = tf_iputp(n, value, vpi_handle(vpiSysTfCall, 0));
95 return rtn;
99 PLI_INT32 tf_iputrealp(PLI_INT32 n, double value, void *obj)
101 vpiHandle sys_h, sys_i, arg_h = 0;
102 s_vpi_value val;
103 int rtn = 0, type;
105 assert(n >= 0);
107 /* get task/func handle */
108 sys_h = (vpiHandle)obj;
109 sys_i = vpi_iterate(vpiArgument, sys_h);
111 type = vpi_get(vpiType, sys_h);
113 /* verify function */
114 if (n == 0 && type != vpiSysFuncCall) { rtn = 1; goto free; }
116 /* find nth arg */
117 while (n > 0) {
118 if (!(arg_h = vpi_scan(sys_i))) { rtn = 1; goto out; }
119 n--;
121 if (!arg_h) arg_h = sys_h;
123 /* fill in vpi_value */
124 val.format = vpiRealVal;
125 val.value.real = value;
126 vpi_put_value(arg_h, &val, 0, vpiNoDelay);
128 free:
129 vpi_free_object(sys_i);
131 out:
132 if (pli_trace) {
133 fprintf(pli_trace, "tf_iputrealp(n=%d, value=%f, obj=%p) --> %d\n",
134 n, value, obj, rtn);
137 return rtn;
140 PLI_INT32 tf_putrealp(PLI_INT32 n, double value)
142 int rtn = tf_iputrealp(n, value, vpi_handle(vpiSysTfCall, 0));
144 return rtn;
147 * $Log: putp.c,v $
148 * Revision 1.7 2004/09/10 23:13:05 steve
149 * Compile cleanup of C code.
151 * Revision 1.6 2003/06/26 03:20:24 steve
152 * Correct handle of put to function return value.
154 * Revision 1.5 2003/06/17 16:55:08 steve
155 * 1) setlinebuf() for vpi_trace
156 * 2) Addes error checks for trace file opens
157 * 3) removes now extraneous flushes
158 * 4) fixes acc_next() bug
160 * Revision 1.4 2003/05/29 03:46:21 steve
161 * Add tf_getp/putp support for integers
162 * and real valued arguments.
164 * Add tf_mipname function.
166 * Revision 1.3 2003/03/15 05:42:39 steve
167 * free argument iterators.
169 * Revision 1.2 2002/08/12 01:35:02 steve
170 * conditional ident string using autoconfig.
172 * Revision 1.1 2002/06/07 16:21:13 steve
173 * Add tf_putlongp and tf_putp.