Clean up warnings for round() function declaration.
[iverilog.git] / libveriuser / getlongp.c
blobdb6c764a5c4a946b02107f11fa310d720108bc67
1 /* vi:sw=6
2 * Copyright (c) 2002 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: getlongp.c,v 1.3 2003/03/15 05:42:39 steve Exp $"
21 #endif
23 #include <stdlib.h>
24 #include <string.h>
25 #include <assert.h>
26 #include <veriuser.h>
27 #include <vpi_user.h>
30 * tf_getlongp implemented using VPI interface
32 int tf_getlongp(int *highvalue, int n)
34 vpiHandle sys_h, sys_i, arg_h = 0;
35 s_vpi_value value;
36 int len, rtn;
37 char *str, **end = 0;
39 assert(highvalue);
40 assert(n > 0);
42 /* get task/func handle */
43 sys_h = vpi_handle(vpiSysTfCall, 0);
44 sys_i = vpi_iterate(vpiArgument, sys_h);
46 /* find nth arg */
47 while (n > 0) {
48 if (!(arg_h = vpi_scan(sys_i))) assert(0);
49 n--;
52 /* get the value */
53 value.format = vpiHexStrVal;
54 vpi_get_value(arg_h, &value);
56 /* convert string to int(s) */
57 len = strlen(value.value.str);
58 if (len > 8) {
59 /* low word */
60 str = value.value.str + (len - 8);
61 rtn = (int) strtoul(str, end, 16);
62 /* high word */
63 *str = '\0';
64 *highvalue = (int) strtoul(value.value.str, end, 16);
65 } else {
66 *highvalue = 0;
67 rtn = (int) strtoul(value.value.str, end, 16);
70 vpi_free_object(sys_i);
72 return rtn;
76 * $Log: getlongp.c,v $
77 * Revision 1.3 2003/03/15 05:42:39 steve
78 * free argument iterators.
80 * Revision 1.2 2002/08/12 01:35:02 steve
81 * conditional ident string using autoconfig.
83 * Revision 1.1 2002/06/07 02:58:59 steve
84 * Add a bunch of acc/tf functions. (mruff)