~samiam/MaraDNS

ref: 3.5.0021 MaraDNS/deadwood-github/lunacy/README.bitlib -rw-r--r-- 2.5 KiB
ca00f282 — Sam Trenholme MaraDNS release 3.5.0021 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
                                bitlib
                                ------

                   by Reuben Thomas <rrt@sc3d.org>
                 http://luaforge.net/projects/bitlib


bitlib is a C library for Lua 5.1 that provides bitwise operations. It
is copyright Reuben Thomas 2000-2009, and is released under the MIT
license, like Lua (see http://www.lua.org/copyright.html; it's
basically the same as the BSD license). There is no warranty.

Please report bugs and make suggestions to the email address above, or
use the LuaForge trackers.

Thanks to John Passaniti for his bitwise operations library, some of
whose ideas I used, to Shmuel Zeigerman for the test suite, to
Thatcher Ulrich for portability fixes, and to Enrico Tassi, John
Stiles and Eduardo Ochs for bug reports.


Installation
------------

As normal:

    ./configure && make [&& make check] [&& make install]

If you get warnings about integer constants being too large, don't
worry. They won't be used.

The following options may be of interest if you have Lua installed on
non-default paths (as you are likely to on any system supporting more
than one version of Lua):

  --libdir=DIR            Install shared library in this directory
  --with-lua-prefix=DIR   Lua files are in DIR
  --with-lua-includes=DIR Lua include files are in DIR
  --with-lua-libraries=DIR
                          Lua library files are in DIR, or "no" if not used
  --with-lua-suffix=ARG   Lua binary and library files are suffixed with ARG

For example, on Debian or Ubuntu:

  ./configure --libdir=/usr/local/lib/lua/5.1 --with-lua-includes=/usr/include/lua5.1 --with-lua-suffix=5.1 --with-lua-libraries=no


Use
---

Make sure the library is installed on your LUA_CPATH, and require it.

The library provides the constant bit.bits that gives the number of
bits that can be used in bitwise operations, and the following
functions:

bit.cast(a)        cast a to the internally-used integer type
bit.bnot(a)        returns the one's complement of a
bit.band(w1, ...)  returns the bitwise and of the w's
bit.bor(w1, ...)   returns the bitwise or of the w's
bit.bxor(w1, ...)  returns the bitwise exclusive or of the w's
bit.lshift(a, b)   returns a shifted left b places
bit.rshift(a, b)   returns a shifted logically right b places
bit.arshift(a, b)  returns a shifted arithmetically right b places

All function arguments should be integers that fit into the C type
lua_Integer.

The logical operations start with "b" for "bit" to avoid clashing with
reserved words; although "xor" isn't a reserved word, it seemed better
to use "bxor" for consistency.