- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: building va_list variable in HP-UX Integrity
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 06:26 AM
03-11-2008 06:26 AM
building va_list varialbe in hpux itanium
I want to copy value in the va_list variable.
I use to do this in HP-UX PARISC as follows
va_list fun(void **vals, int numvals)
{
int x;
out=(void**)malloc(sizeof(void*)*(numvals+1));
for (x=0;x
out[numvals - 1 - x] = vals[x];
}
out[x] = (void *)numvals;
return (va_list)(out + numvals);
}
But typecasting of void** to va_list is not working in HP-UX itanium.
can you please help me to know how can i build a va_list variable with some arguments.
Thanks in advance
- Tags:
- va_list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 07:50 AM - edited 09-05-2011 11:30 PM
03-11-2008 07:50 AM - edited 09-05-2011 11:30 PM
Re: building va_list variable in HP-UX Integrity
What you are doing isn't portable. The only supported way to get a va_list is with va_start.
It does appear you know that the parms are in reverse order. But not that it is off by one.
Also, you need to allocate an array of long long, not void*. Unless you know they are all pointers??
As to your return, you need to use a type hammer to get this right. va_list is a thingy and you can't do much with it. See:
http://h30499.www3.hp.com/t5/Languages-and-Scripting/experiencing-different-behaviour-for-va-list-initialization-with/m-p/5094394
out += numvals + 1
return *(va_list*)&out;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2008 04:56 AM
03-14-2008 04:56 AM
Re: building va_list varialbe in hpux itanium
My problem is i want to send variable arguments to a function.
I have two interface
1) method(char *val, ...)
{
va_list arglist;
va_start(arglist, val);
method(val, arglist);
va_end(arglist);
}
2) method(char *val, va_list arglist)
{
//Process the arglist
}
When i know how many arguments i have to pass to function i use the first function method call
if i dont know the number of arguments to pass then i first create the va_list variable with all the arguments and then pass it to second function method.
i used above method fun to create the va_list variable in other platforms, but in hpux itanium this does not work. can any body tell me how to create va_list in hpux itanium so that i can pass those variables to second function.
Many thanks in advance...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2008 06:12 PM - edited 09-06-2011 12:18 AM
03-14-2008 06:12 PM - edited 09-06-2011 12:18 AM
Re: building va_list variable in HP-UX Integrity
>My problem is i want to send variable arguments to a function. I have two interface
>1) method(const char *val, ...)
> method(val, arglist);
This is Standard and portable.
>2) method(const char *val, va_list arglist)
Again Standard and portable, provided your va_list is ONLY created by method 1).
>i first create the va_list variable with all the arguments and then pass it to second function method.
This is not portable and so is non-supported and illegal. Only va_start can create a va_list.
Note: you didn't see this here but you might try something like this. :-)
It is PA32 with the reversed list. IPF and PA64 have args in increasing order.
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
// portable solution
void foo(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
}
// not portable at all!
void bar(const char *fmt, void **vals) {
int numvals, i;
for (numvals = 0; vals[numvals]; ++numvals) {}
long long *out = (long long*)malloc(sizeof(long long)*numvals);
for (i = 0; i < numvals; ++i) // widen to register size
out[i] = (long long)vals[i];
// use a type hammer
vprintf(fmt, *(va_list*)&out);
}
int main() {
foo("%s %s %s\n", "hi", "ho", "off we go");
const char *lists[] = { "hi", "ho", "off we go", NULL };
bar("%s %s %s\n", (void**)lists);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2008 04:07 PM - edited 09-05-2011 11:33 PM
03-16-2008 04:07 PM - edited 09-05-2011 11:33 PM
Re: building va_list variable in HP-UX Integrity
>for (i = 0; i < numvals; ++i) // reverse
Oops, this is the wrong comment. It really should be: // widen to register size
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2008 05:40 AM - edited 09-05-2011 11:32 PM
11-17-2008 05:40 AM - edited 09-05-2011 11:32 PM
Re: building va_list variable in HP-UX Integrity
If the replies answered your questions, you should read the following about assigning points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33