1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

dtsr, DtSearch: finish removing need for BYTE_SWAP define

This commit is contained in:
Jon Trulson 2021-12-21 15:45:35 -07:00
parent 3a0c2ae879
commit 931bcaa494
8 changed files with 34 additions and 83 deletions

View file

@ -517,27 +517,23 @@ struct or_hwordrec {
* Actual host_to_network functions defined in <netinit/in.h> * Actual host_to_network functions defined in <netinit/in.h>
* which is not yet standardized. * which is not yet standardized.
*/ */
/* JET - Update 12/21/2021 - no need to define (or not) BYTE_SWAP
* anymore as we can determine that via autotools (for the code).
* Elsewhere, we can just use the systems hto*()/nto*() routines
* regardless.
*/
typedef enum {HTON=1, NTOH} SWABDIR; typedef enum {HTON=1, NTOH} SWABDIR;
extern void swab_dbrec (struct or_dbrec *rec, SWABDIR direction); extern void swab_dbrec (struct or_dbrec *rec, SWABDIR direction);
extern void swab_objrec (struct or_objrec *rec, SWABDIR direction); extern void swab_objrec (struct or_objrec *rec, SWABDIR direction);
#ifdef BYTE_SWAP /* ie (BYTE_ORDER != BIG_ENDIAN) */
#define HTONL(x) x = htonl(x) #define HTONL(x) x = htonl(x)
#define HTONS(x) x = htons(x) #define HTONS(x) x = htons(x)
#define NTOHL(x) x = ntohl(x) #define NTOHL(x) x = ntohl(x)
#define NTOHS(x) x = ntohs(x) #define NTOHS(x) x = ntohs(x)
#else /* !BYTE_SWAP, ie (BYTE_ORDER == BIG_ENDIAN) */
#define HTONL(x)
#define HTONS(x)
#define NTOHL(x)
#define NTOHS(x)
#endif /* BYTE_SWAP */
/*--------------- TESKEY PARSE CHARACTER TYPES ------------ /*--------------- TESKEY PARSE CHARACTER TYPES ------------
* Used in langmap.c for linguistic parsing modules. * Used in langmap.c for linguistic parsing modules.

View file

@ -9,34 +9,16 @@ CLEANFILES = boolyac.h boolyac.c
AM_YFLAGS = -d AM_YFLAGS = -d
libDtSearch_la_CFLAGS = -DI18N_MSG -DMULTIBYTE -I./raima \ libDtSearch_la_CFLAGS = -DI18N_MSG -DMULTIBYTE -I./raima \
@DT_INCDIR@ $(DT_INCDIR)
libDtSearch_la_LDFLAGS = -version-info 3:0:1 libDtSearch_la_LDFLAGS = -version-info 3:0:1
libDtSearch_la_LIBADD = raima/libraima.la libDtSearch_la_LIBADD = raima/libraima.la
if LINUX
libDtSearch_la_CFLAGS += -DBYTE_SWAP
libDtSearch_la_LIBADD += -lm
endif
if BSD
libDtSearch_la_CFLAGS += -DBYTE_SWAP
endif
if SOLARIS if SOLARIS
libDtSearch_la_CFLAGS += -DBYTE_SWAP
libDtSearch_la_LIBADD += -lm -lc libDtSearch_la_LIBADD += -lm -lc
endif endif
if AIX
libDtSearch_la_LIBADD += -lisode
endif
if HPUX
libDtSearch_la_LIBADD += -lm
endif
libDtSearch_la_SOURCES = apndext.c ausdopen.c ausexit.c \ libDtSearch_la_SOURCES = apndext.c ausdopen.c ausexit.c \
bmstrstr.c boolpars.c boolsrch.c \ bmstrstr.c boolpars.c boolsrch.c \
boolyac.y cuslang.c dbchange.c \ boolyac.y cuslang.c dbchange.c \

View file

@ -52,7 +52,8 @@
* *
* $Log$ * $Log$
*/ */
#include "SearchP.h" #include <autotools_config.h>
#include <Dt/SearchP.h>
/********************************/ /********************************/
/* */ /* */
@ -61,7 +62,7 @@
/********************************/ /********************************/
void swab_objrec (struct or_objrec *rec, SWABDIR direction) void swab_objrec (struct or_objrec *rec, SWABDIR direction)
{ {
#ifndef BYTE_SWAP #if defined(WORDS_BIGENDIAN)
return; return;
#else #else
if (direction == NTOH) { if (direction == NTOH) {
@ -91,7 +92,7 @@ void swab_objrec (struct or_objrec *rec, SWABDIR direction)
HTONS (rec->or_objeureka); HTONS (rec->or_objeureka);
} }
return; return;
#endif /* BYTE_SWAP */ #endif /* WORDS_BIGENDIAN */
} /* swab_objrec() */ } /* swab_objrec() */
@ -102,7 +103,7 @@ void swab_objrec (struct or_objrec *rec, SWABDIR direction)
/********************************/ /********************************/
void swab_dbrec (struct or_dbrec *rec, SWABDIR direction) void swab_dbrec (struct or_dbrec *rec, SWABDIR direction)
{ {
#ifndef BYTE_SWAP #if defined(WORDS_BIGENDIAN)
return; return;
#else #else
if (direction == NTOH) { if (direction == NTOH) {
@ -147,7 +148,7 @@ void swab_dbrec (struct or_dbrec *rec, SWABDIR direction)
HTONS (rec->or_language); HTONS (rec->or_language);
} }
return; return;
#endif /* BYTE_SWAP */ #endif /* WORDS_BIGENDIAN */
} /* swab_dbrec() */ } /* swab_dbrec() */
/********************* DTSRSWAB.C **********************************/ /********************* DTSRSWAB.C **********************************/

View file

@ -137,7 +137,7 @@ void swab_page (char *pgbuf, FILE_ENTRY *file_ptr, SWABDIR direction)
/* dba, or delete chain ptr */ /* dba, or delete chain ptr */
memcpy (&align_LONG, slotptr + sizeof(INT), sizeof(LONG)); memcpy (&align_LONG, slotptr + sizeof(INT), sizeof(LONG));
align_LONG = HTONL (align_LONG); HTONL (align_LONG);
memcpy (slotptr + sizeof(INT), &align_LONG, sizeof(LONG)); memcpy (slotptr + sizeof(INT), &align_LONG, sizeof(LONG));
/* If this is a deleted record, we're done */ /* If this is a deleted record, we're done */
@ -151,7 +151,7 @@ void swab_page (char *pgbuf, FILE_ENTRY *file_ptr, SWABDIR direction)
curr_offset < data_offset; curr_offset < data_offset;
curr_offset += sizeof(LONG)) { curr_offset += sizeof(LONG)) {
memcpy (&align_LONG, slotptr + curr_offset, sizeof(LONG)); memcpy (&align_LONG, slotptr + curr_offset, sizeof(LONG));
align_LONG = HTONL (align_LONG); HTONL (align_LONG);
memcpy (slotptr + curr_offset, &align_LONG, sizeof(LONG)); memcpy (slotptr + curr_offset, &align_LONG, sizeof(LONG));
} }
} /* end loop on each slot */ } /* end loop on each slot */
@ -183,7 +183,7 @@ void swab_page (char *pgbuf, FILE_ENTRY *file_ptr, SWABDIR direction)
/* 'orphan' ptr or 'delete chain' ptr */ /* 'orphan' ptr or 'delete chain' ptr */
memcpy (&align_LONG, pgbuf + 6, sizeof(LONG)); memcpy (&align_LONG, pgbuf + 6, sizeof(LONG));
align_LONG = HTONL (align_LONG); HTONL (align_LONG);
memcpy (pgbuf + 6, &align_LONG, sizeof(LONG)); memcpy (pgbuf + 6, &align_LONG, sizeof(LONG));
#ifdef DEBUG_DBSWAB #ifdef DEBUG_DBSWAB
@ -234,7 +234,7 @@ void swab_page (char *pgbuf, FILE_ENTRY *file_ptr, SWABDIR direction)
cptr = slotptr + slsize - 8; cptr = slotptr + slsize - 8;
memcpy (&align_LONG, cptr, sizeof(LONG)); memcpy (&align_LONG, cptr, sizeof(LONG));
align_LONG = HTONL (align_LONG); HTONL (align_LONG);
memcpy (cptr, &align_LONG, sizeof(LONG)); memcpy (cptr, &align_LONG, sizeof(LONG));
#ifdef DEBUG_DBSWAB #ifdef DEBUG_DBSWAB
@ -249,7 +249,7 @@ void swab_page (char *pgbuf, FILE_ENTRY *file_ptr, SWABDIR direction)
/* 'child ptr'. after dba, 4 bytes before end of slot. */ /* 'child ptr'. after dba, 4 bytes before end of slot. */
cptr += 4; cptr += 4;
memcpy (&align_LONG, cptr, sizeof(LONG)); memcpy (&align_LONG, cptr, sizeof(LONG));
align_LONG = HTONL (align_LONG); HTONL (align_LONG);
memcpy (cptr, &align_LONG, sizeof(LONG)); memcpy (cptr, &align_LONG, sizeof(LONG));
} /* end loop on each slot */ } /* end loop on each slot */

