New installation mechanism, changed byte order mechanism

This commit is contained in:
ceriel 1991-08-26 16:57:47 +00:00
parent 73177ad913
commit da188bbb4d
7 changed files with 136 additions and 79 deletions

View file

@ -1,5 +1,4 @@
Makefile
byte_order.c
proto.make
object.3
object.h
rd.c

View file

@ -3,25 +3,24 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include "byte_order.h"
#include <local.h>
#include <stdio.h>
#if ! defined(CHAR_UNSIGNED)
#define CHAR_UNSIGNED 0
#endif
#if CHAR_UNSIGNED
#define Xchar(ch) (ch)
#else
#define Xchar(ch) ((ch) & 0377)
#endif
#if ! defined(BYTES_REVERSED)
#define BYTES_REVERSED 1
#if ! defined(BYTE_ORDER)
#define BYTE_ORDER 0x3210
#endif
#if ! defined(WORDS_REVERSED)
#define WORDS_REVERSED 1
#endif
#if BYTES_REVERSED
#if (BYTE_ORDER == 0x3210 || BYTE_ORDER == 0x1032)
#define uget2(c) (Xchar((c)[0]) | ((unsigned) Xchar((c)[1]) << 8))
#define Xput2(i, c) (((c)[0] = (i)), ((c)[1] = (i) >> 8))
#define put2(i, c) { register int j = (i); Xput2(j, c); }
@ -33,7 +32,7 @@
#define get2(c) ((short) uget2(c))
#if WORDS_REVERSED || BYTES_REVERSED
#if BYTE_ORDER != 0x0123
#define get4(c) (uget2(c) | ((long) uget2((c)+2) << 16))
#define put4(l, c) { register long x=(l); \
Xput2((int)x,c); \

View file

