Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread safety: step 1: cleanup #1379

Merged
merged 2 commits into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions debug/cf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ DAP=1
#CDF5=1
#HDF4=1

#TR=--trace

NCC="c:/tools/nccmake"

export SETX=1

for arg in "$@" ; do
case "$arg" in
vs|VS) VS=1 ;;
linux|nix|l|x) unset VS ;;
nobuild|nb) NOBUILD=1 ;;
notest|nt) NOTEST=1 ;;
*) echo "Must specify env: vs|linux"; exit 1; ;;
esac
done
Expand All @@ -35,8 +40,10 @@ else
CFG="Release"
fi

FLAGS=

if test "x$VS" != x -a "x$INSTALL" != x ; then
FLAGS="-DCMAKE_PREFIX_PATH=c:/tools/nccmake"
FLAGS="$FLAGS -DCMAKE_PREFIX_PATH=${NCC}"
fi
FLAGS="$FLAGS -DCMAKE_INSTALL_PREFIX=/tmp/netcdf"

Expand All @@ -45,6 +52,8 @@ FLAGS="$FLAGS -DENABLE_DAP=false"
fi
if test "x$NC4" = x ; then
FLAGS="$FLAGS -DENABLE_NETCDF_4=false"
else
FLAGS="-DHDF5_C_LIBRARY=${NCC}/lib/hdf5 -DHDF5_HL_LIBRARY=${NCC}/lib/hdf5_hl -DHDF5_INCLUDE_DIR=${NCC}/include"
fi
if test "x$CDF5" != x ; then
FLAGS="$FLAGS -DENABLE_CDF5=true"
Expand All @@ -69,6 +78,7 @@ FLAGS="$FLAGS -DENABLE_EXAMPLES=false"
FLAGS="$FLAGS -DENABLE_CONVERSION_WARNINGS=false"
#FLAGS="$FLAGS -DENABLE_TESTS=false"
#FLAGS="$FLAGS -DENABLE_DISKLESS=false"
FLAGS="$FLAGS -DBUILD_UTILITIES=true"

# Withs
FLAGS="$FLAGS -DNCPROPERTIES_EXTRA=\"key1=value1|key2=value2\""
Expand All @@ -86,10 +96,12 @@ CFG="Release"
NCLIB="${NCLIB}/liblib"
export PATH="${NCLIB}:${PATH}"
#G=
cmake "$G" -DCMAKE_BUILD_TYPE=${CFG} $FLAGS ..
cmake ${TR} "$G" -DCMAKE_BUILD_TYPE=${CFG} $FLAGS ..
if test "x$NOBUILD" = x ; then
cmake --build . --config ${CFG}
cmake --build . --config ${CFG} --target RUN_TESTS
cmake ${TR} --build . --config ${CFG} --target ZERO_CHECK
if test "x$NOTEST" = x ; then
cmake ${TR} --build . --config ${CFG} --target RUN_TESTS
fi
fi
else
# GCC
Expand Down
2 changes: 1 addition & 1 deletion include/hdf4dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern "C" {

extern int
NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
void *parameters, NC_Dispatch *, NC *);
void *parameters, const NC_Dispatch *, NC *);

extern int
NC_HDF4_abort(int ncid);
Expand Down
6 changes: 3 additions & 3 deletions include/hdf5internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ extern int NC4_provenance_init();
extern int NC4_provenance_finalize();

/* Extract the provenance from a file, using dfalt as default */
extern int NC4_get_provenance(NC_FILE_INFO_T* file, const char* propstring, const struct NCPROPINFO* dfalt);
extern int NC4_get_provenance(NC_FILE_INFO_T* file, const char* propstring);

/* Set the provenance for a created file using dfalt as default */
extern int NC4_set_provenance(NC_FILE_INFO_T* file, const struct NCPROPINFO* dfalt);
/* Set the provenance for a created file */
extern int NC4_set_provenance(NC_FILE_INFO_T* file);