View file

@ -68,7 +68,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <autotools_config.h>
/* Record number for OR_MISCREC DtSearch record */ /* Record number for OR_MISCREC DtSearch record */
#define MISCREC_RECNO 3 #define MISCREC_RECNO 3
@ -81,22 +80,11 @@ typedef enum {HTON=1, NTOH} SWABDIR;
extern void swab_page (char *pgbuf, FILE_ENTRY *file_ptr, SWABDIR direction); extern void swab_page (char *pgbuf, FILE_ENTRY *file_ptr, SWABDIR direction);
#if !defined(WORDS_BIGENDIAN) /* ie (BYTE_ORDER != BIG_ENDIAN) */
#define HTONL(x) x = htonl(x) #define HTONL(x) x = htonl(x)
#define HTONS(x) x = htons(x) #define HTONS(x) x = htons(x)
#define NTOHL(x) x = ntohl(x) #define NTOHL(x) x = ntohl(x)
#define NTOHS(x) x = ntohs(x) #define NTOHS(x) x = ntohs(x)
#else /* !BYTE_SWAP, ie (BYTE_ORDER == BIG_ENDIAN) */
#define HTONL(x)
#define HTONS(x)
#define NTOHL(x)
#define NTOHS(x)
#endif /* BYTE_SWAP */
/******** debug stuff *******/ /******** debug stuff *******/
extern char *debug_keyslot_ptr; extern char *debug_keyslot_ptr;
extern void snap_dump (char *label, void *ptr, int len); extern void snap_dump (char *label, void *ptr, int len);

