Re: [netcdfgroup] Problem with netCDF "classic" files larger than 2GB on Windows

Hi Russ and Ed,

 

I've attached a patch file, and a text file that describes my changes to
netCDF 4.1.3 in order to:

 

- Build on Windows with the Visual Studio 9 VC compiler

- Be able to create netCDF classic files >2GB on Windows

- Build for vxWorks on a Linux host with an old version of the GCC
cross-compiler (2-7-2)

 

Some of these fixes are definitely errors in the netCDF code, and should
be incorporated in a future release.

 

Some are workarounds for problems, particularly on vxWorks, that should
probably be handled differently, but I am not sure of the best way.

 

The config.h file for Windows could be distributed as an example, with
users instructed to edit it as needed.  The items that Christoph
supplied in his message yesterday clearly need to be in an example
config.h to allow >2GB classic files on Windows.

 

Note that I am using gnumake, not the Visual Studio development
environment, so I have not created any Visual Studio project files.

 

Thanks,

Mark

 

 

________________________________________

From: Mark Rivers 

Sent: Tuesday, July 05, 2011 5:14 PM

To: 'Russ Rew'; 'Ed Hartnett'

Cc: netcdfgroup@xxxxxxxxxxxxxxxx

Subject: RE: [netcdfgroup] Problem with netCDF "classic" files larger
than 2GB on Windows

 

Hi Russ and Ed,

 

Thanks for your replies.

 

I have now upgraded from netCDF 3.6.3 to 4.1.3 as you suggested.

 

I have reproduced the problem in a simple test program, which I have
attached.  The test program creates a netCDF file of the following
format as revealed by ncdump:

 

corvette:areaDetector/ADApp/netCDFSrc>ncdump -k
/home/epics/scratch/test.nc

classic 

 

corvette:areaDetector/ADApp/netCDFSrc>ncdump -h
/home/epics/scratch/test.nc

netcdf test {

dimensions:

        numArrays = UNLIMITED ; // (4100 currently)

        YSize = 1024 ;

        XSize = 1024 ;

variables:

        byte array_data(numArrays, YSize, XSize) ;

}

 

So it writes a 1024x1024 byte array to the file 4100 times, where 4100
is the unlimited dimension.  This tests writing files that are larger
than both the 2GB and 4GB potential limits.

 

The test program runs fine on Linux and Cygwin.

 

However, when compiled with the Microsoft Visual Studio 2008 compiler,
it fails with exactly the same error I got in netCDF 3.6.3, except it is
now in line 342 rather than 325 of posixio.c.

 

writing record 2047/4100

writing record 2048/4100

Assertion failed: pxp->bf_offset <= offset && offset < pxp->bf_offset +
(off_t) pxp->bf_extent, file ..\..\..\ADApp\netCDFSrc\libsrc\posixio.c,
line 342

 

By way of background on why I need to use the Microsoft compiler:

 

I run a fairly large NSF-funded user facility at the Advanced Photon
Source at Argonne National Laboratory.  We collect data using a wide
variety of x-ray and other detectors under a distributed real-time
control system called EPICS.  Some of these detectors can be controlled
from Linux and Cygwin, but many of them have vendor-supplied drivers
that can only be called from code compiled with the Microsoft compiler.
I also need to build my application to run on the vxWorks and RTEMS
real-time operating systems, which we use to control specialized VME
hardware.  These use the gcc compiler, but cross-compiling for the
real-time target on a Linux host.  

 

I am building with gnumake, not the Visual Studio application
development environment on all platforms, including when building with
the Microsoft VC++ compiler on Windows.

 

I have also attached a copy of the config.h file I am using, which has
been modified from the version built by "configure" on Linux to do
things differently if _WIN32 or vxWorks are defined.

 

I had to make some minor changes to the 4.1.3 source code in order to
allow it to build with the Microsoft VS 2008 compiler, and to build on
vxWorks.  I will send those changes in a separate e-mail.

 

