summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Glondu <steph@glondu.net>2020-01-24 15:00:46 +0100
committerStéphane Glondu <steph@glondu.net>2020-01-24 15:00:46 +0100
commitb9b15cb0caa8075c66bed4f177b797abdb5ee1bb (patch)
treeaae8102aac12756d346e357e2d425e86c5e98319
parent852896e9fcf018b7fed43a571947c06ec449010f (diff)
New upstream version 3.0.0
-rw-r--r--.depend10
-rw-r--r--.gitignore3
-rw-r--r--.travis.yml13
-rw-r--r--MANIFEST141
-rw-r--r--META.in22
-rw-r--r--Makefile.in342
-rw-r--r--README.md69
-rw-r--r--README.orig (renamed from README)2
-rw-r--r--TODO136
-rw-r--r--aclocal.m4254
-rw-r--r--benchmarks/parse_ext3_superblock.ml73
-rw-r--r--bitmatch.ml27
-rw-r--r--bitstring.opam30
-rw-r--r--bitstring_objinfo.ml50
-rw-r--r--bitstring_persistent.ml274
-rw-r--r--bitstring_persistent.mli539
-rwxr-xr-xbootstrap5
-rw-r--r--cil-tools/.depend4
-rw-r--r--cil-tools/Makefile.in129
-rw-r--r--cil-tools/bitstring-import-prefix.h18
-rw-r--r--cil-tools/bitstring_import_c.ml374
-rw-r--r--cil-tools/ext3.c27
-rw-r--r--cil-tools/ext3.ml29
-rw-r--r--cil-tools/task_struct.c26
-rw-r--r--cil-tools/task_struct.ml17
-rw-r--r--config.h.in76
-rwxr-xr-xconfigure6420
-rw-r--r--configure.ac107
-rw-r--r--coverage-report/file0000.html66
-rw-r--r--coverage-report/file0001.html1209
-rw-r--r--coverage-report/file0002.html59
-rw-r--r--coverage-report/file0003.html59
-rw-r--r--coverage-report/index.html97
-rw-r--r--coverage-report/style.css70
-rw-r--r--create_test_pattern.ml27
-rw-r--r--examples/.merlin6
-rw-r--r--examples/elf.ml8
-rw-r--r--examples/ext3_superblock.ml8
-rw-r--r--examples/gif.ml8
-rw-r--r--examples/ipv4_header.ml10
-rw-r--r--examples/jbuild50
-rw-r--r--examples/libpcap.ml36
-rw-r--r--examples/make_ipv4_header.ml14
-rw-r--r--examples/ping.ml14
-rwxr-xr-xinstall-sh507
-rw-r--r--opam27
-rw-r--r--pa_bitstring.ml1188
-rw-r--r--ppx/.merlin9
-rw-r--r--ppx/jbuild13
-rw-r--r--ppx/ppx_bitstring.ml1235
-rw-r--r--src/.merlin3
-rw-r--r--src/bitstring.ml (renamed from bitstring.ml)207
-rw-r--r--src/bitstring.mli (renamed from bitstring.mli)134
-rw-r--r--src/bitstring_c.c (renamed from bitstring_c.c)8
-rw-r--r--src/bitstring_config.ml (renamed from bitstring_config.ml.in)11
-rw-r--r--src/bitstring_types.ml (renamed from bitstring_types.ml)0
-rw-r--r--src/byteswap.h (renamed from byteswap.in.h)0
-rw-r--r--src/jbuild9
-rw-r--r--t12_signed_bytes_limits.ml36
-rw-r--r--t13_signed_byte_create.ml26
-rw-r--r--t141_signed_int_limits.ml131
-rw-r--r--t14_signed_byte_match.ml27
-rw-r--r--tests/.merlin9
-rw-r--r--tests/BitstringConstructorTest.ml146
-rw-r--r--tests/BitstringConstructorTest.mli1
-rw-r--r--tests/BitstringLegacyTest.ml1251
-rw-r--r--tests/BitstringLegacyTest.mli3
-rw-r--r--tests/BitstringParserTest.ml240
-rw-r--r--tests/BitstringParserTest.mli1
-rw-r--r--tests/BitstringQualifierTest.ml64
-rw-r--r--tests/BitstringQualifierTest.mli1
-rw-r--r--tests/bitstring_tests.ml9
-rw-r--r--tests/data/ext3_sbbin0 -> 1024 bytes
-rw-r--r--tests/data/hex1.expected (renamed from tests/80_testdata/hex1.expected)0
-rw-r--r--tests/data/hex10.expected (renamed from tests/80_testdata/hex10.expected)0
-rw-r--r--tests/data/hex1000.expected (renamed from tests/80_testdata/hex1000.expected)0
-rw-r--r--tests/data/hex11.expected (renamed from tests/80_testdata/hex11.expected)0
-rw-r--r--tests/data/hex12.expected (renamed from tests/80_testdata/hex12.expected)0
-rw-r--r--tests/data/hex127.expected (renamed from tests/80_testdata/hex127.expected)0
-rw-r--r--tests/data/hex128.expected (renamed from tests/80_testdata/hex128.expected)0
-rw-r--r--tests/data/hex13.expected (renamed from tests/80_testdata/hex13.expected)0
-rw-r--r--tests/data/hex14.expected (renamed from tests/80_testdata/hex14.expected)0
-rw-r--r--tests/data/hex15.expected (renamed from tests/80_testdata/hex15.expected)0
-rw-r--r--tests/data/hex16.expected (renamed from tests/80_testdata/hex16.expected)0
-rw-r--r--tests/data/hex2.expected (renamed from tests/80_testdata/hex2.expected)0
-rw-r--r--tests/data/hex200.expected (renamed from tests/80_testdata/hex200.expected)0
-rw-r--r--tests/data/hex3.expected (renamed from tests/80_testdata/hex3.expected)0
-rw-r--r--tests/data/hex31.expected (renamed from tests/80_testdata/hex31.expected)0
-rw-r--r--tests/data/hex32.expected (renamed from tests/80_testdata/hex32.expected)0
-rw-r--r--tests/data/hex33.expected (renamed from tests/80_testdata/hex33.expected)0
-rw-r--r--tests/data/hex34.expected (renamed from tests/80_testdata/hex34.expected)0
-rw-r--r--tests/data/hex4.expected (renamed from tests/80_testdata/hex4.expected)0
-rw-r--r--tests/data/hex47.expected (renamed from tests/80_testdata/hex47.expected)0
-rw-r--r--tests/data/hex48.expected (renamed from tests/80_testdata/hex48.expected)0
-rw-r--r--tests/data/hex49.expected (renamed from tests/80_testdata/hex49.expected)0
-rw-r--r--tests/data/hex5.expected (renamed from tests/80_testdata/hex5.expected)0
-rw-r--r--tests/data/hex50.expected (renamed from tests/80_testdata/hex50.expected)0
-rw-r--r--tests/data/hex500.expected (renamed from tests/80_testdata/hex500.expected)0
-rw-r--r--tests/data/hex6.expected (renamed from tests/80_testdata/hex6.expected)0
-rw-r--r--tests/data/hex63.expected (renamed from tests/80_testdata/hex63.expected)0
-rw-r--r--tests/data/hex64.expected (renamed from tests/80_testdata/hex64.expected)0
-rw-r--r--tests/data/hex65.expected (renamed from tests/80_testdata/hex65.expected)0
-rw-r--r--tests/data/hex66.expected (renamed from tests/80_testdata/hex66.expected)0
-rw-r--r--tests/data/hex67.expected (renamed from tests/80_testdata/hex67.expected)0
-rw-r--r--tests/data/hex7.expected (renamed from tests/80_testdata/hex7.expected)0
-rw-r--r--tests/data/hex8.expected (renamed from tests/80_testdata/hex8.expected)0
-rw-r--r--tests/data/hex9.expected (renamed from tests/80_testdata/hex9.expected)0
-rw-r--r--tests/data/net.pcapbin0 -> 114 bytes
-rw-r--r--tests/data/rnd1 (renamed from tests/80_testdata/rnd1)0
-rw-r--r--tests/data/rnd10 (renamed from tests/80_testdata/rnd10)0
-rw-r--r--tests/data/rnd1000 (renamed from tests/80_testdata/rnd1000)bin125 -> 125 bytes
-rw-r--r--tests/data/rnd11 (renamed from tests/80_testdata/rnd11)0
-rw-r--r--tests/data/rnd12 (renamed from tests/80_testdata/rnd12)0
-rw-r--r--tests/data/rnd127 (renamed from tests/80_testdata/rnd127)0
-rw-r--r--tests/data/rnd128 (renamed from tests/80_testdata/rnd128)0
-rw-r--r--tests/data/rnd13 (renamed from tests/80_testdata/rnd13)0
-rw-r--r--tests/data/rnd14 (renamed from tests/80_testdata/rnd14)0
-rw-r--r--tests/data/rnd15 (renamed from tests/80_testdata/rnd15)0
-rw-r--r--tests/data/rnd16 (renamed from tests/80_testdata/rnd16)0
-rw-r--r--tests/data/rnd2 (renamed from tests/80_testdata/rnd2)0
-rw-r--r--tests/data/rnd200 (renamed from tests/80_testdata/rnd200)0
-rw-r--r--tests/data/rnd3 (renamed from tests/80_testdata/rnd3)0
-rw-r--r--tests/data/rnd31 (renamed from tests/80_testdata/rnd31)0
-rw-r--r--tests/data/rnd32 (renamed from tests/80_testdata/rnd32)0
-rw-r--r--tests/data/rnd33 (renamed from tests/80_testdata/rnd33)0
-rw-r--r--tests/data/rnd34 (renamed from tests/80_testdata/rnd34)0
-rw-r--r--tests/data/rnd4 (renamed from tests/80_testdata/rnd4)0
-rw-r--r--tests/data/rnd47 (renamed from tests/80_testdata/rnd47)0
-rw-r--r--tests/data/rnd48 (renamed from tests/80_testdata/rnd48)0
-rw-r--r--tests/data/rnd49 (renamed from tests/80_testdata/rnd49)0
-rw-r--r--tests/data/rnd5 (renamed from tests/80_testdata/rnd5)0
-rw-r--r--tests/data/rnd50 (renamed from tests/80_testdata/rnd50)0
-rw-r--r--tests/data/rnd500 (renamed from tests/80_testdata/rnd500)bin63 -> 63 bytes
-rw-r--r--tests/data/rnd6 (renamed from tests/80_testdata/rnd6)0
-rw-r--r--tests/data/rnd63 (renamed from tests/80_testdata/rnd63)0
-rw-r--r--tests/data/rnd64 (renamed from tests/80_testdata/rnd64)0
-rw-r--r--tests/data/rnd65 (renamed from tests/80_testdata/rnd65)0
-rw-r--r--tests/data/rnd66 (renamed from tests/80_testdata/rnd66)0
-rw-r--r--tests/data/rnd67 (renamed from tests/80_testdata/rnd67)0
-rw-r--r--tests/data/rnd7 (renamed from tests/80_testdata/rnd7)0
-rw-r--r--tests/data/rnd8 (renamed from tests/80_testdata/rnd8)0
-rw-r--r--tests/data/rnd9 (renamed from tests/80_testdata/rnd9)0
-rw-r--r--tests/data/sad_face.gifbin0 -> 57167 bytes
-rw-r--r--tests/jbuild12
-rw-r--r--tests/test_01_load.ml5
-rw-r--r--tests/test_02_run.ml7
-rw-r--r--tests/test_10_match_bits.ml86
-rw-r--r--tests/test_11_match_ints.ml49
-rw-r--r--tests/test_15_extract_int.ml112
-rw-r--r--tests/test_18_extract_32_64_int.ml43
-rw-r--r--tests/test_20_varsize.ml95
-rw-r--r--tests/test_30_bitbuffer.ml66
-rw-r--r--tests/test_31_bitstring_concat.ml27
-rw-r--r--tests/test_32_bitstring_compare.ml60
-rw-r--r--tests/test_33_substring.ml20
-rw-r--r--tests/test_34_takebits.ml13
-rw-r--r--tests/test_35_load_from_file.ml56
-rw-r--r--tests/test_36_is_zeroes_ones.ml29
-rw-r--r--tests/test_40_endianexpr.ml35
-rw-r--r--tests/test_50_named_pattern.ml20
-rw-r--r--tests/test_51_open_pattern.ml17
-rw-r--r--tests/test_60_simple_offset.ml35
-rw-r--r--tests/test_61_offset_string.ml40
-rw-r--r--tests/test_62_offset_padding.ml42
-rw-r--r--tests/test_65_save_offset_to.ml47
-rw-r--r--tests/test_70_check_and_bind.ml17
-rw-r--r--tests/test_80_hexdump.ml58
-rw-r--r--tests/test_90_bind_as.ml18
-rw-r--r--tests/test_91_concat.ml74
169 files changed, 3405 insertions, 13932 deletions
diff --git a/.depend b/.depend
deleted file mode 100644
index 41833a9..0000000
--- a/.depend
+++ /dev/null
@@ -1,10 +0,0 @@
-bitstring.cmo: bitstring_types.cmo bitstring_config.cmo bitstring.cmi
-bitstring.cmx: bitstring_types.cmx bitstring_config.cmx bitstring.cmi
-bitstring.cmi:
-bitstring_objinfo.cmo: bitstring_persistent.cmi bitstring.cmi
-bitstring_objinfo.cmx: bitstring_persistent.cmx bitstring.cmx
-bitstring_persistent.cmo: bitstring.cmi bitstring_persistent.cmi
-bitstring_persistent.cmx: bitstring.cmx bitstring_persistent.cmi
-bitstring_persistent.cmi: bitstring.cmi
-create_test_pattern.cmo: bitstring_persistent.cmi
-create_test_pattern.cmx: bitstring_persistent.cmx
diff --git a/.gitignore b/.gitignore
index 3e257fa..2369ae7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,7 +8,9 @@
*.a
*.so
*.opt
+*.actual
+/_build
/autom4te.cache
/bitstring-objinfo
/bitstring_config.ml
@@ -21,4 +23,5 @@
/Makefile
/tests/80_testdata/*.actual
/tests/test.bmpp
+/bitstring.install
byteswap.h
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..b43abc3
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,13 @@
+language: c
+sudo: required
+install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh
+script: bash -ex .travis-opam.sh
+env:
+ - PACKAGE=bitstring OCAML_VERSION=4.02
+ - PACKAGE=bitstring OCAML_VERSION=4.03
+ - PACKAGE=bitstring OCAML_VERSION=4.04
+ - PACKAGE=bitstring OCAML_VERSION=4.05
+ - PACKAGE=bitstring OCAML_VERSION=4.06
+os:
+ - linux
+ - osx
diff --git a/MANIFEST b/MANIFEST
deleted file mode 100644
index 7617a9a..0000000
--- a/MANIFEST
+++ /dev/null
@@ -1,141 +0,0 @@
-aclocal.m4
-benchmarks/parse_ext3_superblock.ml
-bitmatch.ml
-bitstring.ml
-bitstring.mli
-bitstring_c.c
-bitstring_config.ml.in
-bitstring_objinfo.ml
-bitstring_persistent.ml
-bitstring_persistent.mli
-bitstring_types.ml
-bootstrap
-byteswap.in.h
-.depend
-cil-tools/bitstring_import_c.ml
-cil-tools/bitstring-import-prefix.h
-cil-tools/.depend
-cil-tools/ext3.c
-cil-tools/ext3.ml
-cil-tools/Makefile.in
-cil-tools/task_struct.c
-cil-tools/task_struct.ml
-configure.ac
-COPYING
-COPYING.LIB
-coverage-report/file0000.html
-coverage-report/file0001.html
-coverage-report/file0002.html
-coverage-report/file0003.html
-coverage-report/style.css
-coverage-report/index.html
-create_test_pattern.ml
-examples/elf.ml
-examples/ext3_sb
-examples/ext3_superblock.ml
-examples/gif.ml
-examples/ipv4_header.ml
-examples/libpcap.ml
-examples/make_ipv4_header.ml
-examples/ping.ipv4
-examples/ping.ipv6
-examples/ping.ml
-install-sh
-Makefile.in
-MANIFEST
-META.in
-README
-pa_bitstring.ml
-tests/test_01_load.ml
-tests/test_02_run.ml
-tests/test_10_match_bits.ml
-tests/test_11_match_ints.ml
-tests/test_15_extract_int.ml
-tests/test_18_extract_32_64_int.ml
-tests/test_20_varsize.ml
-tests/test_30_bitbuffer.ml
-tests/test_31_bitstring_concat.ml
-tests/test_32_bitstring_compare.ml
-tests/test_33_substring.ml
-tests/test_34_takebits.ml
-tests/test_35_load_from_file.ml
-tests/test_40_endianexpr.ml
-tests/test_50_named_pattern.ml
-tests/test_51_open_pattern.ml
-tests/test_60_simple_offset.ml
-tests/test_61_offset_string.ml
-tests/test_62_offset_padding.ml
-tests/test_65_save_offset_to.ml
-tests/test_70_check_and_bind.ml
-tests/test_80_hexdump.ml
-tests/80_testdata/hex1000.expected
-tests/80_testdata/hex10.expected
-tests/80_testdata/hex11.expected
-tests/80_testdata/hex127.expected
-tests/80_testdata/hex128.expected
-tests/80_testdata/hex12.expected
-tests/80_testdata/hex13.expected
-tests/80_testdata/hex14.expected
-tests/80_testdata/hex15.expected
-tests/80_testdata/hex16.expected
-tests/80_testdata/hex1.expected
-tests/80_testdata/hex200.expected
-tests/80_testdata/hex2.expected
-tests/80_testdata/hex31.expected
-tests/80_testdata/hex32.expected
-tests/80_testdata/hex33.expected
-tests/80_testdata/hex34.expected
-tests/80_testdata/hex3.expected
-tests/80_testdata/hex47.expected
-tests/80_testdata/hex48.expected
-tests/80_testdata/hex49.expected
-tests/80_testdata/hex4.expected
-tests/80_testdata/hex500.expected
-tests/80_testdata/hex50.expected
-tests/80_testdata/hex5.expected
-tests/80_testdata/hex63.expected
-tests/80_testdata/hex64.expected
-tests/80_testdata/hex65.expected
-tests/80_testdata/hex66.expected
-tests/80_testdata/hex67.expected
-tests/80_testdata/hex6.expected
-tests/80_testdata/hex7.expected
-tests/80_testdata/hex8.expected
-tests/80_testdata/hex9.expected
-tests/80_testdata/rnd1
-tests/80_testdata/rnd10
-tests/80_testdata/rnd1000
-tests/80_testdata/rnd11
-tests/80_testdata/rnd12
-tests/80_testdata/rnd127
-tests/80_testdata/rnd128
-tests/80_testdata/rnd13
-tests/80_testdata/rnd14
-tests/80_testdata/rnd15
-tests/80_testdata/rnd16
-tests/80_testdata/rnd2
-tests/80_testdata/rnd200
-tests/80_testdata/rnd3
-tests/80_testdata/rnd31
-tests/80_testdata/rnd32
-tests/80_testdata/rnd33
-tests/80_testdata/rnd34
-tests/80_testdata/rnd4
-tests/80_testdata/rnd47
-tests/80_testdata/rnd48
-tests/80_testdata/rnd49
-tests/80_testdata/rnd5
-tests/80_testdata/rnd50
-tests/80_testdata/rnd500
-tests/80_testdata/rnd6
-tests/80_testdata/rnd63
-tests/80_testdata/rnd64
-tests/80_testdata/rnd65
-tests/80_testdata/rnd66
-tests/80_testdata/rnd67
-tests/80_testdata/rnd7
-tests/80_testdata/rnd8
-tests/80_testdata/rnd9
-tests/test_90_bind_as.ml
-tests/test_91_concat.ml
-TODO
diff --git a/META.in b/META.in
deleted file mode 100644
index 6b14f17..0000000
--- a/META.in
+++ /dev/null
@@ -1,22 +0,0 @@
-name = "bitstring"
-version = "@PACKAGE_VERSION@"
-description = "Bitstrings and bitstring matching"
-requires = "unix"
-archive(byte) = "bitstring.cma"
-archive(native) = "bitstring.cmxa"
-
-package "persistent" (
- requires = "bitstring"
- version = "@PACKAGE_VERSION@"
- description = "Persistent patterns for bitstring (requires camlp4)"
- archive(byte) = "bitstring_persistent.cma"
- archive(native) = "bitstring_persistent.cmxa"
-)
-
-package "syntax" (
- version = "@PACKAGE_VERSION@"
- requires = "camlp4"
- description = "Syntax extension: bitstring operators"
- archive(syntax,preprocessor) = "-parser o -parser op -printer p unix.cma bitstring.cma bitstring_persistent.cma pa_bitstring.cmo"
- archive(syntax,toploop) = "unix.cma bitstring.cma bitstring_persistent.cma pa_bitstring.cmo"
-)
diff --git a/Makefile.in b/Makefile.in
deleted file mode 100644
index d040f4c..0000000
--- a/Makefile.in
+++ /dev/null
@@ -1,342 +0,0 @@
-# Bitstring syntax extension.
-# Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# $Id$
-
-PACKAGE = @PACKAGE_NAME@
-VERSION = @PACKAGE_VERSION@
-
-OCAMLFIND = @OCAMLFIND@
-OCAMLMKLIB = @OCAMLMKLIB@
-OCAMLDOC = @OCAMLDOC@
-INSTALL = @INSTALL@
-TIME = @TIME@
-GPROF = @GPROF@
-SED = @SED@
-BISECT_REPORT = @BISECT_REPORT@
-
-BYTESWAP_H = @BYTESWAP_H@
-
-OCAMLLIB = @OCAMLLIB@
-top_srcdir = @top_srcdir@
-
-pkg_cil = @OCAML_PKG_cil@
-pkg_extlib = @OCAML_PKG_extlib@
-
-enable_coverage = @enable_coverage@
-
-OCAMLCFLAGS = -g
-OCAMLCPACKAGES =
-OCAMLCLIBS = -linkpkg
-OCAMLOPTFLAGS = $(OCAMLCFLAGS)
-OCAMLOPTPACKAGES = $(OCAMLCPACKAGES)
-OCAMLOPTLIBS = -linkpkg
-
-ifneq ($(enable_coverage),no)
-OCAMLCFLAGS += -I +bisect -pp 'camlp4o $(OCAMLLIB)/bisect/instrument.cma'
-OCAMLCLIBS += -I +bisect bisect.cma
-OCAMLOPTFLAGS += -I +bisect -pp 'camlp4o $(OCAMLLIB)/bisect/instrument.cma'
-OCAMLOPTLIBS += -I +bisect bisect.cmxa
-endif
-
-OCAMLDOCFLAGS = -html -sort
-
-CC = @CC@
-CFLAGS = @CFLAGS@ -Wall -Werror -fPIC -I$(top_srcdir) -I$(OCAMLLIB)
-
-LIBRARY_PATH = @abs_top_builddir@
-LD_LIBRARY_PATH = @abs_top_builddir@
-export LIBRARY_PATH
-export LD_LIBRARY_PATH
-
-SUBDIRS =
-ifneq ($(pkg_cil),no)
-ifneq ($(pkg_extlib),no)
-SUBDIRS += cil-tools
-endif
-endif
-
-EXAMPLES = $(patsubst %.ml,%,$(wildcard examples/*.ml))
-
-TESTS = $(patsubst %.ml,%,$(wildcard tests/*.ml))
-
-BENCHMARKS = $(patsubst %.ml,%,$(wildcard benchmarks/*.ml))
-
-all: $(BYTESWAP_H) \
- bitstring.cma bitstring_persistent.cma \
- bitstring.cmxa bitstring_persistent.cmxa \
- pa_bitstring.cmo \
- bitstring-objinfo
- @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
-
-bitstring.cma: bitstring_types.cmo bitstring_config.cmo \
- bitstring_c.o bitstring.cmo bitmatch.cmo
- $(OCAMLMKLIB) -o bitstring $^
-
-bitstring_persistent.cma: bitstring_persistent.cmo
- $(OCAMLFIND) ocamlc -a $(OCAMLCFLAGS) -o $@ $^
-
-bitstring_persistent.cmo: bitstring_persistent.ml
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
- -I +camlp4 -pp camlp4of -c $<
-
-bitstring.cmxa: bitstring_types.cmx bitstring_config.cmx \
- bitstring_c.o bitstring.cmx bitmatch.cmx
- $(OCAMLMKLIB) -o bitstring $^
-
-bitstring_persistent.cmxa: bitstring_persistent.cmx
- $(OCAMLFIND) ocamlopt -a $(OCAMLOPTFLAGS) -o $@ $^
-
-bitstring_persistent.cmx: bitstring_persistent.ml
- $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) \
- -I +camlp4 -pp camlp4of -c $<
-
-bitstring_persistent.cmi: bitstring_persistent.mli
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
- -I +camlp4 -pp camlp4of -c $<
-
-pa_bitstring.cmo: pa_bitstring.ml bitstring.cma bitstring_persistent.cma
- $(OCAMLFIND) ocamlc bitstring.cma -I +camlp4 dynlink.cma camlp4lib.cma \
- -pp camlp4of -c $< -o $@
-
-bitstring-objinfo: bitstring_objinfo.cmo bitstring.cma bitstring_persistent.cma
- $(OCAMLFIND) ocamlc -I +camlp4 unix.cma dynlink.cma camlp4lib.cma \
- $(OCAMLCFLAGS) $(OCAMLCLIBS) \
- bitstring.cma bitstring_persistent.cma \
- $< -o $@
-
-# Create byteswap.h if the system doesn't have this file.
-# From gnulib, license is LGPLv2+.
-
-byteswap.h: byteswap.in.h
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- cat $(srcdir)/byteswap.in.h; \
- } > $@-t
- mv -f $@-t $@
-
-# Tests.
-
-ifeq ($(enable_coverage),no)
-PP = -pp 'camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo'
-else
-PP = -pp 'camlp4o $(OCAMLLIB)/bisect/bisect.cma bitstring.cma bitstring_persistent.cma pa_bitstring.cmo'
-endif
-
-check: test
-
-test: pa_bitstring.cmo \
- bitstring.cma bitstring_persistent.cma \
- bitstring.cmxa bitstring_persistent.cmxa \
- tests/test.bmpp
- @for f in $(TESTS); do \
- echo Building $$f; \
- $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) -package unix $(OCAMLOPTLIBS) -I . bitstring.cmxa $$f.ml -o $$f.opt; \
- if [ $$? -ne 0 ]; then exit 1; fi; \
- echo Running $$f; \
- $$f.opt; \
- if [ $$? -ne 0 ]; then exit 1; fi; \
- done
- @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
-
-tests/test.bmpp: create_test_pattern
- ./$< $@.new
- mv $@.new $@
-
-create_test_pattern: create_test_pattern.cmo
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
- unix.cma -I +camlp4 dynlink.cma camlp4lib.cma \
- $(OCAMLCLIBS) \
- -I . bitstring.cma bitstring_persistent.cma $< -o $@
-
-create_test_pattern.cmo: create_test_pattern.ml
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -pp camlp4of \
- unix.cma -I +camlp4 \
- -I . -c $< -o $@
-
-# Coverage of tests.
-
-ifneq ($(BISECT_REPORT),no)
-coverage:
- rm -f coverage-report/*
- rm -f bisect*.out
- $(MAKE) test
- $(BISECT_REPORT) -html coverage-report bisect*.out
- rm -f bisect*.out
- @echo Coverage report is in `pwd`/coverage-report/index.html
-endif
-
-# Examples.
-
-examples: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma
- @for f in $(EXAMPLES); do \
- echo Building $$f; \
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(PP) \
- -package unix -linkpkg -I . bitstring.cma $$f.ml -o $$f; \
- if [ $$? -ne 0 ]; then exit 1; fi; \
- done
- @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
-
-print-tests: pa_bitstring.cmo bitstring_persistent.cma
- @for f in $(TESTS); do \
- echo Test: $$f.ml; \
- cmd="camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo \
- -printer pr_o.cmo $$f.ml"; \
- echo $$cmd; \
- $$cmd; \
- done
-
-print-examples: pa_bitstring.cmo
- @for f in $(EXAMPLES); do \
- echo Example: $$f.ml; \
- camlp4o bitstring.cma bitstring_persistent.cma pa_bitstring.cmo \
- -printer pr_o.cmo $$f.ml; \
- if [ $$? -ne 0 ]; then exit 1; fi; \
- done
-
-# Benchmarks.
-
-ifneq ($(TIME),no)
-
-benchmarks: pa_bitstring.cmo bitstring.cma bitstring_persistent.cma
- @for f in $(BENCHMARKS); do \
- $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) \
- -package unix -linkpkg -I . bitstring.cmxa $$f.ml -o $$f.opt; \
- if [ $$? -ne 0 ]; then exit 1; fi; \
- $(TIME) -f "$$f: %e seconds" $$f.opt; \
- if [ $$? -ne 0 ]; then exit 1; fi; \
- done
-ifneq ($(GPROF),no)
- @for f in $(BENCHMARKS); do \
- $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(PP) -p \
- -package unix -linkpkg -I . bitstring.cmxa $$f.ml -o $$f.opt.p; \
- if [ $$? -ne 0 ]; then exit 1; fi; \
- rm -f gmon.out; \
- $$f.opt.p; \
- if [ $$? -ne 0 ]; then exit 1; fi; \
- gprof $$f.opt.p > $$f.profile; \
- if [ $$? -ne 0 ]; then exit 1; fi; \
- echo "Wrote profile of $$f"; \
- echo " to $$f.profile"; \
- rm -f gmon.out; \
- done
-endif
-
-endif
-
-# Clean.
-
-clean:
- rm -f core *~ *.cmi *.cmo *.cmx *.cma *.cmxa *.cmp *.a *.o *.so
- rm -f tests/*~ tests/*.cmi tests/*.cmo tests/*.cmx tests/*.opt
- rm -f tests/*.o
- rm -f examples/*~ examples/*.cmi examples/*.cmo examples/*.cmx
- rm -f examples/*.o $(EXAMPLES)
- rm -f benchmarks/*~ benchmarks/*.cmi benchmarks/*.cmo
- rm -f benchmarks/*.cmx benchmarks/*.o
- rm -f benchmarks/*.opt benchmarks/*.opt.p benchmarks/*.profile
- rm -f create_test_pattern bitstring-objinfo
- @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
-
-distclean: clean
- rm -rf autom4te.cache
- rm -f config.log config.status
- rm -f config.h Makefile META bitstring_config.ml
- rm -f bitstring-objinfo
- @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
-
-# Documentation.
-
-ifneq ($(OCAMLDOC),)
-doc:
- rm -rf html
- mkdir html
- $(OCAMLDOC) $(OCAMLDOCFLAGS) -d html -I +camlp4 \
- bitstring.mli bitstring_persistent.mli bitmatch.ml
-endif
-
-# Install.
-
-install:
- ocamlfind install bitstring META *.mli *.cmx *.cma *.cmxa *.a *.so \
- bitstring.cmi \
- bitstring_persistent.cmi \
- pa_bitstring.cmo
- @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
-
-uninstall:
- ocamlfind remove bitstring
-
-# Standard rules.
-
-.mli.cmi:
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
-.ml.cmo:
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
-.ml.cmx:
- $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $<
-
-depend: .depend
- @for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
-
-.depend: bitstring.ml bitstring.mli \
- bitstring_persistent.ml bitstring_persistent.mli \
- bitstring_objinfo.ml \
- create_test_pattern.ml
- rm -f $@ $@-t
- $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) \
- bitstring.ml bitstring.mli \
- bitstring_objinfo.ml | \
- $(SED) 's/ :/:/' | \
- $(SED) 's/ *$$//' | \
- $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' >> $@-t
- $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) -pp camlp4of \
- bitstring_persistent.ml bitstring_persistent.mli \
- create_test_pattern.ml | \
- $(SED) 's/ :/:/' | \
- $(SED) 's/ *$$//' | \
- $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' >> $@-t
- mv $@-t $@
-
-ifeq ($(wildcard .depend),.depend)
-include .depend
-endif
-
-# Distribution.
-
-dist:
- $(MAKE) check-manifest
- rm -rf $(PACKAGE)-$(VERSION)
- mkdir $(PACKAGE)-$(VERSION)
- tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
- $(INSTALL) -m 0755 configure $(PACKAGE)-$(VERSION)/
- $(INSTALL) -m 0644 config.h.in $(PACKAGE)-$(VERSION)/
- svn log -v > $(PACKAGE)-$(VERSION)/CHANGES
- tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
- rm -rf $(PACKAGE)-$(VERSION)
- ls -l $(PACKAGE)-$(VERSION).tar.gz
-
-check-manifest:
- svn -R list | grep -v '/$$' | sort > .check-manifest
- sort MANIFEST > .orig-manifest; \
- diff -u .orig-manifest .check-manifest; rv=$$?; \
- rm -f .orig-manifest .check-manifest; \
- exit $$rv
-
-.PHONY: depend dist check-manifest dpkg doc \
- print-examples print-tests examples test benchmarks
-
-.SUFFIXES: .cmo .cmi .cmx .ml .mli .mll
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e806c27
--- /dev/null
+++ b/README.md
@@ -0,0 +1,69 @@
+# OCaml Bistring Library
+
+[![Build Status](https://travis-ci.org/xguerin/bitstring.svg?branch=master)](https://travis-ci.org/xguerin/bitstring)
+
+```
+Copyright (C) 2008-2016 Red Hat Inc, Richard W.M. Jones.
+Copyright (C) 2016-2018 Red Hat Inc, Richard W.M. Jones, Xavier R. Guerin.
+```
+
+The original `README` content can be found in the `README.orig` file.
+
+## Documentation
+
+The documentation is located [here](http://xguer.in/bitstring).
+
+## How to install
+
+`opam install bitstring`
+
+## How to use
+
+### Ocamlfind
+
+```
+ocamlfind c -package bitstring -package bitstring.ppx -linkpkg ...
+```
+
+### Jbuilder
+
+```lisp
+(jbuild_version 1)
+
+(executable
+ ((name foo)
+ (libraries (bitstring))
+ (preprocess (pps (bitstring.ppx)))
+ ))
+```
+
+## How to build
+
+`bitstring` version `3` requires OCaml `>= 4.02.3`.
+
+### Dependencies
+
+* `str`
+* `unix`
+* `compiler-libs`
+* `ppx_tools_versioned`
+* `ocaml-migrate-parsetree`
+
+### Building the project
+
+```
+$ jbuilder build
+```
+
+### Running the tests
+
+```
+$ jbuilder runtest
+```
+
+## License
+
+The library is licensed under the LGPL v2 or later, with the OCaml linking
+exception. See the file `COPYING.LIB` for full terms. Programs are licensed under
+the GPL v2 or later. See the file `COPYING` for full terms. All examples and tests
+are public domain.
diff --git a/README b/README.orig
index 1d82d17..2f47553 100644
--- a/README
+++ b/README.orig
@@ -4,7 +4,7 @@ This library was formerly known as 'bitmatch'.
Please see the html subdirectory for developer documentation.
-The only requirements are OCaml >= 3.10.0, camlp4, ocamldoc, and findlib.
+The only requirements are OCaml >= 4.02.0, camlp4, ocamldoc, and findlib.
If you optionally have CIL (http://cil.sourceforge.net/) installed
then there are some nice extra tools for converting C header files
diff --git a/TODO b/TODO
deleted file mode 100644
index ff2a556..0000000
--- a/TODO
+++ /dev/null
@@ -1,136 +0,0 @@
-$Id$
-Major to-do items.
-
-(1) DONE - In bitmatch operator, use patterns not expressions.
-
-(2) DONE - Allow matching against strings.
-
-(3) DONE - Change the syntax so { ... } surrounds match patterns.
-
-(4) Provide UInt32 and UInt64 types.
-
-(5) DONE - Allow for specific offsets and alignment. Something like this:
-
- { start : 16;
- another : 16 : offset(256); (* location would be 256 bits from start *)
- }
-
-(6) and:
-
- { start : 16;
- another : 16 : align(32); (* implicit 16 bit gap before this *)
- }
-
-(7) Assertions:
-
- { start : 16 : assert (offset = 0); }
-
- (Q: Are these evaluated at compile time or at run time or selectable?)
-
-(8) Named but unbound patterns to avoid "Warning Y: unused variable".
-
-(9) DONE -
- Make the error locations fine-grained, particularly so they point to
- individual fields, not the whole match.
-
-(10) DONE - Cross-module, persistent, named patterns, see:
- http://caml.inria.fr/pub/ml-archives/caml-list/2008/04/25992c9c9fa999fe1d35d961dd9917a2.en.html
-
-(11) DONE -
- Runtime endiannness expressions. The suggested syntax is:
-
- { field : len : endian (expr) }
-
- where expr would evaluate to something like BigEndian or
- LittleEndian.
-
- There are several protocols around where endianness is only
- determined at runtime, examples are libpcap and TIFF.
-
-(12) DONE - More constant field lengths.
-
-(13) PARTLY DONE - Implement native endian functions.
-
-(14) PARTLY DONE - A proper test suite.
-
-(15) DONE - More examples:
-
- ELF binaries
- GIF images
-
-(16) We now know the offset of the current field relative to the
- whole match. This may allow more efficient aligned versions
- of functions to be called (at compile time). However do note
- that the offset in the bitstring is usually not known.
-
-(17) PARTLY DONE - Fix the META file. Current one is very broken.
-
-(18) DONE - check() qualifier:
-
- { field : 16 : check (field > 100) }
-
- The check(expr) qualifier will abort the rest of the match if the
- expression is false.
-
-(19) DONE - bind() qualifier:
-
- { field : 16 : bind (field * 3) }
- ^pattern ^new value
-
- The bind(expr) qualifier binds the pattern to a new value,
- equivalent to doing:
-
- let field = field * 3 in
- (* remainder of match *)
-
- There is a question of whether bind() should run before or
- after when() [best is probably when() first, then bind()].
-
-(20) DONE - save_offset_to() qualifier:
-
- { field : 16 : save_offset_to (offset), bind (field - offset) }
-
- or:
-
- { field : 16 : save_offset_to (field_offset) } ->
- printf "the offset of field (%d) is %d\n" field field_offset
-
- save_offset_to(patt) binds the current match offset to
- the variable, for later use within bind(), when() or
- any later parts of the match.
-
-(21) derive() so you can add your own variable decls:
-
- { field : 32 : derive (field_as_int, Int32.to_int field) }
-
- This would add a let derivation, equivalent to:
-
- let field_as_int = Int32.to_int field
-
- allowing you to use both the original field and field_as_int
- as variables.
-
- Note you can do this clumsily using bind():
-
- { field : 32 : bind (field, Int32.to_int field) }
-
- which redefines 'field' as a pair of (old value, derived value).
-
-(22) Allow constant 0 to be used in constructors to mean a zero-length
- bitstring of the right length, eg:
-
- BITSTRING { 0 : 32*8 : bitstring }
-
- which would be equivalent to:
-
- BITSTRING { zeroes_bitstring (32*8) : 32*8 : bitstring }
-
-(23) Add predicate Bitstring.is_zero_bitstring : bitstring -> bool
-
-(24) Add a function to turn bitstrings into printable strings.
-
-(25) Folding over bitstrings. A narrow usage for this is to generate
- checksums and hashes, where usually you want to fold over every
- 8/16/32-bit word. So a set of functions which just enabled this
- would be useful. (However you still need le/be/ne variations so
- it involves at least 7 functions).
diff --git a/aclocal.m4 b/aclocal.m4
deleted file mode 100644
index 36c9013..0000000
--- a/aclocal.m4
+++ /dev/null
@@ -1,254 +0,0 @@
-# generated automatically by aclocal 1.12.2 -*- Autoconf -*-
-
-# Copyright (C) 1996-2012 Free Software Foundation, Inc.
-
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-dnl autoconf macros for OCaml
-dnl
-dnl Copyright © 2009 Richard W.M. Jones
-dnl Copyright © 2009 Stefano Zacchiroli
-dnl Copyright © 2000-2005 Olivier Andrieu
-dnl Copyright © 2000-2005 Jean-Christophe Filliâtre
-dnl Copyright © 2000-2005 Georges Mariano
-dnl
-dnl For documentation, please read the ocaml.m4 man page.
-
-AC_DEFUN([AC_PROG_OCAML],
-[dnl
- # checking for ocamlc
- AC_CHECK_TOOL([OCAMLC],[ocamlc],[no])
-
- if test "$OCAMLC" != "no"; then
- OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'`
- AC_MSG_RESULT([OCaml version is $OCAMLVERSION])
- # If OCAMLLIB is set, use it
- if test "$OCAMLLIB" = ""; then
- OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
- else
- AC_MSG_RESULT([OCAMLLIB previously set; preserving it.])
- fi
- AC_MSG_RESULT([OCaml library path is $OCAMLLIB])
-
- AC_SUBST([OCAMLVERSION])
- AC_SUBST([OCAMLLIB])
-
- # checking for ocamlopt
- AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no])
- OCAMLBEST=byte
- if test "$OCAMLOPT" = "no"; then
- AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
- else
- TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
- OCAMLOPT=no
- else
- OCAMLBEST=opt
- fi
- fi
-
- AC_SUBST([OCAMLBEST])
-
- # checking for ocamlc.opt
- AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no])
- if test "$OCAMLCDOTOPT" != "no"; then
- TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
- else
- OCAMLC=$OCAMLCDOTOPT
- fi
- fi
-
- # checking for ocamlopt.opt
- if test "$OCAMLOPT" != "no" ; then
- AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
- if test "$OCAMLOPTDOTOPT" != "no"; then
- TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
- else
- OCAMLOPT=$OCAMLOPTDOTOPT
- fi
- fi
- fi
-
- AC_SUBST([OCAMLOPT])
- fi
-
- AC_SUBST([OCAMLC])
-
- # checking for ocaml toplevel
- AC_CHECK_TOOL([OCAML],[ocaml],[no])
-
- # checking for ocamldep
- AC_CHECK_TOOL([OCAMLDEP],[ocamldep],[no])
-
- # checking for ocamlmktop
- AC_CHECK_TOOL([OCAMLMKTOP],[ocamlmktop],[no])
-
- # checking for ocamlmklib
- AC_CHECK_TOOL([OCAMLMKLIB],[ocamlmklib],[no])
-
- # checking for ocamldoc
- AC_CHECK_TOOL([OCAMLDOC],[ocamldoc],[no])
-
- # checking for ocamlbuild
- AC_CHECK_TOOL([OCAMLBUILD],[ocamlbuild],[no])
-])
-
-
-AC_DEFUN([AC_PROG_OCAMLLEX],
-[dnl
- # checking for ocamllex
- AC_CHECK_TOOL([OCAMLLEX],[ocamllex],[no])
- if test "$OCAMLLEX" != "no"; then
- AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no])
- if test "$OCAMLLEXDOTOPT" != "no"; then
- OCAMLLEX=$OCAMLLEXDOTOPT
- fi
- fi
- AC_SUBST([OCAMLLEX])
-])
-
-AC_DEFUN([AC_PROG_OCAMLYACC],
-[dnl
- AC_CHECK_TOOL([OCAMLYACC],[ocamlyacc],[no])
- AC_SUBST([OCAMLYACC])
-])
-
-
-AC_DEFUN([AC_PROG_CAMLP4],
-[dnl
- AC_REQUIRE([AC_PROG_OCAML])dnl
-
- # checking for camlp4
- AC_CHECK_TOOL([CAMLP4],[camlp4],[no])
- if test "$CAMLP4" != "no"; then
- TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'`
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT([versions differs from ocamlc])
- CAMLP4=no
- fi
- fi
- AC_SUBST([CAMLP4])
-
- # checking for companion tools
- AC_CHECK_TOOL([CAMLP4BOOT],[camlp4boot],[no])
- AC_CHECK_TOOL([CAMLP4O],[camlp4o],[no])
- AC_CHECK_TOOL([CAMLP4OF],[camlp4of],[no])
- AC_CHECK_TOOL([CAMLP4OOF],[camlp4oof],[no])
- AC_CHECK_TOOL([CAMLP4ORF],[camlp4orf],[no])
- AC_CHECK_TOOL([CAMLP4PROF],[camlp4prof],[no])
- AC_CHECK_TOOL([CAMLP4R],[camlp4r],[no])
- AC_CHECK_TOOL([CAMLP4RF],[camlp4rf],[no])
- AC_SUBST([CAMLP4BOOT])
- AC_SUBST([CAMLP4O])
- AC_SUBST([CAMLP4OF])
- AC_SUBST([CAMLP4OOF])
- AC_SUBST([CAMLP4ORF])
- AC_SUBST([CAMLP4PROF])
- AC_SUBST([CAMLP4R])
- AC_SUBST([CAMLP4RF])
-])
-
-
-AC_DEFUN([AC_PROG_FINDLIB],
-[dnl
- AC_REQUIRE([AC_PROG_OCAML])dnl
-
- # checking for ocamlfind
- AC_CHECK_TOOL([OCAMLFIND],[ocamlfind],[no])
- AC_SUBST([OCAMLFIND])
-])
-
-
-dnl Thanks to Jim Meyering for working this next bit out for us.
-dnl XXX We should define AS_TR_SH if it's not defined already
-dnl (eg. for old autoconf).
-AC_DEFUN([AC_CHECK_OCAML_PKG],
-[dnl
- AC_REQUIRE([AC_PROG_FINDLIB])dnl
-
- AC_MSG_CHECKING([for OCaml findlib package $1])
-
- unset found
- unset pkg
- found=no
- for pkg in $1 $2 ; do
- if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then
- AC_MSG_RESULT([found])
- AS_TR_SH([OCAML_PKG_$1])=$pkg
- found=yes
- break
- fi
- done
- if test "$found" = "no" ; then
- AC_MSG_RESULT([not found])
- AS_TR_SH([OCAML_PKG_$1])=no
- fi
-
- AC_SUBST(AS_TR_SH([OCAML_PKG_$1]))
-])
-
-
-AC_DEFUN([AC_CHECK_OCAML_MODULE],
-[dnl
- AC_MSG_CHECKING([for OCaml module $2])
-
- cat > conftest.ml <<EOF
-open $3
-EOF
- unset found
- for $1 in $$1 $4 ; do
- if $OCAMLC -c -I "$$1" conftest.ml >&5 2>&5 ; then
- found=yes
- break
- fi
- done
-
- if test "$found" ; then
- AC_MSG_RESULT([$$1])
- else
- AC_MSG_RESULT([not found])
- $1=no
- fi
- AC_SUBST([$1])
-])
-
-
-dnl XXX Cross-compiling
-AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE],
-[dnl
- AC_REQUIRE([AC_PROG_OCAML])dnl
- AC_MSG_CHECKING([for OCaml compiler word size])
- cat > conftest.ml <<EOF
- print_endline (string_of_int Sys.word_size)
- EOF
- OCAML_WORD_SIZE=`$OCAML conftest.ml`
- AC_MSG_RESULT([$OCAML_WORD_SIZE])
- AC_SUBST([OCAML_WORD_SIZE])
-])
-
-AC_DEFUN([AC_CHECK_OCAML_OS_TYPE],
-[dnl
- AC_REQUIRE([AC_PROG_OCAML])dnl
- AC_MSG_CHECKING([OCaml Sys.os_type])
-
- cat > conftest.ml <<EOF
- print_string(Sys.os_type);;
-EOF
-
- OCAML_OS_TYPE=`$OCAML conftest.ml`
- AC_MSG_RESULT([$OCAML_OS_TYPE])
- AC_SUBST([OCAML_OS_TYPE])
-])
-
diff --git a/benchmarks/parse_ext3_superblock.ml b/benchmarks/parse_ext3_superblock.ml
deleted file mode 100644
index edda82f..0000000
--- a/benchmarks/parse_ext3_superblock.ml
+++ /dev/null
@@ -1,73 +0,0 @@
-(* Benchmark parsing of an ext3 superblock.
- * $Id$
- *)
-
-open Printf
-
-let bits = Bitstring.bitstring_of_file "examples/ext3_sb"
-
-let parse () =
- bitmatch bits with
- | { s_inodes_count : 32 : littleendian; (* Inodes count *)
- s_blocks_count : 32 : littleendian; (* Blocks count *)
- s_r_blocks_count : 32 : littleendian; (* Reserved blocks count *)
- s_free_blocks_count : 32 : littleendian; (* Free blocks count *)
- s_free_inodes_count : 32 : littleendian; (* Free inodes count *)
- s_first_data_block : 32 : littleendian; (* First Data Block *)
- s_log_block_size : 32 : littleendian; (* Block size *)
- s_log_frag_size : 32 : littleendian; (* Fragment size *)
- s_blocks_per_group : 32 : littleendian; (* # Blocks per group *)
- s_frags_per_group : 32 : littleendian; (* # Fragments per group *)
- s_inodes_per_group : 32 : littleendian; (* # Inodes per group *)
- s_mtime : 32 : littleendian; (* Mount time *)
- s_wtime : 32 : littleendian; (* Write time *)
- s_mnt_count : 16 : littleendian; (* Mount count *)
- s_max_mnt_count : 16 : littleendian; (* Maximal mount count *)
- 0xef53 : 16 : littleendian; (* Magic signature *)
- s_state : 16 : littleendian; (* File system state *)
- s_errors : 16 : littleendian; (* Behaviour when detecting errors *)
- s_minor_rev_level : 16 : littleendian; (* minor revision level *)
- s_lastcheck : 32 : littleendian; (* time of last check *)
- s_checkinterval : 32 : littleendian; (* max. time between checks *)
- s_creator_os : 32 : littleendian; (* OS *)
- s_rev_level : 32 : littleendian; (* Revision level *)
- s_def_resuid : 16 : littleendian; (* Default uid for reserved blocks *)
- s_def_resgid : 16 : littleendian; (* Default gid for reserved blocks *)
- s_first_ino : 32 : littleendian; (* First non-reserved inode *)
- s_inode_size : 16 : littleendian; (* size of inode structure *)
- s_block_group_nr : 16 : littleendian; (* block group # of this superblock *)
- s_feature_compat : 32 : littleendian; (* compatible feature set *)
- s_feature_incompat : 32 : littleendian; (* incompatible feature set *)
- s_feature_ro_compat : 32 : littleendian; (* readonly-compatible feature set *)
- s_uuid : 128 : string; (* 128-bit uuid for volume *)
- s_volume_name : 128 : string; (* volume name *)
- s_last_mounted : 512 : string; (* directory where last mounted *)
- s_algorithm_usage_bitmap : 32 : littleendian; (* For compression *)
- s_prealloc_blocks : 8; (* Nr of blocks to try to preallocate*)
- s_prealloc_dir_blocks : 8; (* Nr to preallocate for dirs *)
- s_reserved_gdt_blocks : 16 : littleendian;(* Per group desc for online growth *)
- s_journal_uuid : 128 : string; (* uuid of journal superblock *)
- s_journal_inum : 32 : littleendian; (* inode number of journal file *)
- s_journal_dev : 32 : littleendian; (* device number of journal file *)
- s_last_orphan : 32 : littleendian; (* start of list of inodes to delete *)
- s_hash_seed0 : 32 : littleendian; (* HTREE hash seed *)
- s_hash_seed1 : 32 : littleendian;
- s_hash_seed2 : 32 : littleendian;
- s_hash_seed3 : 32 : littleendian;
- s_def_hash_version : 8; (* Default hash version to use *)
- s_reserved_char_pad : 8;
- s_reserved_word_pad : 16 : littleendian;
- s_default_mount_opts : 32 : littleendian;
- s_first_meta_bg : 32 : littleendian; (* First metablock block group *)
- _ : 6080 : bitstring } -> (* Padding to the end of the block *)
-
- ()
-
- | { _ } ->
- eprintf "not an ext3 superblock!\n%!";
- exit 2
-
-let () =
- for i = 0 to 2_000_000 do
- parse ()
- done
diff --git a/bitmatch.ml b/bitmatch.ml
deleted file mode 100644
index 2d1992b..0000000
--- a/bitmatch.ml
+++ /dev/null
@@ -1,27 +0,0 @@
-(** Bitmatch backwards compatibility library. *)
-(* Bitstring library.
- * Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version,
- * with the OCaml linking exception described in COPYING.LIB.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * $Id$
- *)
-(** This is just for backwards compatibility with code
- from when the library was called bitmatch. You should
- replace all references to this module with {!Bitstring}.
-*)
-
-include Bitstring
diff --git a/bitstring.opam b/bitstring.opam
new file mode 100644
index 0000000..a82b176
--- /dev/null
+++ b/bitstring.opam
@@ -0,0 +1,30 @@
+authors : [ "Richard W.M. Jones" "Xavier R. Guérin" ]
+bug-reports : "https://github.com/xguerin/bitstring/issues"
+dev-repo : "https://github.com/xguerin/bitstring.git"
+doc : "https://xguer.in/bitstring"
+homepage : "https://github.com/xguerin/bitstring"
+license : "LGPLv2+ with exceptions and GPLv2+"
+maintainer : "Xavier R. Guérin <ghub@applepine.org>"
+opam-version : "1.2"
+version : "3.0.0"
+
+build: [
+ ["jbuilder" "build" "-p" name "-j" jobs]
+]
+
+build-test: [
+ ["jbuilder" "runtest" "-p" name "-j" jobs]
+]
+
+depends: [
+ "jbuilder" { build }
+ "ppx_tools_versioned" { build }
+ "ocaml-migrate-parsetree" { build & >= "1.0.5" }
+ "ounit" { build }
+]
+
+conflicts: [
+ "ppx_bitstring"
+]
+
+available: ocaml-version >= "4.02.3"
diff --git a/bitstring_objinfo.ml b/bitstring_objinfo.ml
deleted file mode 100644
index c74de69..0000000
--- a/bitstring_objinfo.ml
+++ /dev/null
@@ -1,50 +0,0 @@
-(* Bitstring syntax extension.
- * Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- *)
-
-open Printf
-
-open Bitstring
-module P = Bitstring_persistent
-
-let () =
- if Array.length Sys.argv <= 1 then
- failwith "bitstring-objinfo filename.bmpp";
- let filename = Sys.argv.(1) in
- let chan = open_in filename in
- let names = ref [] in
- (try
- let rec loop () =
- let name = P.named_from_channel chan in
- names := name :: !names
- in
- loop ()
- with End_of_file -> ()
- );
- close_in chan;
- let names = List.rev !names in
- List.iter (
- function
- | name, P.Pattern patt ->
- printf "let bitmatch %s =\n%s\n"
- name (P.string_of_pattern patt)
- | name, P.Constructor cons ->
- printf "let BITSTRING %s =\n%s\n"
- name (P.string_of_constructor cons)
- ) names
diff --git a/bitstring_persistent.ml b/bitstring_persistent.ml
deleted file mode 100644
index 032b2d8..0000000
--- a/bitstring_persistent.ml
+++ /dev/null
@@ -1,274 +0,0 @@
-(* Bitstring persistent patterns.
- * Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version,
- * with the OCaml linking exception described in COPYING.LIB.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * $Id$
- *)
-
-open Printf
-
-open Camlp4.PreCast
-open Syntax
-open Ast
-
-type patt = Camlp4.PreCast.Syntax.Ast.patt
-type expr = Camlp4.PreCast.Syntax.Ast.expr
-type loc_t = Camlp4.PreCast.Syntax.Ast.Loc.t
-
-(* Field. In bitmatch (patterns) the type is [patt field]. In
- * BITSTRING (constructor) the type is [expr field].
- *)
-type 'a field = {
- field : 'a; (* field ('a is either patt or expr) *)
- flen : expr; (* length in bits, may be non-const *)
- endian : endian_expr; (* endianness *)
- signed : bool; (* true if signed, false if unsigned *)
- t : field_type; (* type *)
- _loc : Loc.t; (* location in source code *)
- offset : expr option; (* offset expression *)
- check : expr option; (* check expression [patterns only] *)
- bind : expr option; (* bind expression [patterns only] *)
- save_offset_to : patt option; (* save_offset_to [patterns only] *)
-}
-and field_type = Int | String | Bitstring (* field type *)
-and endian_expr =
- | ConstantEndian of Bitstring.endian (* a constant little/big/nativeendian *)
- | EndianExpr of expr (* an endian expression *)
-
-type pattern = patt field list
-
-type constructor = expr field list
-
-type named = string * alt
-and alt =
- | Pattern of pattern
- | Constructor of constructor
-
-(* Work out if an expression is an integer constant.
- *
- * Returns [Some i] if so (where i is the integer value), else [None].
- *
- * Fairly simplistic algorithm: we can only detect simple constant
- * expressions such as [k], [k+c], [k-c] etc.
- *)
-let rec expr_is_constant = function
- | <:expr< $int:i$ >> -> (* Literal integer constant. *)
- Some (int_of_string i)
- | <:expr< $a$ + $b$ >> -> (* Addition of constants. *)
- (match expr_is_constant a, expr_is_constant b with
- | Some a, Some b -> Some (a+b)
- | _ -> None)
- | <:expr< $a$ - $b$ >> -> (* Subtraction. *)
- (match expr_is_constant a, expr_is_constant b with
- | Some a, Some b -> Some (a-b)
- | _ -> None)
- | <:expr< $a$ * $b$ >> -> (* Multiplication. *)
- (match expr_is_constant a, expr_is_constant b with
- | Some a, Some b -> Some (a*b)
- | _ -> None)
- | <:expr< $a$ / $b$ >> -> (* Division. *)
- (match expr_is_constant a, expr_is_constant b with
- | Some a, Some b -> Some (a/b)
- | _ -> None)
- | <:expr< $a$ lsl $b$ >> -> (* Shift left. *)
- (match expr_is_constant a, expr_is_constant b with
- | Some a, Some b -> Some (a lsl b)
- | _ -> None)
- | <:expr< $a$ lsr $b$ >> -> (* Shift right. *)
- (match expr_is_constant a, expr_is_constant b with
- | Some a, Some b -> Some (a lsr b)
- | _ -> None)
- | _ -> None (* Anything else is not constant. *)
-
-let string_of_field_type = function
- | Int -> "int"
- | String -> "string"
- | Bitstring -> "bitstring"
-
-let patt_printer = function
- | <:patt< $lid:id$ >> -> id
- | <:patt< _ >> -> "_"
- | _ -> "[pattern]"
-
-let rec expr_printer = function
- | <:expr< $lid:id$ >> -> id
- | <:expr< $int:i$ >> -> i
- | <:expr< $lid:op$ $a$ $b$ >> ->
- sprintf "%s %s %s" op (expr_printer a) (expr_printer b)
- | _ -> "[expr]"
-
-let _string_of_field { flen = flen;
- endian = endian; signed = signed; t = t;
- _loc = _loc;
- offset = offset; check = check; bind = bind;
- save_offset_to = save_offset_to } =
- let flen = expr_printer flen in
- let endian =
- match endian with
- | ConstantEndian endian -> Bitstring.string_of_endian endian
- | EndianExpr expr -> sprintf "endian(%s)" (expr_printer expr) in
- let signed = if signed then "signed" else "unsigned" in
- let t = string_of_field_type t in
-
- let offset =
- match offset with
- | None -> ""
- | Some expr -> sprintf ", offset(%s)" (expr_printer expr) in
-
- let check =
- match check with
- | None -> ""
- | Some expr -> sprintf ", check(%s)" (expr_printer expr) in
-
- let bind =
- match bind with
- | None -> ""
- | Some expr -> sprintf ", bind(%s)" (expr_printer expr) in
-
- let save_offset_to =
- match save_offset_to with
- | None -> ""
- | Some patt ->
- match patt with
- | <:patt< $lid:id$ >> -> sprintf ", save_offset_to(%s)" id
- | _ -> sprintf ", save_offset_to([patt])" in
-
- let loc_fname = Loc.file_name _loc in
- let loc_line = Loc.start_line _loc in
- let loc_char = Loc.start_off _loc - Loc.start_bol _loc in
-
- sprintf "%s : %s, %s, %s%s%s%s%s (* %S:%d %d *)"
- flen t endian signed offset check bind save_offset_to
- loc_fname loc_line loc_char
-
-let rec string_of_pattern_field ({ field = patt } as field) =
- sprintf "%s : %s" (patt_printer patt) (_string_of_field field)
-
-and string_of_constructor_field ({ field = expr } as field) =
- sprintf "%s : %s" (expr_printer expr) (_string_of_field field)
-
-let string_of_pattern pattern =
- "{ " ^
- String.concat ";\n " (List.map string_of_pattern_field pattern) ^
- " }\n"
-
-let string_of_constructor constructor =
- "{ " ^
- String.concat ";\n " (List.map string_of_constructor_field constructor) ^
- " }\n"
-
-let named_to_channel chan n = Marshal.to_channel chan n []
-
-let named_to_string n = Marshal.to_string n []
-
-let named_to_buffer str ofs len n = Marshal.to_buffer str ofs len n []
-
-let named_from_channel = Marshal.from_channel
-
-let named_from_string = Marshal.from_string
-
-let create_pattern_field _loc =
- {
- field = <:patt< _ >>;
- flen = <:expr< 32 >>;
- endian = ConstantEndian Bitstring.BigEndian;
- signed = false;
- t = Int;
- _loc = _loc;
- offset = None;
- check = None;
- bind = None;
- save_offset_to = None;
- }
-
-let set_lident_patt field id =
- let _loc = field._loc in
- { field with field = <:patt< $lid:id$ >> }
-let set_int_patt field i =
- let _loc = field._loc in
- { field with field = <:patt< $`int:i$ >> }
-let set_string_patt field str =
- let _loc = field._loc in
- { field with field = <:patt< $str:str$ >> }
-let set_unbound_patt field =
- let _loc = field._loc in
- { field with field = <:patt< _ >> }
-let set_patt field patt = { field with field = patt }
-let set_length_int field flen =
- let _loc = field._loc in
- { field with flen = <:expr< $`int:flen$ >> }
-let set_length field flen = { field with flen = flen }
-let set_endian field endian = { field with endian = ConstantEndian endian }
-let set_endian_expr field expr = { field with endian = EndianExpr expr }
-let set_signed field signed = { field with signed = signed }
-let set_type_int field = { field with t = Int }
-let set_type_string field = { field with t = String }
-let set_type_bitstring field = { field with t = Bitstring }
-let set_location field loc = { field with _loc = loc }
-let set_offset_int field i =
- let _loc = field._loc in
- { field with offset = Some <:expr< $`int:i$ >> }
-let set_offset field expr = { field with offset = Some expr }
-let set_no_offset field = { field with offset = None }
-let set_check field expr = { field with check = Some expr }
-let set_no_check field = { field with check = None }
-let set_bind field expr = { field with bind = Some expr }
-let set_no_bind field = { field with bind = None }
-let set_save_offset_to field patt = { field with save_offset_to = Some patt }
-let set_save_offset_to_lident field id =
- let _loc = field._loc in
- { field with save_offset_to = Some <:patt< $lid:id$ >> }
-let set_no_save_offset_to field = { field with save_offset_to = None }
-
-let create_constructor_field _loc =
- {
- field = <:expr< 0 >>;
- flen = <:expr< 32 >>;
- endian = ConstantEndian Bitstring.BigEndian;
- signed = false;
- t = Int;
- _loc = _loc;
- offset = None;
- check = None;
- bind = None;
- save_offset_to = None;
- }
-
-let set_lident_expr field id =
- let _loc = field._loc in
- { field with field = <:expr< $lid:id$ >> }
-let set_int_expr field i =
- let _loc = field._loc in
- { field with field = <:expr< $`int:i$ >> }
-let set_string_expr field str =
- let _loc = field._loc in
- { field with field = <:expr< $str:str$ >> }
-let set_expr field expr =
- let _loc = field._loc in
- { field with field = expr }
-
-let get_patt field = field.field
-let get_expr field = field.field
-let get_length field = field.flen
-let get_endian field = field.endian
-let get_signed field = field.signed
-let get_type field = field.t
-let get_location field = field._loc
-let get_offset field = field.offset
-let get_check field = field.check
-let get_bind field = field.bind
-let get_save_offset_to field = field.save_offset_to
diff --git a/bitstring_persistent.mli b/bitstring_persistent.mli
deleted file mode 100644
index 250306a..0000000
--- a/bitstring_persistent.mli
+++ /dev/null
@@ -1,539 +0,0 @@
-(** Bitstring persistent patterns. *)
-(* Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version,
- * with the OCaml linking exception described in COPYING.LIB.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * $Id$
- *)
-
-(**
- {b Warning:} This documentation is for ADVANCED USERS ONLY.
- If you are not an advanced user, you are probably looking
- for {{:Bitstring.html}the Bitstring documentation}.
-
- {{:#reference}Jump straight to the reference section for
- documentation on types and functions}.
-
- {2 Introduction}
-
- Bitstring allows you to name sets of fields and reuse them
- elsewhere. For example if you frequently need to parse
- Pascal-style strings in the form length byte + string, then you
- could name the [{ strlen : 8 : int; str : strlen*8 : string }]
- pattern and reuse it everywhere by name.
-
- These are called {b persistent patterns}.
-
- The basic usage is:
-
-{v
-(* Create a persistent pattern called 'pascal_string' which
- * matches Pascal-style strings (length byte + string).
- *)
-let bitmatch pascal_string =
- \{ strlen : 8 : int;
- str : strlen*8 : string }
-
-let is_pascal_string bits =
- bitmatch bits with
- | \{ :pascal_string } ->
- printf "matches a Pascal string %s, len %d bytes\n"
- str strlen
-v}
-
- or:
-
-{v
-(* Load a persistent pattern from a file. *)
-open bitmatch "pascal.bmpp"
-
-let is_pascal_string bits =
- bitmatch bits with
- | \{ :pascal_string } ->
- printf "matches a Pascal string %s, len %d bytes\n"
- str strlen
-v}
-
- {3 Important notes}
-
- There are some important things you should know about
- persistent patterns before you decide to use them:
-
- 'Persistent' refers to the fact that they can be saved into binary
- files. However these binary files use OCaml [Marshal] module and
- depend (sometimes) on the version of OCaml used to generate them
- and (sometimes) the version of bitstring used. So your build system
- should rebuild these files from source when your code is rebuilt.
-
- Persistent patterns are syntactic. They work in the same way
- as cutting and pasting (or [#include]-ing) code. For example
- if a persistent pattern binds a field named [len], then any
- uses of [len] following in the surrounding pattern could
- be affected.
-
- Programs which generate and manipulate persistent patterns have to
- link to camlp4. Since camlp4 in OCaml >= 3.10 is rather large, we
- have placed this code into this separate submodule, so that
- programs which just use bitstring don't need to pull in the whole of
- camlp4. This restriction does not apply to code which only uses
- persistent patterns but does not generate them. If the distinction
- isn't clear, use [ocamlobjinfo] to look at the dependencies of your
- [*.cmo] files.
-
- Persistent patterns can be generated in several ways, but they
- can only be {i used} by the [pa_bitstring] syntax extension.
- This means they are purely compile-time constructs. You
- cannot use them to make arbitrary patterns and run those
- patterns (not unless your program runs [ocamlc] to make a [*.cmo]
- file then dynamically links to the [*.cmo] file).
-
- {2 Named patterns}
-
- A named pattern is a way to name a pattern and use it later
- in the same source file. To name a pattern, use:
-
- [let bitmatch name = { fields ... } ;;]
-
- and you can then use the name later on inside another pattern,
- by prefixing the name with a colon.
- For example:
-
- [bitmatch bits with { :name } -> ...]
-
- You can nest named patterns within named patterns to any depth.
-
- Currently the use of named patterns is somewhat limited.
- The restrictions are:
-
- Named patterns can only be used within the same source file, and
- the names occupy a completely separate namespace from anything
- else in the source file.
-
- The [let bitmatch] syntax only works at the top level. We may
- add a [let bitmatch ... in] for inner levels later.
-
- Because you cannot rename the bound identifiers in named
- patterns, you can effectively only use them once in a
- pattern. For example, [{ :name; :name }] is legal, but
- any bindings in the first name would be overridden by
- the second name.
-
- There are no "named constructors" yet, but the machinery
- is in place to do this, and we may add them later.
-
- {2 Persistent patterns in files}
-
- More useful than just naming patterns, you can load
- persistent patterns from external files. The patterns
- in these external files can come from a variety of sources:
- for example, in the [cil-tools] subdirectory are some
- {{:http://cil.sf.net/}Cil-based} tools for importing C
- structures from header files. You can also generate
- your own files or write your own tools, as described below.
-
- To use the persistent pattern(s) from a file do:
-
- [open bitmatch "filename.bmpp" ;;]
-
- A list of zero or more {!named} patterns are read from the file
- and each is bound to a name (as contained in the file),
- and then the patterns can be used with the usual [:name]
- syntax described above.
-
- {3 Extension}
-
- The standard extension is [.bmpp]. This is just a convention
- and you can use any extension you want.
-
- {3 Directory search order}
-
- If the filename is an absolute or explicit path, then we try to
- load it from that path and stop if it fails. See the [Filename]
- module in the standard OCaml library for the definitions of
- "absolute path" and "explicit path". Otherwise we use the
- following directory search order:
-
- - Relative to the current directory
- - Relative to the OCaml library directory
-
- {3 bitstring-objinfo}
-
- The [bitstring-objinfo] command can be run on a file in order
- to print out the patterns in the file.
-
- {3 Constructors}
-
- We haven't implemented persistent constructors yet, although
- the machinery is in place to make this happen. Any constructors
- found in the file are ignored.
-
- {2 Creating your own persistent patterns}
-
- If you want to write a tool to import bitstrings from an
- exotic location or markup language, you will need
- to use the functions found in the {{:#reference}reference section}.
-
- I will describe using an example here of how you would
- programmatically create a persistent pattern which
- matches Pascal-style "length byte + data" strings.
- Firstly note that there are two fields, so our pattern
- will be a list of length 2 and type {!pattern}.
-
- You will need to create a camlp4 location object ([Loc.t])
- describing the source file. This source file is used
- to generate useful error messages for the user, so
- you may want to set it to be the name and location in
- the file that your tool reads for input. By convention,
- locations are bound to name [_loc]:
-
- {v
- let _loc = Loc.move_line 42 (Loc.mk "input.xml")
- v}
-
- Create a pattern field representing a length field which is 8 bits wide,
- bound to the identifier [len]:
-
- {v
- let len_field = create_pattern_field _loc
- let len_field = set_length_int len_field 8
- let len_field = set_lident_patt len_field "len"
- v}
-
- Create a pattern field representing a string of [len*8] bits.
- Note that the use of [<:expr< >>] quotation requires
- you to preprocess your source with [camlp4of]
- (see {{:http://brion.inria.fr/gallium/index.php/Reflective_OCaml}this
- page on Reflective OCaml}).
-
- {v
- let str_field = create_pattern_field _loc
- let str_field = set_length str_field <:expr< len*8 >>
- let str_field = set_lident_patt str_field "str"
- let str_field = set_type_string str_field
- v}
-
- Join the two fields together and name it:
-
- {v
- let pattern = [len_field; str_field]
- let named_pattern = "pascal_string", Pattern pattern
- v}
-
- Save it to a file:
-
- {v
- let chan = open_out "output.bmpp" in
- named_to_channel chan named_pattern;
- close_out chan
- v}
-
- You can now use this pattern in another program like this:
-
- {v
- open bitmatch "output.bmpp" ;;
- let parse_pascal_string bits =
- bitmatch bits with
- | \{ :pascal_string } -> str, len
- | \{ _ } -> invalid_arg "not a Pascal string"
- v}
-
- You can write more than one named pattern to the output file, and
- they will all be loaded at the same time by [open bitmatch ".."]
- (obviously you should give each pattern a different name). To do
- this, just call {!named_to_channel} as many times as needed.
-
- {2:reference Reference}
-
- {3 Types}
-*)
-
-type patt = Camlp4.PreCast.Syntax.Ast.patt
-type expr = Camlp4.PreCast.Syntax.Ast.expr
-type loc_t = Camlp4.PreCast.Syntax.Ast.Loc.t
-(** Just short names for the camlp4 types. *)
-
-type 'a field
-(** A field in a persistent pattern or persistent constructor. *)
-
-type pattern = patt field list
-(** A persistent pattern (used in [bitmatch] operator), is just a
- list of pattern fields. *)
-
-type constructor = expr field list
-(** A persistent constructor (used in [BITSTRING] operator), is just a
- list of constructor fields. *)
-
-type named = string * alt
-and alt =
- | Pattern of pattern (** Pattern *)
- | Constructor of constructor (** Constructor *)
-(** A named pattern or constructor.
-
- The name is used when binding a pattern from a file, but
- is otherwise ignored. *)
-
-(** {3 Printers} *)
-
-val string_of_pattern : pattern -> string
-val string_of_constructor : constructor -> string
-val string_of_pattern_field : patt field -> string
-val string_of_constructor_field : expr field -> string
-(** Convert patterns, constructors or individual fields
- into printable strings for debugging purposes.
-
- The strings look similar to the syntax used by bitmatch, but
- some things cannot be printed fully, eg. length expressions. *)
-
-(** {3 Persistence} *)
-
-val named_to_channel : out_channel -> named -> unit
-(** Save a pattern/constructor to an output channel. *)
-
-val named_to_string : named -> string
-(** Serialize a pattern/constructor to a string. *)
-
-val named_to_buffer : string -> int -> int -> named -> int
-(** Serialize a pattern/constructor to part of a string, return the length. *)
-
-val named_from_channel : in_channel -> named
-(** Load a pattern/constructor from an output channel.
-
- Note: This is not type safe. The pattern/constructor must
- have been written out under the same version of OCaml and
- the same version of bitstring. *)
-
-val named_from_string : string -> int -> named
-(** Load a pattern/constructor from a string at offset within the string.
-
- Note: This is not type safe. The pattern/constructor must
- have been written out under the same version of OCaml and
- the same version of bitstring. *)
-
-(** {3 Create pattern fields}
-
- These fields are used in pattern matches ([bitmatch]). *)
-
-val create_pattern_field : loc_t -> patt field
-(** Create a pattern field.
-
- The pattern is unbound, the type is set to [int], bit length to [32],
- endianness to [BigEndian], signedness to unsigned ([false]),
- source code location to the [_loc] parameter, and no offset expression.
-
- To create a complete field you need to call the [set_*]
- functions. For example, to create [{ len : 8 : int }]
- you would do:
-
-{v
- let field = create_pattern_field _loc in
- let field = set_lident_patt field "len" in
- let field = set_length_int field 8 in
-v}
-*)
-
-val set_lident_patt : patt field -> string -> patt field
-(** Sets the pattern to the pattern binding an identifier
- given in the string.
-
- The effect is that the field [{ len : 8 : int }] could
- be created by calling [set_lident_patt field "len"]. *)
-
-val set_int_patt : patt field -> int -> patt field
-(** Sets the pattern field to the pattern which matches an integer.
-
- The effect is that the field [{ 2 : 8 : int }] could
- be created by calling [set_int_patt field 2]. *)
-
-val set_string_patt : patt field -> string -> patt field
-(** Sets the pattern field to the pattern which matches a string.
-
- The effect is that the field [{ "MAGIC" : 8*5 : string }] could
- be created by calling [set_int_patt field "MAGIC"]. *)
-
-val set_unbound_patt : patt field -> patt field
-(** Sets the pattern field to the unbound pattern (usually written [_]).
-
- The effect is that the field [{ _ : 8 : int }] could
- be created by calling [set_unbound_patt field]. *)
-
-val set_patt : patt field -> patt -> patt field
-(** Sets the pattern field to an arbitrary OCaml pattern match. *)
-
-val set_length_int : 'a field -> int -> 'a field
-(** Sets the length in bits of a field to a constant integer.
-
- The effect is that the field [{ len : 8 : string }] could
- be created by calling [set_length field 8]. *)
-
-val set_length : 'a field -> expr -> 'a field
-(** Sets the length in bits of a field to an OCaml expression.
-
- The effect is that the field [{ len : 2*i : string }] could
- be created by calling [set_length field <:expr< 2*i >>]. *)
-
-val set_endian : 'a field -> Bitstring.endian -> 'a field
-(** Sets the endianness of a field to the constant endianness.
-
- The effect is that the field [{ _ : 16 : bigendian }] could
- be created by calling [set_endian field Bitstring.BigEndian]. *)
-
-val set_endian_expr : 'a field -> expr -> 'a field
-(** Sets the endianness of a field to an endianness expression.
-
- The effect is that the field [{ _ : 16 : endian(e) }] could
- be created by calling [set_endian_expr field e]. *)
-
-val set_signed : 'a field -> bool -> 'a field
-(** Sets the signedness of a field to a constant signedness.
-
- The effect is that the field [{ _ : 16 : signed }] could
- be created by calling [set_signed field true]. *)
-
-val set_type_int : 'a field -> 'a field
-(** Sets the type of a field to [int].
-
- The effect is that the field [{ _ : 16 : int }] could
- be created by calling [set_type_int field]. *)
-
-val set_type_string : 'a field -> 'a field
-(** Sets the type of a field to [string].
-
- The effect is that the field [{ str : 16 : string }] could
- be created by calling [set_type_string field]. *)
-
-val set_type_bitstring : 'a field -> 'a field
-(** Sets the type of a field to [bitstring].
-
- The effect is that the field [{ _ : 768 : bitstring }] could
- be created by calling [set_type_bitstring field]. *)
-
-val set_location : 'a field -> loc_t -> 'a field
-(** Sets the source code location of a field. This is used when
- pa_bitstring displays error messages. *)
-
-val set_offset_int : 'a field -> int -> 'a field
-(** Set the offset expression for a field to the given number.
-
- The effect is that the field [{ _ : 8 : offset(160) }] could
- be created by calling [set_offset_int field 160]. *)
-
-val set_offset : 'a field -> expr -> 'a field
-(** Set the offset expression for a field to the given expression.
-
- The effect is that the field [{ _ : 8 : offset(160) }] could
- be created by calling [set_offset_int field <:expr< 160 >>]. *)
-
-val set_no_offset : 'a field -> 'a field
-(** Remove the offset expression from a field. The field will
- follow the previous field, or if it is the first field will
- be at offset zero. *)
-
-val set_check : 'a field -> expr -> 'a field
-(** Set the check expression for a field to the given expression. *)
-
-val set_no_check : 'a field -> 'a field
-(** Remove the check expression from a field. *)
-
-val set_bind : 'a field -> expr -> 'a field
-(** Set the bind-expression for a field to the given expression. *)
-
-val set_no_bind : 'a field -> 'a field
-(** Remove the bind-expression from a field. *)
-
-val set_save_offset_to : 'a field -> patt -> 'a field
-(** Set the save_offset_to pattern for a field to the given pattern. *)
-
-val set_save_offset_to_lident : 'a field -> string -> 'a field
-(** Set the save_offset_to pattern for a field to identifier. *)
-
-val set_no_save_offset_to : 'a field -> 'a field
-(** Remove the save_offset_to from a field. *)
-
-(** {3 Create constructor fields}
-
- These fields are used in constructors ([BITSTRING]). *)
-
-val create_constructor_field : loc_t -> expr field
-(** Create a constructor field.
-
- The defaults are the same as for {!create_pattern_field}
- except that the expression is initialized to [0].
-*)
-
-val set_lident_expr : expr field -> string -> expr field
-(** Sets the expression in a constructor field to an expression
- which uses the identifier.
-
- The effect is that the field [{ len : 8 : int }] could
- be created by calling [set_lident_expr field "len"]. *)
-
-val set_int_expr : expr field -> int -> expr field
-(** Sets the expression to the value of the integer.
-
- The effect is that the field [{ 2 : 8 : int }] could
- be created by calling [set_int_expr field 2]. *)
-
-val set_string_expr : expr field -> string -> expr field
-(** Sets the expression to the value of the string.
-
- The effect is that the field [{ "MAGIC" : 8*5 : string }] could
- be created by calling [set_int_expr field "MAGIC"]. *)
-
-val set_expr : expr field -> expr -> expr field
-(** Sets the expression field to an arbitrary OCaml expression. *)
-
-(** {3 Accessors} *)
-
-val get_patt : patt field -> patt
-(** Get the pattern from a pattern field. *)
-
-val get_expr : expr field -> expr
-(** Get the expression from an expression field. *)
-
-val get_length : 'a field -> expr
-(** Get the length in bits from a field. Note that what is returned
- is an OCaml expression, since lengths can be non-constant. *)
-
-type endian_expr =
- | ConstantEndian of Bitstring.endian
- | EndianExpr of expr
-
-val get_endian : 'a field -> endian_expr
-(** Get the endianness of a field. This is an {!endian_expr} which
- could be a constant or an OCaml expression. *)
-
-val get_signed : 'a field -> bool
-(** Get the signedness of a field. *)
-
-type field_type = Int | String | Bitstring
-
-val get_type : 'a field -> field_type
-(** Get the type of a field, [Int], [String] or [Bitstring]. *)
-
-val get_location : 'a field -> loc_t
-(** Get the source code location of a field. *)
-
-val get_offset : 'a field -> expr option
-(** Get the offset expression of a field, or [None] if there is none. *)
-
-val get_check : 'a field -> expr option
-(** Get the check expression of a field, or [None] if there is none. *)
-
-val get_bind : 'a field -> expr option
-(** Get the bind expression of a field, or [None] if there is none. *)
-
-val get_save_offset_to : 'a field -> patt option
-(** Get the save_offset_to pattern of a field, or [None] if there is none. *)
diff --git a/bootstrap b/bootstrap
deleted file mode 100755
index 06d18c4..0000000
--- a/bootstrap
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-aclocal
-autoheader
-autoconf
diff --git a/cil-tools/.depend b/cil-tools/.depend
deleted file mode 100644
index 8def24e..0000000
--- a/cil-tools/.depend
+++ /dev/null
@@ -1,4 +0,0 @@
-bitstring_import_c.cmo: ../bitstring_persistent.cmi ../bitstring_config.cmo \
- ../bitstring.cmi
-bitstring_import_c.cmx: ../bitstring_persistent.cmx ../bitstring_config.cmx \
- ../bitstring.cmx
diff --git a/cil-tools/Makefile.in b/cil-tools/Makefile.in
deleted file mode 100644
index c439ecc..0000000
--- a/cil-tools/Makefile.in
+++ /dev/null
@@ -1,129 +0,0 @@
-# Bitstring CIL tools for processing C code.
-# Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# $Id$
-
-PACKAGE = @PACKAGE_NAME@
-VERSION = @PACKAGE_VERSION@
-
-OCAMLFIND = @OCAMLFIND@
-OCAMLMKLIB = @OCAMLMKLIB@
-OCAMLDOC = @OCAMLDOC@
-INSTALL = @INSTALL@
-
-enable_coverage = @enable_coverage@
-
-OCAMLCFLAGS = -g
-OCAMLCPACKAGES = -package dynlink,unix,str,extlib,cil -I +camlp4 -I ..
-OCAMLCLIBS = $(OCAMLCPACKAGES) camlp4lib.cma -linkpkg ../bitstring.cma ../bitstring_persistent.cma
-OCAMLOPTFLAGS =
-OCAMLOPTPACKAGES = $(OCAMLCPACKAGES)
-OCAMLOPTLIBS = $(OCAMLOPTPACKAGES) camlp4lib.cmxa -linkpkg ../bitstring.cmxa ../bitstring_persistent.cmxa
-
-ifneq ($(enable_coverage),no)
-OCAMLCLIBS := -I +bisect bisect.cma $(OCAMLCLIBS)
-OCAMLOPTLIBS := -I +bisect bisect.cmxa $(OCAMLOPTLIBS)
-endif
-
-PP = -pp "camlp4o -I .. bitstring.cma bitstring_persistent.cma pa_bitstring.cmo"
-
-OCAMLDOCFLAGS = -html -sort
-
-all: bitstring-import-c bitstring-import-c.opt
-
-bitstring-import-c: bitstring_import_c.cmo
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCLIBS) $< -o $@
-
-bitstring-import-c.opt: bitstring_import_c.cmx
- $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTLIBS) $< -o $@
-
-test:
-
-# Examples.
-#
-# To compile task_struct you'll need to grab a copy of the Linux
-# kernel original header files and set the directory below.
-
-#DEBUG =
-DEBUG = --debug
-LINUX_HEADERS = linux-2.6.25.7-headers
-LINUX_INCLUDES = -I $(LINUX_HEADERS)
-
-#EXAMPLES = ext3 task_struct
-EXAMPLES = ext3
-
-examples: $(EXAMPLES)
-
-ext3: ext3.cmo
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCLIBS) $< -o $@
-
-ext3.cmo: ext3.ml ext3.bmpp
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $(PP) -c $< -o $@
-
-ext3.bmpp: ext3.c bitstring-import-c
- rm -f $@.new
- ./bitstring-import-c $(DEBUG) $< > $@.new
- mv $@.new $@
-
-task_struct: task_struct.cmo
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCLIBS) $< -o $@
-
-task_struct.cmo: task_struct.ml task_struct.bmpp
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $(PP) -c $< -o $@
-
-task_struct.bmpp: task_struct.c bitstring-import-c
- cd $(LINUX_HEADERS) && ln -sf asm-x86 asm
- rm -f $@.new
- ./bitstring-import-c $(DEBUG) $(LINUX_INCLUDES) $< > $@.new
- mv $@.new $@
-
-# Clean.
-
-clean:
- rm -f core *~ *.cmi *.cmo *.cmx *.cma *.cmxa *.a *.o *.bmpp
- rm -f bitstring-import-c bitstring-import-c.opt
- rm -f ext3 task_struct
-
-distclean: clean
-
-# Install.
-
-install:
-
-# Standard rules.
-
-.mli.cmi:
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
-.ml.cmo:
- $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
-.ml.cmx:
- $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $<
-
-depend: .depend
-
-.depend: bitstring_import_c.ml
- rm -f .depend
- $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) $^ > $@
-
-ifeq ($(wildcard .depend),.depend)
-include .depend
-endif
-
-.PHONY: depend dist check-manifest dpkg doc \
- print-examples print-tests examples test
-
-.SUFFIXES: .cmo .cmi .cmx .ml .mli .mll
diff --git a/cil-tools/bitstring-import-prefix.h b/cil-tools/bitstring-import-prefix.h
deleted file mode 100644
index 52b8a69..0000000
--- a/cil-tools/bitstring-import-prefix.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* This file is automagically prefixed to all .ubd files
- * and provides some macros that we need for CIL.
- *
- * This file is in the public domain.
- */
-
-/* This is needed for older versions of CIL which didn't
- * support this C99 type.
- */
-#ifndef _Bool
-#define _Bool unsigned
-#endif
-
-#define BITSTRING_IMPORT(name) __bitstring_import_##name
-#define BITSTRING_CONSTANT_STRING(name,val) \
- char *__bitstring_constant_##name = val
-#define BITSTRING_CONSTANT_INT32(name,val) \
- int __bitstring_constant_##name = val
diff --git a/cil-tools/bitstring_import_c.ml b/cil-tools/bitstring_import_c.ml
deleted file mode 100644
index 802c009..0000000
--- a/cil-tools/bitstring_import_c.ml
+++ /dev/null
@@ -1,374 +0,0 @@
-(* Import a C header file.
- * Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- *)
-
-open Printf
-open ExtList
-open ExtString
-
-open Cil
-
-module P = Bitstring_persistent
-
-let (//) = Filename.concat
-
-let () =
- (* Parse command line arguments. *)
- let debug = ref false in
- let save_temps = ref false in
- let version () =
- printf "bitstring-import-c %s" Bitstring.version;
- exit 1
- in
- let cpp_args = ref [] in
- let cpp_arg2 name value =
- cpp_args := (name ^ value) :: !cpp_args
- in
-
- let argspec = Arg.align [
- "--debug", Arg.Set debug,
- " Debug messages";
- "--version", Arg.Unit version,
- " Display version and exit";
- "-save-temps", Arg.Set save_temps,
- " Save temporary files";
- "-I", Arg.String (cpp_arg2 "-I"),
- "dir Specify extra include directory for cpp";
- "-D", Arg.String (cpp_arg2 "-D"),
- "name=value Define value in cpp";
- "-U", Arg.String (cpp_arg2 "-U"),
- "name Undefine value in cpp";
- ] in
-
- let input_file = ref None in
- let anon_fun str =
- match !input_file with
- | None -> input_file := Some str
- | Some _ ->
- eprintf "bitstring-import-c: only give a single input file\n";
- exit 1
- in
- let usage_msg = "\
-
-bitstring-import-c: Import C structures and constants and
- generate bitmatching functions from them. Please see the
- manual page bitstring-import-c(1) for more information.
-
-OPTIONS" in
-
- Arg.parse argspec anon_fun usage_msg;
-
- let debug = !debug in
- let save_temps = !save_temps in
- let input_file =
- match !input_file with
- | Some f -> f
- | None ->
- eprintf "bitstring-import-c: no input file specified\n";
- exit 1 in
- let cpp_args = List.rev !cpp_args in
-
- (* Grab the file and pass it to the preprocessor, and then read the
- * C code into memory using CIL.
- *)
- msvcMode := false;
- Cil.initCIL ();
-
- (* XXX Unavoidable tmp exploit here. Fix? *)
- let tmp, delete_tmp =
- if not save_temps then (
- let tmp = Filename.temp_file (Filename.temp_dir_name) ".i" in
- tmp, fun () -> try Unix.unlink tmp with Unix.Unix_error _ -> ()
- ) else (
- let tmp = Filename.chop_extension input_file ^ ".i" in
- tmp, fun () -> (* -save-temps, so do nothing *) ()
- ) in
-
- let cmd =
- sprintf "cpp %s -I %s -include bitstring-import-prefix.h %s > %s"
- (String.concat " " (List.map Filename.quote cpp_args))
- (Filename.quote (Bitstring_config.ocamllibdir // "bitstring"))
- (Filename.quote input_file) (Filename.quote tmp) in
- if debug then prerr_endline cmd;
- if Sys.command cmd <> 0 then (
- eprintf "%s: command failed\n" cmd;
- delete_tmp ();
- exit 1
- );
-
- (* Why does Frontc.parse return a continuation ...? *)
- let file = (Frontc.parse tmp) () in
- delete_tmp ();
-
- (* Find out which structures, #defines, etc. are to be imported.
- * (cf. the macros in bitstring-import-prefix.h)
- *)
- let constants =
- List.filter_map (
- function
- | GVar ({vname = vname; vtype = vtype},
- { init = Some (SingleInit vinit) },
- loc)
- when String.starts_with vname "__bitstring_constant_" ->
- let vname = String.sub vname 20 (String.length vname - 20) in
-
- (* Do constant folding on the initializer and then calculate
- * its compile-time value.
- *)
- let vinit =
- match isInteger (constFold true vinit) with
- | Some i -> i
- | None ->
- Errormsg.error
- "%a: non-constant initializer: %a" d_loc loc d_exp vinit;
- -1L in
-
- Some (vname, vinit, loc)
- | _ -> None
- ) file.globals in
- let structs =
- List.filter_map (
- function
- | GType ({tname = tname; ttype = ttype}, loc)
- when String.starts_with tname "__bitstring_import_" ->
- let tname = String.sub tname 18 (String.length tname - 18) in
- Some (tname, ttype, loc)
- | _ -> None
- ) file.globals in
-
- if !Errormsg.hadErrors then exit 1;
-
- (* If debugging, print out the imports. *)
- if debug then (
- List.iter (
- fun (vname, vinit, loc) ->
- Errormsg.log "%a: import %s as constant 0x%LX\n" d_loc loc vname vinit;
- ) constants;
- List.iter (
- fun (tname, ttype, loc) ->
- Errormsg.log "%a: import %s as %a\n" d_loc loc tname d_type ttype;
- ) structs;
- );
-
-(*
- (* Output constants.
- * XXX Disabled at the moment until we work out where to put them XXX
- *)
- List.iter (
- fun (vname, vinit, loc) ->
- printf "let %s = 0x%LX\n" vname vinit
- ) constants;
-*)
-
- (* Output structures. *)
- List.iter (
- fun (tname, ttype, loc) ->
- (* Uncomment the next line if you want to really print the
- * complete CIL structure of the type (for debugging etc.).
- * The ASTs printed here are usually quite large.
- *)
- (*Errormsg.log "%a: %s %a\n" d_loc loc tname d_plaintype ttype;*)
-
- (* Recursive function to generate a persistent pattern from a
- * C struct or union. Quite a few limitations at the moment:
- * (1) Structure elements must be in order.
- * (2) Doesn't really work with unions [XXX].
- *
- * Parameters:
- * ?names List of names of parent structs. Used in the
- * recursive case for nested structs.
- * ?offset Offset of struct within parent, usually NoOffset. Used
- * in the recursive case for nested structs.
- * ?endian Inherited endianness, usually None. Used for C
- * __attribute__((bitwise)).
- * ttype CIL type of struct.
- * Returns:
- * pattern A bitstring persistent pattern.
- *)
- let rec pattern_of_struct ?(names=[]) ?(offset=NoOffset) ?(endian=None)
- ttype =
- match ttype with
- (* Some types contain attributes to indicate their
- * endianness. See many examples from <linux/types.h>.
- *)
- | (TNamed ({ tname = tname;
- ttype = TNamed (_, attrs) },
- _) as t)
- when hasAttribute "bitwise" attrs ->
- let endian =
- if String.starts_with tname "__le" then
- Some Bitstring.LittleEndian
- else if String.starts_with tname "__be" then
- Some Bitstring.BigEndian
- else (
- Errormsg.warn "%a: unknown bitwise attribute typename: %s\n"
- d_loc loc tname;
- endian
- ) in
- pattern_of_struct ~names ~offset ~endian (unrollType t)
-
- (* See into named types. *)
- | (TNamed _ as t) ->
- pattern_of_struct ~names ~offset ~endian (unrollType t)
-
- (* struct or union *)
- | TComp ({ cdefined = true; cfields = cfields }, _) ->
- let cfields =
- List.map (
- fun ({ fname = fname; ftype = ftype } as finfo) ->
- let offset = Field (finfo, offset) in
- let names = fname :: names in
- pattern_of_struct ~names ~offset ~endian ftype
- ) cfields in
- List.flatten cfields
-
- (* int array with constant length *)
- | TArray (basetype, (Some _ as len), _) when isIntegralType basetype ->
- let nr_elems = lenOfArray len in
- let bitsoffset, totalwidth = bitsOffset ttype offset in
- let bitswidth = totalwidth / nr_elems (* of the element *) in
- let basetype = unrollType basetype in
- let ikind =
- match basetype with
- | TInt (ikind, _) -> ikind
- | t ->
- Errormsg.unimp "%a: unhandled type: %a" d_loc loc d_type t;
- IInt in
- let fname = String.concat "_" (List.rev names) in
-
- (* If the base type is 8 bits then we always translate this to
- * a string (whether the C type is signed or unsigned). There
- * is no endianness in bytes so ignore that.
- *)
- if bitswidth = 8 then
- [pattern_field_of_string fname bitsoffset nr_elems]
- else (
- (* XXX Realistically we don't handle arrays well at
- * the moment. Perhaps we should give up and match
- * this to a bitstring?
- *)
- let signed = isSigned ikind in
- if debug then
- eprintf "--> array %s: nr_elems=%d signed=%b\n"
- fname nr_elems signed;
- [] (* XXX *)
- )
-
- (* basic integer type *)
- | TInt (ikind, _) ->
- let bitsoffset, bitswidth = bitsOffset ttype offset in
- (*if debug then (
- let name = String.concat "." (List.rev names) in
- Errormsg.log "%s: int: %d, %d\n" name bitsoffset bitswidth
- );*)
- let fname = String.concat "_" (List.rev names) in
- let field =
- pattern_field_of_int fname bitsoffset bitswidth ikind endian in
- [field]
-
- (* a pointer - in this mapping we assume this is an address
- * (endianness and wordsize come from function parameters),
- * in other words we DON'T try to follow pointers, we just
- * note that they are there.
- *)
- | TPtr _ ->
- let bitsoffset, bitswidth = bitsOffset ttype offset in
- let fname = String.concat "_" (List.rev names) in
- if debug then
- eprintf "--> pointer %s: bitsoffset=%d bitswidth=%d\n"
- fname bitsoffset bitswidth;
- [] (* XXX *)
-
- | t ->
- Errormsg.warn "pattern_of_struct: %a: unhandled type: %a"
- d_loc loc d_type t;
- []
-
- (* Convert a single int field into a pattern field.
- * Could be a bitfield, byte, short, etc.
- *)
- and pattern_field_of_int fname bitsoffset bitswidth ikind endian =
- let signed = isSigned ikind in
- let _loc = camlp4_loc_of_cil_loc loc in
-
- let field = P.create_pattern_field _loc in
- let field = P.set_lident_patt field fname in
- let field = P.set_type_int field in
- let field = P.set_length_int field bitswidth in
- let field = P.set_offset_int field bitsoffset in
- let field = P.set_signed field signed in
- let field =
- match endian with
- | Some endian -> P.set_endian field endian
- | None -> P.set_endian field Bitstring.NativeEndian in
-
- field
-
- and pattern_field_of_string fname bitsoffset nr_elems =
- let _loc = camlp4_loc_of_cil_loc loc in
- let field = P.create_pattern_field _loc in
- let field = P.set_lident_patt field fname in
- let field = P.set_type_string field in
- let field = P.set_length_int field (nr_elems*8) in
- let field = P.set_offset_int field bitsoffset in
- field
-
- (* Convert a CIL location into a camlp4 location. Grrr these
- * should be compatible!
- *)
- and camlp4_loc_of_cil_loc loc =
- let _loc = Camlp4.PreCast.Syntax.Ast.Loc.mk loc.file in
- Camlp4.PreCast.Syntax.Ast.Loc.move_line loc.line _loc
- in
-
- (* Match on the type of this structure, and from it generate
- * a single parsing function.
- *)
- match ttype with
- (* struct or union *)
- | TComp ({ cdefined = true; cname = cname }, _) ->
- let pattern = pattern_of_struct ttype in
- let named_pattern = cname, P.Pattern pattern in
- P.named_to_channel stdout named_pattern
-
- (* An undefined struct or union -- means one which was only ever
- * defined with 'struct foo;'. This is an error.
- *)
- | TComp ({ cdefined = false; cname = cname }, _) ->
- Errormsg.error
- "%a: struct or union has no definition: %s" d_loc loc cname
-
- (* Types which are not allowed, eg. void, int, arrays. *)
- | TVoid _ | TInt _ | TFloat _ | TPtr _ | TArray _ | TFun _
- | TNamed _ | TBuiltin_va_list _ ->
- Errormsg.error
- "%a: not a struct or union: %a" d_loc loc d_type ttype
-
- (* Types which we might implement in the future.
- * For enum we should probably split out enums separately
- * from structs above, since enums are more like constants.
- *)
- | TEnum ({ ename = ename }, _) ->
- Errormsg.unimp "%a: %a" d_loc loc d_type ttype
-
- ) structs;
-
- if !Errormsg.hadErrors then exit 1;
-
- exit 0
diff --git a/cil-tools/ext3.c b/cil-tools/ext3.c
deleted file mode 100644
index b666016..0000000
--- a/cil-tools/ext3.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* This is an example import file, showing how to import the ext3
- * superblock automatically from Linux header files.
- *
- * Use: bitstring-import-c ext3.c > ext3.bmpp
- *
- * Tip: Add the --debug flag to that command line to see what's going on.
- * Also use bitstring-objinfo to examine the bmpp file.
- */
-
-/* These are required by Linux in order to get the little/big-endian
- * notations present in the Linux kernel header files. Any other
- * defines needed can go here.
- */
-#define __CHECKER__ 1
-#define __CHECK_ENDIAN__ 1
-
-/* Include files necessary to get the structure(s) and constant(s) we're
- * interested in.
- */
-#include <linux/fs.h>
-#include <linux/magic.h>
-#include <linux/ext2_fs.h>
-
-/* This tells the importer program what structures and constants to import. */
-//typedef struct ext3_super_block BITSTRING_IMPORT(ext3_super_block);
-typedef struct ext2_super_block BITSTRING_IMPORT(ext3_super_block);
-BITSTRING_CONSTANT_INT32 (ext3_super_magic, EXT3_SUPER_MAGIC);
diff --git a/cil-tools/ext3.ml b/cil-tools/ext3.ml
deleted file mode 100644
index 23e9ce3..0000000
--- a/cil-tools/ext3.ml
+++ /dev/null
@@ -1,29 +0,0 @@
-(* This is an example program using an imported C structure.
- *
- * The C structure is imported from <linux/ext3_fs.h> via "ext3.c"
- * by the bitstring-import-c program, and saved as "ext3.bmpp".
- *
- * Then we can load "ext3.bmpp" here.
- *)
-
-open Printf
-
-open bitmatch "ext3.bmpp"
-
-let () =
- (* Load a real ext3 superblock from the examples directory. *)
- let bits = Bitstring.bitstring_of_file "examples/ext3_sb" in
-
- bitmatch bits with
- | { :ext2_super_block } ->
- printf "ext3 superblock:\n";
- printf " s_inodes_count = %ld\n" s_inodes_count;
- printf " s_blocks_count = %ld\n" s_blocks_count;
- printf " s_free_inodes_count = %ld\n" s_free_inodes_count;
- printf " s_free_blocks_count = %ld\n" s_free_blocks_count;
- printf " s_uuid = %S\n" s_uuid;
- printf " s_volume_name = %S\n" s_volume_name;
- printf " s_last_mounted = %S\n" s_last_mounted
-
- | { _ } ->
- failwith "input is not an ext2/3 superblock"
diff --git a/cil-tools/task_struct.c b/cil-tools/task_struct.c
deleted file mode 100644
index c5dbac3..0000000
--- a/cil-tools/task_struct.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* This is an example import file, showing how to import the
- * Linux task_struct structure from header files.
- *
- * Use: bitstring-import-c task_struct.c > task_struct.ml
- *
- * Tip: Add the --debug flag to that command line to see what's going on.
- * Also use bitstring-objinfo to examine the bmpp file.
- */
-
-/* Any defines, etc. necessary to get the include to work. */
-#define __KERNEL__
-#define CONFIG_HZ 100
-#define CONFIG_PAGE_OFFSETUL 0xc0000000 /* XXX? */
-#define THREAD_SIZE 4096 /* XXX? */
-
-/* Include files necessary to get the structure(s) and constant(s) we're
- * interested in.
- *
- * Note in this case glibc strips the useful structures out of the
- * so-called "kernel headers" that it supplies, so instead I have
- * a local copy of the real headers from a version of Linux.
- */
-#include "linux/sched.h"
-
-/* This tells the importer program what structures and constants to import. */
-typedef struct task_struct BITSTRING_IMPORT(task_struct);
diff --git a/cil-tools/task_struct.ml b/cil-tools/task_struct.ml
deleted file mode 100644
index db0596e..0000000
--- a/cil-tools/task_struct.ml
+++ /dev/null
@@ -1,17 +0,0 @@
-(* This is an example program using an imported C structure.
- *
- * The Linux process table entry structure is imported from
- * <linux/sched.h> via "task_struct.c" by the bitstring-import-c
- * program, and saved as "task_struct.bmpp".
- *
- * Then we can load "task_struct.bmpp" here.
- *)
-
-open Printf
-
-open bitmatch "task_struct.bmpp"
-
-(*
-let () =
- let bits = Bitstring.bitstring_of_file "examples/ext3_sb" in
-*)
diff --git a/config.h.in b/config.h.in
deleted file mode 100644
index d16cd04..0000000
--- a/config.h.in
+++ /dev/null
@@ -1,76 +0,0 @@
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define if building universal (internal helper macro) */
-#undef AC_APPLE_UNIVERSAL_BUILD
-
-/* Define to 1 if you have the <byteswap.h> header file. */
-#undef HAVE_BYTESWAP_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-#undef NO_MINUS_C_MINUS_O
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define to 1 if the C compiler supports function prototypes. */
-#undef PROTOTYPES
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
- significant byte first (like Motorola and SPARC, unlike Intel). */
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-# endif
-#else
-# ifndef WORDS_BIGENDIAN
-# undef WORDS_BIGENDIAN
-# endif
-#endif
-
-/* Define like PROTOTYPES; this can be used by system headers. */
-#undef __PROTOTYPES
diff --git a/configure b/configure
deleted file mode 100755
index 85918ef..0000000
--- a/configure
+++ /dev/null
@@ -1,6420 +0,0 @@
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for ocaml-bitstring 2.0.4.
-#
-#
-# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
-#
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
- emulate sh
- NULLCMD=:
- # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
-else
- case `(set -o) 2>/dev/null` in #(
- *posix*) :
- set -o posix ;; #(
- *) :
- ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
- && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
- as_echo='print -r --'
- as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
- as_echo='printf %s\n'
- as_echo_n='printf %s'
-else
- if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
- as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
- as_echo_n='/usr/ucb/echo -n'
- else
- as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
- as_echo_n_body='eval
- arg=$1;
- case $arg in #(
- *"$as_nl"*)
- expr "X$arg" : "X\\(.*\\)$as_nl";
- arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
- esac;
- expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
- '
- export as_echo_n_body
- as_echo_n='sh -c $as_echo_n_body as_echo'
- fi
- export as_echo_body
- as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- PATH_SEPARATOR=:
- (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
- (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
- PATH_SEPARATOR=';'
- }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order. Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" "" $as_nl"
-
-# Find who we are. Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
- done
-IFS=$as_save_IFS
-
- ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
- as_myself=$0
-fi
-if test ! -f "$as_myself"; then
- $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
- exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there. '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
- && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-# Use a proper internal environment variable to ensure we don't fall
- # into an infinite loop, continuously re-executing ourselves.
- if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
- _as_can_reexec=no; export _as_can_reexec;
- # We cannot yet assume a decent shell, so we have to provide a
-# neutralization value for shells without unset; and this also
-# works around shells that cannot unset nonexistent variables.
-# Preserve -v and -x to the replacement shell.
-BASH_ENV=/dev/null
-ENV=/dev/null
-(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-case $- in # ((((
- *v*x* | *x*v* ) as_opts=-vx ;;
- *v* ) as_opts=-v ;;
- *x* ) as_opts=-x ;;
- * ) as_opts= ;;
-esac
-exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-# Admittedly, this is quite paranoid, since all the known shells bail
-# out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-as_fn_exit 255
- fi
- # We don't want this to propagate to other subprocesses.
- { _as_can_reexec=; unset _as_can_reexec;}
-if test "x$CONFIG_SHELL" = x; then
- as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
- emulate sh
- NULLCMD=:
- # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '\${1+\"\$@\"}'='\"\$@\"'
- setopt NO_GLOB_SUBST
-else
- case \`(set -o) 2>/dev/null\` in #(
- *posix*) :
- set -o posix ;; #(
- *) :
- ;;
-esac
-fi
-"
- as_required="as_fn_return () { (exit \$1); }
-as_fn_success () { as_fn_return 0; }
-as_fn_failure () { as_fn_return 1; }
-as_fn_ret_success () { return 0; }
-as_fn_ret_failure () { return 1; }
-
-exitcode=0
-as_fn_success || { exitcode=1; echo as_fn_success failed.; }
-as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
-as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
-as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
-if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
-
-else
- exitcode=1; echo positional parameters were not saved.
-fi
-test x\$exitcode = x0 || exit 1
-test -x / || exit 1"
- as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
- as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
- eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
- test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
-test \$(( 1 + 1 )) = 2 || exit 1"
- if (eval "$as_required") 2>/dev/null; then :
- as_have_required=yes
-else
- as_have_required=no
-fi
- if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
-
-else
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-as_found=false
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- as_found=:
- case $as_dir in #(
- /*)
- for as_base in sh bash ksh sh5; do
- # Try only shells that exist, to save several forks.
- as_shell=$as_dir/$as_base
- if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
- { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
- CONFIG_SHELL=$as_shell as_have_required=yes
- if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
- break 2
-fi
-fi
- done;;
- esac
- as_found=false
-done
-$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
- { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
- CONFIG_SHELL=$SHELL as_have_required=yes
-fi; }
-IFS=$as_save_IFS
-
-
- if test "x$CONFIG_SHELL" != x; then :
- export CONFIG_SHELL
- # We cannot yet assume a decent shell, so we have to provide a
-# neutralization value for shells without unset; and this also
-# works around shells that cannot unset nonexistent variables.
-# Preserve -v and -x to the replacement shell.
-BASH_ENV=/dev/null
-ENV=/dev/null
-(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-case $- in # ((((
- *v*x* | *x*v* ) as_opts=-vx ;;
- *v* ) as_opts=-v ;;
- *x* ) as_opts=-x ;;
- * ) as_opts= ;;
-esac
-exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-# Admittedly, this is quite paranoid, since all the known shells bail
-# out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-exit 255
-fi
-
- if test x$as_have_required = xno; then :
- $as_echo "$0: This script requires a shell more modern than all"
- $as_echo "$0: the shells that I found on your system."
- if test x${ZSH_VERSION+set} = xset ; then
- $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
- $as_echo "$0: be upgraded to zsh 4.3.4 or later."
- else
- $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
-$0: including any error possibly output before this
-$0: message. Then install a modern shell, or manually run
-$0: the script under such a shell if you do have one."
- fi
- exit 1
-fi
-fi
-fi
-SHELL=${CONFIG_SHELL-/bin/sh}
-export SHELL
-# Unset more variables known to interfere with behavior of common tools.
-CLICOLOR_FORCE= GREP_OPTIONS=
-unset CLICOLOR_FORCE GREP_OPTIONS
-
-## --------------------- ##
-## M4sh Shell Functions. ##
-## --------------------- ##
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
- { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
- return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
- set +e
- as_fn_set_status $1
- exit $1
-} # as_fn_exit
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
- case $as_dir in #(
- -*) as_dir=./$as_dir;;
- esac
- test -d "$as_dir" || eval $as_mkdir_p || {
- as_dirs=
- while :; do
- case $as_dir in #(
- *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
- *) as_qdir=$as_dir;;
- esac
- as_dirs="'$as_qdir' $as_dirs"
- as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
- test -d "$as_dir" && break
- done
- test -z "$as_dirs" || eval "mkdir $as_dirs"
- } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-
-# as_fn_executable_p FILE
-# -----------------------
-# Test if FILE is an executable regular file.
-as_fn_executable_p ()
-{
- test -f "$1" && test -x "$1"
-} # as_fn_executable_p
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
- eval 'as_fn_append ()
- {
- eval $1+=\$2
- }'
-else
- as_fn_append ()
- {
- eval $1=\$$1\$2
- }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
- eval 'as_fn_arith ()
- {
- as_val=$(( $* ))
- }'
-else
- as_fn_arith ()
- {
- as_val=`expr "$@" || test $? -eq 1`
- }
-fi # as_fn_arith
-
-
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
- as_status=$1; test $as_status -eq 0 && as_status=1
- if test "$4"; then
- as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
- fi
- $as_echo "$as_me: error: $2" >&2
- as_fn_exit $as_status
-} # as_fn_error
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
- test "X`expr 00001 : '.*\(...\)'`" = X001; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
- as_dirname=dirname
-else
- as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{
- s//\1/
- q
- }
- /^X\/\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\/\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-
- as_lineno_1=$LINENO as_lineno_1a=$LINENO
- as_lineno_2=$LINENO as_lineno_2a=$LINENO
- eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
- test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
- # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
- sed -n '
- p
- /[$]LINENO/=
- ' <$as_myself |
- sed '
- s/[$]LINENO.*/&-/
- t lineno
- b
- :lineno
- N
- :loop
- s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
- t loop
- s/-\n.*//
- ' >$as_me.lineno &&
- chmod +x "$as_me.lineno" ||
- { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
-
- # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
- # already done that, so ensure we don't try to do so again and fall
- # in an infinite loop. This has already happened in practice.
- _as_can_reexec=no; export _as_can_reexec
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensitive to this).
- . "./$as_me.lineno"
- # Exit status is that of the last command.
- exit
-}
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
- case `echo 'xy\c'` in
- *c*) ECHO_T=' ';; # ECHO_T is single tab character.
- xy) ECHO_C='\c';;
- *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
- ECHO_T=' ';;
- esac;;
-*)
- ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
- rm -f conf$$.dir/conf$$.file
-else
- rm -f conf$$.dir
- mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
- if ln -s conf$$.file conf$$ 2>/dev/null; then
- as_ln_s='ln -s'
- # ... but there are two gotchas:
- # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
- # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
- # In both cases, we have to default to `cp -pR'.
- ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
- as_ln_s='cp -pR'
- elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
- else
- as_ln_s='cp -pR'
- fi
-else
- as_ln_s='cp -pR'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p='mkdir -p "$as_dir"'
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-test -n "$DJDIR" || exec 7<&0 </dev/null
-exec 6>&1
-
-# Name of the host.
-# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_clean_files=
-ac_config_libobj_dir=.
-LIBOBJS=
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-
-# Identity of this package.
-PACKAGE_NAME='ocaml-bitstring'
-PACKAGE_TARNAME='ocaml-bitstring'
-PACKAGE_VERSION='2.0.4'
-PACKAGE_STRING='ocaml-bitstring 2.0.4'
-PACKAGE_BUGREPORT=''
-PACKAGE_URL=''
-
-# Factoring default headers for most tests.
-ac_includes_default="\
-#include <stdio.h>
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-#endif
-#ifdef HAVE_STRING_H
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
-
-ac_subst_vars='LTLIBOBJS
-LIBOBJS
-enable_coverage
-BISECT_REPORT
-GPROF
-DIFF
-TIME
-OCAML_PKG_cil
-OCAML_PKG_extlib
-CAMLP4OF
-OCAMLFIND
-OCAMLBUILD
-OCAMLDOC
-OCAMLMKLIB
-OCAMLMKTOP
-OCAMLDEP
-OCAML
-OCAMLOPTDOTOPT
-OCAMLCDOTOPT
-OCAMLBEST
-OCAMLOPT
-OCAMLLIB
-OCAMLVERSION
-OCAMLC
-BYTESWAP_H
-NATIVEENDIAN
-EGREP
-GREP
-CPP
-INSTALL_DATA
-INSTALL_SCRIPT
-INSTALL_PROGRAM
-OBJEXT
-EXEEXT
-ac_ct_CC
-CPPFLAGS
-LDFLAGS
-CFLAGS
-CC
-SED
-target_alias
-host_alias
-build_alias
-LIBS
-ECHO_T
-ECHO_N
-ECHO_C
-DEFS
-mandir
-localedir
-libdir
-psdir
-pdfdir
-dvidir
-htmldir
-infodir
-docdir
-oldincludedir
-includedir
-localstatedir
-sharedstatedir
-sysconfdir
-datadir
-datarootdir
-libexecdir
-sbindir
-bindir
-program_transform_name
-prefix
-exec_prefix
-PACKAGE_URL
-PACKAGE_BUGREPORT
-PACKAGE_STRING
-PACKAGE_VERSION
-PACKAGE_TARNAME
-PACKAGE_NAME
-PATH_SEPARATOR
-SHELL'
-ac_subst_files=''
-ac_user_opts='
-enable_option_checking
-enable_coverage
-'
- ac_precious_vars='build_alias
-host_alias
-target_alias
-CC
-CFLAGS
-LDFLAGS
-LIBS
-CPPFLAGS
-CPP'
-
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-ac_unrecognized_opts=
-ac_unrecognized_sep=
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-# (The list follows the same order as the GNU Coding Standards.)
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datarootdir='${prefix}/share'
-datadir='${datarootdir}'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
-infodir='${datarootdir}/info'
-htmldir='${docdir}'
-dvidir='${docdir}'
-pdfdir='${docdir}'
-psdir='${docdir}'
-libdir='${exec_prefix}/lib'
-localedir='${datarootdir}/locale'
-mandir='${datarootdir}/man'
-
-ac_prev=
-ac_dashdash=
-for ac_option
-do
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval $ac_prev=\$ac_option
- ac_prev=
- continue
- fi
-
- case $ac_option in
- *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
- *=) ac_optarg= ;;
- *) ac_optarg=yes ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case $ac_dashdash$ac_option in
- --)
- ac_dashdash=yes ;;
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir=$ac_optarg ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build_alias ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build_alias=$ac_optarg ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file=$ac_optarg ;;
-
- --config-cache | -C)
- cache_file=config.cache ;;
-
- -datadir | --datadir | --datadi | --datad)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=*)
- datadir=$ac_optarg ;;
-
- -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
- | --dataroo | --dataro | --datar)
- ac_prev=datarootdir ;;
- -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
- | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
- datarootdir=$ac_optarg ;;
-
- -disable-* | --disable-*)
- ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
- as_fn_error $? "invalid feature name: $ac_useropt"
- ac_useropt_orig=$ac_useropt
- ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
- case $ac_user_opts in
- *"
-"enable_$ac_useropt"
-"*) ;;
- *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
- ac_unrecognized_sep=', ';;
- esac
- eval enable_$ac_useropt=no ;;
-
- -docdir | --docdir | --docdi | --doc | --do)
- ac_prev=docdir ;;
- -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
- docdir=$ac_optarg ;;
-
- -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
- ac_prev=dvidir ;;
- -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
- dvidir=$ac_optarg ;;
-
- -enable-* | --enable-*)
- ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
- as_fn_error $? "invalid feature name: $ac_useropt"
- ac_useropt_orig=$ac_useropt
- ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
- case $ac_user_opts in
- *"
-"enable_$ac_useropt"
-"*) ;;
- *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
- ac_unrecognized_sep=', ';;
- esac
- eval enable_$ac_useropt=\$ac_optarg ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix=$ac_optarg ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he | -h)
- ac_init_help=long ;;
- -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
- ac_init_help=recursive ;;
- -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
- ac_init_help=short ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host_alias ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host_alias=$ac_optarg ;;
-
- -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
- ac_prev=htmldir ;;
- -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
- | --ht=*)
- htmldir=$ac_optarg ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir=$ac_optarg ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir=$ac_optarg ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir=$ac_optarg ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir=$ac_optarg ;;
-
- -localedir | --localedir | --localedi | --localed | --locale)
- ac_prev=localedir ;;
- -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
- localedir=$ac_optarg ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst | --locals)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
- localstatedir=$ac_optarg ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir=$ac_optarg ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c | -n)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir=$ac_optarg ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix=$ac_optarg ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix=$ac_optarg ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix=$ac_optarg ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name=$ac_optarg ;;
-
- -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
- ac_prev=pdfdir ;;
- -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
- pdfdir=$ac_optarg ;;
-
- -psdir | --psdir | --psdi | --psd | --ps)
- ac_prev=psdir ;;
- -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
- psdir=$ac_optarg ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir=$ac_optarg ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir=$ac_optarg ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site=$ac_optarg ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir=$ac_optarg ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir=$ac_optarg ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target_alias ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target_alias=$ac_optarg ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers | -V)
- ac_init_version=: ;;
-
- -with-* | --with-*)
- ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
- as_fn_error $? "invalid package name: $ac_useropt"
- ac_useropt_orig=$ac_useropt
- ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
- case $ac_user_opts in
- *"
-"with_$ac_useropt"
-"*) ;;
- *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
- ac_unrecognized_sep=', ';;
- esac
- eval with_$ac_useropt=\$ac_optarg ;;
-
- -without-* | --without-*)
- ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
- as_fn_error $? "invalid package name: $ac_useropt"
- ac_useropt_orig=$ac_useropt
- ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
- case $ac_user_opts in
- *"
-"with_$ac_useropt"
-"*) ;;
- *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
- ac_unrecognized_sep=', ';;
- esac
- eval with_$ac_useropt=no ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes=$ac_optarg ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries=$ac_optarg ;;
-
- -*) as_fn_error $? "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information"
- ;;
-
- *=*)
- ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
- # Reject names that are not valid shell variable names.
- case $ac_envvar in #(
- '' | [0-9]* | *[!_$as_cr_alnum]* )
- as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
- esac
- eval $ac_envvar=\$ac_optarg
- export $ac_envvar ;;
-
- *)
- # FIXME: should be removed in autoconf 3.0.
- $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
- expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
- $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
- : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- ac_option=--`echo $ac_prev | sed 's/_/-/g'`
- as_fn_error $? "missing argument to $ac_option"
-fi
-
-if test -n "$ac_unrecognized_opts"; then
- case $enable_option_checking in
- no) ;;
- fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
- *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
- esac
-fi
-
-# Check all directory arguments for consistency.
-for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
- datadir sysconfdir sharedstatedir localstatedir includedir \
- oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
-do
- eval ac_val=\$$ac_var
- # Remove trailing slashes.
- case $ac_val in
- */ )
- ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
- eval $ac_var=\$ac_val;;
- esac
- # Be sure to have absolute directory names.
- case $ac_val in
- [\\/$]* | ?:[\\/]* ) continue;;
- NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
- esac
- as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
- if test "x$build_alias" = x; then
- cross_compiling=maybe
- elif test "x$build_alias" != "x$host_alias"; then
- cross_compiling=yes
- fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-ac_pwd=`pwd` && test -n "$ac_pwd" &&
-ac_ls_di=`ls -di .` &&
-ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
- as_fn_error $? "working directory cannot be determined"
-test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
- as_fn_error $? "pwd does not report name of working directory"
-
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then the parent directory.
- ac_confdir=`$as_dirname -- "$as_myself" ||
-$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_myself" : 'X\(//\)[^/]' \| \
- X"$as_myself" : 'X\(//\)$' \| \
- X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_myself" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
- srcdir=$ac_confdir
- if test ! -r "$srcdir/$ac_unique_file"; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r "$srcdir/$ac_unique_file"; then
- test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
- as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
-fi
-ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
-ac_abs_confdir=`(
- cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
- pwd)`
-# When building in place, set srcdir=.
-if test "$ac_abs_confdir" = "$ac_pwd"; then
- srcdir=.
-fi
-# Remove unnecessary trailing slashes from srcdir.
-# Double slashes in file names in object file debugging info
-# mess up M-x gdb in Emacs.
-case $srcdir in
-*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
-esac
-for ac_var in $ac_precious_vars; do
- eval ac_env_${ac_var}_set=\${${ac_var}+set}
- eval ac_env_${ac_var}_value=\$${ac_var}
- eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
- eval ac_cv_env_${ac_var}_value=\$${ac_var}
-done
-
-#
-# Report the --help message.
-#
-if test "$ac_init_help" = "long"; then
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat <<_ACEOF
-\`configure' configures ocaml-bitstring 2.0.4 to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE. See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
- -h, --help display this help and exit
- --help=short display options specific to this package
- --help=recursive display the short help of all the included packages
- -V, --version display version information and exit
- -q, --quiet, --silent do not print \`checking ...' messages
- --cache-file=FILE cache test results in FILE [disabled]
- -C, --config-cache alias for \`--cache-file=config.cache'
- -n, --no-create do not create output files
- --srcdir=DIR find the sources in DIR [configure dir or \`..']
-
-Installation directories:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
- --bindir=DIR user executables [EPREFIX/bin]
- --sbindir=DIR system admin executables [EPREFIX/sbin]
- --libexecdir=DIR program executables [EPREFIX/libexec]
- --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --libdir=DIR object code libraries [EPREFIX/lib]
- --includedir=DIR C header files [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc [/usr/include]
- --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
- --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
- --infodir=DIR info documentation [DATAROOTDIR/info]
- --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
- --mandir=DIR man documentation [DATAROOTDIR/man]
- --docdir=DIR documentation root [DATAROOTDIR/doc/ocaml-bitstring]
- --htmldir=DIR html documentation [DOCDIR]
- --dvidir=DIR dvi documentation [DOCDIR]
- --pdfdir=DIR pdf documentation [DOCDIR]
- --psdir=DIR ps documentation [DOCDIR]
-_ACEOF
-
- cat <<\_ACEOF
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
- case $ac_init_help in
- short | recursive ) echo "Configuration of ocaml-bitstring 2.0.4:";;
- esac
- cat <<\_ACEOF
-
-Optional Features:
- --disable-option-checking ignore unrecognized --enable/--with options
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --enable-coverage add code coverage information (slow) [default=no]
-
-Some influential environment variables:
- CC C compiler command
- CFLAGS C compiler flags
- LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
- nonstandard directory <lib dir>
- LIBS libraries to pass to the linker, e.g. -l<library>
- CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
- you have headers in a nonstandard directory <include dir>
- CPP C preprocessor
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-Report bugs to the package provider.
-_ACEOF
-ac_status=$?
-fi
-
-if test "$ac_init_help" = "recursive"; then
- # If there are subdirs, report their specific --help.
- for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
- test -d "$ac_dir" ||
- { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
- continue
- ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
- ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
- # A ".." for each directory in $ac_dir_suffix.
- ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
- case $ac_top_builddir_sub in
- "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
- *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
- esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
- .) # We are building in place.
- ac_srcdir=.
- ac_top_srcdir=$ac_top_builddir_sub
- ac_abs_top_srcdir=$ac_pwd ;;
- [\\/]* | ?:[\\/]* ) # Absolute name.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir
- ac_abs_top_srcdir=$srcdir ;;
- *) # Relative name.
- ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_build_prefix$srcdir
- ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
- cd "$ac_dir" || { ac_status=$?; continue; }
- # Check for guested configure.
- if test -f "$ac_srcdir/configure.gnu"; then
- echo &&
- $SHELL "$ac_srcdir/configure.gnu" --help=recursive
- elif test -f "$ac_srcdir/configure"; then
- echo &&
- $SHELL "$ac_srcdir/configure" --help=recursive
- else
- $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
- fi || ac_status=$?
- cd "$ac_pwd" || { ac_status=$?; break; }
- done
-fi
-
-test -n "$ac_init_help" && exit $ac_status
-if $ac_init_version; then
- cat <<\_ACEOF
-ocaml-bitstring configure 2.0.4
-generated by GNU Autoconf 2.69
-
-Copyright (C) 2012 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-_ACEOF
- exit
-fi
-
-## ------------------------ ##
-## Autoconf initialization. ##
-## ------------------------ ##
-
-# ac_fn_c_try_compile LINENO
-# --------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_compile ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- rm -f conftest.$ac_objext
- if { { ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_compile") 2>conftest.err
- ac_status=$?
- if test -s conftest.err; then
- grep -v '^ *+' conftest.err >conftest.er1
- cat conftest.er1 >&5
- mv -f conftest.er1 conftest.err
- fi
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest.$ac_objext; then :
- ac_retval=0
-else
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_retval=1
-fi
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
- as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_compile
-
-# ac_fn_c_try_cpp LINENO
-# ----------------------
-# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_cpp ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- if { { ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
- ac_status=$?
- if test -s conftest.err; then
- grep -v '^ *+' conftest.err >conftest.er1
- cat conftest.er1 >&5
- mv -f conftest.er1 conftest.err
- fi
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } > conftest.i && {
- test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
- test ! -s conftest.err
- }; then :
- ac_retval=0
-else
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_retval=1
-fi
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
- as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_cpp
-
-# ac_fn_c_try_run LINENO
-# ----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-# that executables *can* be run.
-ac_fn_c_try_run ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- if { { ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
- { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; }; then :
- ac_retval=0
-else
- $as_echo "$as_me: program exited with status $ac_status" >&5
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_retval=$ac_status
-fi
- rm -rf conftest.dSYM conftest_ipa8_conftest.oo
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
- as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_run
-
-# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists and can be compiled using the include files in
-# INCLUDES, setting the cache variable VAR accordingly.
-ac_fn_c_check_header_compile ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- eval "$3=yes"
-else
- eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_compile
-
-# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists, giving a warning if it cannot be compiled using
-# the include files in INCLUDES and setting the cache variable VAR
-# accordingly.
-ac_fn_c_check_header_mongrel ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- if eval \${$3+:} false; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-else
- # Is the header compilable?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
-$as_echo_n "checking $2 usability... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_header_compiler=yes
-else
- ac_header_compiler=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
-$as_echo "$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
-$as_echo_n "checking $2 presence... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <$2>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
- ac_header_preproc=yes
-else
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
-$as_echo "$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
- yes:no: )
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
-$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
- ;;
- no:yes:* )
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
-$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
-$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
-$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
-$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
- ;;
-esac
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- eval "$3=\$ac_header_compiler"
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-fi
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_mongrel
-cat >config.log <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by ocaml-bitstring $as_me 2.0.4, which was
-generated by GNU Autoconf 2.69. Invocation command line was
-
- $ $0 $@
-
-_ACEOF
-exec 5>>config.log
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
-
-/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
-/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
-/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- $as_echo "PATH: $as_dir"
- done
-IFS=$as_save_IFS
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
- for ac_arg
- do
- case $ac_arg in
- -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- continue ;;
- *\'*)
- ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
- esac
- case $ac_pass in
- 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
- 2)
- as_fn_append ac_configure_args1 " '$ac_arg'"
- if test $ac_must_keep_next = true; then
- ac_must_keep_next=false # Got value, back to normal.
- else
- case $ac_arg in
- *=* | --config-cache | -C | -disable-* | --disable-* \
- | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
- | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
- | -with-* | --with-* | -without-* | --without-* | --x)
- case "$ac_configure_args0 " in
- "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
- esac
- ;;
- -* ) ac_must_keep_next=true ;;
- esac
- fi
- as_fn_append ac_configure_args " '$ac_arg'"
- ;;
- esac
- done
-done
-{ ac_configure_args0=; unset ac_configure_args0;}
-{ ac_configure_args1=; unset ac_configure_args1;}
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log. We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Use '\'' to represent an apostrophe within the trap.
-# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
-trap 'exit_status=$?
- # Save into config.log some information that might help in debugging.
- {
- echo
-
- $as_echo "## ---------------- ##
-## Cache variables. ##
-## ---------------- ##"
- echo
- # The following way of writing the cache mishandles newlines in values,
-(
- for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
- eval ac_val=\$$ac_var
- case $ac_val in #(
- *${as_nl}*)
- case $ac_var in #(
- *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
- esac
- case $ac_var in #(
- _ | IFS | as_nl) ;; #(
- BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
- *) { eval $ac_var=; unset $ac_var;} ;;
- esac ;;
- esac
- done
- (set) 2>&1 |
- case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
- *${as_nl}ac_space=\ *)
- sed -n \
- "s/'\''/'\''\\\\'\'''\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
- ;; #(
- *)
- sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
- ;;
- esac |
- sort
-)
- echo
-
- $as_echo "## ----------------- ##
-## Output variables. ##
-## ----------------- ##"
- echo
- for ac_var in $ac_subst_vars
- do
- eval ac_val=\$$ac_var
- case $ac_val in
- *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
- esac
- $as_echo "$ac_var='\''$ac_val'\''"
- done | sort
- echo
-
- if test -n "$ac_subst_files"; then
- $as_echo "## ------------------- ##
-## File substitutions. ##
-## ------------------- ##"
- echo
- for ac_var in $ac_subst_files
- do
- eval ac_val=\$$ac_var
- case $ac_val in
- *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
- esac
- $as_echo "$ac_var='\''$ac_val'\''"
- done | sort
- echo
- fi
-
- if test -s confdefs.h; then
- $as_echo "## ----------- ##
-## confdefs.h. ##
-## ----------- ##"
- echo
- cat confdefs.h
- echo
- fi
- test "$ac_signal" != 0 &&
- $as_echo "$as_me: caught signal $ac_signal"
- $as_echo "$as_me: exit $exit_status"
- } >&5
- rm -f core *.core core.conftest.* &&
- rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
- exit $exit_status
-' 0
-for ac_signal in 1 2 13 15; do
- trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
-done
-ac_signal=0
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -f -r conftest* confdefs.h
-
-$as_echo "/* confdefs.h */" > confdefs.h
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_URL "$PACKAGE_URL"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# Prefer an explicitly selected file to automatically selected ones.
-ac_site_file1=NONE
-ac_site_file2=NONE
-if test -n "$CONFIG_SITE"; then
- # We do not want a PATH search for config.site.
- case $CONFIG_SITE in #((
- -*) ac_site_file1=./$CONFIG_SITE;;
- */*) ac_site_file1=$CONFIG_SITE;;
- *) ac_site_file1=./$CONFIG_SITE;;
- esac
-elif test "x$prefix" != xNONE; then
- ac_site_file1=$prefix/share/config.site
- ac_site_file2=$prefix/etc/config.site
-else
- ac_site_file1=$ac_default_prefix/share/config.site
- ac_site_file2=$ac_default_prefix/etc/config.site
-fi
-for ac_site_file in "$ac_site_file1" "$ac_site_file2"
-do
- test "x$ac_site_file" = xNONE && continue
- if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
-$as_echo "$as_me: loading site script $ac_site_file" >&6;}
- sed 's/^/| /' "$ac_site_file" >&5
- . "$ac_site_file" \
- || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "failed to load site script $ac_site_file
-See \`config.log' for more details" "$LINENO" 5; }
- fi
-done
-
-if test -r "$cache_file"; then
- # Some versions of bash will fail to source /dev/null (special files
- # actually), so we avoid doing that. DJGPP emulates it as a regular file.
- if test /dev/null != "$cache_file" && test -f "$cache_file"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
-$as_echo "$as_me: loading cache $cache_file" >&6;}
- case $cache_file in
- [\\/]* | ?:[\\/]* ) . "$cache_file";;
- *) . "./$cache_file";;
- esac
- fi
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
-$as_echo "$as_me: creating cache $cache_file" >&6;}
- >$cache_file
-fi
-
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in $ac_precious_vars; do
- eval ac_old_set=\$ac_cv_env_${ac_var}_set
- eval ac_new_set=\$ac_env_${ac_var}_set
- eval ac_old_val=\$ac_cv_env_${ac_var}_value
- eval ac_new_val=\$ac_env_${ac_var}_value
- case $ac_old_set,$ac_new_set in
- set,)
- { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,set)
- { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,);;
- *)
- if test "x$ac_old_val" != "x$ac_new_val"; then
- # differences in whitespace do not lead to failure.
- ac_old_val_w=`echo x $ac_old_val`
- ac_new_val_w=`echo x $ac_new_val`
- if test "$ac_old_val_w" != "$ac_new_val_w"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
-$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
- ac_cache_corrupted=:
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
-$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
- eval $ac_var=\$ac_old_val
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
-$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
-$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
- fi;;
- esac
- # Pass precious variables to config.status.
- if test "$ac_new_set" = set; then
- case $ac_new_val in
- *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
- *) ac_arg=$ac_var=$ac_new_val ;;
- esac
- case " $ac_configure_args " in
- *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
- *) as_fn_append ac_configure_args " '$ac_arg'" ;;
- esac
- fi
-done
-if $ac_cache_corrupted; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
-$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
- as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
-fi
-## -------------------- ##
-## Main body of script. ##
-## -------------------- ##
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
-$as_echo_n "checking for a sed that does not truncate output... " >&6; }
-if ${ac_cv_path_SED+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
- for ac_i in 1 2 3 4 5 6 7; do
- ac_script="$ac_script$as_nl$ac_script"
- done
- echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
- { ac_script=; unset ac_script;}
- if test -z "$SED"; then
- ac_path_SED_found=false
- # Loop through the user's path and test for each of PROGNAME-LIST
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_prog in sed gsed; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
- as_fn_executable_p "$ac_path_SED" || continue
-# Check for GNU ac_path_SED and select it if it is found.
- # Check for GNU $ac_path_SED
-case `"$ac_path_SED" --version 2>&1` in
-*GNU*)
- ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
-*)
- ac_count=0
- $as_echo_n 0123456789 >"conftest.in"
- while :
- do
- cat "conftest.in" "conftest.in" >"conftest.tmp"
- mv "conftest.tmp" "conftest.in"
- cp "conftest.in" "conftest.nl"
- $as_echo '' >> "conftest.nl"
- "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
- as_fn_arith $ac_count + 1 && ac_count=$as_val
- if test $ac_count -gt ${ac_path_SED_max-0}; then
- # Best one so far, save it but keep looking for a better one
- ac_cv_path_SED="$ac_path_SED"
- ac_path_SED_max=$ac_count
- fi
- # 10*(2^10) chars as input seems more than enough
- test $ac_count -gt 10 && break
- done
- rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
- $ac_path_SED_found && break 3
- done
- done
- done
-IFS=$as_save_IFS
- if test -z "$ac_cv_path_SED"; then
- as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
- fi
-else
- ac_cv_path_SED=$SED
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
-$as_echo "$ac_cv_path_SED" >&6; }
- SED="$ac_cv_path_SED"
- rm -f conftest.sed
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}gcc"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="gcc"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_CC" = x; then
- CC=""
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- CC=$ac_ct_CC
- fi
-else
- CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}cc"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- fi
-fi
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# != 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
- fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- for ac_prog in cl.exe
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$CC" && break
- done
-fi
-if test -z "$CC"; then
- ac_ct_CC=$CC
- for ac_prog in cl.exe
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="$ac_prog"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$ac_ct_CC" && break
-done
-
- if test "x$ac_ct_CC" = x; then
- CC=""
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- CC=$ac_ct_CC
- fi
-fi
-
-fi
-
-
-test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5; }
-
-# Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
-set X $ac_compile
-ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
- { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_compiler $ac_option >&5") 2>conftest.err
- ac_status=$?
- if test -s conftest.err; then
- sed '10a\
-... rest of stderr output deleted ...
- 10q' conftest.err >conftest.er1
- cat conftest.er1 >&5
- fi
- rm -f conftest.er1 conftest.err
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }
-done
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-$as_echo_n "checking whether the C compiler works... " >&6; }
-ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-
-# The possible output files:
-ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
-
-ac_rmfiles=
-for ac_file in $ac_files
-do
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
- * ) ac_rmfiles="$ac_rmfiles $ac_file";;
- esac
-done
-rm -f $ac_rmfiles
-
-if { { ac_try="$ac_link_default"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link_default") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then :
- # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
-# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
-# in a Makefile. We should not override ac_cv_exeext if it was cached,
-# so that the user can short-circuit this test for compilers unknown to
-# Autoconf.
-for ac_file in $ac_files ''
-do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
- ;;
- [ab].out )
- # We found the default executable, but exeext='' is most
- # certainly right.
- break;;
- *.* )
- if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
- then :; else
- ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- fi
- # We set ac_cv_exeext here because the later test for it is not
- # safe: cross compilers may not add the suffix if given an `-o'
- # argument, so we may need to know it at that point already.
- # Even if this section looks crufty: it has the advantage of
- # actually working.
- break;;
- * )
- break;;
- esac
-done
-test "$ac_cv_exeext" = no && ac_cv_exeext=
-
-else
- ac_file=''
-fi
-if test -z "$ac_file"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-$as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "C compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-$as_echo_n "checking for C compiler default output file name... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-$as_echo "$ac_file" >&6; }
-ac_exeext=$ac_cv_exeext
-
-rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
-$as_echo_n "checking for suffix of executables... " >&6; }
-if { { ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then :
- # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
- *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- break;;
- * ) break;;
- esac
-done
-else
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-rm -f conftest conftest$ac_cv_exeext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
-$as_echo "$ac_cv_exeext" >&6; }
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdio.h>
-int
-main ()
-{
-FILE *f = fopen ("conftest.out", "w");
- return ferror (f) || fclose (f) != 0;
-
- ;
- return 0;
-}
-_ACEOF
-ac_clean_files="$ac_clean_files conftest.out"
-# Check that the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-$as_echo_n "checking whether we are cross compiling... " >&6; }
-if test "$cross_compiling" != yes; then
- { { ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }
- if { ac_try='./conftest$ac_cv_exeext'
- { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; }; then
- cross_compiling=no
- else
- if test "$cross_compiling" = maybe; then
- cross_compiling=yes
- else
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5; }
- fi
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-$as_echo "$cross_compiling" >&6; }
-
-rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
-$as_echo_n "checking for suffix of object files... " >&6; }
-if ${ac_cv_objext+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { { ac_try="$ac_compile"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_compile") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then :
- for ac_file in conftest.o conftest.obj conftest.*; do
- test -f "$ac_file" || continue;
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
- *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
- break;;
- esac
-done
-else
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
-$as_echo "$ac_cv_objext" >&6; }
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
-$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if ${ac_cv_c_compiler_gnu+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_compiler_gnu=yes
-else
- ac_compiler_gnu=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
-$as_echo "$ac_cv_c_compiler_gnu" >&6; }
-if test $ac_compiler_gnu = yes; then
- GCC=yes
-else
- GCC=
-fi
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
-$as_echo_n "checking whether $CC accepts -g... " >&6; }
-if ${ac_cv_prog_cc_g+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_save_c_werror_flag=$ac_c_werror_flag
- ac_c_werror_flag=yes
- ac_cv_prog_cc_g=no
- CFLAGS="-g"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_prog_cc_g=yes
-else
- CFLAGS=""
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-else
- ac_c_werror_flag=$ac_save_c_werror_flag
- CFLAGS="-g"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_prog_cc_g=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- ac_c_werror_flag=$ac_save_c_werror_flag
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
-$as_echo "$ac_cv_prog_cc_g" >&6; }
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
-$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if ${ac_cv_prog_cc_c89+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_cv_prog_cc_c89=no
-ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdarg.h>
-#include <stdio.h>
-struct stat;
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
- char **p;
- int i;
-{
- return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
- char *s;
- va_list v;
- va_start (v,p);
- s = g (p, va_arg (v,int));
- va_end (v);
- return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
- function prototypes and stuff, but not '\xHH' hex character constants.
- These don't provoke an error unfortunately, instead are silently treated
- as 'x'. The following induces an error, until -std is added to get
- proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
- array size at least. It's necessary to write '\x00'==0 to get something
- that's true only with -std. */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
- inside strings and character constants. */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
- ;
- return 0;
-}
-_ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
- -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
- CC="$ac_save_CC $ac_arg"
- if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_prog_cc_c89=$ac_arg
-fi
-rm -f core conftest.err conftest.$ac_objext
- test "x$ac_cv_prog_cc_c89" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
- x)
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
- xno)
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
- *)
- CC="$CC $ac_cv_prog_cc_c89"
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
-$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
-
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-ac_aux_dir=
-for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
- if test -f "$ac_dir/install-sh"; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install-sh -c"
- break
- elif test -f "$ac_dir/install.sh"; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install.sh -c"
- break
- elif test -f "$ac_dir/shtool"; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/shtool install -c"
- break
- fi
-done
-if test -z "$ac_aux_dir"; then
- as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
-fi
-
-# These three variables are undocumented and unsupported,
-# and are intended to be withdrawn in a future Autoconf release.
-# They can cause serious problems if a builder's source tree is in a directory
-# whose full name contains unusual characters.
-ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
-ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
-ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
-
-
-# Find a good install program. We prefer a C program (faster),
-# so one script is as good as another. But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AmigaOS /C/install, which installs bootblocks on floppy discs
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# OS/2's system install, which has a completely different semantic
-# ./install, which can be erroneously created by make from ./install.sh.
-# Reject install programs that cannot install multiple files.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
-$as_echo_n "checking for a BSD-compatible install... " >&6; }
-if test -z "$INSTALL"; then
-if ${ac_cv_path_install+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- # Account for people who put trailing slashes in PATH elements.
-case $as_dir/ in #((
- ./ | .// | /[cC]/* | \
- /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
- ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
- /usr/ucb/* ) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- # Don't use installbsd from OSF since it installs stuff as root
- # by default.
- for ac_prog in ginstall scoinst install; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
- if test $ac_prog = install &&
- grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- :
- elif test $ac_prog = install &&
- grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
- # program-specific install script used by HP pwplus--don't use.
- :
- else
- rm -rf conftest.one conftest.two conftest.dir
- echo one > conftest.one
- echo two > conftest.two
- mkdir conftest.dir
- if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
- test -s conftest.one && test -s conftest.two &&
- test -s conftest.dir/conftest.one &&
- test -s conftest.dir/conftest.two
- then
- ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
- break 3
- fi
- fi
- fi
- done
- done
- ;;
-esac
-
- done
-IFS=$as_save_IFS
-
-rm -rf conftest.one conftest.two conftest.dir
-
-fi
- if test "${ac_cv_path_install+set}" = set; then
- INSTALL=$ac_cv_path_install
- else
- # As a last resort, use the slow shell script. Don't cache a
- # value for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the value is a relative name.
- INSTALL=$ac_install_sh
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
-$as_echo "$INSTALL" >&6; }
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
-$as_echo_n "checking how to run the C preprocessor... " >&6; }
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
- if ${ac_cv_prog_CPP+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- # Double quotes because CPP needs to be expanded
- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
- do
- ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether nonexistent headers
- # can be detected and how.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
- # Broken: success on invalid input.
-continue
-else
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
- break
-fi
-
- done
- ac_cv_prog_CPP=$CPP
-
-fi
- CPP=$ac_cv_prog_CPP
-else
- ac_cv_prog_CPP=$CPP
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
-$as_echo "$CPP" >&6; }
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether nonexistent headers
- # can be detected and how.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
- # Broken: success on invalid input.
-continue
-else
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-
-else
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for function prototypes" >&5
-$as_echo_n "checking for function prototypes... " >&6; }
-if test "$ac_cv_prog_cc_c89" != no; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-$as_echo "#define PROTOTYPES 1" >>confdefs.h
-
-
-$as_echo "#define __PROTOTYPES 1" >>confdefs.h
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-test "x$U" != "x" && as_fn_error $? "Compiler not ANSI compliant" "$LINENO" 5
-
-if test "x$CC" != xcc; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5
-$as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5
-$as_echo_n "checking whether cc understands -c and -o together... " >&6; }
-fi
-set dummy $CC; ac_cc=`$as_echo "$2" |
- sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
-if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-# Make sure it works both with $CC and with simple cc.
-# We do the test twice because some compilers refuse to overwrite an
-# existing .o file with -o, though they will create one.
-ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
-rm -f conftest2.*
-if { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } &&
- test -f conftest2.$ac_objext && { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; };
-then
- eval ac_cv_prog_cc_${ac_cc}_c_o=yes
- if test "x$CC" != xcc; then
- # Test first that cc exists at all.
- if { ac_try='cc -c conftest.$ac_ext >&5'
- { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; }; then
- ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
- rm -f conftest2.*
- if { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } &&
- test -f conftest2.$ac_objext && { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; };
- then
- # cc works too.
- :
- else
- # cc exists but doesn't like -o.
- eval ac_cv_prog_cc_${ac_cc}_c_o=no
- fi
- fi
- fi
-else
- eval ac_cv_prog_cc_${ac_cc}_c_o=no
-fi
-rm -f core conftest*
-
-fi
-if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-$as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h
-
-fi
-
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if ${ac_cv_path_GREP+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -z "$GREP"; then
- ac_path_GREP_found=false
- # Loop through the user's path and test for each of PROGNAME-LIST
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_prog in grep ggrep; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
- as_fn_executable_p "$ac_path_GREP" || continue
-# Check for GNU ac_path_GREP and select it if it is found.
- # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
- ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
- ac_count=0
- $as_echo_n 0123456789 >"conftest.in"
- while :
- do
- cat "conftest.in" "conftest.in" >"conftest.tmp"
- mv "conftest.tmp" "conftest.in"
- cp "conftest.in" "conftest.nl"
- $as_echo 'GREP' >> "conftest.nl"
- "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
- as_fn_arith $ac_count + 1 && ac_count=$as_val
- if test $ac_count -gt ${ac_path_GREP_max-0}; then
- # Best one so far, save it but keep looking for a better one
- ac_cv_path_GREP="$ac_path_GREP"
- ac_path_GREP_max=$ac_count
- fi
- # 10*(2^10) chars as input seems more than enough
- test $ac_count -gt 10 && break
- done
- rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
- $ac_path_GREP_found && break 3
- done
- done
- done
-IFS=$as_save_IFS
- if test -z "$ac_cv_path_GREP"; then
- as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
- fi
-else
- ac_cv_path_GREP=$GREP
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-$as_echo "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-$as_echo_n "checking for egrep... " >&6; }
-if ${ac_cv_path_EGREP+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
- then ac_cv_path_EGREP="$GREP -E"
- else
- if test -z "$EGREP"; then
- ac_path_EGREP_found=false
- # Loop through the user's path and test for each of PROGNAME-LIST
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_prog in egrep; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
- as_fn_executable_p "$ac_path_EGREP" || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
- # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
- ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
- ac_count=0
- $as_echo_n 0123456789 >"conftest.in"
- while :
- do
- cat "conftest.in" "conftest.in" >"conftest.tmp"
- mv "conftest.tmp" "conftest.in"
- cp "conftest.in" "conftest.nl"
- $as_echo 'EGREP' >> "conftest.nl"
- "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
- diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
- as_fn_arith $ac_count + 1 && ac_count=$as_val
- if test $ac_count -gt ${ac_path_EGREP_max-0}; then
- # Best one so far, save it but keep looking for a better one
- ac_cv_path_EGREP="$ac_path_EGREP"
- ac_path_EGREP_max=$ac_count
- fi
- # 10*(2^10) chars as input seems more than enough
- test $ac_count -gt 10 && break
- done
- rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
- $ac_path_EGREP_found && break 3
- done
- done
- done
-IFS=$as_save_IFS
- if test -z "$ac_cv_path_EGREP"; then
- as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
- fi
-else
- ac_cv_path_EGREP=$EGREP
-fi
-
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-$as_echo "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_header_stdc=yes
-else
- ac_cv_header_stdc=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
- if test "$cross_compiling" = yes; then :
- :
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
- int i;
- for (i = 0; i < 256; i++)
- if (XOR (islower (i), ISLOWER (i))
- || toupper (i) != TOUPPER (i))
- return 2;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
-
-fi
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
- inttypes.h stdint.h unistd.h
-do :
- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
-$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
-if ${ac_cv_c_bigendian+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_cv_c_bigendian=unknown
- # See if we're dealing with a universal compiler.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#ifndef __APPLE_CC__
- not a universal capable compiler
- #endif
- typedef int dummy;
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
- # Check for potential -arch flags. It is not universal unless
- # there are at least two -arch flags with different values.
- ac_arch=
- ac_prev=
- for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do
- if test -n "$ac_prev"; then
- case $ac_word in
- i?86 | x86_64 | ppc | ppc64)
- if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then
- ac_arch=$ac_word
- else
- ac_cv_c_bigendian=universal
- break
- fi
- ;;
- esac
- ac_prev=
- elif test "x$ac_word" = "x-arch"; then
- ac_prev=arch
- fi
- done
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- if test $ac_cv_c_bigendian = unknown; then
- # See if sys/param.h defines the BYTE_ORDER macro.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
- #include <sys/param.h>
-
-int
-main ()
-{
-#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
- && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
- && LITTLE_ENDIAN)
- bogus endian macros
- #endif
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- # It does; now see whether it defined to BIG_ENDIAN or not.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
- #include <sys/param.h>
-
-int
-main ()
-{
-#if BYTE_ORDER != BIG_ENDIAN
- not big endian
- #endif
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_c_bigendian=yes
-else
- ac_cv_c_bigendian=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- fi
- if test $ac_cv_c_bigendian = unknown; then
- # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <limits.h>
-
-int
-main ()
-{
-#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
- bogus endian macros
- #endif
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- # It does; now see whether it defined to _BIG_ENDIAN or not.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <limits.h>
-
-int
-main ()
-{
-#ifndef _BIG_ENDIAN
- not big endian
- #endif
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_c_bigendian=yes
-else
- ac_cv_c_bigendian=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- fi
- if test $ac_cv_c_bigendian = unknown; then
- # Compile a test program.
- if test "$cross_compiling" = yes; then :
- # Try to guess by grepping values from an object file.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-short int ascii_mm[] =
- { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
- short int ascii_ii[] =
- { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
- int use_ascii (int i) {
- return ascii_mm[i] + ascii_ii[i];
- }
- short int ebcdic_ii[] =
- { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
- short int ebcdic_mm[] =
- { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
- int use_ebcdic (int i) {
- return ebcdic_mm[i] + ebcdic_ii[i];
- }
- extern int foo;
-
-int
-main ()
-{
-return use_ascii (foo) == use_ebcdic (foo);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
- ac_cv_c_bigendian=yes
- fi
- if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
- if test "$ac_cv_c_bigendian" = unknown; then
- ac_cv_c_bigendian=no
- else
- # finding both strings is unlikely to happen, but who knows?
- ac_cv_c_bigendian=unknown
- fi
- fi
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-
- /* Are we little or big endian? From Harbison&Steele. */
- union
- {
- long int l;
- char c[sizeof (long int)];
- } u;
- u.l = 1;
- return u.c[sizeof (long int) - 1] == 1;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ac_cv_c_bigendian=no
-else
- ac_cv_c_bigendian=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
- fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5
-$as_echo "$ac_cv_c_bigendian" >&6; }
- case $ac_cv_c_bigendian in #(
- yes)
- $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h
-;; #(
- no)
- ;; #(
- universal)
-
-$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
-
- ;; #(
- *)
- as_fn_error $? "Machine endianness could not be determined" "$LINENO" 5
- ;;
- esac
-
-if test "x$WORDS_BIGENDIAN" = "x"; then
- NATIVEENDIAN=LittleEndian
-else
- NATIVEENDIAN=BigEndian
-fi
-
-
-for ac_header in byteswap.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "byteswap.h" "ac_cv_header_byteswap_h" "$ac_includes_default"
-if test "x$ac_cv_header_byteswap_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_BYTESWAP_H 1
-_ACEOF
-
- BYTESWAP_H=''
-
-else
-
- BYTESWAP_H='byteswap.h'
-
-fi
-
-done
-
-
-
- # checking for ocamlc
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ocamlc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ocamlc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OCAMLC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$OCAMLC"; then
- ac_cv_prog_OCAMLC="$OCAMLC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_OCAMLC="${ac_tool_prefix}ocamlc"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-OCAMLC=$ac_cv_prog_OCAMLC
-if test -n "$OCAMLC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLC" >&5
-$as_echo "$OCAMLC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_OCAMLC"; then
- ac_ct_OCAMLC=$OCAMLC
- # Extract the first word of "ocamlc", so it can be a program name with args.
-set dummy ocamlc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OCAMLC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_OCAMLC"; then
- ac_cv_prog_ac_ct_OCAMLC="$ac_ct_OCAMLC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_OCAMLC="ocamlc"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_OCAMLC=$ac_cv_prog_ac_ct_OCAMLC
-if test -n "$ac_ct_OCAMLC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLC" >&5
-$as_echo "$ac_ct_OCAMLC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_OCAMLC" = x; then
- OCAMLC="no"
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- OCAMLC=$ac_ct_OCAMLC
- fi
-else
- OCAMLC="$ac_cv_prog_OCAMLC"
-fi
-
-
- if test "$OCAMLC" != "no"; then
- OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'`
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCaml version is $OCAMLVERSION" >&5
-$as_echo "OCaml version is $OCAMLVERSION" >&6; }
- # If OCAMLLIB is set, use it
- if test "$OCAMLLIB" = ""; then
- OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCAMLLIB previously set; preserving it." >&5
-$as_echo "OCAMLLIB previously set; preserving it." >&6; }
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCaml library path is $OCAMLLIB" >&5
-$as_echo "OCaml library path is $OCAMLLIB" >&6; }
-
-
-
-
- # checking for ocamlopt
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ocamlopt", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ocamlopt; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OCAMLOPT+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$OCAMLOPT"; then
- ac_cv_prog_OCAMLOPT="$OCAMLOPT" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_OCAMLOPT="${ac_tool_prefix}ocamlopt"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-OCAMLOPT=$ac_cv_prog_OCAMLOPT
-if test -n "$OCAMLOPT"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLOPT" >&5
-$as_echo "$OCAMLOPT" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_OCAMLOPT"; then
- ac_ct_OCAMLOPT=$OCAMLOPT
- # Extract the first word of "ocamlopt", so it can be a program name with args.
-set dummy ocamlopt; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OCAMLOPT+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_OCAMLOPT"; then
- ac_cv_prog_ac_ct_OCAMLOPT="$ac_ct_OCAMLOPT" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_OCAMLOPT="ocamlopt"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_OCAMLOPT=$ac_cv_prog_ac_ct_OCAMLOPT
-if test -n "$ac_ct_OCAMLOPT"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLOPT" >&5
-$as_echo "$ac_ct_OCAMLOPT" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_OCAMLOPT" = x; then
- OCAMLOPT="no"
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- OCAMLOPT=$ac_ct_OCAMLOPT
- fi
-else
- OCAMLOPT="$ac_cv_prog_OCAMLOPT"
-fi
-
- OCAMLBEST=byte
- if test "$OCAMLOPT" = "no"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find ocamlopt; bytecode compilation only." >&5
-$as_echo "$as_me: WARNING: Cannot find ocamlopt; bytecode compilation only." >&2;}
- else
- TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: versions differs from ocamlc; ocamlopt discarded." >&5
-$as_echo "versions differs from ocamlc; ocamlopt discarded." >&6; }
- OCAMLOPT=no
- else
- OCAMLBEST=opt
- fi
- fi
-
-
-
- # checking for ocamlc.opt
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ocamlc.opt", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ocamlc.opt; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OCAMLCDOTOPT+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$OCAMLCDOTOPT"; then
- ac_cv_prog_OCAMLCDOTOPT="$OCAMLCDOTOPT" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_OCAMLCDOTOPT="${ac_tool_prefix}ocamlc.opt"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-OCAMLCDOTOPT=$ac_cv_prog_OCAMLCDOTOPT
-if test -n "$OCAMLCDOTOPT"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLCDOTOPT" >&5
-$as_echo "$OCAMLCDOTOPT" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_OCAMLCDOTOPT"; then
- ac_ct_OCAMLCDOTOPT=$OCAMLCDOTOPT
- # Extract the first word of "ocamlc.opt", so it can be a program name with args.
-set dummy ocamlc.opt; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OCAMLCDOTOPT+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_OCAMLCDOTOPT"; then
- ac_cv_prog_ac_ct_OCAMLCDOTOPT="$ac_ct_OCAMLCDOTOPT" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_OCAMLCDOTOPT="ocamlc.opt"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_OCAMLCDOTOPT=$ac_cv_prog_ac_ct_OCAMLCDOTOPT
-if test -n "$ac_ct_OCAMLCDOTOPT"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLCDOTOPT" >&5
-$as_echo "$ac_ct_OCAMLCDOTOPT" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_OCAMLCDOTOPT" = x; then
- OCAMLCDOTOPT="no"
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- OCAMLCDOTOPT=$ac_ct_OCAMLCDOTOPT
- fi
-else
- OCAMLCDOTOPT="$ac_cv_prog_OCAMLCDOTOPT"
-fi
-
- if test "$OCAMLCDOTOPT" != "no"; then
- TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: versions differs from ocamlc; ocamlc.opt discarded." >&5
-$as_echo "versions differs from ocamlc; ocamlc.opt discarded." >&6; }
- else
- OCAMLC=$OCAMLCDOTOPT
- fi
- fi
-
- # checking for ocamlopt.opt
- if test "$OCAMLOPT" != "no" ; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ocamlopt.opt", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ocamlopt.opt; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OCAMLOPTDOTOPT+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$OCAMLOPTDOTOPT"; then
- ac_cv_prog_OCAMLOPTDOTOPT="$OCAMLOPTDOTOPT" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_OCAMLOPTDOTOPT="${ac_tool_prefix}ocamlopt.opt"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-OCAMLOPTDOTOPT=$ac_cv_prog_OCAMLOPTDOTOPT
-if test -n "$OCAMLOPTDOTOPT"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLOPTDOTOPT" >&5
-$as_echo "$OCAMLOPTDOTOPT" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_OCAMLOPTDOTOPT"; then
- ac_ct_OCAMLOPTDOTOPT=$OCAMLOPTDOTOPT
- # Extract the first word of "ocamlopt.opt", so it can be a program name with args.
-set dummy ocamlopt.opt; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OCAMLOPTDOTOPT+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_OCAMLOPTDOTOPT"; then
- ac_cv_prog_ac_ct_OCAMLOPTDOTOPT="$ac_ct_OCAMLOPTDOTOPT" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_OCAMLOPTDOTOPT="ocamlopt.opt"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_OCAMLOPTDOTOPT=$ac_cv_prog_ac_ct_OCAMLOPTDOTOPT
-if test -n "$ac_ct_OCAMLOPTDOTOPT"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLOPTDOTOPT" >&5
-$as_echo "$ac_ct_OCAMLOPTDOTOPT" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_OCAMLOPTDOTOPT" = x; then
- OCAMLOPTDOTOPT="no"
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- OCAMLOPTDOTOPT=$ac_ct_OCAMLOPTDOTOPT
- fi
-else
- OCAMLOPTDOTOPT="$ac_cv_prog_OCAMLOPTDOTOPT"
-fi
-
- if test "$OCAMLOPTDOTOPT" != "no"; then
- TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: version differs from ocamlc; ocamlopt.opt discarded." >&5
-$as_echo "version differs from ocamlc; ocamlopt.opt discarded." >&6; }
- else
- OCAMLOPT=$OCAMLOPTDOTOPT
- fi
- fi
- fi
-
-
- fi
-
-
-
- # checking for ocaml toplevel
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ocaml", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ocaml; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OCAML+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$OCAML"; then
- ac_cv_prog_OCAML="$OCAML" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_OCAML="${ac_tool_prefix}ocaml"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-OCAML=$ac_cv_prog_OCAML
-if test -n "$OCAML"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAML" >&5
-$as_echo "$OCAML" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_OCAML"; then
- ac_ct_OCAML=$OCAML
- # Extract the first word of "ocaml", so it can be a program name with args.
-set dummy ocaml; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OCAML+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_OCAML"; then
- ac_cv_prog_ac_ct_OCAML="$ac_ct_OCAML" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_OCAML="ocaml"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_OCAML=$ac_cv_prog_ac_ct_OCAML
-if test -n "$ac_ct_OCAML"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAML" >&5
-$as_echo "$ac_ct_OCAML" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_OCAML" = x; then
- OCAML="no"
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- OCAML=$ac_ct_OCAML
- fi
-else
- OCAML="$ac_cv_prog_OCAML"
-fi
-
-
- # checking for ocamldep
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ocamldep", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ocamldep; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OCAMLDEP+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$OCAMLDEP"; then
- ac_cv_prog_OCAMLDEP="$OCAMLDEP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_OCAMLDEP="${ac_tool_prefix}ocamldep"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-OCAMLDEP=$ac_cv_prog_OCAMLDEP
-if test -n "$OCAMLDEP"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLDEP" >&5
-$as_echo "$OCAMLDEP" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_OCAMLDEP"; then
- ac_ct_OCAMLDEP=$OCAMLDEP
- # Extract the first word of "ocamldep", so it can be a program name with args.
-set dummy ocamldep; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OCAMLDEP+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_OCAMLDEP"; then
- ac_cv_prog_ac_ct_OCAMLDEP="$ac_ct_OCAMLDEP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_OCAMLDEP="ocamldep"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_OCAMLDEP=$ac_cv_prog_ac_ct_OCAMLDEP
-if test -n "$ac_ct_OCAMLDEP"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLDEP" >&5
-$as_echo "$ac_ct_OCAMLDEP" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_OCAMLDEP" = x; then
- OCAMLDEP="no"
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- OCAMLDEP=$ac_ct_OCAMLDEP
- fi
-else
- OCAMLDEP="$ac_cv_prog_OCAMLDEP"
-fi
-
-
- # checking for ocamlmktop
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ocamlmktop", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ocamlmktop; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OCAMLMKTOP+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$OCAMLMKTOP"; then
- ac_cv_prog_OCAMLMKTOP="$OCAMLMKTOP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_OCAMLMKTOP="${ac_tool_prefix}ocamlmktop"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-OCAMLMKTOP=$ac_cv_prog_OCAMLMKTOP
-if test -n "$OCAMLMKTOP"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLMKTOP" >&5
-$as_echo "$OCAMLMKTOP" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_OCAMLMKTOP"; then
- ac_ct_OCAMLMKTOP=$OCAMLMKTOP
- # Extract the first word of "ocamlmktop", so it can be a program name with args.
-set dummy ocamlmktop; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OCAMLMKTOP+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_OCAMLMKTOP"; then
- ac_cv_prog_ac_ct_OCAMLMKTOP="$ac_ct_OCAMLMKTOP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_OCAMLMKTOP="ocamlmktop"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_OCAMLMKTOP=$ac_cv_prog_ac_ct_OCAMLMKTOP
-if test -n "$ac_ct_OCAMLMKTOP"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLMKTOP" >&5
-$as_echo "$ac_ct_OCAMLMKTOP" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_OCAMLMKTOP" = x; then
- OCAMLMKTOP="no"
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- OCAMLMKTOP=$ac_ct_OCAMLMKTOP
- fi
-else
- OCAMLMKTOP="$ac_cv_prog_OCAMLMKTOP"
-fi
-
-
- # checking for ocamlmklib
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ocamlmklib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ocamlmklib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OCAMLMKLIB+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$OCAMLMKLIB"; then
- ac_cv_prog_OCAMLMKLIB="$OCAMLMKLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_OCAMLMKLIB="${ac_tool_prefix}ocamlmklib"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-OCAMLMKLIB=$ac_cv_prog_OCAMLMKLIB
-if test -n "$OCAMLMKLIB"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLMKLIB" >&5
-$as_echo "$OCAMLMKLIB" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_OCAMLMKLIB"; then
- ac_ct_OCAMLMKLIB=$OCAMLMKLIB
- # Extract the first word of "ocamlmklib", so it can be a program name with args.
-set dummy ocamlmklib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OCAMLMKLIB+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_OCAMLMKLIB"; then
- ac_cv_prog_ac_ct_OCAMLMKLIB="$ac_ct_OCAMLMKLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_OCAMLMKLIB="ocamlmklib"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_OCAMLMKLIB=$ac_cv_prog_ac_ct_OCAMLMKLIB
-if test -n "$ac_ct_OCAMLMKLIB"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLMKLIB" >&5
-$as_echo "$ac_ct_OCAMLMKLIB" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_OCAMLMKLIB" = x; then
- OCAMLMKLIB="no"
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- OCAMLMKLIB=$ac_ct_OCAMLMKLIB
- fi
-else
- OCAMLMKLIB="$ac_cv_prog_OCAMLMKLIB"
-fi
-
-
- # checking for ocamldoc
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ocamldoc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ocamldoc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OCAMLDOC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$OCAMLDOC"; then
- ac_cv_prog_OCAMLDOC="$OCAMLDOC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_OCAMLDOC="${ac_tool_prefix}ocamldoc"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-OCAMLDOC=$ac_cv_prog_OCAMLDOC
-if test -n "$OCAMLDOC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLDOC" >&5
-$as_echo "$OCAMLDOC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_OCAMLDOC"; then
- ac_ct_OCAMLDOC=$OCAMLDOC
- # Extract the first word of "ocamldoc", so it can be a program name with args.
-set dummy ocamldoc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OCAMLDOC+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_OCAMLDOC"; then
- ac_cv_prog_ac_ct_OCAMLDOC="$ac_ct_OCAMLDOC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_OCAMLDOC="ocamldoc"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_OCAMLDOC=$ac_cv_prog_ac_ct_OCAMLDOC
-if test -n "$ac_ct_OCAMLDOC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLDOC" >&5
-$as_echo "$ac_ct_OCAMLDOC" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_OCAMLDOC" = x; then
- OCAMLDOC="no"
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- OCAMLDOC=$ac_ct_OCAMLDOC
- fi
-else
- OCAMLDOC="$ac_cv_prog_OCAMLDOC"
-fi
-
-
- # checking for ocamlbuild
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ocamlbuild", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ocamlbuild; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OCAMLBUILD+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$OCAMLBUILD"; then
- ac_cv_prog_OCAMLBUILD="$OCAMLBUILD" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_OCAMLBUILD="${ac_tool_prefix}ocamlbuild"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-OCAMLBUILD=$ac_cv_prog_OCAMLBUILD
-if test -n "$OCAMLBUILD"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLBUILD" >&5
-$as_echo "$OCAMLBUILD" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_OCAMLBUILD"; then
- ac_ct_OCAMLBUILD=$OCAMLBUILD
- # Extract the first word of "ocamlbuild", so it can be a program name with args.
-set dummy ocamlbuild; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OCAMLBUILD+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_OCAMLBUILD"; then
- ac_cv_prog_ac_ct_OCAMLBUILD="$ac_ct_OCAMLBUILD" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_OCAMLBUILD="ocamlbuild"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_OCAMLBUILD=$ac_cv_prog_ac_ct_OCAMLBUILD
-if test -n "$ac_ct_OCAMLBUILD"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLBUILD" >&5
-$as_echo "$ac_ct_OCAMLBUILD" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_OCAMLBUILD" = x; then
- OCAMLBUILD="no"
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- OCAMLBUILD=$ac_ct_OCAMLBUILD
- fi
-else
- OCAMLBUILD="$ac_cv_prog_OCAMLBUILD"
-fi
-
-
-
- # checking for ocamlfind
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ocamlfind", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ocamlfind; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OCAMLFIND+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$OCAMLFIND"; then
- ac_cv_prog_OCAMLFIND="$OCAMLFIND" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_OCAMLFIND="${ac_tool_prefix}ocamlfind"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-OCAMLFIND=$ac_cv_prog_OCAMLFIND
-if test -n "$OCAMLFIND"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLFIND" >&5
-$as_echo "$OCAMLFIND" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_OCAMLFIND"; then
- ac_ct_OCAMLFIND=$OCAMLFIND
- # Extract the first word of "ocamlfind", so it can be a program name with args.
-set dummy ocamlfind; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OCAMLFIND+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_OCAMLFIND"; then
- ac_cv_prog_ac_ct_OCAMLFIND="$ac_ct_OCAMLFIND" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_OCAMLFIND="ocamlfind"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_OCAMLFIND=$ac_cv_prog_ac_ct_OCAMLFIND
-if test -n "$ac_ct_OCAMLFIND"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLFIND" >&5
-$as_echo "$ac_ct_OCAMLFIND" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_OCAMLFIND" = x; then
- OCAMLFIND="no"
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- OCAMLFIND=$ac_ct_OCAMLFIND
- fi
-else
- OCAMLFIND="$ac_cv_prog_OCAMLFIND"
-fi
-
-
-
-
-if test "x$OCAMLFIND" = "x"; then
- as_fn_error $? "You must have ocaml and findlib installed" "$LINENO" 5
-fi
-
-# Extract the first word of "camlp4of.opt", so it can be a program name with args.
-set dummy camlp4of.opt; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CAMLP4OF+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$CAMLP4OF"; then
- ac_cv_prog_CAMLP4OF="$CAMLP4OF" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CAMLP4OF="camlp4of.opt"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- test -z "$ac_cv_prog_CAMLP4OF" && ac_cv_prog_CAMLP4OF="no"
-fi
-fi
-CAMLP4OF=$ac_cv_prog_CAMLP4OF
-if test -n "$CAMLP4OF"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CAMLP4OF" >&5
-$as_echo "$CAMLP4OF" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-if test "x$CAMLP4OF" = "xno"; then
- as_fn_error $? "You must have camlp4 installed" "$LINENO" 5
-fi
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OCaml findlib package extlib" >&5
-$as_echo_n "checking for OCaml findlib package extlib... " >&6; }
-
- unset found
- unset pkg
- found=no
- for pkg in extlib ; do
- if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
-$as_echo "found" >&6; }
- OCAML_PKG_extlib=$pkg
- found=yes
- break
- fi
- done
- if test "$found" = "no" ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
-$as_echo "not found" >&6; }
- OCAML_PKG_extlib=no
- fi
-
-
-
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OCaml findlib package cil" >&5
-$as_echo_n "checking for OCaml findlib package cil... " >&6; }
-
- unset found
- unset pkg
- found=no
- for pkg in cil ; do
- if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
-$as_echo "found" >&6; }
- OCAML_PKG_cil=$pkg
- found=yes
- break
- fi
- done
- if test "$found" = "no" ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
-$as_echo "not found" >&6; }
- OCAML_PKG_cil=no
- fi
-
-
-
-
-# Extract the first word of "time", so it can be a program name with args.
-set dummy time; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_TIME+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- case $TIME in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_TIME="$TIME" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_TIME="$as_dir/$ac_word$ac_exec_ext"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- test -z "$ac_cv_path_TIME" && ac_cv_path_TIME="no"
- ;;
-esac
-fi
-TIME=$ac_cv_path_TIME
-if test -n "$TIME"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TIME" >&5
-$as_echo "$TIME" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-if test "x$TIME" = "xno"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'time' command not found; \`make benchmarks\` will not be available." >&5
-$as_echo "$as_me: WARNING: 'time' command not found; \`make benchmarks\` will not be available." >&2;}
-fi
-
-# Extract the first word of "diff", so it can be a program name with args.
-set dummy diff; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_DIFF+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- case $DIFF in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_DIFF="$DIFF" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_DIFF="$as_dir/$ac_word$ac_exec_ext"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- test -z "$ac_cv_path_DIFF" && ac_cv_path_DIFF="no"
- ;;
-esac
-fi
-DIFF=$ac_cv_path_DIFF
-if test -n "$DIFF"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DIFF" >&5
-$as_echo "$DIFF" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-if test "x$DIFF" = "xno"; then
- as_fn_error $? "'diff' command not found" "$LINENO" 5
-fi
-
-
-# Extract the first word of "gprof", so it can be a program name with args.
-set dummy gprof; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_GPROF+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$GPROF"; then
- ac_cv_prog_GPROF="$GPROF" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_GPROF="gprof"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- test -z "$ac_cv_prog_GPROF" && ac_cv_prog_GPROF="no"
-fi
-fi
-GPROF=$ac_cv_prog_GPROF
-if test -n "$GPROF"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GPROF" >&5
-$as_echo "$GPROF" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-# Extract the first word of "bisect-report", so it can be a program name with args.
-set dummy bisect-report; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_BISECT_REPORT+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$BISECT_REPORT"; then
- ac_cv_prog_BISECT_REPORT="$BISECT_REPORT" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_BISECT_REPORT="bisect-report"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- test -z "$ac_cv_prog_BISECT_REPORT" && ac_cv_prog_BISECT_REPORT="no"
-fi
-fi
-BISECT_REPORT=$ac_cv_prog_BISECT_REPORT
-if test -n "$BISECT_REPORT"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISECT_REPORT" >&5
-$as_echo "$BISECT_REPORT" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-# Check whether --enable-coverage was given.
-if test "${enable_coverage+set}" = set; then :
- enableval=$enable_coverage;
-else
- enable_coverage=no
-fi
-
-
-if test "x$enable_coverage" != "xno" -a "x$BISECT_REPORT" = "xno"; then
- as_fn_error $? "You must install ocaml-bisect package to get code coverage" "$LINENO" 5
-fi
-
-
-ac_config_headers="$ac_config_headers config.h"
-
-ac_config_files="$ac_config_files Makefile META bitstring_config.ml cil-tools/Makefile"
-
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems. If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, we kill variables containing newlines.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(
- for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
- eval ac_val=\$$ac_var
- case $ac_val in #(
- *${as_nl}*)
- case $ac_var in #(
- *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
- esac
- case $ac_var in #(
- _ | IFS | as_nl) ;; #(
- BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
- *) { eval $ac_var=; unset $ac_var;} ;;
- esac ;;
- esac
- done
-
- (set) 2>&1 |
- case $as_nl`(ac_space=' '; set) 2>&1` in #(
- *${as_nl}ac_space=\ *)
- # `set' does not quote correctly, so add quotes: double-quote
- # substitution turns \\\\ into \\, and sed turns \\ into \.
- sed -n \
- "s/'/'\\\\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
- ;; #(
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
- ;;
- esac |
- sort
-) |
- sed '
- /^ac_cv_env_/b end
- t clear
- :clear
- s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
- t end
- s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
- :end' >>confcache
-if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
- if test -w "$cache_file"; then
- if test "x$cache_file" != "x/dev/null"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
-$as_echo "$as_me: updating cache $cache_file" >&6;}
- if test ! -f "$cache_file" || test -h "$cache_file"; then
- cat confcache >"$cache_file"
- else
- case $cache_file in #(
- */* | ?:*)
- mv -f confcache "$cache_file"$$ &&
- mv -f "$cache_file"$$ "$cache_file" ;; #(
- *)
- mv -f confcache "$cache_file" ;;
- esac
- fi
- fi
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
-$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
- fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-U=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
- # 1. Remove the extension, and $U if already installed.
- ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
- ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
- # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
- # will be set to the directory where LIBOBJS objects are built.
- as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
- as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-
-
-: "${CONFIG_STATUS=./config.status}"
-ac_write_fail=0
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
-$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
-as_write_fail=0
-cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-
-SHELL=\${CONFIG_SHELL-$SHELL}
-export SHELL
-_ASEOF
-cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
- emulate sh
- NULLCMD=:
- # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
-else
- case `(set -o) 2>/dev/null` in #(
- *posix*) :
- set -o posix ;; #(
- *) :
- ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
- && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
- as_echo='print -r --'
- as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
- as_echo='printf %s\n'
- as_echo_n='printf %s'
-else
- if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
- as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
- as_echo_n='/usr/ucb/echo -n'
- else
- as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
- as_echo_n_body='eval
- arg=$1;
- case $arg in #(
- *"$as_nl"*)
- expr "X$arg" : "X\\(.*\\)$as_nl";
- arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
- esac;
- expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
- '
- export as_echo_n_body
- as_echo_n='sh -c $as_echo_n_body as_echo'
- fi
- export as_echo_body
- as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- PATH_SEPARATOR=:
- (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
- (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
- PATH_SEPARATOR=';'
- }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order. Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" "" $as_nl"
-
-# Find who we are. Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
- done
-IFS=$as_save_IFS
-
- ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
- as_myself=$0
-fi
-if test ! -f "$as_myself"; then
- $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
- exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there. '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
- && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
- as_status=$1; test $as_status -eq 0 && as_status=1
- if test "$4"; then
- as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
- fi
- $as_echo "$as_me: error: $2" >&2
- as_fn_exit $as_status
-} # as_fn_error
-
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
- return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
- set +e
- as_fn_set_status $1
- exit $1
-} # as_fn_exit
-
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
- { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
- eval 'as_fn_append ()
- {
- eval $1+=\$2
- }'
-else
- as_fn_append ()
- {
- eval $1=\$$1\$2
- }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
- eval 'as_fn_arith ()
- {
- as_val=$(( $* ))
- }'
-else
- as_fn_arith ()
- {
- as_val=`expr "$@" || test $? -eq 1`
- }
-fi # as_fn_arith
-
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
- test "X`expr 00001 : '.*\(...\)'`" = X001; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
- as_dirname=dirname
-else
- as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{
- s//\1/
- q
- }
- /^X\/\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\/\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
- case `echo 'xy\c'` in
- *c*) ECHO_T=' ';; # ECHO_T is single tab character.
- xy) ECHO_C='\c';;
- *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
- ECHO_T=' ';;
- esac;;
-*)
- ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
- rm -f conf$$.dir/conf$$.file
-else
- rm -f conf$$.dir
- mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
- if ln -s conf$$.file conf$$ 2>/dev/null; then
- as_ln_s='ln -s'
- # ... but there are two gotchas:
- # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
- # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
- # In both cases, we have to default to `cp -pR'.
- ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
- as_ln_s='cp -pR'
- elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
- else
- as_ln_s='cp -pR'
- fi
-else
- as_ln_s='cp -pR'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
- case $as_dir in #(
- -*) as_dir=./$as_dir;;
- esac
- test -d "$as_dir" || eval $as_mkdir_p || {
- as_dirs=
- while :; do
- case $as_dir in #(
- *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
- *) as_qdir=$as_dir;;
- esac
- as_dirs="'$as_qdir' $as_dirs"
- as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
- test -d "$as_dir" && break
- done
- test -z "$as_dirs" || eval "mkdir $as_dirs"
- } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p='mkdir -p "$as_dir"'
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-
-# as_fn_executable_p FILE
-# -----------------------
-# Test if FILE is an executable regular file.
-as_fn_executable_p ()
-{
- test -f "$1" && test -x "$1"
-} # as_fn_executable_p
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-exec 6>&1
-## ----------------------------------- ##
-## Main body of $CONFIG_STATUS script. ##
-## ----------------------------------- ##
-_ASEOF
-test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# Save the log message, to keep $0 and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling.
-ac_log="
-This file was extended by ocaml-bitstring $as_me 2.0.4, which was
-generated by GNU Autoconf 2.69. Invocation command line was
-
- CONFIG_FILES = $CONFIG_FILES
- CONFIG_HEADERS = $CONFIG_HEADERS
- CONFIG_LINKS = $CONFIG_LINKS
- CONFIG_COMMANDS = $CONFIG_COMMANDS
- $ $0 $@
-
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
-"
-
-_ACEOF
-
-case $ac_config_files in *"
-"*) set x $ac_config_files; shift; ac_config_files=$*;;
-esac
-
-case $ac_config_headers in *"
-"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
-esac
-
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-# Files that config.status was made for.
-config_files="$ac_config_files"
-config_headers="$ac_config_headers"
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-ac_cs_usage="\
-\`$as_me' instantiates files and other configuration actions
-from templates according to the current configuration. Unless the files
-and actions are specified as TAGs, all are instantiated by default.
-
-Usage: $0 [OPTION]... [TAG]...
-
- -h, --help print this help, then exit
- -V, --version print version number and configuration settings, then exit
- --config print configuration, then exit
- -q, --quiet, --silent
- do not print progress messages
- -d, --debug don't remove temporary files
- --recheck update $as_me by reconfiguring in the same conditions
- --file=FILE[:TEMPLATE]
- instantiate the configuration file FILE
- --header=FILE[:TEMPLATE]
- instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Report bugs to the package provider."
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
-ac_cs_version="\\
-ocaml-bitstring config.status 2.0.4
-configured by $0, generated by GNU Autoconf 2.69,
- with options \\"\$ac_cs_config\\"
-
-Copyright (C) 2012 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-
-ac_pwd='$ac_pwd'
-srcdir='$srcdir'
-INSTALL='$INSTALL'
-test -n "\$AWK" || AWK=awk
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# The default lists apply if the user does not specify any file.
-ac_need_defaults=:
-while test $# != 0
-do
- case $1 in
- --*=?*)
- ac_option=`expr "X$1" : 'X\([^=]*\)='`
- ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
- ac_shift=:
- ;;
- --*=)
- ac_option=`expr "X$1" : 'X\([^=]*\)='`
- ac_optarg=
- ac_shift=:
- ;;
- *)
- ac_option=$1
- ac_optarg=$2
- ac_shift=shift
- ;;
- esac
-
- case $ac_option in
- # Handling of the options.
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- ac_cs_recheck=: ;;
- --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
- $as_echo "$ac_cs_version"; exit ;;
- --config | --confi | --conf | --con | --co | --c )
- $as_echo "$ac_cs_config"; exit ;;
- --debug | --debu | --deb | --de | --d | -d )
- debug=: ;;
- --file | --fil | --fi | --f )
- $ac_shift
- case $ac_optarg in
- *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
- '') as_fn_error $? "missing file argument" ;;
- esac
- as_fn_append CONFIG_FILES " '$ac_optarg'"
- ac_need_defaults=false;;
- --header | --heade | --head | --hea )
- $ac_shift
- case $ac_optarg in
- *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
- esac
- as_fn_append CONFIG_HEADERS " '$ac_optarg'"
- ac_need_defaults=false;;
- --he | --h)
- # Conflict between --help and --header
- as_fn_error $? "ambiguous option: \`$1'
-Try \`$0 --help' for more information.";;
- --help | --hel | -h )
- $as_echo "$ac_cs_usage"; exit ;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil | --si | --s)
- ac_cs_silent=: ;;
-
- # This is an error.
- -*) as_fn_error $? "unrecognized option: \`$1'
-Try \`$0 --help' for more information." ;;
-
- *) as_fn_append ac_config_targets " $1"
- ac_need_defaults=false ;;
-
- esac
- shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
- exec 6>/dev/null
- ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-if \$ac_cs_recheck; then
- set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
- shift
- \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
- CONFIG_SHELL='$SHELL'
- export CONFIG_SHELL
- exec "\$@"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-exec 5>>config.log
-{
- echo
- sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
- $as_echo "$ac_log"
-} >&5
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-
-# Handling of arguments.
-for ac_config_target in $ac_config_targets
-do
- case $ac_config_target in
- "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
- "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
- "META") CONFIG_FILES="$CONFIG_FILES META" ;;
- "bitstring_config.ml") CONFIG_FILES="$CONFIG_FILES bitstring_config.ml" ;;
- "cil-tools/Makefile") CONFIG_FILES="$CONFIG_FILES cil-tools/Makefile" ;;
-
- *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
- esac
-done
-
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used. Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
- test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
- test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-fi
-
-# Have a temporary directory for convenience. Make it in the build tree
-# simply because there is no reason against having it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Hook for its removal unless debugging.
-# Note that there is a small window in which the directory will not be cleaned:
-# after its creation but before its name has been assigned to `$tmp'.
-$debug ||
-{
- tmp= ac_tmp=
- trap 'exit_status=$?
- : "${ac_tmp:=$tmp}"
- { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
-' 0
- trap 'as_fn_exit 1' 1 2 13 15
-}
-# Create a (secure) tmp directory for tmp files.
-
-{
- tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
- test -d "$tmp"
-} ||
-{
- tmp=./conf$$-$RANDOM
- (umask 077 && mkdir "$tmp")
-} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
-ac_tmp=$tmp
-
-# Set up the scripts for CONFIG_FILES section.
-# No need to generate them if there are no CONFIG_FILES.
-# This happens for instance with `./config.status config.h'.
-if test -n "$CONFIG_FILES"; then
-
-
-ac_cr=`echo X | tr X '\015'`
-# On cygwin, bash can eat \r inside `` if the user requested igncr.
-# But we know of no other shell where ac_cr would be empty at this
-# point, so we can use a bashism as a fallback.
-if test "x$ac_cr" = x; then
- eval ac_cr=\$\'\\r\'
-fi
-ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
-if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
- ac_cs_awk_cr='\\r'
-else
- ac_cs_awk_cr=$ac_cr
-fi
-
-echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
-_ACEOF
-
-
-{
- echo "cat >conf$$subs.awk <<_ACEOF" &&
- echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
- echo "_ACEOF"
-} >conf$$subs.sh ||
- as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
-ac_delim='%!_!# '
-for ac_last_try in false false false false false :; do
- . ./conf$$subs.sh ||
- as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-
- ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
- if test $ac_delim_n = $ac_delim_num; then
- break
- elif $ac_last_try; then
- as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
- else
- ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
- fi
-done
-rm -f conf$$subs.sh
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
-_ACEOF
-sed -n '
-h
-s/^/S["/; s/!.*/"]=/
-p
-g
-s/^[^!]*!//
-:repl
-t repl
-s/'"$ac_delim"'$//
-t delim
-:nl
-h
-s/\(.\{148\}\)..*/\1/
-t more1
-s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
-p
-n
-b repl
-:more1
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t nl
-:delim
-h
-s/\(.\{148\}\)..*/\1/
-t more2
-s/["\\]/\\&/g; s/^/"/; s/$/"/
-p
-b
-:more2
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t delim
-' <conf$$subs.awk | sed '
-/^[^""]/{
- N
- s/\n//
-}
-' >>$CONFIG_STATUS || ac_write_fail=1
-rm -f conf$$subs.awk
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-_ACAWK
-cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
- for (key in S) S_is_set[key] = 1
- FS = ""
-
-}
-{
- line = $ 0
- nfields = split(line, field, "@")
- substed = 0
- len = length(field[1])
- for (i = 2; i < nfields; i++) {
- key = field[i]
- keylen = length(key)
- if (S_is_set[key]) {
- value = S[key]
- line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
- len += length(value) + length(field[++i])
- substed = 1
- } else
- len += 1 + keylen
- }
-
- print line
-}
-
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
- sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
-else
- cat
-fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
- || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
-_ACEOF
-
-# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
-# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
-h
-s///
-s/^/:/
-s/[ ]*$/:/
-s/:\$(srcdir):/:/g
-s/:\${srcdir}:/:/g
-s/:@srcdir@:/:/g
-s/^:*//
-s/:*$//
-x
-s/\(=[ ]*\).*/\1/
-G
-s/\n//
-s/^[^=]*=[ ]*$//
-}'
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-fi # test -n "$CONFIG_FILES"
-
-# Set up the scripts for CONFIG_HEADERS section.
-# No need to generate them if there are no CONFIG_HEADERS.
-# This happens for instance with `./config.status Makefile'.
-if test -n "$CONFIG_HEADERS"; then
-cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
-BEGIN {
-_ACEOF
-
-# Transform confdefs.h into an awk script `defines.awk', embedded as
-# here-document in config.status, that substitutes the proper values into
-# config.h.in to produce config.h.
-
-# Create a delimiter string that does not exist in confdefs.h, to ease
-# handling of long lines.
-ac_delim='%!_!# '
-for ac_last_try in false false :; do
- ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
- if test -z "$ac_tt"; then
- break
- elif $ac_last_try; then
- as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
- else
- ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
- fi
-done
-
-# For the awk script, D is an array of macro values keyed by name,
-# likewise P contains macro parameters if any. Preserve backslash
-# newline sequences.
-
-ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
-sed -n '
-s/.\{148\}/&'"$ac_delim"'/g
-t rset
-:rset
-s/^[ ]*#[ ]*define[ ][ ]*/ /
-t def
-d
-:def
-s/\\$//
-t bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3"/p
-s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
-d
-:bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3\\\\\\n"\\/p
-t cont
-s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
-t cont
-d
-:cont
-n
-s/.\{148\}/&'"$ac_delim"'/g
-t clear
-:clear
-s/\\$//
-t bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/"/p
-d
-:bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
-b cont
-' <confdefs.h | sed '
-s/'"$ac_delim"'/"\\\
-"/g' >>$CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
- for (key in D) D_is_set[key] = 1
- FS = ""
-}
-/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
- line = \$ 0
- split(line, arg, " ")
- if (arg[1] == "#") {
- defundef = arg[2]
- mac1 = arg[3]
- } else {
- defundef = substr(arg[1], 2)
- mac1 = arg[2]
- }
- split(mac1, mac2, "(") #)
- macro = mac2[1]
- prefix = substr(line, 1, index(line, defundef) - 1)
- if (D_is_set[macro]) {
- # Preserve the white space surrounding the "#".
- print prefix "define", macro P[macro] D[macro]
- next
- } else {
- # Replace #undef with comments. This is necessary, for example,
- # in the case of _POSIX_SOURCE, which is predefined and required
- # on some systems where configure will not decide to define it.
- if (defundef == "undef") {
- print "/*", prefix defundef, macro, "*/"
- next
- }
- }
-}
-{ print }
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
- as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
-fi # test -n "$CONFIG_HEADERS"
-
-
-eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS "
-shift
-for ac_tag
-do
- case $ac_tag in
- :[FHLC]) ac_mode=$ac_tag; continue;;
- esac
- case $ac_mode$ac_tag in
- :[FHL]*:*);;
- :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
- :[FH]-) ac_tag=-:-;;
- :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
- esac
- ac_save_IFS=$IFS
- IFS=:
- set x $ac_tag
- IFS=$ac_save_IFS
- shift
- ac_file=$1
- shift
-
- case $ac_mode in
- :L) ac_source=$1;;
- :[FH])
- ac_file_inputs=
- for ac_f
- do
- case $ac_f in
- -) ac_f="$ac_tmp/stdin";;
- *) # Look for the file first in the build tree, then in the source tree
- # (if the path is not absolute). The absolute path cannot be DOS-style,
- # because $ac_f cannot contain `:'.
- test -f "$ac_f" ||
- case $ac_f in
- [\\/$]*) false;;
- *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
- esac ||
- as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
- esac
- case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
- as_fn_append ac_file_inputs " '$ac_f'"
- done
-
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- configure_input='Generated from '`
- $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
- `' by configure.'
- if test x"$ac_file" != x-; then
- configure_input="$ac_file. $configure_input"
- { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
-$as_echo "$as_me: creating $ac_file" >&6;}
- fi
- # Neutralize special characters interpreted by sed in replacement strings.
- case $configure_input in #(
- *\&* | *\|* | *\\* )
- ac_sed_conf_input=`$as_echo "$configure_input" |
- sed 's/[\\\\&|]/\\\\&/g'`;; #(
- *) ac_sed_conf_input=$configure_input;;
- esac
-
- case $ac_tag in
- *:-:* | *:-) cat >"$ac_tmp/stdin" \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
- esac
- ;;
- esac
-
- ac_dir=`$as_dirname -- "$ac_file" ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`
- as_dir="$ac_dir"; as_fn_mkdir_p
- ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
- ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
- # A ".." for each directory in $ac_dir_suffix.
- ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
- case $ac_top_builddir_sub in
- "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
- *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
- esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
- .) # We are building in place.
- ac_srcdir=.
- ac_top_srcdir=$ac_top_builddir_sub
- ac_abs_top_srcdir=$ac_pwd ;;
- [\\/]* | ?:[\\/]* ) # Absolute name.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir
- ac_abs_top_srcdir=$srcdir ;;
- *) # Relative name.
- ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_build_prefix$srcdir
- ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
-
- case $ac_mode in
- :F)
- #
- # CONFIG_FILE
- #
-
- case $INSTALL in
- [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
- *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
- esac
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# If the template does not know about datarootdir, expand it.
-# FIXME: This hack should be removed a few years after 2.60.
-ac_datarootdir_hack=; ac_datarootdir_seen=
-ac_sed_dataroot='
-/datarootdir/ {
- p
- q
-}
-/@datadir@/p
-/@docdir@/p
-/@infodir@/p
-/@localedir@/p
-/@mandir@/p'
-case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
-*datarootdir*) ac_datarootdir_seen=yes;;
-*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
-$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
- ac_datarootdir_hack='
- s&@datadir@&$datadir&g
- s&@docdir@&$docdir&g
- s&@infodir@&$infodir&g
- s&@localedir@&$localedir&g
- s&@mandir@&$mandir&g
- s&\\\${datarootdir}&$datarootdir&g' ;;
-esac
-_ACEOF
-
-# Neutralize VPATH when `$srcdir' = `.'.
-# Shell code in configure.ac might set extrasub.
-# FIXME: do we really want to maintain this feature?
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_sed_extra="$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s|@configure_input@|$ac_sed_conf_input|;t t
-s&@top_builddir@&$ac_top_builddir_sub&;t t
-s&@top_build_prefix@&$ac_top_build_prefix&;t t
-s&@srcdir@&$ac_srcdir&;t t
-s&@abs_srcdir@&$ac_abs_srcdir&;t t
-s&@top_srcdir@&$ac_top_srcdir&;t t
-s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
-s&@builddir@&$ac_builddir&;t t
-s&@abs_builddir@&$ac_abs_builddir&;t t
-s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
-s&@INSTALL@&$ac_INSTALL&;t t
-$ac_datarootdir_hack
-"
-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
- >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-
-test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
- { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
- { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
- "$ac_tmp/out"`; test -z "$ac_out"; } &&
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined. Please make sure it is defined" >&5
-$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined. Please make sure it is defined" >&2;}
-
- rm -f "$ac_tmp/stdin"
- case $ac_file in
- -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
- *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
- esac \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5
- ;;
- :H)
- #
- # CONFIG_HEADER
- #
- if test x"$ac_file" != x-; then
- {
- $as_echo "/* $configure_input */" \
- && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
- } >"$ac_tmp/config.h" \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5
- if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
-$as_echo "$as_me: $ac_file is unchanged" >&6;}
- else
- rm -f "$ac_file"
- mv "$ac_tmp/config.h" "$ac_file" \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5
- fi
- else
- $as_echo "/* $configure_input */" \
- && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
- || as_fn_error $? "could not create -" "$LINENO" 5
- fi
- ;;
-
-
- esac
-
-done # for ac_tag
-
-
-as_fn_exit 0
-_ACEOF
-ac_clean_files=$ac_clean_files_save
-
-test $ac_write_fail = 0 ||
- as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded. So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status. When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
- ac_cs_success=:
- ac_config_status_args=
- test "$silent" = yes &&
- ac_config_status_args="$ac_config_status_args --quiet"
- exec 5>/dev/null
- $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
- exec 5>>config.log
- # Use ||, not &&, to avoid exiting from the if with $? = 1, which
- # would make configure fail if this is the last instruction.
- $ac_cs_success || as_fn_exit 1
-fi
-if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
-$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
-fi
-
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index fa4368c..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,107 +0,0 @@
-# Bitstring syntax extension.
-# Copyright (C) 2008-2013 Red Hat Inc., Richard W.M. Jones
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-dnl Process this file with autoconf to produce a configure script.
-
-AC_INIT(ocaml-bitstring,2.0.4)
-
-AC_PROG_SED
-
-dnl Check for basic C environment.
-AC_PROG_CC
-AC_PROG_INSTALL
-AC_PROG_CPP
-
-AC_C_PROTOTYPES
-test "x$U" != "x" && AC_MSG_ERROR(Compiler not ANSI compliant)
-
-AC_PROG_CC_C_O
-
-dnl Check for native endianness.
-AC_C_BIGENDIAN(,,
- [AC_MSG_ERROR([Machine endianness could not be determined])]
-)
-if test "x$WORDS_BIGENDIAN" = "x"; then
- NATIVEENDIAN=LittleEndian
-else
- NATIVEENDIAN=BigEndian
-fi
-AC_SUBST(NATIVEENDIAN)
-
-dnl Create byteswap.h if the system doesn't have this file.
-dnl Written by Oskar Liljeblad.
-dnl From gnulib, license is LGPLv2+.
-AC_CHECK_HEADERS([byteswap.h], [
- BYTESWAP_H=''
-], [
- BYTESWAP_H='byteswap.h'
-])
-AC_SUBST(BYTESWAP_H)
-
-dnl Check for basic OCaml environment & findlib.
-AC_PROG_OCAML
-AC_PROG_FINDLIB
-
-if test "x$OCAMLFIND" = "x"; then
- AC_MSG_ERROR([You must have ocaml and findlib installed])
-fi
-
-dnl Check for camlp4
-AC_CHECK_PROG(CAMLP4OF,camlp4of.opt,camlp4of.opt,no)
-if test "x$CAMLP4OF" = "xno"; then
- AC_MSG_ERROR([You must have camlp4 installed])
-fi
-
-dnl Check for Extlib (optional)
-AC_CHECK_OCAML_PKG(extlib)
-
-dnl Check for CIL (optional)
-AC_CHECK_OCAML_PKG(cil)
-
-dnl Check for /usr/bin/time and get full path.
-AC_PATH_PROG(TIME,time,no)
-if test "x$TIME" = "xno"; then
- AC_MSG_WARN(['time' command not found; `make benchmarks` will not be available.])
-fi
-
-dnl Check for diff and get full path.
-AC_PATH_PROG(DIFF,diff,no)
-if test "x$DIFF" = "xno"; then
- AC_MSG_ERROR(['diff' command not found])
-fi
-AC_SUBST(DIFF)
-
-dnl Check for gprof (optional).
-AC_CHECK_PROG(GPROF,gprof,gprof,no)
-
-dnl Check for ocaml-bisect (optional) and --enable-coverage.
-AC_CHECK_PROG(BISECT_REPORT,bisect-report,bisect-report,no)
-AC_ARG_ENABLE([coverage],
- [AS_HELP_STRING([--enable-coverage],
- [add code coverage information (slow) @<:@default=no@:>@])],
- [],
- [enable_coverage=no])
-
-if test "x$enable_coverage" != "xno" -a "x$BISECT_REPORT" = "xno"; then
- AC_MSG_ERROR([You must install ocaml-bisect package to get code coverage])
-fi
-AC_SUBST(enable_coverage)
-
-dnl Produce output files.
-AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_FILES([Makefile META bitstring_config.ml cil-tools/Makefile])
-AC_OUTPUT
diff --git a/coverage-report/file0000.html b/coverage-report/file0000.html
deleted file mode 100644
index 7856c13..0000000
--- a/coverage-report/file0000.html
+++ /dev/null
@@ -1,66 +0,0 @@
-<html>
- <head>
- <title>Bisect report</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <h3>File: bitstring_config.ml (<a href="index.html">return to index</a>)</h3>
- <hr class="codeSep"/>
- <h4>Statistics:</h4>
- <table class="simple">
- <tr><th>kind</th><th width="16px">&nbsp;</th><th>coverage</th></tr>
- <tr><td>binding</td><td width="16px">&nbsp;</td><td>5 / 5 (100 %)</td></tr>
- <tr><td>sequence</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>for</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>if/then</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>try</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>while</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>match/function</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class expression</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class initializer</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class method</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class value</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>toplevel expression</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- </table>
- <hr class="codeSep"/>
- <h4>Source:</h4>
- <code>
- <div class="lineNone">000001| (*&nbsp;Bitstring&nbsp;library.</div>
- <div class="lineNone">000002| &nbsp;*&nbsp;Copyright&nbsp;(C)&nbsp;2008&nbsp;Red&nbsp;Hat&nbsp;Inc.,&nbsp;Richard&nbsp;W.M.&nbsp;Jones</div>
- <div class="lineNone">000003| &nbsp;*</div>
- <div class="lineNone">000004| &nbsp;*&nbsp;bitstring_config.ml.&nbsp;&nbsp;Generated&nbsp;from&nbsp;bitstring_config.ml.in&nbsp;by&nbsp;configure.</div>
- <div class="lineNone">000005| &nbsp;*</div>
- <div class="lineNone">000006| &nbsp;*&nbsp;This&nbsp;library&nbsp;is&nbsp;free&nbsp;software;&nbsp;you&nbsp;can&nbsp;redistribute&nbsp;it&nbsp;and/or</div>
- <div class="lineNone">000007| &nbsp;*&nbsp;modify&nbsp;it&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;the&nbsp;GNU&nbsp;Lesser&nbsp;General&nbsp;Public</div>
- <div class="lineNone">000008| &nbsp;*&nbsp;License&nbsp;as&nbsp;published&nbsp;by&nbsp;the&nbsp;Free&nbsp;Software&nbsp;Foundation;&nbsp;either</div>
- <div class="lineNone">000009| &nbsp;*&nbsp;version&nbsp;2&nbsp;of&nbsp;the&nbsp;License,&nbsp;or&nbsp;(at&nbsp;your&nbsp;option)&nbsp;any&nbsp;later&nbsp;version,</div>
- <div class="lineNone">000010| &nbsp;*&nbsp;with&nbsp;the&nbsp;OCaml&nbsp;linking&nbsp;exception&nbsp;described&nbsp;in&nbsp;COPYING.LIB.</div>
- <div class="lineNone">000011| &nbsp;*</div>
- <div class="lineNone">000012| &nbsp;*&nbsp;This&nbsp;library&nbsp;is&nbsp;distributed&nbsp;in&nbsp;the&nbsp;hope&nbsp;that&nbsp;it&nbsp;will&nbsp;be&nbsp;useful,</div>
- <div class="lineNone">000013| &nbsp;*&nbsp;but&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of</div>
- <div class="lineNone">000014| &nbsp;*&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;&nbsp;See&nbsp;the&nbsp;GNU</div>
- <div class="lineNone">000015| &nbsp;*&nbsp;Lesser&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.</div>
- <div class="lineNone">000016| &nbsp;*</div>
- <div class="lineNone">000017| &nbsp;*&nbsp;You&nbsp;should&nbsp;have&nbsp;received&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;GNU&nbsp;Lesser&nbsp;General&nbsp;Public</div>
- <div class="lineNone">000018| &nbsp;*&nbsp;License&nbsp;along&nbsp;with&nbsp;this&nbsp;library;&nbsp;if&nbsp;not,&nbsp;write&nbsp;to&nbsp;the&nbsp;Free&nbsp;Software</div>
- <div class="lineNone">000019| &nbsp;*&nbsp;Foundation,&nbsp;Inc.,&nbsp;51&nbsp;Franklin&nbsp;Street,&nbsp;Fifth&nbsp;Floor,&nbsp;Boston,&nbsp;MA&nbsp;02110-1301&nbsp;USA</div>
- <div class="lineNone">000020| &nbsp;*</div>
- <div class="lineNone">000021| &nbsp;*&nbsp;$Id:&nbsp;bitstring_config.ml.in&nbsp;142&nbsp;2008-07-17&nbsp;15:45:56Z&nbsp;richard.wm.jones&nbsp;$</div>
- <div class="lineNone">000022| &nbsp;*)</div>
- <div class="lineNone">000023| &nbsp;</div>
- <div class="lineNone">000024| (*&nbsp;This&nbsp;file&nbsp;contains&nbsp;general&nbsp;configuration&nbsp;settings,&nbsp;set&nbsp;by&nbsp;the</div>
- <div class="lineNone">000025| &nbsp;*&nbsp;configure&nbsp;script.</div>
- <div class="lineNone">000026| &nbsp;*)</div>
- <div class="lineNone">000027| &nbsp;</div>
- <div class="lineAllVisited">000028| let&nbsp;nativeendian&nbsp;=&nbsp;(*[43]*)Bitstring_types.LittleEndian</div>
- <div class="lineNone">000029| &nbsp;</div>
- <div class="lineAllVisited">000030| let&nbsp;package&nbsp;=&nbsp;(*[43]*)&quot;ocaml-bitstring&quot;</div>
- <div class="lineAllVisited">000031| let&nbsp;version&nbsp;=&nbsp;(*[43]*)&quot;1.9.8&quot;</div>
- <div class="lineAllVisited">000032| let&nbsp;ocamllibdir&nbsp;=&nbsp;(*[43]*)&quot;/usr/lib/ocaml&quot;</div>
- <div class="lineNone">000033| &nbsp;</div>
- <div class="lineAllVisited">000034| let&nbsp;diff&nbsp;=&nbsp;(*[43]*)&quot;/usr/bin/diff&quot;</div>
- </code>
- <hr class="codeSep"/>
- <p class="footer">Generated by <a href="http://bisect.x9c.fr">Bisect</a> on 2008-08-27 13:53:18</p>
- </body>
-</html>
diff --git a/coverage-report/file0001.html b/coverage-report/file0001.html
deleted file mode 100644
index 3e88fb4..0000000
--- a/coverage-report/file0001.html
+++ /dev/null
@@ -1,1209 +0,0 @@
-<html>
- <head>
- <title>Bisect report</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <h3>File: bitstring.ml (<a href="index.html">return to index</a>)</h3>
- <hr class="codeSep"/>
- <h4>Statistics:</h4>
- <table class="simple">
- <tr><th>kind</th><th width="16px">&nbsp;</th><th>coverage</th></tr>
- <tr><td>binding</td><td width="16px">&nbsp;</td><td>226 / 245 (92 %)</td></tr>
- <tr><td>sequence</td><td width="16px">&nbsp;</td><td>83 / 95 (87 %)</td></tr>
- <tr><td>for</td><td width="16px">&nbsp;</td><td>5 / 5 (100 %)</td></tr>
- <tr><td>if/then</td><td width="16px">&nbsp;</td><td>141 / 194 (72 %)</td></tr>
- <tr><td>try</td><td width="16px">&nbsp;</td><td>1 / 2 (50 %)</td></tr>
- <tr><td>while</td><td width="16px">&nbsp;</td><td>3 / 3 (100 %)</td></tr>
- <tr><td>match/function</td><td width="16px">&nbsp;</td><td>64 / 87 (73 %)</td></tr>
- <tr><td>class expression</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class initializer</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class method</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class value</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>toplevel expression</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- </table>
- <hr class="codeSep"/>
- <h4>Source:</h4>
- <code>
- <div class="lineNone">000001| (*&nbsp;Bitstring&nbsp;library.</div>
- <div class="lineNone">000002| &nbsp;*&nbsp;Copyright&nbsp;(C)&nbsp;2008&nbsp;Red&nbsp;Hat&nbsp;Inc.,&nbsp;Richard&nbsp;W.M.&nbsp;Jones</div>
- <div class="lineNone">000003| &nbsp;*</div>
- <div class="lineNone">000004| &nbsp;*&nbsp;This&nbsp;library&nbsp;is&nbsp;free&nbsp;software;&nbsp;you&nbsp;can&nbsp;redistribute&nbsp;it&nbsp;and/or</div>
- <div class="lineNone">000005| &nbsp;*&nbsp;modify&nbsp;it&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;the&nbsp;GNU&nbsp;Lesser&nbsp;General&nbsp;Public</div>
- <div class="lineNone">000006| &nbsp;*&nbsp;License&nbsp;as&nbsp;published&nbsp;by&nbsp;the&nbsp;Free&nbsp;Software&nbsp;Foundation;&nbsp;either</div>
- <div class="lineNone">000007| &nbsp;*&nbsp;version&nbsp;2&nbsp;of&nbsp;the&nbsp;License,&nbsp;or&nbsp;(at&nbsp;your&nbsp;option)&nbsp;any&nbsp;later&nbsp;version,</div>
- <div class="lineNone">000008| &nbsp;*&nbsp;with&nbsp;the&nbsp;OCaml&nbsp;linking&nbsp;exception&nbsp;described&nbsp;in&nbsp;COPYING.LIB.</div>
- <div class="lineNone">000009| &nbsp;*</div>
- <div class="lineNone">000010| &nbsp;*&nbsp;This&nbsp;library&nbsp;is&nbsp;distributed&nbsp;in&nbsp;the&nbsp;hope&nbsp;that&nbsp;it&nbsp;will&nbsp;be&nbsp;useful,</div>
- <div class="lineNone">000011| &nbsp;*&nbsp;but&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of</div>
- <div class="lineNone">000012| &nbsp;*&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;&nbsp;See&nbsp;the&nbsp;GNU</div>
- <div class="lineNone">000013| &nbsp;*&nbsp;Lesser&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.</div>
- <div class="lineNone">000014| &nbsp;*</div>
- <div class="lineNone">000015| &nbsp;*&nbsp;You&nbsp;should&nbsp;have&nbsp;received&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;GNU&nbsp;Lesser&nbsp;General&nbsp;Public</div>
- <div class="lineNone">000016| &nbsp;*&nbsp;License&nbsp;along&nbsp;with&nbsp;this&nbsp;library;&nbsp;if&nbsp;not,&nbsp;write&nbsp;to&nbsp;the&nbsp;Free&nbsp;Software</div>
- <div class="lineNone">000017| &nbsp;*&nbsp;Foundation,&nbsp;Inc.,&nbsp;51&nbsp;Franklin&nbsp;Street,&nbsp;Fifth&nbsp;Floor,&nbsp;Boston,&nbsp;MA&nbsp;02110-1301&nbsp;USA</div>
- <div class="lineNone">000018| &nbsp;*</div>
- <div class="lineNone">000019| &nbsp;*&nbsp;$Id:&nbsp;bitstring.ml&nbsp;159&nbsp;2008-08-27&nbsp;11:26:45Z&nbsp;richard.wm.jones&nbsp;$</div>
- <div class="lineNone">000020| &nbsp;*)</div>
- <div class="lineNone">000021| &nbsp;</div>
- <div class="lineNone">000022| open&nbsp;Printf</div>
- <div class="lineNone">000023| &nbsp;</div>
- <div class="lineNone">000024| include&nbsp;Bitstring_types</div>
- <div class="lineNone">000025| include&nbsp;Bitstring_config</div>
- <div class="lineNone">000026| &nbsp;</div>
- <div class="lineNone">000027| (*&nbsp;Enable&nbsp;runtime&nbsp;debug&nbsp;messages.&nbsp;&nbsp;Must&nbsp;also&nbsp;have&nbsp;been&nbsp;enabled</div>
- <div class="lineNone">000028| &nbsp;*&nbsp;in&nbsp;pa_bitstring.ml.</div>
- <div class="lineNone">000029| &nbsp;*)</div>
- <div class="lineAllVisited">000030| let&nbsp;debug&nbsp;=&nbsp;(*[43]*)ref&nbsp;false</div>
- <div class="lineNone">000031| &nbsp;</div>
- <div class="lineNone">000032| (*&nbsp;Exceptions.&nbsp;*)</div>
- <div class="lineNone">000033| exception&nbsp;Construct_failure&nbsp;of&nbsp;string&nbsp;*&nbsp;string&nbsp;*&nbsp;int&nbsp;*&nbsp;int</div>
- <div class="lineNone">000034| &nbsp;</div>
- <div class="lineNone">000035| (*&nbsp;A&nbsp;bitstring&nbsp;is&nbsp;simply&nbsp;the&nbsp;data&nbsp;itself&nbsp;(as&nbsp;a&nbsp;string),&nbsp;and&nbsp;the</div>
- <div class="lineNone">000036| &nbsp;*&nbsp;bitoffset&nbsp;and&nbsp;the&nbsp;bitlength&nbsp;within&nbsp;the&nbsp;string.&nbsp;&nbsp;Note&nbsp;offset/length</div>
- <div class="lineNone">000037| &nbsp;*&nbsp;are&nbsp;counted&nbsp;in&nbsp;bits,&nbsp;not&nbsp;bytes.</div>
- <div class="lineNone">000038| &nbsp;*)</div>
- <div class="lineNone">000039| type&nbsp;bitstring&nbsp;=&nbsp;string&nbsp;*&nbsp;int&nbsp;*&nbsp;int</div>
- <div class="lineNone">000040| &nbsp;</div>
- <div class="lineNone">000041| type&nbsp;t&nbsp;=&nbsp;bitstring</div>
- <div class="lineNone">000042| &nbsp;</div>
- <div class="lineNone">000043| (*&nbsp;Functions&nbsp;to&nbsp;create&nbsp;and&nbsp;load&nbsp;bitstrings.&nbsp;*)</div>
- <div class="lineAllVisited">000044| let&nbsp;empty_bitstring&nbsp;=&nbsp;(*[43]*)&quot;&quot;,&nbsp;0,&nbsp;0</div>
- <div class="lineNone">000045| &nbsp;</div>
- <div class="lineNone">000046| let&nbsp;make_bitstring&nbsp;len&nbsp;c&nbsp;=</div>
- <div class="lineAllVisited">000047| &nbsp;&nbsp;(*[1325989]*)if&nbsp;len&nbsp;&gt;=&nbsp;0&nbsp;then&nbsp;(*[1325989]*)String.make&nbsp;((len+7)&nbsp;lsr&nbsp;3)&nbsp;c,&nbsp;0,&nbsp;len</div>
- <div class="lineNone">000048| &nbsp;&nbsp;else</div>
- <div class="lineAllUnvisited">000049| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)invalid_arg&nbsp;(</div>
- <div class="lineNone">000050| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sprintf&nbsp;&quot;make_bitstring/create_bitstring:&nbsp;len&nbsp;%d&nbsp;&lt;&nbsp;0&quot;&nbsp;len</div>
- <div class="lineNone">000051| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000052| &nbsp;</div>
- <div class="lineAllVisited">000053| let&nbsp;create_bitstring&nbsp;len&nbsp;=&nbsp;(*[42903]*)make_bitstring&nbsp;len&nbsp;'\000'</div>
- <div class="lineNone">000054| &nbsp;</div>
- <div class="lineAllVisited">000055| let&nbsp;zeroes_bitstring&nbsp;=&nbsp;(*[43]*)create_bitstring</div>
- <div class="lineNone">000056| &nbsp;</div>
- <div class="lineAllVisited">000057| let&nbsp;ones_bitstring&nbsp;len&nbsp;=&nbsp;(*[1278457]*)make_bitstring&nbsp;len&nbsp;'\xff'</div>
- <div class="lineNone">000058| &nbsp;</div>
- <div class="lineAllVisited">000059| let&nbsp;bitstring_of_string&nbsp;str&nbsp;=&nbsp;(*[2]*)str,&nbsp;0,&nbsp;String.length&nbsp;str&nbsp;lsl&nbsp;3</div>
- <div class="lineNone">000060| &nbsp;</div>
- <div class="lineNone">000061| let&nbsp;bitstring_of_chan&nbsp;chan&nbsp;=</div>
- <div class="lineAllVisited">000062| &nbsp;&nbsp;(*[36]*)let&nbsp;tmpsize&nbsp;=&nbsp;16384&nbsp;in</div>
- <div class="lineAllVisited">000063| &nbsp;&nbsp;(*[36]*)let&nbsp;buf&nbsp;=&nbsp;Buffer.create&nbsp;tmpsize&nbsp;in</div>
- <div class="lineAllVisited">000064| &nbsp;&nbsp;(*[36]*)let&nbsp;tmp&nbsp;=&nbsp;String.create&nbsp;tmpsize&nbsp;in</div>
- <div class="lineAllVisited">000065| &nbsp;&nbsp;(*[36]*)let&nbsp;n&nbsp;=&nbsp;ref&nbsp;0&nbsp;in</div>
- <div class="lineAllVisited">000066| &nbsp;&nbsp;(*[36]*)while&nbsp;(*[72]*)n&nbsp;:=&nbsp;input&nbsp;chan&nbsp;tmp&nbsp;0&nbsp;tmpsize;&nbsp;!(*[72]*)n&nbsp;&gt;&nbsp;0&nbsp;do</div>
- <div class="lineAllVisited">000067| &nbsp;&nbsp;&nbsp;&nbsp;(*[36]*)Buffer.add_substring&nbsp;buf&nbsp;tmp&nbsp;0&nbsp;!n;</div>
- <div class="lineNone">000068| &nbsp;&nbsp;done;</div>
- <div class="lineAllVisited">000069| &nbsp;&nbsp;(*[36]*)Buffer.contents&nbsp;buf,&nbsp;0,&nbsp;Buffer.length&nbsp;buf&nbsp;lsl&nbsp;3</div>
- <div class="lineNone">000070| &nbsp;</div>
- <div class="lineNone">000071| let&nbsp;bitstring_of_chan_max&nbsp;chan&nbsp;max&nbsp;=</div>
- <div class="lineAllVisited">000072| &nbsp;&nbsp;(*[2]*)let&nbsp;tmpsize&nbsp;=&nbsp;16384&nbsp;in</div>
- <div class="lineAllVisited">000073| &nbsp;&nbsp;(*[2]*)let&nbsp;buf&nbsp;=&nbsp;Buffer.create&nbsp;tmpsize&nbsp;in</div>
- <div class="lineAllVisited">000074| &nbsp;&nbsp;(*[2]*)let&nbsp;tmp&nbsp;=&nbsp;String.create&nbsp;tmpsize&nbsp;in</div>
- <div class="lineAllVisited">000075| &nbsp;&nbsp;(*[2]*)let&nbsp;len&nbsp;=&nbsp;ref&nbsp;0&nbsp;in</div>
- <div class="lineAllVisited">000076| &nbsp;&nbsp;(*[2]*)let&nbsp;rec&nbsp;loop&nbsp;()&nbsp;=</div>
- <div class="lineAllVisited">000077| &nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)if&nbsp;!len&nbsp;&lt;&nbsp;max&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000078| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)let&nbsp;r&nbsp;=&nbsp;min&nbsp;tmpsize&nbsp;(max&nbsp;-&nbsp;!len)&nbsp;in</div>
- <div class="lineAllVisited">000079| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)let&nbsp;n&nbsp;=&nbsp;input&nbsp;chan&nbsp;tmp&nbsp;0&nbsp;r&nbsp;in</div>
- <div class="lineAllUnvisited">000080| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)if&nbsp;n&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000081| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)Buffer.add_substring&nbsp;buf&nbsp;tmp&nbsp;0&nbsp;n;</div>
- <div class="lineAllVisited">000082| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)len&nbsp;(*[2]*):=&nbsp;!len&nbsp;+&nbsp;n;</div>
- <div class="lineAllVisited">000083| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)loop&nbsp;()</div>
- <div class="lineNone">000084| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000085| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000086| &nbsp;&nbsp;in</div>
- <div class="lineAllVisited">000087| &nbsp;&nbsp;(*[2]*)loop&nbsp;(*[2]*)();</div>
- <div class="lineAllVisited">000088| &nbsp;&nbsp;(*[2]*)Buffer.contents&nbsp;buf,&nbsp;0,&nbsp;!len&nbsp;lsl&nbsp;3</div>
- <div class="lineNone">000089| &nbsp;</div>
- <div class="lineNone">000090| let&nbsp;bitstring_of_file_descr&nbsp;fd&nbsp;=</div>
- <div class="lineAllVisited">000091| &nbsp;&nbsp;(*[1]*)let&nbsp;tmpsize&nbsp;=&nbsp;16384&nbsp;in</div>
- <div class="lineAllVisited">000092| &nbsp;&nbsp;(*[1]*)let&nbsp;buf&nbsp;=&nbsp;Buffer.create&nbsp;tmpsize&nbsp;in</div>
- <div class="lineAllVisited">000093| &nbsp;&nbsp;(*[1]*)let&nbsp;tmp&nbsp;=&nbsp;String.create&nbsp;tmpsize&nbsp;in</div>
- <div class="lineAllVisited">000094| &nbsp;&nbsp;(*[1]*)let&nbsp;n&nbsp;=&nbsp;ref&nbsp;0&nbsp;in</div>
- <div class="lineAllVisited">000095| &nbsp;&nbsp;(*[1]*)while&nbsp;(*[2]*)n&nbsp;:=&nbsp;Unix.read&nbsp;fd&nbsp;tmp&nbsp;0&nbsp;tmpsize;&nbsp;!(*[2]*)n&nbsp;&gt;&nbsp;0&nbsp;do</div>
- <div class="lineAllVisited">000096| &nbsp;&nbsp;&nbsp;&nbsp;(*[1]*)Buffer.add_substring&nbsp;buf&nbsp;tmp&nbsp;0&nbsp;!n;</div>
- <div class="lineNone">000097| &nbsp;&nbsp;done;</div>
- <div class="lineAllVisited">000098| &nbsp;&nbsp;(*[1]*)Buffer.contents&nbsp;buf,&nbsp;0,&nbsp;Buffer.length&nbsp;buf&nbsp;lsl&nbsp;3</div>
- <div class="lineNone">000099| &nbsp;</div>
- <div class="lineNone">000100| let&nbsp;bitstring_of_file_descr_max&nbsp;fd&nbsp;max&nbsp;=</div>
- <div class="lineAllVisited">000101| &nbsp;&nbsp;(*[2]*)let&nbsp;tmpsize&nbsp;=&nbsp;16384&nbsp;in</div>
- <div class="lineAllVisited">000102| &nbsp;&nbsp;(*[2]*)let&nbsp;buf&nbsp;=&nbsp;Buffer.create&nbsp;tmpsize&nbsp;in</div>
- <div class="lineAllVisited">000103| &nbsp;&nbsp;(*[2]*)let&nbsp;tmp&nbsp;=&nbsp;String.create&nbsp;tmpsize&nbsp;in</div>
- <div class="lineAllVisited">000104| &nbsp;&nbsp;(*[2]*)let&nbsp;len&nbsp;=&nbsp;ref&nbsp;0&nbsp;in</div>
- <div class="lineAllVisited">000105| &nbsp;&nbsp;(*[2]*)let&nbsp;rec&nbsp;loop&nbsp;()&nbsp;=</div>
- <div class="lineAllVisited">000106| &nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)if&nbsp;!len&nbsp;&lt;&nbsp;max&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000107| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)let&nbsp;r&nbsp;=&nbsp;min&nbsp;tmpsize&nbsp;(max&nbsp;-&nbsp;!len)&nbsp;in</div>
- <div class="lineAllVisited">000108| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)let&nbsp;n&nbsp;=&nbsp;Unix.read&nbsp;fd&nbsp;tmp&nbsp;0&nbsp;r&nbsp;in</div>
- <div class="lineAllUnvisited">000109| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)if&nbsp;n&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000110| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)Buffer.add_substring&nbsp;buf&nbsp;tmp&nbsp;0&nbsp;n;</div>
- <div class="lineAllVisited">000111| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)len&nbsp;(*[2]*):=&nbsp;!len&nbsp;+&nbsp;n;</div>
- <div class="lineAllVisited">000112| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)loop&nbsp;()</div>
- <div class="lineNone">000113| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000114| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000115| &nbsp;&nbsp;in</div>
- <div class="lineAllVisited">000116| &nbsp;&nbsp;(*[2]*)loop&nbsp;(*[2]*)();</div>
- <div class="lineAllVisited">000117| &nbsp;&nbsp;(*[2]*)Buffer.contents&nbsp;buf,&nbsp;0,&nbsp;!len&nbsp;lsl&nbsp;3</div>
- <div class="lineNone">000118| &nbsp;</div>
- <div class="lineNone">000119| let&nbsp;bitstring_of_file&nbsp;fname&nbsp;=</div>
- <div class="lineAllVisited">000120| &nbsp;&nbsp;(*[35]*)let&nbsp;chan&nbsp;=&nbsp;open_in_bin&nbsp;fname&nbsp;in</div>
- <div class="lineAllVisited">000121| &nbsp;&nbsp;(*[35]*)try</div>
- <div class="lineAllVisited">000122| &nbsp;&nbsp;&nbsp;&nbsp;(*[35]*)let&nbsp;bs&nbsp;=&nbsp;bitstring_of_chan&nbsp;chan&nbsp;in</div>
- <div class="lineAllVisited">000123| &nbsp;&nbsp;&nbsp;&nbsp;(*[35]*)close_in&nbsp;(*[35]*)chan;</div>
- <div class="lineAllVisited">000124| &nbsp;&nbsp;&nbsp;&nbsp;(*[35]*)bs</div>
- <div class="lineNone">000125| &nbsp;&nbsp;with&nbsp;exn&nbsp;-&gt;</div>
- <div class="lineAllUnvisited">000126| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)close_in&nbsp;(*[0]*)chan;</div>
- <div class="lineAllUnvisited">000127| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)raise&nbsp;exn</div>
- <div class="lineNone">000128| &nbsp;</div>
- <div class="lineAllVisited">000129| let&nbsp;bitstring_length&nbsp;(_,&nbsp;_,&nbsp;len)&nbsp;=&nbsp;(*[1565492]*)len</div>
- <div class="lineNone">000130| &nbsp;</div>
- <div class="lineNone">000131| let&nbsp;subbitstring&nbsp;(data,&nbsp;off,&nbsp;len)&nbsp;off'&nbsp;len'&nbsp;=</div>
- <div class="lineAllVisited">000132| &nbsp;&nbsp;(*[1]*)let&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;off'&nbsp;in</div>
- <div class="lineMixed">000133| &nbsp;&nbsp;(*[1]*)if&nbsp;len&nbsp;&lt;&nbsp;off'&nbsp;+&nbsp;len'&nbsp;then&nbsp;(*[0]*)invalid_arg&nbsp;&quot;subbitstring&quot;;</div>
- <div class="lineAllVisited">000134| &nbsp;&nbsp;((*[1]*)data,&nbsp;off,&nbsp;len')</div>
- <div class="lineNone">000135| &nbsp;</div>
- <div class="lineNone">000136| let&nbsp;dropbits&nbsp;n&nbsp;(data,&nbsp;off,&nbsp;len)&nbsp;=</div>
- <div class="lineAllVisited">000137| &nbsp;&nbsp;(*[336643]*)let&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;n&nbsp;in</div>
- <div class="lineAllVisited">000138| &nbsp;&nbsp;(*[336643]*)let&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;n&nbsp;in</div>
- <div class="lineMixed">000139| &nbsp;&nbsp;(*[336643]*)if&nbsp;len&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;(*[0]*)invalid_arg&nbsp;&quot;dropbits&quot;;</div>
- <div class="lineAllVisited">000140| &nbsp;&nbsp;((*[336643]*)data,&nbsp;off,&nbsp;len)</div>
- <div class="lineNone">000141| &nbsp;</div>
- <div class="lineNone">000142| let&nbsp;takebits&nbsp;n&nbsp;(data,&nbsp;off,&nbsp;len)&nbsp;=</div>
- <div class="lineMixed">000143| &nbsp;&nbsp;(*[100]*)if&nbsp;len&nbsp;&lt;&nbsp;n&nbsp;then&nbsp;(*[0]*)invalid_arg&nbsp;&quot;takebits&quot;;</div>
- <div class="lineAllVisited">000144| &nbsp;&nbsp;((*[100]*)data,&nbsp;off,&nbsp;n)</div>
- <div class="lineNone">000145| &nbsp;</div>
- <div class="lineNone">000146| (*----------------------------------------------------------------------*)</div>
- <div class="lineNone">000147| (*&nbsp;Bitwise&nbsp;functions.</div>
- <div class="lineNone">000148| &nbsp;*</div>
- <div class="lineNone">000149| &nbsp;*&nbsp;We&nbsp;try&nbsp;to&nbsp;isolate&nbsp;all&nbsp;bitwise&nbsp;functions&nbsp;within&nbsp;these&nbsp;modules.</div>
- <div class="lineNone">000150| &nbsp;*)</div>
- <div class="lineNone">000151| &nbsp;</div>
- <div class="lineNone">000152| module&nbsp;I&nbsp;=&nbsp;struct</div>
- <div class="lineNone">000153| &nbsp;&nbsp;(*&nbsp;Bitwise&nbsp;operations&nbsp;on&nbsp;ints.&nbsp;&nbsp;Note&nbsp;that&nbsp;we&nbsp;assume&nbsp;int&nbsp;&lt;=&nbsp;31&nbsp;bits.&nbsp;*)</div>
- <div class="lineNone">000154| &nbsp;&nbsp;external&nbsp;(&lt;&lt;&lt;)&nbsp;:&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;%lslint&quot;</div>
- <div class="lineNone">000155| &nbsp;&nbsp;external&nbsp;(&gt;&gt;&gt;)&nbsp;:&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;%lsrint&quot;</div>
- <div class="lineNone">000156| &nbsp;&nbsp;external&nbsp;to_int&nbsp;:&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;%identity&quot;</div>
- <div class="lineAllVisited">000157| &nbsp;&nbsp;let&nbsp;zero&nbsp;=&nbsp;(*[43]*)0</div>
- <div class="lineAllVisited">000158| &nbsp;&nbsp;let&nbsp;one&nbsp;=&nbsp;(*[43]*)1</div>
- <div class="lineAllVisited">000159| &nbsp;&nbsp;let&nbsp;minus_one&nbsp;=&nbsp;(*[43]*)-1</div>
- <div class="lineAllVisited">000160| &nbsp;&nbsp;let&nbsp;ff&nbsp;=&nbsp;(*[43]*)0xff</div>
- <div class="lineNone">000161| &nbsp;</div>
- <div class="lineNone">000162| &nbsp;&nbsp;(*&nbsp;Create&nbsp;a&nbsp;mask&nbsp;0-31&nbsp;bits&nbsp;wide.&nbsp;*)</div>
- <div class="lineNone">000163| &nbsp;&nbsp;let&nbsp;mask&nbsp;bits&nbsp;=</div>
- <div class="lineAllVisited">000164| &nbsp;&nbsp;&nbsp;&nbsp;(*[2342]*)if&nbsp;bits&nbsp;&lt;&nbsp;30&nbsp;then</div>
- <div class="lineAllVisited">000165| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((*[1952]*)one&nbsp;&lt;&lt;&lt;&nbsp;bits)&nbsp;-&nbsp;1</div>
- <div class="lineAllVisited">000166| &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(*[390]*)if&nbsp;bits&nbsp;=&nbsp;30&nbsp;then</div>
- <div class="lineAllUnvisited">000167| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)max_int</div>
- <div class="lineAllVisited">000168| &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(*[390]*)if&nbsp;bits&nbsp;=&nbsp;31&nbsp;then</div>
- <div class="lineAllVisited">000169| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[390]*)minus_one</div>
- <div class="lineNone">000170| &nbsp;&nbsp;&nbsp;&nbsp;else</div>
- <div class="lineAllUnvisited">000171| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)invalid_arg&nbsp;&quot;Bitstring.I.mask&quot;</div>
- <div class="lineNone">000172| &nbsp;</div>
- <div class="lineNone">000173| &nbsp;&nbsp;(*&nbsp;Byte&nbsp;swap&nbsp;an&nbsp;int&nbsp;of&nbsp;a&nbsp;given&nbsp;size.&nbsp;*)</div>
- <div class="lineNone">000174| &nbsp;&nbsp;let&nbsp;byteswap&nbsp;v&nbsp;bits&nbsp;=</div>
- <div class="lineMixed">000175| &nbsp;&nbsp;&nbsp;&nbsp;(*[780]*)if&nbsp;bits&nbsp;&lt;=&nbsp;8&nbsp;then&nbsp;(*[0]*)v</div>
- <div class="lineAllVisited">000176| &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(*[780]*)if&nbsp;bits&nbsp;&lt;=&nbsp;16&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000177| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;shift&nbsp;=&nbsp;bits-8&nbsp;in</div>
- <div class="lineAllVisited">000178| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;v1&nbsp;=&nbsp;v&nbsp;&gt;&gt;&gt;&nbsp;shift&nbsp;in</div>
- <div class="lineAllVisited">000179| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;v2&nbsp;=&nbsp;((v&nbsp;land&nbsp;(mask&nbsp;shift))&nbsp;&lt;&lt;&lt;&nbsp;8)&nbsp;in</div>
- <div class="lineAllVisited">000180| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v2&nbsp;(*[260]*)lor&nbsp;v1</div>
- <div class="lineAllVisited">000181| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(*[520]*)if&nbsp;bits&nbsp;&lt;=&nbsp;24&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000182| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;shift&nbsp;=&nbsp;bits&nbsp;-&nbsp;16&nbsp;in</div>
- <div class="lineAllVisited">000183| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;v1&nbsp;=&nbsp;v&nbsp;&gt;&gt;&gt;&nbsp;(8+shift)&nbsp;in</div>
- <div class="lineAllVisited">000184| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;v2&nbsp;=&nbsp;((v&nbsp;&gt;&gt;&gt;&nbsp;shift)&nbsp;land&nbsp;ff)&nbsp;&lt;&lt;&lt;&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000185| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;v3&nbsp;=&nbsp;(v&nbsp;land&nbsp;(mask&nbsp;shift))&nbsp;&lt;&lt;&lt;&nbsp;16&nbsp;in</div>
- <div class="lineAllVisited">000186| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v3&nbsp;lor&nbsp;v2&nbsp;(*[260]*)lor&nbsp;v1</div>
- <div class="lineNone">000187| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(</div>
- <div class="lineAllVisited">000188| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;shift&nbsp;=&nbsp;bits&nbsp;-&nbsp;24&nbsp;in</div>
- <div class="lineAllVisited">000189| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;v1&nbsp;=&nbsp;v&nbsp;&gt;&gt;&gt;&nbsp;(16+shift)&nbsp;in</div>
- <div class="lineAllVisited">000190| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;v2&nbsp;=&nbsp;((v&nbsp;&gt;&gt;&gt;&nbsp;(8+shift))&nbsp;land&nbsp;ff)&nbsp;&lt;&lt;&lt;&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000191| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;v3&nbsp;=&nbsp;((v&nbsp;&gt;&gt;&gt;&nbsp;shift)&nbsp;land&nbsp;ff)&nbsp;&lt;&lt;&lt;&nbsp;16&nbsp;in</div>
- <div class="lineAllVisited">000192| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;v4&nbsp;=&nbsp;(v&nbsp;land&nbsp;(mask&nbsp;shift))&nbsp;&lt;&lt;&lt;&nbsp;24&nbsp;in</div>
- <div class="lineAllVisited">000193| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v4&nbsp;lor&nbsp;v3&nbsp;lor&nbsp;v2&nbsp;(*[260]*)lor&nbsp;v1</div>
- <div class="lineNone">000194| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000195| &nbsp;</div>
- <div class="lineNone">000196| &nbsp;&nbsp;(*&nbsp;Check&nbsp;a&nbsp;value&nbsp;is&nbsp;in&nbsp;range&nbsp;0&nbsp;..&nbsp;2^bits-1.&nbsp;*)</div>
- <div class="lineNone">000197| &nbsp;&nbsp;let&nbsp;range_unsigned&nbsp;v&nbsp;bits&nbsp;=</div>
- <div class="lineAllVisited">000198| &nbsp;&nbsp;&nbsp;&nbsp;(*[1172]*)let&nbsp;mask&nbsp;=&nbsp;lnot&nbsp;(mask&nbsp;bits)&nbsp;in</div>
- <div class="lineAllVisited">000199| &nbsp;&nbsp;&nbsp;&nbsp;(v&nbsp;(*[1172]*)land&nbsp;mask)&nbsp;=&nbsp;zero</div>
- <div class="lineNone">000200| &nbsp;</div>
- <div class="lineNone">000201| &nbsp;&nbsp;(*&nbsp;Call&nbsp;function&nbsp;g&nbsp;on&nbsp;the&nbsp;top&nbsp;bits,&nbsp;then&nbsp;f&nbsp;on&nbsp;each&nbsp;full&nbsp;byte</div>
- <div class="lineNone">000202| &nbsp;&nbsp;&nbsp;*&nbsp;(big&nbsp;endian&nbsp;-&nbsp;so&nbsp;start&nbsp;at&nbsp;top).</div>
- <div class="lineNone">000203| &nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineNone">000204| &nbsp;&nbsp;let&nbsp;rec&nbsp;map_bytes_be&nbsp;g&nbsp;f&nbsp;v&nbsp;bits&nbsp;=</div>
- <div class="lineAllVisited">000205| &nbsp;&nbsp;&nbsp;&nbsp;(*[1436]*)if&nbsp;bits&nbsp;&gt;=&nbsp;8&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000206| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[1044]*)map_bytes_be&nbsp;g&nbsp;f&nbsp;(v&nbsp;&gt;&gt;&gt;&nbsp;8)&nbsp;(*[1044]*)(bits-8);</div>
- <div class="lineAllVisited">000207| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[1044]*)let&nbsp;lsb&nbsp;=&nbsp;v&nbsp;land&nbsp;ff&nbsp;in</div>
- <div class="lineAllVisited">000208| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[1044]*)f&nbsp;(to_int&nbsp;lsb)</div>
- <div class="lineAllVisited">000209| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(*[262]*)if&nbsp;bits&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000210| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[130]*)let&nbsp;lsb&nbsp;=&nbsp;v&nbsp;land&nbsp;(mask&nbsp;bits)&nbsp;in</div>
- <div class="lineAllVisited">000211| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[130]*)g&nbsp;(to_int&nbsp;lsb)&nbsp;bits</div>
- <div class="lineNone">000212| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000213| &nbsp;</div>
- <div class="lineNone">000214| &nbsp;&nbsp;(*&nbsp;Call&nbsp;function&nbsp;g&nbsp;on&nbsp;the&nbsp;top&nbsp;bits,&nbsp;then&nbsp;f&nbsp;on&nbsp;each&nbsp;full&nbsp;byte</div>
- <div class="lineNone">000215| &nbsp;&nbsp;&nbsp;*&nbsp;(little&nbsp;endian&nbsp;-&nbsp;so&nbsp;start&nbsp;at&nbsp;root).</div>
- <div class="lineNone">000216| &nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineNone">000217| &nbsp;&nbsp;let&nbsp;rec&nbsp;map_bytes_le&nbsp;g&nbsp;f&nbsp;v&nbsp;bits&nbsp;=</div>
- <div class="lineAllVisited">000218| &nbsp;&nbsp;&nbsp;&nbsp;(*[2860]*)if&nbsp;bits&nbsp;&gt;=&nbsp;8&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000219| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2080]*)let&nbsp;lsb&nbsp;=&nbsp;v&nbsp;land&nbsp;ff&nbsp;in</div>
- <div class="lineAllVisited">000220| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2080]*)f&nbsp;(*[2080]*)(to_int&nbsp;lsb);</div>
- <div class="lineAllVisited">000221| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2080]*)map_bytes_le&nbsp;g&nbsp;f&nbsp;(v&nbsp;&gt;&gt;&gt;&nbsp;8)&nbsp;(bits-8)</div>
- <div class="lineAllVisited">000222| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(*[520]*)if&nbsp;bits&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000223| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)let&nbsp;lsb&nbsp;=&nbsp;v&nbsp;land&nbsp;(mask&nbsp;bits)&nbsp;in</div>
- <div class="lineAllVisited">000224| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[260]*)g&nbsp;(to_int&nbsp;lsb)&nbsp;bits</div>
- <div class="lineNone">000225| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000226| end</div>
- <div class="lineNone">000227| &nbsp;</div>
- <div class="lineNone">000228| module&nbsp;I32&nbsp;=&nbsp;struct</div>
- <div class="lineNone">000229| &nbsp;&nbsp;(*&nbsp;Bitwise&nbsp;operations&nbsp;on&nbsp;int32s.&nbsp;&nbsp;Note&nbsp;we&nbsp;try&nbsp;to&nbsp;keep&nbsp;it&nbsp;as&nbsp;similar</div>
- <div class="lineNone">000230| &nbsp;&nbsp;&nbsp;*&nbsp;as&nbsp;possible&nbsp;to&nbsp;the&nbsp;I&nbsp;module&nbsp;above,&nbsp;to&nbsp;make&nbsp;it&nbsp;easier&nbsp;to&nbsp;track</div>
- <div class="lineNone">000231| &nbsp;&nbsp;&nbsp;*&nbsp;down&nbsp;bugs.</div>
- <div class="lineNone">000232| &nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineAllVisited">000233| &nbsp;&nbsp;let&nbsp;(&lt;&lt;&lt;)&nbsp;=&nbsp;(*[43]*)Int32.shift_left</div>
- <div class="lineAllVisited">000234| &nbsp;&nbsp;let&nbsp;(&gt;&gt;&gt;)&nbsp;=&nbsp;(*[43]*)Int32.shift_right_logical</div>
- <div class="lineAllVisited">000235| &nbsp;&nbsp;let&nbsp;(land)&nbsp;=&nbsp;(*[43]*)Int32.logand</div>
- <div class="lineAllVisited">000236| &nbsp;&nbsp;let&nbsp;(lor)&nbsp;=&nbsp;(*[43]*)Int32.logor</div>
- <div class="lineAllVisited">000237| &nbsp;&nbsp;let&nbsp;lnot&nbsp;=&nbsp;(*[43]*)Int32.lognot</div>
- <div class="lineAllVisited">000238| &nbsp;&nbsp;let&nbsp;pred&nbsp;=&nbsp;(*[43]*)Int32.pred</div>
- <div class="lineAllVisited">000239| &nbsp;&nbsp;let&nbsp;max_int&nbsp;=&nbsp;(*[43]*)Int32.max_int</div>
- <div class="lineAllVisited">000240| &nbsp;&nbsp;let&nbsp;to_int&nbsp;=&nbsp;(*[43]*)Int32.to_int</div>
- <div class="lineAllVisited">000241| &nbsp;&nbsp;let&nbsp;zero&nbsp;=&nbsp;(*[43]*)Int32.zero</div>
- <div class="lineAllVisited">000242| &nbsp;&nbsp;let&nbsp;one&nbsp;=&nbsp;(*[43]*)Int32.one</div>
- <div class="lineAllVisited">000243| &nbsp;&nbsp;let&nbsp;minus_one&nbsp;=&nbsp;(*[43]*)Int32.minus_one</div>
- <div class="lineAllVisited">000244| &nbsp;&nbsp;let&nbsp;ff&nbsp;=&nbsp;(*[43]*)0xff_l</div>
- <div class="lineNone">000245| &nbsp;</div>
- <div class="lineNone">000246| &nbsp;&nbsp;(*&nbsp;Create&nbsp;a&nbsp;mask&nbsp;so&nbsp;many&nbsp;bits&nbsp;wide.&nbsp;*)</div>
- <div class="lineNone">000247| &nbsp;&nbsp;let&nbsp;mask&nbsp;bits&nbsp;=</div>
- <div class="lineAllVisited">000248| &nbsp;&nbsp;&nbsp;&nbsp;(*[272]*)if&nbsp;bits&nbsp;&lt;&nbsp;31&nbsp;then</div>
- <div class="lineAllVisited">000249| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[272]*)pred&nbsp;(one&nbsp;&lt;&lt;&lt;&nbsp;bits)</div>
- <div class="lineAllUnvisited">000250| &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(*[0]*)if&nbsp;bits&nbsp;=&nbsp;31&nbsp;then</div>
- <div class="lineAllUnvisited">000251| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)max_int</div>
- <div class="lineAllUnvisited">000252| &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(*[0]*)if&nbsp;bits&nbsp;=&nbsp;32&nbsp;then</div>
- <div class="lineAllUnvisited">000253| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)minus_one</div>
- <div class="lineNone">000254| &nbsp;&nbsp;&nbsp;&nbsp;else</div>
- <div class="lineAllUnvisited">000255| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)invalid_arg&nbsp;&quot;Bitstring.I32.mask&quot;</div>
- <div class="lineNone">000256| &nbsp;</div>
- <div class="lineNone">000257| &nbsp;&nbsp;(*&nbsp;Byte&nbsp;swap&nbsp;an&nbsp;int&nbsp;of&nbsp;a&nbsp;given&nbsp;size.&nbsp;*)</div>
- <div class="lineNone">000258| &nbsp;&nbsp;let&nbsp;byteswap&nbsp;v&nbsp;bits&nbsp;=</div>
- <div class="lineMixed">000259| &nbsp;&nbsp;&nbsp;&nbsp;(*[272]*)if&nbsp;bits&nbsp;&lt;=&nbsp;8&nbsp;then&nbsp;(*[0]*)v</div>
- <div class="lineAllVisited">000260| &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(*[272]*)if&nbsp;bits&nbsp;&lt;=&nbsp;16&nbsp;then&nbsp;(</div>
- <div class="lineAllUnvisited">000261| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;shift&nbsp;=&nbsp;bits-8&nbsp;in</div>
- <div class="lineAllUnvisited">000262| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;v1&nbsp;=&nbsp;v&nbsp;&gt;&gt;&gt;&nbsp;shift&nbsp;in</div>
- <div class="lineAllUnvisited">000263| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;v2&nbsp;=&nbsp;(v&nbsp;land&nbsp;(mask&nbsp;shift))&nbsp;&lt;&lt;&lt;&nbsp;8&nbsp;in</div>
- <div class="lineAllUnvisited">000264| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v2&nbsp;(*[0]*)lor&nbsp;v1</div>
- <div class="lineAllVisited">000265| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(*[272]*)if&nbsp;bits&nbsp;&lt;=&nbsp;24&nbsp;then&nbsp;(</div>
- <div class="lineAllUnvisited">000266| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;shift&nbsp;=&nbsp;bits&nbsp;-&nbsp;16&nbsp;in</div>
- <div class="lineAllUnvisited">000267| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;v1&nbsp;=&nbsp;v&nbsp;&gt;&gt;&gt;&nbsp;(8+shift)&nbsp;in</div>
- <div class="lineAllUnvisited">000268| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;v2&nbsp;=&nbsp;((v&nbsp;&gt;&gt;&gt;&nbsp;shift)&nbsp;land&nbsp;ff)&nbsp;&lt;&lt;&lt;&nbsp;8&nbsp;in</div>
- <div class="lineAllUnvisited">000269| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;v3&nbsp;=&nbsp;(v&nbsp;land&nbsp;(mask&nbsp;shift))&nbsp;&lt;&lt;&lt;&nbsp;16&nbsp;in</div>
- <div class="lineAllUnvisited">000270| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v3&nbsp;lor&nbsp;v2&nbsp;(*[0]*)lor&nbsp;v1</div>
- <div class="lineNone">000271| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(</div>
- <div class="lineAllVisited">000272| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[272]*)let&nbsp;shift&nbsp;=&nbsp;bits&nbsp;-&nbsp;24&nbsp;in</div>
- <div class="lineAllVisited">000273| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[272]*)let&nbsp;v1&nbsp;=&nbsp;v&nbsp;&gt;&gt;&gt;&nbsp;(16+shift)&nbsp;in</div>
- <div class="lineAllVisited">000274| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[272]*)let&nbsp;v2&nbsp;=&nbsp;((v&nbsp;&gt;&gt;&gt;&nbsp;(8+shift))&nbsp;land&nbsp;ff)&nbsp;&lt;&lt;&lt;&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000275| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[272]*)let&nbsp;v3&nbsp;=&nbsp;((v&nbsp;&gt;&gt;&gt;&nbsp;shift)&nbsp;land&nbsp;ff)&nbsp;&lt;&lt;&lt;&nbsp;16&nbsp;in</div>
- <div class="lineAllVisited">000276| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[272]*)let&nbsp;v4&nbsp;=&nbsp;(v&nbsp;land&nbsp;(mask&nbsp;shift))&nbsp;&lt;&lt;&lt;&nbsp;24&nbsp;in</div>
- <div class="lineAllVisited">000277| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v4&nbsp;lor&nbsp;v3&nbsp;lor&nbsp;v2&nbsp;(*[272]*)lor&nbsp;v1</div>
- <div class="lineNone">000278| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000279| &nbsp;</div>
- <div class="lineNone">000280| &nbsp;&nbsp;(*&nbsp;Check&nbsp;a&nbsp;value&nbsp;is&nbsp;in&nbsp;range&nbsp;0&nbsp;..&nbsp;2^bits-1.&nbsp;*)</div>
- <div class="lineNone">000281| &nbsp;&nbsp;let&nbsp;range_unsigned&nbsp;v&nbsp;bits&nbsp;=</div>
- <div class="lineAllUnvisited">000282| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;mask&nbsp;=&nbsp;lnot&nbsp;(mask&nbsp;bits)&nbsp;in</div>
- <div class="lineAllUnvisited">000283| &nbsp;&nbsp;&nbsp;&nbsp;(v&nbsp;(*[0]*)land&nbsp;mask)&nbsp;=&nbsp;zero</div>
- <div class="lineNone">000284| &nbsp;</div>
- <div class="lineNone">000285| &nbsp;&nbsp;(*&nbsp;Call&nbsp;function&nbsp;g&nbsp;on&nbsp;the&nbsp;top&nbsp;bits,&nbsp;then&nbsp;f&nbsp;on&nbsp;each&nbsp;full&nbsp;byte</div>
- <div class="lineNone">000286| &nbsp;&nbsp;&nbsp;*&nbsp;(big&nbsp;endian&nbsp;-&nbsp;so&nbsp;start&nbsp;at&nbsp;top).</div>
- <div class="lineNone">000287| &nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineNone">000288| &nbsp;&nbsp;let&nbsp;rec&nbsp;map_bytes_be&nbsp;g&nbsp;f&nbsp;v&nbsp;bits&nbsp;=</div>
- <div class="lineAllUnvisited">000289| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)if&nbsp;bits&nbsp;&gt;=&nbsp;8&nbsp;then&nbsp;(</div>
- <div class="lineAllUnvisited">000290| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)map_bytes_be&nbsp;g&nbsp;f&nbsp;(v&nbsp;&gt;&gt;&gt;&nbsp;8)&nbsp;(*[0]*)(bits-8);</div>
- <div class="lineAllUnvisited">000291| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;lsb&nbsp;=&nbsp;v&nbsp;land&nbsp;ff&nbsp;in</div>
- <div class="lineAllUnvisited">000292| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)f&nbsp;(to_int&nbsp;lsb)</div>
- <div class="lineAllUnvisited">000293| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(*[0]*)if&nbsp;bits&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllUnvisited">000294| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;lsb&nbsp;=&nbsp;v&nbsp;land&nbsp;(mask&nbsp;bits)&nbsp;in</div>
- <div class="lineAllUnvisited">000295| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)g&nbsp;(to_int&nbsp;lsb)&nbsp;bits</div>
- <div class="lineNone">000296| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000297| &nbsp;</div>
- <div class="lineNone">000298| &nbsp;&nbsp;(*&nbsp;Call&nbsp;function&nbsp;g&nbsp;on&nbsp;the&nbsp;top&nbsp;bits,&nbsp;then&nbsp;f&nbsp;on&nbsp;each&nbsp;full&nbsp;byte</div>
- <div class="lineNone">000299| &nbsp;&nbsp;&nbsp;*&nbsp;(little&nbsp;endian&nbsp;-&nbsp;so&nbsp;start&nbsp;at&nbsp;root).</div>
- <div class="lineNone">000300| &nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineNone">000301| &nbsp;&nbsp;let&nbsp;rec&nbsp;map_bytes_le&nbsp;g&nbsp;f&nbsp;v&nbsp;bits&nbsp;=</div>
- <div class="lineAllUnvisited">000302| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)if&nbsp;bits&nbsp;&gt;=&nbsp;8&nbsp;then&nbsp;(</div>
- <div class="lineAllUnvisited">000303| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;lsb&nbsp;=&nbsp;v&nbsp;land&nbsp;ff&nbsp;in</div>
- <div class="lineAllUnvisited">000304| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)f&nbsp;(*[0]*)(to_int&nbsp;lsb);</div>
- <div class="lineAllUnvisited">000305| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)map_bytes_le&nbsp;g&nbsp;f&nbsp;(v&nbsp;&gt;&gt;&gt;&nbsp;8)&nbsp;(bits-8)</div>
- <div class="lineAllUnvisited">000306| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(*[0]*)if&nbsp;bits&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllUnvisited">000307| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;lsb&nbsp;=&nbsp;v&nbsp;land&nbsp;(mask&nbsp;bits)&nbsp;in</div>
- <div class="lineAllUnvisited">000308| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)g&nbsp;(to_int&nbsp;lsb)&nbsp;bits</div>
- <div class="lineNone">000309| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000310| end</div>
- <div class="lineNone">000311| &nbsp;</div>
- <div class="lineNone">000312| module&nbsp;I64&nbsp;=&nbsp;struct</div>
- <div class="lineNone">000313| &nbsp;&nbsp;(*&nbsp;Bitwise&nbsp;operations&nbsp;on&nbsp;int64s.&nbsp;&nbsp;Note&nbsp;we&nbsp;try&nbsp;to&nbsp;keep&nbsp;it&nbsp;as&nbsp;similar</div>
- <div class="lineNone">000314| &nbsp;&nbsp;&nbsp;*&nbsp;as&nbsp;possible&nbsp;to&nbsp;the&nbsp;I/I32&nbsp;modules&nbsp;above,&nbsp;to&nbsp;make&nbsp;it&nbsp;easier&nbsp;to&nbsp;track</div>
- <div class="lineNone">000315| &nbsp;&nbsp;&nbsp;*&nbsp;down&nbsp;bugs.</div>
- <div class="lineNone">000316| &nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineAllVisited">000317| &nbsp;&nbsp;let&nbsp;(&lt;&lt;&lt;)&nbsp;=&nbsp;(*[43]*)Int64.shift_left</div>
- <div class="lineAllVisited">000318| &nbsp;&nbsp;let&nbsp;(&gt;&gt;&gt;)&nbsp;=&nbsp;(*[43]*)Int64.shift_right_logical</div>
- <div class="lineAllVisited">000319| &nbsp;&nbsp;let&nbsp;(land)&nbsp;=&nbsp;(*[43]*)Int64.logand</div>
- <div class="lineAllVisited">000320| &nbsp;&nbsp;let&nbsp;(lor)&nbsp;=&nbsp;(*[43]*)Int64.logor</div>
- <div class="lineAllVisited">000321| &nbsp;&nbsp;let&nbsp;lnot&nbsp;=&nbsp;(*[43]*)Int64.lognot</div>
- <div class="lineAllVisited">000322| &nbsp;&nbsp;let&nbsp;pred&nbsp;=&nbsp;(*[43]*)Int64.pred</div>
- <div class="lineAllVisited">000323| &nbsp;&nbsp;let&nbsp;max_int&nbsp;=&nbsp;(*[43]*)Int64.max_int</div>
- <div class="lineAllVisited">000324| &nbsp;&nbsp;let&nbsp;to_int&nbsp;=&nbsp;(*[43]*)Int64.to_int</div>
- <div class="lineAllVisited">000325| &nbsp;&nbsp;let&nbsp;zero&nbsp;=&nbsp;(*[43]*)Int64.zero</div>
- <div class="lineAllVisited">000326| &nbsp;&nbsp;let&nbsp;one&nbsp;=&nbsp;(*[43]*)Int64.one</div>
- <div class="lineAllVisited">000327| &nbsp;&nbsp;let&nbsp;minus_one&nbsp;=&nbsp;(*[43]*)Int64.minus_one</div>
- <div class="lineAllVisited">000328| &nbsp;&nbsp;let&nbsp;ff&nbsp;=&nbsp;(*[43]*)0xff_L</div>
- <div class="lineNone">000329| &nbsp;</div>
- <div class="lineNone">000330| &nbsp;&nbsp;(*&nbsp;Create&nbsp;a&nbsp;mask&nbsp;so&nbsp;many&nbsp;bits&nbsp;wide.&nbsp;*)</div>
- <div class="lineNone">000331| &nbsp;&nbsp;let&nbsp;mask&nbsp;bits&nbsp;=</div>
- <div class="lineAllVisited">000332| &nbsp;&nbsp;&nbsp;&nbsp;(*[670350]*)if&nbsp;bits&nbsp;&lt;&nbsp;63&nbsp;then</div>
- <div class="lineAllVisited">000333| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[664750]*)pred&nbsp;(one&nbsp;&lt;&lt;&lt;&nbsp;bits)</div>
- <div class="lineAllVisited">000334| &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(*[5600]*)if&nbsp;bits&nbsp;=&nbsp;63&nbsp;then</div>
- <div class="lineAllVisited">000335| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[4950]*)max_int</div>
- <div class="lineAllVisited">000336| &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(*[650]*)if&nbsp;bits&nbsp;=&nbsp;64&nbsp;then</div>
- <div class="lineAllVisited">000337| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[650]*)minus_one</div>
- <div class="lineNone">000338| &nbsp;&nbsp;&nbsp;&nbsp;else</div>
- <div class="lineAllUnvisited">000339| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)invalid_arg&nbsp;&quot;Bitstring.I64.mask&quot;</div>
- <div class="lineNone">000340| &nbsp;</div>
- <div class="lineNone">000341| &nbsp;&nbsp;(*&nbsp;Byte&nbsp;swap&nbsp;an&nbsp;int&nbsp;of&nbsp;a&nbsp;given&nbsp;size.&nbsp;*)</div>
- <div class="lineNone">000342| &nbsp;&nbsp;(*&nbsp;let&nbsp;byteswap&nbsp;v&nbsp;bits&nbsp;=&nbsp;*)</div>
- <div class="lineNone">000343| &nbsp;</div>
- <div class="lineNone">000344| &nbsp;&nbsp;(*&nbsp;Check&nbsp;a&nbsp;value&nbsp;is&nbsp;in&nbsp;range&nbsp;0&nbsp;..&nbsp;2^bits-1.&nbsp;*)</div>
- <div class="lineNone">000345| &nbsp;&nbsp;let&nbsp;range_unsigned&nbsp;v&nbsp;bits&nbsp;=</div>
- <div class="lineAllVisited">000346| &nbsp;&nbsp;&nbsp;&nbsp;(*[352630]*)let&nbsp;mask&nbsp;=&nbsp;lnot&nbsp;(mask&nbsp;bits)&nbsp;in</div>
- <div class="lineAllVisited">000347| &nbsp;&nbsp;&nbsp;&nbsp;(v&nbsp;(*[352630]*)land&nbsp;mask)&nbsp;=&nbsp;zero</div>
- <div class="lineNone">000348| &nbsp;</div>
- <div class="lineNone">000349| &nbsp;&nbsp;(*&nbsp;Call&nbsp;function&nbsp;g&nbsp;on&nbsp;the&nbsp;top&nbsp;bits,&nbsp;then&nbsp;f&nbsp;on&nbsp;each&nbsp;full&nbsp;byte</div>
- <div class="lineNone">000350| &nbsp;&nbsp;&nbsp;*&nbsp;(big&nbsp;endian&nbsp;-&nbsp;so&nbsp;start&nbsp;at&nbsp;top).</div>
- <div class="lineNone">000351| &nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineNone">000352| &nbsp;&nbsp;let&nbsp;rec&nbsp;map_bytes_be&nbsp;g&nbsp;f&nbsp;v&nbsp;bits&nbsp;=</div>
- <div class="lineAllVisited">000353| &nbsp;&nbsp;&nbsp;&nbsp;(*[1462730]*)if&nbsp;bits&nbsp;&gt;=&nbsp;8&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000354| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[1110620]*)map_bytes_be&nbsp;g&nbsp;f&nbsp;(v&nbsp;&gt;&gt;&gt;&nbsp;8)&nbsp;(*[1110620]*)(bits-8);</div>
- <div class="lineAllVisited">000355| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[1110620]*)let&nbsp;lsb&nbsp;=&nbsp;v&nbsp;land&nbsp;ff&nbsp;in</div>
- <div class="lineAllVisited">000356| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[1110620]*)f&nbsp;(to_int&nbsp;lsb)</div>
- <div class="lineAllVisited">000357| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(*[34910]*)if&nbsp;bits&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000358| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[317200]*)let&nbsp;lsb&nbsp;=&nbsp;v&nbsp;land&nbsp;(mask&nbsp;bits)&nbsp;in</div>
- <div class="lineAllVisited">000359| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[317200]*)g&nbsp;(to_int&nbsp;lsb)&nbsp;bits</div>
- <div class="lineNone">000360| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000361| &nbsp;</div>
- <div class="lineNone">000362| &nbsp;&nbsp;(*&nbsp;Call&nbsp;function&nbsp;g&nbsp;on&nbsp;the&nbsp;top&nbsp;bits,&nbsp;then&nbsp;f&nbsp;on&nbsp;each&nbsp;full&nbsp;byte</div>
- <div class="lineNone">000363| &nbsp;&nbsp;&nbsp;*&nbsp;(little&nbsp;endian&nbsp;-&nbsp;so&nbsp;start&nbsp;at&nbsp;root).</div>
- <div class="lineNone">000364| &nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineNone">000365| &nbsp;&nbsp;let&nbsp;rec&nbsp;map_bytes_le&nbsp;g&nbsp;f&nbsp;v&nbsp;bits&nbsp;=</div>
- <div class="lineAllVisited">000366| &nbsp;&nbsp;&nbsp;&nbsp;(*[4160]*)if&nbsp;bits&nbsp;&gt;=&nbsp;8&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000367| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[3640]*)let&nbsp;lsb&nbsp;=&nbsp;v&nbsp;land&nbsp;ff&nbsp;in</div>
- <div class="lineAllVisited">000368| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[3640]*)f&nbsp;(*[3640]*)(to_int&nbsp;lsb);</div>
- <div class="lineAllVisited">000369| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[3640]*)map_bytes_le&nbsp;g&nbsp;f&nbsp;(v&nbsp;&gt;&gt;&gt;&nbsp;8)&nbsp;(bits-8)</div>
- <div class="lineAllVisited">000370| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(*[520]*)if&nbsp;bits&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllUnvisited">000371| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;lsb&nbsp;=&nbsp;v&nbsp;land&nbsp;(mask&nbsp;bits)&nbsp;in</div>
- <div class="lineAllUnvisited">000372| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)g&nbsp;(to_int&nbsp;lsb)&nbsp;bits</div>
- <div class="lineNone">000373| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000374| end</div>
- <div class="lineNone">000375| &nbsp;</div>
- <div class="lineNone">000376| (*----------------------------------------------------------------------*)</div>
- <div class="lineNone">000377| (*&nbsp;Extraction&nbsp;functions.</div>
- <div class="lineNone">000378| &nbsp;*</div>
- <div class="lineNone">000379| &nbsp;*&nbsp;NB:&nbsp;internal&nbsp;functions,&nbsp;called&nbsp;from&nbsp;the&nbsp;generated&nbsp;macros,&nbsp;and</div>
- <div class="lineNone">000380| &nbsp;*&nbsp;the&nbsp;parameters&nbsp;should&nbsp;have&nbsp;been&nbsp;checked&nbsp;for&nbsp;sanity&nbsp;already).</div>
- <div class="lineNone">000381| &nbsp;*)</div>
- <div class="lineNone">000382| &nbsp;</div>
- <div class="lineNone">000383| (*&nbsp;Extract&nbsp;and&nbsp;convert&nbsp;to&nbsp;numeric.&nbsp;&nbsp;A&nbsp;single&nbsp;bit&nbsp;is&nbsp;returned&nbsp;as</div>
- <div class="lineNone">000384| &nbsp;*&nbsp;a&nbsp;boolean.&nbsp;&nbsp;There&nbsp;are&nbsp;no&nbsp;endianness&nbsp;or&nbsp;signedness&nbsp;considerations.</div>
- <div class="lineNone">000385| &nbsp;*)</div>
- <div class="lineNone">000386| let&nbsp;extract_bit&nbsp;data&nbsp;off&nbsp;len&nbsp;_&nbsp;=&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;final&nbsp;param&nbsp;is&nbsp;always&nbsp;1&nbsp;*)</div>
- <div class="lineAllVisited">000387| &nbsp;&nbsp;(*[2515282]*)let&nbsp;byteoff&nbsp;=&nbsp;off&nbsp;lsr&nbsp;3&nbsp;in</div>
- <div class="lineAllVisited">000388| &nbsp;&nbsp;(*[2515282]*)let&nbsp;bitmask&nbsp;=&nbsp;1&nbsp;lsl&nbsp;(7&nbsp;-&nbsp;(off&nbsp;land&nbsp;7))&nbsp;in</div>
- <div class="lineAllVisited">000389| &nbsp;&nbsp;(*[2515282]*)let&nbsp;b&nbsp;=&nbsp;Char.code&nbsp;data.[byteoff]&nbsp;land&nbsp;bitmask&nbsp;&lt;&gt;&nbsp;0&nbsp;in</div>
- <div class="lineAllVisited">000390| &nbsp;&nbsp;(*[2515282]*)b&nbsp;(*,&nbsp;off+1,&nbsp;len-1*)</div>
- <div class="lineNone">000391| &nbsp;</div>
- <div class="lineNone">000392| (*&nbsp;Returns&nbsp;8&nbsp;bit&nbsp;unsigned&nbsp;aligned&nbsp;bytes&nbsp;from&nbsp;the&nbsp;string.</div>
- <div class="lineNone">000393| &nbsp;*&nbsp;If&nbsp;the&nbsp;string&nbsp;ends&nbsp;then&nbsp;this&nbsp;returns&nbsp;0's.</div>
- <div class="lineNone">000394| &nbsp;*)</div>
- <div class="lineNone">000395| let&nbsp;_get_byte&nbsp;data&nbsp;byteoff&nbsp;strlen&nbsp;=</div>
- <div class="lineAllVisited">000396| &nbsp;&nbsp;(*[9840892]*)if&nbsp;strlen&nbsp;&gt;&nbsp;byteoff&nbsp;then&nbsp;(*[9274362]*)Char.code&nbsp;data.[byteoff]&nbsp;else&nbsp;(*[566530]*)0</div>
- <div class="lineNone">000397| let&nbsp;_get_byte32&nbsp;data&nbsp;byteoff&nbsp;strlen&nbsp;=</div>
- <div class="lineMixed">000398| &nbsp;&nbsp;(*[264]*)if&nbsp;strlen&nbsp;&gt;&nbsp;byteoff&nbsp;then&nbsp;(*[264]*)Int32.of_int&nbsp;(Char.code&nbsp;data.[byteoff])&nbsp;else&nbsp;(*[0]*)0l</div>
- <div class="lineNone">000399| let&nbsp;_get_byte64&nbsp;data&nbsp;byteoff&nbsp;strlen&nbsp;=</div>
- <div class="lineAllVisited">000400| &nbsp;&nbsp;(*[1626792]*)if&nbsp;strlen&nbsp;&gt;&nbsp;byteoff&nbsp;then&nbsp;(*[1518549]*)Int64.of_int&nbsp;(Char.code&nbsp;data.[byteoff])&nbsp;else&nbsp;(*[108243]*)0L</div>
- <div class="lineNone">000401| &nbsp;</div>
- <div class="lineNone">000402| (*&nbsp;Extract&nbsp;[2..8]&nbsp;bits.&nbsp;&nbsp;Because&nbsp;the&nbsp;result&nbsp;fits&nbsp;into&nbsp;a&nbsp;single</div>
- <div class="lineNone">000403| &nbsp;*&nbsp;byte&nbsp;we&nbsp;don't&nbsp;have&nbsp;to&nbsp;worry&nbsp;about&nbsp;endianness,&nbsp;only&nbsp;signedness.</div>
- <div class="lineNone">000404| &nbsp;*)</div>
- <div class="lineNone">000405| let&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;flen&nbsp;=</div>
- <div class="lineAllVisited">000406| &nbsp;&nbsp;(*[5040562]*)let&nbsp;byteoff&nbsp;=&nbsp;off&nbsp;lsr&nbsp;3&nbsp;in</div>
- <div class="lineNone">000407| &nbsp;</div>
- <div class="lineNone">000408| &nbsp;&nbsp;(*&nbsp;Optimize&nbsp;the&nbsp;common&nbsp;(byte-aligned)&nbsp;case.&nbsp;*)</div>
- <div class="lineAllVisited">000409| &nbsp;&nbsp;(*[5040562]*)if&nbsp;off&nbsp;land&nbsp;7&nbsp;=&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000410| &nbsp;&nbsp;&nbsp;&nbsp;(*[121776]*)let&nbsp;byte&nbsp;=&nbsp;Char.code&nbsp;data.[byteoff]&nbsp;in</div>
- <div class="lineAllVisited">000411| &nbsp;&nbsp;&nbsp;&nbsp;byte&nbsp;(*[121776]*)lsr&nbsp;(8&nbsp;-&nbsp;flen)&nbsp;(*,&nbsp;off+flen,&nbsp;len-flen*)</div>
- <div class="lineNone">000412| &nbsp;&nbsp;)&nbsp;else&nbsp;(</div>
- <div class="lineNone">000413| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Extract&nbsp;the&nbsp;16&nbsp;bits&nbsp;at&nbsp;byteoff&nbsp;and&nbsp;byteoff+1&nbsp;(note&nbsp;that&nbsp;the</div>
- <div class="lineNone">000414| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;second&nbsp;byte&nbsp;might&nbsp;not&nbsp;exist&nbsp;in&nbsp;the&nbsp;original&nbsp;string).</div>
- <div class="lineNone">000415| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineAllVisited">000416| &nbsp;&nbsp;&nbsp;&nbsp;(*[4918786]*)let&nbsp;strlen&nbsp;=&nbsp;String.length&nbsp;data&nbsp;in</div>
- <div class="lineNone">000417| &nbsp;</div>
- <div class="lineAllVisited">000418| &nbsp;&nbsp;&nbsp;&nbsp;(*[4918786]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000419| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(_get_byte&nbsp;data&nbsp;byteoff&nbsp;strlen&nbsp;lsl&nbsp;8)&nbsp;+</div>
- <div class="lineNone">000420| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_get_byte&nbsp;data&nbsp;(byteoff+1)&nbsp;strlen&nbsp;in</div>
- <div class="lineNone">000421| &nbsp;</div>
- <div class="lineNone">000422| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Mask&nbsp;off&nbsp;the&nbsp;top&nbsp;bits.&nbsp;*)</div>
- <div class="lineAllVisited">000423| &nbsp;&nbsp;&nbsp;&nbsp;(*[4918786]*)let&nbsp;bitmask&nbsp;=&nbsp;(1&nbsp;lsl&nbsp;(16&nbsp;-&nbsp;(off&nbsp;land&nbsp;7)))&nbsp;-&nbsp;1&nbsp;in</div>
- <div class="lineAllVisited">000424| &nbsp;&nbsp;&nbsp;&nbsp;(*[4918786]*)let&nbsp;word&nbsp;=&nbsp;word&nbsp;land&nbsp;bitmask&nbsp;in</div>
- <div class="lineNone">000425| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Shift&nbsp;right&nbsp;to&nbsp;get&nbsp;rid&nbsp;of&nbsp;the&nbsp;bottom&nbsp;bits.&nbsp;*)</div>
- <div class="lineAllVisited">000426| &nbsp;&nbsp;&nbsp;&nbsp;(*[4918786]*)let&nbsp;shift&nbsp;=&nbsp;16&nbsp;-&nbsp;((off&nbsp;land&nbsp;7)&nbsp;+&nbsp;flen)&nbsp;in</div>
- <div class="lineAllVisited">000427| &nbsp;&nbsp;&nbsp;&nbsp;(*[4918786]*)let&nbsp;word&nbsp;=&nbsp;word&nbsp;lsr&nbsp;shift&nbsp;in</div>
- <div class="lineNone">000428| &nbsp;</div>
- <div class="lineAllVisited">000429| &nbsp;&nbsp;&nbsp;&nbsp;(*[4918786]*)word&nbsp;(*,&nbsp;off+flen,&nbsp;len-flen*)</div>
- <div class="lineNone">000430| &nbsp;&nbsp;)</div>
- <div class="lineNone">000431| &nbsp;</div>
- <div class="lineNone">000432| (*&nbsp;Extract&nbsp;[9..31]&nbsp;bits.&nbsp;&nbsp;We&nbsp;have&nbsp;to&nbsp;consider&nbsp;endianness&nbsp;and&nbsp;signedness.&nbsp;*)</div>
- <div class="lineNone">000433| let&nbsp;extract_int_be_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;flen&nbsp;=</div>
- <div class="lineAllVisited">000434| &nbsp;&nbsp;(*[1170]*)let&nbsp;byteoff&nbsp;=&nbsp;off&nbsp;lsr&nbsp;3&nbsp;in</div>
- <div class="lineNone">000435| &nbsp;</div>
- <div class="lineAllVisited">000436| &nbsp;&nbsp;(*[1170]*)let&nbsp;strlen&nbsp;=&nbsp;String.length&nbsp;data&nbsp;in</div>
- <div class="lineNone">000437| &nbsp;</div>
- <div class="lineAllVisited">000438| &nbsp;&nbsp;(*[1170]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000439| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Optimize&nbsp;the&nbsp;common&nbsp;(byte-aligned)&nbsp;case.&nbsp;*)</div>
- <div class="lineNone">000440| &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;off&nbsp;land&nbsp;7&nbsp;=&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000441| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[152]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000442| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(_get_byte&nbsp;data&nbsp;byteoff&nbsp;strlen&nbsp;lsl&nbsp;23)&nbsp;+</div>
- <div class="lineNone">000443| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(_get_byte&nbsp;data&nbsp;(byteoff+1)&nbsp;strlen&nbsp;lsl&nbsp;15)&nbsp;+</div>
- <div class="lineNone">000444| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(_get_byte&nbsp;data&nbsp;(byteoff+2)&nbsp;strlen&nbsp;lsl&nbsp;7)&nbsp;+</div>
- <div class="lineNone">000445| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(_get_byte&nbsp;data&nbsp;(byteoff+3)&nbsp;strlen&nbsp;lsr&nbsp;1)&nbsp;in</div>
- <div class="lineAllVisited">000446| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;word&nbsp;(*[152]*)lsr&nbsp;(31&nbsp;-&nbsp;flen)</div>
- <div class="lineAllVisited">000447| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(*[1018]*)if&nbsp;flen&nbsp;&lt;=&nbsp;24&nbsp;then&nbsp;(</div>
- <div class="lineNone">000448| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Extract&nbsp;the&nbsp;31&nbsp;bits&nbsp;at&nbsp;byteoff&nbsp;..&nbsp;byteoff+3.&nbsp;*)</div>
- <div class="lineAllVisited">000449| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[678]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000450| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(_get_byte&nbsp;data&nbsp;byteoff&nbsp;strlen&nbsp;lsl&nbsp;23)&nbsp;+</div>
- <div class="lineNone">000451| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(_get_byte&nbsp;data&nbsp;(byteoff+1)&nbsp;strlen&nbsp;lsl&nbsp;15)&nbsp;+</div>
- <div class="lineNone">000452| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(_get_byte&nbsp;data&nbsp;(byteoff+2)&nbsp;strlen&nbsp;lsl&nbsp;7)&nbsp;+</div>
- <div class="lineNone">000453| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(_get_byte&nbsp;data&nbsp;(byteoff+3)&nbsp;strlen&nbsp;lsr&nbsp;1)&nbsp;in</div>
- <div class="lineNone">000454| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Mask&nbsp;off&nbsp;the&nbsp;top&nbsp;bits.&nbsp;*)</div>
- <div class="lineAllVisited">000455| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[678]*)let&nbsp;bitmask&nbsp;=&nbsp;(1&nbsp;lsl&nbsp;(31&nbsp;-&nbsp;(off&nbsp;land&nbsp;7)))&nbsp;-&nbsp;1&nbsp;in</div>
- <div class="lineAllVisited">000456| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[678]*)let&nbsp;word&nbsp;=&nbsp;word&nbsp;land&nbsp;bitmask&nbsp;in</div>
- <div class="lineNone">000457| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Shift&nbsp;right&nbsp;to&nbsp;get&nbsp;rid&nbsp;of&nbsp;the&nbsp;bottom&nbsp;bits.&nbsp;*)</div>
- <div class="lineAllVisited">000458| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[678]*)let&nbsp;shift&nbsp;=&nbsp;31&nbsp;-&nbsp;((off&nbsp;land&nbsp;7)&nbsp;+&nbsp;flen)&nbsp;in</div>
- <div class="lineAllVisited">000459| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;word&nbsp;(*[678]*)lsr&nbsp;shift</div>
- <div class="lineNone">000460| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(</div>
- <div class="lineNone">000461| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Extract&nbsp;the&nbsp;next&nbsp;31&nbsp;bits,&nbsp;slow&nbsp;method.&nbsp;*)</div>
- <div class="lineAllVisited">000462| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[340]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000463| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;c0&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000464| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000465| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[340]*)let&nbsp;c1&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000466| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000467| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[340]*)let&nbsp;c2&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000468| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000469| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[340]*)let&nbsp;c3&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;7&nbsp;in</div>
- <div class="lineAllVisited">000470| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(c0&nbsp;(*[340]*)lsl&nbsp;23)&nbsp;+&nbsp;(c1&nbsp;lsl&nbsp;15)&nbsp;+&nbsp;(c2&nbsp;lsl&nbsp;7)&nbsp;+&nbsp;c3&nbsp;in</div>
- <div class="lineAllVisited">000471| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;word&nbsp;(*[340]*)lsr&nbsp;(31&nbsp;-&nbsp;flen)</div>
- <div class="lineNone">000472| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;in</div>
- <div class="lineAllVisited">000473| &nbsp;&nbsp;(*[1170]*)word&nbsp;(*,&nbsp;off+flen,&nbsp;len-flen*)</div>
- <div class="lineNone">000474| &nbsp;</div>
- <div class="lineNone">000475| let&nbsp;extract_int_le_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;flen&nbsp;=</div>
- <div class="lineAllVisited">000476| &nbsp;&nbsp;(*[780]*)let&nbsp;v&nbsp;=&nbsp;extract_int_be_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;flen&nbsp;in</div>
- <div class="lineAllVisited">000477| &nbsp;&nbsp;(*[780]*)let&nbsp;v&nbsp;=&nbsp;I.byteswap&nbsp;v&nbsp;flen&nbsp;in</div>
- <div class="lineAllVisited">000478| &nbsp;&nbsp;(*[780]*)v</div>
- <div class="lineNone">000479| &nbsp;</div>
- <div class="lineNone">000480| let&nbsp;extract_int_ne_unsigned&nbsp;=</div>
- <div class="lineAllVisited">000481| &nbsp;&nbsp;(*[43]*)if&nbsp;nativeendian&nbsp;=&nbsp;BigEndian</div>
- <div class="lineAllUnvisited">000482| &nbsp;&nbsp;then&nbsp;(*[0]*)extract_int_be_unsigned</div>
- <div class="lineAllVisited">000483| &nbsp;&nbsp;else&nbsp;(*[43]*)extract_int_le_unsigned</div>
- <div class="lineNone">000484| &nbsp;</div>
- <div class="lineNone">000485| let&nbsp;extract_int_ee_unsigned&nbsp;=&nbsp;function</div>
- <div class="lineAllUnvisited">000486| &nbsp;&nbsp;|&nbsp;BigEndian&nbsp;-&gt;&nbsp;(*[0]*)extract_int_be_unsigned</div>
- <div class="lineAllUnvisited">000487| &nbsp;&nbsp;|&nbsp;LittleEndian&nbsp;-&gt;&nbsp;(*[0]*)extract_int_le_unsigned</div>
- <div class="lineAllUnvisited">000488| &nbsp;&nbsp;|&nbsp;NativeEndian&nbsp;-&gt;&nbsp;(*[0]*)extract_int_ne_unsigned</div>
- <div class="lineNone">000489| &nbsp;</div>
- <div class="lineNone">000490| let&nbsp;_make_int32_be&nbsp;c0&nbsp;c1&nbsp;c2&nbsp;c3&nbsp;=</div>
- <div class="lineAllVisited">000491| &nbsp;&nbsp;(*[408]*)Int32.logor</div>
- <div class="lineNone">000492| &nbsp;&nbsp;&nbsp;&nbsp;(Int32.logor</div>
- <div class="lineNone">000493| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int32.logor</div>
- <div class="lineNone">000494| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int32.shift_left&nbsp;c0&nbsp;24)</div>
- <div class="lineNone">000495| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int32.shift_left&nbsp;c1&nbsp;16))</div>
- <div class="lineNone">000496| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int32.shift_left&nbsp;c2&nbsp;8))</div>
- <div class="lineNone">000497| &nbsp;&nbsp;&nbsp;&nbsp;c3</div>
- <div class="lineNone">000498| &nbsp;</div>
- <div class="lineNone">000499| let&nbsp;_make_int32_le&nbsp;c0&nbsp;c1&nbsp;c2&nbsp;c3&nbsp;=</div>
- <div class="lineAllUnvisited">000500| &nbsp;&nbsp;(*[0]*)Int32.logor</div>
- <div class="lineNone">000501| &nbsp;&nbsp;&nbsp;&nbsp;(Int32.logor</div>
- <div class="lineNone">000502| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int32.logor</div>
- <div class="lineNone">000503| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int32.shift_left&nbsp;c3&nbsp;24)</div>
- <div class="lineNone">000504| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int32.shift_left&nbsp;c2&nbsp;16))</div>
- <div class="lineNone">000505| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int32.shift_left&nbsp;c1&nbsp;8))</div>
- <div class="lineNone">000506| &nbsp;&nbsp;&nbsp;&nbsp;c0</div>
- <div class="lineNone">000507| &nbsp;</div>
- <div class="lineNone">000508| (*&nbsp;Extract&nbsp;exactly&nbsp;32&nbsp;bits.&nbsp;&nbsp;We&nbsp;have&nbsp;to&nbsp;consider&nbsp;endianness&nbsp;and&nbsp;signedness.&nbsp;*)</div>
- <div class="lineNone">000509| let&nbsp;extract_int32_be_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;flen&nbsp;=</div>
- <div class="lineAllVisited">000510| &nbsp;&nbsp;(*[408]*)let&nbsp;byteoff&nbsp;=&nbsp;off&nbsp;lsr&nbsp;3&nbsp;in</div>
- <div class="lineNone">000511| &nbsp;</div>
- <div class="lineAllVisited">000512| &nbsp;&nbsp;(*[408]*)let&nbsp;strlen&nbsp;=&nbsp;String.length&nbsp;data&nbsp;in</div>
- <div class="lineNone">000513| &nbsp;</div>
- <div class="lineAllVisited">000514| &nbsp;&nbsp;(*[408]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000515| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Optimize&nbsp;the&nbsp;common&nbsp;(byte-aligned)&nbsp;case.&nbsp;*)</div>
- <div class="lineNone">000516| &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;off&nbsp;land&nbsp;7&nbsp;=&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000517| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[66]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000518| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;c0&nbsp;=&nbsp;_get_byte32&nbsp;data&nbsp;byteoff&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000519| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[66]*)let&nbsp;c1&nbsp;=&nbsp;_get_byte32&nbsp;data&nbsp;(byteoff+1)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000520| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[66]*)let&nbsp;c2&nbsp;=&nbsp;_get_byte32&nbsp;data&nbsp;(byteoff+2)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000521| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[66]*)let&nbsp;c3&nbsp;=&nbsp;_get_byte32&nbsp;data&nbsp;(byteoff+3)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000522| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[66]*)_make_int32_be&nbsp;c0&nbsp;c1&nbsp;c2&nbsp;c3&nbsp;in</div>
- <div class="lineAllVisited">000523| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[66]*)Int32.shift_right_logical&nbsp;word&nbsp;(32&nbsp;-&nbsp;flen)</div>
- <div class="lineNone">000524| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(</div>
- <div class="lineNone">000525| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Extract&nbsp;the&nbsp;next&nbsp;32&nbsp;bits,&nbsp;slow&nbsp;method.&nbsp;*)</div>
- <div class="lineAllVisited">000526| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[342]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000527| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;c0&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000528| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000529| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[342]*)let&nbsp;c1&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000530| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000531| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[342]*)let&nbsp;c2&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000532| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000533| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[342]*)let&nbsp;c3&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000534| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[342]*)let&nbsp;c0&nbsp;=&nbsp;Int32.of_int&nbsp;c0&nbsp;in</div>
- <div class="lineAllVisited">000535| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[342]*)let&nbsp;c1&nbsp;=&nbsp;Int32.of_int&nbsp;c1&nbsp;in</div>
- <div class="lineAllVisited">000536| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[342]*)let&nbsp;c2&nbsp;=&nbsp;Int32.of_int&nbsp;c2&nbsp;in</div>
- <div class="lineAllVisited">000537| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[342]*)let&nbsp;c3&nbsp;=&nbsp;Int32.of_int&nbsp;c3&nbsp;in</div>
- <div class="lineAllVisited">000538| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[342]*)_make_int32_be&nbsp;c0&nbsp;c1&nbsp;c2&nbsp;c3&nbsp;in</div>
- <div class="lineAllVisited">000539| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[342]*)Int32.shift_right_logical&nbsp;word&nbsp;(32&nbsp;-&nbsp;flen)</div>
- <div class="lineNone">000540| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;in</div>
- <div class="lineAllVisited">000541| &nbsp;&nbsp;(*[408]*)word&nbsp;(*,&nbsp;off+flen,&nbsp;len-flen*)</div>
- <div class="lineNone">000542| &nbsp;</div>
- <div class="lineNone">000543| let&nbsp;extract_int32_le_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;flen&nbsp;=</div>
- <div class="lineAllVisited">000544| &nbsp;&nbsp;(*[272]*)let&nbsp;v&nbsp;=&nbsp;extract_int32_be_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;flen&nbsp;in</div>
- <div class="lineAllVisited">000545| &nbsp;&nbsp;(*[272]*)let&nbsp;v&nbsp;=&nbsp;I32.byteswap&nbsp;v&nbsp;flen&nbsp;in</div>
- <div class="lineAllVisited">000546| &nbsp;&nbsp;(*[272]*)v</div>
- <div class="lineNone">000547| &nbsp;</div>
- <div class="lineNone">000548| let&nbsp;extract_int32_ne_unsigned&nbsp;=</div>
- <div class="lineAllVisited">000549| &nbsp;&nbsp;(*[43]*)if&nbsp;nativeendian&nbsp;=&nbsp;BigEndian</div>
- <div class="lineAllUnvisited">000550| &nbsp;&nbsp;then&nbsp;(*[0]*)extract_int32_be_unsigned</div>
- <div class="lineAllVisited">000551| &nbsp;&nbsp;else&nbsp;(*[43]*)extract_int32_le_unsigned</div>
- <div class="lineNone">000552| &nbsp;</div>
- <div class="lineNone">000553| let&nbsp;extract_int32_ee_unsigned&nbsp;=&nbsp;function</div>
- <div class="lineAllVisited">000554| &nbsp;&nbsp;|&nbsp;BigEndian&nbsp;-&gt;&nbsp;(*[6]*)extract_int32_be_unsigned</div>
- <div class="lineAllVisited">000555| &nbsp;&nbsp;|&nbsp;LittleEndian&nbsp;-&gt;&nbsp;(*[6]*)extract_int32_le_unsigned</div>
- <div class="lineAllVisited">000556| &nbsp;&nbsp;|&nbsp;NativeEndian&nbsp;-&gt;&nbsp;(*[6]*)extract_int32_ne_unsigned</div>
- <div class="lineNone">000557| &nbsp;</div>
- <div class="lineNone">000558| let&nbsp;_make_int64_be&nbsp;c0&nbsp;c1&nbsp;c2&nbsp;c3&nbsp;c4&nbsp;c5&nbsp;c6&nbsp;c7&nbsp;=</div>
- <div class="lineAllVisited">000559| &nbsp;&nbsp;(*[658243]*)Int64.logor</div>
- <div class="lineNone">000560| &nbsp;&nbsp;&nbsp;&nbsp;(Int64.logor</div>
- <div class="lineNone">000561| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int64.logor</div>
- <div class="lineNone">000562| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int64.logor</div>
- <div class="lineNone">000563| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int64.logor</div>
- <div class="lineNone">000564| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int64.logor</div>
- <div class="lineNone">000565| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int64.logor</div>
- <div class="lineNone">000566| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int64.shift_left&nbsp;c0&nbsp;56)</div>
- <div class="lineNone">000567| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int64.shift_left&nbsp;c1&nbsp;48))</div>
- <div class="lineNone">000568| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int64.shift_left&nbsp;c2&nbsp;40))</div>
- <div class="lineNone">000569| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int64.shift_left&nbsp;c3&nbsp;32))</div>
- <div class="lineNone">000570| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int64.shift_left&nbsp;c4&nbsp;24))</div>
- <div class="lineNone">000571| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int64.shift_left&nbsp;c5&nbsp;16))</div>
- <div class="lineNone">000572| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Int64.shift_left&nbsp;c6&nbsp;8))</div>
- <div class="lineNone">000573| &nbsp;&nbsp;&nbsp;&nbsp;c7</div>
- <div class="lineNone">000574| &nbsp;</div>
- <div class="lineNone">000575| let&nbsp;_make_int64_le&nbsp;c0&nbsp;c1&nbsp;c2&nbsp;c3&nbsp;c4&nbsp;c5&nbsp;c6&nbsp;c7&nbsp;=</div>
- <div class="lineAllVisited">000576| &nbsp;&nbsp;(*[520]*)_make_int64_be&nbsp;c7&nbsp;c6&nbsp;c5&nbsp;c4&nbsp;c3&nbsp;c2&nbsp;c1&nbsp;c0</div>
- <div class="lineNone">000577| &nbsp;</div>
- <div class="lineNone">000578| (*&nbsp;Extract&nbsp;[1..64]&nbsp;bits.&nbsp;&nbsp;We&nbsp;have&nbsp;to&nbsp;consider&nbsp;endianness&nbsp;and&nbsp;signedness.&nbsp;*)</div>
- <div class="lineNone">000579| let&nbsp;extract_int64_be_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;flen&nbsp;=</div>
- <div class="lineAllVisited">000580| &nbsp;&nbsp;(*[657723]*)let&nbsp;byteoff&nbsp;=&nbsp;off&nbsp;lsr&nbsp;3&nbsp;in</div>
- <div class="lineNone">000581| &nbsp;</div>
- <div class="lineAllVisited">000582| &nbsp;&nbsp;(*[657723]*)let&nbsp;strlen&nbsp;=&nbsp;String.length&nbsp;data&nbsp;in</div>
- <div class="lineNone">000583| &nbsp;</div>
- <div class="lineAllVisited">000584| &nbsp;&nbsp;(*[657723]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000585| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Optimize&nbsp;the&nbsp;common&nbsp;(byte-aligned)&nbsp;case.&nbsp;*)</div>
- <div class="lineNone">000586| &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;off&nbsp;land&nbsp;7&nbsp;=&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000587| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[203285]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000588| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;c0&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;byteoff&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000589| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[203285]*)let&nbsp;c1&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+1)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000590| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[203285]*)let&nbsp;c2&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+2)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000591| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[203285]*)let&nbsp;c3&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+3)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000592| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[203285]*)let&nbsp;c4&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+4)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000593| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[203285]*)let&nbsp;c5&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+5)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000594| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[203285]*)let&nbsp;c6&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+6)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000595| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[203285]*)let&nbsp;c7&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+7)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000596| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[203285]*)_make_int64_be&nbsp;c0&nbsp;c1&nbsp;c2&nbsp;c3&nbsp;c4&nbsp;c5&nbsp;c6&nbsp;c7&nbsp;in</div>
- <div class="lineAllVisited">000597| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[203285]*)Int64.shift_right_logical&nbsp;word&nbsp;(64&nbsp;-&nbsp;flen)</div>
- <div class="lineNone">000598| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(</div>
- <div class="lineNone">000599| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Extract&nbsp;the&nbsp;next&nbsp;64&nbsp;bits,&nbsp;slow&nbsp;method.&nbsp;*)</div>
- <div class="lineAllVisited">000600| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000601| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;c0&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000602| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000603| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c1&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000604| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000605| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c2&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000606| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000607| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c3&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000608| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000609| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c4&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000610| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000611| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c5&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000612| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000613| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c6&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000614| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000615| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c7&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000616| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c0&nbsp;=&nbsp;Int64.of_int&nbsp;c0&nbsp;in</div>
- <div class="lineAllVisited">000617| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c1&nbsp;=&nbsp;Int64.of_int&nbsp;c1&nbsp;in</div>
- <div class="lineAllVisited">000618| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c2&nbsp;=&nbsp;Int64.of_int&nbsp;c2&nbsp;in</div>
- <div class="lineAllVisited">000619| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c3&nbsp;=&nbsp;Int64.of_int&nbsp;c3&nbsp;in</div>
- <div class="lineAllVisited">000620| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c4&nbsp;=&nbsp;Int64.of_int&nbsp;c4&nbsp;in</div>
- <div class="lineAllVisited">000621| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c5&nbsp;=&nbsp;Int64.of_int&nbsp;c5&nbsp;in</div>
- <div class="lineAllVisited">000622| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c6&nbsp;=&nbsp;Int64.of_int&nbsp;c6&nbsp;in</div>
- <div class="lineAllVisited">000623| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)let&nbsp;c7&nbsp;=&nbsp;Int64.of_int&nbsp;c7&nbsp;in</div>
- <div class="lineAllVisited">000624| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)_make_int64_be&nbsp;c0&nbsp;c1&nbsp;c2&nbsp;c3&nbsp;c4&nbsp;c5&nbsp;c6&nbsp;c7&nbsp;in</div>
- <div class="lineAllVisited">000625| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[454438]*)Int64.shift_right_logical&nbsp;word&nbsp;(64&nbsp;-&nbsp;flen)</div>
- <div class="lineNone">000626| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;in</div>
- <div class="lineAllVisited">000627| &nbsp;&nbsp;(*[657723]*)word&nbsp;(*,&nbsp;off+flen,&nbsp;len-flen*)</div>
- <div class="lineNone">000628| &nbsp;</div>
- <div class="lineNone">000629| let&nbsp;extract_int64_le_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;flen&nbsp;=</div>
- <div class="lineAllVisited">000630| &nbsp;&nbsp;(*[520]*)let&nbsp;byteoff&nbsp;=&nbsp;off&nbsp;lsr&nbsp;3&nbsp;in</div>
- <div class="lineNone">000631| &nbsp;</div>
- <div class="lineAllVisited">000632| &nbsp;&nbsp;(*[520]*)let&nbsp;strlen&nbsp;=&nbsp;String.length&nbsp;data&nbsp;in</div>
- <div class="lineNone">000633| &nbsp;</div>
- <div class="lineAllVisited">000634| &nbsp;&nbsp;(*[520]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000635| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Optimize&nbsp;the&nbsp;common&nbsp;(byte-aligned)&nbsp;case.&nbsp;*)</div>
- <div class="lineNone">000636| &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;off&nbsp;land&nbsp;7&nbsp;=&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000637| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[64]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000638| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;c0&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;byteoff&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000639| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[64]*)let&nbsp;c1&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+1)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000640| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[64]*)let&nbsp;c2&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+2)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000641| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[64]*)let&nbsp;c3&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+3)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000642| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[64]*)let&nbsp;c4&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+4)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000643| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[64]*)let&nbsp;c5&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+5)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000644| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[64]*)let&nbsp;c6&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+6)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000645| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[64]*)let&nbsp;c7&nbsp;=&nbsp;_get_byte64&nbsp;data&nbsp;(byteoff+7)&nbsp;strlen&nbsp;in</div>
- <div class="lineAllVisited">000646| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[64]*)_make_int64_le&nbsp;c0&nbsp;c1&nbsp;c2&nbsp;c3&nbsp;c4&nbsp;c5&nbsp;c6&nbsp;c7&nbsp;in</div>
- <div class="lineAllVisited">000647| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[64]*)Int64.logand&nbsp;word&nbsp;(I64.mask&nbsp;flen)</div>
- <div class="lineNone">000648| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(</div>
- <div class="lineNone">000649| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Extract&nbsp;the&nbsp;next&nbsp;64&nbsp;bits,&nbsp;slow&nbsp;method.&nbsp;*)</div>
- <div class="lineAllVisited">000650| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;word&nbsp;=</div>
- <div class="lineNone">000651| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;c0&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000652| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000653| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c1&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000654| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000655| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c2&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000656| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000657| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c3&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000658| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000659| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c4&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000660| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000661| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c5&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000662| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000663| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c6&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">000664| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000665| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c7&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">000666| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c0&nbsp;=&nbsp;Int64.of_int&nbsp;c0&nbsp;in</div>
- <div class="lineAllVisited">000667| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c1&nbsp;=&nbsp;Int64.of_int&nbsp;c1&nbsp;in</div>
- <div class="lineAllVisited">000668| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c2&nbsp;=&nbsp;Int64.of_int&nbsp;c2&nbsp;in</div>
- <div class="lineAllVisited">000669| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c3&nbsp;=&nbsp;Int64.of_int&nbsp;c3&nbsp;in</div>
- <div class="lineAllVisited">000670| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c4&nbsp;=&nbsp;Int64.of_int&nbsp;c4&nbsp;in</div>
- <div class="lineAllVisited">000671| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c5&nbsp;=&nbsp;Int64.of_int&nbsp;c5&nbsp;in</div>
- <div class="lineAllVisited">000672| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c6&nbsp;=&nbsp;Int64.of_int&nbsp;c6&nbsp;in</div>
- <div class="lineAllVisited">000673| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)let&nbsp;c7&nbsp;=&nbsp;Int64.of_int&nbsp;c7&nbsp;in</div>
- <div class="lineAllVisited">000674| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)_make_int64_le&nbsp;c0&nbsp;c1&nbsp;c2&nbsp;c3&nbsp;c4&nbsp;c5&nbsp;c6&nbsp;c7&nbsp;in</div>
- <div class="lineAllVisited">000675| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[456]*)Int64.logand&nbsp;word&nbsp;(I64.mask&nbsp;flen)</div>
- <div class="lineNone">000676| &nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;in</div>
- <div class="lineAllVisited">000677| &nbsp;&nbsp;(*[520]*)word&nbsp;(*,&nbsp;off+flen,&nbsp;len-flen*)</div>
- <div class="lineNone">000678| &nbsp;</div>
- <div class="lineNone">000679| let&nbsp;extract_int64_ne_unsigned&nbsp;=</div>
- <div class="lineAllVisited">000680| &nbsp;&nbsp;(*[43]*)if&nbsp;nativeendian&nbsp;=&nbsp;BigEndian</div>
- <div class="lineAllUnvisited">000681| &nbsp;&nbsp;then&nbsp;(*[0]*)extract_int64_be_unsigned</div>
- <div class="lineAllVisited">000682| &nbsp;&nbsp;else&nbsp;(*[43]*)extract_int64_le_unsigned</div>
- <div class="lineNone">000683| &nbsp;</div>
- <div class="lineNone">000684| let&nbsp;extract_int64_ee_unsigned&nbsp;=&nbsp;function</div>
- <div class="lineAllUnvisited">000685| &nbsp;&nbsp;|&nbsp;BigEndian&nbsp;-&gt;&nbsp;(*[0]*)extract_int64_be_unsigned</div>
- <div class="lineAllUnvisited">000686| &nbsp;&nbsp;|&nbsp;LittleEndian&nbsp;-&gt;&nbsp;(*[0]*)extract_int64_le_unsigned</div>
- <div class="lineAllUnvisited">000687| &nbsp;&nbsp;|&nbsp;NativeEndian&nbsp;-&gt;&nbsp;(*[0]*)extract_int64_ne_unsigned</div>
- <div class="lineNone">000688| &nbsp;</div>
- <div class="lineNone">000689| external&nbsp;extract_fastpath_int16_be_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int16_be_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000690| &nbsp;</div>
- <div class="lineNone">000691| external&nbsp;extract_fastpath_int16_le_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int16_le_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000692| &nbsp;</div>
- <div class="lineNone">000693| external&nbsp;extract_fastpath_int16_ne_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int16_ne_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000694| &nbsp;</div>
- <div class="lineNone">000695| external&nbsp;extract_fastpath_int16_be_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int16_be_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000696| &nbsp;</div>
- <div class="lineNone">000697| external&nbsp;extract_fastpath_int16_le_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int16_le_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000698| &nbsp;</div>
- <div class="lineNone">000699| external&nbsp;extract_fastpath_int16_ne_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int16_ne_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000700| &nbsp;</div>
- <div class="lineNone">000701| (*</div>
- <div class="lineNone">000702| external&nbsp;extract_fastpath_int24_be_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int24_be_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000703| &nbsp;</div>
- <div class="lineNone">000704| external&nbsp;extract_fastpath_int24_le_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int24_le_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000705| &nbsp;</div>
- <div class="lineNone">000706| external&nbsp;extract_fastpath_int24_ne_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int24_ne_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000707| &nbsp;</div>
- <div class="lineNone">000708| external&nbsp;extract_fastpath_int24_be_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int24_be_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000709| &nbsp;</div>
- <div class="lineNone">000710| external&nbsp;extract_fastpath_int24_le_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int24_le_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000711| &nbsp;</div>
- <div class="lineNone">000712| external&nbsp;extract_fastpath_int24_ne_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int24_ne_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000713| *)</div>
- <div class="lineNone">000714| &nbsp;</div>
- <div class="lineNone">000715| external&nbsp;extract_fastpath_int32_be_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int32&nbsp;-&gt;&nbsp;int32&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int32_be_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000716| &nbsp;</div>
- <div class="lineNone">000717| external&nbsp;extract_fastpath_int32_le_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int32&nbsp;-&gt;&nbsp;int32&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int32_le_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000718| &nbsp;</div>
- <div class="lineNone">000719| external&nbsp;extract_fastpath_int32_ne_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int32&nbsp;-&gt;&nbsp;int32&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int32_ne_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000720| &nbsp;</div>
- <div class="lineNone">000721| external&nbsp;extract_fastpath_int32_be_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int32&nbsp;-&gt;&nbsp;int32&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int32_be_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000722| &nbsp;</div>
- <div class="lineNone">000723| external&nbsp;extract_fastpath_int32_le_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int32&nbsp;-&gt;&nbsp;int32&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int32_le_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000724| &nbsp;</div>
- <div class="lineNone">000725| external&nbsp;extract_fastpath_int32_ne_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int32&nbsp;-&gt;&nbsp;int32&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int32_ne_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000726| &nbsp;</div>
- <div class="lineNone">000727| (*</div>
- <div class="lineNone">000728| external&nbsp;extract_fastpath_int40_be_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int40_be_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000729| &nbsp;</div>
- <div class="lineNone">000730| external&nbsp;extract_fastpath_int40_le_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int40_le_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000731| &nbsp;</div>
- <div class="lineNone">000732| external&nbsp;extract_fastpath_int40_ne_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int40_ne_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000733| &nbsp;</div>
- <div class="lineNone">000734| external&nbsp;extract_fastpath_int40_be_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int40_be_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000735| &nbsp;</div>
- <div class="lineNone">000736| external&nbsp;extract_fastpath_int40_le_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int40_le_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000737| &nbsp;</div>
- <div class="lineNone">000738| external&nbsp;extract_fastpath_int40_ne_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int40_ne_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000739| &nbsp;</div>
- <div class="lineNone">000740| external&nbsp;extract_fastpath_int48_be_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int48_be_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000741| &nbsp;</div>
- <div class="lineNone">000742| external&nbsp;extract_fastpath_int48_le_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int48_le_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000743| &nbsp;</div>
- <div class="lineNone">000744| external&nbsp;extract_fastpath_int48_ne_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int48_ne_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000745| &nbsp;</div>
- <div class="lineNone">000746| external&nbsp;extract_fastpath_int48_be_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int48_be_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000747| &nbsp;</div>
- <div class="lineNone">000748| external&nbsp;extract_fastpath_int48_le_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int48_le_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000749| &nbsp;</div>
- <div class="lineNone">000750| external&nbsp;extract_fastpath_int48_ne_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int48_ne_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000751| &nbsp;</div>
- <div class="lineNone">000752| external&nbsp;extract_fastpath_int56_be_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int56_be_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000753| &nbsp;</div>
- <div class="lineNone">000754| external&nbsp;extract_fastpath_int56_le_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int56_le_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000755| &nbsp;</div>
- <div class="lineNone">000756| external&nbsp;extract_fastpath_int56_ne_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int56_ne_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000757| &nbsp;</div>
- <div class="lineNone">000758| external&nbsp;extract_fastpath_int56_be_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int56_be_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000759| &nbsp;</div>
- <div class="lineNone">000760| external&nbsp;extract_fastpath_int56_le_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int56_le_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000761| &nbsp;</div>
- <div class="lineNone">000762| external&nbsp;extract_fastpath_int56_ne_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int56_ne_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000763| *)</div>
- <div class="lineNone">000764| &nbsp;</div>
- <div class="lineNone">000765| external&nbsp;extract_fastpath_int64_be_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int64_be_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000766| &nbsp;</div>
- <div class="lineNone">000767| external&nbsp;extract_fastpath_int64_le_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int64_le_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000768| &nbsp;</div>
- <div class="lineNone">000769| external&nbsp;extract_fastpath_int64_ne_unsigned&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int64_ne_unsigned&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000770| &nbsp;</div>
- <div class="lineNone">000771| external&nbsp;extract_fastpath_int64_be_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int64_be_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000772| &nbsp;</div>
- <div class="lineNone">000773| external&nbsp;extract_fastpath_int64_le_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int64_le_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000774| &nbsp;</div>
- <div class="lineNone">000775| external&nbsp;extract_fastpath_int64_ne_signed&nbsp;:&nbsp;string&nbsp;-&gt;&nbsp;int&nbsp;-&gt;&nbsp;int64&nbsp;-&gt;&nbsp;int64&nbsp;=&nbsp;&quot;ocaml_bitstring_extract_fastpath_int64_ne_signed&quot;&nbsp;&quot;noalloc&quot;</div>
- <div class="lineNone">000776| &nbsp;</div>
- <div class="lineNone">000777| (*----------------------------------------------------------------------*)</div>
- <div class="lineNone">000778| (*&nbsp;Constructor&nbsp;functions.&nbsp;*)</div>
- <div class="lineNone">000779| &nbsp;</div>
- <div class="lineNone">000780| module&nbsp;Buffer&nbsp;=&nbsp;struct</div>
- <div class="lineNone">000781| &nbsp;&nbsp;type&nbsp;t&nbsp;=&nbsp;{</div>
- <div class="lineNone">000782| &nbsp;&nbsp;&nbsp;&nbsp;buf&nbsp;:&nbsp;Buffer.t;</div>
- <div class="lineNone">000783| &nbsp;&nbsp;&nbsp;&nbsp;mutable&nbsp;len&nbsp;:&nbsp;int;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Length&nbsp;in&nbsp;bits.&nbsp;*)</div>
- <div class="lineNone">000784| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Last&nbsp;byte&nbsp;in&nbsp;the&nbsp;buffer&nbsp;(if&nbsp;len&nbsp;is&nbsp;not&nbsp;aligned).&nbsp;&nbsp;We&nbsp;store</div>
- <div class="lineNone">000785| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;it&nbsp;outside&nbsp;the&nbsp;buffer&nbsp;because&nbsp;buffers&nbsp;aren't&nbsp;mutable.</div>
- <div class="lineNone">000786| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineNone">000787| &nbsp;&nbsp;&nbsp;&nbsp;mutable&nbsp;last&nbsp;:&nbsp;int;</div>
- <div class="lineNone">000788| &nbsp;&nbsp;}</div>
- <div class="lineNone">000789| &nbsp;</div>
- <div class="lineNone">000790| &nbsp;&nbsp;let&nbsp;create&nbsp;()&nbsp;=</div>
- <div class="lineNone">000791| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;XXX&nbsp;We&nbsp;have&nbsp;almost&nbsp;enough&nbsp;information&nbsp;in&nbsp;the&nbsp;generator&nbsp;to</div>
- <div class="lineNone">000792| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;choose&nbsp;a&nbsp;good&nbsp;initial&nbsp;size.</div>
- <div class="lineNone">000793| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineAllVisited">000794| &nbsp;&nbsp;&nbsp;&nbsp;(*[493152]*){&nbsp;buf&nbsp;=&nbsp;Buffer.create&nbsp;128;&nbsp;len&nbsp;=&nbsp;0;&nbsp;last&nbsp;=&nbsp;0&nbsp;}</div>
- <div class="lineNone">000795| &nbsp;</div>
- <div class="lineNone">000796| &nbsp;&nbsp;let&nbsp;contents&nbsp;{&nbsp;buf&nbsp;=&nbsp;buf;&nbsp;len&nbsp;=&nbsp;len;&nbsp;last&nbsp;=&nbsp;last&nbsp;}&nbsp;=</div>
- <div class="lineAllVisited">000797| &nbsp;&nbsp;&nbsp;&nbsp;(*[493152]*)let&nbsp;data&nbsp;=</div>
- <div class="lineNone">000798| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;len&nbsp;land&nbsp;7&nbsp;=&nbsp;0&nbsp;then</div>
- <div class="lineAllVisited">000799| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[63280]*)Buffer.contents&nbsp;buf</div>
- <div class="lineNone">000800| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else</div>
- <div class="lineAllVisited">000801| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[429872]*)Buffer.contents&nbsp;buf&nbsp;^&nbsp;(String.make&nbsp;1&nbsp;(Char.chr&nbsp;last))&nbsp;in</div>
- <div class="lineAllVisited">000802| &nbsp;&nbsp;&nbsp;&nbsp;(*[493152]*)data,&nbsp;0,&nbsp;len</div>
- <div class="lineNone">000803| &nbsp;</div>
- <div class="lineNone">000804| &nbsp;&nbsp;(*&nbsp;Add&nbsp;exactly&nbsp;8&nbsp;bits.&nbsp;*)</div>
- <div class="lineNone">000805| &nbsp;&nbsp;let&nbsp;add_byte&nbsp;({&nbsp;buf&nbsp;=&nbsp;buf;&nbsp;len&nbsp;=&nbsp;len;&nbsp;last&nbsp;=&nbsp;last&nbsp;}&nbsp;as&nbsp;t)&nbsp;byte&nbsp;=</div>
- <div class="lineMixed">000806| &nbsp;&nbsp;&nbsp;&nbsp;(*[8266092]*)if&nbsp;(*[8266092]*)byte&nbsp;&lt;&nbsp;0&nbsp;||&nbsp;(*[8266092]*)byte&nbsp;&gt;&nbsp;255&nbsp;then&nbsp;(*[0]*)invalid_arg&nbsp;&quot;Bitstring.Buffer.add_byte&quot;;</div>
- <div class="lineAllVisited">000807| &nbsp;&nbsp;&nbsp;&nbsp;(*[8266092]*)let&nbsp;shift&nbsp;=&nbsp;len&nbsp;land&nbsp;7&nbsp;in</div>
- <div class="lineAllVisited">000808| &nbsp;&nbsp;&nbsp;&nbsp;(*[8266092]*)if&nbsp;shift&nbsp;=&nbsp;0&nbsp;then</div>
- <div class="lineNone">000809| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Target&nbsp;buffer&nbsp;is&nbsp;byte-aligned.&nbsp;*)</div>
- <div class="lineAllVisited">000810| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[521241]*)Buffer.add_char&nbsp;buf&nbsp;(Char.chr&nbsp;byte)</div>
- <div class="lineNone">000811| &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(</div>
- <div class="lineNone">000812| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Target&nbsp;buffer&nbsp;is&nbsp;unaligned.&nbsp;&nbsp;'last'&nbsp;is&nbsp;meaningful.&nbsp;*)</div>
- <div class="lineAllVisited">000813| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[7744851]*)let&nbsp;first&nbsp;=&nbsp;byte&nbsp;lsr&nbsp;shift&nbsp;in</div>
- <div class="lineAllVisited">000814| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[7744851]*)let&nbsp;second&nbsp;=&nbsp;(byte&nbsp;lsl&nbsp;(8&nbsp;-&nbsp;shift))&nbsp;land&nbsp;0xff&nbsp;in</div>
- <div class="lineAllVisited">000815| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[7744851]*)Buffer.add_char&nbsp;buf&nbsp;(*[7744851]*)(Char.chr&nbsp;(last&nbsp;lor&nbsp;first));</div>
- <div class="lineAllVisited">000816| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[7744851]*)t.last&nbsp;&lt;-&nbsp;second</div>
- <div class="lineNone">000817| &nbsp;&nbsp;&nbsp;&nbsp;);</div>
- <div class="lineAllVisited">000818| &nbsp;&nbsp;&nbsp;&nbsp;(*[8266092]*)t.len&nbsp;&lt;-&nbsp;t.len&nbsp;+&nbsp;8</div>
- <div class="lineNone">000819| &nbsp;</div>
- <div class="lineNone">000820| &nbsp;&nbsp;(*&nbsp;Add&nbsp;exactly&nbsp;1&nbsp;bit.&nbsp;*)</div>
- <div class="lineNone">000821| &nbsp;&nbsp;let&nbsp;add_bit&nbsp;({&nbsp;buf&nbsp;=&nbsp;buf;&nbsp;len&nbsp;=&nbsp;len;&nbsp;last&nbsp;=&nbsp;last&nbsp;}&nbsp;as&nbsp;t)&nbsp;bit&nbsp;=</div>
- <div class="lineAllVisited">000822| &nbsp;&nbsp;&nbsp;&nbsp;(*[4426193]*)let&nbsp;shift&nbsp;=&nbsp;7&nbsp;-&nbsp;(len&nbsp;land&nbsp;7)&nbsp;in</div>
- <div class="lineAllVisited">000823| &nbsp;&nbsp;&nbsp;&nbsp;(*[4426193]*)if&nbsp;shift&nbsp;&gt;&nbsp;0&nbsp;then</div>
- <div class="lineNone">000824| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Somewhere&nbsp;in&nbsp;the&nbsp;middle&nbsp;of&nbsp;'last'.&nbsp;*)</div>
- <div class="lineAllVisited">000825| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[3893270]*)t.last&nbsp;&lt;-&nbsp;last&nbsp;lor&nbsp;((if&nbsp;bit&nbsp;then&nbsp;(*[3004643]*)1&nbsp;else&nbsp;(*[888627]*)0)&nbsp;lsl&nbsp;shift)</div>
- <div class="lineNone">000826| &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(</div>
- <div class="lineNone">000827| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Just&nbsp;a&nbsp;single&nbsp;spare&nbsp;bit&nbsp;in&nbsp;'last'.&nbsp;*)</div>
- <div class="lineAllVisited">000828| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[532923]*)let&nbsp;last&nbsp;=&nbsp;last&nbsp;lor&nbsp;if&nbsp;bit&nbsp;then&nbsp;(*[407944]*)1&nbsp;else&nbsp;(*[124979]*)0&nbsp;in</div>
- <div class="lineAllVisited">000829| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[532923]*)Buffer.add_char&nbsp;buf&nbsp;(*[532923]*)(Char.chr&nbsp;last);</div>
- <div class="lineAllVisited">000830| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[532923]*)t.last&nbsp;&lt;-&nbsp;0</div>
- <div class="lineNone">000831| &nbsp;&nbsp;&nbsp;&nbsp;);</div>
- <div class="lineAllVisited">000832| &nbsp;&nbsp;&nbsp;&nbsp;(*[4426193]*)t.len&nbsp;&lt;-&nbsp;len&nbsp;+&nbsp;1</div>
- <div class="lineNone">000833| &nbsp;</div>
- <div class="lineNone">000834| &nbsp;&nbsp;(*&nbsp;Add&nbsp;a&nbsp;small&nbsp;number&nbsp;of&nbsp;bits&nbsp;(definitely&nbsp;&lt;&nbsp;8).&nbsp;&nbsp;This&nbsp;uses&nbsp;a&nbsp;loop</div>
- <div class="lineNone">000835| &nbsp;&nbsp;&nbsp;*&nbsp;to&nbsp;call&nbsp;add_bit&nbsp;so&nbsp;it's&nbsp;slow.</div>
- <div class="lineNone">000836| &nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineNone">000837| &nbsp;&nbsp;let&nbsp;_add_bits&nbsp;t&nbsp;c&nbsp;slen&nbsp;=</div>
- <div class="lineMixed">000838| &nbsp;&nbsp;&nbsp;&nbsp;(*[318370]*)if&nbsp;(*[318370]*)slen&nbsp;&lt;&nbsp;1&nbsp;||&nbsp;(*[318370]*)slen&nbsp;&gt;=&nbsp;8&nbsp;then&nbsp;(*[0]*)invalid_arg&nbsp;&quot;Bitstring.Buffer._add_bits&quot;;</div>
- <div class="lineAllVisited">000839| &nbsp;&nbsp;&nbsp;&nbsp;(*[318370]*)for&nbsp;i&nbsp;=&nbsp;slen-1&nbsp;downto&nbsp;0&nbsp;do</div>
- <div class="lineAllVisited">000840| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[1273808]*)let&nbsp;bit&nbsp;=&nbsp;c&nbsp;land&nbsp;(1&nbsp;lsl&nbsp;i)&nbsp;&lt;&gt;&nbsp;0&nbsp;in</div>
- <div class="lineAllVisited">000841| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[1273808]*)add_bit&nbsp;t&nbsp;bit</div>
- <div class="lineNone">000842| &nbsp;&nbsp;&nbsp;&nbsp;done</div>
- <div class="lineNone">000843| &nbsp;</div>
- <div class="lineNone">000844| &nbsp;&nbsp;let&nbsp;add_bits&nbsp;({&nbsp;buf&nbsp;=&nbsp;buf;&nbsp;len&nbsp;=&nbsp;len&nbsp;}&nbsp;as&nbsp;t)&nbsp;str&nbsp;slen&nbsp;=</div>
- <div class="lineAllVisited">000845| &nbsp;&nbsp;&nbsp;&nbsp;(*[26867]*)if&nbsp;slen&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000846| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[1389114]*)if&nbsp;len&nbsp;land&nbsp;7&nbsp;=&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000847| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[575784]*)if&nbsp;slen&nbsp;land&nbsp;7&nbsp;=&nbsp;0&nbsp;then</div>
- <div class="lineNone">000848| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Common&nbsp;case&nbsp;-&nbsp;everything&nbsp;is&nbsp;byte-aligned.&nbsp;*)</div>
- <div class="lineAllVisited">000849| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[64322]*)Buffer.add_substring&nbsp;buf&nbsp;str&nbsp;0&nbsp;(slen&nbsp;lsr&nbsp;3)</div>
- <div class="lineNone">000850| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(</div>
- <div class="lineNone">000851| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Target&nbsp;buffer&nbsp;is&nbsp;aligned.&nbsp;&nbsp;Copy&nbsp;whole&nbsp;bytes&nbsp;then&nbsp;leave&nbsp;the</div>
- <div class="lineNone">000852| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;remaining&nbsp;bits&nbsp;in&nbsp;last.</div>
- <div class="lineNone">000853| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineAllVisited">000854| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[511462]*)let&nbsp;slenbytes&nbsp;=&nbsp;slen&nbsp;lsr&nbsp;3&nbsp;in</div>
- <div class="lineAllVisited">000855| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[345655]*)if&nbsp;slenbytes&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(*[165807]*)Buffer.add_substring&nbsp;buf&nbsp;str&nbsp;0&nbsp;slenbytes;</div>
- <div class="lineAllVisited">000856| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[511462]*)let&nbsp;last&nbsp;=&nbsp;Char.code&nbsp;str.[slenbytes]&nbsp;in&nbsp;(*&nbsp;last&nbsp;char&nbsp;*)</div>
- <div class="lineAllVisited">000857| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[511462]*)let&nbsp;mask&nbsp;=&nbsp;0xff&nbsp;lsl&nbsp;(8&nbsp;-&nbsp;(slen&nbsp;land&nbsp;7))&nbsp;in</div>
- <div class="lineAllVisited">000858| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[511462]*)t.last&nbsp;&lt;-&nbsp;last&nbsp;land&nbsp;mask</div>
- <div class="lineNone">000859| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);</div>
- <div class="lineAllVisited">000860| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[575784]*)t.len&nbsp;&lt;-&nbsp;len&nbsp;+&nbsp;slen</div>
- <div class="lineNone">000861| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(</div>
- <div class="lineNone">000862| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Target&nbsp;buffer&nbsp;is&nbsp;unaligned.&nbsp;&nbsp;Copy&nbsp;whole&nbsp;bytes&nbsp;using</div>
- <div class="lineNone">000863| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;add_byte&nbsp;which&nbsp;knows&nbsp;how&nbsp;to&nbsp;deal&nbsp;with&nbsp;an&nbsp;unaligned</div>
- <div class="lineNone">000864| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;target&nbsp;buffer,&nbsp;then&nbsp;call&nbsp;add_bit&nbsp;for&nbsp;the&nbsp;remaining&nbsp;&lt;&nbsp;8&nbsp;bits.</div>
- <div class="lineNone">000865| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</div>
- <div class="lineNone">000866| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;XXX&nbsp;This&nbsp;is&nbsp;going&nbsp;to&nbsp;be&nbsp;dog-slow.</div>
- <div class="lineNone">000867| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineAllVisited">000868| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[813330]*)let&nbsp;slenbytes&nbsp;=&nbsp;slen&nbsp;lsr&nbsp;3&nbsp;in</div>
- <div class="lineAllVisited">000869| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[813330]*)for&nbsp;i&nbsp;=&nbsp;0&nbsp;to&nbsp;slenbytes-1&nbsp;do</div>
- <div class="lineAllVisited">000870| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[5943116]*)let&nbsp;byte&nbsp;=&nbsp;Char.code&nbsp;str.[i]&nbsp;in</div>
- <div class="lineAllVisited">000871| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[5943116]*)add_byte&nbsp;t&nbsp;byte</div>
- <div class="lineNone">000872| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;done;</div>
- <div class="lineAllVisited">000873| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[813330]*)let&nbsp;bitsleft&nbsp;=&nbsp;slen&nbsp;-&nbsp;(slenbytes&nbsp;lsl&nbsp;3)&nbsp;in</div>
- <div class="lineAllVisited">000874| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[144583]*)if&nbsp;bitsleft&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">000875| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[668747]*)let&nbsp;c&nbsp;=&nbsp;Char.code&nbsp;str.[slenbytes]&nbsp;in</div>
- <div class="lineAllVisited">000876| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[668747]*)for&nbsp;i&nbsp;=&nbsp;0&nbsp;to&nbsp;bitsleft&nbsp;-&nbsp;1&nbsp;do</div>
- <div class="lineAllVisited">000877| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2652755]*)let&nbsp;bit&nbsp;=&nbsp;c&nbsp;land&nbsp;(0x80&nbsp;lsr&nbsp;i)&nbsp;&lt;&gt;&nbsp;0&nbsp;in</div>
- <div class="lineAllVisited">000878| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[2652755]*)add_bit&nbsp;t&nbsp;bit</div>
- <div class="lineNone">000879| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;done</div>
- <div class="lineNone">000880| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000881| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);</div>
- <div class="lineNone">000882| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000883| end</div>
- <div class="lineNone">000884| &nbsp;</div>
- <div class="lineNone">000885| (*&nbsp;Construct&nbsp;a&nbsp;single&nbsp;bit.&nbsp;*)</div>
- <div class="lineNone">000886| let&nbsp;construct_bit&nbsp;buf&nbsp;b&nbsp;_&nbsp;_&nbsp;=</div>
- <div class="lineAllVisited">000887| &nbsp;&nbsp;(*[130]*)Buffer.add_bit&nbsp;buf&nbsp;b</div>
- <div class="lineNone">000888| &nbsp;</div>
- <div class="lineNone">000889| (*&nbsp;Construct&nbsp;a&nbsp;field,&nbsp;flen&nbsp;=&nbsp;[2..8].&nbsp;*)</div>
- <div class="lineNone">000890| let&nbsp;construct_char_unsigned&nbsp;buf&nbsp;v&nbsp;flen&nbsp;exn&nbsp;=</div>
- <div class="lineAllVisited">000891| &nbsp;&nbsp;(*[1204740]*)let&nbsp;max_val&nbsp;=&nbsp;1&nbsp;lsl&nbsp;flen&nbsp;in</div>
- <div class="lineMixed">000892| &nbsp;&nbsp;(*[1204740]*)if&nbsp;(*[1204740]*)v&nbsp;&lt;&nbsp;0&nbsp;||&nbsp;(*[1204740]*)v&nbsp;&gt;=&nbsp;max_val&nbsp;then&nbsp;(*[0]*)raise&nbsp;exn;</div>
- <div class="lineAllVisited">000893| &nbsp;&nbsp;(*[1204740]*)if&nbsp;flen&nbsp;=&nbsp;8&nbsp;then</div>
- <div class="lineAllVisited">000894| &nbsp;&nbsp;&nbsp;&nbsp;(*[1203960]*)Buffer.add_byte&nbsp;buf&nbsp;v</div>
- <div class="lineNone">000895| &nbsp;&nbsp;else</div>
- <div class="lineAllVisited">000896| &nbsp;&nbsp;&nbsp;&nbsp;(*[780]*)Buffer._add_bits&nbsp;buf&nbsp;v&nbsp;flen</div>
- <div class="lineNone">000897| &nbsp;</div>
- <div class="lineNone">000898| (*&nbsp;Construct&nbsp;a&nbsp;field&nbsp;of&nbsp;up&nbsp;to&nbsp;31&nbsp;bits.&nbsp;*)</div>
- <div class="lineNone">000899| let&nbsp;construct_int_be_unsigned&nbsp;buf&nbsp;v&nbsp;flen&nbsp;exn&nbsp;=</div>
- <div class="lineNone">000900| &nbsp;&nbsp;(*&nbsp;Check&nbsp;value&nbsp;is&nbsp;within&nbsp;range.&nbsp;*)</div>
- <div class="lineMixed">000901| &nbsp;&nbsp;(*[392]*)if&nbsp;not&nbsp;(I.range_unsigned&nbsp;v&nbsp;flen)&nbsp;then&nbsp;(*[0]*)raise&nbsp;exn;</div>
- <div class="lineNone">000902| &nbsp;&nbsp;(*&nbsp;Add&nbsp;the&nbsp;bytes.&nbsp;*)</div>
- <div class="lineAllVisited">000903| &nbsp;&nbsp;(*[392]*)I.map_bytes_be&nbsp;(Buffer._add_bits&nbsp;buf)&nbsp;(Buffer.add_byte&nbsp;buf)&nbsp;v&nbsp;flen</div>
- <div class="lineNone">000904| &nbsp;</div>
- <div class="lineNone">000905| (*&nbsp;Construct&nbsp;a&nbsp;field&nbsp;of&nbsp;up&nbsp;to&nbsp;31&nbsp;bits.&nbsp;*)</div>
- <div class="lineNone">000906| let&nbsp;construct_int_le_unsigned&nbsp;buf&nbsp;v&nbsp;flen&nbsp;exn&nbsp;=</div>
- <div class="lineNone">000907| &nbsp;&nbsp;(*&nbsp;Check&nbsp;value&nbsp;is&nbsp;within&nbsp;range.&nbsp;*)</div>
- <div class="lineMixed">000908| &nbsp;&nbsp;(*[780]*)if&nbsp;not&nbsp;(I.range_unsigned&nbsp;v&nbsp;flen)&nbsp;then&nbsp;(*[0]*)raise&nbsp;exn;</div>
- <div class="lineNone">000909| &nbsp;&nbsp;(*&nbsp;Add&nbsp;the&nbsp;bytes.&nbsp;*)</div>
- <div class="lineAllVisited">000910| &nbsp;&nbsp;(*[780]*)I.map_bytes_le&nbsp;(Buffer._add_bits&nbsp;buf)&nbsp;(Buffer.add_byte&nbsp;buf)&nbsp;v&nbsp;flen</div>
- <div class="lineNone">000911| &nbsp;</div>
- <div class="lineNone">000912| let&nbsp;construct_int_ne_unsigned&nbsp;=</div>
- <div class="lineAllVisited">000913| &nbsp;&nbsp;(*[43]*)if&nbsp;nativeendian&nbsp;=&nbsp;BigEndian</div>
- <div class="lineAllUnvisited">000914| &nbsp;&nbsp;then&nbsp;(*[0]*)construct_int_be_unsigned</div>
- <div class="lineAllVisited">000915| &nbsp;&nbsp;else&nbsp;(*[43]*)construct_int_le_unsigned</div>
- <div class="lineNone">000916| &nbsp;</div>
- <div class="lineNone">000917| let&nbsp;construct_int_ee_unsigned&nbsp;=&nbsp;function</div>
- <div class="lineAllUnvisited">000918| &nbsp;&nbsp;|&nbsp;BigEndian&nbsp;-&gt;&nbsp;(*[0]*)construct_int_be_unsigned</div>
- <div class="lineAllUnvisited">000919| &nbsp;&nbsp;|&nbsp;LittleEndian&nbsp;-&gt;&nbsp;(*[0]*)construct_int_le_unsigned</div>
- <div class="lineAllUnvisited">000920| &nbsp;&nbsp;|&nbsp;NativeEndian&nbsp;-&gt;&nbsp;(*[0]*)construct_int_ne_unsigned</div>
- <div class="lineNone">000921| &nbsp;</div>
- <div class="lineNone">000922| (*&nbsp;Construct&nbsp;a&nbsp;field&nbsp;of&nbsp;exactly&nbsp;32&nbsp;bits.&nbsp;*)</div>
- <div class="lineNone">000923| let&nbsp;construct_int32_be_unsigned&nbsp;buf&nbsp;v&nbsp;flen&nbsp;_&nbsp;=</div>
- <div class="lineAllVisited">000924| &nbsp;&nbsp;(*[136]*)Buffer.add_byte&nbsp;buf</div>
- <div class="lineNone">000925| &nbsp;&nbsp;&nbsp;&nbsp;(Int32.to_int&nbsp;(Int32.shift_right_logical&nbsp;v&nbsp;24));</div>
- <div class="lineAllVisited">000926| &nbsp;&nbsp;(*[136]*)Buffer.add_byte&nbsp;buf</div>
- <div class="lineNone">000927| &nbsp;&nbsp;&nbsp;&nbsp;(Int32.to_int&nbsp;((Int32.logand&nbsp;(Int32.shift_right_logical&nbsp;v&nbsp;16)&nbsp;0xff_l)));</div>
- <div class="lineAllVisited">000928| &nbsp;&nbsp;(*[136]*)Buffer.add_byte&nbsp;buf</div>
- <div class="lineAllVisited">000929| &nbsp;&nbsp;&nbsp;&nbsp;(*[136]*)(Int32.to_int&nbsp;((Int32.logand&nbsp;(Int32.shift_right_logical&nbsp;v&nbsp;8)&nbsp;0xff_l)));</div>
- <div class="lineAllVisited">000930| &nbsp;&nbsp;(*[136]*)Buffer.add_byte&nbsp;buf</div>
- <div class="lineNone">000931| &nbsp;&nbsp;&nbsp;&nbsp;(Int32.to_int&nbsp;(Int32.logand&nbsp;v&nbsp;0xff_l))</div>
- <div class="lineNone">000932| &nbsp;</div>
- <div class="lineNone">000933| let&nbsp;construct_int32_le_unsigned&nbsp;buf&nbsp;v&nbsp;flen&nbsp;_&nbsp;=</div>
- <div class="lineAllVisited">000934| &nbsp;&nbsp;(*[272]*)Buffer.add_byte&nbsp;buf</div>
- <div class="lineNone">000935| &nbsp;&nbsp;&nbsp;&nbsp;(Int32.to_int&nbsp;(Int32.logand&nbsp;v&nbsp;0xff_l));</div>
- <div class="lineAllVisited">000936| &nbsp;&nbsp;(*[272]*)Buffer.add_byte&nbsp;buf</div>
- <div class="lineNone">000937| &nbsp;&nbsp;&nbsp;&nbsp;(Int32.to_int&nbsp;((Int32.logand&nbsp;(Int32.shift_right_logical&nbsp;v&nbsp;8)&nbsp;0xff_l)));</div>
- <div class="lineAllVisited">000938| &nbsp;&nbsp;(*[272]*)Buffer.add_byte&nbsp;buf</div>
- <div class="lineAllVisited">000939| &nbsp;&nbsp;&nbsp;&nbsp;(*[272]*)(Int32.to_int&nbsp;((Int32.logand&nbsp;(Int32.shift_right_logical&nbsp;v&nbsp;16)&nbsp;0xff_l)));</div>
- <div class="lineAllVisited">000940| &nbsp;&nbsp;(*[272]*)Buffer.add_byte&nbsp;buf</div>
- <div class="lineNone">000941| &nbsp;&nbsp;&nbsp;&nbsp;(Int32.to_int&nbsp;(Int32.shift_right_logical&nbsp;v&nbsp;24))</div>
- <div class="lineNone">000942| &nbsp;</div>
- <div class="lineNone">000943| let&nbsp;construct_int32_ne_unsigned&nbsp;=</div>
- <div class="lineAllVisited">000944| &nbsp;&nbsp;(*[43]*)if&nbsp;nativeendian&nbsp;=&nbsp;BigEndian</div>
- <div class="lineAllUnvisited">000945| &nbsp;&nbsp;then&nbsp;(*[0]*)construct_int32_be_unsigned</div>
- <div class="lineAllVisited">000946| &nbsp;&nbsp;else&nbsp;(*[43]*)construct_int32_le_unsigned</div>
- <div class="lineNone">000947| &nbsp;</div>
- <div class="lineNone">000948| let&nbsp;construct_int32_ee_unsigned&nbsp;=&nbsp;function</div>
- <div class="lineAllVisited">000949| &nbsp;&nbsp;|&nbsp;BigEndian&nbsp;-&gt;&nbsp;(*[6]*)construct_int32_be_unsigned</div>
- <div class="lineAllVisited">000950| &nbsp;&nbsp;|&nbsp;LittleEndian&nbsp;-&gt;&nbsp;(*[6]*)construct_int32_le_unsigned</div>
- <div class="lineAllVisited">000951| &nbsp;&nbsp;|&nbsp;NativeEndian&nbsp;-&gt;&nbsp;(*[6]*)construct_int32_ne_unsigned</div>
- <div class="lineNone">000952| &nbsp;</div>
- <div class="lineNone">000953| (*&nbsp;Construct&nbsp;a&nbsp;field&nbsp;of&nbsp;up&nbsp;to&nbsp;64&nbsp;bits.&nbsp;*)</div>
- <div class="lineNone">000954| let&nbsp;construct_int64_be_unsigned&nbsp;buf&nbsp;v&nbsp;flen&nbsp;exn&nbsp;=</div>
- <div class="lineNone">000955| &nbsp;&nbsp;(*&nbsp;Check&nbsp;value&nbsp;is&nbsp;within&nbsp;range.&nbsp;*)</div>
- <div class="lineMixed">000956| &nbsp;&nbsp;(*[352110]*)if&nbsp;not&nbsp;(I64.range_unsigned&nbsp;v&nbsp;flen)&nbsp;then&nbsp;(*[0]*)raise&nbsp;exn;</div>
- <div class="lineNone">000957| &nbsp;&nbsp;(*&nbsp;Add&nbsp;the&nbsp;bytes.&nbsp;*)</div>
- <div class="lineAllVisited">000958| &nbsp;&nbsp;(*[352110]*)I64.map_bytes_be&nbsp;(Buffer._add_bits&nbsp;buf)&nbsp;(Buffer.add_byte&nbsp;buf)&nbsp;v&nbsp;flen</div>
- <div class="lineNone">000959| &nbsp;</div>
- <div class="lineNone">000960| (*&nbsp;Construct&nbsp;a&nbsp;field&nbsp;of&nbsp;up&nbsp;to&nbsp;64&nbsp;bits.&nbsp;*)</div>
- <div class="lineNone">000961| let&nbsp;construct_int64_le_unsigned&nbsp;buf&nbsp;v&nbsp;flen&nbsp;exn&nbsp;=</div>
- <div class="lineNone">000962| &nbsp;&nbsp;(*&nbsp;Check&nbsp;value&nbsp;is&nbsp;within&nbsp;range.&nbsp;*)</div>
- <div class="lineMixed">000963| &nbsp;&nbsp;(*[520]*)if&nbsp;not&nbsp;(I64.range_unsigned&nbsp;v&nbsp;flen)&nbsp;then&nbsp;(*[0]*)raise&nbsp;exn;</div>
- <div class="lineNone">000964| &nbsp;&nbsp;(*&nbsp;Add&nbsp;the&nbsp;bytes.&nbsp;*)</div>
- <div class="lineAllVisited">000965| &nbsp;&nbsp;(*[520]*)I64.map_bytes_le&nbsp;(Buffer._add_bits&nbsp;buf)&nbsp;(Buffer.add_byte&nbsp;buf)&nbsp;v&nbsp;flen</div>
- <div class="lineNone">000966| &nbsp;</div>
- <div class="lineNone">000967| let&nbsp;construct_int64_ne_unsigned&nbsp;=</div>
- <div class="lineAllVisited">000968| &nbsp;&nbsp;(*[43]*)if&nbsp;nativeendian&nbsp;=&nbsp;BigEndian</div>
- <div class="lineAllUnvisited">000969| &nbsp;&nbsp;then&nbsp;(*[0]*)construct_int64_be_unsigned</div>
- <div class="lineAllVisited">000970| &nbsp;&nbsp;else&nbsp;(*[43]*)construct_int64_le_unsigned</div>
- <div class="lineNone">000971| &nbsp;</div>
- <div class="lineNone">000972| let&nbsp;construct_int64_ee_unsigned&nbsp;=&nbsp;function</div>
- <div class="lineAllUnvisited">000973| &nbsp;&nbsp;|&nbsp;BigEndian&nbsp;-&gt;&nbsp;(*[0]*)construct_int64_be_unsigned</div>
- <div class="lineAllUnvisited">000974| &nbsp;&nbsp;|&nbsp;LittleEndian&nbsp;-&gt;&nbsp;(*[0]*)construct_int64_le_unsigned</div>
- <div class="lineAllUnvisited">000975| &nbsp;&nbsp;|&nbsp;NativeEndian&nbsp;-&gt;&nbsp;(*[0]*)construct_int64_ne_unsigned</div>
- <div class="lineNone">000976| &nbsp;</div>
- <div class="lineNone">000977| (*&nbsp;Construct&nbsp;from&nbsp;a&nbsp;string&nbsp;of&nbsp;bytes,&nbsp;exact&nbsp;multiple&nbsp;of&nbsp;8&nbsp;bits</div>
- <div class="lineNone">000978| &nbsp;*&nbsp;in&nbsp;length&nbsp;of&nbsp;course.</div>
- <div class="lineNone">000979| &nbsp;*)</div>
- <div class="lineNone">000980| let&nbsp;construct_string&nbsp;buf&nbsp;str&nbsp;=</div>
- <div class="lineAllVisited">000981| &nbsp;&nbsp;(*[89505]*)let&nbsp;len&nbsp;=&nbsp;String.length&nbsp;str&nbsp;in</div>
- <div class="lineAllVisited">000982| &nbsp;&nbsp;(*[89505]*)Buffer.add_bits&nbsp;buf&nbsp;str&nbsp;(len&nbsp;lsl&nbsp;3)</div>
- <div class="lineNone">000983| &nbsp;</div>
- <div class="lineNone">000984| (*&nbsp;Construct&nbsp;from&nbsp;a&nbsp;bitstring.&nbsp;*)</div>
- <div class="lineNone">000985| let&nbsp;construct_bitstring&nbsp;buf&nbsp;(data,&nbsp;off,&nbsp;len)&nbsp;=</div>
- <div class="lineNone">000986| &nbsp;&nbsp;(*&nbsp;Add&nbsp;individual&nbsp;bits&nbsp;until&nbsp;we&nbsp;get&nbsp;to&nbsp;the&nbsp;next&nbsp;byte&nbsp;boundary&nbsp;of</div>
- <div class="lineNone">000987| &nbsp;&nbsp;&nbsp;*&nbsp;the&nbsp;underlying&nbsp;string.</div>
- <div class="lineNone">000988| &nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineAllVisited">000989| &nbsp;&nbsp;(*[1317896]*)let&nbsp;blen&nbsp;=&nbsp;7&nbsp;-&nbsp;((off&nbsp;+&nbsp;7)&nbsp;land&nbsp;7)&nbsp;in</div>
- <div class="lineAllVisited">000990| &nbsp;&nbsp;(*[1317896]*)let&nbsp;blen&nbsp;=&nbsp;min&nbsp;blen&nbsp;len&nbsp;in</div>
- <div class="lineAllVisited">000991| &nbsp;&nbsp;(*[1317896]*)let&nbsp;rec&nbsp;loop&nbsp;off&nbsp;len&nbsp;blen&nbsp;=</div>
- <div class="lineAllVisited">000992| &nbsp;&nbsp;&nbsp;&nbsp;(*[1317896]*)if&nbsp;blen&nbsp;=&nbsp;0&nbsp;then&nbsp;((*[1317896]*)off,&nbsp;len)</div>
- <div class="lineNone">000993| &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(</div>
- <div class="lineAllUnvisited">000994| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;b&nbsp;=&nbsp;extract_bit&nbsp;data&nbsp;off&nbsp;len&nbsp;1</div>
- <div class="lineNone">000995| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;1&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;+&nbsp;1&nbsp;in</div>
- <div class="lineAllUnvisited">000996| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)Buffer.add_bit&nbsp;buf&nbsp;(*[0]*)b;</div>
- <div class="lineAllUnvisited">000997| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)loop&nbsp;off&nbsp;len&nbsp;(blen-1)</div>
- <div class="lineNone">000998| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">000999| &nbsp;&nbsp;in</div>
- <div class="lineAllVisited">001000| &nbsp;&nbsp;(*[1317896]*)let&nbsp;off,&nbsp;len&nbsp;=&nbsp;loop&nbsp;off&nbsp;len&nbsp;blen&nbsp;in</div>
- <div class="lineAllVisited">001001| &nbsp;&nbsp;(*[1317896]*)assert&nbsp;((*[1317896]*)len&nbsp;=&nbsp;0&nbsp;||&nbsp;(off&nbsp;(*[1291094]*)land&nbsp;7)&nbsp;=&nbsp;0);</div>
- <div class="lineNone">001002| &nbsp;</div>
- <div class="lineNone">001003| &nbsp;&nbsp;(*&nbsp;Add&nbsp;the&nbsp;remaining&nbsp;'len'&nbsp;bits.&nbsp;*)</div>
- <div class="lineAllVisited">001004| &nbsp;&nbsp;(*[1317896]*)let&nbsp;data&nbsp;=</div>
- <div class="lineNone">001005| &nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;off&nbsp;=&nbsp;off&nbsp;lsr&nbsp;3&nbsp;in</div>
- <div class="lineNone">001006| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;XXX&nbsp;dangerous&nbsp;allocation&nbsp;*)</div>
- <div class="lineAllVisited">001007| &nbsp;&nbsp;&nbsp;&nbsp;(*[1317896]*)if&nbsp;off&nbsp;=&nbsp;0&nbsp;then&nbsp;(*[1317896]*)data</div>
- <div class="lineAllUnvisited">001008| &nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(*[0]*)String.sub&nbsp;data&nbsp;off&nbsp;(String.length&nbsp;data&nbsp;-&nbsp;off)&nbsp;in</div>
- <div class="lineNone">001009| &nbsp;</div>
- <div class="lineAllVisited">001010| &nbsp;&nbsp;(*[1317896]*)Buffer.add_bits&nbsp;buf&nbsp;data&nbsp;len</div>
- <div class="lineNone">001011| &nbsp;</div>
- <div class="lineNone">001012| (*&nbsp;Concatenate&nbsp;bitstrings.&nbsp;*)</div>
- <div class="lineNone">001013| let&nbsp;concat&nbsp;bs&nbsp;=</div>
- <div class="lineAllVisited">001014| &nbsp;&nbsp;(*[40461]*)let&nbsp;buf&nbsp;=&nbsp;Buffer.create&nbsp;()&nbsp;in</div>
- <div class="lineAllVisited">001015| &nbsp;&nbsp;(*[40461]*)List.iter&nbsp;(construct_bitstring&nbsp;buf)&nbsp;(*[40461]*)bs;</div>
- <div class="lineAllVisited">001016| &nbsp;&nbsp;(*[40461]*)Buffer.contents&nbsp;buf</div>
- <div class="lineNone">001017| &nbsp;</div>
- <div class="lineNone">001018| (*----------------------------------------------------------------------*)</div>
- <div class="lineNone">001019| (*&nbsp;Extract&nbsp;a&nbsp;string&nbsp;from&nbsp;a&nbsp;bitstring.&nbsp;*)</div>
- <div class="lineNone">001020| let&nbsp;string_of_bitstring&nbsp;(data,&nbsp;off,&nbsp;len)&nbsp;=</div>
- <div class="lineAllVisited">001021| &nbsp;&nbsp;(*[73011]*)if&nbsp;off&nbsp;(*[73011]*)land&nbsp;7&nbsp;=&nbsp;0&nbsp;&amp;&amp;&nbsp;len&nbsp;(*[16597]*)land&nbsp;7&nbsp;=&nbsp;0&nbsp;then</div>
- <div class="lineNone">001022| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Easy&nbsp;case:&nbsp;everything&nbsp;is&nbsp;byte-aligned.&nbsp;*)</div>
- <div class="lineAllVisited">001023| &nbsp;&nbsp;&nbsp;&nbsp;(*[9037]*)String.sub&nbsp;data&nbsp;(off&nbsp;lsr&nbsp;3)&nbsp;(len&nbsp;lsr&nbsp;3)</div>
- <div class="lineNone">001024| &nbsp;&nbsp;else&nbsp;(</div>
- <div class="lineNone">001025| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Bit-twiddling&nbsp;case.&nbsp;*)</div>
- <div class="lineAllVisited">001026| &nbsp;&nbsp;&nbsp;&nbsp;(*[63974]*)let&nbsp;strlen&nbsp;=&nbsp;(len&nbsp;+&nbsp;7)&nbsp;lsr&nbsp;3&nbsp;in</div>
- <div class="lineAllVisited">001027| &nbsp;&nbsp;&nbsp;&nbsp;(*[63974]*)let&nbsp;str&nbsp;=&nbsp;String.make&nbsp;strlen&nbsp;'\000'&nbsp;in</div>
- <div class="lineAllVisited">001028| &nbsp;&nbsp;&nbsp;&nbsp;(*[63974]*)let&nbsp;rec&nbsp;loop&nbsp;data&nbsp;off&nbsp;len&nbsp;i&nbsp;=</div>
- <div class="lineAllVisited">001029| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[326148]*)if&nbsp;len&nbsp;&gt;=&nbsp;8&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">001030| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[262174]*)let&nbsp;c&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;8</div>
- <div class="lineNone">001031| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;off&nbsp;=&nbsp;off&nbsp;+&nbsp;8&nbsp;and&nbsp;len&nbsp;=&nbsp;len&nbsp;-&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">001032| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[262174]*)str.[i]&nbsp;(*[262174]*)&lt;-&nbsp;Char.chr&nbsp;c;</div>
- <div class="lineAllVisited">001033| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[262174]*)loop&nbsp;data&nbsp;off&nbsp;len&nbsp;(i+1)</div>
- <div class="lineAllVisited">001034| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;else&nbsp;(*[52324]*)if&nbsp;len&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">001035| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[11650]*)let&nbsp;c&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;off&nbsp;len&nbsp;len&nbsp;in</div>
- <div class="lineAllVisited">001036| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[11650]*)str.[i]&nbsp;&lt;-&nbsp;Char.chr&nbsp;(c&nbsp;lsl&nbsp;(8-len))</div>
- <div class="lineNone">001037| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">001038| &nbsp;&nbsp;&nbsp;&nbsp;in</div>
- <div class="lineAllVisited">001039| &nbsp;&nbsp;&nbsp;&nbsp;(*[63974]*)loop&nbsp;data&nbsp;off&nbsp;len&nbsp;(*[63974]*)0;</div>
- <div class="lineAllVisited">001040| &nbsp;&nbsp;&nbsp;&nbsp;(*[63974]*)str</div>
- <div class="lineNone">001041| &nbsp;&nbsp;)</div>
- <div class="lineNone">001042| &nbsp;</div>
- <div class="lineNone">001043| (*&nbsp;To&nbsp;channel.&nbsp;*)</div>
- <div class="lineNone">001044| &nbsp;</div>
- <div class="lineNone">001045| let&nbsp;bitstring_to_chan&nbsp;((data,&nbsp;off,&nbsp;len)&nbsp;as&nbsp;bits)&nbsp;chan&nbsp;=</div>
- <div class="lineNone">001046| &nbsp;&nbsp;(*&nbsp;Fail&nbsp;if&nbsp;the&nbsp;bitstring&nbsp;length&nbsp;isn't&nbsp;a&nbsp;multiple&nbsp;of&nbsp;8.&nbsp;*)</div>
- <div class="lineMixed">001047| &nbsp;&nbsp;(*[1]*)if&nbsp;len&nbsp;land&nbsp;7&nbsp;&lt;&gt;&nbsp;0&nbsp;then&nbsp;(*[0]*)invalid_arg&nbsp;&quot;bitstring_to_chan&quot;;</div>
- <div class="lineNone">001048| &nbsp;</div>
- <div class="lineAllVisited">001049| &nbsp;&nbsp;(*[1]*)if&nbsp;off&nbsp;land&nbsp;7&nbsp;=&nbsp;0&nbsp;then</div>
- <div class="lineNone">001050| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Easy&nbsp;case:&nbsp;string&nbsp;is&nbsp;byte-aligned.&nbsp;*)</div>
- <div class="lineAllVisited">001051| &nbsp;&nbsp;&nbsp;&nbsp;(*[1]*)output&nbsp;chan&nbsp;data&nbsp;(off&nbsp;lsr&nbsp;3)&nbsp;(len&nbsp;lsr&nbsp;3)</div>
- <div class="lineNone">001052| &nbsp;&nbsp;else&nbsp;(</div>
- <div class="lineNone">001053| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Bit-twiddling&nbsp;case:&nbsp;reuse&nbsp;string_of_bitstring&nbsp;*)</div>
- <div class="lineAllUnvisited">001054| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;str&nbsp;=&nbsp;string_of_bitstring&nbsp;bits&nbsp;in</div>
- <div class="lineAllUnvisited">001055| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)output_string&nbsp;chan&nbsp;str</div>
- <div class="lineNone">001056| &nbsp;&nbsp;)</div>
- <div class="lineNone">001057| &nbsp;</div>
- <div class="lineNone">001058| let&nbsp;bitstring_to_file&nbsp;bits&nbsp;filename&nbsp;=</div>
- <div class="lineAllUnvisited">001059| &nbsp;&nbsp;(*[0]*)let&nbsp;chan&nbsp;=&nbsp;open_out_bin&nbsp;filename&nbsp;in</div>
- <div class="lineAllUnvisited">001060| &nbsp;&nbsp;(*[0]*)try</div>
- <div class="lineAllUnvisited">001061| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)bitstring_to_chan&nbsp;bits&nbsp;chan;</div>
- <div class="lineAllUnvisited">001062| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)close_out&nbsp;chan</div>
- <div class="lineNone">001063| &nbsp;&nbsp;with&nbsp;exn&nbsp;-&gt;</div>
- <div class="lineAllUnvisited">001064| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)close_out&nbsp;(*[0]*)chan;</div>
- <div class="lineAllUnvisited">001065| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)raise&nbsp;exn</div>
- <div class="lineNone">001066| &nbsp;</div>
- <div class="lineNone">001067| (*----------------------------------------------------------------------*)</div>
- <div class="lineNone">001068| (*&nbsp;Comparison.&nbsp;*)</div>
- <div class="lineNone">001069| let&nbsp;compare&nbsp;((data1,&nbsp;off1,&nbsp;len1)&nbsp;as&nbsp;bs1)&nbsp;((data2,&nbsp;off2,&nbsp;len2)&nbsp;as&nbsp;bs2)&nbsp;=</div>
- <div class="lineNone">001070| &nbsp;&nbsp;(*&nbsp;In&nbsp;the&nbsp;fully-aligned&nbsp;case,&nbsp;this&nbsp;is&nbsp;reduced&nbsp;to&nbsp;string&nbsp;comparison&nbsp;...&nbsp;*)</div>
- <div class="lineAllVisited">001071| &nbsp;&nbsp;(*[4624]*)if&nbsp;off1&nbsp;(*[4624]*)land&nbsp;7&nbsp;=&nbsp;0&nbsp;&amp;&amp;&nbsp;len1&nbsp;(*[4624]*)land&nbsp;7&nbsp;(*[4624]*)=&nbsp;0&nbsp;&amp;&amp;&nbsp;off2&nbsp;(*[680]*)land&nbsp;7&nbsp;(*[680]*)=&nbsp;0&nbsp;&amp;&amp;&nbsp;len2&nbsp;(*[535]*)land&nbsp;7&nbsp;=&nbsp;0</div>
- <div class="lineNone">001072| &nbsp;&nbsp;then&nbsp;(</div>
- <div class="lineNone">001073| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;...&nbsp;but&nbsp;we&nbsp;have&nbsp;to&nbsp;do&nbsp;that&nbsp;by&nbsp;hand&nbsp;because&nbsp;the&nbsp;bits&nbsp;may</div>
- <div class="lineNone">001074| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;not&nbsp;extend&nbsp;to&nbsp;the&nbsp;full&nbsp;length&nbsp;of&nbsp;the&nbsp;underlying&nbsp;string.</div>
- <div class="lineNone">001075| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*)</div>
- <div class="lineAllVisited">001076| &nbsp;&nbsp;&nbsp;&nbsp;(*[100]*)let&nbsp;off1&nbsp;=&nbsp;off1&nbsp;lsr&nbsp;3&nbsp;and&nbsp;off2&nbsp;=&nbsp;off2&nbsp;lsr&nbsp;3</div>
- <div class="lineNone">001077| &nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;len1&nbsp;=&nbsp;len1&nbsp;lsr&nbsp;3&nbsp;and&nbsp;len2&nbsp;=&nbsp;len2&nbsp;lsr&nbsp;3&nbsp;in</div>
- <div class="lineAllVisited">001078| &nbsp;&nbsp;&nbsp;&nbsp;(*[100]*)let&nbsp;rec&nbsp;loop&nbsp;i&nbsp;=</div>
- <div class="lineAllVisited">001079| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[240]*)if&nbsp;(*[240]*)i&nbsp;&lt;&nbsp;len1&nbsp;&amp;&amp;&nbsp;(*[170]*)i&nbsp;&lt;&nbsp;len2&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">001080| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[140]*)let&nbsp;c1&nbsp;=&nbsp;String.unsafe_get&nbsp;data1&nbsp;(off1&nbsp;+&nbsp;i)</div>
- <div class="lineNone">001081| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;c2&nbsp;=&nbsp;String.unsafe_get&nbsp;data2&nbsp;(off2&nbsp;+&nbsp;i)&nbsp;in</div>
- <div class="lineAllVisited">001082| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[140]*)let&nbsp;r&nbsp;=&nbsp;compare&nbsp;c1&nbsp;c2&nbsp;in</div>
- <div class="lineMixed">001083| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[140]*)if&nbsp;r&nbsp;&lt;&gt;&nbsp;0&nbsp;then&nbsp;(*[0]*)r</div>
- <div class="lineAllVisited">001084| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(*[140]*)loop&nbsp;(i+1)</div>
- <div class="lineNone">001085| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineAllVisited">001086| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;(*[100]*)len1&nbsp;-&nbsp;len2</div>
- <div class="lineNone">001087| &nbsp;&nbsp;&nbsp;&nbsp;in</div>
- <div class="lineAllVisited">001088| &nbsp;&nbsp;&nbsp;&nbsp;(*[100]*)loop&nbsp;0</div>
- <div class="lineNone">001089| &nbsp;&nbsp;)</div>
- <div class="lineNone">001090| &nbsp;&nbsp;else&nbsp;(</div>
- <div class="lineNone">001091| &nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;Slow/unaligned.&nbsp;*)</div>
- <div class="lineAllVisited">001092| &nbsp;&nbsp;&nbsp;&nbsp;(*[4524]*)let&nbsp;str1&nbsp;=&nbsp;string_of_bitstring&nbsp;bs1</div>
- <div class="lineNone">001093| &nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;str2&nbsp;=&nbsp;string_of_bitstring&nbsp;bs2&nbsp;in</div>
- <div class="lineAllVisited">001094| &nbsp;&nbsp;&nbsp;&nbsp;(*[4524]*)let&nbsp;r&nbsp;=&nbsp;String.compare&nbsp;str1&nbsp;str2&nbsp;in</div>
- <div class="lineAllVisited">001095| &nbsp;&nbsp;&nbsp;&nbsp;(*[4524]*)if&nbsp;r&nbsp;&lt;&gt;&nbsp;0&nbsp;then&nbsp;(*[3058]*)r&nbsp;else&nbsp;(*[1466]*)len1&nbsp;-&nbsp;len2</div>
- <div class="lineNone">001096| &nbsp;&nbsp;)</div>
- <div class="lineNone">001097| &nbsp;</div>
- <div class="lineNone">001098| let&nbsp;equals&nbsp;((_,&nbsp;_,&nbsp;len1)&nbsp;as&nbsp;bs1)&nbsp;((_,&nbsp;_,&nbsp;len2)&nbsp;as&nbsp;bs2)&nbsp;=</div>
- <div class="lineMixed">001099| &nbsp;&nbsp;(*[7]*)if&nbsp;len1&nbsp;&lt;&gt;&nbsp;len2&nbsp;then&nbsp;(*[0]*)false</div>
- <div class="lineAllVisited">001100| &nbsp;&nbsp;else&nbsp;(*[7]*)if&nbsp;bs1&nbsp;=&nbsp;bs2&nbsp;then&nbsp;(*[7]*)true</div>
- <div class="lineAllUnvisited">001101| &nbsp;&nbsp;else&nbsp;(*[0]*)0&nbsp;=&nbsp;compare&nbsp;bs1&nbsp;bs2</div>
- <div class="lineNone">001102| &nbsp;</div>
- <div class="lineNone">001103| (*----------------------------------------------------------------------*)</div>
- <div class="lineNone">001104| (*&nbsp;Bit&nbsp;get/set&nbsp;functions.&nbsp;*)</div>
- <div class="lineNone">001105| &nbsp;</div>
- <div class="lineAllUnvisited">001106| let&nbsp;index_out_of_bounds&nbsp;()&nbsp;=&nbsp;(*[0]*)invalid_arg&nbsp;&quot;index&nbsp;out&nbsp;of&nbsp;bounds&quot;</div>
- <div class="lineNone">001107| &nbsp;</div>
- <div class="lineNone">001108| let&nbsp;put&nbsp;(data,&nbsp;off,&nbsp;len)&nbsp;n&nbsp;v&nbsp;=</div>
- <div class="lineAllUnvisited">001109| &nbsp;&nbsp;(*[0]*)if&nbsp;(*[0]*)n&nbsp;&lt;&nbsp;0&nbsp;||&nbsp;(*[0]*)off+n&nbsp;&gt;=&nbsp;len&nbsp;then&nbsp;(*[0]*)index_out_of_bounds&nbsp;()</div>
- <div class="lineNone">001110| &nbsp;&nbsp;else&nbsp;(</div>
- <div class="lineAllUnvisited">001111| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;i&nbsp;=&nbsp;off+n&nbsp;in</div>
- <div class="lineAllUnvisited">001112| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;si&nbsp;=&nbsp;i&nbsp;lsr&nbsp;3&nbsp;and&nbsp;mask&nbsp;=&nbsp;0x80&nbsp;lsr&nbsp;(i&nbsp;land&nbsp;7)&nbsp;in</div>
- <div class="lineAllUnvisited">001113| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;c&nbsp;=&nbsp;Char.code&nbsp;data.[si]&nbsp;in</div>
- <div class="lineAllUnvisited">001114| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)let&nbsp;c&nbsp;=&nbsp;if&nbsp;v&nbsp;&lt;&gt;&nbsp;0&nbsp;then&nbsp;c&nbsp;(*[0]*)lor&nbsp;mask&nbsp;else&nbsp;c&nbsp;(*[0]*)land&nbsp;(lnot&nbsp;mask)&nbsp;in</div>
- <div class="lineAllUnvisited">001115| &nbsp;&nbsp;&nbsp;&nbsp;(*[0]*)data.[si]&nbsp;&lt;-&nbsp;Char.unsafe_chr&nbsp;c</div>
- <div class="lineNone">001116| &nbsp;&nbsp;)</div>
- <div class="lineNone">001117| &nbsp;</div>
- <div class="lineAllUnvisited">001118| let&nbsp;set&nbsp;bits&nbsp;n&nbsp;=&nbsp;(*[0]*)put&nbsp;bits&nbsp;n&nbsp;1</div>
- <div class="lineNone">001119| &nbsp;</div>
- <div class="lineAllUnvisited">001120| let&nbsp;clear&nbsp;bits&nbsp;n&nbsp;=&nbsp;(*[0]*)put&nbsp;bits&nbsp;n&nbsp;0</div>
- <div class="lineNone">001121| &nbsp;</div>
- <div class="lineNone">001122| let&nbsp;get&nbsp;(data,&nbsp;off,&nbsp;len)&nbsp;n&nbsp;=</div>
- <div class="lineMixed">001123| &nbsp;&nbsp;(*[1945548]*)if&nbsp;(*[1945548]*)n&nbsp;&lt;&nbsp;0&nbsp;||&nbsp;(*[1945548]*)off+n&nbsp;&gt;=&nbsp;len&nbsp;then&nbsp;(*[0]*)index_out_of_bounds&nbsp;()</div>
- <div class="lineNone">001124| &nbsp;&nbsp;else&nbsp;(</div>
- <div class="lineAllVisited">001125| &nbsp;&nbsp;&nbsp;&nbsp;(*[1945548]*)let&nbsp;i&nbsp;=&nbsp;off+n&nbsp;in</div>
- <div class="lineAllVisited">001126| &nbsp;&nbsp;&nbsp;&nbsp;(*[1945548]*)let&nbsp;si&nbsp;=&nbsp;i&nbsp;lsr&nbsp;3&nbsp;and&nbsp;mask&nbsp;=&nbsp;0x80&nbsp;lsr&nbsp;(i&nbsp;land&nbsp;7)&nbsp;in</div>
- <div class="lineAllVisited">001127| &nbsp;&nbsp;&nbsp;&nbsp;(*[1945548]*)let&nbsp;c&nbsp;=&nbsp;Char.code&nbsp;data.[si]&nbsp;in</div>
- <div class="lineAllVisited">001128| &nbsp;&nbsp;&nbsp;&nbsp;c&nbsp;(*[1945548]*)land&nbsp;mask</div>
- <div class="lineNone">001129| &nbsp;&nbsp;)</div>
- <div class="lineNone">001130| &nbsp;</div>
- <div class="lineAllVisited">001131| let&nbsp;is_set&nbsp;bits&nbsp;n&nbsp;=&nbsp;(*[1297032]*)get&nbsp;bits&nbsp;n&nbsp;&lt;&gt;&nbsp;0</div>
- <div class="lineNone">001132| &nbsp;</div>
- <div class="lineAllVisited">001133| let&nbsp;is_clear&nbsp;bits&nbsp;n&nbsp;=&nbsp;(*[648516]*)get&nbsp;bits&nbsp;n&nbsp;=&nbsp;0</div>
- <div class="lineNone">001134| &nbsp;</div>
- <div class="lineNone">001135| (*----------------------------------------------------------------------*)</div>
- <div class="lineNone">001136| (*&nbsp;Display&nbsp;functions.&nbsp;*)</div>
- <div class="lineNone">001137| &nbsp;</div>
- <div class="lineNone">001138| let&nbsp;isprint&nbsp;c&nbsp;=</div>
- <div class="lineAllVisited">001139| &nbsp;&nbsp;(*[356]*)let&nbsp;c&nbsp;=&nbsp;Char.code&nbsp;c&nbsp;in</div>
- <div class="lineAllVisited">001140| &nbsp;&nbsp;(*[356]*)c&nbsp;(*[356]*)&gt;=&nbsp;32&nbsp;&amp;&amp;&nbsp;(*[311]*)c&nbsp;&lt;&nbsp;127</div>
- <div class="lineNone">001141| &nbsp;</div>
- <div class="lineNone">001142| let&nbsp;hexdump_bitstring&nbsp;chan&nbsp;(data,&nbsp;off,&nbsp;len)&nbsp;=</div>
- <div class="lineAllVisited">001143| &nbsp;&nbsp;(*[34]*)let&nbsp;count&nbsp;=&nbsp;ref&nbsp;0&nbsp;in</div>
- <div class="lineAllVisited">001144| &nbsp;&nbsp;(*[34]*)let&nbsp;off&nbsp;=&nbsp;ref&nbsp;off&nbsp;in</div>
- <div class="lineAllVisited">001145| &nbsp;&nbsp;(*[34]*)let&nbsp;len&nbsp;=&nbsp;ref&nbsp;len&nbsp;in</div>
- <div class="lineAllVisited">001146| &nbsp;&nbsp;(*[34]*)let&nbsp;linelen&nbsp;=&nbsp;ref&nbsp;0&nbsp;in</div>
- <div class="lineAllVisited">001147| &nbsp;&nbsp;(*[34]*)let&nbsp;linechars&nbsp;=&nbsp;String.make&nbsp;16&nbsp;'&nbsp;'&nbsp;in</div>
- <div class="lineNone">001148| &nbsp;</div>
- <div class="lineAllVisited">001149| &nbsp;&nbsp;(*[34]*)fprintf&nbsp;chan&nbsp;&quot;00000000&nbsp;&nbsp;&quot;;</div>
- <div class="lineNone">001150| &nbsp;</div>
- <div class="lineAllVisited">001151| &nbsp;&nbsp;(*[34]*)while&nbsp;!len&nbsp;&gt;&nbsp;0&nbsp;do</div>
- <div class="lineAllVisited">001152| &nbsp;&nbsp;&nbsp;&nbsp;(*[356]*)let&nbsp;bits&nbsp;=&nbsp;min&nbsp;!len&nbsp;8&nbsp;in</div>
- <div class="lineAllVisited">001153| &nbsp;&nbsp;&nbsp;&nbsp;(*[356]*)let&nbsp;byte&nbsp;=&nbsp;extract_char_unsigned&nbsp;data&nbsp;!off&nbsp;!len&nbsp;bits&nbsp;in</div>
- <div class="lineAllVisited">001154| &nbsp;&nbsp;&nbsp;&nbsp;(*[356]*)off&nbsp;:=&nbsp;!off&nbsp;+&nbsp;bits;&nbsp;(*[356]*)len&nbsp;(*[356]*):=&nbsp;!len&nbsp;-&nbsp;bits;</div>
- <div class="lineNone">001155| &nbsp;</div>
- <div class="lineAllVisited">001156| &nbsp;&nbsp;&nbsp;&nbsp;(*[356]*)let&nbsp;byte&nbsp;=&nbsp;byte&nbsp;lsl&nbsp;(8-bits)&nbsp;in</div>
- <div class="lineAllVisited">001157| &nbsp;&nbsp;&nbsp;&nbsp;(*[356]*)fprintf&nbsp;chan&nbsp;&quot;%02x&nbsp;&quot;&nbsp;byte;</div>
- <div class="lineNone">001158| &nbsp;</div>
- <div class="lineAllVisited">001159| &nbsp;&nbsp;&nbsp;&nbsp;(*[356]*)incr&nbsp;count;</div>
- <div class="lineAllVisited">001160| &nbsp;&nbsp;&nbsp;&nbsp;(*[356]*)linechars.[!linelen]&nbsp;&lt;-</div>
- <div class="lineNone">001161| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;c&nbsp;=&nbsp;Char.chr&nbsp;byte&nbsp;in</div>
- <div class="lineAllVisited">001162| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[356]*)if&nbsp;isprint&nbsp;c&nbsp;then&nbsp;(*[110]*)c&nbsp;else&nbsp;(*[246]*)'.');</div>
- <div class="lineAllVisited">001163| &nbsp;&nbsp;&nbsp;&nbsp;(*[356]*)incr&nbsp;linelen;</div>
- <div class="lineAllVisited">001164| &nbsp;&nbsp;&nbsp;&nbsp;(*[335]*)if&nbsp;!linelen&nbsp;=&nbsp;8&nbsp;then&nbsp;(*[21]*)fprintf&nbsp;chan&nbsp;&quot;&nbsp;&quot;;</div>
- <div class="lineAllVisited">001165| &nbsp;&nbsp;&nbsp;&nbsp;(*[343]*)if&nbsp;!linelen&nbsp;=&nbsp;16&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">001166| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[13]*)fprintf&nbsp;chan&nbsp;&quot;&nbsp;|%s|\n%08x&nbsp;&nbsp;&quot;&nbsp;linechars&nbsp;!count;</div>
- <div class="lineAllVisited">001167| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[13]*)linelen&nbsp;(*[13]*):=&nbsp;0;</div>
- <div class="lineAllVisited">001168| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*[13]*)for&nbsp;i&nbsp;=&nbsp;0&nbsp;to&nbsp;15&nbsp;do&nbsp;(*[208]*)linechars.[i]&nbsp;&lt;-&nbsp;'&nbsp;'&nbsp;done</div>
- <div class="lineNone">001169| &nbsp;&nbsp;&nbsp;&nbsp;)</div>
- <div class="lineNone">001170| &nbsp;&nbsp;done;</div>
- <div class="lineNone">001171| &nbsp;</div>
- <div class="lineAllVisited">001172| &nbsp;&nbsp;(*[34]*)if&nbsp;!linelen&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;(</div>
- <div class="lineAllVisited">001173| &nbsp;&nbsp;&nbsp;&nbsp;(*[32]*)let&nbsp;skip&nbsp;=&nbsp;(16&nbsp;-&nbsp;!linelen)&nbsp;*&nbsp;3&nbsp;+&nbsp;if&nbsp;!linelen&nbsp;&lt;&nbsp;8&nbsp;then&nbsp;(*[24]*)1&nbsp;else&nbsp;(*[8]*)0&nbsp;in</div>
- <div class="lineAllVisited">001174| &nbsp;&nbsp;&nbsp;&nbsp;(*[32]*)for&nbsp;i&nbsp;=&nbsp;0&nbsp;to&nbsp;skip-1&nbsp;do&nbsp;(*[1116]*)fprintf&nbsp;chan&nbsp;&quot;&nbsp;&quot;&nbsp;done;</div>
- <div class="lineAllVisited">001175| &nbsp;&nbsp;&nbsp;&nbsp;(*[32]*)fprintf&nbsp;chan&nbsp;&quot;&nbsp;|%s|\n%!&quot;&nbsp;linechars</div>
- <div class="lineNone">001176| &nbsp;&nbsp;)&nbsp;else</div>
- <div class="lineAllVisited">001177| &nbsp;&nbsp;&nbsp;&nbsp;(*[2]*)fprintf&nbsp;chan&nbsp;&quot;\n%!&quot;</div>
- </code>
- <hr class="codeSep"/>
- <p class="footer">Generated by <a href="http://bisect.x9c.fr">Bisect</a> on 2008-08-27 13:53:18</p>
- </body>
-</html>
diff --git a/coverage-report/file0002.html b/coverage-report/file0002.html
deleted file mode 100644
index a267d13..0000000
--- a/coverage-report/file0002.html
+++ /dev/null
@@ -1,59 +0,0 @@
-<html>
- <head>
- <title>Bisect report</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <h3>File: bitmatch.ml (<a href="index.html">return to index</a>)</h3>
- <hr class="codeSep"/>
- <h4>Statistics:</h4>
- <table class="simple">
- <tr><th>kind</th><th width="16px">&nbsp;</th><th>coverage</th></tr>
- <tr><td>binding</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>sequence</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>for</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>if/then</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>try</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>while</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>match/function</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class expression</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class initializer</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class method</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class value</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>toplevel expression</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- </table>
- <hr class="codeSep"/>
- <h4>Source:</h4>
- <code>
- <div class="lineNone">000001| (**&nbsp;Bitmatch&nbsp;backwards&nbsp;compatibility&nbsp;library.&nbsp;*)</div>
- <div class="lineNone">000002| (*&nbsp;Bitstring&nbsp;library.</div>
- <div class="lineNone">000003| &nbsp;*&nbsp;Copyright&nbsp;(C)&nbsp;2008&nbsp;Red&nbsp;Hat&nbsp;Inc.,&nbsp;Richard&nbsp;W.M.&nbsp;Jones</div>
- <div class="lineNone">000004| &nbsp;*</div>
- <div class="lineNone">000005| &nbsp;*&nbsp;This&nbsp;library&nbsp;is&nbsp;free&nbsp;software;&nbsp;you&nbsp;can&nbsp;redistribute&nbsp;it&nbsp;and/or</div>
- <div class="lineNone">000006| &nbsp;*&nbsp;modify&nbsp;it&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;the&nbsp;GNU&nbsp;Lesser&nbsp;General&nbsp;Public</div>
- <div class="lineNone">000007| &nbsp;*&nbsp;License&nbsp;as&nbsp;published&nbsp;by&nbsp;the&nbsp;Free&nbsp;Software&nbsp;Foundation;&nbsp;either</div>
- <div class="lineNone">000008| &nbsp;*&nbsp;version&nbsp;2&nbsp;of&nbsp;the&nbsp;License,&nbsp;or&nbsp;(at&nbsp;your&nbsp;option)&nbsp;any&nbsp;later&nbsp;version,</div>
- <div class="lineNone">000009| &nbsp;*&nbsp;with&nbsp;the&nbsp;OCaml&nbsp;linking&nbsp;exception&nbsp;described&nbsp;in&nbsp;COPYING.LIB.</div>
- <div class="lineNone">000010| &nbsp;*</div>
- <div class="lineNone">000011| &nbsp;*&nbsp;This&nbsp;library&nbsp;is&nbsp;distributed&nbsp;in&nbsp;the&nbsp;hope&nbsp;that&nbsp;it&nbsp;will&nbsp;be&nbsp;useful,</div>
- <div class="lineNone">000012| &nbsp;*&nbsp;but&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of</div>
- <div class="lineNone">000013| &nbsp;*&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;&nbsp;See&nbsp;the&nbsp;GNU</div>
- <div class="lineNone">000014| &nbsp;*&nbsp;Lesser&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.</div>
- <div class="lineNone">000015| &nbsp;*</div>
- <div class="lineNone">000016| &nbsp;*&nbsp;You&nbsp;should&nbsp;have&nbsp;received&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;GNU&nbsp;Lesser&nbsp;General&nbsp;Public</div>
- <div class="lineNone">000017| &nbsp;*&nbsp;License&nbsp;along&nbsp;with&nbsp;this&nbsp;library;&nbsp;if&nbsp;not,&nbsp;write&nbsp;to&nbsp;the&nbsp;Free&nbsp;Software</div>
- <div class="lineNone">000018| &nbsp;*&nbsp;Foundation,&nbsp;Inc.,&nbsp;51&nbsp;Franklin&nbsp;Street,&nbsp;Fifth&nbsp;Floor,&nbsp;Boston,&nbsp;MA&nbsp;02110-1301&nbsp;USA</div>
- <div class="lineNone">000019| &nbsp;*</div>
- <div class="lineNone">000020| &nbsp;*&nbsp;$Id:&nbsp;bitmatch.ml&nbsp;142&nbsp;2008-07-17&nbsp;15:45:56Z&nbsp;richard.wm.jones&nbsp;$</div>
- <div class="lineNone">000021| &nbsp;*)</div>
- <div class="lineNone">000022| (**&nbsp;This&nbsp;is&nbsp;just&nbsp;for&nbsp;backwards&nbsp;compatibility&nbsp;with&nbsp;code</div>
- <div class="lineNone">000023| &nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;when&nbsp;the&nbsp;library&nbsp;was&nbsp;called&nbsp;bitmatch.&nbsp;&nbsp;You&nbsp;should</div>
- <div class="lineNone">000024| &nbsp;&nbsp;&nbsp;&nbsp;replace&nbsp;all&nbsp;references&nbsp;to&nbsp;this&nbsp;module&nbsp;with&nbsp;{!Bitstring}.</div>
- <div class="lineNone">000025| *)</div>
- <div class="lineNone">000026| &nbsp;</div>
- <div class="lineNone">000027| include&nbsp;Bitstring</div>
- </code>
- <hr class="codeSep"/>
- <p class="footer">Generated by <a href="http://bisect.x9c.fr">Bisect</a> on 2008-08-27 13:53:18</p>
- </body>
-</html>
diff --git a/coverage-report/file0003.html b/coverage-report/file0003.html
deleted file mode 100644
index f57630a..0000000
--- a/coverage-report/file0003.html
+++ /dev/null
@@ -1,59 +0,0 @@
-<html>
- <head>
- <title>Bisect report</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <h3>File: bitstring_types.ml (<a href="index.html">return to index</a>)</h3>
- <hr class="codeSep"/>
- <h4>Statistics:</h4>
- <table class="simple">
- <tr><th>kind</th><th width="16px">&nbsp;</th><th>coverage</th></tr>
- <tr><td>binding</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>sequence</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>for</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>if/then</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>try</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>while</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>match/function</td><td width="16px">&nbsp;</td><td>0 / 3 (0 %)</td></tr>
- <tr><td>class expression</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class initializer</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class method</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class value</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>toplevel expression</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- </table>
- <hr class="codeSep"/>
- <h4>Source:</h4>
- <code>
- <div class="lineNone">000001| (*&nbsp;Bitstring&nbsp;library.</div>
- <div class="lineNone">000002| &nbsp;*&nbsp;Copyright&nbsp;(C)&nbsp;2008&nbsp;Red&nbsp;Hat&nbsp;Inc.,&nbsp;Richard&nbsp;W.M.&nbsp;Jones</div>
- <div class="lineNone">000003| &nbsp;*</div>
- <div class="lineNone">000004| &nbsp;*&nbsp;This&nbsp;library&nbsp;is&nbsp;free&nbsp;software;&nbsp;you&nbsp;can&nbsp;redistribute&nbsp;it&nbsp;and/or</div>
- <div class="lineNone">000005| &nbsp;*&nbsp;modify&nbsp;it&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;the&nbsp;GNU&nbsp;Lesser&nbsp;General&nbsp;Public</div>
- <div class="lineNone">000006| &nbsp;*&nbsp;License&nbsp;as&nbsp;published&nbsp;by&nbsp;the&nbsp;Free&nbsp;Software&nbsp;Foundation;&nbsp;either</div>
- <div class="lineNone">000007| &nbsp;*&nbsp;version&nbsp;2&nbsp;of&nbsp;the&nbsp;License,&nbsp;or&nbsp;(at&nbsp;your&nbsp;option)&nbsp;any&nbsp;later&nbsp;version,</div>
- <div class="lineNone">000008| &nbsp;*&nbsp;with&nbsp;the&nbsp;OCaml&nbsp;linking&nbsp;exception&nbsp;described&nbsp;in&nbsp;COPYING.LIB.</div>
- <div class="lineNone">000009| &nbsp;*</div>
- <div class="lineNone">000010| &nbsp;*&nbsp;This&nbsp;library&nbsp;is&nbsp;distributed&nbsp;in&nbsp;the&nbsp;hope&nbsp;that&nbsp;it&nbsp;will&nbsp;be&nbsp;useful,</div>
- <div class="lineNone">000011| &nbsp;*&nbsp;but&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of</div>
- <div class="lineNone">000012| &nbsp;*&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;&nbsp;See&nbsp;the&nbsp;GNU</div>
- <div class="lineNone">000013| &nbsp;*&nbsp;Lesser&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.</div>
- <div class="lineNone">000014| &nbsp;*</div>
- <div class="lineNone">000015| &nbsp;*&nbsp;You&nbsp;should&nbsp;have&nbsp;received&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;GNU&nbsp;Lesser&nbsp;General&nbsp;Public</div>
- <div class="lineNone">000016| &nbsp;*&nbsp;License&nbsp;along&nbsp;with&nbsp;this&nbsp;library;&nbsp;if&nbsp;not,&nbsp;write&nbsp;to&nbsp;the&nbsp;Free&nbsp;Software</div>
- <div class="lineNone">000017| &nbsp;*&nbsp;Foundation,&nbsp;Inc.,&nbsp;51&nbsp;Franklin&nbsp;Street,&nbsp;Fifth&nbsp;Floor,&nbsp;Boston,&nbsp;MA&nbsp;02110-1301&nbsp;USA</div>
- <div class="lineNone">000018| &nbsp;*</div>
- <div class="lineNone">000019| &nbsp;*&nbsp;$Id:&nbsp;bitstring_types.ml&nbsp;142&nbsp;2008-07-17&nbsp;15:45:56Z&nbsp;richard.wm.jones&nbsp;$</div>
- <div class="lineNone">000020| &nbsp;*)</div>
- <div class="lineNone">000021| &nbsp;</div>
- <div class="lineNone">000022| type&nbsp;endian&nbsp;=&nbsp;BigEndian&nbsp;|&nbsp;LittleEndian&nbsp;|&nbsp;NativeEndian</div>
- <div class="lineNone">000023| &nbsp;</div>
- <div class="lineNone">000024| let&nbsp;string_of_endian&nbsp;=&nbsp;function</div>
- <div class="lineAllUnvisited">000025| &nbsp;&nbsp;|&nbsp;BigEndian&nbsp;-&gt;&nbsp;(*[0]*)&quot;bigendian&quot;</div>
- <div class="lineAllUnvisited">000026| &nbsp;&nbsp;|&nbsp;LittleEndian&nbsp;-&gt;&nbsp;(*[0]*)&quot;littleendian&quot;</div>
- <div class="lineAllUnvisited">000027| &nbsp;&nbsp;|&nbsp;NativeEndian&nbsp;-&gt;&nbsp;(*[0]*)&quot;nativeendian&quot;</div>
- </code>
- <hr class="codeSep"/>
- <p class="footer">Generated by <a href="http://bisect.x9c.fr">Bisect</a> on 2008-08-27 13:53:18</p>
- </body>
-</html>
diff --git a/coverage-report/index.html b/coverage-report/index.html
deleted file mode 100644
index 8483c53..0000000
--- a/coverage-report/index.html
+++ /dev/null
@@ -1,97 +0,0 @@
-<html>
- <head>
- <title>Bisect report</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <h1>Bisect report</h1>
- <hr class="indexSep"/>
- <center>
- <h3>Overall statistics</h3
- <table class="simple">
- <tr><th>kind</th><th width="16px">&nbsp;</th><th>coverage</th></tr>
- <tr><td>binding</td><td width="16px">&nbsp;</td><td>231 / 250 (92 %)</td></tr>
- <tr><td>sequence</td><td width="16px">&nbsp;</td><td>83 / 95 (87 %)</td></tr>
- <tr><td>for</td><td width="16px">&nbsp;</td><td>5 / 5 (100 %)</td></tr>
- <tr><td>if/then</td><td width="16px">&nbsp;</td><td>141 / 194 (72 %)</td></tr>
- <tr><td>try</td><td width="16px">&nbsp;</td><td>1 / 2 (50 %)</td></tr>
- <tr><td>while</td><td width="16px">&nbsp;</td><td>3 / 3 (100 %)</td></tr>
- <tr><td>match/function</td><td width="16px">&nbsp;</td><td>64 / 90 (71 %)</td></tr>
- <tr><td>class expression</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class initializer</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class method</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>class value</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- <tr><td>toplevel expression</td><td width="16px">&nbsp;</td><td>0 / 0 (- %)</td></tr>
- </table>
- <br/>
- </center>
- <hr class="indexSep"/>
- <center>
- <br/>
- <h3>Per-file coverage</h3
- <table class="simple">
- <tr>
- <th>coverage</th>
- <th width="16px">&nbsp;</th>
- <th>file</th>
- </tr>
- <tr>
- <td>
- <table class="gauge">
- <tr>
- <td class="gaugeOK" width="100px"/>
- <td class="gaugeKO" width="0px"/>
- <td>&nbsp;-%</td>
- </tr>
- </table>
- </td>
- <td width="16px">&nbsp;</td>
- <td><a href="file0002.html">bitmatch.ml</a></td>
- </tr>
- <tr>
- <td>
- <table class="gauge">
- <tr>
- <td class="gaugeOK" width="82px"/>
- <td class="gaugeKO" width="18px"/>
- <td>&nbsp;82%</td>
- </tr>
- </table>
- </td>
- <td width="16px">&nbsp;</td>
- <td><a href="file0001.html">bitstring.ml</a></td>
- </tr>
- <tr>
- <td>
- <table class="gauge">
- <tr>
- <td class="gaugeOK" width="100px"/>
- <td class="gaugeKO" width="0px"/>
- <td>&nbsp;100%</td>
- </tr>
- </table>
- </td>
- <td width="16px">&nbsp;</td>
- <td><a href="file0000.html">bitstring_config.ml</a></td>
- </tr>
- <tr>
- <td>
- <table class="gauge">
- <tr>
- <td class="gaugeOK" width="0px"/>
- <td class="gaugeKO" width="100px"/>
- <td>&nbsp;0%</td>
- </tr>
- </table>
- </td>
- <td width="16px">&nbsp;</td>
- <td><a href="file0003.html">bitstring_types.ml</a></td>
- </tr>
- </table>
- </center>
- <br/>
- <br/>
- <hr class="indexSep"/>
- <p class="footer">Generated by <a href="http://bisect.x9c.fr">Bisect</a> on 2008-08-27 13:53:18</p>
- </body>
-</html>
diff --git a/coverage-report/style.css b/coverage-report/style.css
deleted file mode 100644
index df7402b..0000000
--- a/coverage-report/style.css
+++ /dev/null
@@ -1,70 +0,0 @@
-body {
- background: white;
- white-space: nowrap;
-}
-
-.footer {
- font-size: smaller;
- text-align: center;
-}
-
-.codeSep {
- border: none 0;
- border-top: 1px solid gray;
- height: 1px;
-}
-
-.indexSep {
- border: none 0;
- border-top: 1px solid gray;
- height: 1px;
- width: 75%;
-}
-
-.lineNone { white-space: nowrap; background: white; }
-.lineAllVisited { white-space: nowrap; background: green; }
-.lineAllUnvisited { white-space: nowrap; background: red; }
-.lineMixed { white-space: nowrap; background: yellow; }
-
-table.simple {
- border-width: 1px;
- border-spacing: 0px;
- border-top-style: solid;
- border-bottom-style: solid;
- border-color: black;
-}
-
-table.simple th {
- border-width: 1px;
- border-spacing: 0px;
- border-bottom-style: solid;
- border-color: black;
- text-align: center;
- font-weight: bold;
-}
-
-table.simple td {
- border-width: 1px;
- border-spacing: 0px;
- border-style: none;
-}
-
-table.gauge {
- border-width: 0px;
- border-spacing: 0px;
- padding: 0px;
- border-style: none;
- border-collapse: collapse;
-}
-
-table.gauge td {
- border-width: 0px;
- border-spacing: 0px;
- padding: 0px;
- border-style: none;
- border-collapse: collapse;
-}
-
-.gaugeOK { background: green; }
-.gaugeKO { background: red; }
-
diff --git a/create_test_pattern.ml b/create_test_pattern.ml
deleted file mode 100644
index 291bcb8..0000000
--- a/create_test_pattern.ml
+++ /dev/null
@@ -1,27 +0,0 @@
-(* Create persistent pattern.
- * $Id$
- *)
-
-open Bitstring_persistent
-
-open Camlp4.PreCast
-open Syntax
-open Ast
-
-let () =
- let _loc = Loc.ghost in
-
- let len_field = create_pattern_field _loc in
- let len_field = set_length_int len_field 8 in
- let len_field = set_lident_patt len_field "len" in
-
- let str_field = create_pattern_field _loc in
- let str_field = set_length str_field <:expr< len*8 >> in
- let str_field = set_lident_patt str_field "str" in
- let str_field = set_type_string str_field in
-
- let named_pattern = "pascal_string", Pattern [len_field; str_field] in
-
- let chan = open_out Sys.argv.(1) in
- named_to_channel chan named_pattern;
- close_out chan
diff --git a/examples/.merlin b/examples/.merlin
new file mode 100644
index 0000000..b8e003b
--- /dev/null
+++ b/examples/.merlin
@@ -0,0 +1,6 @@
+B ../_build/default/examples
+B ../_build/default/src
+FLG -ppx '/Users/xguerin/Workspace/bitstring/_build/default/.ppx/bitstring.ppx/ppx.exe --as-ppx'
+FLG -w -40 -w -40 -w -40 -w -40 -w -40 -w -40 -w -40
+PKG unix
+S ../src
diff --git a/examples/elf.ml b/examples/elf.ml
index 67431be..366a67a 100644
--- a/examples/elf.ml
+++ b/examples/elf.ml
@@ -8,13 +8,13 @@ let () =
let filename = "/bin/ls" in
let bits = Bitstring.bitstring_of_file filename in
- bitmatch bits with
- | { 0x7f : 8; "ELF" : 24 : string; (* ELF magic number *)
+ match%bitstring bits with
+ | {| 0x7f : 8; "ELF" : 24 : string; (* ELF magic number *)
_ : 12*8 : bitstring; (* ELF identifier *)
e_type : 16 : littleendian; (* object file type *)
e_machine : 16 : littleendian (* architecture *)
- } ->
+ |} ->
printf "%s: ELF binary, type %d, arch %d\n" filename e_type e_machine
- | { _ } ->
+ | {| _ |} ->
eprintf "%s: Not an ELF binary\n" filename
diff --git a/examples/ext3_superblock.ml b/examples/ext3_superblock.ml
index 77ef2db..f397f1e 100644
--- a/examples/ext3_superblock.ml
+++ b/examples/ext3_superblock.ml
@@ -11,8 +11,8 @@ let bits = Bitstring.bitstring_of_file "ext3_sb"
(* The structure is straight from /usr/include/linux/ext3_fs.h *)
let () =
- bitmatch bits with
- | { s_inodes_count : 32 : littleendian; (* Inodes count *)
+ match%bitstring bits with
+ | {|s_inodes_count : 32 : littleendian; (* Inodes count *)
s_blocks_count : 32 : littleendian; (* Blocks count *)
s_r_blocks_count : 32 : littleendian; (* Reserved blocks count *)
s_free_blocks_count : 32 : littleendian; (* Free blocks count *)
@@ -63,7 +63,7 @@ let () =
s_reserved_word_pad : 16 : littleendian;
s_default_mount_opts : 32 : littleendian;
s_first_meta_bg : 32 : littleendian; (* First metablock block group *)
- _ : 6080 : bitstring } -> (* Padding to the end of the block *)
+ _ : 6080 : bitstring |} -> (* Padding to the end of the block *)
printf "ext3 superblock:\n";
printf " s_inodes_count = %ld\n" s_inodes_count;
@@ -74,6 +74,6 @@ let () =
printf " s_volume_name = %S\n" s_volume_name;
printf " s_last_mounted = %S\n" s_last_mounted
- | { _ } ->
+ | {| _ |} ->
eprintf "not an ext3 superblock!\n%!";
exit 2
diff --git a/examples/gif.ml b/examples/gif.ml
index cbfa928..033e150 100644
--- a/examples/gif.ml
+++ b/examples/gif.ml
@@ -10,8 +10,8 @@ let () =
let filename = Sys.argv.(1) in
let bits = Bitstring.bitstring_of_file filename in
- bitmatch bits with
- | { ("GIF87a"|"GIF89a") : 6*8 : string; (* GIF magic. *)
+ match%bitstring bits with
+ | {|("GIF87a"|"GIF89a") : 6*8 : string; (* GIF magic. *)
width : 16 : littleendian;
height : 16 : littleendian;
colormap : 1; (* Has colormap? *)
@@ -19,7 +19,7 @@ let () =
sortflag : 1;
bps : 3; (* Bits/pixel = bps+1 *)
bg : 8; (* Background colour. *)
- aspectratio : 8 } ->
+ aspectratio : 8|} ->
printf "%s: GIF image:\n" filename;
printf " size %d %d\n" width height;
printf " has global colormap? %b\n" colormap;
@@ -29,5 +29,5 @@ let () =
printf " background color index %d\n" bg;
printf " aspect ratio %d\n" aspectratio
- | { _ } ->
+ | {|_|} ->
eprintf "%s: Not a GIF image\n" filename
diff --git a/examples/ipv4_header.ml b/examples/ipv4_header.ml
index e47de03..c81c70b 100644
--- a/examples/ipv4_header.ml
+++ b/examples/ipv4_header.ml
@@ -7,14 +7,14 @@ open Printf
let header = Bitstring.bitstring_of_file "ipv4_header.dat"
let () =
- bitmatch header with
- | { version : 4; hdrlen : 4; tos : 8; length : 16;
+ match%bitstring header with
+ | {|version : 4; hdrlen : 4; tos : 8; length : 16;
identification : 16; flags : 3; fragoffset : 13;
ttl : 8; protocol : 8; checksum : 16;
source : 32;
dest : 32;
options : (hdrlen-5)*32 : bitstring;
- payload : -1 : bitstring }
+ payload : -1 : bitstring|}
when version = 4 ->
printf "IPv%d:\n" version;
@@ -33,9 +33,9 @@ let () =
printf " packet payload:\n";
Bitstring.hexdump_bitstring stdout payload
- | { version : 4 } ->
+ | {|version : 4|} ->
eprintf "cannot parse IP version %d\n" version
- | { _ } as header ->
+ | {|_|} as header ->
eprintf "data is smaller than one nibble:\n";
Bitstring.hexdump_bitstring stderr header
diff --git a/examples/jbuild b/examples/jbuild
new file mode 100644
index 0000000..819b819
--- /dev/null
+++ b/examples/jbuild
@@ -0,0 +1,50 @@
+(jbuild_version 1)
+
+(executable
+ ((name elf)
+ (modules (Elf))
+ (libraries (bitstring unix))
+ (preprocess (pps (bitstring.ppx)))
+ ))
+
+(executable
+ ((name ext3_superblock)
+ (modules (Ext3_superblock))
+ (libraries (bitstring unix))
+ (preprocess (pps (bitstring.ppx)))
+ ))
+
+(executable
+ ((name gif)
+ (modules (Gif))
+ (libraries (bitstring unix))
+ (preprocess (pps (bitstring.ppx)))
+ ))
+
+(executable
+ ((name ipv4_header)
+ (modules (Ipv4_header))
+ (libraries (bitstring unix))
+ (preprocess (pps (bitstring.ppx)))
+ ))
+
+(executable
+ ((name libpcap)
+ (modules (Libpcap))
+ (libraries (bitstring unix))
+ (preprocess (pps (bitstring.ppx)))
+ ))
+
+(executable
+ ((name make_ipv4_header)
+ (modules (Make_ipv4_header))
+ (libraries (bitstring unix))
+ (preprocess (pps (bitstring.ppx)))
+ ))
+
+(executable
+ ((name ping)
+ (modules (Ping))
+ (libraries (bitstring unix))
+ (preprocess (pps (bitstring.ppx)))
+ ))
diff --git a/examples/libpcap.ml b/examples/libpcap.ml
index e7fdd93..79194ed 100644
--- a/examples/libpcap.ml
+++ b/examples/libpcap.ml
@@ -36,8 +36,8 @@ and endian_of = function
| _ -> assert false
and libpcap_header bits =
- bitmatch bits with
- | { ((0xa1b2c3d4_l|0xd4c3b2a1_l) as magic) : 32; (* magic number *)
+ match%bitstring bits with
+ | {|((0xa1b2c3d4_l|0xd4c3b2a1_l) as magic) : 32; (* magic number *)
major : 16 : endian (endian_of magic); (* version *)
minor : 16 : endian (endian_of magic);
timezone : 32 : endian (endian_of magic); (* timezone correction (secs)*)
@@ -45,24 +45,24 @@ and libpcap_header bits =
snaplen : 32 : endian (endian_of magic); (* max length of capt pckts *)
network : 32 : endian (endian_of magic); (* data link layer type *)
rest : -1 : bitstring
- } ->
+ |} ->
endian_of magic, (major, minor, timezone, snaplen, network), rest
- | { _ } ->
+ | {|_|} ->
failwith "not a libpcap/tcpdump packet capture file"
and libpcap_packet e file_header bits =
- bitmatch bits with
- | { ts_sec : 32 : endian (e); (* packet timestamp seconds *)
+ match%bitstring bits with
+ | {|ts_sec : 32 : endian (e); (* packet timestamp seconds *)
ts_usec : 32 : endian (e); (* packet timestamp microseconds *)
incl_len : 32 : endian (e); (* packet length saved in this file *)
orig_len : 32 : endian (e); (* packet length originally on wire *)
pkt_data : Int32.to_int incl_len*8 : bitstring;
rest : -1 : bitstring
- } ->
+ |} ->
(ts_sec, ts_usec, incl_len, orig_len), pkt_data, rest
- | { _ } -> raise End_of_file
+ | {|_|} -> raise End_of_file
and decode_and_print_packet file_header pkt_header pkt_data =
let (ts_sec, ts_usec, _, orig_len) = pkt_header in
@@ -72,40 +72,40 @@ and decode_and_print_packet file_header pkt_header pkt_data =
* the ethertype field and determine the IP version from the packet
* itself. If it doesn't match our assumptions, hexdump it.
*)
- (bitmatch pkt_data with
- | { d0 : 8; d1 : 8; d2 : 8; d3 : 8; d4 : 8; d5 : 8; (* ether dest *)
+ (match%bitstring pkt_data with
+ | {|d0 : 8; d1 : 8; d2 : 8; d3 : 8; d4 : 8; d5 : 8; (* ether dest *)
s0 : 8; s1 : 8; s2 : 8; s3 : 8; s4 : 8; s5 : 8; (* ether src *)
_ : 16; (* ethertype *)
packet : -1 : bitstring (* payload *)
- } ->
+ |} ->
printf "%x:%x:%x:%x:%x:%x < %x:%x:%x:%x:%x:%x "
d0 d1 d2 d3 d4 d5 s0 s1 s2 s3 s4 s5;
- (bitmatch packet with
- | { 4 : 4; (* IPv4 *)
+ (match%bitstring packet with
+ | {|4 : 4; (* IPv4 *)
hdrlen : 4; tos : 8; length : 16;
identification : 16; flags : 3; fragoffset : 13;
ttl : 8; protocol : 8; checksum : 16;
s0 : 8; s1 : 8; s2 : 8; s3 : 8;
d0 : 8; d1 : 8; d2 : 8; d3 : 8;
_(*options*) : (hdrlen-5)*32 : bitstring;
- _(*payload*) : -1 : bitstring } ->
+ _(*payload*) : -1 : bitstring|} ->
printf "IPv4 %d.%d.%d.%d < %d.%d.%d.%d "
s0 s1 s2 s3 d0 d1 d2 d3
- | { 6 : 4; (* IPv6 *)
+ | {|6 : 4; (* IPv6 *)
tclass : 8; flow : 20;
length : 16; nexthdr : 8; ttl : 8;
_(*source*) : 128 : bitstring;
_(*dest*) : 128 : bitstring;
- _(*payload*) : -1 : bitstring } ->
+ _(*payload*) : -1 : bitstring|} ->
printf "IPv6 ";
- | { _ } ->
+ | {|_|} ->
printf "\n"; Bitstring.hexdump_bitstring stdout packet
)
- | { _ } ->
+ | {|_|} ->
printf "\n"; Bitstring.hexdump_bitstring stdout pkt_data
);
printf "\n"
diff --git a/examples/make_ipv4_header.ml b/examples/make_ipv4_header.ml
index 225eae3..f9940d4 100644
--- a/examples/make_ipv4_header.ml
+++ b/examples/make_ipv4_header.ml
@@ -20,18 +20,12 @@ let options = Bitstring.empty_bitstring
let payload_length = (length - hdrlen*4) * 8
let payload = Bitstring.create_bitstring payload_length
-let header =
- BITSTRING {
+let%bitstring header =
+ {|
version : 4; hdrlen : 4; tos : 8; length : 16;
identification : 16; flags : 3; fragoffset : 13;
ttl : 8; protocol : 8; checksum : 16;
- source : 32;
- dest : 32
-(*
- Not implemented at the moment XXX
- options : -1 : bitstring;
- payload : payload_length : bitstring
-*)
- }
+ source : 32; dest : 32
+ |}
let () = Bitstring.bitstring_to_file header "ipv4_header_out.dat"
diff --git a/examples/ping.ml b/examples/ping.ml
index 6112364..3d918c9 100644
--- a/examples/ping.ml
+++ b/examples/ping.ml
@@ -5,15 +5,15 @@
open Printf
let display pkt =
- bitmatch pkt with
+ match%bitstring pkt with
(* IPv4 packet header *)
- | { 4 : 4; hdrlen : 4; tos : 8; length : 16;
+ | {|4 : 4; hdrlen : 4; tos : 8; length : 16;
identification : 16; flags : 3; fragoffset : 13;
ttl : 8; protocol : 8; checksum : 16;
source : 32;
dest : 32;
options : (hdrlen-5)*32 : bitstring;
- payload : -1 : bitstring } ->
+ payload : -1 : bitstring|} ->
printf "IPv4:\n";
printf " header length: %d * 32 bit words\n" hdrlen;
@@ -32,11 +32,11 @@ let display pkt =
Bitstring.hexdump_bitstring stdout payload
(* IPv6 packet header *)
- | { 6 : 4; tclass : 8; flow : 20;
+ | {|6 : 4; tclass : 8; flow : 20;
length : 16; nexthdr : 8; ttl : 8;
source : 128 : bitstring;
dest : 128 : bitstring;
- payload : -1 : bitstring } ->
+ payload : -1 : bitstring|} ->
printf "IPv6:\n";
printf " traffic class: %d\n" tclass;
@@ -51,11 +51,11 @@ let display pkt =
printf "packet payload:\n";
Bitstring.hexdump_bitstring stdout payload
- | { version : 4 } ->
+ | {|version : 4|} ->
eprintf "unknown IP version %d\n" version;
exit 1
- | { _ } as pkt ->
+ | {|_|} as pkt ->
eprintf "data is smaller than one nibble:\n";
Bitstring.hexdump_bitstring stderr pkt;
exit 1
diff --git a/install-sh b/install-sh
deleted file mode 100755
index 4fbbae7..0000000
--- a/install-sh
+++ /dev/null
@@ -1,507 +0,0 @@
-#!/bin/sh
-# install - install a program, script, or datafile
-
-scriptversion=2006-10-14.15
-
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
-# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Except as contained in this notice, the name of the X Consortium shall not
-# be used in advertising or otherwise to promote the sale, use or other deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
-#
-#
-# FSF changes to this file are in the public domain.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-
-nl='
-'
-IFS=" "" $nl"
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-if test -z "$doit"; then
- doit_exec=exec
-else
- doit_exec=$doit
-fi
-
-# Put in absolute file names if you don't have them in your path;
-# or use environment vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-posix_glob=
-posix_mkdir=
-
-# Desired mode of installed file.
-mode=0755
-
-chmodcmd=$chmodprog
-chowncmd=
-chgrpcmd=
-stripcmd=
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=
-dst=
-dir_arg=
-dstarg=
-no_target_directory=
-
-usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
- or: $0 [OPTION]... SRCFILES... DIRECTORY
- or: $0 [OPTION]... -t DIRECTORY SRCFILES...
- or: $0 [OPTION]... -d DIRECTORIES...
-
-In the 1st form, copy SRCFILE to DSTFILE.
-In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
-In the 4th, create DIRECTORIES.
-
-Options:
--c (ignored)
--d create directories instead of installing files.
--g GROUP $chgrpprog installed files to GROUP.
--m MODE $chmodprog installed files to MODE.
--o USER $chownprog installed files to USER.
--s $stripprog installed files.
--t DIRECTORY install into DIRECTORY.
--T report an error if DSTFILE is a directory.
---help display this help and exit.
---version display version info and exit.
-
-Environment variables override the default commands:
- CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
-"
-
-while test $# -ne 0; do
- case $1 in
- -c) shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- --help) echo "$usage"; exit $?;;
-
- -m) mode=$2
- shift
- shift
- case $mode in
- *' '* | *' '* | *'
-'* | *'*'* | *'?'* | *'['*)
- echo "$0: invalid mode: $mode" >&2
- exit 1;;
- esac
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd=$stripprog
- shift
- continue;;
-
- -t) dstarg=$2
- shift
- shift
- continue;;
-
- -T) no_target_directory=true
- shift
- continue;;
-
- --version) echo "$0 $scriptversion"; exit $?;;
-
- --) shift
- break;;
-
- -*) echo "$0: invalid option: $1" >&2
- exit 1;;
-
- *) break;;
- esac
-done
-
-if test $# -ne 0 && test -z "$dir_arg$dstarg"; then
- # When -d is used, all remaining arguments are directories to create.
- # When -t is used, the destination is already specified.
- # Otherwise, the last argument is the destination. Remove it from $@.
- for arg
- do
- if test -n "$dstarg"; then
- # $@ is not empty: it contains at least $arg.
- set fnord "$@" "$dstarg"
- shift # fnord
- fi
- shift # arg
- dstarg=$arg
- done
-fi
-
-if test $# -eq 0; then
- if test -z "$dir_arg"; then
- echo "$0: no input file specified." >&2
- exit 1
- fi
- # It's OK to call `install-sh -d' without argument.
- # This can happen when creating conditional directories.
- exit 0
-fi
-
-if test -z "$dir_arg"; then
- trap '(exit $?); exit' 1 2 13 15
-
- # Set umask so as not to create temps with too-generous modes.
- # However, 'strip' requires both read and write access to temps.
- case $mode in
- # Optimize common cases.
- *644) cp_umask=133;;
- *755) cp_umask=22;;
-
- *[0-7])
- if test -z "$stripcmd"; then
- u_plus_rw=
- else
- u_plus_rw='% 200'
- fi
- cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
- *)
- if test -z "$stripcmd"; then
- u_plus_rw=
- else
- u_plus_rw=,u+rw
- fi
- cp_umask=$mode$u_plus_rw;;
- esac
-fi
-
-for src
-do
- # Protect names starting with `-'.
- case $src in
- -*) src=./$src ;;
- esac
-
- if test -n "$dir_arg"; then
- dst=$src
- dstdir=$dst
- test -d "$dstdir"
- dstdir_status=$?
- else
-
- # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
- # might cause directories to be created, which would be especially bad
- # if $src (and thus $dsttmp) contains '*'.
- if test ! -f "$src" && test ! -d "$src"; then
- echo "$0: $src does not exist." >&2
- exit 1
- fi
-
- if test -z "$dstarg"; then
- echo "$0: no destination specified." >&2
- exit 1
- fi
-
- dst=$dstarg
- # Protect names starting with `-'.
- case $dst in
- -*) dst=./$dst ;;
- esac
-
- # If destination is a directory, append the input filename; won't work
- # if double slashes aren't ignored.
- if test -d "$dst"; then
- if test -n "$no_target_directory"; then
- echo "$0: $dstarg: Is a directory" >&2
- exit 1
- fi
- dstdir=$dst
- dst=$dstdir/`basename "$src"`
- dstdir_status=0
- else
- # Prefer dirname, but fall back on a substitute if dirname fails.
- dstdir=`
- (dirname "$dst") 2>/dev/null ||
- expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$dst" : 'X\(//\)[^/]' \| \
- X"$dst" : 'X\(//\)$' \| \
- X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
- echo X"$dst" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'
- `
-
- test -d "$dstdir"
- dstdir_status=$?
- fi
- fi
-
- obsolete_mkdir_used=false
-
- if test $dstdir_status != 0; then
- case $posix_mkdir in
- '')
- # Create intermediate dirs using mode 755 as modified by the umask.
- # This is like FreeBSD 'install' as of 1997-10-28.
- umask=`umask`
- case $stripcmd.$umask in
- # Optimize common cases.
- *[2367][2367]) mkdir_umask=$umask;;
- .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
- *[0-7])
- mkdir_umask=`expr $umask + 22 \
- - $umask % 100 % 40 + $umask % 20 \
- - $umask % 10 % 4 + $umask % 2
- `;;
- *) mkdir_umask=$umask,go-w;;
- esac
-
- # With -d, create the new directory with the user-specified mode.
- # Otherwise, rely on $mkdir_umask.
- if test -n "$dir_arg"; then
- mkdir_mode=-m$mode
- else
- mkdir_mode=
- fi
-
- posix_mkdir=false
- case $umask in
- *[123567][0-7][0-7])
- # POSIX mkdir -p sets u+wx bits regardless of umask, which
- # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
- ;;
- *)
- tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
- trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
- if (umask $mkdir_umask &&
- exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
- then
- if test -z "$dir_arg" || {
- # Check for POSIX incompatibilities with -m.
- # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
- # other-writeable bit of parent directory when it shouldn't.
- # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
- ls_ld_tmpdir=`ls -ld "$tmpdir"`
- case $ls_ld_tmpdir in
- d????-?r-*) different_mode=700;;
- d????-?--*) different_mode=755;;
- *) false;;
- esac &&
- $mkdirprog -m$different_mode -p -- "$tmpdir" && {
- ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
- test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
- }
- }
- then posix_mkdir=:
- fi
- rmdir "$tmpdir/d" "$tmpdir"
- else
- # Remove any dirs left behind by ancient mkdir implementations.
- rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
- fi
- trap '' 0;;
- esac;;
- esac
-
- if
- $posix_mkdir && (
- umask $mkdir_umask &&
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
- )
- then :
- else
-
- # The umask is ridiculous, or mkdir does not conform to POSIX,
- # or it failed possibly due to a race condition. Create the
- # directory the slow way, step by step, checking for races as we go.
-
- case $dstdir in
- /*) prefix=/ ;;
- -*) prefix=./ ;;
- *) prefix= ;;
- esac
-
- case $posix_glob in
- '')
- if (set -f) 2>/dev/null; then
- posix_glob=true
- else
- posix_glob=false
- fi ;;
- esac
-
- oIFS=$IFS
- IFS=/
- $posix_glob && set -f
- set fnord $dstdir
- shift
- $posix_glob && set +f
- IFS=$oIFS
-
- prefixes=
-
- for d
- do
- test -z "$d" && continue
-
- prefix=$prefix$d
- if test -d "$prefix"; then
- prefixes=
- else
- if $posix_mkdir; then
- (umask=$mkdir_umask &&
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
- # Don't fail if two instances are running concurrently.
- test -d "$prefix" || exit 1
- else
- case $prefix in
- *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
- *) qprefix=$prefix;;
- esac
- prefixes="$prefixes '$qprefix'"
- fi
- fi
- prefix=$prefix/
- done
-
- if test -n "$prefixes"; then
- # Don't fail if two instances are running concurrently.
- (umask $mkdir_umask &&
- eval "\$doit_exec \$mkdirprog $prefixes") ||
- test -d "$dstdir" || exit 1
- obsolete_mkdir_used=true
- fi
- fi
- fi
-
- if test -n "$dir_arg"; then
- { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
- { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
- { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
- test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
- else
-
- # Make a couple of temp file names in the proper directory.
- dsttmp=$dstdir/_inst.$$_
- rmtmp=$dstdir/_rm.$$_
-
- # Trap to clean up those temp files at exit.
- trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
-
- # Copy the file name to the temp name.
- (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
-
- # and set any options; do chmod last to preserve setuid bits.
- #
- # If any of these fail, we abort the whole thing. If we want to
- # ignore errors from any of these, just make sure not to ignore
- # errors from the above "$doit $cpprog $src $dsttmp" command.
- #
- { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
- && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
- && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
- && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
-
- # Now rename the file to the real destination.
- { $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \
- || {
- # The rename failed, perhaps because mv can't rename something else
- # to itself, or perhaps because mv is so ancient that it does not
- # support -f.
-
- # Now remove or move aside any old file at destination location.
- # We try this two ways since rm can't unlink itself on some
- # systems and the destination file might be busy for other
- # reasons. In this case, the final cleanup might fail but the new
- # file should still install successfully.
- {
- if test -f "$dst"; then
- $doit $rmcmd -f "$dst" 2>/dev/null \
- || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \
- && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\
- || {
- echo "$0: cannot unlink or rename $dst" >&2
- (exit 1); exit 1
- }
- else
- :
- fi
- } &&
-
- # Now rename the file to the real destination.
- $doit $mvcmd "$dsttmp" "$dst"
- }
- } || exit 1
-
- trap '' 0
- fi
-done
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff --git a/opam b/opam
deleted file mode 100644
index 407f9c0..0000000
--- a/opam
+++ /dev/null
@@ -1,27 +0,0 @@
-authors: [ "Richard W.M. Jones" ]
-bug-reports: "https://github.com/xguerin/ppx_bitstring/issues"
-dev-repo: "https://github.com/xguerin/bitstring.git"
-doc: ["http://et.redhat.com/~rjones/bitstring/html/Bitstring.html"]
-homepage: "https://github.com/xguerin/bitstring"
-license: "LGPLv2+ with exceptions and GPLv2+"
-maintainer: "Xavier Guérin <github@applepine.org>"
-opam-version: "1.2"
-version: "2.1.1"
-
-build: [
- ["./configure" "--prefix" prefix]
- [make "srcdir=./"]
-]
-build-test: [[make "check"]]
-patches: [
- "fix_402.patch" {ocaml-version = "4.02"}
- "fix_404.patch"
-]
-remove: [["ocamlfind" "remove" "bitstring"]]
-depends: ["ocamlfind" {build} "camlp4" {build}]
-depexts: [
- [["debian"] ["time"]]
- [["ubuntu"] ["time"]]
-]
-available: [ ocaml-version >= "3.10" ]
-install: [make "install"]
diff --git a/pa_bitstring.ml b/pa_bitstring.ml
deleted file mode 100644
index 313760a..0000000
--- a/pa_bitstring.ml
+++ /dev/null
@@ -1,1188 +0,0 @@
-(* Bitstring syntax extension.
- * Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version,
- * with the OCaml linking exception described in COPYING.LIB.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * $Id$
- *)
-
-open Printf
-
-open Camlp4.PreCast
-open Syntax
-open Ast
-
-open Bitstring
-module P = Bitstring_persistent
-
-(* If this is true then we emit some debugging code which can
- * be useful to tell what is happening during matches. You
- * also need to do 'Bitstring.debug := true' in your main program.
- *
- * If this is false then no extra debugging code is emitted.
- *)
-let debug = false
-
-(* Hashtable storing named persistent patterns. *)
-let pattern_hash : (string, P.pattern) Hashtbl.t = Hashtbl.create 13
-
-let locfail _loc msg = Loc.raise _loc (Failure msg)
-
-(* Work out if an expression is an integer constant.
- *
- * Returns [Some i] if so (where i is the integer value), else [None].
- *
- * Fairly simplistic algorithm: we can only detect simple constant
- * expressions such as [k], [k+c], [k-c] etc.
- *)
-let rec expr_is_constant = function
- | <:expr< $int:i$ >> -> (* Literal integer constant. *)
- Some (int_of_string i)
- | <:expr< $lid:op$ $a$ $b$ >> ->
- (match expr_is_constant a, expr_is_constant b with
- | Some a, Some b -> (* Integer binary operations. *)
- let ops = ["+", (+); "-", (-); "*", ( * ); "/", (/);
- (* NB: explicit fun .. -> is necessary here to work
- * around a camlp4 bug in OCaml 3.10.0.
- *)
- "land", (fun a b -> a land b);
- "lor", (fun a b -> a lor b);
- "lxor", (fun a b -> a lxor b);
- "lsl", (fun a b -> a lsl b);
- "lsr", (fun a b -> a lsr b);
- "asr", (fun a b -> a asr b);
- "mod", (fun a b -> a mod b)] in
- (try Some ((List.assoc op ops) a b) with Not_found -> None)
- | _ -> None)
- | _ -> None
-
-(* Generate a fresh, unique symbol each time called. *)
-let gensym =
- let i = ref 1000 in
- fun name ->
- incr i; let i = !i in
- sprintf "__pabitstring_%s_%d" name i
-
-(* Used to keep track of which qualifiers we've seen in parse_field. *)
-type whatset_t = {
- endian_set : bool; signed_set : bool; type_set : bool;
- offset_set : bool; check_set : bool; bind_set : bool;
- save_offset_to_set : bool;
-}
-let noneset = {
- endian_set = false; signed_set = false; type_set = false;
- offset_set = false; check_set = false; bind_set = false;
- save_offset_to_set = false
-}
-
-(* Deal with the qualifiers which appear for a field of both types. *)
-let parse_field _loc field qs =
- let fail = locfail _loc in
-
- let whatset, field =
- match qs with
- | None -> noneset, field
- | Some qs ->
- let check already_set msg = if already_set then fail msg in
- let apply_qualifier (whatset, field) =
- function
- | "endian", Some expr ->
- check whatset.endian_set "an endian flag has been set already";
- let field = P.set_endian_expr field expr in
- { whatset with endian_set = true }, field
- | "endian", None ->
- fail "qualifier 'endian' should be followed by an expression"
- | "offset", Some expr ->
- check whatset.offset_set "an offset has been set already";
- let field = P.set_offset field expr in
- { whatset with offset_set = true }, field
- | "offset", None ->
- fail "qualifier 'offset' should be followed by an expression"
- | "check", Some expr ->
- check whatset.check_set "a check-qualifier has been set already";
- let field = P.set_check field expr in
- { whatset with check_set = true }, field
- | "check", None ->
- fail "qualifier 'check' should be followed by an expression"
- | "bind", Some expr ->
- check whatset.bind_set "a bind expression has been set already";
- let field = P.set_bind field expr in
- { whatset with bind_set = true }, field
- | "bind", None ->
- fail "qualifier 'bind' should be followed by an expression"
- | "save_offset_to", Some expr (* XXX should be a pattern *) ->
- check whatset.save_offset_to_set
- "a save_offset_to-qualifier has been set already";
- let id =
- match expr with
- | <:expr< $lid:id$ >> -> id
- | _ ->
- failwith "pa_bitstring: internal error: save_offset_to only supports simple identifiers at the moment. In future we should support full patterns." in
- let field = P.set_save_offset_to_lident field id in
- { whatset with save_offset_to_set = true }, field
- | "save_offset_to", None ->
- fail "qualifier 'save_offset_to' should be followed by a binding expression"
- | s, Some _ ->
- fail (s ^ ": unknown qualifier, or qualifier should not be followed by an expression")
- | qual, None ->
- let endian_quals = ["bigendian", BigEndian;
- "littleendian", LittleEndian;
- "nativeendian", NativeEndian] in
- let sign_quals = ["signed", true; "unsigned", false] in
- let type_quals = ["int", P.set_type_int;
- "string", P.set_type_string;
- "bitstring", P.set_type_bitstring] in
- if List.mem_assoc qual endian_quals then (
- check whatset.endian_set "an endian flag has been set already";
- let field = P.set_endian field (List.assoc qual endian_quals) in
- { whatset with endian_set = true }, field
- ) else if List.mem_assoc qual sign_quals then (
- check whatset.signed_set "a signed flag has been set already";
- let field = P.set_signed field (List.assoc qual sign_quals) in
- { whatset with signed_set = true }, field
- ) else if List.mem_assoc qual type_quals then (
- check whatset.type_set "a type flag has been set already";
- let field = (List.assoc qual type_quals) field in
- { whatset with type_set = true }, field
- ) else
- fail (qual ^ ": unknown qualifier, or qualifier should be followed by an expression") in
- List.fold_left apply_qualifier (noneset, field) qs in
-
- (* If type is set to string or bitstring then endianness and
- * signedness qualifiers are meaningless and must not be set.
- *)
- let () =
- let t = P.get_type field in
- if (t = P.Bitstring || t = P.String) &&
- (whatset.endian_set || whatset.signed_set) then
- fail "string types and endian or signed qualifiers cannot be mixed" in
-
- (* Default endianness, signedness, type if not set already. *)
- let field =
- if whatset.endian_set then field else P.set_endian field BigEndian in
- let field =
- if whatset.signed_set then field else P.set_signed field false in
- let field =
- if whatset.type_set then field else P.set_type_int field in
-
- field
-
-type functype = ExtractFunc | ConstructFunc
-
-(* Choose the right constructor function. *)
-let build_bitstring_call _loc functype length endian signed =
- match functype, length, endian, signed with
- (* XXX The meaning of signed/unsigned breaks down at
- * 31, 32, 63 and 64 bits.
- *)
- | (ExtractFunc, Some 1, _, _) -> <:expr< Bitstring.extract_bit >>
- | (ConstructFunc, Some 1, _, _) -> <:expr< Bitstring.construct_bit >>
- | (functype, Some (2|3|4|5|6|7|8), _, signed) ->
- let funcname = match functype with
- | ExtractFunc -> "extract"
- | ConstructFunc -> "construct" in
- let sign = if signed then "signed" else "unsigned" in
- let call = sprintf "%s_char_%s" funcname sign in
- <:expr< Bitstring.$lid:call$ >>
- | (functype, len, endian, signed) ->
- let funcname = match functype with
- | ExtractFunc -> "extract"
- | ConstructFunc -> "construct" in
- let t = match len with
- | Some i when i <= 31 -> "int"
- | Some 32 -> "int32"
- | _ -> "int64" in
- let sign = if signed then "signed" else "unsigned" in
- match endian with
- | P.ConstantEndian constant ->
- let endianness = match constant with
- | BigEndian -> "be"
- | LittleEndian -> "le"
- | NativeEndian -> "ne" in
- let call = sprintf "%s_%s_%s_%s" funcname t endianness sign in
- <:expr< Bitstring.$lid:call$ >>
- | P.EndianExpr expr ->
- let call = sprintf "%s_%s_%s_%s" funcname t "ee" sign in
- <:expr< Bitstring.$lid:call$ $expr$ >>
-
-(* Generate the code for a constructor, ie. 'BITSTRING ...'. *)
-let output_constructor _loc fields =
- (* This function makes code to raise a Bitstring.Construct_failure exception
- * containing a message and the current _loc context.
- * (Thanks to Bluestorm for suggesting this).
- *)
- let construct_failure _loc msg =
- <:expr<
- Bitstring.Construct_failure
- ($`str:msg$,
- $`str:Loc.file_name _loc$,
- $`int:Loc.start_line _loc$,
- $`int:Loc.start_off _loc - Loc.start_bol _loc$)
- >>
- in
- let raise_construct_failure _loc msg =
- <:expr< raise $construct_failure _loc msg$ >>
- in
-
- (* Bitstrings are created like the 'Buffer' module (in fact, using
- * the Buffer module), by appending snippets to a growing buffer.
- * This is reasonably efficient and avoids a lot of garbage.
- *)
- let buffer = gensym "buffer" in
-
- (* General exception which is raised inside the constructor functions
- * when an int expression is out of range at runtime.
- *)
- let exn = gensym "exn" in
- let exn_used = ref false in
-
- (* Convert each field to a simple bitstring-generating expression. *)
- let fields = List.map (
- fun field ->
- let fexpr = P.get_expr field in
- let flen = P.get_length field in
- let endian = P.get_endian field in
- let signed = P.get_signed field in
- let t = P.get_type field in
- let _loc = P.get_location field in
-
- let fail = locfail _loc in
-
- (* offset(), check(), bind(), save_offset_to() not supported in
- * constructors.
- *
- * Implementation of forward-only offsets is fairly
- * straightforward: we would need to just calculate the length of
- * padding here and add it to what has been constructed. For
- * general offsets, including going backwards, that would require
- * a rethink in how we construct bitstrings.
- *)
- if P.get_offset field <> None then
- fail "offset expressions are not supported in BITSTRING constructors";
- if P.get_check field <> None then
- fail "check expressions are not supported in BITSTRING constructors";
- if P.get_bind field <> None then
- fail "bind expressions are not supported in BITSTRING constructors";
- if P.get_save_offset_to field <> None then
- fail "save_offset_to is not supported in BITSTRING constructors";
-
- (* Is flen an integer constant? If so, what is it? This
- * is very simple-minded and only detects simple constants.
- *)
- let flen_is_const = expr_is_constant flen in
-
- let int_construct_const (i, endian, signed) =
- build_bitstring_call _loc ConstructFunc (Some i) endian signed in
- let int_construct (endian, signed) =
- build_bitstring_call _loc ConstructFunc None endian signed in
-
- let expr =
- match t, flen_is_const with
- (* Common case: int field, constant flen.
- *
- * Range checks are done inside the construction function
- * because that's a lot simpler w.r.t. types. It might
- * be better to move them here. XXX
- *)
- | P.Int, Some i when i > 0 && i <= 64 ->
- let construct_fn = int_construct_const (i,endian,signed) in
- exn_used := true;
-
- <:expr<
- $construct_fn$ $lid:buffer$ $fexpr$ $`int:i$ $lid:exn$
- >>
-
- | P.Int, Some _ ->
- fail "length of int field must be [1..64]"
-
- (* Int field, non-constant length. We need to perform a runtime
- * test to ensure the length is [1..64].
- *
- * Range checks are done inside the construction function
- * because that's a lot simpler w.r.t. types. It might
- * be better to move them here. XXX
- *)
- | P.Int, None ->
- let construct_fn = int_construct (endian,signed) in
- exn_used := true;
-
- <:expr<
- if $flen$ >= 1 && $flen$ <= 64 then
- $construct_fn$ $lid:buffer$ $fexpr$ $flen$ $lid:exn$
- else
- $raise_construct_failure _loc "length of int field must be [1..64]"$
- >>
-
- (* String, constant length > 0, must be a multiple of 8. *)
- | P.String, Some i when i > 0 && i land 7 = 0 ->
- let bs = gensym "bs" in
- let j = i lsr 3 in
- <:expr<
- let $lid:bs$ = $fexpr$ in
- if String.length $lid:bs$ = $`int:j$ then
- Bitstring.construct_string $lid:buffer$ $lid:bs$
- else
- $raise_construct_failure _loc "length of string does not match declaration"$
- >>
-
- (* String, constant length -1, means variable length string
- * with no checks.
- *)
- | P.String, Some (-1) ->
- <:expr< Bitstring.construct_string $lid:buffer$ $fexpr$ >>
-
- (* String, constant length = 0 is probably an error, and so is
- * any other value.
- *)
- | P.String, Some _ ->
- fail "length of string must be > 0 and a multiple of 8, or the special value -1"
-
- (* String, non-constant length.
- * We check at runtime that the length is > 0, a multiple of 8,
- * and matches the declared length.
- *)
- | P.String, None ->
- let bslen = gensym "bslen" in
- let bs = gensym "bs" in
- <:expr<
- let $lid:bslen$ = $flen$ in
- if $lid:bslen$ > 0 then (
- if $lid:bslen$ land 7 = 0 then (
- let $lid:bs$ = $fexpr$ in
- if String.length $lid:bs$ = ($lid:bslen$ lsr 3) then
- Bitstring.construct_string $lid:buffer$ $lid:bs$
- else
- $raise_construct_failure _loc "length of string does not match declaration"$
- ) else
- $raise_construct_failure _loc "length of string must be a multiple of 8"$
- ) else
- $raise_construct_failure _loc "length of string must be > 0"$
- >>
-
- (* Bitstring, constant length >= 0. *)
- | P.Bitstring, Some i when i >= 0 ->
- let bs = gensym "bs" in
- <:expr<
- let $lid:bs$ = $fexpr$ in
- if Bitstring.bitstring_length $lid:bs$ = $`int:i$ then
- Bitstring.construct_bitstring $lid:buffer$ $lid:bs$
- else
- $raise_construct_failure _loc "length of bitstring does not match declaration"$
- >>
-
- (* Bitstring, constant length -1, means variable length bitstring
- * with no checks.
- *)
- | P.Bitstring, Some (-1) ->
- <:expr< Bitstring.construct_bitstring $lid:buffer$ $fexpr$ >>
-
- (* Bitstring, constant length < -1 is an error. *)
- | P.Bitstring, Some _ ->
- fail "length of bitstring must be >= 0 or the special value -1"
-
- (* Bitstring, non-constant length.
- * We check at runtime that the length is >= 0 and matches
- * the declared length.
- *)
- | P.Bitstring, None ->
- let bslen = gensym "bslen" in
- let bs = gensym "bs" in
- <:expr<
- let $lid:bslen$ = $flen$ in
- if $lid:bslen$ >= 0 then (
- let $lid:bs$ = $fexpr$ in
- if Bitstring.bitstring_length $lid:bs$ = $lid:bslen$ then
- Bitstring.construct_bitstring $lid:buffer$ $lid:bs$
- else
- $raise_construct_failure _loc "length of bitstring does not match declaration"$
- ) else
- $raise_construct_failure _loc "length of bitstring must be > 0"$
- >> in
- expr
- ) fields in
-
- (* Create the final bitstring. Start by creating an empty buffer
- * and then evaluate each expression above in turn which will
- * append some more to the bitstring buffer. Finally extract
- * the bitstring.
- *
- * XXX We almost have enough information to be able to guess
- * a good initial size for the buffer.
- *)
- let fields =
- match fields with
- | [] -> <:expr< [] >>
- | h::t -> List.fold_left (fun h t -> <:expr< $h$; $t$ >>) h t in
-
- let expr =
- <:expr<
- let $lid:buffer$ = Bitstring.Buffer.create () in
- $fields$;
- Bitstring.Buffer.contents $lid:buffer$
- >> in
-
- if !exn_used then
- <:expr<
- let $lid:exn$ = $construct_failure _loc "value out of range"$ in
- $expr$
- >>
- else
- expr
-
-(* Generate the code for a bitmatch statement. '_loc' is the
- * location, 'bs' is the bitstring parameter, 'cases' are
- * the list of cases to test against.
- *)
-let output_bitmatch _loc bs cases =
- (* These symbols are used through the generated code to record our
- * current position within the bitstring:
- *
- * data - original bitstring data (string, never changes)
- * off - current offset within data (int, increments as we move through
- * the bitstring)
- * len - current remaining length within data (int, decrements as
- * we move through the bitstring)
- *
- * Also:
- *
- * original_off - saved offset at the start of the match (never changes)
- * original_len - saved length at the start of the match (never changes)
- * off_aligned - true if the original offset is byte-aligned (allows
- * us to make some common optimizations)
- *)
- let data = gensym "data"
- and off = gensym "off"
- and len = gensym "len"
- and original_off = gensym "original_off"
- and original_len = gensym "original_len"
- and off_aligned = gensym "off_aligned"
-
- (* This is where the result will be stored (a reference). *)
- and result = gensym "result" in
-
- (* This generates the field extraction code for each
- * field in a single case. There must be enough remaining data
- * in the bitstring to satisfy the field.
- *
- * As we go through the fields, symbols 'data', 'off' and 'len'
- * track our position and remaining length in the bitstring.
- *
- * The whole thing is a lot of nested 'if'/'match' statements.
- * Code is generated from the inner-most (last) field outwards.
- *)
- let rec output_field_extraction inner = function
- | [] -> inner
- | field :: fields ->
- let fpatt = P.get_patt field in
- let flen = P.get_length field in
- let endian = P.get_endian field in
- let signed = P.get_signed field in
- let t = P.get_type field in
- let _loc = P.get_location field in
-
- let fail = locfail _loc in
-
- (* Is flen (field len) an integer constant? If so, what is it?
- * This will be [Some i] if it's a constant or [None] if it's
- * non-constant or we couldn't determine.
- *)
- let flen_is_const = expr_is_constant flen in
-
- (* Surround the inner expression by check and bind clauses, so:
- * if $check$ then
- * let $bind...$ in
- * $inner$
- * where the check and bind are switched on only if they are
- * present in the field. (In the common case when neither
- * clause is present, expr = inner). Note the order of the
- * check & bind is visible to the user and defined in the
- * documentation, so it must not change.
- *)
- let expr = inner in
- let expr =
- match P.get_bind field with
- | None -> expr
- | Some bind_expr ->
- <:expr< let $fpatt$ = $bind_expr$ in $expr$ >> in
- let expr =
- match P.get_check field with
- | None -> expr
- | Some check_expr ->
- <:expr< if $check_expr$ then $expr$ >> in
-
- (* Compute the offset of this field within the match, if it
- * can be known at compile time.
- *
- * Actually, we'll compute two things: the 'natural_field_offset'
- * is the offset assuming this field had no offset() qualifier
- * (in other words, its position, immediately following the
- * preceding field). 'field_offset' is the real field offset
- * taking into account any offset() qualifier.
- *
- * This will be [Some i] if our current offset is known
- * at compile time, or [None] if we can't determine it.
- *)
- let natural_field_offset, field_offset =
- let has_constant_offset field =
- match P.get_offset field with
- | None -> false
- | Some expr ->
- match expr_is_constant expr with
- | None -> false
- | Some i -> true
- in
- let get_constant_offset field =
- match P.get_offset field with
- | None -> assert false
- | Some expr ->
- match expr_is_constant expr with
- | None -> assert false
- | Some i -> i
- in
-
- let has_constant_len field =
- match expr_is_constant (P.get_length field) with
- | None -> false
- | Some i when i > 0 -> true
- | Some _ -> false
- in
- let get_constant_len field =
- match expr_is_constant (P.get_length field) with
- | None -> assert false
- | Some i when i > 0 -> i
- | Some _ -> assert false
- in
-
- (* NB: We are looping over the PRECEDING fields in reverse order. *)
- let rec loop = function
- (* first field has constant offset 0 *)
- | [] -> Some 0
- (* preceding field with constant offset & length *)
- | f :: _
- when has_constant_offset f && has_constant_len f ->
- Some (get_constant_offset f + get_constant_len f)
- (* preceding field with no offset & constant length *)
- | f :: fs
- when P.get_offset f = None && has_constant_len f ->
- (match loop fs with
- | None -> None
- | Some offset -> Some (offset + get_constant_len f))
- (* else, can't work out the offset *)
- | _ -> None
- in
-
- let natural_field_offset = loop fields in
-
- let field_offset =
- match P.get_offset field with
- | None -> natural_field_offset
- | Some expr -> (* has an offset() clause *)
- match expr_is_constant expr with
- | None -> None
- | i -> i in
-
- natural_field_offset, field_offset in
-
- (* Also compute if the field_offset is known to be byte-aligned at
- * compile time, which is usually both the common and best possible
- * case for generating optimized code.
- *
- * This is None if not aligned / don't know.
- * Or Some byte_offset if we can work it out.
- *)
- let field_offset_aligned =
- match field_offset with
- | None -> None (* unknown, assume no *)
- | Some off when off land 7 = 0 -> Some (off lsr 3)
- | Some _ -> None in (* definitely no *)
-
- (* Now build the code which matches a single field. *)
- let int_extract_const i endian signed =
- build_bitstring_call _loc ExtractFunc (Some i) endian signed in
- let int_extract endian signed =
- build_bitstring_call _loc ExtractFunc None endian signed in
-
- let expr =
- match t, flen_is_const, field_offset_aligned, endian, signed with
- (* Very common cases: int field, constant 8/16/32/64 bit
- * length, aligned to the match at a known offset. We
- * still have to check if the bitstring is aligned (can only
- * be known at runtime) but we may be able to directly access
- * the bytes in the string.
- *)
- | P.Int, Some 8, Some field_byte_offset, _, signed ->
- let extract_fn = int_extract_const 8 endian signed in
-
- (* The fast-path code when everything is aligned. *)
- let fastpath =
- <:expr<
- let o =
- ($lid:original_off$ lsr 3) + $`int:field_byte_offset$ in
- Bitstring.char_code (String.unsafe_get $lid:data$ o)
- >> in
-
- <:expr<
- if $lid:len$ >= 8 then (
- let v =
- if not $`bool:signed$ && $lid:off_aligned$ then
- $fastpath$
- else
- $extract_fn$ $lid:data$ $lid:off$ $lid:len$ 8 in
- let $lid:off$ = $lid:off$ + 8
- and $lid:len$ = $lid:len$ - 8 in
- match v with $fpatt$ when true -> $expr$ | _ -> ()
- )
- >>
-
- | P.Int, Some ((16|32|64) as i),
- Some field_byte_offset, (P.ConstantEndian _ as endian), signed ->
- let extract_fn = int_extract_const i endian signed in
-
- (* The fast-path code when everything is aligned. *)
- let fastpath =
- let fastpath_call =
- let endian = match endian with
- | P.ConstantEndian BigEndian -> "be"
- | P.ConstantEndian LittleEndian -> "le"
- | P.ConstantEndian NativeEndian -> "ne"
- | P.EndianExpr _ -> assert false in
- let signed = if signed then "signed" else "unsigned" in
- let name =
- sprintf "extract_fastpath_int%d_%s_%s" i endian signed in
- match i with
- | 16 ->
- <:expr< Bitstring.$lid:name$ $lid:data$ o >>
- | 32 ->
- <:expr< Bitstring.$lid:name$ $lid:data$ o >>
- | 64 ->
- <:expr< Bitstring.$lid:name$ $lid:data$ o >>
- | _ -> assert false in
- <:expr<
- (* Starting offset within the string. *)
- let o =
- ($lid:original_off$ lsr 3) + $`int:field_byte_offset$ in
- $fastpath_call$
- >> in
-
- let slowpath =
- <:expr<
- $extract_fn$ $lid:data$ $lid:off$ $lid:len$ $`int:i$
- >> in
-
- <:expr<
- if $lid:len$ >= $`int:i$ then (
- let v =
- if $lid:off_aligned$ then $fastpath$ else $slowpath$ in
- let $lid:off$ = $lid:off$ + $`int:i$
- and $lid:len$ = $lid:len$ - $`int:i$ in
- match v with $fpatt$ when true -> $expr$ | _ -> ()
- )
- >>
-
- (* Common case: int field, constant flen *)
- | P.Int, Some i, _, _, _ when i > 0 && i <= 64 ->
- let extract_fn = int_extract_const i endian signed in
- let v = gensym "val" in
- <:expr<
- if $lid:len$ >= $`int:i$ then (
- let $lid:v$ =
- $extract_fn$ $lid:data$ $lid:off$ $lid:len$ $`int:i$ in
- let $lid:off$ = $lid:off$ + $`int:i$
- and $lid:len$ = $lid:len$ - $`int:i$ in
- match $lid:v$ with $fpatt$ when true -> $expr$ | _ -> ()
- )
- >>
-
- | P.Int, Some _, _, _, _ ->
- fail "length of int field must be [1..64]"
-
- (* Int field, non-const flen. We have to test the range of
- * the field at runtime. If outside the range it's a no-match
- * (not an error).
- *)
- | P.Int, None, _, _, _ ->
- let extract_fn = int_extract endian signed in
- let v = gensym "val" in
- <:expr<
- if $flen$ >= 1 && $flen$ <= 64 && $flen$ <= $lid:len$ then (
- let $lid:v$ =
- $extract_fn$ $lid:data$ $lid:off$ $lid:len$ $flen$ in
- let $lid:off$ = $lid:off$ + $flen$
- and $lid:len$ = $lid:len$ - $flen$ in
- match $lid:v$ with $fpatt$ when true -> $expr$ | _ -> ()
- )
- >>
-
- (* String, constant flen > 0.
- * The field is at a known byte-aligned offset so we may
- * be able to optimize the substring extraction.
- *)
- | P.String, Some i, Some field_byte_offset, _, _
- when i > 0 && i land 7 = 0 ->
- let fastpath =
- <:expr<
- (* Starting offset within the string. *)
- let o =
- ($lid:original_off$ lsr 3) + $`int:field_byte_offset$ in
- String.sub $lid:data$ o $`int:(i lsr 3)$
- >> in
-
- let slowpath =
- <:expr<
- Bitstring.string_of_bitstring
- ($lid:data$, $lid:off$, $`int:i$)
- >> in
-
- let cond =
- <:expr<
- if $lid:off_aligned$ then $fastpath$ else $slowpath$
- >> in
-
- <:expr<
- if $lid:len$ >= $`int:i$ then (
- let str = $cond$ in
- let $lid:off$ = $lid:off$ + $`int:i$
- and $lid:len$ = $lid:len$ - $`int:i$ in
- match str with
- | $fpatt$ when true -> $expr$
- | _ -> ()
- )
- >>
-
- (* String, constant flen > 0. *)
- | P.String, Some i, None, _, _ when i > 0 && i land 7 = 0 ->
- <:expr<
- if $lid:len$ >= $`int:i$ then (
- let str =
- Bitstring.string_of_bitstring
- ($lid:data$, $lid:off$, $`int:i$) in
- let $lid:off$ = $lid:off$ + $`int:i$
- and $lid:len$ = $lid:len$ - $`int:i$ in
- match str with
- | $fpatt$ when true -> $expr$
- | _ -> ()
- )
- >>
-
- (* String, constant flen = -1, means consume all the
- * rest of the input.
- * XXX It should be possible to optimize this for known byte
- * offset, but the optimization is tricky because the end/length
- * of the string may not be byte-aligned.
- *)
- | P.String, Some i, _, _, _ when i = -1 ->
- let str = gensym "str" in
-
- <:expr<
- let $lid:str$ =
- Bitstring.string_of_bitstring
- ($lid:data$, $lid:off$, $lid:len$) in
- let $lid:off$ = $lid:off$ + $lid:len$ in
- let $lid:len$ = 0 in
- match $lid:str$ with
- | $fpatt$ when true -> $expr$
- | _ -> ()
- >>
-
- | P.String, Some _, _, _, _ ->
- fail "length of string must be > 0 and a multiple of 8, or the special value -1"
-
- (* String field, non-const flen. We check the flen is > 0
- * and a multiple of 8 (-1 is not allowed here), at runtime.
- *)
- | P.String, None, _, _, _ ->
- let bs = gensym "bs" in
- <:expr<
- if $flen$ >= 0 && $flen$ <= $lid:len$
- && $flen$ land 7 = 0 then (
- let $lid:bs$ = ($lid:data$, $lid:off$, $flen$) in
- let $lid:off$ = $lid:off$ + $flen$
- and $lid:len$ = $lid:len$ - $flen$ in
- match Bitstring.string_of_bitstring $lid:bs$ with
- | $fpatt$ when true -> $expr$
- | _ -> ()
- )
- >>
-
- (* Bitstring, constant flen >= 0.
- * At the moment all we can do is assign the bitstring to an
- * identifier.
- *)
- | P.Bitstring, Some i, _, _, _ when i >= 0 ->
- let ident =
- match fpatt with
- | <:patt< $lid:ident$ >> -> ident
- | <:patt< _ >> -> "_"
- | _ ->
- fail "cannot compare a bitstring to a constant" in
- <:expr<
- if $lid:len$ >= $`int:i$ then (
- let $lid:ident$ = ($lid:data$, $lid:off$, $`int:i$) in
- let $lid:off$ = $lid:off$ + $`int:i$
- and $lid:len$ = $lid:len$ - $`int:i$ in
- $expr$
- )
- >>
-
- (* Bitstring, constant flen = -1, means consume all the
- * rest of the input.
- *)
- | P.Bitstring, Some i, _, _, _ when i = -1 ->
- let ident =
- match fpatt with
- | <:patt< $lid:ident$ >> -> ident
- | <:patt< _ >> -> "_"
- | _ ->
- fail "cannot compare a bitstring to a constant" in
- <:expr<
- let $lid:ident$ = ($lid:data$, $lid:off$, $lid:len$) in
- let $lid:off$ = $lid:off$ + $lid:len$ in
- let $lid:len$ = 0 in
- $expr$
- >>
-
- | P.Bitstring, Some _, _, _, _ ->
- fail "length of bitstring must be >= 0 or the special value -1"
-
- (* Bitstring field, non-const flen. We check the flen is >= 0
- * (-1 is not allowed here) at runtime.
- *)
- | P.Bitstring, None, _, _, _ ->
- let ident =
- match fpatt with
- | <:patt< $lid:ident$ >> -> ident
- | <:patt< _ >> -> "_"
- | _ ->
- fail "cannot compare a bitstring to a constant" in
- <:expr<
- if $flen$ >= 0 && $flen$ <= $lid:len$ then (
- let $lid:ident$ = ($lid:data$, $lid:off$, $flen$) in
- let $lid:off$ = $lid:off$ + $flen$
- and $lid:len$ = $lid:len$ - $flen$ in
- $expr$
- )
- >>
- in
-
- (* Computed offset: only offsets forward are supported.
- *
- * We try hard to optimize this based on what we know. Are
- * we at a predictable offset now? (Look at the outer 'fields'
- * list and see if they all have constant field length starting
- * at some constant offset). Is this offset constant?
- *
- * Based on this we can do a lot of the computation at
- * compile time, or defer it to runtime only if necessary.
- *
- * In all cases, the off and len fields get updated.
- *)
- let expr =
- match P.get_offset field with
- | None -> expr (* common case: there was no offset expression *)
- | Some offset_expr ->
- (* This will be [Some i] if offset is a constant expression
- * or [None] if it's a non-constant.
- *)
- let requested_offset = expr_is_constant offset_expr in
-
- (* Look at the field offset (if known) and requested offset
- * cases and determine what code to generate.
- *)
- match natural_field_offset, requested_offset with
- (* This is the good case: both the field offset and
- * the requested offset are constant, so we can remove
- * almost all the runtime checks.
- *)
- | Some natural_field_offset, Some requested_offset ->
- let move = requested_offset - natural_field_offset in
- if move < 0 then
- fail (sprintf "requested offset is less than the field offset (%d < %d)" requested_offset natural_field_offset);
- (* Add some code to move the offset and length by a
- * constant amount, and a runtime test that len >= 0
- * (XXX possibly the runtime test is unnecessary?)
- *)
- <:expr<
- let $lid:off$ = $lid:off$ + $`int:move$ in
- let $lid:len$ = $lid:len$ - $`int:move$ in
- if $lid:len$ >= 0 then $expr$
- >>
- (* In any other case, we need to use runtime checks.
- *
- * XXX It's not clear if a backwards move detected at runtime
- * is merely a match failure, or a runtime error. At the
- * moment it's just a match failure since bitmatch generally
- * doesn't raise runtime errors.
- *)
- | _ ->
- let move = gensym "move" in
- <:expr<
- let $lid:move$ =
- $offset_expr$ - ($lid:off$ - $lid:original_off$) in
- if $lid:move$ >= 0 then (
- let $lid:off$ = $lid:off$ + $lid:move$ in
- let $lid:len$ = $lid:len$ - $lid:move$ in
- if $lid:len$ >= 0 then $expr$
- )
- >> in (* end of computed offset code *)
-
- (* save_offset_to(patt) saves the current offset into a variable. *)
- let expr =
- match P.get_save_offset_to field with
- | None -> expr (* no save_offset_to *)
- | Some patt ->
- <:expr<
- let $patt$ = $lid:off$ - $lid:original_off$ in
- $expr$
- >> in
-
- (* Emit extra debugging code. *)
- let expr =
- if not debug then expr else (
- let field = P.string_of_pattern_field field in
-
- <:expr<
- if !Bitstring.debug then (
- Printf.eprintf "PA_BITSTRING: TEST:\n";
- Printf.eprintf " %s\n" $str:field$;
- Printf.eprintf " off %d len %d\n%!" $lid:off$ $lid:len$;
- (*Bitstring.hexdump_bitstring stderr
- ($lid:data$,$lid:off$,$lid:len$);*)
- );
- $expr$
- >>
- ) in
-
- output_field_extraction expr fields
- in
-
- (* Convert each case in the match. *)
- let cases = List.map (
- fun (fields, bind, whenclause, code) ->
- let inner = <:expr< $lid:result$ := Some ($code$); raise Exit >> in
- let inner =
- match whenclause with
- | Some whenclause ->
- <:expr< if $whenclause$ then $inner$ >>
- | None -> inner in
- let inner =
- match bind with
- | Some name ->
- <:expr<
- let $lid:name$ = ($lid:data$,
- $lid:original_off$, $lid:original_len$) in
- $inner$
- >>
- | None -> inner in
- output_field_extraction inner (List.rev fields)
- ) cases in
-
- (* Join them into a single expression.
- *
- * Don't do it with a normal fold_right because that leaves
- * 'raise Exit; ()' at the end which causes a compiler warning.
- * Hence a bit of complexity here.
- *
- * Note that the number of cases is always >= 1 so List.hd is safe.
- *)
- let cases = List.rev cases in
- let cases =
- List.fold_left (fun base case -> <:expr< $case$ ; $base$ >>)
- (List.hd cases) (List.tl cases) in
-
- (* The final code just wraps the list of cases in a
- * try/with construct so that each case is tried in
- * turn until one case matches (that case sets 'result'
- * and raises 'Exit' to leave the whole statement).
- * If result isn't set by the end then we will raise
- * Match_failure with the location of the bitmatch
- * statement in the original code.
- *)
- let loc_fname = Loc.file_name _loc in
- let loc_line = string_of_int (Loc.start_line _loc) in
- let loc_char = string_of_int (Loc.start_off _loc - Loc.start_bol _loc) in
-
- <:expr<
- (* Note we save the original offset/length at the start of the match
- * in 'original_off'/'original_len' symbols. 'data' never changes.
- * This code also ensures that if original_off/original_len/off_aligned
- * aren't actually used, we don't get a warning.
- *)
- let ($lid:data$, $lid:original_off$, $lid:original_len$) = $bs$ in
- let $lid:off$ = $lid:original_off$ and $lid:len$ = $lid:original_len$ in
- let $lid:off_aligned$ = $lid:off$ land 7 = 0 in
- ignore $lid:off_aligned$;
- let $lid:result$ = ref None in
- (try
- $cases$
- with Exit -> ());
- match ! $lid:result$ with
- | Some x -> x
- | None -> raise (Match_failure ($str:loc_fname$,
- $int:loc_line$, $int:loc_char$))
- >>
-
-(* Add a named pattern. *)
-let add_named_pattern _loc name pattern =
- Hashtbl.add pattern_hash name pattern
-
-(* Expand a named pattern from the pattern_hash. *)
-let expand_named_pattern _loc name =
- try Hashtbl.find pattern_hash name
- with Not_found ->
- locfail _loc (sprintf "named pattern not found: %s" name)
-
-(* Add named patterns from a file. See the documentation on the
- * directory search path in bitstring_persistent.mli
- *)
-let load_patterns_from_file _loc filename =
- let chan =
- if Filename.is_relative filename && Filename.is_implicit filename then (
- (* Try current directory. *)
- try open_in filename
- with _ ->
- (* Try OCaml library directory. *)
- try open_in (Filename.concat Bitstring_config.ocamllibdir filename)
- with exn -> Loc.raise _loc exn
- ) else (
- try open_in filename
- with exn -> Loc.raise _loc exn
- ) in
- let names = ref [] in
- (try
- let rec loop () =
- let name = P.named_from_channel chan in
- names := name :: !names
- in
- loop ()
- with End_of_file -> ()
- );
- close_in chan;
- let names = List.rev !names in
- List.iter (
- function
- | name, P.Pattern patt ->
- if patt = [] then
- locfail _loc (sprintf "pattern %s: no fields" name);
- add_named_pattern _loc name patt
- | _, P.Constructor _ -> () (* just ignore these for now *)
- ) names
-
-EXTEND Gram
- GLOBAL: expr str_item;
-
- (* Qualifiers are a list of identifiers ("string", "bigendian", etc.)
- * followed by an optional expression (used in certain cases). Note
- * that we are careful not to declare any explicit reserved words.
- *)
- qualifiers: [
- [ LIST0
- [ q = LIDENT;
- e = OPT [ "("; e = expr; ")" -> e ] -> (q, e) ]
- SEP "," ]
- ];
-
- (* Field used in the bitmatch operator (a pattern). This can actually
- * return multiple fields, in the case where the 'field' is a named
- * persitent pattern.
- *)
- patt_field: [
- [ fpatt = patt; ":"; len = expr LEVEL "top";
- qs = OPT [ ":"; qs = qualifiers -> qs ] ->
- let field = P.create_pattern_field _loc in
- let field = P.set_patt field fpatt in
- let field = P.set_length field len in
- [parse_field _loc field qs] (* Normal, single field. *)
- | ":"; name = LIDENT ->
- expand_named_pattern _loc name (* Named -> list of fields. *)
- ]
- ];
-
- (* Case inside bitmatch operator. *)
- patt_fields: [
- [ "{";
- fields = LIST0 patt_field SEP ";";
- "}" ->
- List.concat fields
- | "{";
- "_";
- "}" ->
- []
- ]
- ];
-
- patt_case: [
- [ fields = patt_fields;
- bind = OPT [ "as"; name = LIDENT -> name ];
- whenclause = OPT [ "when"; e = expr -> e ]; "->";
- code = expr ->
- (fields, bind, whenclause, code)
- ]
- ];
-
- (* Field used in the BITSTRING constructor (an expression). *)
- constr_field: [
- [ fexpr = expr LEVEL "top"; ":"; len = expr LEVEL "top";
- qs = OPT [ ":"; qs = qualifiers -> qs ] ->
- let field = P.create_constructor_field _loc in
- let field = P.set_expr field fexpr in
- let field = P.set_length field len in
- parse_field _loc field qs
- ]
- ];
-
- constr_fields: [
- [ "{";
- fields = LIST0 constr_field SEP ";";
- "}" ->
- fields
- ]
- ];
-
- (* 'bitmatch' expressions. *)
- expr: LEVEL ";" [
- [ "bitmatch";
- bs = expr; "with"; OPT "|";
- cases = LIST1 patt_case SEP "|" ->
- output_bitmatch _loc bs cases
- ]
-
- (* Constructor. *)
- | [ "BITSTRING";
- fields = constr_fields ->
- output_constructor _loc fields
- ]
- ];
-
- (* Named persistent patterns.
- *
- * NB: Currently only allowed at the top level. We can probably lift
- * this restriction later if necessary. We only deal with patterns
- * at the moment, not constructors, but the infrastructure to do
- * constructors is in place.
- *)
- str_item: LEVEL "top" [
- [ "let"; "bitmatch";
- name = LIDENT; "="; fields = patt_fields ->
- add_named_pattern _loc name fields;
- (* The statement disappears, but we still need a str_item so ... *)
- <:str_item< >>
- | "open"; "bitmatch"; filename = STRING ->
- load_patterns_from_file _loc filename;
- <:str_item< >>
- ]
- ];
-
-END
diff --git a/ppx/.merlin b/ppx/.merlin
new file mode 100644
index 0000000..901f85c
--- /dev/null
+++ b/ppx/.merlin
@@ -0,0 +1,9 @@
+B ../_build/default/ppx
+FLG -ppx '/Users/xguerin/Workspace/bitstring/_build/default/.ppx/ppx_tools_versioned.metaquot_405/ppx.exe --as-ppx --cookie '\''library-name="ppx_bitstring"'\'''
+FLG -w -40
+PKG compiler-libs
+PKG compiler-libs.common
+PKG ocaml-migrate-parsetree
+PKG ppx_tools_versioned
+PKG result
+PKG str
diff --git a/ppx/jbuild b/ppx/jbuild
new file mode 100644
index 0000000..9f38577
--- /dev/null
+++ b/ppx/jbuild
@@ -0,0 +1,13 @@
+(jbuild_version 1)
+
+(library
+ ((name ppx_bitstring)
+ (public_name bitstring.ppx)
+ (kind ppx_rewriter)
+ (libraries (str
+ compiler-libs
+ ppx_tools_versioned
+ ocaml-migrate-parsetree
+ ))
+ (preprocess (pps (ppx_tools_versioned.metaquot_405)))
+ ))
diff --git a/ppx/ppx_bitstring.ml b/ppx/ppx_bitstring.ml
new file mode 100644
index 0000000..53cc6d7
--- /dev/null
+++ b/ppx/ppx_bitstring.ml
@@ -0,0 +1,1235 @@
+(*
+ * Copyright (c) 2016 Xavier R. Guérin <copyright@applepine.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *)
+
+open Migrate_parsetree
+open Ast_405
+
+open Ast_convenience_405
+open Ast_mapper
+open Asttypes
+open Parsetree
+open Lexing
+open Printf
+
+(*
+ * Version management
+ *)
+
+let ocaml_version = Versions.ocaml_405
+
+(* Type definition *)
+
+module Entity = struct
+ type t = {
+ txt : string;
+ exp : Parsetree.expression;
+ pat : Parsetree.pattern
+ }
+
+ let mksym =
+ let i = ref 1000 in
+ fun name ->
+ incr i; let i = !i in
+ sprintf "__ppxbitstring_%s_%d" name i
+ ;;
+
+ let make ~loc v =
+ let txt = mksym v in
+ { txt; exp = evar ~loc txt; pat = pvar ~loc txt }
+end
+
+module Context = struct
+ type t = {
+ dat : Entity.t;
+ off : Entity.t;
+ len : Entity.t
+ }
+
+ let make ~loc =
+ let dat = Entity.make ~loc "dat"
+ and off = Entity.make ~loc "off"
+ and len = Entity.make ~loc "len"
+ in
+ { dat; off; len }
+
+ let next ~loc t =
+ let off = Entity.make ~loc "off"
+ and len = Entity.make ~loc "len"
+ in
+ { t with off; len }
+end
+
+module Type = struct
+ type t =
+ | Int
+ | String
+ | Bitstring
+end
+
+module Sign = struct
+ type t =
+ | Signed
+ | Unsigned
+
+ let to_string = function
+ | Signed -> "signed"
+ | Unsigned -> "unsigned"
+end
+
+module Endian = struct
+ type t =
+ | Little
+ | Big
+ | Native
+ | Referred of Parsetree.expression
+
+ let to_string = function
+ | Little -> "le"
+ | Big -> "be"
+ | Native -> "ne"
+ | Referred _ -> "ee"
+end
+
+module Qualifiers = struct
+ type t = {
+ value_type : Type.t option;
+ sign : Sign.t option;
+ endian : Endian.t option;
+ check : Parsetree.expression option;
+ bind : Parsetree.expression option;
+ map : Parsetree.expression option;
+ save_offset_to : Parsetree.expression option;
+ offset : Parsetree.expression option;
+ }
+
+ let empty = {
+ value_type = None;
+ sign = None;
+ endian = None;
+ check = None;
+ bind = None;
+ map = None;
+ save_offset_to = None;
+ offset = None;
+ }
+
+ let default = {
+ value_type = Some Type.Int;
+ sign = Some Sign.Unsigned;
+ endian = Some Endian.Big;
+ check = None;
+ bind = None;
+ map = None;
+ save_offset_to = None;
+ offset = None;
+ }
+
+ let set_value_type_default q =
+ match q.value_type with
+ | None -> { q with value_type = Some Type.Int }
+ | _ -> q
+ ;;
+
+ let set_sign_default q =
+ match q.sign with
+ | None -> { q with sign = Some Sign.Unsigned }
+ | _ -> q
+ ;;
+
+ let set_endian_default q =
+ match q.endian with
+ | None -> { q with endian = Some Endian.Big }
+ | _ -> q
+ ;;
+
+ let set_defaults v =
+ v
+ |> set_value_type_default
+ |> set_sign_default
+ |> set_endian_default
+ ;;
+end
+
+module MatchField = struct
+ type bitlen =
+ (Parsetree.expression * int option)
+ ;;
+
+ type tuple = {
+ pat : Parsetree.pattern;
+ len : bitlen;
+ qls : Qualifiers.t;
+ opt : bool
+ }
+
+ type t =
+ | Any of Parsetree.pattern
+ | Tuple of tuple
+ ;;
+end
+
+(* Exception *)
+
+let location_exn ~loc msg =
+ Location.Error (Location.error ~loc msg)
+ |> raise
+;;
+
+(* Helper functions *)
+
+let split_string ~on s =
+ Str.split (Str.regexp on) s
+;;
+
+let option_bind opt f =
+ match opt with
+ | None -> None
+ | Some v -> f v
+;;
+
+let rec process_expr_loc ~loc expr =
+ match expr with
+ | { pexp_desc = Pexp_ident(ident) } ->
+ let lident = Location.mkloc ident.txt loc in
+ { expr with pexp_desc = Pexp_ident(lident); pexp_loc = loc }
+ | { pexp_desc = Pexp_tuple(ops) } ->
+ let fld = List.fold_left
+ (fun acc exp -> acc @ [ process_expr_loc ~loc exp ])
+ []
+ ops
+ in { expr with pexp_desc = Pexp_tuple(fld); pexp_loc = loc }
+ | { pexp_desc = Pexp_construct(ident, ops) } ->
+ let lident = Location.mkloc ident.txt loc in
+ let lops = begin match ops with
+ | Some o -> Some (process_expr_loc ~loc o)
+ | None -> None
+ end in
+ { expr with pexp_desc = Pexp_construct(lident, lops); pexp_loc = loc }
+ | { pexp_desc = Pexp_apply(ident, ops) } ->
+ let lident = process_expr_loc ~loc ident in
+ let fld = List.fold_left
+ (fun acc (lbl, exp) -> acc @ [ (lbl, (process_expr_loc ~loc exp)) ])
+ []
+ ops
+ in { expr with pexp_desc = Pexp_apply(lident, fld); pexp_loc = loc }
+ | { pexp_desc = Pexp_fun(ident, ops,
+ { ppat_desc = Ppat_var(pid); ppat_loc; ppat_attributes },
+ exp) } ->
+ let lpid = Location.mkloc pid.txt loc in
+ let lpat = { ppat_desc = Ppat_var lpid; ppat_loc = loc; ppat_attributes } in
+ let lops = begin match ops with
+ | Some o -> Some (process_expr_loc ~loc o)
+ | None -> None
+ end in
+ let lexp = process_expr_loc ~loc exp in
+ { expr with pexp_desc = Pexp_fun(ident, lops, lpat, lexp); pexp_loc = loc }
+ | _ ->
+ { expr with pexp_loc = loc }
+;;
+
+let parse_expr expr =
+ try
+ Parse.expression Versions.ocaml_405 (Lexing.from_string expr.txt)
+ |> process_expr_loc ~loc:expr.loc
+ with
+ _ -> location_exn ~loc:expr.loc ("Parse expression error: '" ^ expr.txt ^ "'")
+;;
+
+let rec process_pat_loc ~loc pat =
+ match pat with
+ | { ppat_desc = Ppat_var(ident); ppat_loc; ppat_attributes } ->
+ let lident = Location.mkloc ident.txt loc in
+ { ppat_desc = Ppat_var(lident); ppat_loc = loc; ppat_attributes }
+ | _ ->
+ { pat with ppat_loc = loc }
+;;
+
+let parse_pattern pat =
+ try
+ Parse.pattern Versions.ocaml_405 (Lexing.from_string pat.txt)
+ |> process_pat_loc ~loc:pat.loc
+ with
+ _ -> location_exn ~loc:pat.loc ("Parse pattern error: '" ^ pat.txt ^ "'")
+;;
+
+(* Location parser and splitter *)
+
+let find_loc_boundaries ~loc last rem =
+ let open Location in
+ let { loc_start; loc_end; loc_ghost } = loc in
+ let xtr_lines = List.length rem in
+ let xtr_char = List.fold_left (+) xtr_lines rem in
+ let ne = { loc_start with
+ pos_lnum = loc_start.pos_lnum + xtr_lines;
+ pos_bol = loc_start.pos_bol + xtr_char;
+ pos_cnum = loc_start.pos_cnum + xtr_char + last
+ }
+ and ns = if xtr_lines = 0
+ then { loc_start with
+ pos_cnum = loc_start.pos_cnum + xtr_char + last + 1
+ }
+ else { loc_start with
+ pos_lnum = loc_start.pos_lnum + xtr_lines;
+ pos_bol = loc_start.pos_bol + xtr_char;
+ pos_cnum = loc_start.pos_cnum + xtr_char
+ } in
+ let tloc = { loc_start; loc_end = ne; loc_ghost } in
+ let nloc = { loc_start = ns; loc_end; loc_ghost } in
+ (tloc, nloc)
+;;
+
+let rec split_loc_rec ~loc = function
+ | [] -> []
+ | hd :: tl ->
+ let line_list = split_string ~on:"\n" hd
+ |> List.rev
+ |> List.map String.length in
+ begin
+ match line_list with
+ | [] -> []
+ | last::rem ->
+ let (tloc, nloc) = find_loc_boundaries ~loc last rem in
+ [ tloc ] @ (split_loc_rec ~loc:nloc tl)
+ end
+;;
+
+let split_loc ~loc lst =
+ split_loc_rec ~loc lst
+ |> List.map2 (fun e loc -> Location.mkloc (String.trim e) loc) lst
+;;
+
+(* Processing qualifiers *)
+
+let check_map_functor sub =
+ match sub with
+ | [%expr (fun [%p? _] -> [%e? _])] -> Some (sub)
+ | _ -> None
+;;
+
+let process_qual state qual =
+ let open Qualifiers in
+ let loc = qual.pexp_loc in
+ match qual with
+ | [%expr int] ->
+ begin match state.value_type with
+ | Some v -> location_exn ~loc "Value type redefined"
+ | None -> { state with value_type = Some Type.Int }
+ end
+ | [%expr string] ->
+ begin match state.value_type with
+ | Some v -> location_exn ~loc "Value type redefined"
+ | None -> { state with value_type = Some Type.String }
+ end
+ | [%expr bitstring] ->
+ begin match state.value_type with
+ | Some v -> location_exn ~loc "Value type redefined"
+ | None -> { state with value_type = Some Type.Bitstring }
+ end
+ | [%expr signed] ->
+ begin match state.sign with
+ | Some v -> location_exn ~loc "Signedness redefined"
+ | None -> { state with sign = Some Sign.Signed }
+ end
+ | [%expr unsigned] ->
+ begin match state.sign with
+ | Some v -> location_exn ~loc "Signedness redefined"
+ | None -> { state with sign = Some Sign.Unsigned }
+ end
+ | [%expr littleendian] ->
+ begin match state.endian with
+ | Some v -> location_exn ~loc "Endianness redefined"
+ | None -> { state with endian = Some Endian.Little }
+ end
+ | [%expr bigendian] ->
+ begin match state.endian with
+ | Some v -> location_exn ~loc "Endianness redefined"
+ | None -> { state with endian = Some Endian.Big }
+ end
+ | [%expr nativeendian] ->
+ begin match state.endian with
+ | Some v -> location_exn ~loc "Endianness redefined"
+ | None -> { state with endian = Some Endian.Native }
+ end
+ | [%expr endian [%e? sub]] ->
+ begin match state.endian with
+ | Some v -> location_exn ~loc "Endianness redefined"
+ | None -> { state with endian = Some (Endian.Referred sub) }
+ end
+ | [%expr bind [%e? sub]] ->
+ begin match state.bind, state.map with
+ | Some b, None -> location_exn ~loc "Bind expression redefined"
+ | None, Some m -> location_exn ~loc "Map expression already defined"
+ | Some b, Some m -> location_exn ~loc "Inconsistent internal state"
+ | None, None -> { state with bind = Some sub }
+ end
+ | [%expr map [%e? sub]] ->
+ begin match state.bind, state.map with
+ | Some b, None -> location_exn ~loc "Bind expression already defined"
+ | None, Some m -> location_exn ~loc "Map expression redefined"
+ | Some b, Some m -> location_exn ~loc "Inconsistent internal state"
+ | None, None -> begin
+ match check_map_functor sub with
+ | Some sub -> { state with map = Some sub }
+ | None -> location_exn ~loc "Invalid map functor"
+ end
+ end
+ | [%expr check [%e? sub]] ->
+ begin match state.check with
+ | Some v -> location_exn ~loc "Check expression redefined"
+ | None -> { state with check = Some sub }
+ end
+ | [%expr save_offset_to [%e? sub]] ->
+ begin match state.save_offset_to with
+ | Some v -> location_exn ~loc "Save offset expression redefined"
+ | None -> { state with save_offset_to = Some sub }
+ end
+ | [%expr offset [%e? sub]] ->
+ begin match state.offset with
+ | Some v -> location_exn ~loc "Offset expression redefined"
+ | None -> { state with offset = Some sub }
+ end
+ | _ ->
+ location_exn ~loc "Invalid qualifier"
+;;
+
+let parse_quals quals =
+ let expr = parse_expr quals in
+ let rec process_quals state = function
+ | [] -> state
+ | hd :: tl -> process_quals (process_qual state hd) tl
+ in match expr with
+ (* single named qualifiers *)
+ | { pexp_desc = Pexp_ident (_) } ->
+ process_qual Qualifiers.empty expr
+ (* single functional qualifiers *)
+ | { pexp_desc = Pexp_apply (_, _) } ->
+ process_qual Qualifiers.empty expr
+ (* multiple qualifiers *)
+ | { pexp_desc = Pexp_tuple (e) } ->
+ process_quals Qualifiers.empty e
+ (* Unrecognized expression *)
+ | expr ->
+ location_exn ~loc:expr.pexp_loc "Invalid qualifiers list"
+;;
+
+(* Processing expression *)
+
+let rec evaluate_expr = function
+ | [%expr [%e? lhs] + [%e? rhs]] ->
+ begin match evaluate_expr lhs, evaluate_expr rhs with
+ | Some l, Some r -> Some (l + r)
+ | _ -> None
+ end
+ | [%expr [%e? lhs] - [%e? rhs]] ->
+ begin match evaluate_expr lhs, evaluate_expr rhs with
+ | Some l, Some r -> Some (l - r)
+ | _ -> None
+ end
+ | [%expr [%e? lhs] * [%e? rhs]] ->
+ begin match evaluate_expr lhs, evaluate_expr rhs with
+ | Some l, Some r -> Some (l * r)
+ | _ -> None
+ end
+ | [%expr [%e? lhs] / [%e? rhs]] ->
+ begin match evaluate_expr lhs, evaluate_expr rhs with
+ | Some l, Some r -> Some (l / r)
+ | _ -> None
+ end
+ | [%expr [%e? lhs] land [%e? rhs]] ->
+ begin match evaluate_expr lhs, evaluate_expr rhs with
+ | Some l, Some r -> Some (l land r)
+ | _ -> None
+ end
+ | [%expr [%e? lhs] lor [%e? rhs]] ->
+ begin match evaluate_expr lhs, evaluate_expr rhs with
+ | Some l, Some r -> Some (l lor r)
+ | _ -> None
+ end
+ | [%expr [%e? lhs] lxor [%e? rhs]] ->
+ begin match evaluate_expr lhs, evaluate_expr rhs with
+ | Some l, Some r -> Some (l lxor r)
+ | _ -> None
+ end
+ | [%expr [%e? lhs] lsr [%e? rhs]] ->
+ begin match evaluate_expr lhs, evaluate_expr rhs with
+ | Some l, Some r -> Some (l lsr r)
+ | _ -> None
+ end
+ | [%expr [%e? lhs] asr [%e? rhs]] ->
+ begin match evaluate_expr lhs, evaluate_expr rhs with
+ | Some l, Some r -> Some (l asr r)
+ | _ -> None
+ end
+ | [%expr [%e? lhs] mod [%e? rhs]] ->
+ begin match evaluate_expr lhs, evaluate_expr rhs with
+ | Some l, Some r -> Some (l mod r)
+ | _ -> None
+ end
+ | { pexp_desc = Pexp_constant (const) } ->
+ begin match const with
+ | Pconst_integer(i, _) -> Some (int_of_string i)
+ | _ -> None
+ end
+ | _ -> None
+;;
+
+(* Parsing fields *)
+
+let parse_match_fields str =
+ let open MatchField in
+ split_string ~on:":" str.txt
+ |> split_loc ~loc:str.loc
+ |> function
+ | [ { txt = "_" ; loc } as pat ] ->
+ MatchField.Any (parse_pattern pat)
+ | [ spat; slen ] ->
+ let qls = Qualifiers.default
+ and eln = parse_expr slen
+ and pat = parse_pattern spat
+ and opt = false in
+ let len = (eln, evaluate_expr eln) in
+ MatchField.Tuple { pat; len; qls; opt }
+ | [ spat; slen; sqls ] ->
+ let qls = Qualifiers.set_defaults (parse_quals sqls)
+ and eln = parse_expr slen
+ and pat = parse_pattern spat
+ and opt = false in
+ let len = (eln, evaluate_expr eln) in
+ MatchField.Tuple { pat; len; qls; opt }
+ | [ stmt ] ->
+ let pat_str = stmt.txt in
+ location_exn ~loc:stmt.loc ("Invalid statement: '" ^ pat_str ^ "'")
+ | _ ->
+ location_exn ~loc:str.loc "Invalid number of fields in statement"
+;;
+
+let parse_const_fields str =
+ let open Qualifiers in
+ split_string ~on:":" str.txt
+ |> split_loc ~loc:str.loc
+ |> function
+ | [ vl; len ] ->
+ (parse_expr vl, Some (parse_expr len), Some Qualifiers.default)
+ | [ vl; len; quals ] ->
+ let q = Qualifiers.set_defaults (parse_quals quals) in
+ begin match q.bind, q.map, q.check, q.save_offset_to with
+ | Some _, _, _, _ ->
+ location_exn ~loc:str.loc "Bind meaningless in constructor"
+ | _, Some _, _, _ ->
+ location_exn ~loc:str.loc "Map meaningless in constructor"
+ | _, _, Some _, _ ->
+ location_exn ~loc:str.loc "Check meaningless in constructor"
+ | _, _, _, Some _ ->
+ location_exn ~loc:str.loc "Saving offset meaningless in constructor"
+ | None, None, None, None ->
+ (parse_expr vl, Some (parse_expr len), Some (q))
+ end
+ | [ stmt ] ->
+ let pat_str = stmt.txt in
+ location_exn ~loc:stmt.loc ("Invalid statement: '" ^ pat_str ^ "'")
+ | _ ->
+ location_exn ~loc:str.loc "Invalid number of fields in statement"
+;;
+
+(* Match generators *)
+
+let check_field_len ~loc fld =
+ let (l, v) = fld.MatchField.len
+ in
+ match v, fld.MatchField.qls.Qualifiers.value_type with
+ | Some (n), Some (Type.String) ->
+ if n < -1 || (n > 0 && (n mod 8) <> 0) then
+ location_exn ~loc "Length of string must be > 0 and multiple of 8, or the special value -1"
+ else Some n
+ | Some (n), Some (Type.Bitstring) ->
+ if n < -1 then location_exn ~loc "Length of bitstring must be >= 0 or the special value -1"
+ else Some n
+ | Some (n), Some (Type.Int) ->
+ if n < 1 || n > 64 then location_exn ~loc "Length of int field must be [1..64]"
+ else Some n
+ | None, Some (_) -> None
+ | _, None -> location_exn ~loc "No type to check"
+;;
+
+let get_inttype ~loc ~fastpath = function
+ | v when v > 8 && v <= 16 -> if fastpath then "int16" else "int"
+ | v when v > 16 && v <= 31 -> if fastpath then "int32" else "int"
+ | v when v = 32 -> "int32"
+ | v when v > 32 && v <= 64 -> "int64"
+ | _ -> location_exn ~loc "Invalid integer size"
+
+let gen_int_extractor_static ~loc nxt size sign endian =
+ let edat = nxt.Context.dat.Entity.exp
+ and eoff = nxt.Context.off.Entity.exp
+ in
+ let sn = Sign.to_string sign
+ and ft = get_inttype ~loc ~fastpath:true size
+ and en = Endian.to_string endian in
+ let fp = sprintf "Bitstring.extract_fastpath_%s_%s_%s" ft en sn
+ in
+ [%expr
+ [%e evar ~loc fp] [%e edat] ([%e eoff] lsr 3)]
+ [@metaloc loc]
+;;
+
+let gen_int_extractor_dynamic ~loc nxt size sign endian =
+ let edat = nxt.Context.dat.Entity.exp
+ and eoff = nxt.Context.off.Entity.exp
+ and elen = nxt.Context.len.Entity.exp
+ in
+ let sn = Sign.to_string sign
+ and it = get_inttype ~loc ~fastpath:false size
+ and en = Endian.to_string endian in
+ let ex = sprintf "Bitstring.extract_%s_%s_%s" it en sn
+ in
+ [%expr [%e evar ~loc ex] [%e edat] [%e eoff] [%e elen] [%e int ~loc size]]
+ [@metaloc loc]
+;;
+
+let gen_int_extractor ~loc nxt fld =
+ let open Qualifiers in
+ let (l, v) = fld.MatchField.len
+ in
+ let edat = nxt.Context.dat.Entity.exp
+ and eoff = nxt.Context.off.Entity.exp
+ and elen = nxt.Context.len.Entity.exp
+ in
+ match v, fld.MatchField.qls.sign, fld.MatchField.qls.endian with
+ (* 1-bit type *)
+ | Some (size), Some (_), Some (_) when size = 1 ->
+ [%expr
+ Bitstring.extract_bit [%e edat] [%e eoff] [%e elen] [%e l]]
+ [@metaloc loc]
+ (* 8-bit type *)
+ | Some (size), Some (sign), Some (_) when size >= 2 && size <= 8 ->
+ let ex = sprintf "Bitstring.extract_char_%s" (Sign.to_string sign)
+ in
+ [%expr
+ [%e evar ~loc ex] [%e edat] [%e eoff] [%e elen] [%e int ~loc size]]
+ [@metaloc loc]
+ (* 16|32|64-bit type with referred endianness *)
+ | Some (size), Some (sign), Some (Endian.Referred r) ->
+ let ss = Sign.to_string sign
+ and it = get_inttype ~loc ~fastpath:false size in
+ let ex = sprintf "Bitstring.extract_%s_ee_%s" it ss
+ in
+ [%expr
+ [%e evar ~loc ex] ([%e r]) [%e edat] [%e eoff] [%e elen] [%e int ~loc size]]
+ [@metaloc loc]
+ (* 16|32|64-bit type with immediate endianness *)
+ | Some (size), Some (sign), Some (endian) ->
+ if fld.MatchField.opt then
+ gen_int_extractor_static ~loc nxt size sign endian
+ else
+ gen_int_extractor_dynamic ~loc nxt size sign endian
+ (* Variable size *)
+ | None, Some (sign), Some (Endian.Referred r) ->
+ let ss = Sign.to_string sign in
+ let ex = sprintf "Bitstring.extract_int64_ee_%s" ss in
+ [%expr
+ [%e evar ~loc ex] ([%e r]) [%e edat] [%e eoff] [%e elen] ([%e l])]
+ [@metaloc loc]
+ | None, Some (sign), Some (endian) ->
+ let es = Endian.to_string endian and ss = Sign.to_string sign in
+ let ex = sprintf "Bitstring.extract_int64_%s_%s" es ss in
+ [%expr
+ [%e evar ~loc ex] [%e edat] [%e eoff] [%e elen] ([%e l])]
+ [@metaloc loc]
+ (* Invalid type *)
+ | _, _, _ ->
+ location_exn ~loc "Invalid type"
+;;
+
+let gen_extractor ~loc nxt fld =
+ let open Qualifiers in
+ let (l, v) = fld.MatchField.len
+ in
+ let edat = nxt.Context.dat.Entity.exp
+ and eoff = nxt.Context.off.Entity.exp
+ and elen = nxt.Context.len.Entity.exp
+ in
+ match fld.MatchField.qls.value_type with
+ | Some (Type.Bitstring) -> begin
+ match v with
+ | Some (-1) ->
+ [%expr ([%e edat], [%e eoff], [%e elen])] [@metaloc loc]
+ | Some (_) | None ->
+ [%expr ([%e edat], [%e eoff], [%e l])] [@metaloc loc]
+ end
+ | Some (Type.String) ->
+ [%expr
+ (Bitstring.string_of_bitstring ([%e edat], [%e eoff], [%e l]))]
+ [@metaloc loc]
+ | Some (Type.Int) ->
+ gen_int_extractor ~loc nxt fld
+ | _ ->
+ location_exn ~loc "Invalid type"
+;;
+
+let gen_value ~loc fld res beh =
+ let open Qualifiers in
+ match fld.MatchField.qls.bind, fld.MatchField.qls.map with
+ | Some b, None ->
+ [%expr let [%p fld.pat] = [%e b] in [%e beh]][@metaloc loc]
+ | None, Some m ->
+ [%expr let [%p fld.pat] = [%e m] [%e res] in [%e beh]][@metaloc loc]
+ | _, _ -> beh
+;;
+
+let rec gen_next ~loc cur nxt fld beh fields =
+ let open Entity in
+ let open Context in
+ let (l, v) = fld.MatchField.len in
+ match v with
+ | Some (-1) ->
+ [%expr
+ let [%p nxt.off.pat] = [%e nxt.off.exp] + [%e nxt.len.exp]
+ and [%p nxt.len.pat] = 0 in
+ [%e (gen_fields ~loc cur nxt beh fields)]]
+ [@metaloc loc]
+ | Some (_) | None ->
+ [%expr
+ let [%p nxt.off.pat] = [%e nxt.off.exp] + [%e l]
+ and [%p nxt.len.pat] = [%e nxt.len.exp] - [%e l] in
+ [%e (gen_fields ~loc cur nxt beh fields)]]
+ [@metaloc loc]
+
+and gen_next_all ~loc cur nxt beh fields =
+ let open Entity in
+ let open Context in
+ [%expr
+ let [%p nxt.off.pat] = [%e nxt.off.exp] + [%e nxt.len.exp]
+ and [%p nxt.len.pat] = 0 in
+ [%e (gen_fields ~loc cur nxt beh fields)]]
+ [@metaloc loc]
+
+and gen_match_check ~loc = function
+ | Some chk -> chk
+ | None -> constr ~loc "true" []
+
+and gen_match ~loc cur nxt fld beh fields =
+ let open Entity in
+ let open Context in
+ let open Qualifiers in
+ let value = Entity.make ~loc "val"
+ and (l, _) = fld.MatchField.len
+ in
+ let mcheck = gen_match_check ~loc fld.MatchField.qls.check
+ and mfields = gen_fields ~loc cur nxt beh fields
+ and mres = gen_extractor ~loc nxt fld
+ in
+ let mwrap = gen_value ~loc fld value.exp mfields
+ in
+ let mcase = [%expr
+ begin match [%e value.exp] with
+ | [%p fld.MatchField.pat] when [%e mcheck] -> [%e mwrap]
+ | _ -> ()
+ end][@metaloc loc]
+ in
+ [%expr
+ let [%p value.pat] = [%e mres]
+ and [%p nxt.off.pat] = [%e nxt.off.exp] + [%e l]
+ and [%p nxt.len.pat] = [%e nxt.len.exp] - [%e l] in [%e mcase]]
+ [@metaloc loc]
+
+and gen_offset ~loc cur nxt fld beh =
+ let open Context in
+ let open Entity in
+ let open Qualifiers in
+ match fld.MatchField.qls.offset with
+ | Some ({ pexp_loc } as off) ->
+ [%expr
+ let [%p nxt.off.pat] = [%e cur.off.exp] + [%e off] in [%e beh]]
+ [@metaloc pexp_loc]
+ | None -> beh
+
+and gen_offset_saver ~loc cur nxt fld beh =
+ let open Context in
+ let open Entity in
+ let open Qualifiers in
+ match fld.MatchField.qls.save_offset_to with
+ | Some { pexp_desc = Pexp_ident ({ txt; loc = eloc }) } ->
+ let ptxt = pvar ~loc:eloc (Longident.last txt) in
+ [%expr
+ let [%p ptxt] = [%e nxt.off.exp] - [%e cur.off.exp] in [%e beh]]
+ [@metaloc eloc]
+ | Some _ | None -> beh
+
+and gen_unbound_string ~loc cur nxt fld beh fields =
+ let open Entity in
+ let open Context in
+ let p = fld.MatchField.pat
+ in
+ match p with
+ | { ppat_desc = Ppat_var(_) } ->
+ [%expr
+ let [%p p] = [%e (gen_extractor ~loc nxt fld)] in
+ [%e (gen_next_all ~loc cur nxt beh fields)]]
+ [@metaloc loc]
+ | [%pat? _ ] ->
+ [%expr
+ [%e (gen_next_all ~loc cur nxt beh fields)]]
+ [@metaloc loc]
+ | _ ->
+ location_exn ~loc "Unbound string or bitstring can only be assigned to a variable or skipped"
+
+and gen_bound_bitstring ~loc cur nxt fld beh fields =
+ let open Entity in
+ let open Context in
+ let p = fld.MatchField.pat
+ and (l, _) = fld.MatchField.len
+ in
+ match p with
+ | { ppat_desc = Ppat_var(_) } ->
+ [%expr
+ if Pervasives.(>=) [%e nxt.len.exp] [%e l] then
+ let [%p p] = [%e (gen_extractor ~loc nxt fld)] in
+ [%e (gen_next ~loc cur nxt fld beh fields)]
+ else ()]
+ [@metaloc loc]
+ | [%pat? _ ] ->
+ [%expr
+ if Pervasives.(>=) [%e nxt.len.exp] [%e l] then
+ [%e (gen_next ~loc cur nxt fld beh fields)]
+ else ()]
+ [@metaloc loc]
+ | _ ->
+ location_exn ~loc "Bound bitstring can only be assigned to variables or skipped"
+
+and gen_bound_string ~loc cur nxt fld beh fields =
+ let open Entity in
+ let open Context in
+ let (l, _) = fld.MatchField.len
+ in
+ [%expr
+ if Pervasives.(>=) [%e nxt.len.exp] [%e l] then
+ [%e (gen_match ~loc cur nxt fld beh fields)]
+ else ()]
+ [@metaloc loc]
+
+and gen_bound_int_with_size ~loc cur nxt fld beh fields =
+ let open Entity in
+ let open Context in
+ let (l, _) = fld.MatchField.len
+ in
+ [%expr
+ if Pervasives.(>=) [%e nxt.len.exp] [%e l] then
+ [%e (gen_match ~loc cur nxt fld beh fields)]
+ else ()]
+ [@metaloc loc]
+
+and gen_bound_int ~loc cur nxt fld beh fields =
+ let open Entity in
+ let open Context in
+ let (l, _) = fld.MatchField.len
+ in
+ [%expr
+ if Pervasives.(>=) [%e l] 1 &&
+ Pervasives.(<=) [%e l] 64 &&
+ Pervasives.(>=) [%e nxt.len.exp] [%e l] then
+ [%e (gen_match ~loc cur nxt fld beh fields)]
+ else ()]
+ [@metaloc loc]
+
+and gen_fields_with_quals_by_type ~loc cur nxt fld beh fields =
+ let open Qualifiers in
+ match check_field_len ~loc fld, fld.MatchField.qls.value_type with
+ | Some (-1), Some (Type.Bitstring | Type.String) ->
+ gen_unbound_string ~loc cur nxt fld beh fields
+ | (Some (_) | None), Some (Type.Bitstring) ->
+ gen_bound_bitstring ~loc cur nxt fld beh fields
+ | (Some (_) | None), Some (Type.String) ->
+ gen_bound_string ~loc cur nxt fld beh fields
+ | Some (s), Some (Type.Int) ->
+ if s >= 1 && s <= 64 then
+ gen_bound_int_with_size ~loc cur nxt fld beh fields
+ else
+ location_exn ~loc "Invalid bit length for type Integer"
+ | None, Some (Type.Int) ->
+ gen_bound_int ~loc cur nxt fld beh fields
+ | _, _ ->
+ location_exn ~loc "No type to generate"
+
+and gen_fields_with_quals ~loc cur nxt fld beh fields =
+ gen_fields_with_quals_by_type ~loc cur nxt fld beh fields
+ |> gen_offset_saver ~loc cur nxt fld
+ |> gen_offset ~loc cur nxt fld
+
+and gen_fields ~loc cur nxt beh fields =
+ let open Qualifiers in
+ let (exp, alias) = beh
+ in
+ match fields with
+ | [] ->
+ begin match alias with
+ | None -> exp
+ | Some a -> [%expr
+ let [%p pvar ~loc a] = ([%e cur.dat.exp], [%e cur.off.exp], ([%e cur.len.exp] - [%e nxt.len.exp]))
+ in
+ [%e exp]
+ ][@metaloc loc]
+ end
+ | MatchField.Any (_) :: tl ->
+ begin match alias with
+ | None -> exp
+ | Some a -> [%expr
+ let [%p pvar ~loc a] = ([%e cur.dat.exp], [%e cur.off.exp], [%e cur.len.exp])
+ in
+ [%e exp]
+ ][@metaloc loc]
+ end
+ | MatchField.Tuple (fld) :: tl -> gen_fields_with_quals ~loc cur nxt fld beh tl
+;;
+
+let is_field_size_open_ended = function
+ | (_, Some (-1)) -> true
+ | _ -> false
+
+let check_for_open_endedness fields =
+ let check init fld =
+ let p = fld.MatchField.pat
+ and l = fld.MatchField.len in
+ let oe = is_field_size_open_ended l in
+ if init || (oe && init) then
+ location_exn ~loc:p.ppat_loc "Pattern is already open-ended"
+ else oe
+ in
+ let inspect init = function
+ | MatchField.Any (_) -> init && false
+ | MatchField.Tuple fld -> check init fld
+ in
+ let rec scan init = function
+ | [] -> ()
+ | hd :: tl -> scan (inspect init hd) tl
+ in
+ scan false fields; fields
+;;
+
+let mark_optimized_fastpath fields =
+ let open Qualifiers in
+ let open MatchField
+ in
+ let check_field off tuple =
+ match tuple with
+ | { pat; len = (l, Some (v)); qls = { value_type = Some (Type.Int) }; _ } ->
+ if (off land 7) = 0 && (v = 16 || v = 32 || v = 64) then
+ (Some (off + v), MatchField.Tuple { tuple with opt = true })
+ else
+ (None, MatchField.Tuple tuple)
+ | _ ->
+ (None, MatchField.Tuple tuple)
+ in
+ let check_offset_and_field offset fld =
+ match offset, fld with
+ | Some (off), MatchField.Tuple (tuple) -> check_field off tuple
+ | _, _ -> (None, fld)
+ in
+ let rec scan offset result = function
+ | [] -> result
+ | hd :: tl ->
+ let (noff, nfld) = check_offset_and_field offset hd in
+ scan noff (result @ [ nfld ]) tl
+ in
+ scan (Some 0) [] fields
+;;
+
+let gen_case_constant ~loc cur nxt res case value alias =
+ let open Entity in
+ let beh = [%expr
+ [%e res.exp] := Some ([%e case.pc_rhs]);
+ raise Exit][@metaloc loc]
+ in
+ let beh =
+ match case.pc_guard with
+ | None -> beh
+ | Some cond -> [%expr if [%e cond] then [%e beh] else ()][@metaloc loc]
+ in
+ split_string ~on:";" value
+ |> split_loc ~loc
+ |> List.map parse_match_fields
+ |> check_for_open_endedness
+ |> mark_optimized_fastpath
+ |> gen_fields ~loc cur nxt (beh, alias)
+
+let gen_case cur nxt res case =
+ let open Entity in
+ let loc = case.pc_lhs.ppat_loc in
+ match case.pc_lhs.ppat_desc with
+ | Ppat_constant (Pconst_string (value, _)) ->
+ gen_case_constant ~loc cur nxt res case value None
+ | Ppat_alias ({ ppat_desc = Ppat_constant (Pconst_string (value, _)) }, { txt = a }) ->
+ gen_case_constant ~loc cur nxt res case value (Some a)
+ | _ ->
+ location_exn ~loc "Wrong pattern type"
+;;
+
+let rec gen_cases_sequence ~loc = function
+ | [] -> location_exn ~loc "Empty case list"
+ | [hd] -> hd
+ | hd :: tl -> [%expr [%e hd]; [%e gen_cases_sequence ~loc tl]][@metaloc loc]
+;;
+
+let gen_cases ~loc ident cases =
+ let open Entity in
+ let open Context in
+ let cur = Context.make ~loc
+ and res = Entity.make ~loc "res"
+ in
+ let nxt = Context.next ~loc cur
+ and tupl = [%pat? ([%p cur.dat.pat], [%p cur.off.pat], [%p cur.len.pat])][@metaloc loc]
+ and fnam = str ~loc loc.Location.loc_start.pos_fname
+ and lpos = int ~loc loc.Location.loc_start.pos_lnum
+ and cpos = int ~loc (loc.Location.loc_start.pos_cnum - loc.Location.loc_start.pos_bol)
+ in
+ List.fold_left
+ (fun acc case -> acc @ [ gen_case cur nxt res case ])
+ []
+ cases
+ |> gen_cases_sequence ~loc
+ |> fun seq ->
+ [%expr
+ let [%p tupl] = [%e ident] in
+ let [%p nxt.off.pat] = [%e cur.off.exp]
+ and [%p nxt.len.pat] = [%e cur.len.exp]
+ and [%p res.pat] = ref None
+ in
+ (try [%e seq]; with | Exit -> ());
+ match ![%e res.exp] with
+ | Some x -> x
+ | None -> raise (Match_failure ([%e fnam], [%e lpos], [%e cpos]))]
+ [@metaloc loc]
+;;
+
+let gen_function ~loc cases =
+ let open Entity in
+ let cas = Entity.make ~loc "case" in
+ [%expr
+ (fun [%p cas.pat] -> [%e (gen_cases ~loc cas.exp cases)])]
+ [@metaloc loc]
+
+(* Constructor generators *)
+
+let gen_constructor_exn ~loc =
+ let open Location in
+ [%expr Bitstring.Construct_failure (
+ [%e str ~loc "Bad field value"],
+ [%e str ~loc loc.loc_start.pos_fname],
+ [%e int ~loc loc.loc_start.pos_lnum],
+ [%e int ~loc loc.loc_start.pos_cnum])]
+ [@metaloc loc]
+;;
+
+let gen_constructor_bitstring ~loc sym (l, _, _ ) =
+ [%expr
+ Bitstring.construct_bitstring [%e sym.Entity.exp] [%e l]]
+ [@metaloc loc]
+;;
+
+let gen_constructor_string ~loc sym (l, _, _) =
+ [%expr
+ Bitstring.construct_string [%e sym.Entity.exp] [%e l]]
+ [@metaloc loc]
+;;
+
+let get_1_bit_constr_value ~loc (l, _, _) =
+ match (evaluate_expr l) with
+ | Some (1) -> [%expr true][@metaloc loc]
+ | Some (0) -> [%expr false][@metaloc loc]
+ | Some (_) | None -> l
+;;
+
+let gen_constructor_int ~loc sym fld =
+ let open Qualifiers in
+ let (l, s, q) = fld in
+ let eexc = gen_constructor_exn ~loc
+ and esym = sym.Entity.exp in
+ let (fnc, vl, sz) = match (evaluate_expr s), q.sign, q.endian with
+ (* 1-bit type *)
+ | Some (size), Some (_), Some (_) when size = 1 ->
+ (evar ~loc "Bitstring.construct_bit", get_1_bit_constr_value ~loc fld, [%expr 1])
+ (* 8-bit type *)
+ | Some (size), Some (sign), Some (_) when size >= 2 && size <= 8 ->
+ let sn = Sign.to_string sign in
+ let ex = sprintf "Bitstring.construct_char_%s" sn in
+ (evar ~loc ex, l, int ~loc size)
+ (* 16|32|64-bit type *)
+ | Some (size), Some (sign), Some (Endian.Referred r) ->
+ let ss = Sign.to_string sign
+ and it = get_inttype ~loc ~fastpath:false size in
+ let ex = sprintf "Bitstring.construct_%s_ee_%s" it ss in
+ ([%expr [%e evar ~loc ex] [%e r]], l, s)
+ | Some (size), Some (sign), Some (endian) ->
+ let tp = get_inttype ~loc ~fastpath:false size
+ and en = Endian.to_string endian
+ and sn = Sign.to_string sign in
+ let ex = sprintf "Bitstring.construct_%s_%s_%s" tp en sn in
+ (evar ~loc ex, l, int ~loc size)
+ (* Variable size types *)
+ | None, Some (sign), Some (Endian.Referred r) ->
+ let ss = Sign.to_string sign in
+ let ex = sprintf "Bitstring.construct_int64_ee_%s" ss in
+ ([%expr [%e evar ~loc ex] [%e r]], l, s)
+ | None, Some (sign), Some (endian) ->
+ let en = Endian.to_string endian
+ and sn = Sign.to_string sign in
+ let ex = sprintf "Bitstring.construct_int64_%s_%s" en sn in
+ (evar ~loc ex, l, s)
+ (* Invalid type *)
+ | _, _, _ ->
+ location_exn ~loc "Invalid type"
+ in
+ [%expr
+ [%e fnc] [%e esym] [%e vl] [%e sz] [%e eexc]]
+ [@metaloc loc]
+;;
+
+let gen_constructor_complete ~loc sym fld =
+ let (_, _, q) = fld in
+ match q.Qualifiers.value_type with
+ | Some (Type.Bitstring) -> gen_constructor_bitstring ~loc sym fld
+ | Some (Type.String) -> gen_constructor_string ~loc sym fld
+ | Some (Type.Int) -> gen_constructor_int ~loc sym fld
+ | _ -> location_exn ~loc "Invalid type"
+;;
+
+let gen_constructor ~loc sym = function
+ | (f, Some (s), Some (q)) -> gen_constructor_complete ~loc sym (f, s, q)
+ | _ -> location_exn ~loc "Invalid field format"
+;;
+
+let gen_assignment_size_of_sized_field ~loc (f, s, q) =
+ match (evaluate_expr s), option_bind q (fun q -> q.Qualifiers.value_type) with
+ (* Deal with String type *)
+ | Some (-1), Some (Type.String) -> [%expr (String.length [%e f] * 8)]
+ | Some (v), Some (Type.String) when v > 0 && (v mod 8) = 0 -> s
+ | Some (_), Some (Type.String) ->
+ location_exn ~loc "Length of string must be > 0 and multiple of 8, or the special value -1"
+ (* Deal with Bitstring type *)
+ | Some (-1), Some (Type.Bitstring) -> [%expr (Bitstring.bitstring_length [%e f])]
+ | Some (v), Some (Type.Bitstring) when v > 0 -> s
+ | Some (_), Some (Type.Bitstring) ->
+ location_exn ~loc "Length of bitstring must be >= 0 or the special value -1"
+ (* Deal with other types *)
+ | Some (v), _ when v > 0 -> s
+ | Some (v), _ ->
+ location_exn ~loc "Negative or null field size in constructor"
+ (* Unknown field size, arbitrary expression *)
+ | None, _ -> s
+;;
+
+let gen_assignment_size_of_field ~loc = function
+ | (_, None, _) -> [%expr 0]
+ | (f, Some (s), q) -> gen_assignment_size_of_sized_field ~loc (f, s, q)
+;;
+
+let rec gen_assignment_size ~loc = function
+ | [] -> [%expr 0]
+ | field :: tl ->
+ let this = gen_assignment_size_of_field ~loc field in
+ let next = gen_assignment_size ~loc tl in
+ [%expr [%e this] + ([%e next])][@metaloc loc]
+;;
+
+let gen_assignment_behavior ~loc sym fields =
+ let size = gen_assignment_size ~loc fields in
+ let res = sym.Entity.exp in
+ let rep = [%expr Bitstring.Buffer.contents [%e res]][@metaloc loc] in
+ let len = match (evaluate_expr size) with
+ | Some (v) -> int v
+ | None -> size
+ in
+ let post =
+ [%expr
+ let _res = [%e rep] in
+ if Pervasives.(=) (Bitstring.bitstring_length _res) [%e len]
+ then _res else raise Exit]
+ [@metaloc loc]
+ in
+ let seq = List.fold_right
+ (fun fld acc -> [%expr [%e (gen_constructor ~loc sym fld)]; [%e acc]])
+ fields
+ post
+ in
+ [%expr
+ let [%p sym.Entity.pat] = Bitstring.Buffer.create () in
+ [%e seq]]
+ [@metaloc loc]
+;;
+
+let parse_assignment_behavior ~loc sym value =
+ split_string ~on:";" value
+ |> split_loc ~loc
+ |> List.map (fun flds -> parse_const_fields flds)
+ |> gen_assignment_behavior ~loc sym
+;;
+
+let gen_constructor_expr ~loc value =
+ let open Entity in
+ let sym = Entity.make ~loc "constructor" in
+ let beh = parse_assignment_behavior ~loc sym value in
+ [%expr let [%p sym.pat] = fun () -> [%e beh] in [%e sym.exp] ()]
+;;
+
+let transform_single_let ~loc ast expr =
+ match ast.pvb_pat.ppat_desc, ast.pvb_expr.pexp_desc with
+ | Parsetree.Ppat_var (s), Pexp_constant (Pconst_string (value, _)) ->
+ let pat = pvar ~loc s.txt in
+ let constructor_expr = gen_constructor_expr loc value in
+ [%expr let [%p pat] = [%e constructor_expr] in [%e expr]]
+ | _ -> location_exn ~loc "Invalid pattern type"
+;;
+
+(*
+ * Rewriter. See:
+ * https://github.com/let-def/ocaml-migrate-parsetree/blob/master/MANUAL.md#new-registration-interface
+ *)
+
+let extension expr =
+ let loc = expr.pexp_loc in
+ match expr.pexp_desc with
+ | Pexp_constant (Pconst_string (value, (_ : string option))) ->
+ gen_constructor_expr loc value
+ | Pexp_let (Nonrecursive, bindings, expr) ->
+ List.fold_right
+ (fun binding expr -> transform_single_let ~loc binding expr)
+ bindings
+ expr
+ | Pexp_match (ident, cases) ->
+ gen_cases ~loc ident cases
+ | Pexp_function (cases) ->
+ gen_function ~loc cases
+ | _ ->
+ location_exn ~loc
+ "'bitstring' can only be used with 'let', 'match', and as '[%bitstring]'"
+
+let expression mapper = function
+ | [%expr [%bitstring [%e? e0]]] -> mapper.expr mapper (extension e0)
+ | expr -> Ast_mapper.default_mapper.expr mapper expr
+
+let structure_item_mapper mapper = function
+ | [%stri [%%bitstring let [%p? var] = [%e? e0]]] ->
+ [%stri let [%p mapper.pat mapper var] = [%e mapper.expr mapper (extension e0)]]
+ | stri -> Ast_mapper.default_mapper.structure_item mapper stri
+
+let rewriter config cookies = {
+ Ast_mapper.default_mapper with
+ expr = expression;
+ structure_item = structure_item_mapper;
+}
+
+let () =
+ Driver.register ~name:"ppx_bitstring" ~args:[] Versions.ocaml_405 rewriter
+;;
diff --git a/src/.merlin b/src/.merlin
new file mode 100644
index 0000000..0ca502f
--- /dev/null
+++ b/src/.merlin
@@ -0,0 +1,3 @@
+B ../_build/default/src
+FLG -open Bitstring__ -w -40
+PKG unix
diff --git a/bitstring.ml b/src/bitstring.ml
index 98f992b..ac5313a 100644
--- a/bitstring.ml
+++ b/src/bitstring.ml
@@ -32,19 +32,19 @@ let debug = ref false
(* Exceptions. *)
exception Construct_failure of string * string * int * int
-(* A bitstring is simply the data itself (as a string), and the
- * bitoffset and the bitlength within the string. Note offset/length
+(* A bitstring is simply the data itself (as a byte sequence), and the
+ * bitoffset and the bitlength within the byte sequence. Note offset/length
* are counted in bits, not bytes.
*)
-type bitstring = string * int * int
+type bitstring = bytes * int * int
type t = bitstring
(* Functions to create and load bitstrings. *)
-let empty_bitstring = "", 0, 0
+let empty_bitstring = Bytes.create 0, 0, 0
let make_bitstring len c =
- if len >= 0 then String.make ((len+7) lsr 3) c, 0, len
+ if len >= 0 then Bytes.make ((len+7) lsr 3) c, 0, len
else
invalid_arg (
sprintf "make_bitstring/create_bitstring: len %d < 0" len
@@ -56,65 +56,65 @@ let zeroes_bitstring = create_bitstring
let ones_bitstring len = make_bitstring len '\xff'
-let bitstring_of_string str = str, 0, String.length str lsl 3
+let bitstring_of_string str = Bytes.of_string str, 0, String.length str lsl 3
let bitstring_of_chan chan =
let tmpsize = 16384 in
let buf = Buffer.create tmpsize in
- let tmp = String.create tmpsize in
+ let tmp = Bytes.create tmpsize in
let n = ref 0 in
while n := input chan tmp 0 tmpsize; !n > 0 do
- Buffer.add_substring buf tmp 0 !n;
+ Buffer.add_subbytes buf tmp 0 !n;
done;
- Buffer.contents buf, 0, Buffer.length buf lsl 3
+ Buffer.to_bytes buf, 0, Buffer.length buf lsl 3
let bitstring_of_chan_max chan max =
let tmpsize = 16384 in
let buf = Buffer.create tmpsize in
- let tmp = String.create tmpsize in
+ let tmp = Bytes.create tmpsize in
let len = ref 0 in
let rec loop () =
if !len < max then (
let r = min tmpsize (max - !len) in
let n = input chan tmp 0 r in
if n > 0 then (
- Buffer.add_substring buf tmp 0 n;
+ Buffer.add_subbytes buf tmp 0 n;
len := !len + n;
loop ()
)
)
in
loop ();
- Buffer.contents buf, 0, !len lsl 3
+ Buffer.to_bytes buf, 0, !len lsl 3
let bitstring_of_file_descr fd =
let tmpsize = 16384 in
let buf = Buffer.create tmpsize in
- let tmp = String.create tmpsize in
+ let tmp = Bytes.create tmpsize in
let n = ref 0 in
while n := Unix.read fd tmp 0 tmpsize; !n > 0 do
- Buffer.add_substring buf tmp 0 !n;
+ Buffer.add_subbytes buf tmp 0 !n;
done;
- Buffer.contents buf, 0, Buffer.length buf lsl 3
+ Buffer.to_bytes buf, 0, Buffer.length buf lsl 3
let bitstring_of_file_descr_max fd max =
let tmpsize = 16384 in
let buf = Buffer.create tmpsize in
- let tmp = String.create tmpsize in
+ let tmp = Bytes.create tmpsize in
let len = ref 0 in
let rec loop () =
if !len < max then (
let r = min tmpsize (max - !len) in
let n = Unix.read fd tmp 0 r in
if n > 0 then (
- Buffer.add_substring buf tmp 0 n;
+ Buffer.add_subbytes buf tmp 0 n;
len := !len + n;
loop ()
)
)
in
loop ();
- Buffer.contents buf, 0, !len lsl 3
+ Buffer.to_bytes buf, 0, !len lsl 3
let bitstring_of_file fname =
let chan = open_in_bin fname in
@@ -400,18 +400,22 @@ end
let extract_bit data off len _ = (* final param is always 1 *)
let byteoff = off lsr 3 in
let bitmask = 1 lsl (7 - (off land 7)) in
- let b = Char.code data.[byteoff] land bitmask <> 0 in
+ let b = Char.code (Bytes.get data byteoff) land bitmask <> 0 in
b (*, off+1, len-1*)
(* Returns 8 bit unsigned aligned bytes from the string.
* If the string ends then this returns 0's.
*)
let _get_byte data byteoff strlen =
- if strlen > byteoff then Char.code data.[byteoff] else 0
+ if strlen > byteoff then Char.code (Bytes.get data byteoff) else 0
let _get_byte32 data byteoff strlen =
- if strlen > byteoff then Int32.of_int (Char.code data.[byteoff]) else 0l
+ if strlen > byteoff then
+ Int32.of_int (Char.code (Bytes.get data byteoff))
+ else 0l
let _get_byte64 data byteoff strlen =
- if strlen > byteoff then Int64.of_int (Char.code data.[byteoff]) else 0L
+ if strlen > byteoff then
+ Int64.of_int (Char.code (Bytes.get data byteoff))
+ else 0L
(* Extend signed [2..31] bits int to 31 bits int or 63 bits int for 64
bits platform*)
@@ -431,13 +435,13 @@ let extract_char_unsigned data off len flen =
(* Optimize the common (byte-aligned) case. *)
if off land 7 = 0 then (
- let byte = Char.code data.[byteoff] in
+ let byte = Char.code (Bytes.get data byteoff) in
byte lsr (8 - flen) (*, off+flen, len-flen*)
) else (
(* Extract the 16 bits at byteoff and byteoff+1 (note that the
* second byte might not exist in the original string).
*)
- let strlen = String.length data in
+ let strlen = Bytes.length data in
let word =
(_get_byte data byteoff strlen lsl 8) +
@@ -460,7 +464,7 @@ let extract_char_signed =
let extract_int_be_unsigned data off len flen =
let byteoff = off lsr 3 in
- let strlen = String.length data in
+ let strlen = Bytes.length data in
let word =
(* Optimize the common (byte-aligned) case. *)
@@ -548,7 +552,7 @@ let _make_int32_le c0 c1 c2 c3 =
let extract_int32_be_unsigned data off len flen =
let byteoff = off lsr 3 in
- let strlen = String.length data in
+ let strlen = Bytes.length data in
let word =
(* Optimize the common (byte-aligned) case. *)
@@ -618,7 +622,7 @@ let _make_int64_le c0 c1 c2 c3 c4 c5 c6 c7 =
let extract_int64_be_unsigned data off len flen =
let byteoff = off lsr 3 in
- let strlen = String.length data in
+ let strlen = Bytes.length data in
let word =
(* Optimize the common (byte-aligned) case. *)
@@ -668,7 +672,7 @@ let extract_int64_be_unsigned data off len flen =
let extract_int64_le_unsigned data off len flen =
let byteoff = off lsr 3 in
- let strlen = String.length data in
+ let strlen = Bytes.length data in
let word =
(* Optimize the common (byte-aligned) case. *)
@@ -725,93 +729,93 @@ let extract_int64_ee_unsigned = function
| LittleEndian -> extract_int64_le_unsigned
| NativeEndian -> extract_int64_ne_unsigned
-external extract_fastpath_int16_be_unsigned : string -> int -> int = "ocaml_bitstring_extract_fastpath_int16_be_unsigned" "noalloc"
+external extract_fastpath_int16_be_unsigned : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int16_be_unsigned"
-external extract_fastpath_int16_le_unsigned : string -> int -> int = "ocaml_bitstring_extract_fastpath_int16_le_unsigned" "noalloc"
+external extract_fastpath_int16_le_unsigned : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int16_le_unsigned"
-external extract_fastpath_int16_ne_unsigned : string -> int -> int = "ocaml_bitstring_extract_fastpath_int16_ne_unsigned" "noalloc"
+external extract_fastpath_int16_ne_unsigned : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int16_ne_unsigned"
-external extract_fastpath_int16_be_signed : string -> int -> int = "ocaml_bitstring_extract_fastpath_int16_be_signed" "noalloc"
+external extract_fastpath_int16_be_signed : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int16_be_signed"
-external extract_fastpath_int16_le_signed : string -> int -> int = "ocaml_bitstring_extract_fastpath_int16_le_signed" "noalloc"
+external extract_fastpath_int16_le_signed : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int16_le_signed"
-external extract_fastpath_int16_ne_signed : string -> int -> int = "ocaml_bitstring_extract_fastpath_int16_ne_signed" "noalloc"
+external extract_fastpath_int16_ne_signed : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int16_ne_signed"
(*
-external extract_fastpath_int24_be_unsigned : string -> int -> int = "ocaml_bitstring_extract_fastpath_int24_be_unsigned" "noalloc"
+external extract_fastpath_int24_be_unsigned : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int24_be_unsigned"
-external extract_fastpath_int24_le_unsigned : string -> int -> int = "ocaml_bitstring_extract_fastpath_int24_le_unsigned" "noalloc"
+external extract_fastpath_int24_le_unsigned : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int24_le_unsigned"
-external extract_fastpath_int24_ne_unsigned : string -> int -> int = "ocaml_bitstring_extract_fastpath_int24_ne_unsigned" "noalloc"
+external extract_fastpath_int24_ne_unsigned : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int24_ne_unsigned"
-external extract_fastpath_int24_be_signed : string -> int -> int = "ocaml_bitstring_extract_fastpath_int24_be_signed" "noalloc"
+external extract_fastpath_int24_be_signed : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int24_be_signed"
-external extract_fastpath_int24_le_signed : string -> int -> int = "ocaml_bitstring_extract_fastpath_int24_le_signed" "noalloc"
+external extract_fastpath_int24_le_signed : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int24_le_signed"
-external extract_fastpath_int24_ne_signed : string -> int -> int = "ocaml_bitstring_extract_fastpath_int24_ne_signed" "noalloc"
+external extract_fastpath_int24_ne_signed : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int24_ne_signed"
*)
-external extract_fastpath_int32_be_unsigned : string -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_be_unsigned"
+external extract_fastpath_int32_be_unsigned : bytes -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_be_unsigned"
-external extract_fastpath_int32_le_unsigned : string -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_le_unsigned"
+external extract_fastpath_int32_le_unsigned : bytes -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_le_unsigned"
-external extract_fastpath_int32_ne_unsigned : string -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_ne_unsigned"
+external extract_fastpath_int32_ne_unsigned : bytes -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_ne_unsigned"
-external extract_fastpath_int32_be_signed : string -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_be_signed"
+external extract_fastpath_int32_be_signed : bytes -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_be_signed"
-external extract_fastpath_int32_le_signed : string -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_le_signed"
+external extract_fastpath_int32_le_signed : bytes -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_le_signed"
-external extract_fastpath_int32_ne_signed : string -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_ne_signed"
+external extract_fastpath_int32_ne_signed : bytes -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_ne_signed"
(*
-external extract_fastpath_int40_be_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_be_unsigned"
+external extract_fastpath_int40_be_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_be_unsigned"
-external extract_fastpath_int40_le_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_le_unsigned"
+external extract_fastpath_int40_le_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_le_unsigned"
-external extract_fastpath_int40_ne_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_ne_unsigned"
+external extract_fastpath_int40_ne_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_ne_unsigned"
-external extract_fastpath_int40_be_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_be_signed"
+external extract_fastpath_int40_be_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_be_signed"
-external extract_fastpath_int40_le_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_le_signed"
+external extract_fastpath_int40_le_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_le_signed"
-external extract_fastpath_int40_ne_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_ne_signed"
+external extract_fastpath_int40_ne_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_ne_signed"
-external extract_fastpath_int48_be_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_be_unsigned"
+external extract_fastpath_int48_be_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_be_unsigned"
-external extract_fastpath_int48_le_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_le_unsigned"
+external extract_fastpath_int48_le_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_le_unsigned"
-external extract_fastpath_int48_ne_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_ne_unsigned"
+external extract_fastpath_int48_ne_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_ne_unsigned"
-external extract_fastpath_int48_be_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_be_signed"
+external extract_fastpath_int48_be_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_be_signed"
-external extract_fastpath_int48_le_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_le_signed"
+external extract_fastpath_int48_le_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_le_signed"
-external extract_fastpath_int48_ne_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_ne_signed"
+external extract_fastpath_int48_ne_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_ne_signed"
-external extract_fastpath_int56_be_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_be_unsigned"
+external extract_fastpath_int56_be_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_be_unsigned"
-external extract_fastpath_int56_le_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_le_unsigned"
+external extract_fastpath_int56_le_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_le_unsigned"
-external extract_fastpath_int56_ne_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_ne_unsigned"
+external extract_fastpath_int56_ne_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_ne_unsigned"
-external extract_fastpath_int56_be_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_be_signed"
+external extract_fastpath_int56_be_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_be_signed"
-external extract_fastpath_int56_le_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_le_signed"
+external extract_fastpath_int56_le_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_le_signed"
-external extract_fastpath_int56_ne_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_ne_signed"
+external extract_fastpath_int56_ne_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_ne_signed"
*)
-external extract_fastpath_int64_be_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_be_unsigned"
+external extract_fastpath_int64_be_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_be_unsigned"
-external extract_fastpath_int64_le_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_le_unsigned"
+external extract_fastpath_int64_le_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_le_unsigned"
-external extract_fastpath_int64_ne_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_ne_unsigned"
+external extract_fastpath_int64_ne_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_ne_unsigned"
-external extract_fastpath_int64_be_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_be_signed"
+external extract_fastpath_int64_be_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_be_signed"
-external extract_fastpath_int64_le_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_le_signed"
+external extract_fastpath_int64_le_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_le_signed"
-external extract_fastpath_int64_ne_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_ne_signed"
+external extract_fastpath_int64_ne_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_ne_signed"
(*----------------------------------------------------------------------*)
(* Constructor functions. *)
@@ -835,13 +839,14 @@ module Buffer = struct
let contents { buf = buf; len = len; last = last } =
let data =
if len land 7 = 0 then
- Buffer.contents buf
+ Buffer.to_bytes buf
else
- Buffer.contents buf ^ (String.make 1 (Char.chr last)) in
+ Bytes.cat (Buffer.to_bytes buf) (Bytes.make 1 (Char.chr last)) in
data, 0, len
(* Add exactly 8 bits. *)
- let add_byte ({ buf = buf; len = len; last = last } as t) byte =
+ let add_byte t byte =
+ let {buf; len; last} = t in
if byte < 0 || byte > 255 then invalid_arg "Bitstring.Buffer.add_byte";
let shift = len land 7 in
if shift = 0 then
@@ -857,7 +862,8 @@ module Buffer = struct
t.len <- t.len + 8
(* Add exactly 1 bit. *)
- let add_bit ({ buf = buf; len = len; last = last } as t) bit =
+ let add_bit t bit =
+ let {buf; len; last} = t in
let shift = 7 - (len land 7) in
if shift > 0 then
(* Somewhere in the middle of 'last'. *)
@@ -880,20 +886,21 @@ module Buffer = struct
add_bit t bit
done
- let add_bits ({ buf = buf; len = len } as t) str slen =
+ let add_bits t str slen =
+ let {buf; len; _} = t in
if slen > 0 then (
if len land 7 = 0 then (
if slen land 7 = 0 then
(* Common case - everything is byte-aligned. *)
- Buffer.add_substring buf str 0 (slen lsr 3)
+ Buffer.add_subbytes buf str 0 (slen lsr 3)
else (
(* Target buffer is aligned. Copy whole bytes then leave the
* remaining bits in last.
*)
let slenbytes = slen lsr 3 in
- if slenbytes > 0 then Buffer.add_substring buf str 0 slenbytes;
- let lastidx = min slenbytes (String.length str - 1) in
- let last = Char.code str.[lastidx] in (* last char *)
+ if slenbytes > 0 then Buffer.add_subbytes buf str 0 slenbytes;
+ let lastidx = min slenbytes (Bytes.length str - 1) in
+ let last = Char.code (Bytes.get str lastidx) in (* last char *)
let mask = 0xff lsl (8 - (slen land 7)) in
t.last <- last land mask
);
@@ -907,12 +914,12 @@ module Buffer = struct
*)
let slenbytes = slen lsr 3 in
for i = 0 to slenbytes-1 do
- let byte = Char.code str.[i] in
+ let byte = Char.code (Bytes.get str i) in
add_byte t byte
done;
let bitsleft = slen - (slenbytes lsl 3) in
if bitsleft > 0 then (
- let c = Char.code str.[slenbytes] in
+ let c = Char.code (Bytes.get str slenbytes) in
for i = 0 to bitsleft - 1 do
let bit = c land (0x80 lsr i) <> 0 in
add_bit t bit
@@ -1042,7 +1049,7 @@ let construct_int64_ee_unsigned = function
*)
let construct_string buf str =
let len = String.length str in
- Buffer.add_bits buf str (len lsl 3)
+ Buffer.add_bits buf (Bytes.unsafe_of_string str) (len lsl 3)
(* Construct from a bitstring. *)
let construct_bitstring buf (data, off, len) =
@@ -1068,7 +1075,7 @@ let construct_bitstring buf (data, off, len) =
let off = off lsr 3 in
(* XXX dangerous allocation *)
if off = 0 then data
- else String.sub data off (String.length data - off) in
+ else Bytes.sub data off (Bytes.length data - off) in
Buffer.add_bits buf data len
@@ -1083,24 +1090,24 @@ let concat bs =
let string_of_bitstring (data, off, len) =
if off land 7 = 0 && len land 7 = 0 then
(* Easy case: everything is byte-aligned. *)
- String.sub data (off lsr 3) (len lsr 3)
+ String.sub (Bytes.unsafe_to_string data) (off lsr 3) (len lsr 3)
else (
(* Bit-twiddling case. *)
let strlen = (len + 7) lsr 3 in
- let str = String.make strlen '\000' in
+ let str = Bytes.make strlen '\000' in
let rec loop data off len i =
if len >= 8 then (
let c = extract_char_unsigned data off len 8
and off = off + 8 and len = len - 8 in
- str.[i] <- Char.chr c;
+ Bytes.set str i (Char.chr c);
loop data off len (i+1)
) else if len > 0 then (
let c = extract_char_unsigned data off len len in
- str.[i] <- Char.chr (c lsl (8-len))
+ Bytes.set str i (Char.chr (c lsl (8-len)))
)
in
loop data off len 0;
- str
+ Bytes.unsafe_to_string str
)
(* To channel. *)
@@ -1140,8 +1147,8 @@ let compare ((data1, off1, len1) as bs1) ((data2, off2, len2) as bs2) =
and len1 = len1 lsr 3 and len2 = len2 lsr 3 in
let rec loop i =
if i < len1 && i < len2 then (
- let c1 = String.unsafe_get data1 (off1 + i)
- and c2 = String.unsafe_get data2 (off2 + i) in
+ let c1 = Bytes.unsafe_get data1 (off1 + i)
+ and c2 = Bytes.unsafe_get data2 (off2 + i) in
let r = compare c1 c2 in
if r <> 0 then r
else loop (i+1)
@@ -1168,7 +1175,7 @@ let is_zeroes_bitstring ((data, off, len) as bits) =
let off = off lsr 3 and len = len lsr 3 in
let rec loop i =
if i < len then (
- if String.unsafe_get data (off + i) <> '\000' then false
+ if Bytes.unsafe_get data (off + i) <> '\000' then false
else loop (i+1)
) else true
in
@@ -1186,7 +1193,7 @@ let is_ones_bitstring ((data, off, len) as bits) =
let off = off lsr 3 and len = len lsr 3 in
let rec loop i =
if i < len then (
- if String.unsafe_get data (off + i) <> '\xff' then false
+ if Bytes.unsafe_get data (off + i) <> '\xff' then false
else loop (i+1)
) else true
in
@@ -1209,9 +1216,9 @@ let put (data, off, len) n v =
else (
let i = off+n in
let si = i lsr 3 and mask = 0x80 lsr (i land 7) in
- let c = Char.code data.[si] in
+ let c = Char.code (Bytes.get data si) in
let c = if v <> 0 then c lor mask else c land (lnot mask) in
- data.[si] <- Char.unsafe_chr c
+ Bytes.set data si (Char.unsafe_chr c)
)
let set bits n = put bits n 1
@@ -1223,7 +1230,7 @@ let get (data, off, len) n =
else (
let i = off+n in
let si = i lsr 3 and mask = 0x80 lsr (i land 7) in
- let c = Char.code data.[si] in
+ let c = Char.code (Bytes.get data si) in
c land mask
)
@@ -1243,7 +1250,7 @@ let hexdump_bitstring chan (data, off, len) =
let off = ref off in
let len = ref len in
let linelen = ref 0 in
- let linechars = String.make 16 ' ' in
+ let linechars = Bytes.make 16 ' ' in
fprintf chan "00000000 ";
@@ -1256,22 +1263,22 @@ let hexdump_bitstring chan (data, off, len) =
fprintf chan "%02x " byte;
incr count;
- linechars.[!linelen] <-
+ Bytes.set linechars !linelen
(let c = Char.chr byte in
if isprint c then c else '.');
incr linelen;
if !linelen = 8 then fprintf chan " ";
if !linelen = 16 then (
- fprintf chan " |%s|\n%08x " linechars !count;
+ fprintf chan " |%s|\n%08x " (Bytes.unsafe_to_string linechars) !count;
linelen := 0;
- for i = 0 to 15 do linechars.[i] <- ' ' done
+ for i = 0 to 15 do Bytes.set linechars i ' ' done
)
done;
if !linelen > 0 then (
let skip = (16 - !linelen) * 3 + if !linelen < 8 then 1 else 0 in
for i = 0 to skip-1 do fprintf chan " " done;
- fprintf chan " |%s|\n%!" linechars
+ fprintf chan " |%s|\n%!" (Bytes.unsafe_to_string linechars)
) else
fprintf chan "\n%!"
diff --git a/bitstring.mli b/src/bitstring.mli
index 93113c0..1aaec16 100644
--- a/bitstring.mli
+++ b/src/bitstring.mli
@@ -650,10 +650,10 @@ type endian = BigEndian | LittleEndian | NativeEndian
val string_of_endian : endian -> string
(** Endianness. *)
-type bitstring = string * int * int
+type bitstring = bytes * int * int
(** [bitstring] is the basic type used to store bitstrings.
- The type contains the underlying data (a string),
+ The type contains the underlying data (a bytes),
the current bit offset within the string and the
current bit length of the string (counting from the
bit offset). Note that the offset and length are
@@ -876,7 +876,7 @@ module Buffer : sig
type t
val create : unit -> t
val contents : t -> bitstring
- val add_bits : t -> string -> int -> unit
+ val add_bits : t -> bytes -> int -> unit
val add_bit : t -> bool -> unit
val add_byte : t -> int -> unit
end
@@ -916,12 +916,6 @@ val get : bitstring -> int -> int
(** {3 Miscellaneous} *)
-val package : string
-(** The package name, always ["ocaml-bitstring"] *)
-
-val version : string
-(** The package version as a string. *)
-
val debug : bool ref
(** Set this variable to true to enable extended debugging.
This only works if debugging was also enabled in the
@@ -936,131 +930,131 @@ val debug : bool ref
(* 'extract' functions are used in bitmatch statements. *)
-val extract_bit : string -> int -> int -> int -> bool
+val extract_bit : bytes -> int -> int -> int -> bool
-val extract_char_unsigned : string -> int -> int -> int -> int
+val extract_char_unsigned : bytes -> int -> int -> int -> int
-val extract_char_signed : string -> int -> int -> int -> int
+val extract_char_signed : bytes -> int -> int -> int -> int
-val extract_int_be_unsigned : string -> int -> int -> int -> int
+val extract_int_be_unsigned : bytes -> int -> int -> int -> int
-val extract_int_be_signed : string -> int -> int -> int -> int
+val extract_int_be_signed : bytes -> int -> int -> int -> int
-val extract_int_le_unsigned : string -> int -> int -> int -> int
+val extract_int_le_unsigned : bytes -> int -> int -> int -> int
-val extract_int_le_signed : string -> int -> int -> int -> int
+val extract_int_le_signed : bytes -> int -> int -> int -> int
-val extract_int_ne_unsigned : string -> int -> int -> int -> int
+val extract_int_ne_unsigned : bytes -> int -> int -> int -> int
-val extract_int_ne_signed : string -> int -> int -> int -> int
+val extract_int_ne_signed : bytes -> int -> int -> int -> int
-val extract_int_ee_unsigned : endian -> string -> int -> int -> int -> int
+val extract_int_ee_unsigned : endian -> bytes -> int -> int -> int -> int
-val extract_int_ee_signed : endian -> string -> int -> int -> int -> int
+val extract_int_ee_signed : endian -> bytes -> int -> int -> int -> int
-val extract_int32_be_unsigned : string -> int -> int -> int -> int32
+val extract_int32_be_unsigned : bytes -> int -> int -> int -> int32
-val extract_int32_le_unsigned : string -> int -> int -> int -> int32
+val extract_int32_le_unsigned : bytes -> int -> int -> int -> int32
-val extract_int32_ne_unsigned : string -> int -> int -> int -> int32
+val extract_int32_ne_unsigned : bytes -> int -> int -> int -> int32
-val extract_int32_ee_unsigned : endian -> string -> int -> int -> int -> int32
+val extract_int32_ee_unsigned : endian -> bytes -> int -> int -> int -> int32
-val extract_int64_be_unsigned : string -> int -> int -> int -> int64
+val extract_int64_be_unsigned : bytes -> int -> int -> int -> int64
-val extract_int64_le_unsigned : string -> int -> int -> int -> int64
+val extract_int64_le_unsigned : bytes -> int -> int -> int -> int64
-val extract_int64_ne_unsigned : string -> int -> int -> int -> int64
+val extract_int64_ne_unsigned : bytes -> int -> int -> int -> int64
-val extract_int64_ee_unsigned : endian -> string -> int -> int -> int -> int64
+val extract_int64_ee_unsigned : endian -> bytes -> int -> int -> int -> int64
-external extract_fastpath_int16_be_unsigned : string -> int -> int = "ocaml_bitstring_extract_fastpath_int16_be_unsigned" "noalloc"
+external extract_fastpath_int16_be_unsigned : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int16_be_unsigned"
-external extract_fastpath_int16_le_unsigned : string -> int -> int = "ocaml_bitstring_extract_fastpath_int16_le_unsigned" "noalloc"
+external extract_fastpath_int16_le_unsigned : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int16_le_unsigned"
-external extract_fastpath_int16_ne_unsigned : string -> int -> int = "ocaml_bitstring_extract_fastpath_int16_ne_unsigned" "noalloc"
+external extract_fastpath_int16_ne_unsigned : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int16_ne_unsigned"
-external extract_fastpath_int16_be_signed : string -> int -> int = "ocaml_bitstring_extract_fastpath_int16_be_signed" "noalloc"
+external extract_fastpath_int16_be_signed : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int16_be_signed"
-external extract_fastpath_int16_le_signed : string -> int -> int = "ocaml_bitstring_extract_fastpath_int16_le_signed" "noalloc"
+external extract_fastpath_int16_le_signed : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int16_le_signed"
-external extract_fastpath_int16_ne_signed : string -> int -> int = "ocaml_bitstring_extract_fastpath_int16_ne_signed" "noalloc"
+external extract_fastpath_int16_ne_signed : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int16_ne_signed"
(*
-external extract_fastpath_int24_be_unsigned : string -> int -> int = "ocaml_bitstring_extract_fastpath_int24_be_unsigned" "noalloc"
+external extract_fastpath_int24_be_unsigned : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int24_be_unsigned"
-external extract_fastpath_int24_le_unsigned : string -> int -> int = "ocaml_bitstring_extract_fastpath_int24_le_unsigned" "noalloc"
+external extract_fastpath_int24_le_unsigned : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int24_le_unsigned"
-external extract_fastpath_int24_ne_unsigned : string -> int -> int = "ocaml_bitstring_extract_fastpath_int24_ne_unsigned" "noalloc"
+external extract_fastpath_int24_ne_unsigned : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int24_ne_unsigned"
-external extract_fastpath_int24_be_signed : string -> int -> int = "ocaml_bitstring_extract_fastpath_int24_be_signed" "noalloc"
+external extract_fastpath_int24_be_signed : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int24_be_signed"
-external extract_fastpath_int24_le_signed : string -> int -> int = "ocaml_bitstring_extract_fastpath_int24_le_signed" "noalloc"
+external extract_fastpath_int24_le_signed : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int24_le_signed"
-external extract_fastpath_int24_ne_signed : string -> int -> int = "ocaml_bitstring_extract_fastpath_int24_ne_signed" "noalloc"
+external extract_fastpath_int24_ne_signed : bytes -> int -> int = "ocaml_bitstring_extract_fastpath_int24_ne_signed"
*)
-external extract_fastpath_int32_be_unsigned : string -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_be_unsigned"
+external extract_fastpath_int32_be_unsigned : bytes -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_be_unsigned"
-external extract_fastpath_int32_le_unsigned : string -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_le_unsigned"
+external extract_fastpath_int32_le_unsigned : bytes -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_le_unsigned"
-external extract_fastpath_int32_ne_unsigned : string -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_ne_unsigned"
+external extract_fastpath_int32_ne_unsigned : bytes -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_ne_unsigned"
-external extract_fastpath_int32_be_signed : string -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_be_signed"
+external extract_fastpath_int32_be_signed : bytes -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_be_signed"
-external extract_fastpath_int32_le_signed : string -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_le_signed"
+external extract_fastpath_int32_le_signed : bytes -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_le_signed"
-external extract_fastpath_int32_ne_signed : string -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_ne_signed"
+external extract_fastpath_int32_ne_signed : bytes -> int -> int32 = "ocaml_bitstring_extract_fastpath_int32_ne_signed"
(*
-external extract_fastpath_int40_be_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_be_unsigned"
+external extract_fastpath_int40_be_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_be_unsigned"
-external extract_fastpath_int40_le_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_le_unsigned"
+external extract_fastpath_int40_le_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_le_unsigned"
-external extract_fastpath_int40_ne_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_ne_unsigned"
+external extract_fastpath_int40_ne_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_ne_unsigned"
-external extract_fastpath_int40_be_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_be_signed"
+external extract_fastpath_int40_be_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_be_signed"
-external extract_fastpath_int40_le_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_le_signed"
+external extract_fastpath_int40_le_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_le_signed"
-external extract_fastpath_int40_ne_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_ne_signed"
+external extract_fastpath_int40_ne_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int40_ne_signed"
-external extract_fastpath_int48_be_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_be_unsigned"
+external extract_fastpath_int48_be_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_be_unsigned"
-external extract_fastpath_int48_le_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_le_unsigned"
+external extract_fastpath_int48_le_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_le_unsigned"
-external extract_fastpath_int48_ne_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_ne_unsigned"
+external extract_fastpath_int48_ne_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_ne_unsigned"
-external extract_fastpath_int48_be_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_be_signed"
+external extract_fastpath_int48_be_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_be_signed"
-external extract_fastpath_int48_le_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_le_signed"
+external extract_fastpath_int48_le_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_le_signed"
-external extract_fastpath_int48_ne_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_ne_signed"
+external extract_fastpath_int48_ne_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int48_ne_signed"
-external extract_fastpath_int56_be_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_be_unsigned"
+external extract_fastpath_int56_be_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_be_unsigned"
-external extract_fastpath_int56_le_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_le_unsigned"
+external extract_fastpath_int56_le_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_le_unsigned"
-external extract_fastpath_int56_ne_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_ne_unsigned"
+external extract_fastpath_int56_ne_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_ne_unsigned"
-external extract_fastpath_int56_be_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_be_signed"
+external extract_fastpath_int56_be_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_be_signed"
-external extract_fastpath_int56_le_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_le_signed"
+external extract_fastpath_int56_le_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_le_signed"
-external extract_fastpath_int56_ne_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_ne_signed"
+external extract_fastpath_int56_ne_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int56_ne_signed"
*)
-external extract_fastpath_int64_be_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_be_unsigned"
+external extract_fastpath_int64_be_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_be_unsigned"
-external extract_fastpath_int64_le_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_le_unsigned"
+external extract_fastpath_int64_le_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_le_unsigned"
-external extract_fastpath_int64_ne_unsigned : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_ne_unsigned"
+external extract_fastpath_int64_ne_unsigned : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_ne_unsigned"
-external extract_fastpath_int64_be_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_be_signed"
+external extract_fastpath_int64_be_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_be_signed"
-external extract_fastpath_int64_le_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_le_signed"
+external extract_fastpath_int64_le_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_le_signed"
-external extract_fastpath_int64_ne_signed : string -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_ne_signed"
+external extract_fastpath_int64_ne_signed : bytes -> int -> int64 = "ocaml_bitstring_extract_fastpath_int64_ne_signed"
(* 'construct' functions are used in BITSTRING constructors. *)
val construct_bit : Buffer.t -> bool -> int -> exn -> unit
diff --git a/bitstring_c.c b/src/bitstring_c.c
index d376f76..6c2f3ab 100644
--- a/bitstring_c.c
+++ b/src/bitstring_c.c
@@ -23,7 +23,11 @@
* certain very frequently used functions.
*/
-#include <config.h>
+#if defined(__APPLE__)
+#include <machine/endian.h>
+#else
+#include <endian.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
@@ -60,7 +64,7 @@
* requires some extra work because sign-extension won't "just happen".
*/
-#ifdef WORDS_BIGENDIAN
+#if BYTE_ORDER == BIG_ENDIAN
#define swap_be(size,v)
#define swap_le(size,v) v = bswap_##size (v)
#define swap_ne(size,v)
diff --git a/bitstring_config.ml.in b/src/bitstring_config.ml
index d079a75..bc8433b 100644
--- a/bitstring_config.ml.in
+++ b/src/bitstring_config.ml
@@ -25,10 +25,7 @@
* configure script.
*)
-let nativeendian = Bitstring_types.@NATIVEENDIAN@
-
-let package = "@PACKAGE_NAME@"
-let version = "@PACKAGE_VERSION@"
-let ocamllibdir = "@OCAMLLIB@"
-
-let diff = "@DIFF@"
+let nativeendian =
+ if Sys.big_endian
+ then Bitstring_types.BigEndian
+ else Bitstring_types.LittleEndian
diff --git a/bitstring_types.ml b/src/bitstring_types.ml
index 459bc4f..459bc4f 100644
--- a/bitstring_types.ml
+++ b/src/bitstring_types.ml
diff --git a/byteswap.in.h b/src/byteswap.h
index 5e4652e..5e4652e 100644
--- a/byteswap.in.h
+++ b/src/byteswap.h
diff --git a/src/jbuild b/src/jbuild
new file mode 100644
index 0000000..f22aae1
--- /dev/null
+++ b/src/jbuild
@@ -0,0 +1,9 @@
+(jbuild_version 1)
+
+(library
+ ((name bitstring)
+ (public_name bitstring)
+ (c_names (bitstring_c))
+ (c_flags (-I.))
+ (libraries (unix))
+ ))
diff --git a/t12_signed_bytes_limits.ml b/t12_signed_bytes_limits.ml
deleted file mode 100644
index e252542..0000000
--- a/t12_signed_bytes_limits.ml
+++ /dev/null
@@ -1,36 +0,0 @@
-let a = Array.init 387 (fun i -> i - 129)
-
-let limits b =
- Array.fold_left
- (fun (mini,maxi) i ->
- try
- ignore (b i);
- (min mini i, max maxi i)
- with
- _ -> (mini, maxi))
- (0,0)
- a
-
-let () =
- if
- List.map limits [
- (fun i -> BITSTRING { i : 2 : signed });
- (fun i -> BITSTRING { i : 3 : signed });
- (fun i -> BITSTRING { i : 4 : signed });
- (fun i -> BITSTRING { i : 5 : signed });
- (fun i -> BITSTRING { i : 6 : signed });
- (fun i -> BITSTRING { i : 7 : signed });
- (fun i -> BITSTRING { i : 8 : signed });
- ]
- <>
- [
- (-2, 3);
- (-4, 7);
- (-8, 15);
- (-16, 31);
- (-32, 63);
- (-64, 127);
- (-128, 255)
- ]
- then
- failwith("t12_signed_bytes_limits: failed")
diff --git a/t13_signed_byte_create.ml b/t13_signed_byte_create.ml
deleted file mode 100644
index a37e116..0000000
--- a/t13_signed_byte_create.ml
+++ /dev/null
@@ -1,26 +0,0 @@
-let a n =
- let n' = 1 lsl (pred n) in
- Array.to_list (Array.init n' (fun i -> -(n'-i), n'+i)) @
- Array.to_list (Array.init (n' lsl 1) (fun i -> i,i));;
-
-let t s i =
- List.fold_left
- (fun ok (n,c) -> s n = String.make 1 (Char.chr (c lsl (8-i))) && ok )
- true
- (a i);;
-
-let ok = fst (List.fold_left (fun (ok,i) s ->
- t s i && ok, succ i) (true, 2)
- [
- (fun i -> Bitstring.string_of_bitstring (BITSTRING { i : 2 : signed }));
- (fun i -> Bitstring.string_of_bitstring (BITSTRING { i : 3 : signed }));
- (fun i -> Bitstring.string_of_bitstring (BITSTRING { i : 4 : signed }));
- (fun i -> Bitstring.string_of_bitstring (BITSTRING { i : 5 : signed }));
- (fun i -> Bitstring.string_of_bitstring (BITSTRING { i : 6 : signed }));
- (fun i -> Bitstring.string_of_bitstring (BITSTRING { i : 7 : signed }));
- (fun i -> Bitstring.string_of_bitstring (BITSTRING { i : 8 : signed }));
- ])
-
-in
-if not ok then
- failwith("t13_signed_byte_create: failed")
diff --git a/t141_signed_int_limits.ml b/t141_signed_int_limits.ml
deleted file mode 100644
index 2a987fa..0000000
--- a/t141_signed_int_limits.ml
+++ /dev/null
@@ -1,131 +0,0 @@
-let () = Random.self_init ();;
-
-
-if not (
- fst (List.fold_left (fun (ok, i) (b,m) ->
- let above_maxp = 1 lsl i in
- let maxp = pred above_maxp in
- let minp = - (above_maxp lsr 1) in
- let below_minp = pred minp in
- let gut =
- try ignore (b maxp); true
- with _ -> false in
- let gut2 =
- try ignore (b above_maxp); false
- with _ -> true in
- let gut3 =
- try ignore (b minp); true
- with _ -> false in
- let gut4 =
- try ignore (b below_minp); false
- with _ -> true in
-
-
- let gut5 =
- let plage = Int32.shift_left 1l i in
- let test () =
- let signed_number =
- Int32.to_int ( Int32.add (Random.int32 plage) (Int32.of_int minp) ) in
- let bits = b signed_number in
- let number' = m bits in
- if signed_number = number' then true
- else
- begin
- Printf.printf "bits:%d n=%d read=%d (%d %d)\n" i signed_number number' minp maxp;
- false
- end in
- let res = ref true in
- for i = 1 to 10_000 do
- res := !res && test ()
- done;
- !res in
-
- (gut && gut2 && gut3 && gut4 && gut5 && ok, succ i)
-
- )
- (true, 9)
- [
- (fun n -> BITSTRING { n : 9 : signed }),
- (fun b -> bitmatch b with { n: 9 : signed } -> n);
- (fun n -> BITSTRING { n : 10 : signed }),
- (fun b -> bitmatch b with { n : 10 : signed } -> n);
- (fun n -> BITSTRING { n : 11 : signed }),
- (fun b -> bitmatch b with { n : 11 : signed } -> n);
- (fun n -> BITSTRING { n : 12 : signed }),
- (fun b -> bitmatch b with { n : 12 : signed } -> n);
- (fun n -> BITSTRING { n : 13 : signed }),
- (fun b -> bitmatch b with { n : 13 : signed } -> n);
- (fun n -> BITSTRING { n : 14 : signed }),
- (fun b -> bitmatch b with { n : 14 : signed } -> n);
- (fun n -> BITSTRING { n : 15 : signed }),
- (fun b -> bitmatch b with { n : 15 : signed } -> n);
- (fun n -> BITSTRING { n : 16 : signed }),
- (fun b -> bitmatch b with { n : 16 : signed } -> n);
- (fun n -> BITSTRING { n : 17 : signed }),
- (fun b -> bitmatch b with { n : 17 : signed } -> n);
- (fun n -> BITSTRING { n : 18 : signed }),
- (fun b -> bitmatch b with { n : 18 : signed } -> n);
- (fun n -> BITSTRING { n : 19 : signed }),
- (fun b -> bitmatch b with { n : 19 : signed } -> n);
- (fun n -> BITSTRING { n : 20 : signed }),
- (fun b -> bitmatch b with { n : 20 : signed } -> n);
- (fun n -> BITSTRING { n : 21 : signed }),
- (fun b -> bitmatch b with { n : 21 : signed } -> n);
- (fun n -> BITSTRING { n : 22 : signed }),
- (fun b -> bitmatch b with { n : 22 : signed } -> n);
- (fun n -> BITSTRING { n : 23 : signed }),
- (fun b -> bitmatch b with { n : 23 : signed } -> n);
- (fun n -> BITSTRING { n : 24 : signed }),
- (fun b -> bitmatch b with { n : 24 : signed } -> n);
- (fun n -> BITSTRING { n : 25 : signed }),
- (fun b -> bitmatch b with { n : 25 : signed } -> n);
- (fun n -> BITSTRING { n : 26 : signed }),
- (fun b -> bitmatch b with { n : 26 : signed } -> n);
- (fun n -> BITSTRING { n : 27 : signed }),
- (fun b -> bitmatch b with { n : 27 : signed } -> n);
- (fun n -> BITSTRING { n : 28 : signed }),
- (fun b -> bitmatch b with { n : 28 : signed } -> n);
- (fun n -> BITSTRING { n : 29 : signed }),
- (fun b -> bitmatch b with { n : 29 : signed } -> n);
- (fun n -> BITSTRING { n : 30 : signed }),
- (fun b -> bitmatch b with { n : 30 : signed } -> n);
- ]
- ) &&
-
- begin
- try
- if Sys.word_size = 32 then
- begin
- ignore (BITSTRING { max_int : 31 : signed });
- ignore (BITSTRING { min_int : 31 : signed });
- end
- else
- begin
- ignore (BITSTRING { pred (1 lsl 31) : 31 : signed });
- ignore (BITSTRING { (-1 lsl 30) : 31 : signed });
- end;
- true
- with
- _ ->
- false;
- end
-
- &&
-
- begin
- if Sys.word_size = 64 then
- try
- ignore (BITSTRING { 1 lsl 31 : 31 : signed });
- ignore (BITSTRING { pred (-1 lsl 30) : 31 : signed });
- false
- with _ -> true
- else
- true
- end
-
-)
-then
- failwith("t141_signed_int_limits: failed")
-
-
-(* Manquent les tests random pour bits = 31 *)
diff --git a/t14_signed_byte_match.ml b/t14_signed_byte_match.ml
deleted file mode 100644
index 6e17743..0000000
--- a/t14_signed_byte_match.ml
+++ /dev/null
@@ -1,27 +0,0 @@
-let a n =
- let n' = 1 lsl (pred n) in
- Array.to_list (Array.init (n' lsl 1) (fun i -> i-n'))
-
-let t s i =
- List.fold_left
- (fun ok n -> s n = n && ok )
- true
- (a i);;
-
-let ok = fst (List.fold_left (fun (ok,i) s ->
- t s i && ok, succ i) (true, 2)
-[
- (fun n -> bitmatch BITSTRING { n : 2 : signed } with { i : 2 : signed } -> i | { _ } -> assert false);
- (fun n -> bitmatch BITSTRING { n : 3 : signed } with { i : 3 : signed } -> i | { _ } -> assert false);
- (fun n -> bitmatch BITSTRING { n : 4 : signed } with { i : 4 : signed } -> i | { _ } -> assert false);
- (fun n -> bitmatch BITSTRING { n : 5 : signed } with { i : 5 : signed } -> i | { _ } -> assert false);
- (fun n -> bitmatch BITSTRING { n : 6 : signed } with { i : 6 : signed } -> i | { _ } -> assert false);
- (fun n -> bitmatch BITSTRING { n : 7 : signed } with { i : 7 : signed } -> i | { _ } -> assert false);
- (fun n -> bitmatch BITSTRING { n : 8 : signed } with { i : 8 : signed } -> i | { _ } -> assert false);
-])
-
-in
-if not ok then
- failwith("t13_signed_byte_create: failed")
-
-
diff --git a/tests/.merlin b/tests/.merlin
new file mode 100644
index 0000000..96fa256
--- /dev/null
+++ b/tests/.merlin
@@ -0,0 +1,9 @@
+B ../_build/default/src
+B ../_build/default/tests
+FLG -ppx '/Users/xguerin/Workspace/bitstring/_build/default/.ppx/ppx_bitstring/ppx.exe --as-ppx'
+FLG -w -40
+PKG bytes
+PKG oUnit
+PKG oUnit.advanced
+PKG unix
+S ../src
diff --git a/tests/BitstringConstructorTest.ml b/tests/BitstringConstructorTest.ml
new file mode 100644
index 0000000..3fb6061
--- /dev/null
+++ b/tests/BitstringConstructorTest.ml
@@ -0,0 +1,146 @@
+(*
+ * Copyright (c) 2016 Xavier R. Guérin <copyright@applepine.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *)
+
+open OUnit2
+open Bitstring
+
+(*
+ * Imbricated bitstring test
+ *)
+
+let imbricated_bistring_test context =
+ let result = "\xde\xad\xbe\xef\x42\x0a" in
+ let magic = "\xde\xad\xbe\xef" in
+ let version = 0x42 in
+ let data = 10 in
+ let header = [%bitstring {| version : 8 |}] in
+ let bits = [%bitstring
+ {| magic : -1 : string
+ ; header : -1 : bitstring
+ ; data : 8
+ |}] in
+ let dump = Bitstring.string_of_bitstring bits in
+ assert_equal result dump
+
+(*
+ * Constructor style test
+ *)
+
+let constructor_style_test context =
+ let%bitstring bits1 = {| "GIF87a" : 6*8 : string
+ ; 2145 : 16 : littleendian
+ ; 2145 : 16 : littleendian
+ ; true : 1
+ ; 7 : 3
+ ; false : 1
+ ; 7 : 3
+ ; 0 : 8
+ ; 0 : 8
+ |} in
+ let bits2 = [%bitstring {| "GIF87a" : 6*8 : string
+ ; 2145 : 16 : littleendian
+ ; 2145 : 16 : littleendian
+ ; true : 1
+ ; 7 : 3
+ ; false : 1
+ ; 7 : 3
+ ; 0 : 8
+ ; 0 : 8
+ |}] in
+ assert_bool "Bistrings are not equal" (Bitstring.equals bits1 bits2)
+
+(*
+ * Swap test
+ *)
+
+let swap bs =
+ match%bitstring bs with
+ | {| a : 1 : bitstring; b : 1 : bitstring|} ->
+ [%bitstring {| b : 1 : bitstring; a : 1 : bitstring |}]
+ | {| _ |} -> failwith "invalid input"
+
+let swap_test context =
+ let one = [%bitstring {| 1 : 2 |}] in
+ let two = [%bitstring {| 2 : 2 |}] in
+ let three = [%bitstring {| 3 : 2 |}] in
+ assert_bool "Bitstring swap failed" (Bitstring.equals two (swap one));
+ assert_bool "Bitstring swap failed" (Bitstring.equals one (swap two));
+ assert_bool "Bitstring swap failed" (Bitstring.equals three (swap three))
+
+(*
+ * External value test
+ *)
+
+let external_value_test context =
+ let result = "\x00\x02\x00\x00\x00\x01\xC0" in
+ let int16_value = 2 in
+ let int32_value = 1_l in
+ let bool_value = true in
+ let bits = [%bitstring {| int16_value : 16
+ ; int32_value : 32
+ ; 1 : 1
+ ; bool_value : 1
+ ; 0 : 6
+ |}] in
+ let str = Bitstring.string_of_bitstring bits in
+ assert_equal str result
+
+(*
+ * Int for [17,31] bits test
+ *)
+
+let int_parser_test context =
+ let result = "\x00\x00\x02" in
+ let%bitstring bits = {| 2 : 24 |} in
+ let str = Bitstring.string_of_bitstring bits in
+ assert_equal str result
+
+(*
+ * Int32 for 32 bits test
+ *)
+
+let int32_parser_test context =
+ let result = "\x00\x00\x00\x02" in
+ let%bitstring bits = {| 2_l : 32 |} in
+ let str = Bitstring.string_of_bitstring bits in
+ assert_equal str result
+
+(*
+ * Structural let
+ *)
+
+let%bitstring ext_bits = {| 2_l : 32 |}
+
+let str_item_test context =
+ let result = "\x00\x00\x00\x02" in
+ let str = Bitstring.string_of_bitstring ext_bits in
+ assert_equal str result
+
+(*
+ * Test suite definition
+ *)
+
+let suite = "BitstringConstructorTest" >::: [
+ "imbricated_bistring_test" >:: imbricated_bistring_test;
+ "constructor_style_test" >:: constructor_style_test;
+ "swap_test" >:: swap_test;
+ "external_value_test" >:: external_value_test;
+ "int_parser_test" >:: int_parser_test;
+ "int32_parser_test" >:: int32_parser_test;
+ "str_item_test" >:: str_item_test
+ ]
+
+let () = run_test_tt_main suite
diff --git a/tests/BitstringConstructorTest.mli b/tests/BitstringConstructorTest.mli
new file mode 100644
index 0000000..caa5fd8
--- /dev/null
+++ b/tests/BitstringConstructorTest.mli
@@ -0,0 +1 @@
+val suite : OUnit2.test
diff --git a/tests/BitstringLegacyTest.ml b/tests/BitstringLegacyTest.ml
new file mode 100644
index 0000000..09f13aa
--- /dev/null
+++ b/tests/BitstringLegacyTest.ml
@@ -0,0 +1,1251 @@
+open OUnit2
+open Printf
+
+(*
+ * Helper functions
+ *)
+
+let rec range a b =
+ if a <= b then
+ a :: range (a+1) b
+ else
+ []
+
+(*
+ * Just check that the extension and library load without error.
+ *)
+
+let load_test _ =
+ let _ = Bitstring.extract_bit in ()
+
+(*
+ * Just check that we can run some functions from the library.
+ *)
+
+let run_test _ =
+ let bits = Bitstring.create_bitstring 16 in
+ ignore (Bitstring.string_of_bitstring bits)
+
+(*
+ * Match random bits.
+ *)
+
+let match_random_bits_test _ =
+ Random.self_init ();
+
+ for len = 0 to 999 do
+ (*
+ * Create a random string of bits.
+ *)
+ let expected = List.map (fun _ -> Random.bool ()) (range 0 (len-1)) in
+
+ let bits = Bitstring.Buffer.create () in
+ List.iter (Bitstring.Buffer.add_bit bits) expected;
+ let bits = Bitstring.Buffer.contents bits in
+ (*
+ * Now read the bitstring in groups of 1, 2, 3 .. etc. bits. In each case
+ * check the result against what we generated ('expected').
+ *)
+ let actual =
+ let rec loop bits =
+ match%bitstring bits with
+ | {| b0 : 1; rest : -1 : bitstring |} -> b0 :: loop rest
+ | {| _ |} -> []
+ in
+ loop bits in
+ assert_equal actual expected;
+ (*
+ *)
+ let actual =
+ let rec loop bits =
+ match%bitstring bits with
+ | {| b0 : 1; b1 : 1; rest : -1 : bitstring |} -> b0 :: b1 :: loop rest
+ | {| b0 : 1; rest : -1 : bitstring |} -> b0 :: loop rest
+ | {| _ |} -> []
+ in
+ loop bits in
+ assert_equal actual expected;
+ (*
+ *)
+ let actual =
+ let rec loop bits =
+ match%bitstring bits with
+ | {| b0 : 1; b1 : 1; b2 : 1;
+ rest : -1 : bitstring |} -> b0 :: b1 :: b2 :: loop rest
+ | {| b0 : 1; rest : -1 : bitstring |} -> b0 :: loop rest
+ | {| _ |} -> []
+ in
+ loop bits in
+ assert_equal actual expected;
+ (*
+ *)
+ let actual =
+ let rec loop bits =
+ match%bitstring bits with
+ | {| b0 : 1; b1 : 1; b2 : 1; b3 : 1;
+ rest : -1 : bitstring |} -> b0 :: b1 :: b2 :: b3 :: loop rest
+ | {| b0 : 1; rest : -1 : bitstring |} -> b0 :: loop rest
+ | {| _ |} -> []
+ in
+ loop bits in
+ assert_equal actual expected;
+ (*
+ *)
+ let actual =
+ let rec loop bits =
+ match%bitstring bits with
+ | {| b0 : 1; b1 : 1; b2 : 1; b3 : 1;
+ b4 : 1; b5 : 1; b6 : 1; b7 : 1;
+ b8 : 1;
+ rest : -1 : bitstring |} ->
+ b0 :: b1 :: b2 :: b3 :: b4 :: b5 :: b6 :: b7 :: b8 :: loop rest
+ | {| b0 : 1; rest : -1 : bitstring |} -> b0 :: loop rest
+ | {| _ |} -> []
+ in
+ loop bits in
+ assert_equal actual expected;
+ done
+
+(*
+ * Match random bits with integers.
+ *)
+
+let match_random_bits_with_int_test _ =
+ Random.self_init ();
+
+ for len = 1 to 99 do
+ for bitlen = 1 to 63 do
+ (*
+ * Create a random string of ints.
+ *)
+ let expected =
+ List.map (fun _ ->
+ Random.int64 (Int64.sub (Int64.shift_left 1L bitlen) 1L))
+ (range 0 (len-1)) in
+
+ let bits = Bitstring.Buffer.create () in
+ List.iter (fun i ->
+ Bitstring.construct_int64_be_unsigned bits i bitlen
+ (Failure "constructing string"))
+ expected;
+ let bits = Bitstring.Buffer.contents bits in
+ (*
+ * Now read the bitstring as integers.
+ * In each case check the result against what we generated ('expected').
+ *)
+ let actual =
+ let rec loop bits =
+ match%bitstring bits with
+ | {| i : bitlen; rest : -1 : bitstring |}
+ when Bitstring.bitstring_length rest = 0 -> [i]
+ | {| i : bitlen; rest : -1 : bitstring |} -> i :: loop rest
+ | {| _ |} ->
+ failwith (sprintf "loop failed with len = %d, bitlen = %d"
+ len bitlen)
+ in
+ loop bits in
+ assert_equal actual expected
+ done
+ done
+
+(*
+ * Check value limits.
+ *)
+
+let check_value_limits_test _ =
+ let a = Array.init 387 (fun i -> i - 129) in
+ let limits b =
+ Array.fold_left
+ (fun (mini,maxi) i ->
+ try
+ ignore (b i);
+ (min mini i, max maxi i)
+ with
+ _ -> (mini, maxi))
+ (0,0)
+ a
+ in
+ assert_equal
+ (List.map limits [
+ (fun i -> [%bitstring {| i : 2 : signed |}]);
+ (fun i -> [%bitstring {| i : 3 : signed |}]);
+ (fun i -> [%bitstring {| i : 4 : signed |}]);
+ (fun i -> [%bitstring {| i : 5 : signed |}]);
+ (fun i -> [%bitstring {| i : 6 : signed |}]);
+ (fun i -> [%bitstring {| i : 7 : signed |}]);
+ (fun i -> [%bitstring {| i : 8 : signed |}]);
+ ])
+ [
+ (-2, 3);
+ (-4, 7);
+ (-8, 15);
+ (-16, 31);
+ (-32, 63);
+ (-64, 127);
+ (-128, 255)
+ ]
+
+(*
+ * Signed byte create.
+ *)
+
+let signed_byte_create_test _ =
+ let a n =
+ let n' = 1 lsl (pred n) in
+ Array.to_list (Array.init n' (fun i -> -(n'-i), n'+i)) @
+ Array.to_list (Array.init (n' lsl 1) (fun i -> i,i))
+ in
+ let t s i =
+ List.fold_left
+ (fun ok (n,c) -> s n = String.make 1 (Char.chr (c lsl (8-i))) && ok )
+ true
+ (a i)
+ in
+ let ok = fst (List.fold_left (fun (ok,i) s ->
+ t s i && ok, succ i) (true, 2)
+ [
+ (fun i -> Bitstring.string_of_bitstring [%bitstring {| i : 2 : signed |}]);
+ (fun i -> Bitstring.string_of_bitstring [%bitstring {| i : 3 : signed |}]);
+ (fun i -> Bitstring.string_of_bitstring [%bitstring {| i : 4 : signed |}]);
+ (fun i -> Bitstring.string_of_bitstring [%bitstring {| i : 5 : signed |}]);
+ (fun i -> Bitstring.string_of_bitstring [%bitstring {| i : 6 : signed |}]);
+ (fun i -> Bitstring.string_of_bitstring [%bitstring {| i : 7 : signed |}]);
+ (fun i -> Bitstring.string_of_bitstring [%bitstring {| i : 8 : signed |}]);
+ ])
+ in
+ assert_equal ok true
+
+(*
+ * Signed byte create and match
+ *)
+
+let signed_byte_create_and_match_test _ =
+ let a n =
+ let n' = 1 lsl (pred n) in
+ Array.to_list (Array.init (n' lsl 1) (fun i -> i-n'))
+ in
+
+ let t s i =
+ List.fold_left
+ (fun ok n -> s n = n && ok )
+ true
+ (a i)
+ in
+ let ok = fst (List.fold_left (fun (ok,i) s ->
+ t s i && ok, succ i) (true, 2)
+ [
+ (fun n -> match%bitstring [%bitstring {| n : 2 : signed |}] with {| i : 2 : signed |} -> i | {| _ |} -> assert false);
+ (fun n -> match%bitstring [%bitstring {| n : 3 : signed |}] with {| i : 3 : signed |} -> i | {| _ |} -> assert false);
+ (fun n -> match%bitstring [%bitstring {| n : 4 : signed |}] with {| i : 4 : signed |} -> i | {| _ |} -> assert false);
+ (fun n -> match%bitstring [%bitstring {| n : 5 : signed |}] with {| i : 5 : signed |} -> i | {| _ |} -> assert false);
+ (fun n -> match%bitstring [%bitstring {| n : 6 : signed |}] with {| i : 6 : signed |} -> i | {| _ |} -> assert false);
+ (fun n -> match%bitstring [%bitstring {| n : 7 : signed |}] with {| i : 7 : signed |} -> i | {| _ |} -> assert false);
+ (fun n -> match%bitstring [%bitstring {| n : 8 : signed |}] with {| i : 8 : signed |} -> i | {| _ |} -> assert false);
+ ])
+ in
+ assert_equal ok true
+
+(*
+ * Signed int limits
+ *)
+
+let signed_int_limits_test _ =
+ Random.self_init ();
+ let res = List.fold_left
+ (fun (ok, i) (b, m) ->
+ let above_maxp = 1 lsl i in
+ let maxp = pred above_maxp in
+ let minp = - (above_maxp lsr 1) in
+ let below_minp = pred minp in
+ let gut =
+ try ignore (b maxp); true
+ with _ -> false in
+ let gut2 =
+ try ignore (b above_maxp); false
+ with _ -> true in
+ let gut3 =
+ try ignore (b minp); true
+ with _ -> false in
+ let gut4 =
+ try ignore (b below_minp); false
+ with _ -> true in
+ let gut5 =
+ let plage = Int32.shift_left 1l i in
+ let test () =
+ let signed_number =
+ Int32.to_int (Int32.add (Random.int32 plage) (Int32.of_int minp)) in
+ let bits = b signed_number in
+ let number' = m bits in
+ if signed_number = number' then true
+ else
+ begin
+ Printf.printf "bits:%d n=%x read=%x (%x %x)\n" i signed_number number' minp maxp;
+ false
+ end in
+ let res = ref true in
+ for i = 1 to 10_000 do
+ res := !res && test ()
+ done;
+ !res
+ in
+ (gut && gut2 && gut3 && gut4 && gut5 && ok, succ i)
+ )
+ (true, 9)
+ [
+ (fun n -> [%bitstring {| n : 9 : signed |}]),
+ (fun b -> match%bitstring b with {| n: 9 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 10 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 10 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 11 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 11 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 12 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 12 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 13 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 13 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 14 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 14 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 15 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 15 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 16 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 16 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 17 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 17 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 18 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 18 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 19 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 19 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 20 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 20 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 21 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 21 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 22 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 22 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 23 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 23 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 24 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 24 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 25 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 25 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 26 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 26 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 27 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 27 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 28 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 28 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 29 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 29 : signed |} -> n);
+ (fun n -> [%bitstring {| n : 30 : signed |}]),
+ (fun b -> match%bitstring b with {| n : 30 : signed |} -> n);
+ ]
+ in
+ assert_equal (fst res) true;
+ begin try
+ if Sys.word_size = 32 then
+ begin
+ ignore ([%bitstring {| max_int : 31 : signed |}]);
+ ignore ([%bitstring {| min_int : 31 : signed |}]);
+ end
+ else
+ begin
+ ignore ([%bitstring {| pred (1 lsl 31) : 31 : signed |}]);
+ ignore ([%bitstring {| (-1 lsl 30) : 31 : signed |}]);
+ end;
+ with
+ _ -> assert_failure "Second test failed"
+ end;
+ if Sys.word_size = 64 then
+ try
+ ignore ([%bitstring {| 1 lsl 31 : 31 : signed |}]);
+ ignore ([%bitstring {| pred (-1 lsl 30) : 31 : signed |}]);
+ assert_failure "Third test failed"
+ with _ ->
+ ()
+
+(*
+ * Test functions which construct and extract fixed-length ints of various
+ * sizes. Manquent les tests random pour bits = 31
+ *)
+
+let fixed_extraction_test _ =
+ for i = 0 to 129 do
+ let zeroes = Bitstring.zeroes_bitstring i in
+ let%bitstring bits = {|
+ zeroes : i : bitstring;
+ true : 1;
+ 2 : 2 : littleendian;
+ 2 : 2 : bigendian;
+ 2 : 2 : nativeendian;
+ 3 : 3 : littleendian;
+ 3 : 3 : bigendian;
+ 3 : 3 : nativeendian;
+ 0x5a : 8 : littleendian;
+ 0x5a : 8 : bigendian;
+ 0x5a : 8 : nativeendian;
+ 0xa5a5 : 16 : littleendian;
+ 0xa5a5 : 16 : bigendian;
+ 0xa5a5 : 16 : nativeendian;
+ 0xeeddcc : 24 : littleendian;
+ 0xeeddcc : 24 : bigendian;
+ 0xeeddcc : 24 : nativeendian;
+ 0x48888888 : 31 : littleendian;
+ 0x48888888 : 31 : bigendian;
+ 0x48888888 : 31 : nativeendian;
+ 0xaabbccdd_l : 32 : littleendian;
+ 0xaabbccdd_l : 32 : bigendian;
+ 0xaabbccdd_l : 32 : nativeendian;
+ 0xaabbccddeeff_L : 48 : littleendian;
+ 0xaabbccddeeff_L : 48 : bigendian;
+ 0xaabbccddeeff_L : 48 : nativeendian;
+ 0x0011aabbccddeeff_L : 64 : littleendian;
+ 0x0011aabbccddeeff_L : 64 : bigendian;
+ 0x0011aabbccddeeff_L : 64 : nativeendian
+ |}
+ in
+ match%bitstring bits with
+ | {| _ : i : bitstring;
+ a : 1;
+ b0 : 2 : littleendian;
+ b1 : 2 : bigendian;
+ b2 : 2 : nativeendian;
+ c0 : 3 : littleendian;
+ c1 : 3 : bigendian;
+ c2 : 3 : nativeendian;
+ d0 : 8 : littleendian;
+ d1 : 8 : bigendian;
+ d2 : 8 : nativeendian;
+ e0 : 16 : littleendian;
+ e1 : 16 : bigendian;
+ e2 : 16 : nativeendian;
+ f0 : 24 : littleendian;
+ f1 : 24 : bigendian;
+ f2 : 24 : nativeendian;
+ g0 : 31 : littleendian;
+ g1 : 31 : bigendian;
+ g2 : 31 : nativeendian;
+ h0 : 32 : littleendian;
+ h1 : 32 : bigendian;
+ h2 : 32 : nativeendian;
+ j0 : 48 : littleendian;
+ j1 : 48 : bigendian;
+ j2 : 48 : nativeendian;
+ k0 : 64 : littleendian;
+ k1 : 64 : bigendian;
+ k2 : 64 : nativeendian
+ |} ->
+ if a <> true
+ || b0 <> 2
+ || b1 <> 2
+ || b2 <> 2
+ || c0 <> 3
+ || c1 <> 3
+ || c2 <> 3
+ || d0 <> 0x5a
+ || d1 <> 0x5a
+ || d2 <> 0x5a
+ || e0 <> 0xa5a5
+ || e1 <> 0xa5a5
+ || e2 <> 0xa5a5
+ || f0 <> 0xeeddcc
+ || f1 <> 0xeeddcc
+ || f2 <> 0xeeddcc
+ || g0 <> 0x48888888
+ || g1 <> 0x48888888
+ || g2 <> 0x48888888
+ || h0 <> 0xaabbccdd_l
+ || h1 <> 0xaabbccdd_l
+ || h2 <> 0xaabbccdd_l
+ || j0 <> 0xaabbccddeeff_L
+ || j1 <> 0xaabbccddeeff_L
+ || j2 <> 0xaabbccddeeff_L
+ || k0 <> 0x0011aabbccddeeff_L
+ || k1 <> 0x0011aabbccddeeff_L
+ || k2 <> 0x0011aabbccddeeff_L
+ then (
+ eprintf "15_extract_int: match failed %b %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %ld %ld %ld %Ld %Ld %Ld %Ld %Ld %Ld\n"
+ a b0 b1 b2 c0 c1 c2 d0 d1 d2 e0 e1 e2 f0 f1 f2 g0 g1 g2 h0 h1 h2 j0 j1 j2 k0 k1 k2;
+ exit 1
+ )
+ | {| _ |} ->
+ failwith "15_extract_int"
+ done
+
+(*
+ * Test fix for a regression when extracting 32 and 64 bit aligned integers
+ * (discovered / fixed / tested by Hans Ole Rafaelsen).
+ *)
+
+let bitstring_of_int32 i =
+ [%bitstring {| i : 32 |}]
+
+let bitstring_of_int64 i =
+ [%bitstring {| i : 64 |}]
+
+let int32_of_bitstring bits =
+ match%bitstring bits with
+ | {| i : 32 |} -> i
+
+let int64_of_bitstring bits =
+ match%bitstring bits with
+ | {| i : 64 |} -> i
+
+let extract_regression_test _ =
+ let b1 = bitstring_of_int32 1_l in
+ let b2 = bitstring_of_int32 2_l in
+ let b3 = bitstring_of_int32 3_l in
+ let i1 = int32_of_bitstring b1 in
+ let i2 = int32_of_bitstring b2 in
+ let i3 = int32_of_bitstring b3 in
+ assert (i1 = 1_l);
+ assert (i2 = 2_l);
+ assert (i3 = 3_l);
+
+ let b1 = bitstring_of_int64 1_L in
+ let b2 = bitstring_of_int64 2_L in
+ let b3 = bitstring_of_int64 3_L in
+ let i1 = int64_of_bitstring b1 in
+ let i2 = int64_of_bitstring b2 in
+ let i3 = int64_of_bitstring b3 in
+ assert (i1 = 1_L);
+ assert (i2 = 2_L);
+ assert (i3 = 3_L)
+
+(*
+ * Construct and match against random variable sized strings.
+ *)
+
+let nr_passes = 10000
+let max_size = 8 (* max field size in bits *)
+
+(* let () = Bitstring.debug := true *)
+
+(* Return a full 64 bits of randomness. *)
+let rand64 () =
+ let r0 = Int64.shift_left (Int64.of_int (Random.bits ())) 34 in (* 30 bits *)
+ let r1 = Int64.shift_left (Int64.of_int (Random.bits ())) 4 in (* 30 bits *)
+ let r2 = Int64.of_int (Random.int 16) in (* 4 bits *)
+ Int64.logor (Int64.logor r0 r1) r2
+
+(* Return unsigned mask of length bits, bits <= 64. *)
+let mask64 bits =
+ if bits < 63 then Int64.pred (Int64.shift_left 1L bits)
+ else if bits = 63 then Int64.max_int
+ else if bits = 64 then -1L
+ else invalid_arg "mask64"
+
+(* Return a random number between 0 and 2^bits-1 where bits <= 64. *)
+let rand bits =
+ let r = rand64 () in
+ let m = mask64 bits in
+ Int64.logand r m
+
+(* Dump the state in case there is an error. *)
+let dump n0 n0sz n1 n1sz n2 n2sz n3 n3sz bits r0 r1 r2 r3 =
+ eprintf "dumping state:\n";
+ eprintf " 0: %3d - %016Lx - %016Lx\n" n0sz n0 r0;
+ eprintf " 1: %3d - %016Lx - %016Lx\n" n1sz n1 r1;
+ eprintf " 2: %3d - %016Lx - %016Lx\n" n2sz n2 r2;
+ eprintf " 3: %3d - %016Lx - %016Lx\n" n3sz n3 r3;
+ eprintf "bits (length = %d):\n" (Bitstring.bitstring_length bits);
+ Bitstring.hexdump_bitstring stderr bits;
+ eprintf "%!"
+
+let construct_and_match_random_test _ =
+ Random.self_init ();
+
+ for pass = 0 to nr_passes-1 do
+ let n0sz = 1 + Random.int (max_size-1) in
+ let n0 = rand n0sz in
+ let n1sz = 1 + Random.int (max_size-1) in
+ let n1 = rand n1sz in
+ let n2sz = 1 + Random.int (max_size-1) in
+ let n2 = rand n2sz in
+ let n3sz = 1 + Random.int (max_size-1) in
+ let n3 = rand n3sz in
+
+ (* Construct the bitstring. *)
+ let bits =
+ try
+ [%bitstring {|
+ n0 : n0sz;
+ n1 : n1sz;
+ n2 : n2sz;
+ n3 : n3sz
+ |}]
+ with
+ Bitstring.Construct_failure (msg, _, _, _) ->
+ eprintf "FAILED: Construct_failure %s\n%!" msg;
+ dump n0 n0sz n1 n1sz n2 n2sz n3 n3sz
+ (Bitstring.empty_bitstring) 0L 0L 0L 0L;
+ exit 2
+ in
+
+ let r0, r1, r2, r3 =
+ match%bitstring bits with
+ | {| r0 : n0sz; r1 : n1sz; r2 : n2sz; r3 : n3sz; rest : -1 : bitstring |} ->
+ let rest_len = Bitstring.bitstring_length rest in
+ if rest_len <> 0 then (
+ eprintf "FAILED: rest is not zero length (length = %d)\n%!"
+ rest_len;
+ dump n0 n0sz n1 n1sz n2 n2sz n3 n3sz bits 0L 0L 0L 0L;
+ exit 2
+ );
+ r0, r1, r2, r3
+ | {| _ |} ->
+ eprintf "FAILED: match operator did not match\n%!";
+ dump n0 n0sz n1 n1sz n2 n2sz n3 n3sz bits 0L 0L 0L 0L;
+ exit 2 in
+
+ (*dump n0 n0sz n1 n1sz n2 n2sz n3 n3sz bits r0 r1 r2 r3;*)
+
+ if n0 <> r0 || n1 <> r1 || n2 <> r2 || n3 <> r3 then (
+ eprintf "FAILED: numbers returned from match are different\n%!";
+ dump n0 n0sz n1 n1sz n2 n2sz n3 n3sz bits r0 r1 r2 r3;
+ exit 2
+ )
+ done
+
+(*
+ * Test the Bitstring.Buffer module and string_of_bitstring in nasty non-aligned
+ * corner cases.
+ *)
+
+let nasty_non_aligned_corner_case_test _ =
+ Random.self_init ();
+
+ let str1 = Bytes.of_string "012345678" in
+
+ for offset = 0 to 65 do
+ for len = 1 to 65 do
+ let expected =
+ let strlen = (len+7) lsr 3 in
+ let expected = Bytes.create strlen in
+ for i = 0 to strlen-1 do
+ Bytes.set expected i (Char.chr (Random.int 256))
+ done;
+ let last = Char.code (Bytes.get expected (strlen-1)) in
+ let last = last land (0xff lsl (8 - (len land 7))) in
+ Bytes.set expected (strlen-1) (Char.chr last);
+ expected in
+
+ (* Create a random bitstring:
+ * +-------------+-------------------------------------------+
+ * | (random) | bits that we check (expected) |
+ * +-------------+-------------------------------------------+
+ * 0 offset offset+len
+ * <---------------- len bits --------------->
+ *)
+ let bits =
+ let bits = Bitstring.Buffer.create () in
+ Bitstring.Buffer.add_bits bits str1 offset;
+ Bitstring.Buffer.add_bits bits expected len;
+ Bitstring.Buffer.contents bits in
+
+ (* Create a sub bitstring corresponding to what we want to check. *)
+ let subbits =
+ let bits, bitoffset, bitlen = bits in
+ (bits, bitoffset+offset, bitlen-offset) in
+
+ assert_equal (Bitstring.bitstring_length subbits) len;
+
+ (* Now try to read out the substring using string_of_bitstring. *)
+ let actual = Bitstring.string_of_bitstring subbits in
+ if Bytes.of_string actual <> expected then (
+ eprintf "MISMATCH between actual and expected, offset=%d, len=%d\n"
+ offset len;
+ eprintf "EXPECTED string:\n";
+ for i = 0 to Bytes.length expected-1 do
+ eprintf " %02x" (Char.code (Bytes.get expected i))
+ done;
+ eprintf "\nACTUAL string:\n";
+ for i = 0 to String.length actual-1 do
+ eprintf " %02x" (Char.code actual.[i])
+ done;
+ eprintf "\nBITS:\n";
+ Bitstring.hexdump_bitstring stderr bits;
+ eprintf "SUBBITS:\n";
+ Bitstring.hexdump_bitstring stderr subbits;
+ exit 1
+ );
+ done
+ done
+
+(*
+ * Test concat and the bit get functions.
+ *)
+
+let concat_bit_get_test _ =
+ for i = 0 to 33 do
+ for j = 0 to 33 do
+ for k = 0 to 33 do
+ let bits =
+ Bitstring.concat [
+ Bitstring.ones_bitstring i;
+ Bitstring.zeroes_bitstring j;
+ Bitstring.ones_bitstring k
+ ] in
+ assert (Bitstring.bitstring_length bits = i+j+k);
+ for n = 0 to i-1 do
+ assert (Bitstring.is_set bits n)
+ done;
+ for n = i to i+j-1 do
+ assert (Bitstring.is_clear bits n)
+ done;
+ for n = i+j to i+j+k-1 do
+ assert (Bitstring.is_set bits n)
+ done
+ done
+ done
+ done
+
+(*
+ * Compare bitstrings.
+ *)
+
+let sgn = function
+ | 0 -> 0
+ | i when i > 0 -> 1
+ | _ -> -1
+
+let compare_test _ =
+ for i = 0 to 33 do
+ for j = 0 to 33 do
+ let bits1 = Bitstring.ones_bitstring i
+ and bits2 = Bitstring.ones_bitstring j in
+ let r = Bitstring.compare bits1 bits2 in
+ if sgn r <> sgn (compare i j) then (
+ eprintf "ones compare failed %d %d %d\n" i j r;
+ exit 1
+ )
+ done
+ done;
+ for i = 0 to 33 do
+ for j = 0 to 33 do
+ let bits1 = Bitstring.zeroes_bitstring i
+ and bits2 = Bitstring.zeroes_bitstring j in
+ let r = Bitstring.compare bits1 bits2 in
+ if sgn r <> sgn (compare i j) then (
+ eprintf "zeroes compare failed %d %d %d\n" i j r;
+ exit 1
+ )
+ done
+ done;
+ for i = 0 to 33 do
+ for j = 0 to 33 do
+ let bits1 = Bitstring.make_bitstring i '\x55'
+ and bits2 = Bitstring.make_bitstring j '\x55' in
+ let r = Bitstring.compare bits1 bits2 in
+ if sgn r <> sgn (compare i j) then (
+ eprintf "x55 compare failed %d %d %d\n" i j r;
+ exit 1
+ )
+ done
+ done;
+ for i = 0 to 33 do
+ for j = 0 to 33 do
+ let bits1 = Bitstring.make_bitstring i '\x55' in
+ let bits2 = Bitstring.make_bitstring i '\x55' in
+ let bits2 = Bitstring.concat [Bitstring.zeroes_bitstring j; bits2] in
+ assert (Bitstring.bitstring_length bits2 = j+i);
+ let bits2 = Bitstring.dropbits j bits2 in
+ assert (Bitstring.bitstring_length bits2 = i);
+ let r = Bitstring.compare bits1 bits2 in
+ if r <> 0 then (
+ eprintf "x55 non-aligned compare failed %d %d %d\n" i j r;
+ exit 1
+ )
+ done
+ done
+
+(*
+ * Test subbitstring call.
+ *)
+
+let subbitstring_test _ =
+ let bits = Bitstring.make_bitstring 65 '\x5a' in
+ for off = 0 to 65 do
+ for len = 65-off to 0 do
+ let sub = Bitstring.subbitstring bits off len in
+ for i = 0 to len-1 do
+ if Bitstring.get bits (off+i) <> Bitstring.get sub i then (
+ eprintf "33_substring: failed %d %d %d\n" off len i;
+ exit 1
+ )
+ done
+ done
+ done
+
+(*
+ * Test takebits call.
+ *)
+
+let takebits_test _ =
+ let bits = Bitstring.make_bitstring 65 '\x5a' in
+ for len = 0 to 65 do
+ let sub = Bitstring.takebits len bits in
+ assert (Bitstring.bitstring_length sub = len)
+ done
+
+(*
+ * Test the various functions to load bitstrings from files.
+ *)
+
+let file_load_test _ =
+ let bits1 =
+ let b1 = Bitstring.make_bitstring 800 '\x5a' in
+ let b2 = Bitstring.make_bitstring 400 '\x88' in (
+ [%bitstring {|
+ b1 : 800 : bitstring;
+ b2 : 400 : bitstring
+ |}]
+ ) in
+ let bits2 = (
+ let b = Bitstring.make_bitstring 800 '\xaa' in
+ [%bitstring {|
+ b : 800 : bitstring
+ |}]
+ ) in
+ let bits = Bitstring.concat [bits1; bits2] in
+ let filename, chan =
+ Filename.open_temp_file ~mode:[Open_binary] "bitstring_test" ".tmp" in
+ Bitstring.bitstring_to_chan bits chan;
+ close_out chan;
+
+ let bits' = Bitstring.bitstring_of_file filename in
+ assert (Bitstring.equals bits bits');
+
+ let chan = open_in filename in
+ let bits' = Bitstring.bitstring_of_chan chan in
+ close_in chan;
+ assert (Bitstring.equals bits bits');
+
+ let chan = open_in filename in
+ let bits' = Bitstring.bitstring_of_chan_max chan 150 in
+ assert (Bitstring.equals bits1 bits');
+ let bits' = Bitstring.bitstring_of_chan_max chan 100 in
+ assert (Bitstring.equals bits2 bits');
+ close_in chan;
+
+ let fd = Unix.openfile filename [Unix.O_RDONLY] 0 in
+ let bits' = Bitstring.bitstring_of_file_descr fd in
+ Unix.close fd;
+ assert (Bitstring.equals bits bits');
+
+ let fd = Unix.openfile filename [Unix.O_RDONLY] 0 in
+ let bits' = Bitstring.bitstring_of_file_descr_max fd 150 in
+ assert (Bitstring.equals bits1 bits');
+ let bits' = Bitstring.bitstring_of_file_descr_max fd 100 in
+ assert (Bitstring.equals bits2 bits');
+ Unix.close fd;
+
+ Unix.unlink filename
+
+(*
+ * Test if bitstrings are all zeroes or all ones.
+ *)
+
+let zeroes_ones_test _ =
+ for i = 0 to 33 do
+ let bits = Bitstring.zeroes_bitstring i in
+ if not (Bitstring.is_zeroes_bitstring bits) then (
+ eprintf "is_zeros_bitstring failed %d\n" i;
+ exit 1
+ );
+ if i > 0 && Bitstring.is_ones_bitstring bits then (
+ eprintf "false match is_ones_bitstring %d\n" i;
+ exit 1
+ )
+ done;
+ for i = 0 to 33 do
+ let bits = Bitstring.ones_bitstring i in
+ if not (Bitstring.is_ones_bitstring bits) then (
+ eprintf "is_ones_bitstring failed %d\n" i;
+ exit 1
+ );
+ if i > 0 && Bitstring.is_zeroes_bitstring bits then (
+ eprintf "false match is_zeroes_bitstring %d\n" i;
+ exit 1
+ )
+ done
+
+(*
+ * Endianness expressions
+ *)
+
+let endianness_test _ =
+ let rec loop = function
+ | (e, expected) :: rest ->
+ let%bitstring bits = {|
+ expected : 32 : endian (e);
+ expected : 32 : endian (e);
+ expected : 32 : endian (e)
+ |} in
+ (match%bitstring bits with
+ | {| actual : 32 : endian (e);
+ actual : 32 : endian (e);
+ actual : 32 : endian (e) |} ->
+ if actual <> expected then
+ failwith (sprintf "actual %ld <> expected %ld" actual expected)
+ | {| _ |} as bits ->
+ Bitstring.hexdump_bitstring stderr bits; exit 1
+ );
+ loop rest
+ | [] -> ()
+ in
+ loop [
+ Bitstring.BigEndian, 0xa1b2c3d4_l;
+ Bitstring.BigEndian, 0xa1d4c3b2_l;
+ Bitstring.LittleEndian, 0xa1b2c3d4_l;
+ Bitstring.LittleEndian, 0xa1d4c3b2_l;
+ Bitstring.NativeEndian, 0xa1b2c3d4_l;
+ Bitstring.NativeEndian, 0xa1d4c3b2_l;
+ ]
+
+(*
+ * Simple offset test
+ *)
+
+let simple_offset_test _ =
+ let make_bits i n j m k = (
+ let pad1 = Bitstring.ones_bitstring (n-8) in
+ let pad2 = Bitstring.ones_bitstring (m-n-8) in
+ [%bitstring {|
+ i : 8;
+ pad1 : n-8 : bitstring;
+ j : 8; (* this should be at offset(n) *)
+ pad2 : m-n-8 : bitstring;
+ k : 8 (* this should be at offset(m) *)
+ |}]
+ )
+ in
+ let test_bits bits i n j m k =
+ match%bitstring bits with
+ | {| i' : 8;
+ j' : 8 : offset(n);
+ k' : 8 : offset(m) |} when i = i' && j = j' && k = k' -> () (* ok *)
+ | {| _ |} ->
+ failwith (sprintf "60_simple_offset: test_bits: failed %d %d %d %d %d"
+ i n j m k)
+ in
+ for n = 8 to 128 do
+ for m = n+8 to 256 do
+ List.iter (fun (i,j,k) -> test_bits (make_bits i n j m k) i n j m k)
+ [0x55, 0xaa, 0x33; 0x33, 0xaa, 0x55; 0x12, 0x34, 0x56]
+ done;
+ done
+
+(*
+ * Offset string. The rotation functions used for strings are
+ * very complicated so this is worth testing separately.
+ *)
+
+let offset_string_test _ =
+ let make_bits si n sj m sk = (
+ let pad1 = Bitstring.ones_bitstring (n-64) in
+ let pad2 = Bitstring.ones_bitstring (m-n-8) in
+ [%bitstring {|
+ si : 64 : string;
+ pad1 : n-64 : bitstring;
+ sj : 8 : string; (* this should be at offset(n) *)
+ pad2 : m-n-8 : bitstring;
+ sk : 64 : string (* this should be at offset(m) *)
+ |}]
+ )
+ in
+ let test_bits bits si n sj m sk =
+ match%bitstring bits with
+ | {| si' : 64 : string;
+ sj' : 8 : string, offset(n);
+ sk' : 64 : string, offset(m) |}
+ when si = si' && sj = sj' && sk = sk' -> () (* ok *)
+ | {| _ |} ->
+ failwith (sprintf "61_offset_string: test_bits: failed %S %d %S %d %S"
+ si n sj m sk)
+ in
+ for n = 64 to 128 do
+ for m = n+8 to 256 do
+ List.iter (fun (si,sj,sk) ->
+ test_bits (make_bits si n sj m sk) si n sj m sk)
+ ["ABCDEFGH", "x", "HGFEDCBA";
+ "01234567", "0", "76543210";
+ "abcdefgh", "\x55", "poiuytre"]
+ done;
+ done
+
+(*
+ * Test computed offsets when original_off <> 0.
+ *)
+
+let computed_offset_test _ =
+ let make_bits p i n j m k =
+ let pad0 = Bitstring.ones_bitstring p in
+ let pad1 = Bitstring.ones_bitstring (n-8) in
+ let pad2 = Bitstring.ones_bitstring (m-n-8) in
+ [%bitstring {|
+ pad0 : p : bitstring; (* will be skipped below *)
+ i : 8;
+ pad1 : n-8 : bitstring;
+ j : 8; (* this should be at offset(n) *)
+ pad2 : m-n-8 : bitstring;
+ k : 8 (* this should be at offset(m) *)
+ |}]
+ in
+ let test_bits bits p i n j m k =
+ (*
+ * Skip the 'p' padding bits so the match starts at a non-zero offset.
+ *)
+ let bits = Bitstring.dropbits p bits
+ in
+ match%bitstring bits with
+ | {| i' : 8;
+ j' : 8 : offset(n);
+ k' : 8 : offset(m)
+ |} when i = i' && j = j' && k = k' -> () (* ok *)
+ | {| i' : 8;
+ j' : 8 : offset(n);
+ k' : 8 : offset(m)
+ |} ->
+ Printf.printf "\n%d %d %d\n" p n m;
+ Bitstring.hexdump_bitstring stdout bits;
+ Printf.printf "%x %x\n" i i';
+ assert_equal i i';
+ Printf.printf "%x %x\n" j j';
+ assert_equal j j';
+ Printf.printf "%x %x\n" k k';
+ assert_equal k k'
+ | {| _ |} ->
+ assert_failure "Bitstring parsing failure"
+ in
+ for p = 1 to 4 do
+ for n = 8 to 128 do
+ for m = n+8 to 256 do
+ List.iter (fun (i,j,k) -> test_bits (make_bits p i n j m k) p i n j m k)
+ [0x55, 0xaa, 0x33; 0x33, 0xaa, 0x55; 0x12, 0x34, 0x56]
+ done;
+ done;
+ done
+
+(*
+ * Test save_offset_to.
+ *)
+
+let save_offset_to_test _ =
+ let make_bits p i n j m k = (
+ let pad0 = Bitstring.ones_bitstring p in
+ let pad1 = Bitstring.ones_bitstring (n-8) in
+ let pad2 = Bitstring.ones_bitstring (m-n-8) in
+ [%bitstring {|
+ pad0 : p : bitstring; (* will be skipped below *)
+ i : 8;
+ pad1 : n-8 : bitstring;
+ j : 8; (* this should be at offset(n) *)
+ pad2 : m-n-8 : bitstring;
+ k : 8 (* this should be at offset(m) *)
+ |}]
+ )
+ in
+ let test_bits bits p i n j m k =
+ (* Skip the 'p' padding bits so the match starts at a non-zero offset. *)
+ let bits = Bitstring.dropbits p bits in
+
+ match%bitstring bits with
+ | {| i' : 8;
+ _ : n-8 : bitstring;
+ j' : 8 : save_offset_to (j_offset);
+ _ : m-n-8 : bitstring;
+ k' : 8 : save_offset_to (k_offset) |}
+ when i = i' && j = j' && k = k' && j_offset = n && k_offset = m ->
+ () (* ok *)
+ | {| _ |} ->
+ failwith (sprintf
+ "65_save_offset_to: test_bits: failed %d %d %d %d %d %d"
+ p i n j m k)
+ in
+ for p = 0 to 4 do
+ for n = 8 to 64 do
+ for m = n+8 to 128 do
+ List.iter (fun (i,j,k) -> test_bits (make_bits p i n j m k) p i n j m k)
+ [0x55, 0xaa, 0x33; 0x33, 0xaa, 0x55; 0x12, 0x34, 0x56]
+ done;
+ done;
+ done
+
+(*
+ * Test check() and bind().
+ *)
+
+let check_bind_test _ =
+ let%bitstring bits = {| 101 : 16; 202 : 16 |}
+ in
+ match%bitstring bits with
+ | {| i : 16 : check (i = 101), bind (i*4);
+ j : 16 : check (j = 202) |} ->
+ if i <> 404 || j <> 202 then
+ failwith (sprintf "70_check_and_bind: failed: %d %d" i j)
+ | {| _ |} ->
+ failwith "70_check_and_bind: match failed"
+
+(*
+ * Test hexdump.
+ *)
+
+let () =
+ let diff = "diff"
+ in
+ let files = Sys.readdir "../../../tests/data" in
+ let files = Array.to_list files in
+ let files = List.filter (
+ fun filename ->
+ String.length filename > 3 &&
+ filename.[0] = 'r' && filename.[1] = 'n' && filename.[2] = 'd'
+ ) files in
+ let files = List.map (
+ fun filename ->
+ let n = String.sub filename 3 (String.length filename - 3) in
+ let n = int_of_string n in
+ let bits = Bitstring.bitstring_of_file ("../../../tests/data/" ^ filename) in
+ (*
+ * 'bitstring_of_file' loads whole bytes. Truncate it to
+ * the real bit-length.
+ *)
+ let bits = Bitstring.takebits n bits in
+ filename, n, bits
+ ) files in
+ (*
+ * Hexdump the bits, then compare using external 'diff' program.
+ *)
+ List.iter (
+ fun (filename, n, bits) ->
+ let output_filename = sprintf "../../../tests/data/hex%d.actual" n in
+ let chan = open_out output_filename in
+ Bitstring.hexdump_bitstring chan bits;
+ close_out chan
+ ) files;
+
+ List.iter (
+ fun (filename, n, bits) ->
+ let actual_filename = sprintf "../../../tests/data/hex%d.actual" n in
+ let expected_filename = sprintf "../../../tests/data/hex%d.expected" n in
+ let cmd =
+ sprintf "%s -u %s %s"
+ (Filename.quote diff)
+ (Filename.quote expected_filename)
+ (Filename.quote actual_filename) in
+ if Sys.command cmd <> 0 then (
+ exit 1
+ )
+ ) files
+
+(*
+ * Regression test for bug in 'as-binding' found by Matej Kosik.
+ * $Id$
+ *)
+
+let as_binding_bug_test _ =
+ let bits = Bitstring.ones_bitstring 1 in
+ match%bitstring bits with
+ | {| _ : 1 |} as foo ->
+ let len = Bitstring.bitstring_length foo in
+ if len <> 1 then (
+ Bitstring.hexdump_bitstring stderr foo;
+ eprintf "test error: length = %d, expecting 1\n" len;
+ exit 1
+ )
+ | {| _ |} ->
+ assert false
+
+(*
+ * Regression test for bug in concatenation found by Phil Tomson.
+ *)
+
+let concat_regression_test _ =
+ let errors = ref 0 in
+ let bs_256 = Bitstring.ones_bitstring 256 in
+ assert (Bitstring.bitstring_length bs_256 = 256);
+
+ let%bitstring bs2 = {|
+ false : 1;
+ (Bitstring.subbitstring bs_256 0 66) : 66 : bitstring
+ |} in
+ let len = Bitstring.bitstring_length bs2 in
+ if len <> 67 then (
+ eprintf "invalid length of bs2: len = %d, expected 67\n" len;
+ Bitstring.hexdump_bitstring stderr bs2;
+ incr errors
+ );
+
+ let%bitstring bs3 = {|
+ false : 1;
+ (Bitstring.subbitstring bs_256 0 66) : 66 : bitstring;
+ (Bitstring.subbitstring bs_256 66 67) : 67 : bitstring
+ |} in
+ let len = Bitstring.bitstring_length bs3 in
+ if len <> 134 then (
+ eprintf "invalid length of bs3: len = %d, expected 134\n" len;
+ Bitstring.hexdump_bitstring stderr bs3;
+ incr errors
+ );
+
+ let%bitstring bs4 = {|
+ (Bitstring.subbitstring bs_256 66 67) : 67 : bitstring
+ |} in
+ let len = Bitstring.bitstring_length bs4 in
+ if len <> 67 then (
+ eprintf "invalid length of bs4: len = %d, expected 67\n" len;
+ Bitstring.hexdump_bitstring stderr bs4;
+ incr errors
+ );
+
+ let bs5 = Bitstring.concat [Bitstring.subbitstring bs_256 0 66; Bitstring.subbitstring bs_256 66 67] in
+ let len = Bitstring.bitstring_length bs5 in
+ if len <> 133 then (
+ eprintf "invalid length of bs5: len = %d, expected 133\n" len;
+ Bitstring.hexdump_bitstring stderr bs5;
+ incr errors
+ );
+
+ let bs6 = Bitstring.concat [ Bitstring.subbitstring bs_256 0 64; Bitstring.subbitstring bs_256 64 64] in
+ let len = Bitstring.bitstring_length bs6 in
+ if len <> 128 then (
+ eprintf "invalid length of bs6: len = %d, expected 128\n" len;
+ Bitstring.hexdump_bitstring stderr bs6;
+ incr errors
+ );
+
+ let bs7 = Bitstring.concat [ Bitstring.subbitstring bs_256 0 65; Bitstring.subbitstring bs_256 65 64] in
+ let len = Bitstring.bitstring_length bs7 in
+ if len <> 129 then (
+ eprintf "invalid length of bs7: len = %d, expected 129\n" len;
+ Bitstring.hexdump_bitstring stderr bs7;
+ incr errors
+ );
+
+ if !errors <> 0 then exit 1
+
+let suite = "BitstringLegacyTests" >::: [
+ "load_test" >:: load_test;
+ "run_test" >:: run_test;
+ "match_random_bits_test" >:: match_random_bits_test;
+ "match_random_bits_with_int_test" >:: match_random_bits_with_int_test;
+ "check_value_limits_test" >:: check_value_limits_test;
+ "signed_byte_create_test" >:: signed_byte_create_test;
+ "signed_byte_create_and_match_test" >:: signed_byte_create_and_match_test;
+ "signed_int_limits_test" >:: signed_int_limits_test;
+ "fixed_extraction_test" >:: fixed_extraction_test;
+ "extract_regression_test" >:: extract_regression_test;
+ "construct_and_match_random_test" >:: construct_and_match_random_test;
+ "nasty_non_aligned_corner_case_test" >:: nasty_non_aligned_corner_case_test;
+ "concat_bit_get_test" >:: concat_bit_get_test;
+ "compare_test" >:: compare_test;
+ "subbitstring_test" >:: subbitstring_test;
+ "takebits_test" >:: takebits_test;
+ "file_load_test" >:: file_load_test;
+ "zeroes_ones_test" >:: zeroes_ones_test;
+ "endianness_test" >:: endianness_test;
+ "simple_offset_test" >:: simple_offset_test;
+ "offset_string_test" >:: offset_string_test;
+ "computed_offset_test" >:: computed_offset_test;
+ "save_offset_to_test" >:: save_offset_to_test;
+ "check_bind_test" >:: check_bind_test;
+ "as_binding_bug_test" >:: as_binding_bug_test;
+ "concat_regression_test" >:: concat_regression_test;
+ ]
diff --git a/tests/BitstringLegacyTest.mli b/tests/BitstringLegacyTest.mli
new file mode 100644
index 0000000..c09b06e
--- /dev/null
+++ b/tests/BitstringLegacyTest.mli
@@ -0,0 +1,3 @@
+open OUnit2
+
+val suite : OUnit2.test
diff --git a/tests/BitstringParserTest.ml b/tests/BitstringParserTest.ml
new file mode 100644
index 0000000..4444c03
--- /dev/null
+++ b/tests/BitstringParserTest.ml
@@ -0,0 +1,240 @@
+(*
+ * Copyright (c) 2016 Xavier R. Guérin <copyright@applepine.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *)
+
+open OUnit2
+open Bitstring
+
+(*
+ * EXT3 superblock parsing test
+ *)
+
+let ext3_test context =
+ let bits = Bitstring.bitstring_of_file "../../../tests/data/ext3_sb" in
+ match%bitstring bits with
+ (*
+ * Check if the file is an EXT3 superblock
+ *)
+ | {| 50200_l : 32 : littleendian (* Inodes count *)
+ ; _ : 32 : littleendian (* Blocks count *)
+ ; _ : 32 : littleendian (* Reserved blocks count *)
+ ; 155333_l : 32 : littleendian (* Free blocks count *)
+ ; 50150_l : 32 : littleendian (* Free inodes count *)
+ ; _ : 32 : littleendian (* First Data Block *)
+ ; _ : 32 : littleendian (* Block size *)
+ ; _ : 32 : littleendian (* Fragment size *)
+ ; _ : 32 : littleendian (* # Blocks per group *)
+ ; _ : 32 : littleendian (* # Fragments per group *)
+ ; _ : 32 : littleendian (* # Inodes per group *)
+ ; _ : 32 : littleendian (* Mount time *)
+ ; _ : 32 : littleendian (* Write time *)
+ ; _ : 16 : littleendian (* Mount count *)
+ ; _ : 16 : littleendian (* Maximal mount count *)
+ ; 0xef53 : 16 : littleendian (* Magic signature *)
+ |} -> ()
+ (*
+ * Otherwise, throw an error
+ *)
+ | {| _ |} ->
+ failwith "Invalid EXT3 superblock"
+
+(*
+ * GIF parser test
+ *)
+
+let gif_test context =
+ let bits = Bitstring.bitstring_of_file "../../../tests/data/sad_face.gif" in
+ match%bitstring bits with
+ (*
+ * Check if the file is a GIF image
+ *)
+ | {| ("GIF87a" | "GIF89a") : 6*8 : string ; (* GIF magic. *)
+ 2145 : 16 : littleendian ;
+ 2145 : 16 : littleendian ;
+ true : 1 ; (* Has colormap? *)
+ 7 : 3 ; (* Color res = colorbits+1 *)
+ false : 1 ;
+ 7 : 3 ; (* Bits/pixel = bps+1 *)
+ 0 : 8 ; (* Background colo *)
+ 0 : 8
+ |} -> ()
+ (*
+ * Otherwise, throw an error
+ *)
+ | {| _ |} ->
+ failwith "Invalid GIF image"
+
+(*
+ * PCAP parser test
+ *)
+
+let to_bitstring_endian = function
+ | 0xa1b2c3d4_l | 0xa1b23c4d_l -> Bitstring.BigEndian
+ | 0xd4c3b2a1_l | 0x4d3cb2a1_l -> Bitstring.LittleEndian
+ | _ -> failwith "Unknown PCAP format"
+
+let pcap_ipv4_test context ipv4 =
+ match%bitstring ipv4 with
+ | {| 4 : 4;
+ 5 : 4;
+ 0 : 8; (* dscn/ecn *)
+ 60 : 16 : bigendian;
+ 0x92A6 : 16 : bigendian; (* ident *)
+ 0x02 : 3; (* flags *)
+ 0 : 13 : bigendian; (* fragment offset *)
+ 64 : 8; (* ttl *)
+ 0x06 : 8;
+ 0xFA91 : 16 : bigendian; (* checksum *)
+ 0xC0 : 8;
+ 0xA8 : 8;
+ 0x01 : 8;
+ 0x21 : 8; (* source IP *)
+ 0xCC : 8;
+ 0xB2 : 8;
+ 0x1F : 8;
+ 0x08 : 8; (* destination IP *)
+ _ : -1 : bitstring
+ |} -> ()
+ | {| _ |} -> failwith "Not a valid IPv4 layer"
+
+let pcap_eth_test context eth =
+ match%bitstring eth with
+ | {| 0x00 : 8;
+ 0xA0 : 8;
+ 0xC5 : 8;
+ 0x8F : 8;
+ 0xE3 : 8;
+ 0xC7 : 8; (* destination MAC *)
+ 0x00 : 8;
+ 0x0C : 8;
+ 0x76 : 8;
+ 0x1C : 8;
+ 0x1B : 8;
+ 0x97 : 8; (* source MAC *)
+ 0x0800 : 16 : bigendian; (* EtherType *)
+ ipv4 : -1 : bitstring
+ |} -> pcap_ipv4_test context ipv4
+ | {| _ |} -> failwith "Not a valid Ethernet layer"
+
+let pcap_packet_test context endian packet =
+ match%bitstring packet with
+ | {| _ : 32;
+ _ : 32;
+ incl_len : 32 : endian (endian);
+ orig_len : 32 : endian (endian);
+ eth : (Int32.to_int incl_len) * 8 : bitstring
+ |} -> pcap_eth_test context eth
+ | {| _ |} -> failwith "Not a valid packet descriptor"
+
+let pcap_test context =
+ let bits = Bitstring.bitstring_of_file "../../../tests/data/net.pcap" in
+ match%bitstring bits with
+ (*
+ * Check if the file is a PCAP file
+ *)
+ | {| ((0xa1b2c3d4_l |
+ 0xa1b23c4d_l |
+ 0xd4c3b2a1_l |
+ 0x4d3cb2a1_l) as magic) : 32;
+ 2 : 16 : littleendian; (* major *)
+ 4 : 16 : littleendian; (* minor *)
+ _ : 32; (* time zone *)
+ 0_l : 32; (* unused *)
+ _ : 32; (* snaplen *)
+ _ : 32; (* network *)
+ packet : -1 : bitstring
+ |} -> pcap_packet_test context (to_bitstring_endian magic) packet
+ (*
+ * Otherwise, throw an error
+ *)
+ | {| _ |} -> failwith "Not a valid PCAP file"
+
+(*
+ * Function-style parser test
+ *)
+
+let function_parser = function%bitstring
+ | {| 1 : 3
+ ; 2 : 4
+ ; "hello" : 40 : string
+ |} ->
+ assert_bool "Bitstring is valid" true
+ | {| _ |} ->
+ assert_bool "Invalid bitstring" false
+;;
+
+let function_parser_test context =
+ [%bitstring {| 1 : 3; 2 : 4; "hello" : 40 : string |}]
+ |> function_parser
+
+(*
+ * Function-style parser test, inline
+ *)
+
+let function_parser_inline_test context =
+ [%bitstring {| 1 : 3; 2 : 4; "hello" : 40 : string |}]
+ |> function%bitstring
+ | {| 1 : 3
+ ; 2 : 4
+ ; "hello" : 40 : string
+ |} ->
+ assert_bool "Bitstring is valid" true
+ | {| _ |} ->
+ assert_bool "Invalid bitstring" false
+
+(*
+ * parser with a guard (PR#16)
+ *)
+
+let parser_with_guard_test context =
+ let bits = Bitstring.bitstring_of_string "abc" in
+ match%bitstring bits with
+ | {| "abc" : 24 : string |} when false ->
+ assert_bool "Guard was ignored" false
+ | {| _ |} ->
+ assert_bool "Guard was honored" true
+
+(*
+ * Wrong fastpath extraction function #46
+ *)
+
+let wrong_fp_extraction context =
+ let mb = ((Bytes.of_string "\000\000\145"), 0, 24) in
+ match%bitstring mb with
+ | {| matched_value : 24 : bigendian |} -> assert_equal matched_value 145
+ | {| _ |} -> assert_bool "Invalid bitstring" false
+
+let wrong_fp_extraction_dynamic context =
+ let mb = ((Bytes.of_string "\000\000\000\145"), 0, 32)
+ and on = 8
+ in
+ match%bitstring mb with
+ | {| _ : on ; matched_value : 24 : bigendian |} -> assert_equal matched_value 145
+ | {| _ |} -> assert_bool "Invalid bitstring" false
+
+(*
+ * Test suite definition
+ *)
+
+let suite = "BitstringParserTest" >::: [
+ "ext3" >:: ext3_test;
+ "gif" >:: gif_test;
+ "pcap" >:: pcap_test;
+ "function" >:: function_parser_test;
+ "function_inline" >:: function_parser_inline_test;
+ "parser_with_guard" >:: parser_with_guard_test;
+ "wrong_fp_extraction" >:: wrong_fp_extraction;
+ "wrong_fp_extraction_dynamic" >:: wrong_fp_extraction_dynamic;
+ ]
diff --git a/tests/BitstringParserTest.mli b/tests/BitstringParserTest.mli
new file mode 100644
index 0000000..caa5fd8
--- /dev/null
+++ b/tests/BitstringParserTest.mli
@@ -0,0 +1 @@
+val suite : OUnit2.test
diff --git a/tests/BitstringQualifierTest.ml b/tests/BitstringQualifierTest.ml
new file mode 100644
index 0000000..bb26c77
--- /dev/null
+++ b/tests/BitstringQualifierTest.ml
@@ -0,0 +1,64 @@
+(*
+ * Copyright (c) 2016 Xavier R. Guérin <copyright@applepine.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *)
+
+open OUnit2
+open Bitstring
+
+(*
+ * Test of the map() qualifier
+ *)
+
+let map_test context =
+ let source = [%bitstring {| 1 : 16 ; 2 : 16 |}] in
+ match%bitstring source with
+ | {| value0 : 16 : map (fun v -> v + 1)
+ ; value1 : 16 : map (fun v -> Some v)
+ |} ->
+ assert_equal value0 2;
+ begin match value1 with
+ | Some v -> assert_equal v 2
+ | _ -> assert_bool "Invalid map result" false
+ end
+ | {| _ |} -> assert_bool "Invalid pattern" false
+
+(*
+ * Test of the save_offset_to() qualifier
+ *)
+
+let save_offset_test context =
+ let source = [%bitstring {| 1 : 3 ; 2 : 7; 5 : 4; "abc" : -1 : string |}] in
+ match%bitstring source with
+ | {| _ : 3 : save_offset_to (off0)
+ ; _ : 7 : save_offset_to (off1)
+ ; _ : 4 : save_offset_to (off2)
+ ; "abc" : 24 : save_offset_to (off3), string
+ |} ->
+ assert_equal off0 0;
+ assert_equal off1 3;
+ assert_equal off2 10;
+ assert_equal off3 14
+ | {| _ |} -> assert_bool "Invalid pattern" false
+
+(*
+ * Test suite definition
+ *)
+
+let suite = "BitstringQualifierTest" >::: [
+ "map" >:: map_test;
+ "save_offset_to" >:: save_offset_test
+ ]
+
+let () = run_test_tt_main suite
diff --git a/tests/BitstringQualifierTest.mli b/tests/BitstringQualifierTest.mli
new file mode 100644
index 0000000..caa5fd8
--- /dev/null
+++ b/tests/BitstringQualifierTest.mli
@@ -0,0 +1 @@
+val suite : OUnit2.test
diff --git a/tests/bitstring_tests.ml b/tests/bitstring_tests.ml
new file mode 100644
index 0000000..6a12316
--- /dev/null
+++ b/tests/bitstring_tests.ml
@@ -0,0 +1,9 @@
+open OUnit2
+
+let () =
+ [
+ BitstringLegacyTest.suite;
+ BitstringParserTest.suite;
+ BitstringQualifierTest.suite;
+ ]
+ |> List.iter (fun t -> run_test_tt_main t)
diff --git a/tests/data/ext3_sb b/tests/data/ext3_sb
new file mode 100644
index 0000000..3cbc044
--- /dev/null
+++ b/tests/data/ext3_sb
Binary files differ
diff --git a/tests/80_testdata/hex1.expected b/tests/data/hex1.expected
index aab2998..aab2998 100644
--- a/tests/80_testdata/hex1.expected
+++ b/tests/data/hex1.expected
diff --git a/tests/80_testdata/hex10.expected b/tests/data/hex10.expected
index 35d015b..35d015b 100644
--- a/tests/80_testdata/hex10.expected
+++ b/tests/data/hex10.expected
diff --git a/tests/80_testdata/hex1000.expected b/tests/data/hex1000.expected
index 9cb787e..9cb787e 100644
--- a/tests/80_testdata/hex1000.expected
+++ b/tests/data/hex1000.expected
diff --git a/tests/80_testdata/hex11.expected b/tests/data/hex11.expected
index 1630251..1630251 100644
--- a/tests/80_testdata/hex11.expected
+++ b/tests/data/hex11.expected
diff --git a/tests/80_testdata/hex12.expected b/tests/data/hex12.expected
index 54c9939..54c9939 100644
--- a/tests/80_testdata/hex12.expected
+++ b/tests/data/hex12.expected
diff --git a/tests/80_testdata/hex127.expected b/tests/data/hex127.expected
index 46e15db..46e15db 100644
--- a/tests/80_testdata/hex127.expected
+++ b/tests/data/hex127.expected
diff --git a/tests/80_testdata/hex128.expected b/tests/data/hex128.expected
index 9f021e2..9f021e2 100644
--- a/tests/80_testdata/hex128.expected
+++ b/tests/data/hex128.expected
diff --git a/tests/80_testdata/hex13.expected b/tests/data/hex13.expected
index 8e19d4b..8e19d4b 100644
--- a/tests/80_testdata/hex13.expected
+++ b/tests/data/hex13.expected
diff --git a/tests/80_testdata/hex14.expected b/tests/data/hex14.expected
index 517507b..517507b 100644
--- a/tests/80_testdata/hex14.expected
+++ b/tests/data/hex14.expected
diff --git a/tests/80_testdata/hex15.expected b/tests/data/hex15.expected
index 29d97d5..29d97d5 100644
--- a/tests/80_testdata/hex15.expected
+++ b/tests/data/hex15.expected
diff --git a/tests/80_testdata/hex16.expected b/tests/data/hex16.expected
index b741f31..b741f31 100644
--- a/tests/80_testdata/hex16.expected
+++ b/tests/data/hex16.expected
diff --git a/tests/80_testdata/hex2.expected b/tests/data/hex2.expected
index 901ca3b..901ca3b 100644
--- a/tests/80_testdata/hex2.expected
+++ b/tests/data/hex2.expected
diff --git a/tests/80_testdata/hex200.expected b/tests/data/hex200.expected
index 0d5d245..0d5d245 100644
--- a/tests/80_testdata/hex200.expected
+++ b/tests/data/hex200.expected
diff --git a/tests/80_testdata/hex3.expected b/tests/data/hex3.expected
index 47c5fe8..47c5fe8 100644
--- a/tests/80_testdata/hex3.expected
+++ b/tests/data/hex3.expected
diff --git a/tests/80_testdata/hex31.expected b/tests/data/hex31.expected
index 198877e..198877e 100644
--- a/tests/80_testdata/hex31.expected
+++ b/tests/data/hex31.expected
diff --git a/tests/80_testdata/hex32.expected b/tests/data/hex32.expected
index d55c2e0..d55c2e0 100644
--- a/tests/80_testdata/hex32.expected
+++ b/tests/data/hex32.expected
diff --git a/tests/80_testdata/hex33.expected b/tests/data/hex33.expected
index 39c5228..39c5228 100644
--- a/tests/80_testdata/hex33.expected
+++ b/tests/data/hex33.expected
diff --git a/tests/80_testdata/hex34.expected b/tests/data/hex34.expected
index a327644..a327644 100644
--- a/tests/80_testdata/hex34.expected
+++ b/tests/data/hex34.expected
diff --git a/tests/80_testdata/hex4.expected b/tests/data/hex4.expected
index aab2998..aab2998 100644
--- a/tests/80_testdata/hex4.expected
+++ b/tests/data/hex4.expected
diff --git a/tests/80_testdata/hex47.expected b/tests/data/hex47.expected
index 41f09a7..41f09a7 100644
--- a/tests/80_testdata/hex47.expected
+++ b/tests/data/hex47.expected
diff --git a/tests/80_testdata/hex48.expected b/tests/data/hex48.expected
index 6552e05..6552e05 100644
--- a/tests/80_testdata/hex48.expected
+++ b/tests/data/hex48.expected
diff --git a/tests/80_testdata/hex49.expected b/tests/data/hex49.expected
index 1749a8c..1749a8c 100644
--- a/tests/80_testdata/hex49.expected
+++ b/tests/data/hex49.expected
diff --git a/tests/80_testdata/hex5.expected b/tests/data/hex5.expected
index ea715e8..ea715e8 100644
--- a/tests/80_testdata/hex5.expected
+++ b/tests/data/hex5.expected
diff --git a/tests/80_testdata/hex50.expected b/tests/data/hex50.expected
index ed0f613..ed0f613 100644
--- a/tests/80_testdata/hex50.expected
+++ b/tests/data/hex50.expected
diff --git a/tests/80_testdata/hex500.expected b/tests/data/hex500.expected
index 1baa114..1baa114 100644
--- a/tests/80_testdata/hex500.expected
+++ b/tests/data/hex500.expected
diff --git a/tests/80_testdata/hex6.expected b/tests/data/hex6.expected
index 47c5fe8..47c5fe8 100644
--- a/tests/80_testdata/hex6.expected
+++ b/tests/data/hex6.expected
diff --git a/tests/80_testdata/hex63.expected b/tests/data/hex63.expected
index a14f5a0..a14f5a0 100644
--- a/tests/80_testdata/hex63.expected
+++ b/tests/data/hex63.expected
diff --git a/tests/80_testdata/hex64.expected b/tests/data/hex64.expected
index 230322e..230322e 100644
--- a/tests/80_testdata/hex64.expected
+++ b/tests/data/hex64.expected
diff --git a/tests/80_testdata/hex65.expected b/tests/data/hex65.expected
index 7c4fe88..7c4fe88 100644
--- a/tests/80_testdata/hex65.expected
+++ b/tests/data/hex65.expected
diff --git a/tests/80_testdata/hex66.expected b/tests/data/hex66.expected
index 884f006..884f006 100644
--- a/tests/80_testdata/hex66.expected
+++ b/tests/data/hex66.expected
diff --git a/tests/80_testdata/hex67.expected b/tests/data/hex67.expected
index 3fed293..3fed293 100644
--- a/tests/80_testdata/hex67.expected
+++ b/tests/data/hex67.expected
diff --git a/tests/80_testdata/hex7.expected b/tests/data/hex7.expected
index d1ef7d7..d1ef7d7 100644
--- a/tests/80_testdata/hex7.expected
+++ b/tests/data/hex7.expected
diff --git a/tests/80_testdata/hex8.expected b/tests/data/hex8.expected
index cdd9041..cdd9041 100644
--- a/tests/80_testdata/hex8.expected
+++ b/tests/data/hex8.expected
diff --git a/tests/80_testdata/hex9.expected b/tests/data/hex9.expected
index 6496fba..6496fba 100644
--- a/tests/80_testdata/hex9.expected
+++ b/tests/data/hex9.expected
diff --git a/tests/data/net.pcap b/tests/data/net.pcap
new file mode 100644
index 0000000..ae1488f
--- /dev/null
+++ b/tests/data/net.pcap
Binary files differ
diff --git a/tests/80_testdata/rnd1 b/tests/data/rnd1
index 8e2f0be..8e2f0be 100644
--- a/tests/80_testdata/rnd1
+++ b/tests/data/rnd1
diff --git a/tests/80_testdata/rnd10 b/tests/data/rnd10
index 54d0b58..54d0b58 100644
--- a/tests/80_testdata/rnd10
+++ b/tests/data/rnd10
diff --git a/tests/80_testdata/rnd1000 b/tests/data/rnd1000
index 781a054..781a054 100644
--- a/tests/80_testdata/rnd1000
+++ b/tests/data/rnd1000
Binary files differ
diff --git a/tests/80_testdata/rnd11 b/tests/data/rnd11
index 2bce407..2bce407 100644
--- a/tests/80_testdata/rnd11
+++ b/tests/data/rnd11
diff --git a/tests/80_testdata/rnd12 b/tests/data/rnd12
index cf09d25..cf09d25 100644
--- a/tests/80_testdata/rnd12
+++ b/tests/data/rnd12
diff --git a/tests/80_testdata/rnd127 b/tests/data/rnd127
index 6637abe..6637abe 100644
--- a/tests/80_testdata/rnd127
+++ b/tests/data/rnd127
diff --git a/tests/80_testdata/rnd128 b/tests/data/rnd128
index 7b36816..7b36816 100644
--- a/tests/80_testdata/rnd128
+++ b/tests/data/rnd128
diff --git a/tests/80_testdata/rnd13 b/tests/data/rnd13
index 18a5ed0..18a5ed0 100644
--- a/tests/80_testdata/rnd13
+++ b/tests/data/rnd13
diff --git a/tests/80_testdata/rnd14 b/tests/data/rnd14
index a68aa4a..a68aa4a 100644
--- a/tests/80_testdata/rnd14
+++ b/tests/data/rnd14
diff --git a/tests/80_testdata/rnd15 b/tests/data/rnd15
index ffb0f65..ffb0f65 100644
--- a/tests/80_testdata/rnd15
+++ b/tests/data/rnd15
diff --git a/tests/80_testdata/rnd16 b/tests/data/rnd16
index 8720f0d..8720f0d 100644
--- a/tests/80_testdata/rnd16
+++ b/tests/data/rnd16
diff --git a/tests/80_testdata/rnd2 b/tests/data/rnd2
index 8b0e2fb..8b0e2fb 100644
--- a/tests/80_testdata/rnd2
+++ b/tests/data/rnd2
diff --git a/tests/80_testdata/rnd200 b/tests/data/rnd200
index d2e6ab5..d2e6ab5 100644
--- a/tests/80_testdata/rnd200
+++ b/tests/data/rnd200
diff --git a/tests/80_testdata/rnd3 b/tests/data/rnd3
index 1bbf238..1bbf238 100644
--- a/tests/80_testdata/rnd3
+++ b/tests/data/rnd3
diff --git a/tests/80_testdata/rnd31 b/tests/data/rnd31
index 7b1c3c1..7b1c3c1 100644
--- a/tests/80_testdata/rnd31
+++ b/tests/data/rnd31
diff --git a/tests/80_testdata/rnd32 b/tests/data/rnd32
index d0474e6..d0474e6 100644
--- a/tests/80_testdata/rnd32
+++ b/tests/data/rnd32
diff --git a/tests/80_testdata/rnd33 b/tests/data/rnd33
index 6aeef33..6aeef33 100644
--- a/tests/80_testdata/rnd33
+++ b/tests/data/rnd33
diff --git a/tests/80_testdata/rnd34 b/tests/data/rnd34
index 667590e..667590e 100644
--- a/tests/80_testdata/rnd34
+++ b/tests/data/rnd34
diff --git a/tests/80_testdata/rnd4 b/tests/data/rnd4
index c30d058..c30d058 100644
--- a/tests/80_testdata/rnd4
+++ b/tests/data/rnd4
diff --git a/tests/80_testdata/rnd47 b/tests/data/rnd47
index 78758d7..78758d7 100644
--- a/tests/80_testdata/rnd47
+++ b/tests/data/rnd47
diff --git a/tests/80_testdata/rnd48 b/tests/data/rnd48
index 4d3be69..4d3be69 100644
--- a/tests/80_testdata/rnd48
+++ b/tests/data/rnd48
diff --git a/tests/80_testdata/rnd49 b/tests/data/rnd49
index 83bac49..83bac49 100644
--- a/tests/80_testdata/rnd49
+++ b/tests/data/rnd49
diff --git a/tests/80_testdata/rnd5 b/tests/data/rnd5
index 3416407..3416407 100644
--- a/tests/80_testdata/rnd5
+++ b/tests/data/rnd5
diff --git a/tests/80_testdata/rnd50 b/tests/data/rnd50
index 839affd..839affd 100644
--- a/tests/80_testdata/rnd50
+++ b/tests/data/rnd50
diff --git a/tests/80_testdata/rnd500 b/tests/data/rnd500
index 2c2bf65..2c2bf65 100644
--- a/tests/80_testdata/rnd500
+++ b/tests/data/rnd500
Binary files differ
diff --git a/tests/80_testdata/rnd6 b/tests/data/rnd6
index 2105af1..2105af1 100644
--- a/tests/80_testdata/rnd6
+++ b/tests/data/rnd6
diff --git a/tests/80_testdata/rnd63 b/tests/data/rnd63
index 7fe322d..7fe322d 100644
--- a/tests/80_testdata/rnd63
+++ b/tests/data/rnd63
diff --git a/tests/80_testdata/rnd64 b/tests/data/rnd64
index 00e38d7..00e38d7 100644
--- a/tests/80_testdata/rnd64
+++ b/tests/data/rnd64
diff --git a/tests/80_testdata/rnd65 b/tests/data/rnd65
index 53ad3f0..53ad3f0 100644
--- a/tests/80_testdata/rnd65
+++ b/tests/data/rnd65
diff --git a/tests/80_testdata/rnd66 b/tests/data/rnd66
index 9898b0a..9898b0a 100644
--- a/tests/80_testdata/rnd66
+++ b/tests/data/rnd66
diff --git a/tests/80_testdata/rnd67 b/tests/data/rnd67
index f1a9266..f1a9266 100644
--- a/tests/80_testdata/rnd67
+++ b/tests/data/rnd67
diff --git a/tests/80_testdata/rnd7 b/tests/data/rnd7
index 08b9811..08b9811 100644
--- a/tests/80_testdata/rnd7
+++ b/tests/data/rnd7
diff --git a/tests/80_testdata/rnd8 b/tests/data/rnd8
index 24de910..24de910 100644
--- a/tests/80_testdata/rnd8
+++ b/tests/data/rnd8
diff --git a/tests/80_testdata/rnd9 b/tests/data/rnd9
index aa5fbfc..aa5fbfc 100644
--- a/tests/80_testdata/rnd9
+++ b/tests/data/rnd9
diff --git a/tests/data/sad_face.gif b/tests/data/sad_face.gif
new file mode 100644
index 0000000..c2ed24d
--- /dev/null
+++ b/tests/data/sad_face.gif
Binary files differ
diff --git a/tests/jbuild b/tests/jbuild
new file mode 100644
index 0000000..5035ce3
--- /dev/null
+++ b/tests/jbuild
@@ -0,0 +1,12 @@
+(jbuild_version 1)
+
+(executable
+ ((name bitstring_tests)
+ (libraries (bitstring oUnit))
+ (preprocess (pps (ppx_bitstring)))
+ ))
+
+(alias
+ ((name runtest)
+ (deps (bitstring_tests.exe))
+ (action (run ${<}))))
diff --git a/tests/test_01_load.ml b/tests/test_01_load.ml
deleted file mode 100644
index 653b70a..0000000
--- a/tests/test_01_load.ml
+++ /dev/null
@@ -1,5 +0,0 @@
-(* Just check that the extension and library load without error.
- * $Id$
- *)
-
-let _ = Bitstring.extract_bit
diff --git a/tests/test_02_run.ml b/tests/test_02_run.ml
deleted file mode 100644
index ae0e331..0000000
--- a/tests/test_02_run.ml
+++ /dev/null
@@ -1,7 +0,0 @@
-(* Just check that we can run some functions from the library.
- * $Id$
- *)
-
-let () =
- let bits = Bitstring.create_bitstring 16 in
- ignore (Bitstring.string_of_bitstring bits)
diff --git a/tests/test_10_match_bits.ml b/tests/test_10_match_bits.ml
deleted file mode 100644
index f0dde30..0000000
--- a/tests/test_10_match_bits.ml
+++ /dev/null
@@ -1,86 +0,0 @@
-(* Match random bits.
- * $Id$
- *)
-
-open Printf
-
-let rec range a b =
- if a <= b then
- a :: range (a+1) b
- else
- []
-
-let () =
- Random.self_init ();
-
- for len = 0 to 999 do
- (* Create a random string of bits. *)
- let expected = List.map (fun _ -> Random.bool ()) (range 0 (len-1)) in
-
- let bits = Bitstring.Buffer.create () in
- List.iter (Bitstring.Buffer.add_bit bits) expected;
- let bits = Bitstring.Buffer.contents bits in
-
- (* Now read the bitstring in groups of 1, 2, 3 .. etc. bits.
- * In each case check the result against what we generated ('expected').
- *)
- let actual =
- let rec loop bits =
- bitmatch bits with
- | { b0 : 1; rest : -1 : bitstring } -> b0 :: loop rest
- | { _ } -> []
- in
- loop bits in
- if actual <> expected then
- failwith (sprintf "match bits: failed on 1 bit test, len = %d" len);
-
- let actual =
- let rec loop bits =
- bitmatch bits with
- | { b0 : 1; b1 : 1; rest : -1 : bitstring } -> b0 :: b1 :: loop rest
- | { b0 : 1; rest : -1 : bitstring } -> b0 :: loop rest
- | { _ } -> []
- in
- loop bits in
- if actual <> expected then
- failwith (sprintf "match bits: failed on 1 bit test, len = %d" len);
-
- let actual =
- let rec loop bits =
- bitmatch bits with
- | { b0 : 1; b1 : 1; b2 : 1;
- rest : -1 : bitstring } -> b0 :: b1 :: b2 :: loop rest
- | { b0 : 1; rest : -1 : bitstring } -> b0 :: loop rest
- | { _ } -> []
- in
- loop bits in
- if actual <> expected then
- failwith (sprintf "match bits: failed on 1 bit test, len = %d" len);
-
- let actual =
- let rec loop bits =
- bitmatch bits with
- | { b0 : 1; b1 : 1; b2 : 1; b3 : 1;
- rest : -1 : bitstring } -> b0 :: b1 :: b2 :: b3 :: loop rest
- | { b0 : 1; rest : -1 : bitstring } -> b0 :: loop rest
- | { _ } -> []
- in
- loop bits in
- if actual <> expected then
- failwith (sprintf "match bits: failed on 1 bit test, len = %d" len);
-
- let actual =
- let rec loop bits =
- bitmatch bits with
- | { b0 : 1; b1 : 1; b2 : 1; b3 : 1;
- b4 : 1; b5 : 1; b6 : 1; b7 : 1;
- b8 : 1;
- rest : -1 : bitstring } ->
- b0 :: b1 :: b2 :: b3 :: b4 :: b5 :: b6 :: b7 :: b8 :: loop rest
- | { b0 : 1; rest : -1 : bitstring } -> b0 :: loop rest
- | { _ } -> []
- in
- loop bits in
- if actual <> expected then
- failwith (sprintf "match bits: failed on 1 bit test, len = %d" len);
- done
diff --git a/tests/test_11_match_ints.ml b/tests/test_11_match_ints.ml
deleted file mode 100644
index c9ffd1a..0000000
--- a/tests/test_11_match_ints.ml
+++ /dev/null
@@ -1,49 +0,0 @@
-(* Match random bits with integers.
- * $Id$
- *)
-
-open Printf
-
-let rec range a b =
- if a <= b then
- a :: range (a+1) b
- else
- []
-
-let () =
- Random.self_init ();
-
- for len = 1 to 99 do
- for bitlen = 1 to 63 do
- (* Create a random string of ints. *)
- let expected =
- List.map (fun _ ->
- Random.int64 (Int64.sub (Int64.shift_left 1L bitlen) 1L))
- (range 0 (len-1)) in
-
- let bits = Bitstring.Buffer.create () in
- List.iter (fun i ->
- Bitstring.construct_int64_be_unsigned bits i bitlen
- (Failure "constructing string"))
- expected;
- let bits = Bitstring.Buffer.contents bits in
-
- (* Now read the bitstring as integers.
- * In each case check the result against what we generated ('expected').
- *)
- let actual =
- let rec loop bits =
- bitmatch bits with
- | { i : bitlen; rest : -1 : bitstring }
- when Bitstring.bitstring_length rest = 0 -> [i]
- | { i : bitlen; rest : -1 : bitstring } -> i :: loop rest
- | { _ } ->
- failwith (sprintf "loop failed with len = %d, bitlen = %d"
- len bitlen)
- in
- loop bits in
- if actual <> expected then
- failwith (sprintf "match ints: failed on test, len = %d, bitlen = %d"
- len bitlen)
- done
- done
diff --git a/tests/test_15_extract_int.ml b/tests/test_15_extract_int.ml
deleted file mode 100644
index 7ba682e..0000000
--- a/tests/test_15_extract_int.ml
+++ /dev/null
@@ -1,112 +0,0 @@
-(* Test functions which construct and extract fixed-length ints
- * of various sizes.
- * $Id$
- *)
-
-open Printf
-
-open Bitstring
-
-let () =
- for i = 0 to 129 do
- let zeroes = zeroes_bitstring i in
- let bits = (
- BITSTRING {
- zeroes : i : bitstring;
- true : 1;
- 2 : 2 : littleendian;
- 2 : 2 : bigendian;
- 2 : 2 : nativeendian;
- 3 : 3 : littleendian;
- 3 : 3 : bigendian;
- 3 : 3 : nativeendian;
- 0x5a : 8 : littleendian;
- 0x5a : 8 : bigendian;
- 0x5a : 8 : nativeendian;
- 0xa5a5 : 16 : littleendian;
- 0xa5a5 : 16 : bigendian;
- 0xa5a5 : 16 : nativeendian;
- 0xeeddcc : 24 : littleendian;
- 0xeeddcc : 24 : bigendian;
- 0xeeddcc : 24 : nativeendian;
- 0x48888888 : 31 : littleendian;
- 0x48888888 : 31 : bigendian;
- 0x48888888 : 31 : nativeendian;
- 0xaabbccdd_l : 32 : littleendian;
- 0xaabbccdd_l : 32 : bigendian;
- 0xaabbccdd_l : 32 : nativeendian;
- 0xaabbccddeeff_L : 48 : littleendian;
- 0xaabbccddeeff_L : 48 : bigendian;
- 0xaabbccddeeff_L : 48 : nativeendian;
- 0x0011aabbccddeeff_L : 64 : littleendian;
- 0x0011aabbccddeeff_L : 64 : bigendian;
- 0x0011aabbccddeeff_L : 64 : nativeendian
- }
- ) in
- bitmatch bits with
- | { _ : i : bitstring;
- a : 1;
- b0 : 2 : littleendian;
- b1 : 2 : bigendian;
- b2 : 2 : nativeendian;
- c0 : 3 : littleendian;
- c1 : 3 : bigendian;
- c2 : 3 : nativeendian;
- d0 : 8 : littleendian;
- d1 : 8 : bigendian;
- d2 : 8 : nativeendian;
- e0 : 16 : littleendian;
- e1 : 16 : bigendian;
- e2 : 16 : nativeendian;
- f0 : 24 : littleendian;
- f1 : 24 : bigendian;
- f2 : 24 : nativeendian;
- g0 : 31 : littleendian;
- g1 : 31 : bigendian;
- g2 : 31 : nativeendian;
- h0 : 32 : littleendian;
- h1 : 32 : bigendian;
- h2 : 32 : nativeendian;
- j0 : 48 : littleendian;
- j1 : 48 : bigendian;
- j2 : 48 : nativeendian;
- k0 : 64 : littleendian;
- k1 : 64 : bigendian;
- k2 : 64 : nativeendian
- } ->
- if a <> true
- || b0 <> 2
- || b1 <> 2
- || b2 <> 2
- || c0 <> 3
- || c1 <> 3
- || c2 <> 3
- || d0 <> 0x5a
- || d1 <> 0x5a
- || d2 <> 0x5a
- || e0 <> 0xa5a5
- || e1 <> 0xa5a5
- || e2 <> 0xa5a5
- || f0 <> 0xeeddcc
- || f1 <> 0xeeddcc
- || f2 <> 0xeeddcc
- || g0 <> 0x48888888
- || g1 <> 0x48888888
- || g2 <> 0x48888888
- || h0 <> 0xaabbccdd_l
- || h1 <> 0xaabbccdd_l
- || h2 <> 0xaabbccdd_l
- || j0 <> 0xaabbccddeeff_L
- || j1 <> 0xaabbccddeeff_L
- || j2 <> 0xaabbccddeeff_L
- || k0 <> 0x0011aabbccddeeff_L
- || k1 <> 0x0011aabbccddeeff_L
- || k2 <> 0x0011aabbccddeeff_L
- then (
- eprintf "15_extract_int: match failed %b %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %ld %ld %ld %Ld %Ld %Ld %Ld %Ld %Ld\n"
- a b0 b1 b2 c0 c1 c2 d0 d1 d2 e0 e1 e2 f0 f1 f2 g0 g1 g2 h0 h1 h2 j0 j1 j2 k0 k1 k2;
- exit 1
- )
- | { _ } ->
- failwith "15_extract_int"
- done
diff --git a/tests/test_18_extract_32_64_int.ml b/tests/test_18_extract_32_64_int.ml
deleted file mode 100644
index bee7f3b..0000000
--- a/tests/test_18_extract_32_64_int.ml
+++ /dev/null
@@ -1,43 +0,0 @@
-(* Test fix for a regression when extracting 32 and 64 bit aligned
- * integers (discovered / fixed / tested by Hans Ole Rafaelsen).
- * $Id$
- *)
-
-open Printf
-
-open Bitstring
-
-let bitstring_of_int32 i =
- BITSTRING { i : 32 }
-
-let bitstring_of_int64 i =
- BITSTRING { i : 64 }
-
-let int32_of_bitstring bits =
- bitmatch bits with
- | { i : 32 } -> i
-
-let int64_of_bitstring bits =
- bitmatch bits with
- | { i : 64 } -> i
-
-let () =
- let b1 = bitstring_of_int32 1_l in
- let b2 = bitstring_of_int32 2_l in
- let b3 = bitstring_of_int32 3_l in
- let i1 = int32_of_bitstring b1 in
- let i2 = int32_of_bitstring b2 in
- let i3 = int32_of_bitstring b3 in
- assert (i1 = 1_l);
- assert (i2 = 2_l);
- assert (i3 = 3_l);
-
- let b1 = bitstring_of_int64 1_L in
- let b2 = bitstring_of_int64 2_L in
- let b3 = bitstring_of_int64 3_L in
- let i1 = int64_of_bitstring b1 in
- let i2 = int64_of_bitstring b2 in
- let i3 = int64_of_bitstring b3 in
- assert (i1 = 1_L);
- assert (i2 = 2_L);
- assert (i3 = 3_L)
diff --git a/tests/test_20_varsize.ml b/tests/test_20_varsize.ml
deleted file mode 100644
index 1014bcb..0000000
--- a/tests/test_20_varsize.ml
+++ /dev/null
@@ -1,95 +0,0 @@
-(* Construct and match against random variable sized strings.
- * $Id$
- *)
-
-open Printf
-
-let nr_passes = 10000
-let max_size = 8 (* max field size in bits *)
-
-(* let () = Bitstring.debug := true *)
-
-(* Return a full 64 bits of randomness. *)
-let rand64 () =
- let r0 = Int64.shift_left (Int64.of_int (Random.bits ())) 34 in (* 30 bits *)
- let r1 = Int64.shift_left (Int64.of_int (Random.bits ())) 4 in (* 30 bits *)
- let r2 = Int64.of_int (Random.int 16) in (* 4 bits *)
- Int64.logor (Int64.logor r0 r1) r2
-
-(* Return unsigned mask of length bits, bits <= 64. *)
-let mask64 bits =
- if bits < 63 then Int64.pred (Int64.shift_left 1L bits)
- else if bits = 63 then Int64.max_int
- else if bits = 64 then -1L
- else invalid_arg "mask64"
-
-(* Return a random number between 0 and 2^bits-1 where bits <= 64. *)
-let rand bits =
- let r = rand64 () in
- let m = mask64 bits in
- Int64.logand r m
-
-(* Dump the state in case there is an error. *)
-let dump n0 n0sz n1 n1sz n2 n2sz n3 n3sz bits r0 r1 r2 r3 =
- eprintf "dumping state:\n";
- eprintf " 0: %3d - %016Lx - %016Lx\n" n0sz n0 r0;
- eprintf " 1: %3d - %016Lx - %016Lx\n" n1sz n1 r1;
- eprintf " 2: %3d - %016Lx - %016Lx\n" n2sz n2 r2;
- eprintf " 3: %3d - %016Lx - %016Lx\n" n3sz n3 r3;
- eprintf "bits (length = %d):\n" (Bitstring.bitstring_length bits);
- Bitstring.hexdump_bitstring stderr bits;
- eprintf "%!"
-
-let () =
- Random.self_init ();
-
- for pass = 0 to nr_passes-1 do
- let n0sz = 1 + Random.int (max_size-1) in
- let n0 = rand n0sz in
- let n1sz = 1 + Random.int (max_size-1) in
- let n1 = rand n1sz in
- let n2sz = 1 + Random.int (max_size-1) in
- let n2 = rand n2sz in
- let n3sz = 1 + Random.int (max_size-1) in
- let n3 = rand n3sz in
-
- (* Construct the bitstring. *)
- let bits =
- try
- (BITSTRING {
- n0 : n0sz;
- n1 : n1sz;
- n2 : n2sz;
- n3 : n3sz
- })
- with
- Bitstring.Construct_failure (msg, _, _, _) ->
- eprintf "FAILED: Construct_failure %s\n%!" msg;
- dump n0 n0sz n1 n1sz n2 n2sz n3 n3sz
- (Bitstring.empty_bitstring) 0L 0L 0L 0L;
- exit 2 in
-
- let r0, r1, r2, r3 =
- bitmatch bits with
- | { r0 : n0sz; r1 : n1sz; r2 : n2sz; r3 : n3sz; rest : -1 : bitstring } ->
- let rest_len = Bitstring.bitstring_length rest in
- if rest_len <> 0 then (
- eprintf "FAILED: rest is not zero length (length = %d)\n%!"
- rest_len;
- dump n0 n0sz n1 n1sz n2 n2sz n3 n3sz bits 0L 0L 0L 0L;
- exit 2
- );
- r0, r1, r2, r3
- | { _ } ->
- eprintf "FAILED: bitmatch operator did not match\n%!";
- dump n0 n0sz n1 n1sz n2 n2sz n3 n3sz bits 0L 0L 0L 0L;
- exit 2 in
-
- (*dump n0 n0sz n1 n1sz n2 n2sz n3 n3sz bits r0 r1 r2 r3;*)
-
- if n0 <> r0 || n1 <> r1 || n2 <> r2 || n3 <> r3 then (
- eprintf "FAILED: numbers returned from match are different\n%!";
- dump n0 n0sz n1 n1sz n2 n2sz n3 n3sz bits r0 r1 r2 r3;
- exit 2
- )
- done
diff --git a/tests/test_30_bitbuffer.ml b/tests/test_30_bitbuffer.ml
deleted file mode 100644
index 466a8f2..0000000
--- a/tests/test_30_bitbuffer.ml
+++ /dev/null
@@ -1,66 +0,0 @@
-(* Test the Bitstring.Buffer module and string_of_bitstring in
- * nasty non-aligned corner cases.
- * $Id$
- *)
-
-open Printf
-
-let () =
- Random.self_init ();
-
- let str1 = "012345678" in
-
- for offset = 0 to 65 do
- for len = 1 to 65 do
- let expected =
- let strlen = (len+7) lsr 3 in
- let expected = String.create strlen in
- for i = 0 to strlen-1 do
- expected.[i] <- Char.chr (Random.int 256)
- done;
- let last = Char.code expected.[strlen-1] in
- let last = last land (0xff lsl (8 - (len land 7))) in
- expected.[strlen-1] <- Char.chr last;
- expected in
-
- (* Create a random bitstring:
- * +-------------+-------------------------------------------+
- * | (random) | bits that we check (expected) |
- * +-------------+-------------------------------------------+
- * 0 offset offset+len
- * <---------------- len bits --------------->
- *)
- let bits =
- let bits = Bitstring.Buffer.create () in
- Bitstring.Buffer.add_bits bits str1 offset;
- Bitstring.Buffer.add_bits bits expected len;
- Bitstring.Buffer.contents bits in
-
- (* Create a sub bitstring corresponding to what we want to check. *)
- let subbits =
- let bits, bitoffset, bitlen = bits in
- (bits, bitoffset+offset, bitlen-offset) in
-
- assert (Bitstring.bitstring_length subbits = len);
-
- (* Now try to read out the substring using string_of_bitstring. *)
- let actual = Bitstring.string_of_bitstring subbits in
- if actual <> expected then (
- eprintf "MISMATCH between actual and expected, offset=%d, len=%d\n"
- offset len;
- eprintf "EXPECTED string:\n";
- for i = 0 to String.length expected-1 do
- eprintf " %02x" (Char.code expected.[i])
- done;
- eprintf "\nACTUAL string:\n";
- for i = 0 to String.length actual-1 do
- eprintf " %02x" (Char.code actual.[i])
- done;
- eprintf "\nBITS:\n";
- Bitstring.hexdump_bitstring stderr bits;
- eprintf "SUBBITS:\n";
- Bitstring.hexdump_bitstring stderr subbits;
- exit 1
- );
- done
- done
diff --git a/tests/test_31_bitstring_concat.ml b/tests/test_31_bitstring_concat.ml
deleted file mode 100644
index cd58c73..0000000
--- a/tests/test_31_bitstring_concat.ml
+++ /dev/null
@@ -1,27 +0,0 @@
-(* Test concat and the bit get functions.
- * $Id$
- *)
-
-let () =
- for i = 0 to 33 do
- for j = 0 to 33 do
- for k = 0 to 33 do
- let bits =
- Bitstring.concat [
- Bitstring.ones_bitstring i;
- Bitstring.zeroes_bitstring j;
- Bitstring.ones_bitstring k
- ] in
- assert (Bitstring.bitstring_length bits = i+j+k);
- for n = 0 to i-1 do
- assert (Bitstring.is_set bits n)
- done;
- for n = i to i+j-1 do
- assert (Bitstring.is_clear bits n)
- done;
- for n = i+j to i+j+k-1 do
- assert (Bitstring.is_set bits n)
- done
- done
- done
- done
diff --git a/tests/test_32_bitstring_compare.ml b/tests/test_32_bitstring_compare.ml
deleted file mode 100644
index 4f06e6d..0000000
--- a/tests/test_32_bitstring_compare.ml
+++ /dev/null
@@ -1,60 +0,0 @@
-(* Compare bitstrings.
- * $Id$
- *)
-
-open Printf
-
-let sgn = function
- | 0 -> 0
- | i when i > 0 -> 1
- | _ -> -1
-
-let () =
- for i = 0 to 33 do
- for j = 0 to 33 do
- let bits1 = Bitstring.ones_bitstring i
- and bits2 = Bitstring.ones_bitstring j in
- let r = Bitstring.compare bits1 bits2 in
- if sgn r <> sgn (compare i j) then (
- eprintf "ones compare failed %d %d %d\n" i j r;
- exit 1
- )
- done
- done;
- for i = 0 to 33 do
- for j = 0 to 33 do
- let bits1 = Bitstring.zeroes_bitstring i
- and bits2 = Bitstring.zeroes_bitstring j in
- let r = Bitstring.compare bits1 bits2 in
- if sgn r <> sgn (compare i j) then (
- eprintf "zeroes compare failed %d %d %d\n" i j r;
- exit 1
- )
- done
- done;
- for i = 0 to 33 do
- for j = 0 to 33 do
- let bits1 = Bitstring.make_bitstring i '\x55'
- and bits2 = Bitstring.make_bitstring j '\x55' in
- let r = Bitstring.compare bits1 bits2 in
- if sgn r <> sgn (compare i j) then (
- eprintf "x55 compare failed %d %d %d\n" i j r;
- exit 1
- )
- done
- done;
- for i = 0 to 33 do
- for j = 0 to 33 do
- let bits1 = Bitstring.make_bitstring i '\x55' in
- let bits2 = Bitstring.make_bitstring i '\x55' in
- let bits2 = Bitstring.concat [Bitstring.zeroes_bitstring j; bits2] in
- assert (Bitstring.bitstring_length bits2 = j+i);
- let bits2 = Bitstring.dropbits j bits2 in
- assert (Bitstring.bitstring_length bits2 = i);
- let r = Bitstring.compare bits1 bits2 in
- if r <> 0 then (
- eprintf "x55 non-aligned compare failed %d %d %d\n" i j r;
- exit 1
- )
- done
- done
diff --git a/tests/test_33_substring.ml b/tests/test_33_substring.ml
deleted file mode 100644
index f6bc93d..0000000
--- a/tests/test_33_substring.ml
+++ /dev/null
@@ -1,20 +0,0 @@
-(* Test subbitstring call.
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-let () =
- let bits = make_bitstring 65 '\x5a' in
- for off = 0 to 65 do
- for len = 65-off to 0 do
- let sub = subbitstring bits off len in
- for i = 0 to len-1 do
- if get bits (off+i) <> get sub i then (
- eprintf "33_substring: failed %d %d %d\n" off len i;
- exit 1
- )
- done
- done
- done
diff --git a/tests/test_34_takebits.ml b/tests/test_34_takebits.ml
deleted file mode 100644
index b86591d..0000000
--- a/tests/test_34_takebits.ml
+++ /dev/null
@@ -1,13 +0,0 @@
-(* Test takebits call.
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-let () =
- let bits = make_bitstring 65 '\x5a' in
- for len = 0 to 65 do
- let sub = takebits len bits in
- assert (bitstring_length sub = len)
- done
diff --git a/tests/test_35_load_from_file.ml b/tests/test_35_load_from_file.ml
deleted file mode 100644
index 849d2f1..0000000
--- a/tests/test_35_load_from_file.ml
+++ /dev/null
@@ -1,56 +0,0 @@
-(* Test the various functions to load bitstrings from files.
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-let () =
- let bits1 =
- let b1 = make_bitstring 800 '\x5a' in
- let b2 = make_bitstring 400 '\x88' in (
- BITSTRING {
- b1 : 800 : bitstring;
- b2 : 400 : bitstring
- }
- ) in
- let bits2 = (
- let b = make_bitstring 800 '\xaa' in
- BITSTRING {
- b : 800 : bitstring
- }
- ) in
- let bits = concat [bits1; bits2] in
- let filename, chan =
- Filename.open_temp_file ~mode:[Open_binary] "bitstring_test" ".tmp" in
- bitstring_to_chan bits chan;
- close_out chan;
-
- let bits' = bitstring_of_file filename in
- assert (equals bits bits');
-
- let chan = open_in filename in
- let bits' = bitstring_of_chan chan in
- close_in chan;
- assert (equals bits bits');
-
- let chan = open_in filename in
- let bits' = bitstring_of_chan_max chan 150 in
- assert (equals bits1 bits');
- let bits' = bitstring_of_chan_max chan 100 in
- assert (equals bits2 bits');
- close_in chan;
-
- let fd = Unix.openfile filename [Unix.O_RDONLY] 0 in
- let bits' = bitstring_of_file_descr fd in
- Unix.close fd;
- assert (equals bits bits');
-
- let fd = Unix.openfile filename [Unix.O_RDONLY] 0 in
- let bits' = bitstring_of_file_descr_max fd 150 in
- assert (equals bits1 bits');
- let bits' = bitstring_of_file_descr_max fd 100 in
- assert (equals bits2 bits');
- Unix.close fd;
-
- Unix.unlink filename
diff --git a/tests/test_36_is_zeroes_ones.ml b/tests/test_36_is_zeroes_ones.ml
deleted file mode 100644
index 59ab38f..0000000
--- a/tests/test_36_is_zeroes_ones.ml
+++ /dev/null
@@ -1,29 +0,0 @@
-(* Test if bitstrings are all zeroes or all ones.
- * $Id$
- *)
-
-open Printf
-
-let () =
- for i = 0 to 33 do
- let bits = Bitstring.zeroes_bitstring i in
- if not (Bitstring.is_zeroes_bitstring bits) then (
- eprintf "is_zeros_bitstring failed %d\n" i;
- exit 1
- );
- if i > 0 && Bitstring.is_ones_bitstring bits then (
- eprintf "false match is_ones_bitstring %d\n" i;
- exit 1
- )
- done;
- for i = 0 to 33 do
- let bits = Bitstring.ones_bitstring i in
- if not (Bitstring.is_ones_bitstring bits) then (
- eprintf "is_ones_bitstring failed %d\n" i;
- exit 1
- );
- if i > 0 && Bitstring.is_zeroes_bitstring bits then (
- eprintf "false match is_zeroes_bitstring %d\n" i;
- exit 1
- )
- done
diff --git a/tests/test_40_endianexpr.ml b/tests/test_40_endianexpr.ml
deleted file mode 100644
index 6dd4a7f..0000000
--- a/tests/test_40_endianexpr.ml
+++ /dev/null
@@ -1,35 +0,0 @@
-(* Endianness expressions
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-let () =
- let rec loop = function
- | (e, expected) :: rest ->
- let bits = BITSTRING {
- expected : 32 : endian (e);
- expected : 32 : endian (e);
- expected : 32 : endian (e)
- } in
- (bitmatch bits with
- | { actual : 32 : endian (e);
- actual : 32 : endian (e);
- actual : 32 : endian (e) } ->
- if actual <> expected then
- failwith (sprintf "actual %ld <> expected %ld" actual expected)
- | { _ } as bits ->
- hexdump_bitstring stderr bits; exit 1
- );
- loop rest
- | [] -> ()
- in
- loop [
- BigEndian, 0xa1b2c3d4_l;
- BigEndian, 0xa1d4c3b2_l;
- LittleEndian, 0xa1b2c3d4_l;
- LittleEndian, 0xa1d4c3b2_l;
- NativeEndian, 0xa1b2c3d4_l;
- NativeEndian, 0xa1d4c3b2_l;
- ]
diff --git a/tests/test_50_named_pattern.ml b/tests/test_50_named_pattern.ml
deleted file mode 100644
index c14bebb..0000000
--- a/tests/test_50_named_pattern.ml
+++ /dev/null
@@ -1,20 +0,0 @@
-(* Named pattern
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-(* A byte+length Pascal string. *)
-let bitmatch pascal_string =
- { len : 8;
- str : len*8 : string }
-
-let () =
- let bits = bitstring_of_string "\022Mary had a little lamb" in
- bitmatch bits with
- | { :pascal_string } ->
- () (*printf "it's a Pascal string, len = %d, string = %S\n" len str*)
- | { _ } ->
- eprintf "not matching error\n";
- exit 1
diff --git a/tests/test_51_open_pattern.ml b/tests/test_51_open_pattern.ml
deleted file mode 100644
index 8c0b33b..0000000
--- a/tests/test_51_open_pattern.ml
+++ /dev/null
@@ -1,17 +0,0 @@
-(* Open a persistent pattern
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-open bitmatch "tests/test.bmpp"
-
-let () =
- let bits = bitstring_of_string "\022Mary had a little lamb" in
- bitmatch bits with
- | { :pascal_string } ->
- () (*printf "it's a Pascal string, len = %d, string = %S\n" len str*)
- | { _ } ->
- eprintf "not matching error\n";
- exit 1
diff --git a/tests/test_60_simple_offset.ml b/tests/test_60_simple_offset.ml
deleted file mode 100644
index a2b00ca..0000000
--- a/tests/test_60_simple_offset.ml
+++ /dev/null
@@ -1,35 +0,0 @@
-(* Simple offset test
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-let make_bits i n j m k = (
- let pad1 = ones_bitstring (n-8) in
- let pad2 = ones_bitstring (m-n-8) in
- BITSTRING {
- i : 8;
- pad1 : n-8 : bitstring;
- j : 8; (* this should be at offset(n) *)
- pad2 : m-n-8 : bitstring;
- k : 8 (* this should be at offset(m) *)
- }
-)
-
-let test_bits bits i n j m k =
- bitmatch bits with
- | { i' : 8;
- j' : 8 : offset(n);
- k' : 8 : offset(m) } when i = i' && j = j' && k = k' -> () (* ok *)
- | { _ } ->
- failwith (sprintf "60_simple_offset: test_bits: failed %d %d %d %d %d"
- i n j m k)
-
-let () =
- for n = 8 to 128 do
- for m = n+8 to 256 do
- List.iter (fun (i,j,k) -> test_bits (make_bits i n j m k) i n j m k)
- [0x55, 0xaa, 0x33; 0x33, 0xaa, 0x55; 0x12, 0x34, 0x56]
- done;
- done
diff --git a/tests/test_61_offset_string.ml b/tests/test_61_offset_string.ml
deleted file mode 100644
index 1ea7f70..0000000
--- a/tests/test_61_offset_string.ml
+++ /dev/null
@@ -1,40 +0,0 @@
-(* Offset string. The rotation functions used for strings are
- * very complicated so this is worth testing separately.
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-let make_bits si n sj m sk = (
- let pad1 = ones_bitstring (n-64) in
- let pad2 = ones_bitstring (m-n-8) in
- BITSTRING {
- si : 64 : string;
- pad1 : n-64 : bitstring;
- sj : 8 : string; (* this should be at offset(n) *)
- pad2 : m-n-8 : bitstring;
- sk : 64 : string (* this should be at offset(m) *)
- }
-)
-
-let test_bits bits si n sj m sk =
- bitmatch bits with
- | { si' : 64 : string;
- sj' : 8 : string, offset(n);
- sk' : 64 : string, offset(m) }
- when si = si' && sj = sj' && sk = sk' -> () (* ok *)
- | { _ } ->
- failwith (sprintf "61_offset_string: test_bits: failed %S %d %S %d %S"
- si n sj m sk)
-
-let () =
- for n = 64 to 128 do
- for m = n+8 to 256 do
- List.iter (fun (si,sj,sk) ->
- test_bits (make_bits si n sj m sk) si n sj m sk)
- ["ABCDEFGH", "x", "HGFEDCBA";
- "01234567", "0", "76543210";
- "abcdefgh", "\x55", "poiuytre"]
- done;
- done
diff --git a/tests/test_62_offset_padding.ml b/tests/test_62_offset_padding.ml
deleted file mode 100644
index 3276965..0000000
--- a/tests/test_62_offset_padding.ml
+++ /dev/null
@@ -1,42 +0,0 @@
-(* Test computed offsets when original_off <> 0.
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-let make_bits p i n j m k = (
- let pad0 = ones_bitstring p in
- let pad1 = ones_bitstring (n-8) in
- let pad2 = ones_bitstring (m-n-8) in
- BITSTRING {
- pad0 : p : bitstring; (* will be skipped below *)
- i : 8;
- pad1 : n-8 : bitstring;
- j : 8; (* this should be at offset(n) *)
- pad2 : m-n-8 : bitstring;
- k : 8 (* this should be at offset(m) *)
- }
-)
-
-let test_bits bits p i n j m k =
- (* Skip the 'p' padding bits so the match starts at a non-zero offset. *)
- let bits = dropbits p bits in
-
- bitmatch bits with
- | { i' : 8;
- j' : 8 : offset(n);
- k' : 8 : offset(m) } when i = i' && j = j' && k = k' -> () (* ok *)
- | { _ } ->
- failwith (sprintf "62_offset_padding: test_bits: failed %d %d %d %d %d %d"
- p i n j m k)
-
-let () =
- for p = 1 to 4 do
- for n = 8 to 128 do
- for m = n+8 to 256 do
- List.iter (fun (i,j,k) -> test_bits (make_bits p i n j m k) p i n j m k)
- [0x55, 0xaa, 0x33; 0x33, 0xaa, 0x55; 0x12, 0x34, 0x56]
- done;
- done;
- done
diff --git a/tests/test_65_save_offset_to.ml b/tests/test_65_save_offset_to.ml
deleted file mode 100644
index b731a5f..0000000
--- a/tests/test_65_save_offset_to.ml
+++ /dev/null
@@ -1,47 +0,0 @@
-(* Test save_offset_to.
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-let make_bits p i n j m k = (
- let pad0 = ones_bitstring p in
- let pad1 = ones_bitstring (n-8) in
- let pad2 = ones_bitstring (m-n-8) in
- BITSTRING {
- pad0 : p : bitstring; (* will be skipped below *)
- i : 8;
- pad1 : n-8 : bitstring;
- j : 8; (* this should be at offset(n) *)
- pad2 : m-n-8 : bitstring;
- k : 8 (* this should be at offset(m) *)
- }
-)
-
-let test_bits bits p i n j m k =
- (* Skip the 'p' padding bits so the match starts at a non-zero offset. *)
- let bits = dropbits p bits in
-
- bitmatch bits with
- | { i' : 8;
- _ : n-8 : bitstring;
- j' : 8 : save_offset_to (j_offset);
- _ : m-n-8 : bitstring;
- k' : 8 : save_offset_to (k_offset) }
- when i = i' && j = j' && k = k' && j_offset = n && k_offset = m ->
- () (* ok *)
- | { _ } ->
- failwith (sprintf
- "65_save_offset_to: test_bits: failed %d %d %d %d %d %d"
- p i n j m k)
-
-let () =
- for p = 0 to 4 do
- for n = 8 to 64 do
- for m = n+8 to 128 do
- List.iter (fun (i,j,k) -> test_bits (make_bits p i n j m k) p i n j m k)
- [0x55, 0xaa, 0x33; 0x33, 0xaa, 0x55; 0x12, 0x34, 0x56]
- done;
- done;
- done
diff --git a/tests/test_70_check_and_bind.ml b/tests/test_70_check_and_bind.ml
deleted file mode 100644
index a63ee6b..0000000
--- a/tests/test_70_check_and_bind.ml
+++ /dev/null
@@ -1,17 +0,0 @@
-(* Test check() and bind().
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-let bits = (BITSTRING { 101 : 16; 202 : 16 })
-
-let () =
- bitmatch bits with
- | { i : 16 : check (i = 101), bind (i*4);
- j : 16 : check (j = 202) } ->
- if i <> 404 || j <> 202 then
- failwith (sprintf "70_check_and_bind: failed: %d %d" i j)
- | { _ } ->
- failwith "70_check_and_bind: match failed"
diff --git a/tests/test_80_hexdump.ml b/tests/test_80_hexdump.ml
deleted file mode 100644
index 0c0ec8d..0000000
--- a/tests/test_80_hexdump.ml
+++ /dev/null
@@ -1,58 +0,0 @@
-(* Test hexdump.
- * $Id$
- *)
-
-open Printf
-
-open Bitstring
-
-let (//) = Filename.concat
-
-let testdata = "tests" // "80_testdata" ;;
-Sys.chdir testdata ;;
-
-let diff = Bitstring_config.diff
-
-let () =
- let files = Sys.readdir "." in
- let files = Array.to_list files in
- let files = List.filter (
- fun filename ->
- String.length filename > 3 &&
- filename.[0] = 'r' && filename.[1] = 'n' && filename.[2] = 'd'
- ) files in
- let files = List.map (
- fun filename ->
- let n = String.sub filename 3 (String.length filename - 3) in
- let n = int_of_string n in
- let bits = bitstring_of_file filename in
- (* 'bitstring_of_file' loads whole bytes. Truncate it to
- * the real bit-length.
- *)
- let bits = takebits n bits in
-
- filename, n, bits
- ) files in
-
- (* Hexdump the bits, then compare using external 'diff' program. *)
- List.iter (
- fun (filename, n, bits) ->
- let output_filename = sprintf "hex%d.actual" n in
- let chan = open_out output_filename in
- hexdump_bitstring chan bits;
- close_out chan
- ) files;
-
- List.iter (
- fun (filename, n, bits) ->
- let actual_filename = sprintf "hex%d.actual" n in
- let expected_filename = sprintf "hex%d.expected" n in
- let cmd =
- sprintf "%s -u %s %s"
- (Filename.quote diff)
- (Filename.quote expected_filename)
- (Filename.quote actual_filename) in
- if Sys.command cmd <> 0 then (
- exit 1
- )
- ) files
diff --git a/tests/test_90_bind_as.ml b/tests/test_90_bind_as.ml
deleted file mode 100644
index a83d7ce..0000000
--- a/tests/test_90_bind_as.ml
+++ /dev/null
@@ -1,18 +0,0 @@
-(* Regression test for bug in 'as-binding' found by Matej Kosik.
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-let bits = Bitstring.ones_bitstring 1 in
-bitmatch bits with
-| { _ : 1 } as foo ->
- let len = Bitstring.bitstring_length foo in
- if len <> 1 then (
- hexdump_bitstring stderr foo;
- eprintf "test error: length = %d, expecting 1\n" len;
- exit 1
- )
-| { _ } ->
- assert false
diff --git a/tests/test_91_concat.ml b/tests/test_91_concat.ml
deleted file mode 100644
index b0ab911..0000000
--- a/tests/test_91_concat.ml
+++ /dev/null
@@ -1,74 +0,0 @@
-(* Regression test for bug in concatenation found by Phil Tomson.
- * $Id$
- *)
-
-open Printf
-open Bitstring
-
-let errors = ref 0
-
-let () =
- let bs_256 = ones_bitstring 256 in
- assert (bitstring_length bs_256 = 256);
-
- let bs2 =
- BITSTRING {
- false : 1;
- (subbitstring bs_256 0 66) : 66 : bitstring
- } in
- let len = bitstring_length bs2 in
- if len <> 67 then (
- eprintf "invalid length of bs2: len = %d, expected 67\n" len;
- hexdump_bitstring stderr bs2;
- incr errors
- );
-
- let bs3 =
- BITSTRING {
- false : 1;
- (subbitstring bs_256 0 66) : 66 : bitstring;
- (subbitstring bs_256 66 67) : 67 : bitstring
- } in
- let len = bitstring_length bs3 in
- if len <> 134 then (
- eprintf "invalid length of bs3: len = %d, expected 134\n" len;
- hexdump_bitstring stderr bs3;
- incr errors
- );
-
- let bs4 =
- BITSTRING {
- (subbitstring bs_256 66 67) : 67 : bitstring
- } in
- let len = bitstring_length bs4 in
- if len <> 67 then (
- eprintf "invalid length of bs4: len = %d, expected 67\n" len;
- hexdump_bitstring stderr bs4;
- incr errors
- );
-
- let bs5 = concat [subbitstring bs_256 0 66; subbitstring bs_256 66 67] in
- let len = bitstring_length bs5 in
- if len <> 133 then (
- eprintf "invalid length of bs5: len = %d, expected 133\n" len;
- hexdump_bitstring stderr bs5;
- incr errors
- );
-
- let bs6 = concat [ subbitstring bs_256 0 64; subbitstring bs_256 64 64] in
- let len = bitstring_length bs6 in
- if len <> 128 then (
- eprintf "invalid length of bs6: len = %d, expected 128\n" len;
- hexdump_bitstring stderr bs6;
- incr errors
- );
-
- let bs7 = concat [ subbitstring bs_256 0 65; subbitstring bs_256 65 64] in
- let len = bitstring_length bs7 in
- if len <> 129 then (
- eprintf "invalid length of bs7: len = %d, expected 129\n" len;
- hexdump_bitstring stderr bs7;
- incr errors
- );
-
- if !errors <> 0 then exit 1