View file

@ -13,18 +13,6 @@ MsgCat.c: ${top_srcdir}/lib/DtSvc/DtUtil2/MsgCat.c
$(RM) MsgCat.c && ln -s ${top_srcdir}/lib/DtSvc/DtUtil2/MsgCat.c MsgCat.c $(RM) MsgCat.c && ln -s ${top_srcdir}/lib/DtSvc/DtUtil2/MsgCat.c MsgCat.c
if I386
AM_CFLAGS += -DBYTE_SWAP
endif
if X86_64
AM_CFLAGS += -DBYTE_SWAP
endif
if ARM
AM_CFLAGS += -DBYTE_SWAP
endif
LDADD = ../../lib/DtSearch/libDtSearch.la LDADD = ../../lib/DtSearch/libDtSearch.la
dtsrcreate_SOURCES = dtsrcreate.c MsgCat.c dtsrcreate_SOURCES = dtsrcreate.c MsgCat.c

View file

@ -737,10 +737,9 @@ static void copy_new_d99 (long keyfield)
* dbrec offset. * dbrec offset.
*/ */
if (validation_mode) { if (validation_mode) {
#ifdef BYTE_SWAP
for (swapx = 0; swapx < num_reads; swapx++) for (swapx = 0; swapx < num_reads; swapx++)
NTOHL (word_addrs[swapx]); NTOHL (word_addrs[swapx]);
#endif
/* set x to number of good addrs in this block */ /* set x to number of good addrs in this block */
if (good_addrs_left > num_reads) { if (good_addrs_left > num_reads) {
x = num_reads; x = num_reads;
@ -868,10 +867,9 @@ static void copy_new_d99 (long keyfield)
* dba loop for this word. * dba loop for this word.
*/ */
if (good_addrs_this_block > 0) { if (good_addrs_this_block > 0) {
#ifdef BYTE_SWAP
for (swapx = 0; swapx < good_addrs_this_block; swapx++) for (swapx = 0; swapx < good_addrs_this_block; swapx++)
NTOHL (word_addrs_out[swapx]); NTOHL (word_addrs_out[swapx]);
#endif
num_writes = fwrite (word_addrs_out, sizeof (DB_ADDR), num_writes = fwrite (word_addrs_out, sizeof (DB_ADDR),
(size_t)good_addrs_this_block, fp_d99_new); (size_t)good_addrs_this_block, fp_d99_new);
if (num_writes != good_addrs_this_block) if (num_writes != good_addrs_this_block)

View file

@ -111,7 +111,8 @@
* 2.1.5b cborodin bug. Segfault due to overflowing bitvector * 2.1.5b cborodin bug. Segfault due to overflowing bitvector
* after many deletions and no mrclean. * after many deletions and no mrclean.
*/ */
#include "SearchP.h" #include <autotools_config.h>
#include <Dt/SearchP.h>
#include <limits.h> #include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -801,13 +802,11 @@ static void put_addrs_2_dtbs_addr_file (
**** num addrs in database by 1 (!?) ******/ **** num addrs in database by 1 (!?) ******/
/* (...only if prev 'overlay/compression' didn't delete all) */ /* (...only if prev 'overlay/compression' didn't delete all) */
#ifdef BYTE_SWAP /* Put both arrays in 'network' byte order */
/* Put both arrays in 'network' byte order */ for (int32 = 0; int32 < nitems; int32++)
for (int32 = 0; int32 < nitems; int32++) HTONL (addrs_array[int32]);
HTONL (addrs_array[int32]); for (int32 = 0; int32 < num_addrs; int32++)
for (int32 = 0; int32 < num_addrs; int32++) HTONL (word_addrs_ii[int32]);
HTONL (word_addrs_ii[int32]);
#endif
/* /*
* If number of new addresses greater than number of free holes, * If number of new addresses greater than number of free holes,
@ -966,11 +965,10 @@ void write_2_dtbs_addr_file (void)
(long)got_word.or_hwoffset, (long)num_reads); (long)got_word.or_hwoffset, (long)num_reads);
DtSearchExit (98); DtSearchExit (98);
} }
#ifdef BYTE_SWAP
for (i = 0; i < num_addrs_ii; i++) for (i = 0; i < num_addrs_ii; i++)
NTOHL (word_addrs_ii[i]); NTOHL (word_addrs_ii[i]);
/* Now both addr arrays are in 'host' byte swap order */ /* Now both addr arrays are in 'host' byte swap order */
#endif
/* If there are only new docs, /* If there are only new docs,
* this switch will prevent the checking for updates. * this switch will prevent the checking for updates.
@ -1116,11 +1114,11 @@ void write_new_word_2_dtbs (void)
(long)record_addr_word[int32] & 0xffL); (long)record_addr_word[int32] & 0xffL);
} }
} }
#ifdef BYTE_SWAP
/* Put addr array in 'network' byte order */ /* Put addr array in 'network' byte order */
for (int32 = 0; int32 < num_addrs_for_word; int32++) for (int32 = 0; int32 < num_addrs_for_word; int32++)
HTONL (record_addr_word[int32]); HTONL (record_addr_word[int32]);
#endif
num_writes = fwrite (record_addr_word, sizeof(DB_ADDR), num_writes = fwrite (record_addr_word, sizeof(DB_ADDR),
(size_t)num_addrs_for_word, dtbs_addr_fp); (size_t)num_addrs_for_word, dtbs_addr_fp);
if (num_writes != num_addrs_for_word) if (num_writes != num_addrs_for_word)