I have also attached an IDL version of the same program.  It should be
completely equivalent to the C program.  It works fine on both Linux and
on Windows.  It appears to me that the idl_netcdf.dll file that ITT
provides with IDL on Windows is built with the Microsoft compiler
(judging from dumpbin /imports), but I am not certain of this.  If so,
it indicates that it is possible to write netCDF classic files when
compiling with Visual Studio, and I am probably just doing something
wrong.

 

Perhaps it is in my flags to the compiler.  Here is the output when I
compile posixio.c as an example of the flags I am using:

J:\epics\devel\areaDetector\ADApp\netCDFSrc>make install.win32-x86

make -C O.win32-x86 -f ../Makefile TOP=../../.. T_A=win32-x86 install

make[1]: Entering directory
`J:/epics/devel/areaDetector/ADApp/netCDFSrc/O.win32-x86'

cl -c               /nologo /D__STDC__=0 /D_CRT_SECURE_NO_DEPRECATE
/D_CRT_NONSTDC_NO_DEPRECATE   /Ox /GL   /W3 /w44355
/D_WIN32_WINNT=0x0503 -DHAVE_CONFIG_H   /MT -DEPICS_DLL_NO    -I.
-I..\\O.Common -I. -I.. -I..\\..\\..\\ADApp\\netCDFSrc\\include
-I..\\..\\..\\ADApp\\netCDFSrc\\libsrc
-I..\\..\\..\\ADApp\\netCDFSrc\\libdispatch
-I..\\..\\..\\ADApp\\netCDFSrc\\liblib -I..\\..\\..\\include\\os\\WIN32
-I..\\..\\..\\include  -IJ:\\epics\\devel\\asyn-4-17\\include
-IJ:\\epics\\devel\\calc-2-8\\include
-IJ:\\epics\\devel\\busy-1-3\\include
-IJ:\\epics\\devel\\sscan-2-6-6\\include
-IJ:\\epics\\devel\\mca-6-12-4\\include
-IJ:\\epics\\devel\\autosave-4-7\\include\\os\\WIN32
-IJ:\\epics\\devel\\autosave-4-7\\include
-IJ:\\epics\\devel\\areaDetector-1-7beta1\\include\\os\\WIN32
-IJ:\\epics\\devel\\areaDetector-1-7beta1\\include
-IH:\\epics\\base-3.14.12.1\\include\\os\\WIN32
-IH:\\epics\\base-3.14.12.1\\include
-I..\\..\\..\\ADApp\\netCDFSrc\\include
..\\..\\..\\ADApp\\netCDFSrc\\libsrc\\posixio.c

posixio.c

..\..\..\ADApp\netCDFSrc\libsrc\posixio.c(433) : warning C4018: '<' :
signed/unsigned mismatch

..\..\..\ADApp\netCDFSrc\libsrc\posixio.c(441) : warning C4018: '<=' :
signed/unsigned mismatch

..\..\..\ADApp\netCDFSrc\libsrc\posixio.c(449) : warning C4018: '<=' :
signed/unsigned mismatch

..\..\..\ADApp\netCDFSrc\libsrc\posixio.c(454) : warning C4018: '>' :
signed/unsigned mismatch

 

 

Thanks,

Mark

 

 

 

-----Original Message-----

From: Russ Rew [mailto:russ@xxxxxxxxxxxxxxxx] 

Sent: Wednesday, June 29, 2011 1:34 PM

To: Mark Rivers

Cc: netcdfgroup@xxxxxxxxxxxxxxxx

Subject: Re: [netcdfgroup] Problem with netCDF "classic" files larger
than 2GB on Windows

 

Hi Mark,

 

> I am having a problem writing netCDF "classic" files larger than 2GB

> when building with the Microsoft Visual Studio 2008 compiler.  The
same

> code works fine when build on Linux, and on Cygwin.

> 

> A bit of background.  This is a project to build generic file writers

> for cameras and detectors in the areaDetector package

> (http://cars9.uchicago.edu/software/epics/areaDetectorDoc.html) for
the

> EPICS (http://www.aps.anl.gov/epics/) real-time control system.  This
is

> a large project, with its own build system based on gnumake.  I am

> building the basic netCDF library from the same source code on all

> supported platforms (Linux 32 and 64-bit, Windows 32 and 64-bit with

> Microsoft compiler, Windows with Cygwin gcc compilet, vxWorks, Darwin,

> Solaris, etc.).  Because I have another file writer that handles HDF5,
I

> am using netCDF 3.6.3, since I only want to netCDF to create "classic"

> files.  I am using 3.6.3 because it is less complex than 4.x, not

> requiring any HDF5 support, etc.

 

I recommend you use the latest netCDF-4 release, 4.1.3.  If you don't

have and HDF5 library installed, it will be built without support for

netCDF-4, but with bug fixes since 3.6.3 was released 3 years ago.  For

example, these bug fixes were mentioned in the RELEASE_NOTES for 4.1.2:

 

            Fixed two large-file bugs with using classic format or

            64-bit offset format and accessing multidimensional

            variables with more than 2**32 values.

 

If the problem you're seeing still occurs in releases since 4.1.2, it

may be something new.

 

--Russ

 

> The application is typically streaming uncompressed images, using the

> UNLIMITED dimension as the streaming dimension. Thus, each record is

> small, only a few MB, and the file size limitations of the classic

> format are not a problem.  Here is an ncdump of a file header created

> with this file writer on Linux:

> 

> corvette:ADApp/op/adl>ncdump -h /home/epics/scratch/netcdf_test_1.nc

> netcdf netcdf_test_1 {

> dimensions:

>         numArrays =3D UNLIMITED ; // (4100 currently)

>         dim0 =3D 1024 ;

>         dim1 =3D 1024 ;

>         attrStringSize =3D 256 ;

> variables:

>         int uniqueId(numArrays) ;

>         double timeStamp(numArrays) ;

>         byte array_data(numArrays, dim0, dim1) ;

>         int Attr_ColorMode(numArrays) ;

>         double Attr_AcquireTime(numArrays) ;

>         double Attr_RingCurrent(numArrays) ;

>         char Attr_RingCurrent_EGU(numArrays, attrStringSize) ;

>         double Attr_ID_Energy(numArrays) ;

>         char Attr_ID_Energy_EGU(numArrays, attrStringSize) ;

>         int Attr_ImageCounter(numArrays) ;

>         int Attr_MaxSizeX(numArrays) ;

>         int Attr_MaxSizeY(numArrays) ;

>         char Attr_CameraModel(numArrays, attrStringSize) ;

>         char Attr_CameraManufacturer(numArrays, attrStringSize) ;

> 

> // global attributes:

>                 :dataType =3D 1 ;

>                 :NDNetCDFFileVersion =3D 3. ;

>                 :numArrayDims =3D 2 ;

>                 :dimSize =3D 1024, 1024 ;

> ...

> 

> So the only large array is called "array_data", and in this case it is

> [4100, 1024, 1024], where 4100 is the unlimited dimension.  Thus, this

> file is over 4GB, and it can be written and read with no problems on

> Linux and Cygwin.  It also works fine when writing files on Windows
with

> the Microsoft compiler, up to file sizes of 2GB.

> 

> However, when I try to write a file on Windows larger than 2GB using
the

> program built with the Visual Studio compiler I get the following
error:

> 

> Assertion failed: pxp->bf_offset <=3D offset && offset <
pxp->bf_offset =

> +

> (off_t) pxp->bf_extent, file ..\posixio.c, line 325

> 

> When I look at the code at line 325 in posixio.c, I see that offset
and

> pdxp->bf_offset are of type off_t.  I added a printf() in that code to

> print the sizeof(offset) and sizeof(off_t), and it comes up as 4, not
8.

> 

> 

> But when I look at the config.h file that comes in the win32/NET

> directory in netCDF 3.6.3 it has the following:

> corvette:areaDetector/ADApp/netCDFSrc>grep -C3 off_t

> /usr/local/netcdf/netcdf-3.6.3/win32/NET/config.h

> /* #undef HAVE_ST_BLKSIZE */

> 

> /* Define to `long' if <sys/types.h> doesn't define.  */

