Example #1
0
static void copy_spc_data(unsigned char **buffer, void (*copy_func)(unsigned char **, void *, size_t))
{
  //SPC stuff, DSP stuff
  copy_func(buffer, SPCRAM, PHspcsave);
  copy_func(buffer, &BRRBuffer, PHdspsave);
  copy_func(buffer, &DSPMem, sizeof(DSPMem));
}
Example #2
0
static void copy_snes_data(unsigned char **buffer, void (*copy_func)(unsigned char **, void *, size_t))
{
  //65816 status, etc.
  copy_func(buffer, &curcyc, PH65816regsize);
  //SPC Timers
  copy_func(buffer, &cycpbl, 2*4);
  //SNES PPU Register status
  copy_func(buffer, &sndrot, 3019);
}
Example #3
0
_STACK *sk_deep_copy(_STACK *sk, void *(*copy_func) (void *),
                     void (*freefunc) (void *))
{
    _STACK *ret;
    int i;

    if ((ret = OPENSSL_malloc(sizeof(_STACK))) == NULL)
        return ret;
    ret->comp = sk->comp;
    ret->sorted = sk->sorted;
    ret->num = sk->num;
    ret->num_alloc = sk->num > MIN_NODES ? sk->num : MIN_NODES;
    ret->data = OPENSSL_malloc(sizeof(char *) * ret->num_alloc);
    if (ret->data == NULL) {
        OPENSSL_free(ret);
        return NULL;
    }
    for (i = 0; i < ret->num_alloc; i++)
        ret->data[i] = NULL;

    for (i = 0; i < ret->num; ++i) {
        if (sk->data[i] == NULL)
            continue;
        if ((ret->data[i] = copy_func(sk->data[i])) == NULL) {
            while (--i >= 0)
                if (ret->data[i] != NULL)
                    freefunc(ret->data[i]);
            sk_free(ret);
            return NULL;
        }
    }
    return ret;
}
Example #4
0
guint64
prop_copy_uint16 (guint16 prop, guint8 ** buffer, guint64 * size,
    guint64 * offset)
{
  prop = GUINT16_TO_BE (prop);
  return copy_func (&prop, sizeof (guint16), buffer, size, offset);
}
Example #5
0
File: gnode.c Project: UIKit0/atv2
/**
 * g_node_copy_deep:
 * @node: a #GNode
 * @copy_func: the function which is called to copy the data inside each node,
 *   or %NULL to use the original data.
 * @data: data to pass to @copy_func
 * 
 * Recursively copies a #GNode and its data.
 * 
 * Return value: a new #GNode containing copies of the data in @node.
 *
 * Since: 2.4
 **/