/* Recover memory of an NCPROVENANCE object */
extern int NC4_free_provenance(struct NCPROVENANCE* prov);
Expand Down
7 changes: 2 additions & 5 deletions include/nc.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct NCmodel;
typedef struct NC {
int ext_ncid;
int int_ncid;
struct NC_Dispatch* dispatch;
const struct NC_Dispatch* dispatch;
void* dispatchdata; /*per-'file' data; points to e.g. NC3_INFO data*/
char* path;
int mode; /* as provided to nc_open/nc_create */
Expand Down Expand Up @@ -81,9 +81,6 @@ extern int iterate_NCList(int i,NC**); /* Walk from 0 ...; ERANGE return => stop

/* Defined in nc.c */
extern void free_NC(NC*);
extern int new_NC(struct NC_Dispatch*, const char*, int, struct NCmodel*, NC**);

/* Defined in nc.c */
extern int ncdebug;
extern int new_NC(const struct NC_Dispatch*, const char*, int, struct NCmodel*, NC**);

#endif /* _NC_H_ */
4 changes: 2 additions & 2 deletions include/nc3dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ extern "C" {
extern int
NC3_create(const char *path, int cmode,
size_t initialsz, int basepe, size_t *chunksizehintp,
void* mpidata, struct NC_Dispatch*, NC* ncp);
void* mpidata, const struct NC_Dispatch*, NC* ncp);

/* WARNING: this signature differs from external nc_open API*/
extern int
NC3_open(const char *path, int mode,
int basepe, size_t *chunksizehintp,
void* mpidata, NC_Dispatch*, NC* ncp);
void* mpidata, const NC_Dispatch*, NC* ncp);

extern int
NC3_new_nc(NC**);
Expand Down
4 changes: 2 additions & 2 deletions include/nc4dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ extern "C" {
EXTERNL int
NC4_create(const char *path, int cmode,
size_t initialsz, int basepe, size_t *chunksizehintp,
void* parameters, NC_Dispatch*, NC*);
void* parameters, const NC_Dispatch*, NC*);

EXTERNL int
NC4_open(const char *path, int mode,
int basepe, size_t *chunksizehintp,
void* parameters, NC_Dispatch*, NC*);
void* parameters, const NC_Dispatch*, NC*);

EXTERNL int
NC4_redef(int ncid);
Expand Down
5 changes: 1 addition & 4 deletions include/nc4internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ typedef struct {
void *p; /* Pointer to VL data */
} nc_hvl_t;

extern char* nc4_atomic_name[NC_MAX_ATOMIC_TYPE+1];
extern const char* nc4_atomic_name[NC_MAX_ATOMIC_TYPE+1];

/* These functions convert between netcdf and HDF5 types. */
int nc4_get_typelen_mem(NC_FILE_INFO_T *h5, nc_type xtype, size_t *len);
Expand Down Expand Up @@ -471,7 +471,4 @@ struct NCPROVENANCE {
} propattr;
};

/* Provenance Initialization */
extern struct NCPROPINFO globalpropinfo;