> /* #undef off_t */

> 

> /* Define to `unsigned' if <sys/types.h> doesn't define.  */

> /* #undef size_t */

> --

> /* The number of bytes in a size_t */

> #define SIZEOF_SIZE_T 4

> 

> /* The number of bytes in a off_t */

> #define SIZEOF_OFF_T 8

> 

> /* Define to `int' if system doesn't define.  */

> 

> 

> So it defines SIZEOF_OFF_T to be 8, not 4.

> 

> I have generated the netCDF config.h file on Linux, but then edited it

> to correctly (?) define things on other platforms, like _WIN32 and

> vxWorks.

> 

> The compiler flags being used on Windows are illustrated in the

> following output when I build:

> 

> cl -c               /nologo /D__STDC__=3D0 /D_CRT_SECURE_NO_DEPRECATE

> /D_CRT_NONSTDC_NO_DEPRECATE   /Ox /GL   /W3 /w44355

> /D_WIN32_WINNT=3D0x0503 -D_FILE_OFFSET_BITS=3D64   /MT -DEPICS_DLL_NO
=

> -I.

> -I..\\O.Common -I. -I.. -I..\\..\\..\\include\\os\\WIN32

> -I..\\..\\..\\include  -IJ:\\epics\\devel\\asyn-4-17\\include