GNode*
g_node_copy_deep (GNode     *node, 
		  GCopyFunc  copy_func,
		  gpointer   data)
{
  GNode *new_node = NULL;

  if (copy_func == NULL)
	return g_node_copy (node);

  if (node)
    {
      GNode *child, *new_child;
      
      new_node = g_node_new (copy_func (node->data, data));
      
      for (child = g_node_last_child (node); child; child = child->prev) 
	{
	  new_child = g_node_copy_deep (child, copy_func, data);
	  g_node_prepend (new_node, new_child);
	}
    }
  
  return new_node;
}
Example #6
0
void sgen_client_clear_togglerefs (char *start, char *end, ScanCopyContext ctx)
{
	CopyOrMarkObjectFunc copy_func = ctx.ops->copy_or_mark_object;
	SgenGrayQueue *queue = ctx.queue;
	int i;

	SGEN_LOG (4, "Clearing ToggleRefs %d", toggleref_array_size);

	for (i = 0; i < toggleref_array_size; ++i) {
		if (toggleref_array [i].weak_ref) {
			GCObject *object = toggleref_array [i].weak_ref;

			if ((char*)object >= start && (char*)object < end) {
				if (sgen_gc_is_object_ready_for_finalization (object)) {
					SGEN_LOG (6, "\tcleaning weak slot %d", i);
					toggleref_array [i].weak_ref = NULL; /* We defer compaction to only happen on the callback step. */
				} else {
					SGEN_LOG (6, "\tkeeping weak slot %d", i);
					copy_func (&toggleref_array [i].weak_ref, queue);
				}
			}
		}
	}
	sgen_drain_gray_stack (ctx);
}
Example #7
0
/* FOURCC */
guint64
prop_copy_fourcc (guint32 prop, guint8 ** buffer, guint64 * size,
    guint64 * offset)
{
  prop = GINT32_TO_LE (prop);
  return copy_func (&prop, sizeof (guint32), buffer, size, offset);
}
Example #8
0
_STACK *sk_deep_copy(const _STACK *sk, void *(*copy_func)(void *),
                     void (*free_func)(void *)) {
  _STACK *ret = sk_dup(sk);
  if (ret == NULL) {
    return NULL;
  }

  for (size_t i = 0; i < ret->num; i++) {
    if (ret->data[i] == NULL) {
      continue;
    }
    ret->data[i] = copy_func(ret->data[i]);
    if (ret->data[i] == NULL) {
      for (size_t j = 0; j < i; j++) {
        if (ret->data[j] != NULL) {
          free_func(ret->data[j]);
        }
      }
      sk_free(ret);
      return NULL;
    }
  }

  return ret;
}
Example #9
0
/*
 * Post 1.0.1 sk function "deep_copy".  For the moment we simply make
 * these take void * and use them directly without a glorious blob of
 * obfuscating macros of dubious value in front of them. All this in
 * preparation for a rototilling of safestack.h (likely inspired by
 * this).
 */
static void *
sk_deep_copy(void *sk_void, void *copy_func_void, void *free_func_void)
{
	_STACK *sk = sk_void;
	void *(*copy_func)(void *) = copy_func_void;
	void (*free_func)(void *) = free_func_void;
	_STACK *ret = sk_dup(sk);
	size_t i;

	if (ret == NULL)
		return NULL;

	for (i = 0; i < ret->num; i++) {
		if (ret->data[i] == NULL)
			continue;
		ret->data[i] = copy_func(ret->data[i]);
		if (ret->data[i] == NULL) {
			size_t j;
			for (j = 0; j < i; j++) {
				if (ret->data[j] != NULL)
					free_func(ret->data[j]);
			}
			sk_free(ret);
			return NULL;
		}
	}

	return ret;
}
Example #10
0
static uint32_t load_image(uint32_t block_start, uint32_t* load_address,uint16_t num_of_blocks){
	copy_mmc_to_mem copy_func = (copy_mmc_to_mem) (*(uint32_t *) 0xD0037F98); //SdMccCopyToMem function from iROM documentation
	uint32_t ret = copy_func(0,block_start, num_of_blocks,load_address, 0);
	if(ret == 0){
		debug_print("Copying failed :-(\n\r\0");
	}
	return ret;
}
Example #11
0
/** copy_list
  *
  * Create a new list structure, new nodes, and new copies of the data by using
  * the copy function. Its implementation for any test structure must copy
  * EVERYTHING!
  *
  * @param llist A pointer to the linked list to make a copy of
  * @param copy_func A function pointer to a function that makes a copy of the
  *        data that's being used in this linked list, allocating space for
  *        every part of that data on the heap. This is some function you must
  *        write yourself for testing, tailored specifically to whatever context
  *        you're using the linked list for in your test.
  * @return The linked list created by copying the old one
  */
