+Tue Sep 19 15:28:58 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * gdbtypes.c (create_set_type): Set TYPE_LENGTH in bytes, not bits.
+ * valops.c (value_bitstring): TYPE_LENGTH is bytes, not bits.
+
+ * gdbtypes.c (force_to_range_type): Calculate upper limit of
+ TYPE_CODE_CHAR depending on TYPE_LENGTH (instead of just using 255).
+
Mon Sep 18 01:43:42 1995 Jeff Law (law@snake.cs.utah.edu)
* somsolib.c (auto_solib_add_at_startup): Delete definition. No
}
case TYPE_CODE_CHAR:
{
- struct type *range_type = create_range_type (NULL, type, 0, 255);
+ int char_max = 1 << (TYPE_LENGTH (type) * HOST_CHAR_BIT) - 1;
+ struct type *range_type = create_range_type (NULL, type, 0, char_max);
TYPE_NAME (range_type) = TYPE_NAME (range_type);
TYPE_DUMMY_RANGE (range_type) = 1;
return range_type;
high_bound = TYPE_HIGH_BOUND (domain_type);
bit_length = high_bound - low_bound + 1;
TYPE_LENGTH (result_type)
- = ((bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT)
- * TARGET_CHAR_BIT;
+ = (bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
}
TYPE_FIELD_TYPE (result_type, 0) = domain_type;
return (result_type);
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "symtab.h"
error ("Left operand of assignment is not an lvalue.");
}
+ /* If the field does not entirely fill a LONGEST, then zero the sign bits.
+ If the field is signed, and is negative, then sign extend. */
+ if ((VALUE_BITSIZE (toval) > 0)
+ && (VALUE_BITSIZE (toval) < 8 * sizeof (LONGEST)))
+ {
+ LONGEST fieldval = value_as_long (fromval);
+ LONGEST valmask = (((unsigned LONGEST) 1) << VALUE_BITSIZE (toval)) - 1;
+
+ fieldval &= valmask;
+ if (!TYPE_UNSIGNED (type) && (fieldval & (valmask ^ (valmask >> 1))))
+ fieldval |= ~valmask;
+
+ fromval = value_from_longest (type, fieldval);
+ }
+
/* Return a value just like TOVAL except with the contents of FROMVAL
(except in the case of the type if TOVAL is an internalvar). */
type = VALUE_TYPE (fromval);
}
- val = allocate_value (type);
- memcpy (val, toval, VALUE_CONTENTS_RAW (val) - (char *) val);
+ val = value_copy (toval);
memcpy (VALUE_CONTENTS_RAW (val), VALUE_CONTENTS (fromval),
TYPE_LENGTH (type));
VALUE_TYPE (val) = type;
struct type *type = create_set_type ((struct type*) NULL, domain_type);
TYPE_CODE (type) = TYPE_CODE_BITSTRING;
val = allocate_value (type);
- memcpy (VALUE_CONTENTS_RAW (val), ptr, TYPE_LENGTH (type) / TARGET_CHAR_BIT);
+ memcpy (VALUE_CONTENTS_RAW (val), ptr, TYPE_LENGTH (type));
return val;
}
\f