Changeset 30767
- Timestamp:
- Mar 27, 2008, 2:06:23 PM (16 years ago)
- Location:
- grass/branches/releasebranch_6_3/raster/r.terraflow
- Files:
-
- 11 edited
-
IOStream/include/ami_stream.h (modified) (2 diffs)
-
IOStream/include/quicksort.h (modified) (1 diff)
-
IOStream/include/rtimer.h (modified) (4 diffs)
-
IOStream/lib/src/ami_stream.cc (modified) (1 diff)
-
IOStream/lib/src/mm_utils.cc (modified) (1 diff)
-
IOStream/lib/src/rtimer.cc (modified) (1 diff)
-
common.cc (modified) (1 diff)
-
flow.cc (modified) (1 diff)
-
grass2str.h (modified) (4 diffs)
-
main.cc (modified) (7 diffs)
-
stats.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
grass/branches/releasebranch_6_3/raster/r.terraflow/IOStream/include/ami_stream.h
r29785 r30767 37 37 #include "mm.h" // Get the memory manager. 38 38 39 #ifdef __MINGW32__ 40 #define getpagesize() (4096) 41 #endif 42 39 43 #define DEBUG_DELETE if(0) 40 44 … … 422 426 // Get rid of the file if not persistent and if not substream. 423 427 if ((per != PERSIST_PERSISTENT) && (substream_level == 0)) { 424 if ( unlink(path) == -1) {428 if (remove(path) == -1) { 425 429 cerr << "AMI_STREAM: failed to unlink " << path << endl; 426 430 perror("cannot unlink "); -
grass/branches/releasebranch_6_3/raster/r.terraflow/IOStream/include/quicksort.h
r25077 r30767 42 42 // Try to get a good partition value and avoid being bitten by already 43 43 // sorted input. 44 #ifdef __MINGW32__ 45 ptpart = data + (rand() % n); 46 #else 44 47 ptpart = data + (random() % n); 48 #endif 45 49 tpart = *ptpart; 46 50 *ptpart = data[0]; -
grass/branches/releasebranch_6_3/raster/r.terraflow/IOStream/include/rtimer.h
r25077 r30767 22 22 23 23 /* $Id$ */ 24 25 #ifdef __MINGW32__ 26 27 #include <time.h> 28 #include <stdio.h> 29 #include <string.h> 30 #include <strings.h> 31 32 typedef struct { 33 time_t tv1, tv2; 34 } Rtimer; 35 36 #define rt_start(rt) \ 37 if((time(&(rt.tv1)) == ((time_t) -1))) { \ 38 perror("time"); \ 39 exit(1); \ 40 } 41 42 /* doesn't really stop, just updates endtimes */ 43 #define rt_stop(rt) \ 44 if((time(&(rt.tv2)) == ((time_t) -1))) { \ 45 perror("time"); \ 46 exit(1); \ 47 } 48 49 #define rt_u_useconds(rt) rt_w_useconds(rt) 50 51 #define rt_s_useconds(rt) rt_w_useconds(rt) 52 53 #define rt_w_useconds(rt) (1.0e6 * (rt.tv2 - rt.tv1)) 54 55 #else /* __MINGW32__ */ 24 56 25 57 #include <sys/time.h> … … 49 81 exit(1); \ 50 82 } 51 52 /* not required to be called, but makes values print as 0.53 obviously a hack */54 #define rt_zero(rt) bzero(&(rt),sizeof(Rtimer));55 83 56 84 … … 73 101 (double)rt.tv1.tv_sec*1000000)) 74 102 103 #endif /* __MINGW32__ */ 104 105 /* not required to be called, but makes values print as 0. 106 obviously a hack */ 107 #define rt_zero(rt) bzero(&(rt),sizeof(Rtimer)); 108 75 109 #define rt_seconds(rt) (rt_w_useconds(rt)/1000000) 76 110 … … 79 113 char * rt_sprint_safe(char *buf, Rtimer rt); 80 114 81 82 83 115 #endif /* RTIMER_H */ -
grass/branches/releasebranch_6_3/raster/r.terraflow/IOStream/lib/src/ami_stream.cc
r25077 r30767 43 43 44 44 sprintf(tmp_path, "%s/%s_XXXXXX", base_dir, base); 45 #ifdef __MINGW32__ 46 fd = mktemp(tmp_path) ? open(tmp_path, O_CREAT|O_EXCL|O_RDWR, 0600) : -1; 47 #else 45 48 fd = mkstemp(tmp_path); 49 #endif 46 50 47 51 if (fd == -1) { -
grass/branches/releasebranch_6_3/raster/r.terraflow/IOStream/lib/src/mm_utils.cc
r25077 r30767 18 18 19 19 #include <sys/types.h> 20 #include <sys/mman.h>21 20 #include <ctype.h> 22 21 -
grass/branches/releasebranch_6_3/raster/r.terraflow/IOStream/lib/src/rtimer.cc
r25077 r30767 19 19 20 20 #include <sys/time.h> 21 #include <sys/resource.h>22 21 #include <stdio.h> 23 22 #include <string.h> -
grass/branches/releasebranch_6_3/raster/r.terraflow/common.cc
r25077 r30767 19 19 20 20 #include <sys/types.h> 21 #ifdef USE_LARGEMEM 21 22 #include <sys/mman.h> 23 #endif 22 24 #include <ctype.h> 23 25 -
grass/branches/releasebranch_6_3/raster/r.terraflow/flow.cc
r25077 r30767 65 65 exit(1); 66 66 } 67 #ifdef __MINGW32__ 68 strcpy(buf, ctime(&t)); 69 #else 67 70 ctime_r(&t, buf); 68 71 buf[24] = '\0'; 72 #endif 69 73 stats->timestamp(buf); 70 74 *stats << endl; -
grass/branches/releasebranch_6_3/raster/r.terraflow/grass2str.h
r25077 r30767 58 58 mapset = G_find_cell (cellname, ""); 59 59 if (mapset == NULL) 60 G_fatal_error ( "cell file [%s] not found", cellname);60 G_fatal_error (_("Raster map <%s> not found"), cellname); 61 61 62 62 /* open map */ 63 63 int infd; 64 64 if ( (infd = G_open_cell_old (cellname, mapset)) < 0) 65 G_fatal_error ( "Cannot open raster map [%s]", cellname);65 G_fatal_error (_("Unable to open raster map <%s>"), cellname); 66 66 67 67 /* determine map type (CELL/FCELL/DCELL) */ … … 83 83 /* read input map */ 84 84 if (G_get_raster_row (infd, inrast, i, data_type) < 0) 85 G_fatal_error ( "Could not read from <%s>, row=%d",cellname,i);85 G_fatal_error (_("Unable to read raster map <%s>, row %d"),cellname, i); 86 86 87 87 for (int j=0; j<ncols; j++) { … … 110 110 break; 111 111 default: 112 G_fatal_error(" raster type not implemented");112 G_fatal_error("Raster type not implemented"); 113 113 } 114 114 /* cout << form("(i=%d,j=%d): (%d, %f)\n",i,j,x,d); cout.flush(); */ … … 176 176 int outfd; 177 177 if ( (outfd = G_open_raster_new (cellname, mtype)) < 0) { 178 G_fatal_error ( "Could not open <%s>", cellname);178 G_fatal_error (_("Unable to create raster map <%s>"), cellname); 179 179 } 180 180 -
grass/branches/releasebranch_6_3/raster/r.terraflow/main.cc
r25077 r30767 15 15 * GNU General Public License for more details. 16 16 * 17 * TODO before GRASS 7 released: change param 'STREAM_DIR' -> 'stream_dir' 17 18 *****************************************************************************/ 18 19 … … 225 226 mapset = G_find_cell(cellname, ""); 226 227 if (mapset == NULL) { 227 G_fatal_error(_(" cell file [%s]not found"), cellname);228 G_fatal_error(_("Raster map <%s> not found"), cellname); 228 229 } 229 230 /* read cell header */ … … 284 285 /* check if filled elevation grid name is valid */ 285 286 if (G_legal_filename (opt->filled_grid) < 0) { 286 G_fatal_error(_(" [%s] is an illegalname"), opt->filled_grid);287 G_fatal_error(_("<%s> is an illegal file name"), opt->filled_grid); 287 288 } 288 289 /* check if output grid names are valid */ 289 290 if (G_legal_filename (opt->dir_grid) < 0) { 290 G_fatal_error(_(" [%s] is an illegalname"), opt->dir_grid);291 G_fatal_error(_("<%s> is an illegal file name"), opt->dir_grid); 291 292 } 292 293 if (G_legal_filename (opt->filled_grid) < 0) { 293 G_fatal_error(_(" [%s] is an illegalname"), opt->filled_grid);294 G_fatal_error(_("<%s> is an illegal file name"), opt->filled_grid); 294 295 } 295 296 if (G_legal_filename (opt->flowaccu_grid) < 0) { 296 G_fatal_error(_(" [%s] is an illegalname"), opt->flowaccu_grid);297 G_fatal_error(_("<%s> is an illegal file name"), opt->flowaccu_grid); 297 298 } 298 299 if (G_legal_filename (opt->watershed_grid) < 0) { 299 G_fatal_error(_(" [%s] is an illegalname"), opt->watershed_grid);300 G_fatal_error(_("<%s> is an illegal file name"), opt->watershed_grid); 300 301 } 301 302 #ifdef OUTPU_TCI 302 303 if (G_legal_filename (opt->tci_grid) < 0) { 303 G_fatal_error(_(" [%s] is an illegalname"), opt->tci_grid);304 G_fatal_error(_("<%s> is an illegal file name"), opt->tci_grid); 304 305 } 305 306 #endif … … 325 326 } 326 327 328 #ifdef __MINGW32__ 329 strcpy(buf, ctime(&t)); 330 #else 327 331 ctime_r(&t, buf); 328 332 buf[24] = '\0'; 333 #endif 329 334 stats->timestamp(buf); 330 335 … … 370 375 mapset = G_find_cell(cellname, ""); 371 376 if (mapset == NULL) { 372 G_fatal_error (_(" cell file [%s]not found"), cellname);377 G_fatal_error (_("Raster map <%s> not found"), cellname); 373 378 } 374 379 if (G_read_range(cellname, mapset, &r) == -1) { … … 410 415 mapset = G_find_cell(cellname, ""); 411 416 if (mapset == NULL) { 412 G_fatal_error (_(" cell file [%s]not found"), cellname);417 G_fatal_error (_("Raster map <%s> not found"), cellname); 413 418 } 414 419 if (G_read_range(cellname, mapset, &r) == -1) { … … 520 525 /* check STREAM path (the place where intermediate STREAMs are placed) */ 521 526 sprintf(buf, "%s=%s",STREAM_TMPDIR, opt->streamdir); 522 putenv(buf); 527 /* don't pass an automatic variable; putenv() isn't guaranteed to make a copy */ 528 putenv(G_store(buf)); 523 529 if (getenv(STREAM_TMPDIR) == NULL) { 524 530 fprintf(stderr, "%s:", STREAM_TMPDIR); -
grass/branches/releasebranch_6_3/raster/r.terraflow/stats.cc
r25077 r30767 22 22 #include <sys/types.h> 23 23 #include <sys/time.h> 24 #ifndef __MINGW32__ 24 25 #include <sys/resource.h> 26 #endif 25 27 #include <stdio.h> 26 28 #include <errno.h> … … 127 129 //closes fd and returns the name; 128 130 rt_start(tm); 131 #ifndef __MINGW32__ 129 132 bss = sbrk(0); 133 #endif 130 134 char buf[BUFSIZ]; 131 135 *this << freeMem(buf) << endl; … … 136 140 long 137 141 statsRecorder::freeMem() { 142 #ifdef __MINGW32__ 143 return -1; 144 #else 138 145 struct rlimit rlim; 139 146 if (getrlimit(RLIMIT_DATA, &rlim) == -1) { … … 149 156 long freeMem = rlim.rlim_cur - ((char*)sbrk(0)-(char*)bss); 150 157 return freeMem; 158 #endif /* __MINGW32__ */ 151 159 } 152 160
Note:
See TracChangeset
for help on using the changeset viewer.
