source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: This is a little gross: Linux and Apple need lots some cajoling
@ 2011-12-02  0:21 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-12-02  0:21 UTC (permalink / raw)
  To: source

Log Message:
-----------
This is a little gross: Linux and Apple need lots some cajoling to work
with byte-swapping.  Tested on Mac.  Any Linux machines somebody can
test on?  Anybody?

While here, note the correct byte-size in mandocdb(8) and also note
field widths and endianness.  The btree is now endian-neutral.

Modified Files:
--------------
    mdocml:
        apropos_db.c
        config.h.post
        mandocdb.8
        mandocdb.c

Revision Data
-------------
Index: mandocdb.8
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.8,v
retrieving revision 1.10
retrieving revision 1.11
diff -Lmandocdb.8 -Lmandocdb.8 -u -p -r1.10 -r1.11
--- mandocdb.8
+++ mandocdb.8
@@ -137,11 +137,11 @@ The keyword database,
 is a
 .Xr btree 3
 database of NUL-terminated keywords (record length is non-zero string
-length plus one) mapping to a 8-byte binary field consisting of the
-keyword type and source
+length plus one) mapping to a 12-byte binary field consisting of the
+64-bit keyword type and 32-bit source
 .Sx Index Database
-record number.
-The type, a 64-bit bit-mask in host order, consists of the following
+record number, both in network-byte order.
+The typet bit-mask consists of the following
 values mapping into
 .Xr mdoc 7
 macro identifiers:
Index: apropos_db.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/apropos_db.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -Lapropos_db.c -Lapropos_db.c -u -p -r1.18 -r1.19
--- apropos_db.c
+++ apropos_db.c
@@ -15,6 +15,10 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <assert.h>
 #include <fcntl.h>
 #include <regex.h>
@@ -24,8 +28,12 @@
 #include <string.h>
 #include <unistd.h>
 
-#ifdef __linux__
+#if defined(__linux__)
+# include <endian.h>
 # include <db_185.h>
+#elif defined(__APPLE__)
+# include <libkern/OSByteOrder.h>
+# include <db.h>
 #else
 # include <db.h>
 #endif
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.20 -r1.21
--- mandocdb.c
+++ mandocdb.c
@@ -33,8 +33,12 @@
 #include <string.h>
 #include <unistd.h>
 
-#ifdef __linux__
+#if defined(__linux__)
+# include <endian.h>
 # include <db_185.h>
+#elif defined(__APPLE__)
+# include <libkern/OSByteOrder.h>
+# include <db.h>
 #else
 # include <db.h>
 #endif
Index: config.h.post
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/config.h.post,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lconfig.h.post -Lconfig.h.post -u -p -r1.2 -r1.3
--- config.h.post
+++ config.h.post
@@ -15,6 +15,16 @@
 #  endif
 #endif
 
+#if defined(__APPLE__)
+# define htobe32(x) OSSwapHostToBigInt32(x)
+# define betoh32(x) OSSwapBigToHostInt32(x)
+# define htobe64(x) OSSwapHostToBigInt64(x)
+# define betoh64(x) OSSwapBigToHostInt64(x)
+#elif defined(__linux__)
+# define betoh32(x) be32toh(x)
+# define betoh64(x) be64toh(x)
+#endif
+
 #ifndef HAVE_STRLCAT
 extern	size_t	  strlcat(char *, const char *, size_t);
 #endif
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-12-02  0:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-02  0:21 mdocml: This is a little gross: Linux and Apple need lots some cajoling kristaps

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).