// SCE CONFIDENTIAL
// PLAYSTATION(R)3 Programmer Tool Runtime Library 250.001
// Copyright (C) 2007 Sony Computer Entertainment Inc.
// All Rights Reserved.

#include "cellUtilSpursTask.h"
#include "cellUtilSpursTaskElf.h"
#include "cellUtilSpursTaskset.h"		// required only for implicit cast

__CELL_UTIL_SPURS_BEGIN

int Task::create(
	Task* task,
	Taskset* taskset,
	const void* elf,
	const CellSpursTaskArgument* argument,
	const CellSpursTaskSaveConfig* config)
{
	CellSpursTaskAttribute attr;
	__RETURN_IF(cellSpursTaskAttributeInitialize(&attr, elf, config, argument));
	__RETURN_IF(cellSpursTaskExitCodeInitialize(&task->m_exitCode));
	__RETURN_IF(cellSpursTaskAttributeSetExitCodeContainer(&attr, &task->m_exitCode));
	__RETURN_IF(cellSpursCreateTaskWithAttribute(taskset, &task->m_id, &attr));
	task->m_taskset = taskset;
	task->m_saveBuffer = config ? config->eaContext : 0;
	return CELL_OK;
}

int Task::create(
	Task* task,
	Taskset* taskset,
	const TaskElf& elf,
	const CellSpursTaskArgument* argument,
	const void* saveBuffer,
	unsigned saveBufferSize)
{
	CellSpursTaskSaveConfig config = {
		const_cast<void*>(saveBuffer), saveBufferSize, elf.lsPattern()
	};
	return create(task, taskset, elf.elf(), argument, &config);
}

__CELL_UTIL_SPURS_END

// Local Variables:
// mode: C++
// c-file-style: "stroustrup"
// tab-width: 4
// End:
// vim:sw=4:sts=4:ts=4
