From 0c2ead7e1669088ac2092baa43524f1c9f9b5215 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Fri, 30 Mar 2007 17:13:02 +0000 Subject: [PATCH] * i387-fp.c (struct i387_fsave, struct i387_fxsave): Make 16-bit fields short instead of int. Add explicit padding. (i387_cache_to_fsave): Remove unnecessary casts. (i387_fsave_to_cache): Doc fix. (i387_cache_to_fxsave): Remove unnecessary casts and masking. --- gdb/gdbserver/ChangeLog | 8 ++++++++ gdb/gdbserver/i387-fp.c | 45 ++++++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 602dae0e313..d629cb3605b 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,11 @@ +2007-03-30 Daniel Jacobowitz + + * i387-fp.c (struct i387_fsave, struct i387_fxsave): Make 16-bit + fields short instead of int. Add explicit padding. + (i387_cache_to_fsave): Remove unnecessary casts. + (i387_fsave_to_cache): Doc fix. + (i387_cache_to_fxsave): Remove unnecessary casts and masking. + 2007-03-30 Daniel Jacobowitz * i387-fp.c (i387_cache_to_fxsave): Reinitialize val2 before use. diff --git a/gdb/gdbserver/i387-fp.c b/gdb/gdbserver/i387-fp.c index e0b460fc742..3abed34246e 100644 --- a/gdb/gdbserver/i387-fp.c +++ b/gdb/gdbserver/i387-fp.c @@ -32,14 +32,18 @@ int num_xmm_registers = 8; struct i387_fsave { /* All these are only sixteen bits, plus padding, except for fop (which is only eleven bits), and fooff / fioff (which are 32 bits each). */ - unsigned int fctrl; - unsigned int fstat; - unsigned int ftag; + unsigned short fctrl; + unsigned short pad1; + unsigned short fstat; + unsigned short pad2; + unsigned short ftag; + unsigned short pad3; unsigned int fioff; unsigned short fiseg; unsigned short fop; unsigned int fooff; - unsigned int foseg; + unsigned short foseg; + unsigned short pad4; /* Space for eight 80-bit FP values. */ unsigned char st_space[80]; @@ -53,13 +57,14 @@ struct i387_fxsave { unsigned short ftag; unsigned short fop; unsigned int fioff; - unsigned int fiseg; + unsigned short fiseg; + unsigned short pad1; unsigned int fooff; - unsigned int foseg; + unsigned short foseg; + unsigned short pad12; unsigned int mxcsr; - - unsigned int _pad1; + unsigned int pad3; /* Space for eight 80-bit FP values in 128-bit spaces. */ unsigned char st_space[128]; @@ -88,23 +93,23 @@ i387_cache_to_fsave (void *buf) /* Some registers are 16-bit. */ collect_register_by_name ("fctrl", &val); - *(unsigned short *) &fp->fctrl = val; + fp->fctrl = val; collect_register_by_name ("fstat", &val); val &= 0xFFFF; - *(unsigned short *) &fp->fstat = val; + fp->fstat = val; collect_register_by_name ("ftag", &val); val &= 0xFFFF; - *(unsigned short *) &fp->ftag = val; + fp->ftag = val; collect_register_by_name ("fiseg", &val); val &= 0xFFFF; - *(unsigned short *) &fp->fiseg = val; + fp->fiseg = val; collect_register_by_name ("foseg", &val); val &= 0xFFFF; - *(unsigned short *) &fp->foseg = val; + fp->foseg = val; } void @@ -137,6 +142,7 @@ i387_fsave_to_cache (const void *buf) val = fp->foseg & 0xFFFF; supply_register_by_name ("foseg", &val); + /* fop has only 11 valid bits. */ val = (fp->fop) & 0x7FF; supply_register_by_name ("fop", &val); } @@ -165,11 +171,10 @@ i387_cache_to_fxsave (void *buf) /* Some registers are 16-bit. */ collect_register_by_name ("fctrl", &val); - *(unsigned short *) &fp->fctrl = val; + fp->fctrl = val; collect_register_by_name ("fstat", &val); - val &= 0xFFFF; - *(unsigned short *) &fp->fstat = val; + fp->fstat = val; /* Convert to the simplifed tag form stored in fxsave data. */ collect_register_by_name ("ftag", &val); @@ -182,15 +187,13 @@ i387_cache_to_fxsave (void *buf) if (tag != 3) val2 |= (1 << i); } - *(unsigned short *) &fp->ftag = val2; + fp->ftag = val2; collect_register_by_name ("fiseg", &val); - val &= 0xFFFF; - *(unsigned short *) &fp->fiseg = val; + fp->fiseg = val; collect_register_by_name ("foseg", &val); - val &= 0xFFFF; - *(unsigned short *) &fp->foseg = val; + fp->foseg = val; } static int