/* DLIFE Copyright (C) 2000 Richard W.M. Jones * and other authors listed in the ``AUTHORS'' file. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id: soup.h,v 1.1 2002/04/05 14:40:28 rich Exp $ */ #ifndef soup_h #define soup_h #include "config.h" #include "types.h" #include "state.h" #include "crc.h" /* How far away can a daughter be from its mother? */ #define MAX_SPAWN_DISTANCE 8192 struct soup_frag { addr_t base; /* Base address of this fragment. */ int len; /* Length of this fragment. */ /* These are kept on a circular doubly-linked list. */ struct soup_frag *next, *prev; }; extern inline addr_t raddr_to_addr (const struct state *state, const struct soup_frag *frag, reg_t raddr) { return (frag->base + raddr) & (state->soup_size - 1); } extern inline int get_soup (const struct state *state, const struct soup_frag *frag, reg_t raddr) { addr_t addr = raddr_to_addr (state, frag, raddr); return state->soup[addr]; } extern inline void set_soup (struct state *state, const struct soup_frag *frag, int v, reg_t raddr) { addr_t addr = raddr_to_addr (state, frag, raddr); state->soup[addr] = v; } extern void soup_init (struct state *state, int _soup_size); extern struct soup_frag *soup_frag_malloc (struct state *state, struct soup_frag *, reg_t); extern void soup_frag_free (struct state *state, struct soup_frag *); extern void soup_state_save (struct state *state, FILE *fp); extern void soup_state_load (struct state *state, FILE *fp); extern void soup_check (struct state *state); extern crc_t soup_frag_compute_crc32 (const struct state *state, const struct soup_frag *frag); #endif /* soup_h */