Mercurial > repos > tabletprog
view modules/dl.tp @ 360:0b83f15e819d
Update llcompile for changes to llFun syntax
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 21 Apr 2015 09:00:56 -0700 |
parents | cba0cb39517a |
children |
line wrap: on
line source
#{ includeSystemHeader: "dlfcn.h" llMessage: sym:from withVars: { handle <- obj_uint64 ptr name <- string ptr intret <- obj_uint64 ptr } andCode: :name :handle { intret <- make_object: (addr_of: obj_int64_meta) NULL 0 intret num!: (dlsym: (handle num) (name data)) intret } llMessage: open:withFlags withVars: { name <- string ptr intret <- obj_uint64 ptr flags <- obj_int32 ptr } andCode: :name :flags { intret <- make_object: (addr_of: obj_int64_meta) NULL 0 if: (name len) > 0 { intret num!: (dlopen: (name data) (flags num)) } else: { intret num!: (dlopen: NULL (flags num)) } intret } llMessage: LAZY withVars: { flagret <- obj_int32 ptr } andCode: { flagret <- make_object: (addr_of: obj_int64_meta) NULL 0 flagret num!: RTLD_LAZY flagret } llMessage: NOW withVars: { flagret <- obj_int32 ptr } andCode: { flagret <- make_object: (addr_of: obj_int64_meta) NULL 0 flagret num!: RTLD_NOW flagret } main <- :args { library <- "" func <- "main" if: (args length) > 2 { library <- args get: 1 func <- args get: 2 } else: { if: (args length) > 1 { func <- args get: 1 } } handle <- open: library withFlags: NOW print: "handle: " . handle . "\n" address <- sym: func from: handle if: (library length) > 0 { print: library . " - " . func . ": " . address . "\n" } else: { print: func . ": " . address . "\n" } 0 } }