[Nexus-developers] NeXus-64 bit

Peterson, Peter F. petersonpf at ornl.gov
Thu Aug 23 15:32:51 BST 2007


Mark,

I'm in favor of generating exceptions for HDF4 int64. In my opinion it
solves that problem. I don't know how others feel though.

For the type problem. What I have done in
applications/NXsummary/data_util.cpp is add
<code>
// use STDINT if possible, otherwise define the types here
#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
typedef signed char             int8_t;
typedef short int               int16_t;
typedef int                     int32_t;
typedef unsigned char           uint8_t;
typedef unsigned short int      uint16_t;
typedef unsigned int            uint32_t;
#endif
</code>
This header is declared in the C99 standard so it is fairly portable. I
don't really know that magic that would enable uint64_t, but I'm fairly
certain that the stdint.h header does and could just be replicated. This
could/should be put in napi.h anyhow to make life easier for future
developments using NAPI.

Another option to help deal with platform dependencies is to have a
config check which declares "HAVE_INT64".

P^2

-----Original Message-----
From: nexus-developers-bounces at nexusformat.org
[mailto:nexus-developers-bounces at nexusformat.org] On Behalf Of Mark
Koennecke
Sent: Thursday, August 23, 2007 10:10 AM
To: nexus-developers at nexusformat.org
Subject: [Nexus-developers] NeXus-64 bit

Hi everyone,

I now got 64 bit integers working for NeXus for HDF-5 and XML. It 
required changes to  several
bindings too. And we are entering a ball of mud:

Contrary to my  expectations I had to notice that a long on an Intel-PC 
is 32bit only and not 64bit.
On an alpha a long is sufficient to get a 64 bit integer.  It would be 
interesting to test this on a
64-bit Intel, but I have none available. In order to get a 64 bit 
integer on 32 bit Intel you need a
long long type. But long long is C99 standard. As this is not yet 50 
years old, there might be
platforms/compilers out there which cannot do this. Well, I worked 
around this. Partially I
used tests for sizeof(long) in order to get the right thing done. But I 
also had to create a new
define, NX64INT, which must be initailized to the correct number type on

the current platform.
I currently have some logic in napi.h to do this, but this could also be

done by a compiler
option automatically determined by the configure script.

The question I want answered before I commit this is:
- The 64 bit integers  introduces platform problems. Do we still want
this?

As an aggravating factor I extended napi_test.c and thus all the 
automatic tests "fail" now.
Sorry, Freddie.  I also  fixed the #16 issue with \0 terminated strings 
in XML. 
Given the complications stated above and the fact that I am not 
convinced that Freddies
suggestion would solve the 64 bit byte order issue, there is no support 
for 64 bit ints in
HDF-4 as of now. It would anyway be ugly, because we would need to 
annotate HDF-4 pseudo
64 bit 32 bit datasets in some way to distinguish them.  Freddie 
suggested some tricky stuff with
bit shifting but I believe the difference between BE and LE is in which 
direction to shift in order
to get the low bytes out.

             What do you think?

                            Mark
 

_______________________________________________
NeXus-developers mailing list
NeXus-developers at nexusformat.org
http://lists.nexusformat.org/mailman/listinfo/nexus-developers



More information about the NeXus-developers mailing list