#endif /* _NC4INTERNAL_ */
46 changes: 15 additions & 31 deletions include/ncdispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,23 @@ typedef struct NC_MPI_INFO {
extern int NCDISPATCH_initialize(void);
extern int NCDISPATCH_finalize(void);

extern NC_Dispatch* NC3_dispatch_table;
extern const NC_Dispatch* NC3_dispatch_table;
extern int NC3_initialize(void);
extern int NC3_finalize(void);

#ifdef ENABLE_DAP
extern NC_Dispatch* NCD2_dispatch_table;
extern const NC_Dispatch* NCD2_dispatch_table;
extern int NCD2_initialize(void);
extern int NCD2_finalize(void);
#endif
#ifdef ENABLE_DAP4
extern NC_Dispatch* NCD4_dispatch_table;
extern const NC_Dispatch* NCD4_dispatch_table;
extern int NCD4_initialize(void);
extern int NCD4_finalize(void);
#endif

#ifdef USE_PNETCDF
extern NC_Dispatch* NCP_dispatch_table;
extern const NC_Dispatch* NCP_dispatch_table;
extern int NCP_initialize(void);
extern int NCP_finalize(void);
#endif
Expand All @@ -131,23 +131,18 @@ extern int NC4_finalize(void);
#endif

#ifdef USE_HDF5
extern NC_Dispatch* HDF5_dispatch_table;
extern const NC_Dispatch* HDF5_dispatch_table;
extern int NC_HDF5_initialize(void);
extern int NC_HDF5_finalize(void);
#endif

#ifdef USE_HDF4
extern NC_Dispatch* HDF4_dispatch_table;
extern const NC_Dispatch* HDF4_dispatch_table;
extern int HDF4_initialize(void);
extern int HDF4_finalize(void);
#endif

/* Vectors of ones and zeros */
extern size_t nc_sizevector0[NC_MAX_VAR_DIMS];
extern size_t nc_sizevector1[NC_MAX_VAR_DIMS];
extern ptrdiff_t nc_ptrdiffvector1[NC_MAX_VAR_DIMS];

/* User-defined formats. */
/* User-defined formats.*/
extern NC_Dispatch* UDF0_dispatch_table;
extern char UDF0_magic_number[NC_MAX_MAGIC_NUMBER_LEN + 1];
extern NC_Dispatch* UDF1_dispatch_table;
Expand Down Expand Up @@ -199,10 +194,10 @@ int model; /* one of the NC_FORMATX #'s */

int (*create)(const char *path, int cmode,
size_t initialsz, int basepe, size_t *chunksizehintp,
void* parameters, struct NC_Dispatch* table, NC* ncp);
void* parameters, const struct NC_Dispatch* table, NC* ncp);
int (*open)(const char *path, int mode,
int basepe, size_t *chunksizehintp,
void* parameters, struct NC_Dispatch* table, NC* ncp);
void* parameters, const struct NC_Dispatch* table, NC* ncp);

int (*redef)(int);
int (*_enddef)(int,size_t,size_t,size_t,size_t);
Expand Down Expand Up @@ -319,25 +314,14 @@ int (*nc_finalize)();
typedef struct NCcommon {
int ext_ncid; /* uid << 16 */
int int_ncid; /* unspecified other id */
struct NC_Dispatch* dispatch;
const struct NC_Dispatch* dispatch;
void* dispatchdata; /* per-protocol instance data */
char* path; /* as specified at open or create */
} NCcommon;

EXTERNL size_t NC_atomictypelen(nc_type xtype);
EXTERNL char* NC_atomictypename(nc_type xtype);

#ifdef OBSOLETE
/* Provide a dispatch table overlay facility */
extern int NC_dispatch_overlay(const NC_Dispatch* overlay,
const NC_Dispatch* base,
NC_Dispatch* merge);

/* Get/set the override dispatch table */
extern NC_Dispatch* NC_get_dispatch_override(void);
extern void NC_set_dispatch_override(NC_Dispatch*);
#endif

/* Misc */

extern int NC_getshape(int ncid, int varid, int ndims, size_t* shape);
Expand All @@ -354,11 +338,11 @@ extern int NC_inq_recvar(int ncid, int varid, int* nrecdims, int* is_recdim);
#define TRACE(fname)
#endif

extern size_t NC_coord_zero[NC_MAX_VAR_DIMS];
extern size_t NC_coord_one[NC_MAX_VAR_DIMS];
/* Vectors of ones and zeros */
extern const size_t NC_coord_zero[NC_MAX_VAR_DIMS];
extern const size_t NC_coord_one[NC_MAX_VAR_DIMS];
extern const ptrdiff_t NC_stride_one[NC_MAX_VAR_DIMS];

extern int NC_argc;
extern char* NC_argv[];
extern int NC_initialized;

