summaryrefslogtreecommitdiffstats
path: root/src/H5Tbit.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-06-12 17:31:06 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-06-12 17:31:06 (GMT)
commitdd58a3ec29a061f42609669ff633c0763f834af9 (patch)
tree82c95ae74cc9730a1920862f183cd98f8371e0f5 /src/H5Tbit.c
parent674198fcc7454b962670010b0e3b120fa792f216 (diff)
downloadhdf5-dd58a3ec29a061f42609669ff633c0763f834af9.zip
hdf5-dd58a3ec29a061f42609669ff633c0763f834af9.tar.gz
hdf5-dd58a3ec29a061f42609669ff633c0763f834af9.tar.bz2
[svn-r425] Changes since 19980610
---------------------- THIS CHECKIN IS FOR QUINCEY -- NOT EVERYTHING WORKS (but it compiles) MOST OF THE CHANGES ARE FOR BETTER TYPE CONVERSION IN THE NEXT ALPHA ./MANIFEST ./src/H5Tbit.c NEW ./src/Makefile.in Bit vector operations (not done yet) ./configure.in Added -lm to the library list, needed by bit-vector operations and conversion functions. Removed vestiges of PARALLEL_SRC no longer used by the makefiles. Albert came up with a better way (that actually works :-) ./src/H5D.c No code changes. Split a couple of long lines, refilled a couple multi-line comments. ./src/H5T.c ./src/H5Tpublic.h Fixed a bug reported by Jim Reus regarding conversion of compound data types whose members require conversions which are satisfied by as-yet unregistered soft conversion functions. Added H5T_IEEE architecture, but the funny-looking integer types will be changed to H5T_BE_ and H5T_LE_ architectures with the type names changed to match the H5T_NATIVE_ integers. Added an H5Tconvert() but it hasn't been documented or tested yet. ./src/H5Tconv.c ./src/H5Tpkg.h Registered conversion functions integer->integer (a general case) and integer->float (for a specific case). The integer->integer conversion depends on the bitvector operations which aren't finished yet and the int->float conversion hasn't been retested since it was borrowed from AIO. Don't look at them yet, they're ugly :-) ./src/H5detect.c Fixed a typo which caused the msb_pad field of an atomic type to not be initialized. ./test/dtypes.c Added a test for number conversions but it's commented out until the conversion stuff is truly working.
Diffstat (limited to 'src/H5Tbit.c')
-rw-r--r--src/H5Tbit.c154
1 files changed, 154 insertions, 0 deletions
diff --git a/src/H5Tbit.c b/src/H5Tbit.c
new file mode 100644
index 0000000..0524dcc
--- /dev/null
+++ b/src/H5Tbit.c
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Wednesday, June 10, 1998
+ *
+ * Purpose: Operations on bit vectors. A bit vector is an array of bytes
+ * with the least-significant bits in the first byte. That is,
+ * the bytes are in little-endian order.
+ */
+#define H5T_PACKAGE
+#include <H5private.h>
+#include <H5Tpkg.h>
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_bit_copy
+ *
+ * Purpose: Copies bits from one vector to another.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, June 10, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+H5T_bit_copy (uint8 *dst, size_t dst_offset, const uint8 *src,
+ size_t src_offset, size_t size)
+{
+ uintn shift;
+ uintn mask_lo, mask_hi;
+ intn s_idx, d_idx;
+
+ /*
+ * Calculate shifts and masks. See diagrams below. MASK_LO in this
+ * example is 0x1f (the low five bits) and MASK_HI is 0xe0 (the high three
+ * bits). SHIFT is three since the source must be shifted right three bits
+ * to line up with the destination.
+ */
+ shift = (dst_offset%8)-(src_offset%8);
+ mask_lo = (1<<(8-shift))-1;
+ mask_hi = ((1<<shift)-1) << (8-shift);
+ s_idx = src_offset / 8;
+ d_idx = dst_offset / 8;
+
+ /*
+ * Get things rolling. This means copying bits until we're aligned on a
+ * source byte. This the following example, four bits are copied to the
+ * destination.
+ *
+ * src[s_idx]
+ * +---------------+---------------+
+ * |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
+ * +---------------+---------------+
+ * ... : : : : : | | | | |
+ * ... v v v v v V V V V V
+ * ...+---------------+---------------+
+ * ...|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
+ * ...+---------------+---------------+
+ * dst[d_idx+1] dst[d_idx]
+ */
+ if (src_offset%8 && size>0) {
+ }
+
+
+
+ /*
+ * The middle bits. We are aligned on a source byte which needs to be
+ * copied to two (or one in the degenerate case) destination bytes.
+ *
+ * src[s_idx]
+ * +---------------+
+ * |7 6 5 4 3 2 1 0|
+ * +---------------+
+ * | | | | | | | |
+ * V V V V V V V V
+ * +---------------+---------------+
+ * |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
+ * +---------------+---------------+
+ * dst[d_idx+1] dst[d_idx]
+ *
+ */
+ for (/*void*/; size>8; size-=8, d_idx++, s_idx++) {
+ if (shift) {
+ dst[d_idx+0] &= mask_lo;
+ dst[d_idx+0] |= (src[s_idx] << shift) & mask_hi;
+ dst[d_idx+1] &= mask_hi;
+ dst[d_idx+1] |= (src[s_idx] >> (8-shift)) & mask_lo;
+ } else {
+ dst[d_idx] = src[s_idx];
+ }
+ }
+
+
+
+
+ /* Finish up */
+
+
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_bit_set
+ *
+ * Purpose: Sets or clears bits in a contiguous region of a vector
+ * beginning at bit OFFSET and continuing for SIZE bits.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, June 10, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+H5T_bit_set (uint8 *buf, size_t offset, size_t size, hbool_t value)
+{
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_bit_find
+ *
+ * Purpose: Finds the first bit with the specified VALUE within a region
+ * of a bit vector. The region begins at OFFSET and continues
+ * for SIZE bits, but the region can be searched from the least
+ * significat end toward the most significant end with
+ *
+ * Return: Success: The position of the bit found, relative to
+ * the offset.
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, June 10, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+ssize_t
+H5T_bit_find (uint8 *buf, size_t offset, size_t size, H5T_sdir_t direction,
+ hbool_t value)
+{
+ return -1;
+}