Changeset 15869 in project for chicken/trunk/library.scm


Ignore:
Timestamp:
09/15/09 01:07:21 (10 years ago)
Author:
Kon Lovett
Message:

library Added new dynamic library sys namespace procedures
runtime Added support for non-chicken dynload, "folded" 'C_dload2' into platform indep routine
chicken Added new dynload procs
eval Made dynload flags a parameter, added new dynload routines (only a subset is "public", i.e. non-sys namespace)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/library.scm

    r15823 r15869  
    365365;;; Dynamic Load
    366366
    367 (define ##sys#literal-frame-info (##core#primitive "C_literal_frame_info"))
    368 (define ##sys#literal-frame-toplevel (##core#primitive "C_literal_frame_toplevel"))
    369 (define ##sys#literal-frame-ptable (##core#primitive "C_literal_frame_ptable"))
     367(define ##sys#dlopen-flags (##core#primitive "C_dlopen_flags"))
     368(define ##sys#set-dlopen-flags! (##core#primitive "C_set_dlopen_flags"))
     369
     370;; Arbitrary library load
     371
     372(define ##sys#dynamic-library-load (##core#primitive "C_dynamic_library_load"))
     373
     374; Dynamic Unload not available on all platforms and to be used with caution!
     375(define ##sys#dynamic-library-unload (##core#primitive "C_dynamic_library_unload"))
     376
     377;; Chicken library load
    370378
    371379(define ##sys#dload (##core#primitive "C_dload"))
    372 (define ##sys#set-dlopen-flags! (##core#primitive "C_set_dlopen_flags"))
    373 
    374 ;; Dynamic Unload not available on all platforms and to be used with caution!
     380
     381; Dynamic Unload not available on all platforms and to be used with caution!
    375382(define (##sys#dunload name)
    376   (and-let* ((r (##core#inline "C_dunload" (##sys#make-c-string name))))
     383  (and-let* (((##core#inline "C_dunload" (##sys#make-c-string name))))
    377384    (##sys#gc #t)
    378385    #t ) )
     386
     387;; Introspection of loaded libraries
     388
     389; (##sys#dynamic-library-procedure-pointer mname sname) => mname+sname-ptr or #f
     390; (##sys#dynamic-library-variable-pointer mname sname) => mname+sname-ptr or #f
     391
     392(define ##sys#dynamic-library-procedure-pointer)
     393(define ##sys#dynamic-library-variable-pointer)
     394(let ((dynlibsymptr (foreign-lambda c-pointer "C_dynamic_library_symbol"
     395                                              scheme-object scheme-object scheme-object)))
     396  (set! ##sys#dynamic-library-procedure-pointer
     397    (lambda (mname sname) (dynlibsymptr mname sname #t) ) )
     398  (set! ##sys#dynamic-library-variable-pointer
     399    (lambda (mname sname) (dynlibsymptr mname sname #f) ) ) )
     400
     401; (##sys#dynamic-library-names)
     402; => (<pathname>...)
     403; Does not return the "name" of the running program (i.e. #f)
     404
     405(define ##sys#dynamic-library-names (##core#primitive "C_dynamic_library_names"))
     406
     407; (##sys#dynamic-library-data name)
     408; => ((<dload-handle> <literal-frame-count> <ptable?>)...)
     409; <dload-handle> is a pointer to the actual dload handle or #f
     410; <literal-frame-count> is the total of entrypoints (toplevel)
     411; <ptable?> is a boolean indicating whether the lib has a ptable
     412
     413(define ##sys#dynamic-library-data (##core#primitive "C_dynamic_library_data"))
     414
     415; (##sys#chicken-library-literal-frame name handle count)
     416; => (<lf[0]>...)
     417
     418(define ##sys#chicken-library-literal-frame (##core#primitive "C_chicken_library_literal_frame"))
     419
     420; (##sys#chicken-library-ptable name handle count pointer?)
     421; => ((<ptable[0].id> . <ptable[0].ptr>)...) when pointer?
     422; => (<ptable[0].id>...) when (not pointer?)
     423
     424(define ##sys#chicken-library-ptable (##core#primitive "C_chicken_library_ptable"))
    379425
    380426
Note: See TracChangeset for help on using the changeset viewer.