| 22 | local function parse_ld_so_conf(conf_file) |
| 23 | -- Linux ldconfig file parser to find system library locations |
| 24 | local first, last |
| 25 | local dirs = { } |
| 26 | local file = io.open(conf_file) |
| 27 | if file == nil then |
| 28 | return dict |
| 29 | end |
| 30 | for line in io.lines(file) do |
| 31 | -- ignore comments |
| 32 | first = line:find("#", 1, true) |
| 33 | if first ~= nil then |
| 34 | line = line:sub(1, first - 1) |
| 35 | end |
| 36 | |
| 37 | if line ~= "" then |
| 38 | -- check for include files |
| 39 | first, last = line:find("include%s+") |
| 40 | if first ~= nil then |
| 41 | -- found include glob |
| 42 | local include_glob = line:sub(last + 1) |
| 43 | local includes = os.matchfiles(include_glob) |
| 44 | for _, v in ipairs(includes) do |
| 45 | dirs = table.join(dirs, parse_ld_so_conf(v)) |
| 46 | end |
| 47 | else |
| 48 | -- found an actual ld path entry |
| 49 | table.insert(dirs, line) |
| 50 | end |
| 51 | end |
| 52 | end |
| 53 | return dirs |
| 54 | end |
| 55 | |
| 117 | -- Determine if the current system is running a 64-bit architecture |
| 118 | -- |
| 119 | |
| 120 | local _64BitHostTypes = { |
| 121 | "x86_64", |
| 122 | "ia64", |
| 123 | "amd64", |
| 124 | "ppc64", |
| 125 | "powerpc64", |
| 126 | "sparc64" |
| 127 | } |
| 128 | |
| 129 | function os.is64bit() |
| 130 | |
| 131 | -- Identify the system |
| 132 | local arch |
| 133 | if _OS == "windows" then |
| 134 | arch = os.getenv("PROCESSOR_ARCHITECTURE") |
| 135 | elseif _OS == "macosx" then |
| 136 | arch = os.outputof("echo $HOSTTYPE") |
| 137 | else |
| 138 | arch = os.outputof("uname -m") |
| 139 | end |
| 140 | |
| 141 | -- Check our known 64-bit identifiers |
| 142 | arch = arch:lower() |
| 143 | for _, hosttype in ipairs(_64BitHostTypes) do |
| 144 | if arch:find(hosttype) then |
| 145 | return true |
| 146 | end |
| 147 | end |
| 148 | return false |
| 149 | end |
| 150 | |
| 151 | |
| 152 | |
| 153 | -- |