Changeset 36077 in project


Ignore:
Timestamp:
08/09/18 03:29:01 (14 months ago)
Author:
Kon Lovett
Message:

add chunk-size to mapped-buffer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/5/message-digest-utils/trunk/message-digest-chunk.scm

    r36064 r36077  
    8383  message-digest-raw-chunk?
    8484  (obj message-digest-raw-chunk-object)
    85   (siz message-digest-raw-chunk-size)
     85  (siz message-digest-raw-chunk-size message-digest-raw-chunk-size-set!)
    8686  (beg message-digest-raw-chunk-start) )
    8787
     
    8989;
    9090(define (default-chunk-fileno-read-maker fd . opts)
    91   (let (
    92     (siz (optional opts (file-size fd))) )
     91  (let-optionals* opts (
     92    (siz (file-size fd))
     93    (chk (message-digest-chunk-size)) )
    9394    (if (fxzero? siz)
    9495      (lambda () #f)
    9596      (let-values (
    96         ((buffer cleanup) (mapped-buffer 'default-chunk-fileno-read-maker fd siz)) )
    97         (let (
    98           (chunk (make-message-digest-raw-chunk buffer siz 0)) )
    99           (lambda ()
    100             ;returns ptr to file-chunk until #floor
    101             ;memory-map means only 1 file-chunk
    102             (if buffer
     97        ((buffer cleanup updater) (mapped-buffer 'default-chunk-fileno-read-maker fd siz chk)) )
     98        (lambda ()
     99          ;returns ptr to file-chunk until #floor
     100          ;memory-map means only 1 file-chunk
     101          (if buffer
     102            (if updater
    103103              (begin
     104                )
     105              (let ((chunk (make-message-digest-raw-chunk buffer siz 0)))
    104106                (set! buffer #f)
    105                 chunk )
    106               (begin
    107                 (cleanup)
    108                 #f ) ) ) ) ) ) ) )
     107                chunk ) )
     108            (begin
     109              (cleanup)
     110              #f ) ) ) ) ) ) )
    109111
    110112(cond-expand
     
    117119        memory-mapped-file-pointer map/shared prot/read))
    118120
    119     (: mapped-buffer (symbol fixnum fixnum -> pointer procedure))
    120     ;
    121     (define (mapped-buffer loc fd siz)
     121    (: mapped-buffer (symbol fixnum fixnum fixnum -> pointer procedure))
     122    ;
     123    (define (mapped-buffer loc fd siz chk)
    122124      (let* (
    123125        (mmap (map-file-to-memory #f siz prot/read map/shared fd))
    124126        (ptr (memory-mapped-file-pointer mmap))
    125127        (finalize (cut unmap-file-from-memory mmap)) )
    126         (values ptr finalize) ) ) )
     128        (values ptr finalize #f) ) ) )
    127129
    128130  (else
     
    138140        "C_return( read( fd, buffer, size ) == size );") )
    139141
    140     (: mapped-buffer (symbol fixnum fixnum -> pointer procedure))
    141     ;
    142     (define (mapped-buffer loc fd siz)
     142    (: mapped-buffer (symbol fixnum fixnum fixnum -> pointer procedure))
     143    ;
     144    (define (mapped-buffer loc fd siz chk)
    143145      (let* (
    144146        (ptr (allocate siz))
     
    147149          (finalize)
    148150          (error loc "cannot read file") )
    149         (values ptr finalize) ) ) ) )
     151        (values ptr finalize #f) ) ) ) )
    150152
    151153#; ;
Note: See TracChangeset for help on using the changeset viewer.