> -IJ:\\epics\\devel\\calc-2-8\\include

> -IJ:\\epics\\devel\\busy-1-3\\include

> -IJ:\\epics\\devel\\sscan-2-6-6\\include

> -IJ:\\epics\\devel\\mca-6-12-4\\include

> -IJ:\\epics\\devel\\autosave-4-7\\include\\os\\WIN32

> -IJ:\\epics\\devel\\autosave-4-7\\include

> -IJ:\\epics\\devel\\areaDetector-1-7beta1\\include\\os\\WIN32

> -IJ:\\epics\\devel\\areaDetector-1-7beta1\\include

> -IH:\\epics\\base-3.14.12.1\\include\\os\\WIN32

> -IH:\\epics\\base-3.14.12.1\\include       ..\\var.c

> 

> There is something I don't understand here.

> 

> Has netCDF 3.6.3 been tested to correctly write classic files > 2GB
with

> the Microsoft compiler?  Why am I getting the assert error?

> 

> Thanks very much,

> Mark Rivers

The following document lists the changes I needed to make to netCDF 4.1.3 in 
order to:

- Build on Windows with the Visual Studio 9 VC compiler
- Be able to create netCDF classic files >2GB on Windows
- Build for vxWorks on a Linux host with an old version of the GCC 
cross-compiler (2-7-2)

lookup3.c unconditionally includes the file "sys/param.h".  That is not 
portable, sys/param.h does not exist on Windows or vxWorks.
I fixed this by adding a new #define to config.h, HAVE_SYS_PARAM_H, and only 
including sys/param.h if HAVE_SYS_PARAM_H is defined.

Index: libsrc/lookup3.c
===================================================================
--- libsrc/lookup3.c    (revision 13003)
+++ libsrc/lookup3.c    (working copy)
@@ -54,7 +54,9 @@
 #else
 #  include <stdint.h>
 #endif /* HAVE_STDINT_H */
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>  /* attempt to define endianness */
+#endif
 #ifdef linux
 # include <endian.h>    /* attempt to define endianness */
 #endif


The file include/ncdispatch.h defines nulldup to always be a macro using 
strdup.  This is incorrect, 
because it won't work on systems that don't have strdup().  I have fixed this, 
so that if HAVE_STRDUP 
is false then nulldup is defined to be a function.  That function is indeed 
provided in libstr/string.c.


Index: include/ncdispatch.h
===================================================================
--- include/ncdispatch.h        (revision 13003)
+++ include/ncdispatch.h        (working copy)
@@ -362,10 +362,15 @@
 
 /* Misc */
 
