diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-02-07 12:32:54 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-02-07 12:32:54 +0000 |
commit | 6345e3dec1097f5ce20dc02bc1136afc353abdf4 (patch) | |
tree | 3059055946f7522a5f76f49a4e1deee427cb21dc | |
parent | ccd29a1d09fee844a38880295d5436748ced3cd4 (diff) |
LuaJITTeX: Include the bit32 library (bitlib/lbitlib.c)
git-svn-id: svn://tug.org/texlive/trunk@32907 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/web2c/Makefile.in | 62 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/ChangeLog | 7 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/am/luamisc.am | 1 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/bitlib/lbitlib.c | 287 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/luatex-api.h | 1 |
5 files changed, 343 insertions, 15 deletions
diff --git a/Build/source/texk/web2c/Makefile.in b/Build/source/texk/web2c/Makefile.in index 9bf6ca0b168..73b6d2151b1 100644 --- a/Build/source/texk/web2c/Makefile.in +++ b/Build/source/texk/web2c/Makefile.in @@ -503,6 +503,8 @@ am_libkanji_a_OBJECTS = ptexdir/libkanji_a-kanji.$(OBJEXT) libkanji_a_OBJECTS = $(am_libkanji_a_OBJECTS) libluajitmisc_a_AR = $(AR) $(ARFLAGS) libluajitmisc_a_LIBADD = +dist_libluajitmisc_a_OBJECTS = \ + luatexdir/bitlib/libluajitmisc_a-lbitlib.$(OBJEXT) am__objects_3 = \ luatexdir/luafilesystem/src/libluajitmisc_a-lfs.$(OBJEXT) \ luatexdir/luamd5/libluajitmisc_a-md5.$(OBJEXT) \ @@ -519,7 +521,8 @@ am__objects_3 = \ luatexdir/luazlib/libluajitmisc_a-lzlib.$(OBJEXT) \ luatexdir/slnunicode/libluajitmisc_a-slnunico.$(OBJEXT) nodist_libluajitmisc_a_OBJECTS = $(am__objects_3) -libluajitmisc_a_OBJECTS = $(nodist_libluajitmisc_a_OBJECTS) +libluajitmisc_a_OBJECTS = $(dist_libluajitmisc_a_OBJECTS) \ + $(nodist_libluajitmisc_a_OBJECTS) libluajitsocket_a_AR = $(AR) $(ARFLAGS) libluajitsocket_a_LIBADD = am__objects_4 = \ @@ -1399,7 +1402,8 @@ am__v_OBJCXXLD_ = $(am__v_OBJCXXLD_@AM_DEFAULT_V@) am__v_OBJCXXLD_0 = @echo " OBJCXXLD" $@; am__v_OBJCXXLD_1 = SOURCES = $(nodist_libff_a_SOURCES) $(nodist_libjitff_a_SOURCES) \ - $(libkanji_a_SOURCES) $(nodist_libluajitmisc_a_SOURCES) \ + $(libkanji_a_SOURCES) $(dist_libluajitmisc_a_SOURCES) \ + $(nodist_libluajitmisc_a_SOURCES) \ $(nodist_libluajitsocket_a_SOURCES) \ $(dist_libluajittex_a_SOURCES) \ $(nodist_libluajittex_a_SOURCES) \ @@ -1455,17 +1459,17 @@ SOURCES = $(nodist_libff_a_SOURCES) $(nodist_libjitff_a_SOURCES) \ $(nodist_wovf2ovp_SOURCES) $(nodist_wovp2ovf_SOURCES) \ $(dist_xetex_SOURCES) $(nodist_xetex_SOURCES) \ $(nodist_EXTRA_xetex_SOURCES) -DIST_SOURCES = $(libkanji_a_SOURCES) $(dist_libluajittex_a_SOURCES) \ - $(dist_libluatex_a_SOURCES) $(libmd5_a_SOURCES) \ - $(libmplib_a_SOURCES) $(am__libpdftex_a_SOURCES_DIST) \ - $(EXTRA_libpdftex_a_SOURCES) $(libukanji_a_SOURCES) \ - $(libunilib_a_SOURCES) $(am__libxetex_a_SOURCES_DIST) \ - $(dist_aleph_SOURCES) $(am__dist_eptex_SOURCES_DIST) \ - $(am__dist_etex_SOURCES_DIST) $(am__dist_euptex_SOURCES_DIST) \ - $(gftodvi_SOURCES) $(md5main_SOURCES) $(dist_mf_SOURCES) \ - $(dist_mf_nowin_SOURCES) $(pbibtex_SOURCES) \ - $(am__dist_pdftex_SOURCES_DIST) $(pdftosrc_SOURCES) \ - $(pdvitype_SOURCES) $(ppltotf_SOURCES) \ +DIST_SOURCES = $(libkanji_a_SOURCES) $(dist_libluajitmisc_a_SOURCES) \ + $(dist_libluajittex_a_SOURCES) $(dist_libluatex_a_SOURCES) \ + $(libmd5_a_SOURCES) $(libmplib_a_SOURCES) \ + $(am__libpdftex_a_SOURCES_DIST) $(EXTRA_libpdftex_a_SOURCES) \ + $(libukanji_a_SOURCES) $(libunilib_a_SOURCES) \ + $(am__libxetex_a_SOURCES_DIST) $(dist_aleph_SOURCES) \ + $(am__dist_eptex_SOURCES_DIST) $(am__dist_etex_SOURCES_DIST) \ + $(am__dist_euptex_SOURCES_DIST) $(gftodvi_SOURCES) \ + $(md5main_SOURCES) $(dist_mf_SOURCES) $(dist_mf_nowin_SOURCES) \ + $(pbibtex_SOURCES) $(am__dist_pdftex_SOURCES_DIST) \ + $(pdftosrc_SOURCES) $(pdvitype_SOURCES) $(ppltotf_SOURCES) \ $(am__dist_ptex_SOURCES_DIST) $(ptftopl_SOURCES) \ $(synctex_SOURCES) $(am__dist_tex_SOURCES_DIST) \ $(ttf2afm_SOURCES) $(EXTRA_ttf2afm_SOURCES) \ @@ -2851,6 +2855,7 @@ libluamisc_a_CFLAGS = # $(WARNING_CFLAGS) libluajitmisc_a_CFLAGS = # $(WARNING_CFLAGS) nodist_libluamisc_a_SOURCES = $(libluamisc_sources) nodist_libluajitmisc_a_SOURCES = $(libluamisc_sources) +dist_libluajitmisc_a_SOURCES = luatexdir/bitlib/lbitlib.c libluamisc_sources = \ luatexdir/luafilesystem/src/lfs.c \ luatexdir/luafilesystem/src/lfs.h \ @@ -3824,6 +3829,15 @@ libkanji.a: $(libkanji_a_OBJECTS) $(libkanji_a_DEPENDENCIES) $(EXTRA_libkanji_a_ $(AM_V_at)-rm -f libkanji.a $(AM_V_AR)$(libkanji_a_AR) libkanji.a $(libkanji_a_OBJECTS) $(libkanji_a_LIBADD) $(AM_V_at)$(RANLIB) libkanji.a +luatexdir/bitlib/$(am__dirstamp): + @$(MKDIR_P) luatexdir/bitlib + @: > luatexdir/bitlib/$(am__dirstamp) +luatexdir/bitlib/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) luatexdir/bitlib/$(DEPDIR) + @: > luatexdir/bitlib/$(DEPDIR)/$(am__dirstamp) +luatexdir/bitlib/libluajitmisc_a-lbitlib.$(OBJEXT): \ + luatexdir/bitlib/$(am__dirstamp) \ + luatexdir/bitlib/$(DEPDIR)/$(am__dirstamp) luatexdir/luafilesystem/src/$(am__dirstamp): @$(MKDIR_P) luatexdir/luafilesystem/src @: > luatexdir/luafilesystem/src/$(am__dirstamp) @@ -4859,6 +4873,7 @@ mostlyclean-compile: -rm -f euptexdir/*.$(OBJEXT) -rm -f libmd5/*.$(OBJEXT) -rm -f luatexdir/*.$(OBJEXT) + -rm -f luatexdir/bitlib/*.$(OBJEXT) -rm -f luatexdir/lua/*.$(OBJEXT) -rm -f luatexdir/luafilesystem/src/*.$(OBJEXT) -rm -f luatexdir/luafontloader/fontforge/fontforge/*.$(OBJEXT) @@ -5183,6 +5198,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@libmd5/$(DEPDIR)/md5main-md5main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@luatexdir/$(DEPDIR)/luajittex-luatex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@luatexdir/$(DEPDIR)/luatex-luatex.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@luatexdir/bitlib/$(DEPDIR)/libluajitmisc_a-lbitlib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@luatexdir/lua/$(DEPDIR)/libluajittex_a-lcallbacklib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@luatexdir/lua/$(DEPDIR)/libluajittex_a-lepdflib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@luatexdir/lua/$(DEPDIR)/libluajittex_a-lfontlib.Po@am__quote@ @@ -6717,6 +6733,20 @@ ptexdir/libkanji_a-kanji.obj: ptexdir/kanji.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libkanji_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ptexdir/libkanji_a-kanji.obj `if test -f 'ptexdir/kanji.c'; then $(CYGPATH_W) 'ptexdir/kanji.c'; else $(CYGPATH_W) '$(srcdir)/ptexdir/kanji.c'; fi` +luatexdir/bitlib/libluajitmisc_a-lbitlib.o: luatexdir/bitlib/lbitlib.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluajitmisc_a_CPPFLAGS) $(CPPFLAGS) $(libluajitmisc_a_CFLAGS) $(CFLAGS) -MT luatexdir/bitlib/libluajitmisc_a-lbitlib.o -MD -MP -MF luatexdir/bitlib/$(DEPDIR)/libluajitmisc_a-lbitlib.Tpo -c -o luatexdir/bitlib/libluajitmisc_a-lbitlib.o `test -f 'luatexdir/bitlib/lbitlib.c' || echo '$(srcdir)/'`luatexdir/bitlib/lbitlib.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) luatexdir/bitlib/$(DEPDIR)/libluajitmisc_a-lbitlib.Tpo luatexdir/bitlib/$(DEPDIR)/libluajitmisc_a-lbitlib.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='luatexdir/bitlib/lbitlib.c' object='luatexdir/bitlib/libluajitmisc_a-lbitlib.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluajitmisc_a_CPPFLAGS) $(CPPFLAGS) $(libluajitmisc_a_CFLAGS) $(CFLAGS) -c -o luatexdir/bitlib/libluajitmisc_a-lbitlib.o `test -f 'luatexdir/bitlib/lbitlib.c' || echo '$(srcdir)/'`luatexdir/bitlib/lbitlib.c + +luatexdir/bitlib/libluajitmisc_a-lbitlib.obj: luatexdir/bitlib/lbitlib.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluajitmisc_a_CPPFLAGS) $(CPPFLAGS) $(libluajitmisc_a_CFLAGS) $(CFLAGS) -MT luatexdir/bitlib/libluajitmisc_a-lbitlib.obj -MD -MP -MF luatexdir/bitlib/$(DEPDIR)/libluajitmisc_a-lbitlib.Tpo -c -o luatexdir/bitlib/libluajitmisc_a-lbitlib.obj `if test -f 'luatexdir/bitlib/lbitlib.c'; then $(CYGPATH_W) 'luatexdir/bitlib/lbitlib.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/bitlib/lbitlib.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) luatexdir/bitlib/$(DEPDIR)/libluajitmisc_a-lbitlib.Tpo luatexdir/bitlib/$(DEPDIR)/libluajitmisc_a-lbitlib.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='luatexdir/bitlib/lbitlib.c' object='luatexdir/bitlib/libluajitmisc_a-lbitlib.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluajitmisc_a_CPPFLAGS) $(CPPFLAGS) $(libluajitmisc_a_CFLAGS) $(CFLAGS) -c -o luatexdir/bitlib/libluajitmisc_a-lbitlib.obj `if test -f 'luatexdir/bitlib/lbitlib.c'; then $(CYGPATH_W) 'luatexdir/bitlib/lbitlib.c'; else $(CYGPATH_W) '$(srcdir)/luatexdir/bitlib/lbitlib.c'; fi` + luatexdir/luafilesystem/src/libluajitmisc_a-lfs.o: luatexdir/luafilesystem/src/lfs.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libluajitmisc_a_CPPFLAGS) $(CPPFLAGS) $(libluajitmisc_a_CFLAGS) $(CFLAGS) -MT luatexdir/luafilesystem/src/libluajitmisc_a-lfs.o -MD -MP -MF luatexdir/luafilesystem/src/$(DEPDIR)/libluajitmisc_a-lfs.Tpo -c -o luatexdir/luafilesystem/src/libluajitmisc_a-lfs.o `test -f 'luatexdir/luafilesystem/src/lfs.c' || echo '$(srcdir)/'`luatexdir/luafilesystem/src/lfs.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) luatexdir/luafilesystem/src/$(DEPDIR)/libluajitmisc_a-lfs.Tpo luatexdir/luafilesystem/src/$(DEPDIR)/libluajitmisc_a-lfs.Po @@ -13636,6 +13666,8 @@ distclean-generic: -rm -f libmd5/$(am__dirstamp) -rm -f luatexdir/$(DEPDIR)/$(am__dirstamp) -rm -f luatexdir/$(am__dirstamp) + -rm -f luatexdir/bitlib/$(DEPDIR)/$(am__dirstamp) + -rm -f luatexdir/bitlib/$(am__dirstamp) -rm -f luatexdir/lua/$(DEPDIR)/$(am__dirstamp) -rm -f luatexdir/lua/$(am__dirstamp) -rm -f luatexdir/luafilesystem/src/$(DEPDIR)/$(am__dirstamp) @@ -13692,7 +13724,7 @@ clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ./$(DEPDIR) alephdir/$(DEPDIR) eptexdir/$(DEPDIR) etexdir/$(DEPDIR) euptexdir/$(DEPDIR) libmd5/$(DEPDIR) luatexdir/$(DEPDIR) luatexdir/lua/$(DEPDIR) luatexdir/luafilesystem/src/$(DEPDIR) luatexdir/luafontloader/fontforge/fontforge/$(DEPDIR) luatexdir/luafontloader/fontforge/gutils/$(DEPDIR) luatexdir/luafontloader/src/$(DEPDIR) luatexdir/luamd5/$(DEPDIR) luatexdir/luapeg/$(DEPDIR) luatexdir/luaprofiler/$(DEPDIR) luatexdir/luasocket/src/$(DEPDIR) luatexdir/luazip/src/$(DEPDIR) luatexdir/luazlib/$(DEPDIR) luatexdir/slnunicode/$(DEPDIR) luatexdir/unilib/$(DEPDIR) luatexdir/utils/$(DEPDIR) mplibdir/$(DEPDIR) pdftexdir/$(DEPDIR) pdftexdir/regex/$(DEPDIR) ptexdir/$(DEPDIR) synctexdir/$(DEPDIR) uptexdir/$(DEPDIR) xetexdir/$(DEPDIR) xetexdir/image/$(DEPDIR) + -rm -rf ./$(DEPDIR) alephdir/$(DEPDIR) eptexdir/$(DEPDIR) etexdir/$(DEPDIR) euptexdir/$(DEPDIR) libmd5/$(DEPDIR) luatexdir/$(DEPDIR) luatexdir/bitlib/$(DEPDIR) luatexdir/lua/$(DEPDIR) luatexdir/luafilesystem/src/$(DEPDIR) luatexdir/luafontloader/fontforge/fontforge/$(DEPDIR) luatexdir/luafontloader/fontforge/gutils/$(DEPDIR) luatexdir/luafontloader/src/$(DEPDIR) luatexdir/luamd5/$(DEPDIR) luatexdir/luapeg/$(DEPDIR) luatexdir/luaprofiler/$(DEPDIR) luatexdir/luasocket/src/$(DEPDIR) luatexdir/luazip/src/$(DEPDIR) luatexdir/luazlib/$(DEPDIR) luatexdir/slnunicode/$(DEPDIR) luatexdir/unilib/$(DEPDIR) luatexdir/utils/$(DEPDIR) mplibdir/$(DEPDIR) pdftexdir/$(DEPDIR) pdftexdir/regex/$(DEPDIR) ptexdir/$(DEPDIR) synctexdir/$(DEPDIR) uptexdir/$(DEPDIR) xetexdir/$(DEPDIR) xetexdir/image/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags @@ -13741,7 +13773,7 @@ installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf ./$(DEPDIR) alephdir/$(DEPDIR) eptexdir/$(DEPDIR) etexdir/$(DEPDIR) euptexdir/$(DEPDIR) libmd5/$(DEPDIR) luatexdir/$(DEPDIR) luatexdir/lua/$(DEPDIR) luatexdir/luafilesystem/src/$(DEPDIR) luatexdir/luafontloader/fontforge/fontforge/$(DEPDIR) luatexdir/luafontloader/fontforge/gutils/$(DEPDIR) luatexdir/luafontloader/src/$(DEPDIR) luatexdir/luamd5/$(DEPDIR) luatexdir/luapeg/$(DEPDIR) luatexdir/luaprofiler/$(DEPDIR) luatexdir/luasocket/src/$(DEPDIR) luatexdir/luazip/src/$(DEPDIR) luatexdir/luazlib/$(DEPDIR) luatexdir/slnunicode/$(DEPDIR) luatexdir/unilib/$(DEPDIR) luatexdir/utils/$(DEPDIR) mplibdir/$(DEPDIR) pdftexdir/$(DEPDIR) pdftexdir/regex/$(DEPDIR) ptexdir/$(DEPDIR) synctexdir/$(DEPDIR) uptexdir/$(DEPDIR) xetexdir/$(DEPDIR) xetexdir/image/$(DEPDIR) + -rm -rf ./$(DEPDIR) alephdir/$(DEPDIR) eptexdir/$(DEPDIR) etexdir/$(DEPDIR) euptexdir/$(DEPDIR) libmd5/$(DEPDIR) luatexdir/$(DEPDIR) luatexdir/bitlib/$(DEPDIR) luatexdir/lua/$(DEPDIR) luatexdir/luafilesystem/src/$(DEPDIR) luatexdir/luafontloader/fontforge/fontforge/$(DEPDIR) luatexdir/luafontloader/fontforge/gutils/$(DEPDIR) luatexdir/luafontloader/src/$(DEPDIR) luatexdir/luamd5/$(DEPDIR) luatexdir/luapeg/$(DEPDIR) luatexdir/luaprofiler/$(DEPDIR) luatexdir/luasocket/src/$(DEPDIR) luatexdir/luazip/src/$(DEPDIR) luatexdir/luazlib/$(DEPDIR) luatexdir/slnunicode/$(DEPDIR) luatexdir/unilib/$(DEPDIR) luatexdir/utils/$(DEPDIR) mplibdir/$(DEPDIR) pdftexdir/$(DEPDIR) pdftexdir/regex/$(DEPDIR) ptexdir/$(DEPDIR) synctexdir/$(DEPDIR) uptexdir/$(DEPDIR) xetexdir/$(DEPDIR) xetexdir/image/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/Build/source/texk/web2c/luatexdir/ChangeLog b/Build/source/texk/web2c/luatexdir/ChangeLog index 5c1fbbb46ae..3902190dc87 100644 --- a/Build/source/texk/web2c/luatexdir/ChangeLog +++ b/Build/source/texk/web2c/luatexdir/ChangeLog @@ -1,3 +1,10 @@ +2014-02-07 Peter Breitenlohner <peb@mppmu.mpg.de> + + * bitlib/lbitlib.c (new): Copied from + ../../../libs/luajit/LuaJIT-2.0.2/src/lbitlib.c. + * lua/luatex-api.h: Declare luaopen_bit32(); + * am/luamisc.am: Add the new file. + 2014-02-06 Akira Kakuto <kakuto@fuk.kindai.ac.jp> * luatex.c: Change engine_name for luajittex. diff --git a/Build/source/texk/web2c/luatexdir/am/luamisc.am b/Build/source/texk/web2c/luatexdir/am/luamisc.am index 42f01cc5b98..849785164f5 100644 --- a/Build/source/texk/web2c/luatexdir/am/luamisc.am +++ b/Build/source/texk/web2c/luatexdir/am/luamisc.am @@ -22,6 +22,7 @@ libluajitmisc_a_CFLAGS = # $(WARNING_CFLAGS) nodist_libluamisc_a_SOURCES = $(libluamisc_sources) nodist_libluajitmisc_a_SOURCES = $(libluamisc_sources) +dist_libluajitmisc_a_SOURCES = luatexdir/bitlib/lbitlib.c libluamisc_sources = \ luatexdir/luafilesystem/src/lfs.c \ diff --git a/Build/source/texk/web2c/luatexdir/bitlib/lbitlib.c b/Build/source/texk/web2c/luatexdir/bitlib/lbitlib.c new file mode 100644 index 00000000000..5187bbff0dc --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/bitlib/lbitlib.c @@ -0,0 +1,287 @@ +/* +** $Id: lbitlib.c,v 1.16 2011/06/20 16:35:23 roberto Exp $ +** Standard library for bitwise operations +** See Copyright Notice in lua.h +*/ + +#define lbitlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + +#include "lj_obj.h" +#include "lj_state.h" + +/* http://lua-users.org/lists/lua-l/2011-01/msg01039.html */ +typedef unsigned int lua_Unsigned; +#define LUA_UNSIGNED unsigned LUA_INT32 + + +#if !defined(lua_unsigned2number) +/* on several machines, coercion from unsigned to double is slow, + so it may be worth to avoid */ +#define lua_unsigned2number(u) \ + (((u) <= (lua_Unsigned)INT_MAX) ? (lua_Number)(int)(u) : (lua_Number)( unsigned int )(u)) +#endif + +#if !defined(lua_lock) +#define lua_lock(L) ((void) 0) +#define lua_unlock(L) ((void) 0) +#endif + + +LUA_API void lua_pushunsigned (lua_State *L, lua_Unsigned u) { + lua_Number n=0; + lua_lock(L); +/* printf("u=%d,%u,%x\n",u,u,u); + printf("INT_MAX=%d %u %x, (lua_Unsigned)INT_MAX=%d %u %x (unsigned int)INT_MAX=%d %u %x\n", + INT_MAX,INT_MAX,INT_MAX, + (lua_Unsigned)INT_MAX,(lua_Unsigned)INT_MAX,(lua_Unsigned)INT_MAX, + (unsigned int)INT_MAX,(unsigned int)INT_MAX,(unsigned int)INT_MAX); + printf("((u) <= (lua_Unsigned)INT_MAX) :%d\n",(((unsigned int)u) <= (lua_Unsigned)INT_MAX)); + printf("(lua_Number)(int)(u) =%d,%u,%x\n",(lua_Number)(int)(u),(lua_Number)(int)(u),(lua_Number)(int)(u)); + printf("(lua_Number)(u) =%f,%u,%x\n",(lua_Number)(u),(lua_Number)(u),(lua_Number)(u)); + printf("u=%d,%u,%x\n",u,u,u); +*/ + /*printf("n=%d,%u,%x u=%d,%u,%x\n",n,n,n,u,u,u); */ + n = lua_unsigned2number(u); +/* printf("n=%f \n",n); + printf("u=%d %u %x n=%d %u %x\n",u,u,u,n,n,n); + printf("n=%d %u %x\n",n,n,n); + printf("u=%d,%u,%x\n",u,u,u); +*/ +/* setintptrV(L->top, n); + incr_top(L); + setnumV(L->top, n); +*/ + setnumV(L->top, n); + if (LJ_UNLIKELY(tvisnan(L->top))) + setnanV(L->top); /* Canonicalize injected NaNs. */ + incr_top(L); + /*setnvalue(L->top, n); + api_incr_top(L); + */ + lua_unlock(L); +} + + + + + + +#define luaL_checkunsigned (lua_Unsigned) luaL_checkinteger +/*#define lua_pushunsigned lua_pushinteger*/ + + + +/* number of bits to consider in a number */ +#if !defined(LUA_NBITS) +#define LUA_NBITS 32 +#endif + + +#define ALLONES (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1)) + +/* macro to trim extra bits */ +#define trim(x) ((x) & ALLONES) + + +/* builds a number with 'n' ones (1 <= n <= LUA_NBITS) */ +#define mask(n) (~((ALLONES << 1) << ((n) - 1))) + + +typedef lua_Unsigned b_uint; + + + +static b_uint andaux (lua_State *L) { + int i, n = lua_gettop(L); + b_uint r = ~(b_uint)0; +/* printf("1 r=%d,%u,%x\n",r,r,r);*/ + for (i = 1; i <= n; i++) + r &= luaL_checkunsigned(L, i); +/* printf("2 r=%d,%u,%x\n",r,r,r); + printf("3 r=%d,%u,%x\n",trim(r),trim(r),trim(r)); +*/ + return trim(r); +} + + +static int b_and (lua_State *L) { + b_uint r = andaux(L); +/* printf("4 r=%d,%u,%x\n",r,r,r);*/ + lua_pushunsigned(L, r); + return 1; +} + + +static int b_test (lua_State *L) { + b_uint r = andaux(L); + lua_pushboolean(L, r != 0); + return 1; +} + + +static int b_or (lua_State *L) { + int i, n = lua_gettop(L); + b_uint r = 0; + for (i = 1; i <= n; i++) + r |= luaL_checkunsigned(L, i); + lua_pushunsigned(L, trim(r)); + return 1; +} + + +static int b_xor (lua_State *L) { + int i, n = lua_gettop(L); + b_uint r = 0; + for (i = 1; i <= n; i++) + r ^= luaL_checkunsigned(L, i); + lua_pushunsigned(L, trim(r)); + return 1; +} + + +static int b_not (lua_State *L) { + b_uint r = ~luaL_checkunsigned(L, 1); + lua_pushunsigned(L, trim(r)); + return 1; +} + + +static int b_shift (lua_State *L, b_uint r, int i) { + if (i < 0) { /* shift right? */ + i = -i; + r = trim(r); + if (i >= LUA_NBITS) r = 0; + else r >>= i; + } + else { /* shift left */ + if (i >= LUA_NBITS) r = 0; + else r <<= i; + r = trim(r); + } + lua_pushunsigned(L, r); + return 1; +} + + +static int b_lshift (lua_State *L) { + return b_shift(L, luaL_checkunsigned(L, 1), luaL_checkint(L, 2)); +} + + +static int b_rshift (lua_State *L) { + return b_shift(L, luaL_checkunsigned(L, 1), -luaL_checkint(L, 2)); +} + + +static int b_arshift (lua_State *L) { + b_uint r = luaL_checkunsigned(L, 1); + int i = luaL_checkint(L, 2); + if (i < 0 || !(r & ((b_uint)1 << (LUA_NBITS - 1)))) + return b_shift(L, r, -i); + else { /* arithmetic shift for 'negative' number */ + if (i >= LUA_NBITS) r = ALLONES; + else + r = trim((r >> i) | ~(~(b_uint)0 >> i)); /* add signal bit */ + lua_pushunsigned(L, r); + return 1; + } +} + + +static int b_rot (lua_State *L, int i) { + b_uint r = luaL_checkunsigned(L, 1); + i &= (LUA_NBITS - 1); /* i = i % NBITS */ + r = trim(r); + r = (r << i) | (r >> (LUA_NBITS - i)); + lua_pushunsigned(L, trim(r)); + return 1; +} + + +static int b_lrot (lua_State *L) { + return b_rot(L, luaL_checkint(L, 2)); +} + + +static int b_rrot (lua_State *L) { + return b_rot(L, -luaL_checkint(L, 2)); +} + + +/* +** get field and width arguments for field-manipulation functions, +** checking whether they are valid +*/ +static int fieldargs (lua_State *L, int farg, int *width) { + int f = luaL_checkint(L, farg); + int w = luaL_optint(L, farg + 1, 1); + luaL_argcheck(L, 0 <= f, farg, "field cannot be negative"); + luaL_argcheck(L, 0 < w, farg + 1, "width must be positive"); + if (f + w > LUA_NBITS) + luaL_error(L, "trying to access non-existent bits"); + *width = w; + return f; +} + + +static int b_extract (lua_State *L) { + int w; + b_uint r = luaL_checkunsigned(L, 1); + int f = fieldargs(L, 2, &w); + r = (r >> f) & mask(w); + lua_pushunsigned(L, r); + return 1; +} + + +static int b_replace (lua_State *L) { + int w; + b_uint r = luaL_checkunsigned(L, 1); + b_uint v = luaL_checkunsigned(L, 2); + int f = fieldargs(L, 3, &w); + int m = mask(w); + v &= m; /* erase bits outside given width */ + r = (r & ~(m << f)) | (v << f); + lua_pushunsigned(L, r); + return 1; +} + + +static const luaL_Reg bitlib[] = { + {"arshift", b_arshift}, + {"band", b_and}, + {"bnot", b_not}, + {"bor", b_or}, + {"bxor", b_xor}, + {"btest", b_test}, + {"extract", b_extract}, + {"lrotate", b_lrot}, + {"lshift", b_lshift}, + {"replace", b_replace}, + {"rrotate", b_rrot}, + {"rshift", b_rshift}, + {NULL, NULL} +}; + + + +/* http://lua-users.org/lists/lua-l/2011-01/msg01039.html */ + +/*LUAMOD_API int luaopen_bit32 (lua_State *L) {*/ +/* luaL_newlib(L, bitlib);*/ +/* return 1;*/ +/*} */ + +int luaopen_bit32 (lua_State *L) { + luaL_register(L, "bit32", bitlib); + return 1; +} + + + diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h index 075c2882e90..40931941eff 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h +++ b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h @@ -71,6 +71,7 @@ extern int luaopen_zlib(lua_State * L); extern int luaopen_gzip(lua_State * L); extern int luaopen_ff(lua_State * L); extern int luaopen_profiler(lua_State * L); +extern int luaopen_bit32(lua_State * L); extern int luaopen_socket_core(lua_State * L); extern int luaopen_mime_core(lua_State * L); |