Merge branch 'master' of factorcode.org:/git/factor
commit
a2b982ebbd
|
@ -1,13 +1,13 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
IN: bootstrap.image.download
|
|
||||||
USING: http.client checksums checksums.openssl splitting assocs
|
USING: http.client checksums checksums.openssl splitting assocs
|
||||||
kernel io.files bootstrap.image sequences io ;
|
kernel io.files bootstrap.image sequences io urls ;
|
||||||
|
IN: bootstrap.image.download
|
||||||
|
|
||||||
: url "http://factorcode.org/images/latest/" ;
|
: url URL" http://factorcode.org/images/latest/" ;
|
||||||
|
|
||||||
: download-checksums ( -- alist )
|
: download-checksums ( -- alist )
|
||||||
url "checksums.txt" append http-get nip
|
url "checksums.txt" >url derive-url http-get nip
|
||||||
string-lines [ " " split1 ] { } map>assoc ;
|
string-lines [ " " split1 ] { } map>assoc ;
|
||||||
|
|
||||||
: need-new-image? ( image -- ? )
|
: need-new-image? ( image -- ? )
|
||||||
|
@ -21,7 +21,10 @@ kernel io.files bootstrap.image sequences io ;
|
||||||
: download-image ( arch -- )
|
: download-image ( arch -- )
|
||||||
boot-image-name dup need-new-image? [
|
boot-image-name dup need-new-image? [
|
||||||
"Downloading " write dup write "..." print
|
"Downloading " write dup write "..." print
|
||||||
url prepend download
|
url over >url derive-url download
|
||||||
|
need-new-image? [
|
||||||
|
"Boot image corrupt, or checksums.txt on server out of date" throw
|
||||||
|
] when
|
||||||
] [
|
] [
|
||||||
"Boot image up to date" print
|
"Boot image up to date" print
|
||||||
drop
|
drop
|
||||||
|
|
19
vm/image.c
19
vm/image.c
|
@ -28,8 +28,14 @@ INLINE void load_data_heap(FILE *file, F_HEADER *h, F_PARAMETERS *p)
|
||||||
|
|
||||||
F_ZONE *tenured = &data_heap->generations[TENURED];
|
F_ZONE *tenured = &data_heap->generations[TENURED];
|
||||||
|
|
||||||
if(fread((void*)tenured->start,h->data_size,1,file) != 1)
|
long int bytes_read = fread((void*)tenured->start,1,h->data_size,file);
|
||||||
|
|
||||||
|
if(bytes_read != h->data_size)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"truncated image: %ld bytes read, %ld bytes expected\n",
|
||||||
|
bytes_read,h->data_size);
|
||||||
fatal_error("load_data_heap failed",0);
|
fatal_error("load_data_heap failed",0);
|
||||||
|
}
|
||||||
|
|
||||||
tenured->here = tenured->start + h->data_size;
|
tenured->here = tenured->start + h->data_size;
|
||||||
data_relocation_base = h->data_relocation_base;
|
data_relocation_base = h->data_relocation_base;
|
||||||
|
@ -44,9 +50,16 @@ INLINE void load_code_heap(FILE *file, F_HEADER *h, F_PARAMETERS *p)
|
||||||
|
|
||||||
init_code_heap(p->code_size);
|
init_code_heap(p->code_size);
|
||||||
|
|
||||||
if(h->code_size != 0
|
if(h->code_size != 0)
|
||||||
&& fread(first_block(&code_heap),h->code_size,1,file) != 1)
|
{
|
||||||
|
long int bytes_read = fread(first_block(&code_heap),1,h->code_size,file);
|
||||||
|
if(bytes_read != h->code_size)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"truncated image: %ld bytes read, %ld bytes expected\n",
|
||||||
|
bytes_read,h->code_size);
|
||||||
fatal_error("load_code_heap failed",0);
|
fatal_error("load_code_heap failed",0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
code_relocation_base = h->code_relocation_base;
|
code_relocation_base = h->code_relocation_base;
|
||||||
build_free_list(&code_heap,h->code_size);
|
build_free_list(&code_heap,h->code_size);
|
||||||
|
|
Loading…
Reference in New Issue