From b00638c52d42745f87388c6773d211a5b7ff9f56 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 26 Aug 2014 09:17:32 -0600 Subject: [PATCH] ffi/unsafe: changed the way `ffi-lib` uses a version number with ".dll" Add the version with a "-" before ".dll", instead of with a "." after ".dll". --- .../racket-doc/scribblings/foreign/libs.scrbl | 18 ++++++++++++++++-- racket/collects/ffi/unsafe.rkt | 7 +++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/foreign/libs.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/foreign/libs.scrbl index 0c1cdeaa66..2bec670c18 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/foreign/libs.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/foreign/libs.scrbl @@ -33,7 +33,16 @@ Normally, @item{@racket[version] is a list of versions to try in order with @racket[#f] (i.e., no version) as the last element of the list; for example, @racket['("2" #f)] indicates version 2 with a - fallback to a versionless library.} + fallback to a versionless library. + + When the library suffix as reported by @racket[(system-type + 'so-suffix)] is @filepath{.dylib}, then a version is added to + @racket[path] after a @filepath{.} and before the + @filepath{.dylib} suffix. When the library suffix is + @filepath{.dll}, then a version is added to @racket[path] after a + @filepath{-} and before the @filepath{.dll} suffix. For any + other suffix, the version number is added after the suffix plus + @filepath{.}.} ] @@ -110,7 +119,12 @@ Due to the way the operating system performs dynamic binding, loaded libraries are associated with Racket (or DrRacket) for the duration of the process. Re-evaluating @racket[ffi-lib] (or hitting the @onscreen{Run} button in DrRacket) will not force a re-load of the -corresponding library.} +corresponding library. + +@history[#:changed "6.1.0.5" @elem{Changed the way a version number is + added with a @filepath{.dll} suffix + to place it before the suffix, + instead of after.}]} @defproc[(get-ffi-obj [objname (or/c string? bytes? symbol?)] [lib (or/c ffi-lib? path-string? #f)] diff --git a/racket/collects/ffi/unsafe.rkt b/racket/collects/ffi/unsafe.rkt index 0f0c68443e..9332e653c2 100644 --- a/racket/collects/ffi/unsafe.rkt +++ b/racket/collects/ffi/unsafe.rkt @@ -104,7 +104,9 @@ (define lib-suffix (bytes->string/latin-1 (subbytes (system-type 'so-suffix) 1))) (define lib-suffix-re (regexp (string-append "\\." lib-suffix "$"))) -(define suffix-before-version? (not (equal? lib-suffix "dylib"))) +(define suffix-before-version? (and (not (equal? lib-suffix "dylib")) + (not (equal? lib-suffix "dll")))) +(define version-sep (if (equal? lib-suffix "dll") "-" ".")) (provide (protect-out (rename-out [get-ffi-lib ffi-lib])) ffi-lib? ffi-lib-name) @@ -129,7 +131,8 @@ (let* ([versions (if (list? version/s) version/s (list version/s))] [versions (map (lambda (v) (if (or (not v) (zero? (string-length v))) - "" (string-append "." v))) + "" + (string-append version-sep v))) versions)] [fullpath (lambda (p) (path->complete-path (cleanse-path p)))] [absolute? (absolute-path? name)]