change td_retval into a union w/ off_t, with defines to mask the

change...  This eliminates a cast, and also forces td_retval
(often 2 32-bit registers) to be aligned so that off_t's can be
stored there on arches with strict alignment requirements like
armeb (AVILA)...  On i386, this doesn't change alignment, and on
amd64 it doesn't either, as register_t is already 64bits...

This will also prevent future breakage due to people adding additional
fields to the struct...

This gets AVILA booting a bit farther...

Reviewed by:	bde
This commit is contained in:
John-Mark Gurney 2014-03-16 00:53:40 +00:00
parent 0775fbb475
commit 6f2b769cac
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=263214
4 changed files with 8 additions and 4 deletions

View File

@ -1504,7 +1504,7 @@ freebsd32_lseek(struct thread *td, struct freebsd32_lseek_args *uap)
ap.whence = uap->whence;
error = sys_lseek(td, &ap);
/* Expand the quad return into two parts for eax and edx */
pos = *(off_t *)(td->td_retval);
pos = td->td_uretoff.tdu_off;
td->td_retval[RETVAL_LO] = pos & 0xffffffff; /* %eax */
td->td_retval[RETVAL_HI] = pos >> 32; /* %edx */
return error;

View File

@ -270,7 +270,7 @@ shm_seek(struct file *fp, off_t offset, int whence, struct thread *td)
if (offset < 0 || offset > shmfd->shm_size)
error = EINVAL;
else
*(off_t *)(td->td_retval) = offset;
td->td_uretoff.tdu_off = offset;
}
foffset_unlock(fp, offset, error != 0 ? FOF_NOUPDATE : 0);
return (error);

View File

@ -2080,7 +2080,7 @@ vn_seek(struct file *fp, off_t offset, int whence, struct thread *td)
if (error != 0)
goto drop;
VFS_KNOTE_UNLOCKED(vp, 0);
*(off_t *)(td->td_retval) = offset;
td->td_uretoff.tdu_off = offset;
drop:
foffset_unlock(fp, offset, error != 0 ? FOF_NOUPDATE : 0);
return (error);

View File

@ -300,7 +300,11 @@ struct thread {
TDS_RUNQ,
TDS_RUNNING
} td_state; /* (t) thread state */
register_t td_retval[2]; /* (k) Syscall aux returns. */
union {
register_t tdu_retval[2];
off_t tdu_off;
} td_uretoff; /* (k) Syscall aux returns. */
#define td_retval td_uretoff.tdu_retval
struct callout td_slpcallout; /* (h) Callout for sleep. */
struct trapframe *td_frame; /* (k) */
struct vm_object *td_kstack_obj;/* (a) Kstack object. */