list* copy_list(list* llist, list_cpy copy_func)
{
    list* copy_list_p = create_list();
    node* current = llist->head;
    while (current != NULL) {
	push_back(copy_list_p, copy_func(current->data));
	current = current->next;
    }
    return copy_list_p;
}
Example #12
0
/* LOCKING: requires that the GC lock is held */
void
sgen_collect_bridge_objects (int generation, ScanCopyContext ctx)
{
    CopyOrMarkObjectFunc copy_func = ctx.copy_func;
    GrayQueue *queue = ctx.queue;
    SgenHashTable *hash_table = get_finalize_entry_hash_table (generation);
    MonoObject *object;
    gpointer dummy;
    char *copy;

    if (no_finalize)
        return;

    SGEN_HASH_TABLE_FOREACH (hash_table, object, dummy) {
        int tag = tagged_object_get_tag (object);
        object = tagged_object_get_object (object);

        /* Bridge code told us to ignore this one */
        if (tag == BRIDGE_OBJECT_MARKED)
            continue;

        /* Object is a bridge object and major heap says it's dead  */
        if (major_collector.is_object_live ((char*)object))
            continue;

        /* Nursery says the object is dead. */
        if (!sgen_gc_is_object_ready_for_finalization (object))
            continue;

        if (!sgen_is_bridge_object (object))
            continue;

        copy = (char*)object;
        copy_func ((void**)&copy, queue);

        sgen_bridge_register_finalized_object ((MonoObject*)copy);

        if (hash_table == &minor_finalizable_hash && !ptr_in_nursery (copy)) {
            /* remove from the list */
            SGEN_HASH_TABLE_FOREACH_REMOVE (TRUE);

            /* insert it into the major hash */
            sgen_hash_table_replace (&major_finalizable_hash, tagged_object_apply (copy, tag), NULL, NULL);

            SGEN_LOG (5, "Promoting finalization of object %p (%s) (was at %p) to major table", copy, sgen_safe_name (copy), object);

            continue;
        } else {
            /* update pointer */
            SGEN_LOG (5, "Updating object for finalization: %p (%s) (was at %p)", copy, sgen_safe_name (copy), object);
            SGEN_HASH_TABLE_FOREACH_SET_KEY (tagged_object_apply (copy, tag));
        }
    }
Example #13
0
/** copy_list
  *
  * Create a new list structure, new nodes, and new copies of the data by using
  * the copy function. Its implementation for any test structure must copy
  * EVERYTHING!
  *
  * @param llist A pointer to the linked list to make a copy of
  * @param copy_func A function pointer to a function that makes a copy of the
  *        data that's being used in this linked list, allocating space for
  *        every part of that data on the heap. This is some function you must
  *        write yourself for testing, tailored specifically to whatever context
  *        you're using the linked list for in your test.
  * @return The linked list created by copying the old one
  */
list* copy_list(list* llist, list_cpy copy_func)
{
	list* newList = create_list();
  // iterate through the old list
  node *current = llist->head;
  while (current != NULL) {
    // put the copied element at the end of the new list 
    // so that it is in the original order
    push_back(newList, copy_func(current->data)); 
    current = current->next;
  }
	return newList;
}
Example #14
0
pa_idxset *pa_idxset_copy(pa_idxset *s, pa_copy_func_t copy_func) {
    pa_idxset *copy;
    struct idxset_entry *i;

    pa_assert(s);

    copy = pa_idxset_new(s->hash_func, s->compare_func);

    for (i = s->iterate_list_head; i; i = i->iterate_next)
        pa_idxset_put(copy, copy_func ? copy_func(i->data) : i->data, NULL);

    return copy;
}
Example #15
0
node_t* node_copy_deep(node_t* node, copy_func_t copy_func)
{
	if (!node) return NULL;
	void *data = NULL;
	if (copy_func) {
		data = copy_func(node->data);
	}
	node_t* copy = node_create(NULL, data);
	node_t* ch;
	for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
		node_t* cc = node_copy_deep(ch, copy_func);
		node_attach(copy, cc);
	}
	return copy;
}
Example #16
0
void copy_bl2_to_sram(void){
	uint32_t *load_address =(uint32_t*) (0xD0020FB0);  // SRAM BL1 start address + 16k (binary kilo)
	debug_print("Copying BL2 started ...\n");
	void (*BL2)(void);
	uint32_t channel = 0;
	copy_mmc_to_mem copy_func = (copy_mmc_to_mem) (*(uint32_t *) 0xD0037F98); //SdMccCopyToMem function from iROM documentation
	uint32_t ret = copy_func(channel, 33, COPY_BL2_SIZE/512,load_address, 0);
	if(ret == 1){
		debug_print("BL2 loading successful, running it ...\n");
		BL2 = (void*) load_address;
		(*BL2)(); // dereferencing and running ...
	}else{
		debug_print("BL2 loading failed :-(\n");
	}
}
static void
gdk_pixbuf_copy_area_intact (GdkPixbuf *src,
                             int        src_x,
                             int        src_y,
                             int        width,
                             int        height,
                             GdkPixbuf *dst,
                             int        dst_x,
                             int        dst_y)
{
    if (src_x == dst_x && src_y == dst_y && src == dst)
        return;
    
    int src_stride = gdk_pixbuf_get_rowstride (src);
    int dst_stride = gdk_pixbuf_get_rowstride (dst);
    int chans = gdk_pixbuf_get_n_channels (src);

    int linelen = width * chans;

    guchar *src_base = gdk_pixbuf_get_pixels (src);
    guchar *dst_base = gdk_pixbuf_get_pixels (dst);

    int src_y_ofs = src_y * src_stride;
    int dst_y_ofs = dst_y * dst_stride;
    if (dst_y > src_y)
    {
        src_y_ofs = (src_y + height - 1) * src_stride;
        dst_y_ofs = (dst_y + height - 1) * dst_stride;
        src_stride = -src_stride;
        dst_stride = -dst_stride;
    }
    guchar *src_ofs = src_base + src_y_ofs + src_x * chans;
    guchar *dst_ofs = dst_base + dst_y_ofs + dst_x * chans;

    void (*copy_func)(void *, void *, size_t) = (void *) memcpy;
    if (dst_x > src_x)
        copy_func = (void *) memmove;

    for (int y = 0; y < height; y++)
    {
        copy_func (dst_ofs, src_ofs, linelen);
        src_ofs += src_stride;
        dst_ofs += dst_stride;
    }
}
Example #18
0
void sgen_client_mark_togglerefs (char *start, char *end, ScanCopyContext ctx)
{
	CopyOrMarkObjectFunc copy_func = ctx.ops->copy_or_mark_object;
	SgenGrayQueue *queue = ctx.queue;
	int i;

	SGEN_LOG (4, "Marking ToggleRefs %d", toggleref_array_size);

	for (i = 0; i < toggleref_array_size; ++i) {
		if (toggleref_array [i].strong_ref) {
			GCObject *object = toggleref_array [i].strong_ref;
			if ((char*)object >= start && (char*)object < end) {
				SGEN_LOG (6, "\tcopying strong slot %d", i);
				copy_func (&toggleref_array [i].strong_ref, queue);
			}
		}
	}
	sgen_drain_gray_stack (ctx);
}
Example #19
0
/**
 * kr_ntree_copy_deep:
 * @node: a #T_KRNTree
 * @copy_func: the function which is called to copy the data inside each node,
 *   or %NULL to use the original data.
 * @data: data to pass to @copy_func
 * 
 * Recursively copies a #T_KRNTree and its data.
 * 
 * Return value: a new #T_KRNTree containing copies of the data in @node.
 *
 **/
