Add volatile declaration to shared global variables

This commit is contained in:
Eric Fischer
2015-10-20 10:15:02 -07:00
parent e4e14b2078
commit a38668a6da
+7 -6
View File
@@ -418,7 +418,7 @@ void rewrite(drawvec &geom, int z, int nextzoom, int file_maxzoom, long long *bb
} }
} }
long long write_tile(char **geoms, char *metabase, char *stringpool, int z, unsigned tx, unsigned ty, int detail, int min_detail, int basezoom, struct pool **file_keys, char **layernames, sqlite3 *outdb, double droprate, int buffer, const char *fname, FILE **geomfile, int file_minzoom, int file_maxzoom, double todo, char *geomstart, long long *along, double gamma, int nlayers, char *prevent, char *additional, int child_shards) { long long write_tile(char **geoms, char *metabase, char *stringpool, int z, unsigned tx, unsigned ty, int detail, int min_detail, int basezoom, struct pool **file_keys, char **layernames, sqlite3 *outdb, double droprate, int buffer, const char *fname, FILE **geomfile, int file_minzoom, int file_maxzoom, double todo, char *geomstart, volatile long long *along, double gamma, int nlayers, char *prevent, char *additional, int child_shards) {
int line_detail; int line_detail;
double fraction = 1; double fraction = 1;
@@ -831,7 +831,7 @@ struct write_tile_args {
int file_minzoom; int file_minzoom;
int file_maxzoom; int file_maxzoom;
double todo; double todo;
long long *along; volatile long long *along;
double gamma; double gamma;
int nlayers; int nlayers;
char *prevent; char *prevent;
@@ -839,13 +839,13 @@ struct write_tile_args {
int child_shards; int child_shards;
int *geomfd; int *geomfd;
off_t *geom_size; off_t *geom_size;
unsigned *midx; volatile unsigned *midx;
unsigned *midy; volatile unsigned *midy;
int maxzoom; int maxzoom;
int minzoom; int minzoom;
int full_detail; int full_detail;
int low_detail; int low_detail;
long long *most; volatile long long *most;
}; };
void *run_thread(void *vargs) { void *run_thread(void *vargs) {
@@ -956,7 +956,6 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpo
useful_threads++; useful_threads++;
} }
} }
printf("\n");
#define MAX_THREADS 20 // XXX Obtain from sysctl(hw.ncpu), /proc/cpuinfo, etc. #define MAX_THREADS 20 // XXX Obtain from sysctl(hw.ncpu), /proc/cpuinfo, etc.
@@ -973,6 +972,8 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpo
// Round down to a power of 2 // Round down to a power of 2
threads = 1 << (int)(log(threads) / log(2)); threads = 1 << (int)(log(threads) / log(2));
printf(" %d threads\n", threads);
// Assign temporary files to threads // Assign temporary files to threads
struct dispatch { struct dispatch {