Diff for /gforth/engine/main.c between versions 1.249 and 1.250

version 1.249, 2012/03/23 22:39:00 version 1.250, 2012/03/24 01:17:51
Line 427  void gforth_relocate(Cell *image, const Line 427  void gforth_relocate(Cell *image, const
                 }                  }
 #endif  #endif
               } else                } else
                 fprintf(stderr,"Primitive %ld used in this image at $%p (offset $%x) is not implemented by this\n engine (%s); executing this code will crash.\n",(long)CF(token), &image[i], i, PACKAGE_VERSION);                  fprintf(stderr,"Primitive %ld used in this image at %p (offset $%x) is not implemented by this\n engine (%s); executing this code will crash.\n",(long)CF(token), &image[i], i, PACKAGE_VERSION);
             }              }
           } else {            } else {
             int tok = -token & 0x1FF;              int tok = -token & 0x1FF;
Line 445  void gforth_relocate(Cell *image, const Line 445  void gforth_relocate(Cell *image, const
               }                }
 #endif  #endif
             } else              } else
               fprintf(stderr,"Primitive %lx, %d of group %d used in this image at $%p (offset $%x) is not implemented by this\n engine (%s); executing this code will crash.\n", (long)-token, tok, group, &image[i],i,PACKAGE_VERSION);                fprintf(stderr,"Primitive %lx, %d of group %d used in this image at %p (offset $%x) is not implemented by this\n engine (%s); executing this code will crash.\n", (long)-token, tok, group, &image[i],i,PACKAGE_VERSION);
           }            }
         } else {          } else {
           /* if base is > 0: 0 is a null reference so don't adjust*/            /* if base is > 0: 0 is a null reference so don't adjust*/
Line 496  static Address verbose_malloc(Cell size) Line 496  static Address verbose_malloc(Cell size)
     exit(1);      exit(1);
   }    }
   r = (Address)((((Cell)r)+(sizeof(Float)-1))&(-sizeof(Float)));    r = (Address)((((Cell)r)+(sizeof(Float)-1))&(-sizeof(Float)));
   debugp(stderr, "malloc succeeds, address=$%p\n", r);    debugp(stderr, "malloc succeeds, address=%p\n", r);
   return r;    return r;
 }  }
   
Line 504  static void *next_address=0; Line 504  static void *next_address=0;
 static void after_alloc(Address r, Cell size)  static void after_alloc(Address r, Cell size)
 {  {
   if (r != (Address)-1) {    if (r != (Address)-1) {
     debugp(stderr, "success, address=$%p\n", r);      debugp(stderr, "success, address=%p\n", r);
 #if 0  #if 0
     /* not needed now that we protect the stacks with mprotect */      /* not needed now that we protect the stacks with mprotect */
     if (pagesize != 1)      if (pagesize != 1)
Line 537  static Address alloc_mmap(Cell size) Line 537  static Address alloc_mmap(Cell size)
   void *r;    void *r;
   
 #if defined(MAP_ANON)  #if defined(MAP_ANON)
   debugp(stderr,"try mmap($%p, $%lx, ..., MAP_ANON, ...); ", next_address, size);    debugp(stderr,"try mmap(%p, $%lx, ..., MAP_ANON, ...); ", next_address, size);
   r = mmap(next_address, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE|map_noreserve, -1, 0);    r = mmap(next_address, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE|map_noreserve, -1, 0);
 #else /* !defined(MAP_ANON) */  #else /* !defined(MAP_ANON) */
   /* Ultrix (at least) does not define MAP_FILE and MAP_PRIVATE (both are    /* Ultrix (at least) does not define MAP_FILE and MAP_PRIVATE (both are
Line 551  static Address alloc_mmap(Cell size) Line 551  static Address alloc_mmap(Cell size)
     debugp(stderr, "open(\"/dev/zero\"...) failed (%s), no mmap; ",       debugp(stderr, "open(\"/dev/zero\"...) failed (%s), no mmap; ", 
               strerror(errno));                strerror(errno));
   } else {    } else {
     debugp(stderr,"try mmap($%p, $%lx, ..., MAP_FILE, dev_zero, ...); ", next_address, size);      debugp(stderr,"try mmap(%p, $%lx, ..., MAP_FILE, dev_zero, ...); ", next_address, size);
     r=mmap(next_address, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_FILE|MAP_PRIVATE|map_noreserve, dev_zero, 0);      r=mmap(next_address, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_FILE|MAP_PRIVATE|map_noreserve, dev_zero, 0);
   }    }
 #endif /* !defined(MAP_ANON) */  #endif /* !defined(MAP_ANON) */
Line 604  static void *dict_alloc_read(FILE *file, Line 604  static void *dict_alloc_read(FILE *file,
     image=alloc_mmap(dictsize);      image=alloc_mmap(dictsize);
     if (image != (void *)MAP_FAILED) {      if (image != (void *)MAP_FAILED) {
       void *image1;        void *image1;
       debugp(stderr,"try mmap($%p, $%lx, ..., MAP_FIXED|MAP_FILE, imagefile, 0); ", image, imagesize);        debugp(stderr,"try mmap(%p, $%lx, ..., MAP_FIXED|MAP_FILE, imagefile, 0); ", image, imagesize);
       image1 = mmap(image, imagesize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_FIXED|MAP_FILE|MAP_PRIVATE|map_noreserve, fileno(file), 0);        image1 = mmap(image, imagesize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_FIXED|MAP_FILE|MAP_PRIVATE|map_noreserve, fileno(file), 0);
       after_alloc(image1,dictsize);        after_alloc(image1,dictsize);
       if (image1 == (void *)MAP_FAILED)        if (image1 == (void *)MAP_FAILED)
Line 1978  Address gforth_loader(FILE *imagefile, c Line 1978  Address gforth_loader(FILE *imagefile, c
 #endif  #endif
   }    }
   else if(header.base!=imp) {    else if(header.base!=imp) {
     fprintf(stderr,"%s: Cannot load nonrelocatable image (compiled for address $%p) at address $%p\n",      fprintf(stderr,"%s: Cannot load nonrelocatable image (compiled for address %p) at address %p\n",
             progname, header.base, imp);              progname, header.base, imp);
     exit(1);      exit(1);
   }    }
Line 2074  Address gforth_alloc(Cell size) Line 2074  Address gforth_alloc(Cell size)
     exit(1);      exit(1);
   }    }
   r = (Address)((((Cell)r)+(sizeof(Float)-1))&(-sizeof(Float)));    r = (Address)((((Cell)r)+(sizeof(Float)-1))&(-sizeof(Float)));
   debugp(stderr, "malloc succeeds, address=$%p\n", r);    debugp(stderr, "malloc succeeds, address=%p\n", r);
   return r;    return r;
 }  }
 #endif  #endif

Removed from v.1.249  
changed lines
  Added in v.1.250


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>