add_far can get away with adding 16 bit offsets only. Saves ~200 bytes!

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@807 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2004-03-21 13:56:13 +00:00
parent 00ef6b1be2
commit 82261c0caf
3 changed files with 11 additions and 10 deletions

View File

@ -1804,7 +1804,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
update_pointers:
ret_cnt += xfr_cnt;
to_xfer -= xfr_cnt;
buffer = add_far((VOID FAR *) buffer, (ULONG) xfr_cnt);
buffer = add_far(buffer, xfr_cnt);
if (mode == XFR_WRITE)
{
if (fnp->f_offset > fnp->f_dir.dir_size)

View File

@ -83,22 +83,23 @@ seg far2para(VOID FAR * p)
/*
* Add a displacement to a far pointer and return the result normalized.
*/
VOID FAR * add_far(VOID FAR * fp, ULONG off)
void FAR * add_far(void FAR * fp, unsigned off)
{
UWORD off2;
unsigned segment, offset;
if (FP_SEG(fp) == 0xffff)
return ((BYTE FAR *) fp) + FP_OFF(off);
return ((char FAR *) fp) + off;
#ifndef I86
if (FP_SEG(fp) == 0)
return ((BYTE FAR *) fp) + FP_OFF(off);
return ((char FAR *) fp) + off;
#endif
off += FP_OFF(fp);
off2 = ((UWORD)(off >> 16) << 12) + ((UWORD) off >> 4);
return MK_FP(FP_SEG(fp) + off2, (UWORD) off & 0xf);
offset = off + FP_OFF(fp);
segment = FP_SEG(fp) + (offset >> 4);
if (offset < off) /* forward carry without using a long */
segment += 0x1000;
return MK_FP(segment, offset & 0xf);
}
/*

View File

@ -230,7 +230,7 @@ COUNT DosDevIOctl(lregs * r);
/* memmgr.c */
seg far2para(VOID FAR * p);
seg long2para(ULONG size);
VOID FAR *add_far(VOID FAR * fp, ULONG off);
void FAR *add_far(void FAR * fp, unsigned off);
VOID FAR *adjust_far(const void FAR * fp);
COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para,
UWORD FAR * asize);