static enum return_value_convention m68k_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { enum type_code code = TYPE_CODE (type); /* GCC returns a `long double' in memory too. */ if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION) && !m68k_reg_struct_return_p (gdbarch, type)) || (code == TYPE_CODE_FLT && TYPE_LENGTH (type) == 12)) { /* The default on m68k is to return structures in static memory. Consequently a function must return the address where we can find the return value. */ if (readbuf) { ULONGEST addr; regcache_raw_read_unsigned (regcache, M68K_D0_REGNUM, &addr); read_memory (addr, readbuf, TYPE_LENGTH (type)); } return RETURN_VALUE_ABI_RETURNS_ADDRESS; } if (readbuf) m68k_extract_return_value (type, regcache, readbuf); if (writebuf) m68k_store_return_value (type, regcache, writebuf); return RETURN_VALUE_REGISTER_CONVENTION; }
static void m68k_svr4_store_return_value (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { int len = TYPE_LENGTH (type); if (TYPE_CODE (type) == TYPE_CODE_FLT) { gdb_byte buf[M68K_MAX_REGISTER_SIZE]; convert_typed_floating (valbuf, type, buf, builtin_type_m68881_ext); regcache_raw_write (regcache, M68K_FP0_REGNUM, buf); } else if (TYPE_CODE (type) == TYPE_CODE_PTR && len == 4) { regcache_raw_write (regcache, M68K_A0_REGNUM, valbuf); regcache_raw_write (regcache, M68K_D0_REGNUM, valbuf); } else m68k_store_return_value (type, regcache, valbuf); }
static void m68k_svr4_store_return_value (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { struct gdbarch *gdbarch = get_regcache_arch (regcache); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (tdep->float_return && TYPE_CODE (type) == TYPE_CODE_FLT) { struct type *fpreg_type = register_type (gdbarch, M68K_FP0_REGNUM); gdb_byte buf[M68K_MAX_REGISTER_SIZE]; convert_typed_floating (valbuf, type, buf, fpreg_type); regcache_raw_write (regcache, M68K_FP0_REGNUM, buf); } else if (TYPE_CODE (type) == TYPE_CODE_PTR && TYPE_LENGTH (type) == 4) { regcache_raw_write (regcache, M68K_A0_REGNUM, valbuf); regcache_raw_write (regcache, M68K_D0_REGNUM, valbuf); } else m68k_store_return_value (type, regcache, valbuf); }