luajit

luajit2.0.0 — Segmentation fault: 11

China☆狼群 提交于 2020-01-03 09:22:30
问题 I use a simple example from http://lua-users.org/wiki/SimpleLuaApiExample to make a test. The sample can be statically linked with libluajit.a with a success, but this error message occurs when you run it: Segmentation fault: 11 I use LuaJIT-2.0.0 released at 2012-11-08. My OS is Mac OSX Lion 10.7.5. $ uname -a Darwin macmatoMacBook-Pro.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64 The test steps: compile luajit-2.0.0 $ cd

luajit2.0.0 — Segmentation fault: 11

自作多情 提交于 2020-01-03 09:21:34
问题 I use a simple example from http://lua-users.org/wiki/SimpleLuaApiExample to make a test. The sample can be statically linked with libluajit.a with a success, but this error message occurs when you run it: Segmentation fault: 11 I use LuaJIT-2.0.0 released at 2012-11-08. My OS is Mac OSX Lion 10.7.5. $ uname -a Darwin macmatoMacBook-Pro.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64 The test steps: compile luajit-2.0.0 $ cd

How to pass a pointer to LuaJIT ffi to be used as out argument?

流过昼夜 提交于 2020-01-01 05:18:08
问题 Assuming there is following C code: struct Foo { int dummy; } int tryToAllocateFoo(Foo ** dest); ...How to do following in LuaJIT? Foo * pFoo = NULL; tryToAllocateFoo(&pFoo); 回答1: local ffi = require 'ffi' ffi.cdef [[ struct Foo { int dummy; }; int tryToAllocateFoo(Foo ** dest); ]] local theDll = ffi.load(dllName) local pFoo = ffi.new 'struct Foo *[1]' local ok = theDll.tryToAllocateFoo(pFoo) if ok == 0 then -- Assuming it returns 0 on success print('dummy ==', pFoo[0].dummy) end 来源: https:/

使用Nginx+Lua实现waf

人走茶凉 提交于 2019-12-30 09:21:00
使用Nginx+Lua实现waf 软件包需求: 1 、Nginx兼容性【最后测试到1.13.6】 wget http://nginx.org/download/nginx-1.13.6.tar.gz 2 、PCRE为Nginx编译安装关系的依赖 wget https://jaist.dl.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.tar.gz 3 、下载luajit解释器和ngx_devel_kit以及lua-nginx-module模块 wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz wget https://github.com/simplresty/ngx_devel_kit/archive/v0.3.0.tar.gz wget https://github.com/openresty/lua-nginx-module/archive/v0.10.13.tar.gz 4 、文件解压: tar xf nginx-1.13.6.tar.gz pcre-8.42.tar.gz LuaJIT-2.0.5.tar.gz v0.3.0.tar.gz v0.10.13.tar.gz 5 、安装LuaJIT Luajit是Lua即时编译器 cd LuaJIT-2.0.5/make

Does LuaJIT support __gc for tables?

不羁岁月 提交于 2019-12-23 07:43:51
问题 Lua 5.2 (in contrast to 5.1) supports __gc for tables. Has LuaJIT borrowed this nice feature? (I did a google search, and examined LuaJIT's Change History but couldn't figure out the answer.) 回答1: Just try it: -- test.lua do local x = setmetatable({},{ __gc = function() print("works") end }) end collectgarbage("collect") collectgarbage("collect") . $ lua51 -v Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio $ lua51 test.lua $ lua52 -v Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio $

Lua: understanding table array part and hash part

故事扮演 提交于 2019-12-22 08:14:37
问题 In section 4, Tables, in The Implementation of Lua 5.0 there is and example: local t = {100, 200, 300, x = 9.3} So we have t[4] == nil . If I write t[0] = 0 , this will go to hash part . If I write t[5] = 500 where it will go? Array part or hash part ? I would eager to hear answer for Lua 5.1, Lua 5.2 and LuaJIT 2 implementation if there is difference. 回答1: Contiguous integer keys starting from 1 always go in the array part. Keys that are not positive integers always go in the hash part.

Why is LuaJIT's memory limited to 1-2 GB on 64-bit platforms?

南笙酒味 提交于 2019-12-22 05:50:31
问题 On 64-bit platforms, LuaJIT allows only up to 1-2GB of data (not counting objects allocated with malloc ). Where does this limitation come from, and why is this even less than on 32-bit platforms? 回答1: LuaJIT is designed to use 32-bit pointers. On x64 platforms the limit comes from the use of mmap and the MAP_32BIT flag. MAP_32BIT (since Linux 2.4.20, 2.6): Put the mapping into the first 2 Gigabytes of the process address space. This flag is supported only on x86-64, for 64-bit programs. It

How to check if nginx uses LuaJit and not Lua?

风流意气都作罢 提交于 2019-12-22 02:51:19
问题 I installed http-lua-module with nginx, made a script that works perfectly fine, but now I want to be sure that nginx uses LuaJit instead of Lua (because my research shows that LuaJit is faster). I added to the .bushrc those lines of code : export LD_LIBRARY_PATH=/usr/local/luajit/lib:$LD_LIBRARY_PATH export LUAJIT_LIB=/usr/local/luajit/lib export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0 I also recompiled nginx and now I just want to be sure that it uses LuaJit. 回答1: Edit your nginx

How do install libraries for both Lua5.2 and 5.1 using Luarocks?

做~自己de王妃 提交于 2019-12-20 18:05:12
问题 I am writing a small Lua project and using Luarocks to install my 3rd-party dependencies. The default Lua version on my machine is 5.2 and up to this point everything is working just fine. However, today I have stumbled across a problem that is confusing me. I want to run my program on Lua 5.1 and Luajit to see if it would also work on those versions but I am having a hard time getting Luarocks to download the appropriate versions of the dependencies. As a last resort hack, I have tried to

How to install Torch on windows 8.1?

梦想与她 提交于 2019-12-17 18:54:09
问题 Torch is a scientific computing framework with wide support for machine learning algorithms. It is easy to use and efficient, thanks to an easy and fast scripting language, LuaJIT, and an underlying C/CUDA implementation. Q: Is there a way to install torch on MS Windows 8.1? 回答1: I got it installed and running on Windows (although not 8.1, but I don't expect the process to be different) following instructions in this repository; it's now deprecated, but wasn't deprecated few months ago when I