|
| error when converting uint64_t to char |
 |
Mon, 25 Jun 2007 09:40:58 GMT |
I got a retrun structure cpu_info by function netware_cpu_info
(cpu_info,int), at first I use spintf to convert elment "SerialNumber"
to
char, but it's always zero, then I use function ulltoa/ultoa(uint64_t,char
*,int) to do it, but it return an error "segmetation fault", and I
also
want to convert element "ThreadCPUTime" to format
"D:H:M:Sec", can anybody
give me some help? Thank you very much.
Here's my sample code:
void print_value( unsigned long int value )
{
int base;
char buffer[33];
for( base = 2; base <= 16; base = base + 2 )
printf( "%2d %s\n", base, ulltoa( value, buffer, base ) );
}
int main( int argc)
{
char buffer[100];
int nextCpu = 0;
memset(buffer, 0x00, sizeof(buffer));
memset( (char *)&StruCPUInfo, 0x00, sizeof( StruCPUInfo ) );
while( !netware_cpu_info(&StruCPUInfo, &nextCpu))
{
printf( "%d\n", StruCPUInfo.SerialNumber );
ulltoa(StruCPUInfo.SerialNumber,buffer,0);
print_value((uint64_t)StruCPUInfo.SerialNumber);
}
printf( "Test 003 END\n");
return EXIT_SUCCESS;
|
| Post Reply
|
| Re: error when converting uint64_t to char |
 |
Tue, 26 Jun 2007 02:06:04 GMT |
Hi,
yushuang@cn.ibm.com wrote in news:K4Mfi.1301$Rg7.588@prv-
forum2.provo.novell.com:
> I got a retrun structure cpu_info by function netware_cpu_info
> (cpu_info,int), at first I use spintf to convert elment
"SerialNumber" to
> char, but it's always zero, then I use function ulltoa/ultoa(uint64_t,char
> *,int) to do it, but it return an error "segmetation fault", and
I also
> want to convert element "ThreadCPUTime" to format
"D:H:M:Sec", can anybody
> give me some help? Thank you very much.
The serialnumber is in most cases disabled in the BIOS, so I guess that's
your prob; here's an older sample from me which you can check with; it uses
ASM inline and I get same back as with the NetWare function:
http://www.gknw.net/development/samples/nlmconv/cpuid.zip
also here's another sample which uses the NetWare function:
http://www.gknw.net/development/samples/nlmconv/nwinfo.zip
it also uses netware_net_info() - so unless you have an updated LibC you need
to recompile without WITH_NETINFO defined....
Jeff has already fixed the abend condition you reported, and I guess he will
soon tell us when the updated LibC will be available...
Günter.
|
| Post Reply
|
| Re: error when converting uint64_t to char |
 |
Tue, 26 Jun 2007 07:21:36 GMT |
> yushuang@cn.ibm.com wrote in news:K4Mfi.1301$Rg7.588@prv-
> forum2.provo.novell.com:
>
> > I got a retrun structure cpu_info by function netware_cpu_info
> > (cpu_info,int), at first I use spintf to convert elment
"SerialNumber" to
> > char, but it's always zero, then I use function
ulltoa/ultoa(uint64_t,char
> > *,int) to do it, but it return an error "segmetation fault",
and I also
> > want to convert element "ThreadCPUTime" to format
"D:H:M:Sec", can anybody
> > give me some help? Thank you very much.
> The serialnumber is in most cases disabled in the BIOS, so I guess that's
> your prob; here's an older sample from me which you can check with; it uses
> ASM inline and I get same back as with the NetWare function:
> http://www.gknw.net/development/samples/nlmconv/cpuid.zip
> also here's another sample which uses the NetWare function:
> http://www.gknw.net/development/samples/nlmconv/nwinfo.zip
> it also uses netware_net_info() - so unless you have an updated LibC you
need
> to recompile without WITH_NETINFO defined....
> Jeff has already fixed the abend condition you reported, and I guess he
will
> soon tell us when the updated LibC will be available...
>
> Günter.
>
Thank you, Günter.
I notice you also use printf("%llu\n") to print serialnumber, so do I,
and
I always got result "0", but on the web page of Netware Remote
Manager->Diagnose Server->Report/Log Files->Config Report, the Serial
number is "F59DBD29", I think it should be my real serialnumber. is it
the
|
| Post Reply
|
| Re: error when converting uint64_t to char |
 |
Tue, 26 Jun 2007 09:42:16 GMT |
Hi,
yushuang@cn.ibm.com wrote in
news:483gi.1941$Rg7.137@prv-forum2.provo.novell.com:
> Thank you, Günter.
> I notice you also use printf("%llu\n") to print serialnumber, so
do I,
> and I always got result "0", but on the web page of Netware
Remote
> Manager->Diagnose Server->Report/Log Files->Config Report, the
Serial
> number is "F59DBD29", I think it should be my real serialnumber.
is it
> the libc's issue?
I doubt that this is the real serialnumber of the processor, but even if it
is - this report is generated with config.nlm, and this NLM can contain ASM
code which enables the serial, fetches it, and afterwards disables it again;
but IIRC config.nlm reported such a serialnumber even with older P1 and AMD
processors which didnt have an internal serialnumber, so I think more that
this a server serialnumber which is created during install....
you can get same output from console with:
load config /l
which produces a sys:/system/config.txt ...
Günter.
|
| Post Reply
|
|
|