made more portable

This commit is contained in:
ceriel 1988-04-21 18:53:31 +00:00
parent e0d31020c8
commit fd4bda4865
4 changed files with 16 additions and 9 deletions

View file

@ -377,6 +377,11 @@ alloc(piece, size)
return full; return full;
if (size != (ind_t)size) if (size != (ind_t)size)
return BADOFF; return BADOFF;
switch(piece) {
case ALLOMODL:
case ALLORANL:
size = int_align(size);
}
if (size - left > 0) if (size - left > 0)
incr = ((size - left + (INCRSIZE - 1)) / INCRSIZE) * INCRSIZE; incr = ((size - left + (INCRSIZE - 1)) / INCRSIZE) * INCRSIZE;

View file

@ -35,6 +35,8 @@ extern struct memory mems[];
#define address(piece,offset) (mems[(piece)].mem_base+(offset)) #define address(piece,offset) (mems[(piece)].mem_base+(offset))
#define modulptr(offset) (mems[ALLOMODL].mem_base+core_position+(offset)) #define modulptr(offset) (mems[ALLOMODL].mem_base+core_position+(offset))
#define int_align(sz) (((sz)+(sizeof(int)-1))&~(sizeof(int)-1))
extern ind_t core_position; extern ind_t core_position;
extern ind_t hard_alloc(); extern ind_t hard_alloc();
extern ind_t alloc(); extern ind_t alloc();

View file

@ -26,9 +26,9 @@ savemagic()
if (!incore) if (!incore)
return; return;
if ((p = core_alloc(ALLOMODL, (long)sizeof(ushort))) != (char *)0) { if ((p = core_alloc(ALLOMODL, (long)sizeof(int))) != (char *)0) {
*(ushort *)p = AALMAG; *(ushort *)p = AALMAG;
core_position += sizeof(ushort); core_position += sizeof(int);
} }
} }
@ -42,7 +42,7 @@ savehdr(hdr)
if ((p=core_alloc(ALLOMODL,(long)sizeof(struct ar_hdr)))!=(char *)0) { if ((p=core_alloc(ALLOMODL,(long)sizeof(struct ar_hdr)))!=(char *)0) {
*(struct ar_hdr *)p = *hdr; *(struct ar_hdr *)p = *hdr;
core_position += sizeof(struct ar_hdr); core_position += int_align(sizeof(struct ar_hdr));
} }
} }

View file

@ -104,8 +104,8 @@ getfile(filename)
if (strcmp(archive_header.ar_name, SYMDEF)) if (strcmp(archive_header.ar_name, SYMDEF))
fatal("no table of contents"); fatal("no table of contents");
} else if (incore) { } else if (incore) {
modulbase += sizeof(ushort); modulbase += sizeof(int);
core_position += sizeof(ushort); core_position += sizeof(int);
} }
return ARCHIVE; return ARCHIVE;
default: default:
@ -130,8 +130,8 @@ get_archive_header(archive_header)
} else { } else {
/* Copy structs. */ /* Copy structs. */
*archive_header = *(struct ar_hdr *)modulbase; *archive_header = *(struct ar_hdr *)modulbase;
modulbase += sizeof(struct ar_hdr); modulbase += int_align(sizeof(struct ar_hdr));
core_position += sizeof(struct ar_hdr); core_position += int_align(sizeof(struct ar_hdr));
} }
#ifdef SYMDBUG #ifdef SYMDBUG
objectsize = archive_header.ar_size; objectsize = archive_header.ar_size;
@ -408,9 +408,9 @@ skip_modul(head)
register ind_t skip = modulsize(head); register ind_t skip = modulsize(head);
if (incore) { if (incore) {
core_position += skip; core_position += int_align(skip);
if (passnumber == SECOND) if (passnumber == SECOND)
modulbase += skip; modulbase += int_align(skip);
} else { } else {
dealloc(ALLOMODL); dealloc(ALLOMODL);
core_position = (ind_t)0; core_position = (ind_t)0;