T_KRNTree* 
kr_ntree_copy_deep(T_KRNTree *node, KRCopyFunc copy_func, kr_pointer data)
{
    T_KRNTree *new_node = NULL;

    if (copy_func == NULL)
        return kr_ntree_copy (node);

    if (node) {
        T_KRNTree *child, *new_child;

        new_node = kr_ntree_new (copy_func (node->data, data));

        for (child = kr_ntree_last_child (node); child; child = child->prev) {
            new_child = kr_ntree_copy_deep (child, copy_func, data);
            kr_ntree_prepend (new_node, new_child);
        }
    }

    return new_node;
}
Example #20
0
/** copy_list
  *
  * Create a new list structure, new nodes, and new copies of the data by using
  * the copy function. Its implementation for any test structure must copy
  * EVERYTHING!
  *
  * @param llist A pointer to the linked list to make a copy of
  * @param copy_func A function pointer to a function that makes a copy of the
  *        data that's being used in this linked list, allocating space for
  *        every part of that data on the heap. This is some function you must
  *        write yourself for testing, tailored specifically to whatever context
  *        you're using the linked list for in your test.
  * @return The linked list created by copying the old one
  */
list* copy_list(list* llist, list_cpy copy_func)
{
	list* copy_list = create_list();
	node* current = llist->head;
	if(llist->head == NULL){
		return copy_list;
	}
	while(current != NULL){
		push_back(copy_list,copy_func(current->data));
		current = current->next;
	}
	return copy_list;
	/*list traverse;
	if(llist->head != NULL){
		traverse->head = llist->head;
		for(int i = 0; i <= llist->size; i++){
			node* copy_node = creat_node(traverse.head->data);
			push_back(copy_list, copy_node->data);
			traverse.head = traverse.head->next;		
		}
	}*/
	/// @todo implement
}
Example #21
0
static void copy_extra_data(unsigned char **buffer, void (*copy_func)(unsigned char **, void *, size_t))
{
  copy_func(buffer, &soundcycleft, 4);
  copy_func(buffer, &curexecstate, 4);
  copy_func(buffer, &nmiprevaddrl, 4);
  copy_func(buffer, &nmiprevaddrh, 4);
  copy_func(buffer, &nmirept, 4);
  copy_func(buffer, &nmiprevline, 4);
  copy_func(buffer, &nmistatus, 4);
  copy_func(buffer, &joycontren, 4);
  copy_func(buffer, &NextLineCache, 1);
  copy_func(buffer, &spc700read, 10*4);
  copy_func(buffer, &timer2upd, 4);
  copy_func(buffer, &xa, 14*4);
  copy_func(buffer, &spcnumread, 1);
  copy_func(buffer, &opcd, 6*4);
  copy_func(buffer, &HIRQCycNext, 4);
  copy_func(buffer, &HIRQNextExe, 1);
  copy_func(buffer, &oamaddr, 14*4);
  copy_func(buffer, &prevoamptr, 1);
}
Example #22
0
int ai_merge_copy_new(const char *source, const char *dest, ai_journal_t j,
		ai_merge_progress_callback_t progress_callback) {
	const uint64_t maxpathlen = ai_journal_get_maxpathlen(j);
	const char *fn_prefix = ai_journal_get_filename_prefix(j);
	/* maxpathlen covers path + filename, + 1 for null terminator */
	const size_t oldpathlen = strlen(source) + maxpathlen + 1;
	/* + .<fn-prefix>~ + .new */
	const size_t newpathlen = strlen(dest) + maxpathlen + 7 + strlen(fn_prefix);

	char *oldpathbuf, *newpathbuf;
	ai_journal_file_t *pp;
	const char *relpath;

	int ret = 0;

	if (!ai_merge_constraint_flags(j, 0, AI_MERGE_COPIED_NEW|AI_MERGE_ROLLBACK_STARTED))
		return EINVAL;

	oldpathbuf = malloc(oldpathlen);
	if (!oldpathbuf)
		return errno;

	newpathbuf = malloc(newpathlen);
	if (!newpathbuf) {
		free(oldpathbuf);
		return errno;
	}

	relpath = oldpathbuf + strlen(source);

	for (pp = ai_journal_get_files(j); pp; pp = ai_journal_file_next(pp)) {
		const char *path = ai_journal_file_path(pp);
		const char *name = ai_journal_file_name(pp);
		const unsigned char flags = ai_journal_file_flags(pp);
		copy_func_t copy_func;

		sprintf(oldpathbuf, "%s%s%s", source, path, name);
		if (flags & AI_MERGE_FILE_DIR) {
			sprintf(newpathbuf, "%s%s%s", dest, path, name);
			copy_func = ai_cp_a;
		} else {
			sprintf(newpathbuf, "%s%s.%s~%s.new", dest, path, fn_prefix, name);
			copy_func = ai_cp_l;
		}

		if (flags & AI_MERGE_FILE_REMOVE) {
			struct stat tmp;

			/* file exists in sourcedir -> will be replaced -> ignore */
			if (!lstat(oldpathbuf, &tmp)) {
				ret = ai_journal_file_set_flag(pp, AI_MERGE_FILE_IGNORE);
				if (ret)
					break;
			}
			continue;
		}

		if (progress_callback)
			progress_callback(relpath, 0, 0);
		ret = copy_func(oldpathbuf, newpathbuf);

		if (ret == ENOENT) {
			ret = ai_mkdir_cp(oldpathbuf, newpathbuf, path, progress_callback);
			if (!ret)
				ret = copy_func(oldpathbuf, newpathbuf);
		}

		if (ret)
			break;
	}

	free(oldpathbuf);
	free(newpathbuf);

	/* Mark as done. */
	if (!ret)
		ret = ai_journal_set_flag(j, AI_MERGE_COPIED_NEW);

	return ret;
}
Example #23
0
/* LOCKING: requires that the GC lock is held */
void
sgen_collect_bridge_objects (int generation, ScanCopyContext ctx)
{
	CopyOrMarkObjectFunc copy_func = ctx.ops->copy_or_mark_object;
	GrayQueue *queue = ctx.queue;
	SgenHashTable *hash_table = get_finalize_entry_hash_table (generation);
	GCObject *object;
	gpointer dummy G_GNUC_UNUSED;
	GCObject *copy;
	SgenPointerQueue moved_fin_objects;

	sgen_pointer_queue_init (&moved_fin_objects, INTERNAL_MEM_TEMPORARY);

	if (no_finalize)
		return;

	SGEN_HASH_TABLE_FOREACH (hash_table, GCObject *, object, gpointer, dummy) {
		int tag = tagged_object_get_tag (object);
		object = tagged_object_get_object (object);

		/* Bridge code told us to ignore this one */
		if (tag == BRIDGE_OBJECT_MARKED)
			continue;

		/* Object is a bridge object and major heap says it's dead  */
		if (major_collector.is_object_live (object))
			continue;

		/* Nursery says the object is dead. */
		if (!sgen_gc_is_object_ready_for_finalization (object))
			continue;

		if (!sgen_client_bridge_is_bridge_object (object))
			continue;

		copy = object;
		copy_func (&copy, queue);

		sgen_client_bridge_register_finalized_object (copy);
		
		if (hash_table == &minor_finalizable_hash && !ptr_in_nursery (copy)) {
			/* remove from the list */
			SGEN_HASH_TABLE_FOREACH_REMOVE (TRUE);

			/* insert it into the major hash */
			sgen_hash_table_replace (&major_finalizable_hash, tagged_object_apply (copy, tag), NULL, NULL);

			SGEN_LOG (5, "Promoting finalization of object %p (%s) (was at %p) to major table", copy, sgen_client_vtable_get_name (SGEN_LOAD_VTABLE (copy)), object);

			continue;
		} else if (copy != object) {
			/* update pointer */
			SGEN_HASH_TABLE_FOREACH_REMOVE (TRUE);

			/* register for reinsertion */
			sgen_pointer_queue_add (&moved_fin_objects, tagged_object_apply (copy, tag));

			SGEN_LOG (5, "Updating object for finalization: %p (%s) (was at %p)", copy, sgen_client_vtable_get_name (SGEN_LOAD_VTABLE (copy)), object);

			continue;
		}
	} SGEN_HASH_TABLE_FOREACH_END;
Example #24
0
/**
 * prop_copy_fixed_size_string:
 * @string: the string to be copied
 * @str_size: size of the string
 * @buffer: the array to copy the string to
 * @offset: the position in the buffer array.
 * This value is updated to the point right after the copied string.
 *
 * Copies a string of bytes without placing its size at the beginning.
 *
 * Returns: the number of bytes copied
 */
guint64
prop_copy_fixed_size_string (guint8 * string, guint str_size, guint8 ** buffer,
    guint64 * size, guint64 * offset)
{
  return copy_func (string, str_size * sizeof (guint8), buffer, size, offset);
}
Example #25
0
/* INTEGERS */
guint64
prop_copy_uint8 (guint8 prop, guint8 ** buffer, guint64 * size,
    guint64 * offset)
{
  return copy_func (&prop, sizeof (guint8), buffer, size, offset);
}
Example #26
0
static mword*
handle_remset (mword *p, void *start_nursery, void *end_nursery, gboolean global, SgenGrayQueue *queue)
{
	void **ptr;
	mword count;
	mword desc;

	if (global)
		HEAVY_STAT (++stat_global_remsets_processed);
	else
		HEAVY_STAT (++stat_local_remsets_processed);

	/* FIXME: exclude stack locations */
	switch ((*p) & REMSET_TYPE_MASK) {
	case REMSET_LOCATION:
		ptr = (void**)(*p);
		//__builtin_prefetch (ptr);
		if (((void*)ptr < start_nursery || (void*)ptr >= end_nursery)) {
			gpointer old = *ptr;

			sgen_get_current_object_ops ()->copy_or_mark_object (ptr, queue);
			SGEN_LOG (9, "Overwrote remset at %p with %p", ptr, *ptr);
			if (old)
				binary_protocol_ptr_update (ptr, old, *ptr, (gpointer)SGEN_LOAD_VTABLE (*ptr), sgen_safe_object_get_size (*ptr));
			if (!global && *ptr >= start_nursery && *ptr < end_nursery) {
				/*
				 * If the object is pinned, each reference to it from nonpinned objects
				 * becomes part of the global remset, which can grow very large.
				 */
				SGEN_LOG (9, "Add to global remset because of pinning %p (%p %s)", ptr, *ptr, sgen_safe_name (*ptr));
				sgen_add_to_global_remset (ptr);
			}
		} else {
			SGEN_LOG (9, "Skipping remset at %p holding %p", ptr, *ptr);
		}
		return p + 1;
	case REMSET_RANGE: {
		CopyOrMarkObjectFunc copy_func = sgen_get_current_object_ops ()->copy_or_mark_object;

		ptr = (void**)(*p & ~REMSET_TYPE_MASK);
		if (((void*)ptr >= start_nursery && (void*)ptr < end_nursery))
			return p + 2;
		count = p [1];
		while (count-- > 0) {
			copy_func (ptr, queue);
			SGEN_LOG (9, "Overwrote remset at %p with %p (count: %d)", ptr, *ptr, (int)count);
			if (!global && *ptr >= start_nursery && *ptr < end_nursery)
				sgen_add_to_global_remset (ptr);
			++ptr;
		}
		return p + 2;
	}
	case REMSET_OBJECT:
		ptr = (void**)(*p & ~REMSET_TYPE_MASK);
		if (((void*)ptr >= start_nursery && (void*)ptr < end_nursery))
			return p + 1;
		sgen_get_current_object_ops ()->scan_object ((char*)ptr, queue);
		return p + 1;
	case REMSET_VTYPE: {
		size_t skip_size;

		ptr = (void**)(*p & ~REMSET_TYPE_MASK);
		if (((void*)ptr >= start_nursery && (void*)ptr < end_nursery))
			return p + 4;
		desc = p [1];
		count = p [2];
		skip_size = p [3];
		while (count-- > 0) {
			sgen_get_current_object_ops ()->scan_vtype ((char*)ptr, desc, queue);
			ptr = (void**)((char*)ptr + skip_size);
		}
		return p + 4;
	}
	default:
		g_assert_not_reached ();
	}
	return NULL;
}
Example #27
0
static void copy_state_data(unsigned char *buffer, void (*copy_func)(unsigned char **, void *, size_t), enum copy_state_method method)
{
  copy_snes_data(&buffer, copy_func);

  //WRAM (128k), VRAM (64k)
  copy_func(&buffer, wramdata, 8192*16);
  copy_func(&buffer, vram, 4096*16);

  if (spcon)
  {
    copy_spc_data(&buffer, copy_func);
    /*
    if (buffer) //Rewind stuff
    {
      copy_func(&buffer, &echoon0, PHdspsave2);
    }
    */
  }

  if (C4Enable)
  {
    copy_func(&buffer, C4Ram, 2048*4);
  }

  if (SFXEnable)
  {
    copy_func(&buffer, sfxramdata, 8192*16);
    copy_func(&buffer, &SfxR0, PHnum2writesfxreg);
  }

  if (SA1Enable)
  {
    copy_func(&buffer, &SA1Mode, PHnum2writesa1reg);
    copy_func(&buffer, SA1RAMArea, 8192*16);
    if (method != csm_load_zst_old)
    {
      copy_func(&buffer, &SA1Status, 3);
      copy_func(&buffer, &SA1xpc, 1*4);
      copy_func(&buffer, &sa1dmaptr, 2*4);
    }
  }

  if (DSP1Type && (method != csm_load_zst_old))
  {
    copy_func(&buffer, &DSP1COp, 70+128);
    copy_func(&buffer, &Op00Multiplicand, 3*4+128);
    copy_func(&buffer, &Op10Coefficient, 4*4+128);
    copy_func(&buffer, &Op04Angle, 4*4+128);
    copy_func(&buffer, &Op08X, 5*4+128);
    copy_func(&buffer, &Op18X, 5*4+128);
    copy_func(&buffer, &Op28X, 4*4+128);
    copy_func(&buffer, &Op0CA, 5*4+128);
    copy_func(&buffer, &Op02FX, 11*4+3*4+28*8+128);
    copy_func(&buffer, &Op0AVS, 5*4+14*8+128);
    copy_func(&buffer, &Op06X, 6*4+10*8+4+128);
    copy_func(&buffer, &Op01m, 4*4+128);
    copy_func(&buffer, &Op0DX, 6*4+128);
    copy_func(&buffer, &Op03F, 6*4+128);
    copy_func(&buffer, &Op14Zr, 9*4+128);
    copy_func(&buffer, &Op0EH, 4*4+128);
  }

  if (SETAEnable)
  {
    copy_func(&buffer, setaramdata, 256*16);

    //Todo: copy the SetaCmdEnable?  For completeness we should do it
    //but currently we ignore it anyway.
  }

  if (SPC7110Enable)
  {
    copy_func(&buffer, romdata+0x510000, 65536);
    copy_func(&buffer, &SPCMultA, PHnum2writespc7110reg);
  }

  if (method != csm_load_zst_old)
  {
    copy_extra_data(&buffer, copy_func);

    //We don't load SRAM from new states if box isn't checked
    if ((method != csm_load_zst_new) || SRAMState)
    {
      copy_func(&buffer, sram, ramsize);
    }

    if ((method == csm_save_rewind) || (method == csm_load_rewind))
    {
      copy_func(&buffer, &tempesi, 4);
      copy_func(&buffer, &tempedi, 4);
      copy_func(&buffer, &tempedx, 4);
      copy_func(&buffer, &tempebp, 4);
    }
  }
}