add fixedpoint flavor, uses int instead of double to represent numbers

in lua.  mostly just an academic exercise, but is 300% faster on zaurus
when doing simple arithmetic

ok pedro@
This commit is contained in:
jolan 2006-01-21 01:29:40 +00:00
parent 877ffc829e
commit b9f762be69
6 changed files with 40 additions and 38 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.18 2006/01/18 11:17:03 pedro Exp $
# $OpenBSD: Makefile,v 1.19 2006/01/21 01:29:40 jolan Exp $
COMMENT= "powerful, light-weight programming language"
DISTNAME= lua-5.0.2
PKGNAME= ${DISTNAME}p4
PKGNAME= ${DISTNAME}p5
SHARED_LIBS= lua 5.0 \
lualib 5.0
CATEGORIES= lang
@ -28,12 +28,15 @@ PERMIT_DISTFILES_FTP= Yes
WANTLIB= c m edit curses
NO_REGRESS= Yes
FLAVORS=fixedpoint
FLAVOR?=
.if ${MACHINE_ARCH} != "m88k" && ${MACHINE_ARCH} != "vax"
CFLAGS+= -fPIC
ALL_TARGET+= all so sobin
.endif
MAKE_FLAGS= LIBlua_VERSION=${LIBlua_VERSION} \
MAKE_FLAGS+= LIBlua_VERSION=${LIBlua_VERSION} \
LIBlualib_VERSION=${LIBlualib_VERSION}
post-extract:
@ -45,6 +48,11 @@ post-extract:
post-patch:
@perl -pi -e 's:\@initconf@:${SYSCONFDIR}/lua/init.lua:g;' \
${WRKSRC}/src/lua/lua.c
@touch ${WRKSRC}/include/luser.h
.if ${FLAVOR:L:Mfixedpoint}
@cp -p ${FILESDIR}/luser_fixedpoint.h ${WRKSRC}/include
@echo '#include "luser_fixedpoint.h"' >> ${WRKSRC}/include/luser.h
.endif
post-build:
cd ${WRKDIST} && ${CC} ${CFLAGS} -o bin/bin2c etc/bin2c.c

View File

@ -0,0 +1,6 @@
/* $OpenBSD: luser_fixedpoint.h,v 1.1 2006/01/21 01:29:40 jolan Exp $ */
#define LUA_NUMBER int
#define LUA_NUMBER_SCAN "%d"
#define LUA_NUMBER_FMT "%d"
#define lua_str2number(s,p) ((int) strtol((s), (p), 10))

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-include_lua_h,v 1.1 2006/01/21 01:29:40 jolan Exp $
--- include/lua.h.orig Thu Mar 11 19:44:52 2004
+++ include/lua.h Fri Jan 20 03:49:39 2006
@@ -77,9 +77,7 @@ typedef int (*lua_Chunkwriter) (lua_Stat
/*
** generic extra include file
*/
-#ifdef LUA_USER_H
-#include LUA_USER_H
-#endif
+#include "luser.h"
/* type of numbers in Lua */

View File

@ -1,37 +1,7 @@
Lua is a powerful, light-weight programming language designed for
extending applications. Lua is also frequently used as a general-purpose,
stand-alone language.
extending applications. Lua is also frequently used as a
general-purpose, stand-alone language.
Lua combines simple procedural syntax (similar to Pascal) with
powerful data description constructs based on associative arrays
and extensible semantics. Lua is dynamically typed, interpreted
from bytecodes, and has automatic memory management with garbage
collection, making it ideal for configuration, scripting, and rapid
prototyping.
FLAVORs:
A fundamental concept in the design of Lua is to provide meta-mechanisms
for implementing features, instead of providing a host of features
directly in the language. For example, although Lua is not a pure
object-oriented language, it does provide meta-mechanisms for
implementing classes and inheritance. Lua's meta-mechanisms bring
an economy of concepts and keep the language small, while allowing
the semantics to be extended in unconventional ways. Extensible
semantics is a distinguishing feature of Lua.
Lua is a language engine that you can embed into your application.
This means that, besides syntax and semantics, Lua has an API that
allows the application to exchange data with Lua programs and also
to extend Lua with C functions. In this sense, Lua can be regarded
as a language framework for building domain-specific languages.
Lua is implemented as a small library of C functions, written in
ANSI C, and compiles unmodified in all known platforms. The
implementation goals are simplicity, efficiency, portability, and
low embedding cost. The result is a fast language engine with small
footprint, making it ideal in embedded systems too.
Lua was designed and implemented at TeCGraf, the Computer Graphics
Technology Group of PUC-Rio (the Pontifical Catholic University of
Rio de Janeiro in Brazil). TeCGraf is a laboratory of the Department
of Computer Science. The authors can be contacted by email at
lua@tecgraf.puc-rio.br.
fixedpoint - use integers instead of doubles for numbers

View File

@ -0,0 +1,2 @@
@comment $OpenBSD: PFRAG.fixedpoint,v 1.1 2006/01/21 01:29:40 jolan Exp $
include/luser_fixedpoint.h

View File

@ -1,10 +1,12 @@
@comment $OpenBSD: PLIST,v 1.8 2004/12/16 13:04:07 pedro Exp $
@comment $OpenBSD: PLIST,v 1.9 2006/01/21 01:29:40 jolan Exp $
bin/bin2c
bin/lua
bin/luac
include/lauxlib.h
include/lua.h
include/lualib.h
include/luser.h
%%fixedpoint%%
lib/liblua.a
lib/liblualib.a
@man man/man1/lua.1