Changeset 30767


Ignore:
Timestamp:
Mar 27, 2008, 2:06:23 PM (16 years ago)
Author:
neteler
Message:

MINGW32 fixed backported

Location:
grass/branches/releasebranch_6_3/raster/r.terraflow
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • grass/branches/releasebranch_6_3/raster/r.terraflow/IOStream/include/ami_stream.h

    r29785 r30767  
    3737#include "mm.h" // Get the memory manager.
    3838
     39#ifdef __MINGW32__
     40#define getpagesize() (4096)
     41#endif
     42
    3943#define DEBUG_DELETE if(0)
    4044
     
    422426  // Get rid of the file if not persistent and if not substream.
    423427  if ((per != PERSIST_PERSISTENT) && (substream_level == 0)) {
    424     if (unlink(path) == -1) {
     428    if (remove(path) == -1) {
    425429      cerr << "AMI_STREAM: failed to unlink " << path << endl;
    426430      perror("cannot unlink ");
  • grass/branches/releasebranch_6_3/raster/r.terraflow/IOStream/include/quicksort.h

    r25077 r30767  
    4242    // Try to get a good partition value and avoid being bitten by already
    4343    // sorted input.
     44#ifdef __MINGW32__
     45    ptpart = data + (rand() % n);
     46#else
    4447    ptpart = data + (random() % n);
     48#endif
    4549    tpart = *ptpart;
    4650    *ptpart = data[0];
  • grass/branches/releasebranch_6_3/raster/r.terraflow/IOStream/include/rtimer.h

    r25077 r30767  
    2222
    2323/* $Id$ */
     24
     25#ifdef __MINGW32__
     26
     27#include <time.h>
     28#include <stdio.h>
     29#include <string.h>
     30#include <strings.h>
     31
     32typedef 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__ */
    2456
    2557#include <sys/time.h>
     
    4981        exit(1);                                                                \
    5082  }
    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));
    5583       
    5684
     
    73101                 (double)rt.tv1.tv_sec*1000000))
    74102
     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
    75109#define rt_seconds(rt) (rt_w_useconds(rt)/1000000)
    76110
     
    79113char * rt_sprint_safe(char *buf, Rtimer rt);
    80114
    81 
    82 
    83115#endif /* RTIMER_H */
  • grass/branches/releasebranch_6_3/raster/r.terraflow/IOStream/lib/src/ami_stream.cc

    r25077 r30767  
    4343
    4444  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
    4548  fd  = mkstemp(tmp_path);
     49#endif
    4650
    4751  if (fd == -1) {
  • grass/branches/releasebranch_6_3/raster/r.terraflow/IOStream/lib/src/mm_utils.cc

    r25077 r30767  
    1818
    1919#include <sys/types.h>
    20 #include <sys/mman.h>
    2120#include <ctype.h>
    2221
  • grass/branches/releasebranch_6_3/raster/r.terraflow/IOStream/lib/src/rtimer.cc

    r25077 r30767  
    1919
    2020#include <sys/time.h>
    21 #include <sys/resource.h>
    2221#include <stdio.h>
    2322#include <string.h>
  • grass/branches/releasebranch_6_3/raster/r.terraflow/common.cc

    r25077 r30767  
    1919
    2020#include <sys/types.h>
     21#ifdef USE_LARGEMEM
    2122#include <sys/mman.h>
     23#endif
    2224#include <ctype.h>
    2325
  • grass/branches/releasebranch_6_3/raster/r.terraflow/flow.cc

    r25077 r30767  
    6565      exit(1);
    6666    }
     67#ifdef __MINGW32__
     68    strcpy(buf, ctime(&t));
     69#else
    6770    ctime_r(&t, buf);
    6871    buf[24] = '\0';
     72#endif
    6973    stats->timestamp(buf);
    7074    *stats << endl; 
  • grass/branches/releasebranch_6_3/raster/r.terraflow/grass2str.h

    r25077 r30767  
    5858  mapset = G_find_cell (cellname, "");
    5959  if (mapset == NULL)
    60     G_fatal_error ("cell file [%s] not found", cellname);
     60    G_fatal_error (_("Raster map <%s> not found"), cellname);
    6161 
    6262  /* open map */
    6363  int infd;
    6464  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);
    6666 
    6767  /* determine map type (CELL/FCELL/DCELL) */
     
    8383        /* read input map */
    8484    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);
    8686 
    8787        for (int j=0; j<ncols; j++) {
     
    110110                break;
    111111          default:
    112                 G_fatal_error("raster type not implemented");           
     112                G_fatal_error("Raster type not implemented");           
    113113      }
    114114          /* cout << form("(i=%d,j=%d): (%d, %f)\n",i,j,x,d); cout.flush(); */
     
    176176  int outfd;
    177177  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);
    179179  }
    180180 
  • grass/branches/releasebranch_6_3/raster/r.terraflow/main.cc

    r25077 r30767  
    1515 *  GNU General Public License for more details.
    1616 *
     17 *  TODO before GRASS 7 released: change param 'STREAM_DIR' -> 'stream_dir'
    1718 *****************************************************************************/
    1819 
     
    225226  mapset = G_find_cell(cellname, "");
    226227  if (mapset == NULL) {
    227     G_fatal_error(_("cell file [%s] not found"), cellname);
     228    G_fatal_error(_("Raster map <%s> not found"), cellname);
    228229  }
    229230  /* read cell header */
     
    284285  /* check if filled elevation grid name is  valid */
    285286  if (G_legal_filename (opt->filled_grid) < 0) {
    286     G_fatal_error(_("[%s] is an illegal name"), opt->filled_grid);
     287    G_fatal_error(_("<%s> is an illegal file name"), opt->filled_grid);
    287288  }
    288289  /* check if output grid names are valid */
    289290  if (G_legal_filename (opt->dir_grid) < 0) {
    290     G_fatal_error(_("[%s] is an illegal name"), opt->dir_grid);
     291    G_fatal_error(_("<%s> is an illegal file name"), opt->dir_grid);
    291292  }
    292293  if (G_legal_filename (opt->filled_grid) < 0) {
    293     G_fatal_error(_("[%s] is an illegal name"), opt->filled_grid);
     294    G_fatal_error(_("<%s> is an illegal file name"), opt->filled_grid);
    294295  }
    295296  if (G_legal_filename (opt->flowaccu_grid) < 0) {
    296     G_fatal_error(_("[%s] is an illegal name"), opt->flowaccu_grid);
     297    G_fatal_error(_("<%s> is an illegal file name"), opt->flowaccu_grid);
    297298  }
    298299  if (G_legal_filename (opt->watershed_grid) < 0) {
    299     G_fatal_error(_("[%s] is an illegal name"), opt->watershed_grid);
     300    G_fatal_error(_("<%s> is an illegal file name"), opt->watershed_grid);
    300301  }
    301302#ifdef OUTPU_TCI
    302303  if (G_legal_filename (opt->tci_grid) < 0) {
    303   G_fatal_error(_("[%s] is an illegal name"), opt->tci_grid);
     304  G_fatal_error(_("<%s> is an illegal file name"), opt->tci_grid);
    304305  }
    305306#endif
     
    325326  }
    326327
     328#ifdef __MINGW32__
     329  strcpy(buf, ctime(&t));
     330#else
    327331  ctime_r(&t, buf);
    328332  buf[24] = '\0';
     333#endif
    329334  stats->timestamp(buf);
    330335 
     
    370375  mapset = G_find_cell(cellname, "");
    371376  if (mapset == NULL) {
    372     G_fatal_error (_("cell file [%s] not found"), cellname);
     377    G_fatal_error (_("Raster map <%s> not found"), cellname);
    373378  }
    374379  if (G_read_range(cellname, mapset, &r) == -1) {
     
    410415  mapset = G_find_cell(cellname, "");
    411416  if (mapset == NULL) {
    412     G_fatal_error (_("cell file [%s] not found"), cellname);
     417    G_fatal_error (_("Raster map <%s> not found"), cellname);
    413418  }
    414419  if (G_read_range(cellname, mapset, &r) == -1) {
     
    520525  /* check STREAM path (the place where intermediate STREAMs are placed) */
    521526  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));
    523529  if (getenv(STREAM_TMPDIR) == NULL) {
    524530    fprintf(stderr, "%s:", STREAM_TMPDIR);
  • grass/branches/releasebranch_6_3/raster/r.terraflow/stats.cc

    r25077 r30767  
    2222#include <sys/types.h>
    2323#include <sys/time.h>
     24#ifndef __MINGW32__
    2425#include <sys/resource.h>
     26#endif
    2527#include <stdio.h>
    2628#include <errno.h>
     
    127129  //closes fd and returns the name;
    128130  rt_start(tm);
     131#ifndef __MINGW32__
    129132  bss = sbrk(0);
     133#endif
    130134  char buf[BUFSIZ];
    131135  *this << freeMem(buf) << endl;
     
    136140long
    137141statsRecorder::freeMem() {
     142#ifdef __MINGW32__
     143  return -1;
     144#else
    138145  struct rlimit rlim;
    139146  if (getrlimit(RLIMIT_DATA, &rlim) == -1) {
     
    149156  long freeMem = rlim.rlim_cur - ((char*)sbrk(0)-(char*)bss);
    150157  return freeMem;
     158#endif /* __MINGW32__ */
    151159}
    152160
Note: See TracChangeset for help on using the changeset viewer.