/**
Expand All @@ -383,7 +367,7 @@ NCDISPATCH_get_att(int ncid, int varid, const char* name, void* value, nc_type t

EXTERNL int NC_RO_create(const char *path, int cmode, size_t initialsz, int basepe,
size_t *chunksizehintp, void* parameters,
NC_Dispatch*, NC*);
const NC_Dispatch*, NC*);
EXTERNL int NC_RO_redef(int ncid);
EXTERNL int NC_RO__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree,
size_t r_align);
Expand Down
3 changes: 0 additions & 3 deletions include/nclog.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ EXTERNL void ncvlog(int tag, const char* fmt, va_list ap);
EXTERNL void nclogtext(int tag, const char* text);
EXTERNL void nclogtextn(int tag, const char* text, size_t count);

/* Provide printable names for tags */
EXTERNL void nclogsettags(char** tagset, char* dfalt);

#if defined(_CPLUSPLUS_) || defined(__CPLUSPLUS__)
}
#endif
Expand Down
5 changes: 2 additions & 3 deletions include/ncoffsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ typedef struct NCtypealignset {
NCalignment ncvlenalign; /* nc_vlen_t*/
} NCtypealignset;

size_t NC_class_alignment(int ncclass);
void NC_compute_alignments(void);
EXTERNL int NC_alignments_computed;
EXTERNL size_t NC_class_alignment(int ncclass);
EXTERNL void NC_compute_alignments(void);

#endif /*NCOFFSETS_H*/
4 changes: 2 additions & 2 deletions include/ncrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ typedef struct NCRCglobalstate {
NCRCinfo rcinfo; /* Currently only one rc file per session */
} NCRCglobalstate;

extern NCRCglobalstate ncrc_globalstate; /* singleton instance */

/* From drc.c */
extern NCRCglobalstate* ncrc_getglobalstate(void);
extern void ncrc_freeglobalstate(void);
/* read and compile the rc file, if any */
extern int NC_rcload(void);
extern char* NC_rclookup(const char* key, const char* hostport);
Expand Down
2 changes: 1 addition & 1 deletion include/ncuri.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ extern char* ncuridecode(char* s);
/* Partial decode */
extern char* ncuridecodepartial(char* s, const char* decodeset);
/* Encode using specified character set */
extern char* ncuriencodeonly(char* s, char* allowable);
extern char* ncuriencodeonly(char* s, const char* allowable);
/* Encode user or pwd */
extern char* ncuriencodeuserpwd(char* s);

Expand Down
2 changes: 0 additions & 2 deletions libdap2/cdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
extern char* ocfqn(OCddsnode);
#endif

CDFnode* v4node = NULL;

/* Forward*/
static NCerror sequencecheckr(CDFnode* node, NClist* vars, CDFnode* topseq);
static NCerror restructr(NCDAPCOMMON*, CDFnode*, CDFnode*, NClist*);
Expand Down
2 changes: 0 additions & 2 deletions libdap2/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

#include "dapdump.h"

extern CDFnode* v4node;

static NCerror buildcdftreer(NCDAPCOMMON*,OCddsnode,CDFnode*,CDFtree*,CDFnode**);
static void defdimensions(OCddsnode, CDFnode*, NCDAPCOMMON*, CDFtree*);
static NCerror attachsubsetr(CDFnode*, CDFnode*);
Expand Down
2 changes: 0 additions & 2 deletions libdap2/dapdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include "dapincludes.h"
#include "nclog.h"

int ncdap3debug = 0;

#ifdef CATCHERROR
/* Place breakpoint here to catch errors close to where they occur*/
int
Expand Down
3 changes: 3 additions & 0 deletions libdap2/dapdebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
# endif
#endif

/* Dump info about constraint processing */
#undef DCEVERBOSE

#undef PARSEDEBUG
/* Warning: setting CATCHERROR has significant performance impact */
#undef CATCHERROR
Expand Down
Loading