Changeset 20397 in project


Ignore:
Timestamp:
09/18/10 02:18:49 (10 years ago)
Author:
Kon Lovett
Message:

Rel 1.1 (mod to u32 access).

Location:
release/4/hashes
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/4/hashes/tags/1.1.0/hash-utils.scm

    r19851 r20397  
    2222    make-hash-procedure
    2323    make-hash-message-digest-primitive
     24    ; reexport
    2425    unsigned-integer32-set!
    2526    unsigned-integer32-ref)
  • release/4/hashes/tags/1.1.0/hashes-support.scm

    r19826 r20397  
    4545;;;
    4646
    47 (define uint32-cptr-ref
    48   (foreign-lambda* unsigned-integer32 ((c-pointer dat))
    49     "return (*((uint32_t *) dat));"))
     47;;
    5048
    51 (define uint32-cptr-set!
    52   (foreign-lambda* void ((c-pointer dat) (unsigned-integer32 w32))
    53     "*((uint32_t *) dat) = (uint32_t) w32;"))
     49(define u32-cptr-ref
     50  (foreign-lambda* unsigned-integer32 ((c-pointer dat) (int idx))
     51    "C_return( ((uint32_t *) dat)[idx] );"))
    5452
    55 (define uint32-sptr-ref
    56   (foreign-lambda* unsigned-integer32 ((scheme-pointer dat))
    57     "return (*((uint32_t *) dat));"))
     53(define u32-cptr-set!
     54  (foreign-lambda* void ((c-pointer dat) (unsigned-integer32 w32) (int idx))
     55    "((uint32_t *) dat)[idx] = (uint32_t) w32;"))
    5856
    59 (define uint32-sptr-set!
    60   (foreign-lambda* void ((scheme-pointer dat) (unsigned-integer32 w32))
    61     "*((uint32_t *) dat) = (uint32_t) w32;"))
     57(define u32-sptr-ref
     58  (foreign-lambda* unsigned-integer32 ((scheme-pointer dat) (int idx))
     59    "C_return( ((uint32_t *) dat)[idx] );"))
    6260
    63 (define-inline (ptr-prc-for-obj obj cptr-proc sptr-proc)
    64     (if (or (pointer? obj) (locative? obj))
    65         cptr-proc
    66         sptr-proc ) )
     61(define u32-sptr-set!
     62  (foreign-lambda* void ((scheme-pointer dat) (unsigned-integer32 w32) (int idx))
     63    "((uint32_t *) dat)[idx] = (uint32_t) w32;"))
    6764
    68 (define-inline (%unsigned-integer32-set! obj num)
    69   ((ptr-prc-for-obj obj uint32-cptr-set! uint32-sptr-set!) obj num) )
     65(define-inline (ptrtyp-if obj cptr-proc sptr-proc)
     66 (if (or (pointer? obj) (locative? obj)) cptr-proc
     67    sptr-proc ) )
    7068
    71 (define-inline (%unsigned-integer32-ref obj)
    72   ((ptr-prc-for-obj obj uint32-cptr-ref uint32-sptr-ref) obj) )
     69(define-inline (%unsigned-integer32-set! obj num idx)
     70  ((ptrtyp-if obj u32-cptr-set! u32-sptr-set!) obj num idx) )
     71
     72(define-inline (%unsigned-integer32-ref obj idx)
     73  ((ptrtyp-if obj u32-cptr-ref u32-sptr-ref) obj idx) )
    7374
    7475;;;
     
    8283;;;
    8384
    84 (define (unsigned-integer32-set! obj num)
    85   (%unsigned-integer32-set! obj num) )
     85(define (unsigned-integer32-set! obj num #!optional (idx 0))
     86  (%unsigned-integer32-set! obj num idx) )
    8687
    87 (define (unsigned-integer32-ref obj)
    88   (%unsigned-integer32-ref obj) )
    89 
    90 (define hash-context-size (foreign-value "sizeof (hashctx)" int))
     88(define (unsigned-integer32-ref obj #!optional (idx 0))
     89  (%unsigned-integer32-ref obj idx) )
    9190
    9291;;
     92
     93(define hash-context-size (foreign-value "sizeof( hashctx )" int))
    9394
    9495(define ctx-hash-ref
    9596  (foreign-lambda* unsigned-integer32 ((c-pointer ctx))
    9697   "return (((hashctx *) ctx)->hash);") )
    97 
    98 ;;
    9998
    10099(define ctx-hash-set!
     
    107106        (ctx-hash-set! ctx +hash-seed+) )
    108107
    109 ;;
    110 
    111108(define (generic-final ctx result)
    112         (%unsigned-integer32-set! result (ctx-hash-ref ctx)) )
     109        (%unsigned-integer32-set! result (ctx-hash-ref ctx) 0) )
    113110
    114111) ;module hashes-support
  • release/4/hashes/tags/1.1.0/hashes.setup

    r20291 r20397  
    1313  "check-errors"          "1.12.0")
    1414
    15 (setup-shared-extension-module 'hashes-support (extension-version "1.0.1")
     15(setup-shared-extension-module 'hashes-support (extension-version "1.1.0")
    1616  #:compile-options '(
    1717    -scrutinize
     
    2121    -no-procedure-checks -no-bound-checks -no-argc-checks))
    2222
    23 (setup-shared-extension-module 'hash-utils (extension-version "1.0.1")
     23(setup-shared-extension-module 'hash-utils (extension-version "1.1.0")
    2424  #:compile-options '(
    2525    -scrutinize
     
    3232  -no-procedure-checks -no-bound-checks))
    3333
    34 (setup-shared-extension-module 'RJMXHash (extension-version "1.0.1")
     34(setup-shared-extension-module 'RJMXHash (extension-version "1.1.0")
    3535  #:compile-options hash-compile-options)
    36 (setup-shared-extension-module 'TWMXHash (extension-version "1.0.1")
     36(setup-shared-extension-module 'TWMXHash (extension-version "1.1.0")
    3737  #:compile-options hash-compile-options)
    38 (setup-shared-extension-module 'TWMGMXHash (extension-version "1.0.1")
     38(setup-shared-extension-module 'TWMGMXHash (extension-version "1.1.0")
    3939  #:compile-options hash-compile-options)
    40 (setup-shared-extension-module 'TWSHMXHash (extension-version "1.0.1")
     40(setup-shared-extension-module 'TWSHMXHash (extension-version "1.1.0")
    4141  #:compile-options hash-compile-options)
    42 (setup-shared-extension-module 'TWSHMLMXHash (extension-version "1.0.1")
     42(setup-shared-extension-module 'TWSHMLMXHash (extension-version "1.1.0")
    4343  #:compile-options hash-compile-options)
    44 (setup-shared-extension-module 'FNVHash (extension-version "1.0.1")
     44(setup-shared-extension-module 'FNVHash (extension-version "1.1.0")
    4545  #:compile-options hash-compile-options)
    46 (setup-shared-extension-module 'FNVAHash (extension-version "1.0.1")
     46(setup-shared-extension-module 'FNVAHash (extension-version "1.1.0")
    4747  #:compile-options hash-compile-options)
    48 (setup-shared-extension-module 'PHSFHash (extension-version "1.0.1")
     48(setup-shared-extension-module 'PHSFHash (extension-version "1.1.0")
    4949  #:compile-options hash-compile-options)
    50 (setup-shared-extension-module 'RSHash (extension-version "1.0.1")
     50(setup-shared-extension-module 'RSHash (extension-version "1.1.0")
    5151  #:compile-options hash-compile-options)
    52 (setup-shared-extension-module 'JSHash (extension-version "1.0.1")
     52(setup-shared-extension-module 'JSHash (extension-version "1.1.0")
    5353  #:compile-options hash-compile-options)
    54 (setup-shared-extension-module 'PJWHash (extension-version "1.0.1")
     54(setup-shared-extension-module 'PJWHash (extension-version "1.1.0")
    5555  #:compile-options hash-compile-options)
    56 (setup-shared-extension-module 'ELFHash (extension-version "1.0.1")
     56(setup-shared-extension-module 'ELFHash (extension-version "1.1.0")
    5757  #:compile-options hash-compile-options)
    58 (setup-shared-extension-module 'BKDRHash (extension-version "1.0.1")
     58(setup-shared-extension-module 'BKDRHash (extension-version "1.1.0")
    5959  #:compile-options hash-compile-options)
    60 (setup-shared-extension-module 'SDBMHash (extension-version "1.0.1")
     60(setup-shared-extension-module 'SDBMHash (extension-version "1.1.0")
    6161  #:compile-options hash-compile-options)
    62 (setup-shared-extension-module 'DJBHash (extension-version "1.0.1")
     62(setup-shared-extension-module 'DJBHash (extension-version "1.1.0")
    6363  #:compile-options hash-compile-options)
    64 (setup-shared-extension-module 'NDJBHash (extension-version "1.0.1")
     64(setup-shared-extension-module 'NDJBHash (extension-version "1.1.0")
    6565  #:compile-options hash-compile-options)
    66 (setup-shared-extension-module 'DEKHash (extension-version "1.0.1")
     66(setup-shared-extension-module 'DEKHash (extension-version "1.1.0")
    6767  #:compile-options hash-compile-options)
    68 (setup-shared-extension-module 'APHash (extension-version "1.0.1")
     68(setup-shared-extension-module 'APHash (extension-version "1.1.0")
    6969  #:compile-options hash-compile-options)
    70 (setup-shared-extension-module 'BRPHash (extension-version "1.0.1")
     70(setup-shared-extension-module 'BRPHash (extension-version "1.1.0")
    7171  #:compile-options hash-compile-options)
    72 (setup-shared-extension-module 'PYHash (extension-version "1.0.1")
     72(setup-shared-extension-module 'PYHash (extension-version "1.1.0")
    7373  #:compile-options hash-compile-options)
    74 (setup-shared-extension-module 'RJL3Hash (extension-version "1.0.1")
     74(setup-shared-extension-module 'RJL3Hash (extension-version "1.1.0")
    7575  #:compile-options hash-compile-options)
    76 (setup-shared-extension-module 'ISPLHash (extension-version "1.0.1")
     76(setup-shared-extension-module 'ISPLHash (extension-version "1.1.0")
    7777  #:compile-options hash-compile-options)
    78 (setup-shared-extension-module 'CRCHash (extension-version "1.0.1")
     78(setup-shared-extension-module 'CRCHash (extension-version "1.1.0")
    7979  #:compile-options hash-compile-options)
    80 (setup-shared-extension-module 'TWUserMixHash (extension-version "1.0.1")
     80(setup-shared-extension-module 'TWUserMixHash (extension-version "1.1.0")
    8181  #:compile-options hash-compile-options)
    8282
    83 (setup-shared-extension-module 'rabin-karp (extension-version "1.0.1")
     83(setup-shared-extension-module 'rabin-karp (extension-version "1.1.0")
    8484  #:compile-options '(
    8585    -scrutinize
     
    8888    -no-procedure-checks -no-bound-checks))
    8989
    90 (install-extension-tag 'hashes (extension-version "1.0.1"))
     90(install-extension-tag 'hashes (extension-version "1.1.0"))
  • release/4/hashes/tags/1.1.0/tests/run.scm

    r19826 r20397  
    99
    1010;;;
     11
     12(define-constant unsigned-integer32-size 4)
    1113
    1214(define TSTSTR "The large brown fox jumped over the lazy dog.")
     
    130132(test-group "Utilities"
    131133
    132   (define tstr (make-string 4))
     134  (define tstr (make-string unsigned-integer32-size))
    133135  (define bnd-hsh #f)
    134136  (define str TSTSTR)
    135137
    136   (test-assert "string" (unsigned-integer32-set! tstr (arithmetic-shift 1 31)))
    137   (test (unsigned-integer32-ref tstr) (arithmetic-shift 1 31))
     138  (test-assert "u32 set" (unsigned-integer32-set! tstr (arithmetic-shift 1 31)))
     139  (test "u32 ref" (arithmetic-shift 1 31) (unsigned-integer32-ref tstr))
    138140
    139141  (test-assert (procedure? (make-bounded-hash *RJMXHash)))
  • release/4/hashes/trunk/hash-utils.scm

    r19851 r20397  
    2222    make-hash-procedure
    2323    make-hash-message-digest-primitive
     24    ; reexport
    2425    unsigned-integer32-set!
    2526    unsigned-integer32-ref)
  • release/4/hashes/trunk/hashes-support.scm

    r19826 r20397  
    4545;;;
    4646
    47 (define uint32-cptr-ref
    48   (foreign-lambda* unsigned-integer32 ((c-pointer dat))
    49     "return (*((uint32_t *) dat));"))
     47;;
    5048
    51 (define uint32-cptr-set!
    52   (foreign-lambda* void ((c-pointer dat) (unsigned-integer32 w32))
    53     "*((uint32_t *) dat) = (uint32_t) w32;"))
     49(define u32-cptr-ref
     50  (foreign-lambda* unsigned-integer32 ((c-pointer dat) (int idx))
     51    "C_return( ((uint32_t *) dat)[idx] );"))
    5452
    55 (define uint32-sptr-ref
    56   (foreign-lambda* unsigned-integer32 ((scheme-pointer dat))
    57     "return (*((uint32_t *) dat));"))
     53(define u32-cptr-set!
     54  (foreign-lambda* void ((c-pointer dat) (unsigned-integer32 w32) (int idx))
     55    "((uint32_t *) dat)[idx] = (uint32_t) w32;"))
    5856
    59 (define uint32-sptr-set!
    60   (foreign-lambda* void ((scheme-pointer dat) (unsigned-integer32 w32))
    61     "*((uint32_t *) dat) = (uint32_t) w32;"))
     57(define u32-sptr-ref
     58  (foreign-lambda* unsigned-integer32 ((scheme-pointer dat) (int idx))
     59    "C_return( ((uint32_t *) dat)[idx] );"))
    6260
    63 (define-inline (ptr-prc-for-obj obj cptr-proc sptr-proc)
    64     (if (or (pointer? obj) (locative? obj))
    65         cptr-proc
    66         sptr-proc ) )
     61(define u32-sptr-set!
     62  (foreign-lambda* void ((scheme-pointer dat) (unsigned-integer32 w32) (int idx))
     63    "((uint32_t *) dat)[idx] = (uint32_t) w32;"))
    6764
    68 (define-inline (%unsigned-integer32-set! obj num)
    69   ((ptr-prc-for-obj obj uint32-cptr-set! uint32-sptr-set!) obj num) )
     65(define-inline (ptrtyp-if obj cptr-proc sptr-proc)
     66 (if (or (pointer? obj) (locative? obj)) cptr-proc
     67    sptr-proc ) )
    7068
    71 (define-inline (%unsigned-integer32-ref obj)
    72   ((ptr-prc-for-obj obj uint32-cptr-ref uint32-sptr-ref) obj) )
     69(define-inline (%unsigned-integer32-set! obj num idx)
     70  ((ptrtyp-if obj u32-cptr-set! u32-sptr-set!) obj num idx) )
     71
     72(define-inline (%unsigned-integer32-ref obj idx)
     73  ((ptrtyp-if obj u32-cptr-ref u32-sptr-ref) obj idx) )
    7374
    7475;;;
     
    8283;;;
    8384
    84 (define (unsigned-integer32-set! obj num)
    85   (%unsigned-integer32-set! obj num) )
     85(define (unsigned-integer32-set! obj num #!optional (idx 0))
     86  (%unsigned-integer32-set! obj num idx) )
    8687
    87 (define (unsigned-integer32-ref obj)
    88   (%unsigned-integer32-ref obj) )
    89 
    90 (define hash-context-size (foreign-value "sizeof (hashctx)" int))
     88(define (unsigned-integer32-ref obj #!optional (idx 0))
     89  (%unsigned-integer32-ref obj idx) )
    9190
    9291;;
     92
     93(define hash-context-size (foreign-value "sizeof( hashctx )" int))
    9394
    9495(define ctx-hash-ref
    9596  (foreign-lambda* unsigned-integer32 ((c-pointer ctx))
    9697   "return (((hashctx *) ctx)->hash);") )
    97 
    98 ;;
    9998
    10099(define ctx-hash-set!
     
    107106        (ctx-hash-set! ctx +hash-seed+) )
    108107
    109 ;;
    110 
    111108(define (generic-final ctx result)
    112         (%unsigned-integer32-set! result (ctx-hash-ref ctx)) )
     109        (%unsigned-integer32-set! result (ctx-hash-ref ctx) 0) )
    113110
    114111) ;module hashes-support
  • release/4/hashes/trunk/hashes.setup

    r20291 r20397  
    1313  "check-errors"          "1.12.0")
    1414
    15 (setup-shared-extension-module 'hashes-support (extension-version "1.0.1")
     15(setup-shared-extension-module 'hashes-support (extension-version "1.1.0")
    1616  #:compile-options '(
    1717    -scrutinize
     
    2121    -no-procedure-checks -no-bound-checks -no-argc-checks))
    2222
    23 (setup-shared-extension-module 'hash-utils (extension-version "1.0.1")
     23(setup-shared-extension-module 'hash-utils (extension-version "1.1.0")
    2424  #:compile-options '(
    2525    -scrutinize
     
    3232  -no-procedure-checks -no-bound-checks))
    3333
    34 (setup-shared-extension-module 'RJMXHash (extension-version "1.0.1")
     34(setup-shared-extension-module 'RJMXHash (extension-version "1.1.0")
    3535  #:compile-options hash-compile-options)
    36 (setup-shared-extension-module 'TWMXHash (extension-version "1.0.1")
     36(setup-shared-extension-module 'TWMXHash (extension-version "1.1.0")
    3737  #:compile-options hash-compile-options)
    38 (setup-shared-extension-module 'TWMGMXHash (extension-version "1.0.1")
     38(setup-shared-extension-module 'TWMGMXHash (extension-version "1.1.0")
    3939  #:compile-options hash-compile-options)
    40 (setup-shared-extension-module 'TWSHMXHash (extension-version "1.0.1")
     40(setup-shared-extension-module 'TWSHMXHash (extension-version "1.1.0")
    4141  #:compile-options hash-compile-options)
    42 (setup-shared-extension-module 'TWSHMLMXHash (extension-version "1.0.1")
     42(setup-shared-extension-module 'TWSHMLMXHash (extension-version "1.1.0")
    4343  #:compile-options hash-compile-options)
    44 (setup-shared-extension-module 'FNVHash (extension-version "1.0.1")
     44(setup-shared-extension-module 'FNVHash (extension-version "1.1.0")
    4545  #:compile-options hash-compile-options)
    46 (setup-shared-extension-module 'FNVAHash (extension-version "1.0.1")
     46(setup-shared-extension-module 'FNVAHash (extension-version "1.1.0")
    4747  #:compile-options hash-compile-options)
    48 (setup-shared-extension-module 'PHSFHash (extension-version "1.0.1")
     48(setup-shared-extension-module 'PHSFHash (extension-version "1.1.0")
    4949  #:compile-options hash-compile-options)
    50 (setup-shared-extension-module 'RSHash (extension-version "1.0.1")
     50(setup-shared-extension-module 'RSHash (extension-version "1.1.0")
    5151  #:compile-options hash-compile-options)
    52 (setup-shared-extension-module 'JSHash (extension-version "1.0.1")
     52(setup-shared-extension-module 'JSHash (extension-version "1.1.0")
    5353  #:compile-options hash-compile-options)
    54 (setup-shared-extension-module 'PJWHash (extension-version "1.0.1")
     54(setup-shared-extension-module 'PJWHash (extension-version "1.1.0")
    5555  #:compile-options hash-compile-options)
    56 (setup-shared-extension-module 'ELFHash (extension-version "1.0.1")
     56(setup-shared-extension-module 'ELFHash (extension-version "1.1.0")
    5757  #:compile-options hash-compile-options)
    58 (setup-shared-extension-module 'BKDRHash (extension-version "1.0.1")
     58(setup-shared-extension-module 'BKDRHash (extension-version "1.1.0")
    5959  #:compile-options hash-compile-options)
    60 (setup-shared-extension-module 'SDBMHash (extension-version "1.0.1")
     60(setup-shared-extension-module 'SDBMHash (extension-version "1.1.0")
    6161  #:compile-options hash-compile-options)
    62 (setup-shared-extension-module 'DJBHash (extension-version "1.0.1")
     62(setup-shared-extension-module 'DJBHash (extension-version "1.1.0")
    6363  #:compile-options hash-compile-options)
    64 (setup-shared-extension-module 'NDJBHash (extension-version "1.0.1")
     64(setup-shared-extension-module 'NDJBHash (extension-version "1.1.0")
    6565  #:compile-options hash-compile-options)
    66 (setup-shared-extension-module 'DEKHash (extension-version "1.0.1")
     66(setup-shared-extension-module 'DEKHash (extension-version "1.1.0")
    6767  #:compile-options hash-compile-options)
    68 (setup-shared-extension-module 'APHash (extension-version "1.0.1")
     68(setup-shared-extension-module 'APHash (extension-version "1.1.0")
    6969  #:compile-options hash-compile-options)
    70 (setup-shared-extension-module 'BRPHash (extension-version "1.0.1")
     70(setup-shared-extension-module 'BRPHash (extension-version "1.1.0")
    7171  #:compile-options hash-compile-options)
    72 (setup-shared-extension-module 'PYHash (extension-version "1.0.1")
     72(setup-shared-extension-module 'PYHash (extension-version "1.1.0")
    7373  #:compile-options hash-compile-options)
    74 (setup-shared-extension-module 'RJL3Hash (extension-version "1.0.1")
     74(setup-shared-extension-module 'RJL3Hash (extension-version "1.1.0")
    7575  #:compile-options hash-compile-options)
    76 (setup-shared-extension-module 'ISPLHash (extension-version "1.0.1")
     76(setup-shared-extension-module 'ISPLHash (extension-version "1.1.0")
    7777  #:compile-options hash-compile-options)
    78 (setup-shared-extension-module 'CRCHash (extension-version "1.0.1")
     78(setup-shared-extension-module 'CRCHash (extension-version "1.1.0")
    7979  #:compile-options hash-compile-options)
    80 (setup-shared-extension-module 'TWUserMixHash (extension-version "1.0.1")
     80(setup-shared-extension-module 'TWUserMixHash (extension-version "1.1.0")
    8181  #:compile-options hash-compile-options)
    8282
    83 (setup-shared-extension-module 'rabin-karp (extension-version "1.0.1")
     83(setup-shared-extension-module 'rabin-karp (extension-version "1.1.0")
    8484  #:compile-options '(
    8585    -scrutinize
     
    8888    -no-procedure-checks -no-bound-checks))
    8989
    90 (install-extension-tag 'hashes (extension-version "1.0.1"))
     90(install-extension-tag 'hashes (extension-version "1.1.0"))
  • release/4/hashes/trunk/tests/run.scm

    r19826 r20397  
    99
    1010;;;
     11
     12(define-constant unsigned-integer32-size 4)
    1113
    1214(define TSTSTR "The large brown fox jumped over the lazy dog.")
     
    130132(test-group "Utilities"
    131133
    132   (define tstr (make-string 4))
     134  (define tstr (make-string unsigned-integer32-size))
    133135  (define bnd-hsh #f)
    134136  (define str TSTSTR)
    135137
    136   (test-assert "string" (unsigned-integer32-set! tstr (arithmetic-shift 1 31)))
    137   (test (unsigned-integer32-ref tstr) (arithmetic-shift 1 31))
     138  (test-assert "u32 set" (unsigned-integer32-set! tstr (arithmetic-shift 1 31)))
     139  (test "u32 ref" (arithmetic-shift 1 31) (unsigned-integer32-ref tstr))
    138140
    139141  (test-assert (procedure? (make-bounded-hash *RJMXHash)))
Note: See TracChangeset for help on using the changeset viewer.