-#ifndef nulldup
-#define nulldup(s) ((s)==NULL?NULL:strdup(s))
+#ifdef HAVE_STRDUP
+  #ifndef nulldup
+    #define nulldup(s) ((s)==NULL?NULL:strdup(s))
+  #endif
+#else
+  char *nulldup(const char* s);
 #endif
 
+
 #define nulllen(s) (s==NULL?0:strlen(s))
 #define nullstring(s) (s==NULL?"(null)":s)
 

dispatch.c calls strdup().  This is an error, it should call nulldup().

Index: libdispatch/dispatch.c
===================================================================
--- libdispatch/dispatch.c      (revision 13003)
+++ libdispatch/dispatch.c      (working copy)
@@ -109,7 +109,7 @@
            model |= protolist->modelflags;
            if(protolist->substitute) {
                if(tmpurl->protocol) free(tmpurl->protocol);
-               tmpurl->protocol = strdup(protolist->substitute);
+               tmpurl->protocol = nulldup(protolist->substitute);
            }
            break;          
        }


file.c calls strdup().  This is an error, it should call nulldup().

ndex: libdispatch/file.c
===================================================================
--- libdispatch/file.c  (revision 13003)
+++ libdispatch/file.c  (working copy)
@@ -202,7 +202,7 @@
    if(stat == NC_NOERR) {
       ncp->dispatch = dispatcher;
       if(ncidp) *ncidp = ncp->ext_ncid;
-      ncp->path = strdup(path);
+      ncp->path = nulldup(path);
       if(path == NULL) stat = NC_ENOMEM;       
    }
    return stat;
@@ -330,7 +330,7 @@
    if(stat == NC_NOERR) {
       ncp->dispatch = dispatcher;
       if(ncidp) *ncidp = ncp->ext_ncid;
-      ncp->path = strdup(path);
+      ncp->path = nulldup(path);
       if(path == NULL) stat = NC_ENOMEM;       
    }
    return stat;


nc_uri calls strdup().  This is an error, it should call nulldup().
nc_uri also creates a new static version of nulldup.  This is not needed,
it should just use the version of nulldup that is provided in string.c.  I have
not fixed this problem, but it should be fixed.


Index: libdispatch/nc_uri.c
===================================================================
--- libdispatch/nc_uri.c        (revision 13003)
+++ libdispatch/nc_uri.c        (working copy)
@@ -27,12 +27,12 @@
 #define NILLEN(s) ((s)==NULL?0:strlen(s))
 #endif
 
