Corrected an issue preventing gcc-4.4 from compiling netcdf.

This commit is contained in:
Ward Fisher 2016-04-26 21:09:41 +00:00
parent 81cd8ebaa6
commit 00eaa53e0b
3 changed files with 51 additions and 53 deletions

View File

@ -25,12 +25,6 @@
/* Always needed */
#include "nc.h"
#include "nc_hashmap.h"
/*#ifndef HAVE_SSIZE_T
#define ssize_t int
#endif*/
#ifndef NC_ARRAY_GROWBY
#define NC_ARRAY_GROWBY 4
#endif
@ -62,6 +56,24 @@ typedef enum {
} NCtype;
/*! Hashmap-related structs.
NOTE: 'data' is the dimid or varid which is non-negative.
we store the dimid+1 so a valid entry will have
data > 0
*/
typedef struct {
long data;
int flags;
unsigned long key;
} hEntry;
typedef struct s_hashmap {
hEntry* table;
unsigned long size;
unsigned long count;
} NC_hashmap;
/*
* NC dimension structure
*/
@ -224,6 +236,37 @@ NC_lookupvar(NC3_INFO* ncp, int varid, NC_var **varp);
/* End defined in var.c */
/* defined in nc_hashmap.c */
/** Creates a new hashmap near the given size. */
extern NC_hashmap* NC_hashmapCreate(unsigned long startsize);
/** Inserts a new element into the hashmap. */
extern void NC_hashmapAddDim(const NC_dimarray*, long data, const char *name);
/** Removes the storage for the element of the key and returns the element. */
extern long NC_hashmapRemoveDim(const NC_dimarray*, const char *name);
/** Returns the element for the key. */
extern long NC_hashmapGetDim(const NC_dimarray*, const char *name);
/** Inserts a new element into the hashmap. */
extern void NC_hashmapAddVar(const NC_vararray*, long data, const char *name);
/** Removes the storage for the element of the key and returns the element. */
extern long NC_hashmapRemoveVar(const NC_vararray*, const char *name);
/** Returns the element for the key. */
extern long NC_hashmapGetVar(const NC_vararray*, const char *name);
/** Returns the number of saved elements. */
extern unsigned long NC_hashmapCount(NC_hashmap*);
/** Removes the hashmap structure. */
extern void NC_hashmapDelete(NC_hashmap*);
/* end defined in nc_hashmap.c */
#define IS_RECVAR(vp) \
((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 )

View File

@ -2,38 +2,10 @@
#define HASHMAP_H_INCLUDED
#include <stdlib.h>
typedef struct NC_vararray NC_vararray;
typedef struct NC_dimarray NC_dimarray;
/** Hashmap structure (forward declaration) */
struct s_hashmap;
typedef struct s_hashmap NC_hashmap;
/** Creates a new hashmap near the given size. */
extern NC_hashmap* NC_hashmapCreate(unsigned long startsize);
/** Inserts a new element into the hashmap. */
extern void NC_hashmapAddDim(const NC_dimarray*, long data, const char *name);
/** Removes the storage for the element of the key and returns the element. */
extern long NC_hashmapRemoveDim(const NC_dimarray*, const char *name);
/** Returns the element for the key. */
extern long NC_hashmapGetDim(const NC_dimarray*, const char *name);
/** Inserts a new element into the hashmap. */
extern void NC_hashmapAddVar(const NC_vararray*, long data, const char *name);
/** Removes the storage for the element of the key and returns the element. */
extern long NC_hashmapRemoveVar(const NC_vararray*, const char *name);
/** Returns the element for the key. */
extern long NC_hashmapGetVar(const NC_vararray*, const char *name);
/** Returns the number of saved elements. */
extern unsigned long NC_hashmapCount(NC_hashmap*);
/** Removes the hashmap structure. */
extern void NC_hashmapDelete(NC_hashmap*);
#endif

View File

@ -1,4 +1,3 @@
#include "nc_hashmap.h"
#include "nc3internal.h"
#include <stdio.h>
@ -15,22 +14,6 @@
extern uint32_t hash_fast(const void *key, size_t length);
/* NOTE: 'data' is the dimid or varid which is non-negative.
we store the dimid+1 so a valid entry will have
data > 0
*/
typedef struct {
long data;
int flags;
unsigned long key;
} hEntry;
struct s_hashmap{
hEntry* table;
unsigned long size;
unsigned long count;
};
static int isPrime(unsigned long val)
{
int i;