@ -0,0 +1,90 @@
#PARAMS do not remove this line!
SRC_DIR = $(SRC_HOME)/modules/src/object
MOD_DIR = $(TARGET_HOME)/modules
INCLUDES = -I$(TARGET_HOME)/h -I$(SRC_DIR)
CFLAGS = $(INCLUDES) $(COPTIONS)
CFILES = $(SRC_DIR)/rd_arhdr.c $(SRC_DIR)/wr_arhdr.c \
$(SRC_DIR)/rd_ranlib.c $(SRC_DIR)/wr_ranlib.c \
$(SRC_DIR)/rd_bytes.c $(SRC_DIR)/wr_bytes.c \
$(SRC_DIR)/rd.c $(SRC_DIR)/wr.c \
$(SRC_DIR)/wr_putc.c \
$(SRC_DIR)/rd_int2.c $(SRC_DIR)/wr_int2.c \
$(SRC_DIR)/rd_unsig2.c \
$(SRC_DIR)/rd_long.c $(SRC_DIR)/wr_long.c
# do not change the order in OFILES
OFILES = rd.$(SUF) rd_arhdr.$(SUF) rd_int2.$(SUF) rd_long.$(SUF) \
rd_ranlib.$(SUF) rd_unsig2.$(SUF) rd_bytes.$(SUF) \
wr_arhdr.$(SUF) wr_int2.$(SUF) wr_long.$(SUF) wr_putc.$(SUF) \
wr.$(SUF) wr_ranlib.$(SUF) wr_bytes.$(SUF)
all: libobject.$(LIBSUF)
install: all lintlib
cp libobject.$(LIBSUF) $(MOD_DIR)/lib/libobject.$(LIBSUF)
$(RANLIB) $(MOD_DIR)/lib/libobject.$(LIBSUF)
cp $(SRC_DIR)/object.3 $(MOD_DIR)/man/object.3
compare: all
-cmp libobject.$(LIBSUF) $(MOD_DIR)/lib/libobject.$(LIBSUF)
-cmp $(SRC_DIR)/object.3 $(MOD_DIR)/man/object.3
pr:
@pr $(SRC_DIR)/proto.make $(SRC_DIR)/object.h $(CFILES)
opr:
make pr | opr
clean:
rm -f *.$(SUF) *.$(LIBSUF) nohup.out Out
libobject.$(LIBSUF): $(OFILES)
rm -f libobject.$(LIBSUF)
$(AR) r libobject.$(LIBSUF) $(OFILES)
$(RANLIB) libobject.$(LIBSUF)
lintlib:
$(MK_LINT_LIB object $(MOD_DIR)/lib $(INCLUDES) $(CFILES)
rd_arhdr.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_arhdr.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/rd_arhdr.c
wr_arhdr.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_arhdr.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/wr_arhdr.c
rd_ranlib.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_ranlib.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/rd_ranlib.c
wr_ranlib.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_ranlib.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/wr_ranlib.c
rd.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/rd.c
wr.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/wr.c
wr_putc.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_putc.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/wr_putc.c
rd_int2.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_int2.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/rd_int2.c
wr_int2.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_int2.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/wr_int2.c
rd_unsig2.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_unsig2.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/rd_unsig2.c
rd_long.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_long.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/rd_long.c
wr_long.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_long.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/wr_long.c
rd_bytes.$(SUF): $(SRC_DIR)/rd_bytes.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/rd_bytes.c
wr_bytes.$(SUF): $(SRC_DIR)/wr_bytes.c
$(CC) -c $(CFLAGS) $(SRC_DIR)/wr_bytes.c

View file

@ -108,7 +108,7 @@ rd_ohead(head)
register long off;
OUTREAD(PARTEMIT, (char *) head, (long) SZ_HEAD);
#if ! (BYTES_REVERSED || WORDS_REVERSED)
#if BYTE_ORDER == 0x0123
if (sizeof(struct outhead) != SZ_HEAD)
#endif
{
@ -154,22 +154,17 @@ rd_sect(sect, cnt)
offcnt += cnt;
while (cnt--) {
sect--;
#if ! (BYTES_REVERSED || WORDS_REVERSED)
#if BYTE_ORDER == 0x0123
if (sizeof(struct outsect) != SZ_SECT)
#endif
{
c -= 4; sect->os_lign = get4(c);
c -= 4; sect->os_flen = get4(c);
c -= 4; sect->os_foff = get4(c);
}
offset[--offcnt] = sect->os_foff + rd_base;
#if ! (BYTES_REVERSED || WORDS_REVERSED)
if (sizeof(struct outsect) != SZ_SECT)
#endif
{
c -= 4; sect->os_size = get4(c);
c -= 4; sect->os_base = get4(c);
}
offset[--offcnt] = sect->os_foff + rd_base;
}
}
@ -196,7 +191,7 @@ rd_relo(relo, cnt)
{
OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO);
#if ! (BYTES_REVERSED || WORDS_REVERSED)
#if BYTE_ORDER == 0x0123
if (sizeof(struct outrelo) != SZ_RELO)
#endif
{
@ -219,7 +214,7 @@ rd_name(name, cnt)
{
OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME);
#if ! (BYTES_REVERSED || WORDS_REVERSED)
#if BYTE_ORDER == 0x0123
if (sizeof(struct outname) != SZ_NAME)
#endif
{

View file

@ -11,16 +11,17 @@ rd_ranlib(fd, ran, cnt)
register long cnt;
{
rd_bytes(fd, (char *) ran, cnt * SZ_RAN);
#if ! (BYTES_REVERSED || WORDS_REVERSED)
#if BYTE_ORDER == 0x0123
if (sizeof (struct ranlib) != SZ_RAN)
#endif
{
register char *c = (char *) ran;
register char *c = (char *) ran + cnt * SZ_RAN;
ran += cnt;
while (cnt--) {
ran->ran_off = get4(c); c += 4;
ran->ran_pos = get4(c); c += 4;
ran++;
ran--;
c -= 4; ran->ran_pos = get4(c);
c -= 4; ran->ran_off = get4(c);
}
}
}

View file

@ -196,12 +196,11 @@ wr_ohead(head)
BEGINSEEK(PARTDBUG, off);
#endif
}
#if ! (BYTES_REVERSED || WORDS_REVERSED)
#if BYTE_ORDER == 0x0123
if (sizeof(struct outhead) != SZ_HEAD)
#endif
{
char buf[SZ_HEAD];
register char *c = buf;
register char *c = (char *) head;
put2(head->oh_magic, c); c += 2;
put2(head->oh_stamp, c); c += 2;
@ -211,53 +210,36 @@ wr_ohead(head)
put2(head->oh_nname, c); c += 2;
put4(head->oh_nemit, c); c += 4;
put4(head->oh_nchar, c);
OUTWRITE(PARTEMIT, buf, (long) SZ_HEAD);
}
#if ! (BYTES_REVERSED || WORDS_REVERSED)
else {
OUTWRITE(PARTEMIT, (char *)head, (long)SZ_HEAD);
}
#endif
}
wr_sect(sect, cnt1)
register struct outsect *sect;
wr_sect(s, cnt1)
struct outsect *s;
unsigned int cnt1;
{
register unsigned int cnt = cnt1;
char buf[MAXSECT * SZ_SECT];
register char *c = buf;
register struct outsect *sect = s;
register char *c = (char *) sect;
while (cnt--) {
#if ! (BYTES_REVERSED || WORDS_REVERSED)
if (offcnt >= 1 && offcnt < SECTCNT) {
BEGINSEEK(PARTEMIT+offcnt, sect->os_foff);
}
offset[offcnt++] = sect->os_foff;
#if BYTE_ORDER == 0x0123
if (sizeof(struct outsect) != SZ_SECT)
#endif
{
put4(sect->os_base, c); c += 4;
put4(sect->os_size, c); c += 4;
put4(sect->os_foff, c); c += 4;
}
if (offcnt >= 1 && offcnt < SECTCNT) {
BEGINSEEK(PARTEMIT+offcnt, sect->os_foff);
}
offset[offcnt++] = sect->os_foff;
#if ! (BYTES_REVERSED || WORDS_REVERSED)
if (sizeof(struct outsect) != SZ_SECT)
#endif
{
put4(sect->os_flen, c); c += 4;
put4(sect->os_lign, c); c += 4;
}
sect++;
}
#if ! (BYTES_REVERSED || WORDS_REVERSED)
if (sizeof(struct outsect) != SZ_SECT)
#endif
OUTWRITE(PARTEMIT, buf, (long) cnt1 * SZ_SECT);
#if ! (BYTES_REVERSED || WORDS_REVERSED)
else
OUTWRITE(PARTEMIT, (char *) (sect - cnt1), (long) cnt1 * SZ_SECT);
#endif
OUTWRITE(PARTEMIT, (char *) s, (long) cnt1 * SZ_SECT);
}
wr_outsect(s)
@ -304,7 +286,7 @@ wr_relo(relo, cnt)
unsigned int cnt;
{
#if ! (BYTES_REVERSED || WORDS_REVERSED)
#if BYTE_ORDER == 0x0123
if (sizeof(struct outrelo) != SZ_RELO)
#endif
while (cnt)
@ -329,7 +311,7 @@ wr_relo(relo, cnt)
__wr_flush(&__parts[PARTRELO]);
}
}
#if ! (BYTES_REVERSED || WORDS_REVERSED)
#if BYTE_ORDER == 0x0123
else {
OUTWRITE(PARTRELO, (char *) relo, (long) cnt * SZ_RELO);
}
@ -340,7 +322,7 @@ wr_name(name, cnt)
register struct outname *name;
unsigned int cnt;
{
#if ! (BYTES_REVERSED || WORDS_REVERSED)
#if BYTE_ORDER == 0x0123
if (sizeof(struct outname) != SZ_NAME)
#endif
while (cnt)
@ -363,7 +345,7 @@ wr_name(name, cnt)
__parts[PARTNAME].pnow = c;
if (cnt) __wr_flush(&__parts[PARTNAME]);
}
#if ! (BYTES_REVERSED || WORDS_REVERSED)
#if BYTE_ORDER == 0x0123
else {
OUTWRITE(PARTNAME, (char *) name, (long)cnt * SZ_NAME);
}

View file

@ -7,30 +7,21 @@
#include "object.h"
wr_ranlib(fd, ran, cnt)
register struct ranlib *ran;
struct ranlib *ran;
register long cnt;
{
#if ! (BYTES_REVERSED || WORDS_REVERSED)
#if BYTE_ORDER == 0x0123
if (sizeof (struct ranlib) != SZ_RAN)
#endif
{
char buf[100 * SZ_RAN];
register struct ranlib *r = ran;
register char *c = (char *) r;
while (cnt) {
register int i = (cnt > 100) ? 100 : cnt;
register char *c = buf;
long j = i * SZ_RAN;
cnt -= i;
while (i--) {
put4(ran->ran_off,c); c += 4;
put4(ran->ran_pos,c); c += 4;
ran++;
}
wr_bytes(fd, buf, j);
while (cnt--) {
put4(r->ran_off,c); c += 4;
put4(r->ran_pos,c); c += 4;
r++;
}
}
#if ! (BYTES_REVERSED || WORDS_REVERSED)
else wr_bytes(fd, (char *) ran, cnt * SZ_RAN);
#endif
wr_bytes(fd, (char *) ran, cnt * SZ_RAN);
}