-#ifndef nulldup
-#define nulldup(s) ((s)==NULL?NULL:strdup(s))
-#endif
-
-#ifndef HAVE_STRDUP
-static char* nulldup(char* s)
+#ifdef HAVE_STRDUP
+  #ifndef nulldup
+    #define nulldup(s) ((s)==NULL?NULL:strdup(s))
+  #endif
+#else
+static char* nulldup(const char* s)
 {
     char* dup = NULL;
     if(s != NULL) {
@@ -81,7 +81,7 @@
     if(nc_uri == NULL) return 0;    
 
     /* make local copy of uri */
-    uri = strdup(uri0);
+    uri = nulldup(uri0);
 
     /* remove all whitespace*/
     p = uri;
@@ -151,20 +151,20 @@
 
     /* assemble the component pieces*/
     if(uri0 && strlen(uri0) > 0)
-        nc_uri->uri = strdup(uri0);
+        nc_uri->uri = nulldup(uri0);
     if(protocol && strlen(protocol) > 0) {
-        nc_uri->protocol = strdup(protocol);
+        nc_uri->protocol = nulldup(protocol);
         /* remove trailing ':' */
         nc_uri->protocol[strlen(protocol)-1] = '\0';
     }
     if(user && strlen(user) > 0)
-        nc_uri->user = strdup(user);
+        nc_uri->user = nulldup(user);
     if(pwd && strlen(pwd) > 0)
-        nc_uri->password = strdup(pwd);
+        nc_uri->password = nulldup(pwd);
     if(host && strlen(host) > 0)
-        nc_uri->host = strdup(host);
+        nc_uri->host = nulldup(host);
     if(port && strlen(port) > 0)
-        nc_uri->port = strdup(port);
+        nc_uri->port = nulldup(port);
     if(file && strlen(file) > 0) {
        /* Add back the leading / */
         nc_uri->file = malloc(strlen(file)+2);
@@ -172,7 +172,7 @@
         strcat(nc_uri->file,file);
     }
     if(constraint && strlen(constraint) > 0)
-        nc_uri->constraint = strdup(constraint);
+        nc_uri->constraint = nulldup(constraint);
     nc_urisetconstraints(nc_uri,constraint);
     if(params != NULL && strlen(params) > 0) {
         nc_uri->params = (char*)malloc(1+2+strlen(params));
@@ -239,7 +239,7 @@
 
     if(constraints == NULL || strlen(constraints)==0) return;
 
-    duri->constraint = strdup(constraints);
+    duri->constraint = nulldup(constraints);
     if(*duri->constraint == '?')
        strcpy(duri->constraint,duri->constraint+1);
 
@@ -375,15 +375,15 @@
 
     /* Pass 1 to replace beginning '[' and ending ']' */
     if(params0[0] == '[') 
-       params = strdup(params0+1);
+       params = nulldup(params0+1);
     else
-       params = strdup(params0);       
+       params = nulldup(params0);      
 
     if(params[strlen(params)-1] == ']')
        params[strlen(params)-1] = '\0';
 
     /* Pass 2 to replace "][" pairs with ','*/
-    params1 = strdup(params);
+    params1 = nulldup(params);
     cp=params; cq = params1;
     while((c=*cp++)) {
        if(c == RBRACKET && *cp == LBRACKET) {cp++; c = ',';}
@@ -413,8 +413,8 @@
        /*break up the ith param*/
        vp = strchr(cp,'=');
        if(vp != NULL) {*vp = '\0'; vp++;} else {vp = "";}
-       plist[2*i] = strdup(cp);        
-       plist[2*i+1] = strdup(vp);
+       plist[2*i] = nulldup(cp);       
+       plist[2*i+1] = nulldup(vp);
        cp = next;
     }
     plist[2*nparams] = NULL;
@@ -527,8 +527,8 @@
     len = sizeof(char*)*((2*i)+1);
     newp = realloc(params,len+2*sizeof(char*));
     memcpy(newp,params,len);
-    newp[2*i] = strdup(key);
-    newp[2*i+1] = (value==NULL?NULL:strdup(value));
+    newp[2*i] = nulldup(key);
+    newp[2*i+1] = (value==NULL?NULL:nulldup(value));
     return newp;
 }
 

The GCC compiler on vxWorks warned that stride1 could be being used 
uninitialized, so I initialized it.

Index: libdispatch/var1.c
===================================================================
--- libdispatch/var1.c  (revision 13003)
+++ libdispatch/var1.c  (working copy)
@@ -603,7 +603,7 @@
       size_t varshape[NC_MAX_VAR_DIMS];
       int isrecvar;
       size_t numrecs;
-      int stride1; /* is stride all ones? */
+      int stride1=0; /* is stride all ones? */
 
       /*
        * Verify stride argument.


utf8proc.h has en error.  It unconditionally includes inttypes.h, but it should 
obey
the HAVE_INTTYPES_H flag.  If HAVE_INTTYPES_H is false it should include 
pstdint.h
instead.

There is a problem with vxWorks, which #defines SSIZE_MAX, but defines it to be 
blank.
I don't understand why they do this, but I have worked around the problem.

Index: include/utf8proc.h
===================================================================
--- include/utf8proc.h  (revision 13003)
+++ include/utf8proc.h  (working copy)
@@ -76,13 +76,22 @@
 # define __bool_true_false_are_defined 1
 #endif
 #include <sys/types.h>
+#ifdef HAVE_INTTYPES_H
 #include <inttypes.h>
+#else
+#include "pstdint.h"
+#endif
 #include <limits.h>
 
 #ifndef HAVE_SSIZE_T
 #define ssize_t int
 #endif
 
+#ifdef vxWorks
+#undef SSIZE_MAX
+#define SSIZE_MAX LONG_MAX
+#endif
+
 #ifndef SSIZE_MAX
 #define SSIZE_MAX (SIZE_MAX/2)
 #endif


The rules in pstdint.h do not work on vxWorks.  vxWorks does have the uint8_t, 
etc. types defined,
but it fails to detect this in the #ifndef.  So I have worked around the 
problem.


Index: libsrc/pstdint.h
===================================================================
--- libsrc/pstdint.h    (revision 13003)
+++ libsrc/pstdint.h    (working copy)
@@ -303,7 +303,7 @@
 #ifndef UINT8_MAX
 # define UINT8_MAX 0xff
 #endif
-#ifndef uint8_t
+#if !defined(uint8_t) && !defined(vxWorks)
 # if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
     typedef unsigned char uint8_t;
 #   define UINT8_C(v) ((uint8_t) v)
@@ -318,7 +318,7 @@
 #ifndef INT8_MIN
 # define INT8_MIN INT8_C(0x80)
 #endif
-#ifndef int8_t
+#if !defined(int8_t) && !defined(vxWorks)
 # if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
     typedef signed char int8_t;
 #   define INT8_C(v) ((int8_t) v)
@@ -330,7 +330,7 @@
 #ifndef UINT16_MAX
 # define UINT16_MAX 0xffff
 #endif
-#ifndef uint16_t
+#if !defined(uint16_t) && !defined(vxWorks)
 #if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
   typedef unsigned int uint16_t;
 # ifndef PRINTF_INT16_MODIFIER
@@ -354,7 +354,7 @@
 #ifndef INT16_MIN
 # define INT16_MIN INT16_C(0x8000)
 #endif
-#ifndef int16_t
+#if !defined(int16_t) && !defined(vxWorks)
 #if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
   typedef signed int int16_t;
 # define INT16_C(v) ((int16_t) (v))
@@ -375,7 +375,7 @@
 #ifndef UINT32_MAX
 # define UINT32_MAX (0xffffffffUL)
 #endif
-#ifndef uint32_t
+#if !defined(uint32_t) && !defined(vxWorks)
 #if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
   typedef unsigned long uint32_t;
 # define UINT32_C(v) v ## UL
@@ -405,7 +405,7 @@
 #ifndef INT32_MIN
 # define INT32_MIN INT32_C(0x80000000)
 #endif
-#ifndef int32_t
+#if !defined(int32_t) && !defined(vxWorks)
 #if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
   typedef signed long int32_t;
 # define INT32_C(v) v ## L
@@ -451,7 +451,7 @@
 #endif
 
 #if !defined (stdint_int64_defined)
-# if defined(__GNUC__)
+# if defined(__GNUC__) && !defined(vxWorks)
 #  define stdint_int64_defined
    __extension__ typedef long long int64_t;
    __extension__ typedef unsigned long long uint64_t;
@@ -646,7 +646,7 @@
  *  type limits.
  */
 
-#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
+#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && 
!defined(vxWorks)
 # include <wchar.h>
 # ifndef WCHAR_MIN
 #  define WCHAR_MIN 0


Finally, I have modified config.h to allow it build on Linux, WIN32, and 
vxWorks, and to 
correctly create classic files >2GB on WIN32.


Index: config.h
===================================================================
--- config.h    (revision 13003)
+++ config.h    (working copy)
@@ -43,7 +43,9 @@
 /* #undef H5_USE_16_API */
 
 /* Define to 1 if you have `alloca', as a function or macro. */
+#if !defined(_WIN32)
 #define HAVE_ALLOCA 1
+#endif
 
 /* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
    */
@@ -115,7 +117,9 @@
 /* #undef HAVE_HDF5_H */
 
 /* Define to 1 if you have the <inttypes.h> header file. */
+#if !defined(vxWorks) && !defined(_WIN32)
 #define HAVE_INTTYPES_H 1
+#endif
 
 /* Define to 1 if you have the `curl' library (-lcurl). */
 #define HAVE_LIBCURL 1
@@ -172,17 +176,28 @@
 #define HAVE_SNPRINTF 1
 
 /* Define to 1 if the system has the type `ssize_t'. */
+#if !defined(_WIN32)
 #define HAVE_SSIZE_T 1
+#endif
 
 /* Define to 1 if you have the <stdarg.h> header file. */
 #define HAVE_STDARG_H 1
 
 /* Define to 1 if stdbool.h conforms to C99. */
+#if !defined(vxWorks) && !defined(_WIN32)
 #define HAVE_STDBOOL_H 1
+#endif
 
 /* Define to 1 if you have the <stdint.h> header file. */
+#if !defined(vxWorks) && !defined(_WIN32)
 #define HAVE_STDINT_H 1
+#endif
 
+/* Define to 1 if you have the <sys/param.h> header file. */
+#if !defined(vxWorks) && !defined(_WIN32)
+#define HAVE_SYS_PARAM_H 1
+#endif
+
 /* Define to 1 if you have the <stdio.h> header file. */
 #define HAVE_STDIO_H 1
 
@@ -202,7 +217,9 @@
 #define HAVE_STRCPY 1
 
 /* Define to 1 if you have the `strdup' function. */
+#if !defined(vxWorks)
 #define HAVE_STRDUP 1
+#endif
 
 /* Define to 1 if you have the `strerror' function. */
 #define HAVE_STRERROR 1
@@ -233,7 +250,9 @@
 
 /* Define to 1 if your `struct stat' has `st_blksize'. Deprecated, use
    `HAVE_STRUCT_STAT_ST_BLKSIZE' instead. */
+#if !defined(_WIN32)
 #define HAVE_ST_BLKSIZE 1
+#endif
 
 /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
    */
@@ -262,7 +281,9 @@
 /* #undef HAVE_UCHAR */
 
 /* Define to 1 if you have the <unistd.h> header file. */
+#if !defined(_WIN32)
 #define HAVE_UNISTD_H 1
+#endif
 
 /* Define to 1 if the system has the type `unsigned long long int'. */
 /* #undef HAVE_UNSIGNED_LONG_LONG_INT */
@@ -271,7 +292,9 @@
 #define HAVE_VPRINTF 1
 
 /* Define to 1 if the system has the type `_Bool'. */
+#if !defined(vxWorks) && !defined(_WIN32)
 #define HAVE__BOOL 1
+#endif
 
 /* do large file tests */
 /* #undef LARGE_FILE_TESTS */
@@ -365,7 +388,19 @@
 #define SIZEOF_LONG 4
 
 /* The size of `off_t', as computed by sizeof. */
-#define SIZEOF_OFF_T 8
+#if defined(vxWorks)
+  #define SIZEOF_OFF_T 4
+#elif defined(_WIN32)
+  #include <io.h>
+  #include <process.h>
+  #define SIZEOF_OFF_T 8
+  #define lseek _lseeki64
+  #define off_t __int64
+  #define _off_t __int64
+  #define _OFF_T_DEFINED
+#else
+  #define SIZEOF_OFF_T 8
+#endif
 
 /* The size of `short', as computed by sizeof. */
 #define SIZEOF_SHORT 2
@@ -400,7 +435,9 @@
 #define USE_EXTREME_NUMBERS 1
 
 /* if true, include experimental fsync code */
+#if !defined(vxWorks) && !defined(_WIN32)
 #define USE_FSYNC 1
+#endif
 
 /* if true, use HDF4 too */
 /* #undef USE_HDF4 */

Attachment: netCDF_patches
Description: netCDF_patches

  • 2011 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: