packspu_context.c revision 964454da2586d3b66e1a88fcff758664abb415b9
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "packspu.h"
#include "cr_mem.h"
#include "cr_packfunctions.h"
#include "cr_string.h"
#include "packspu_proto.h"
#define MAGIC_OFFSET 3000
/*
* Allocate a new ThreadInfo structure, setup a connection to the
* the calling thread with crSetTSD().
* We'll always call this function at least once even if we're not
* using threads.
*/
{
int i;
#ifdef CHROMIUM_THREADSAFE
#else
#endif
for (i=0; i<MAX_THREADS; ++i)
{
{
break;
}
}
/* connect to the server */
if (pack_spu.numThreads == 0) {
return NULL;
}
}
else {
/* a new pthread */
}
/* packer setup */
#ifdef CHROMIUM_THREADSAFE
#endif
#ifdef CHROMIUM_THREADSAFE
#endif
return thread;
}
{
int writeback = 1;
int slot;
#ifdef CHROMIUM_THREADSAFE
#endif
if (!thread) {
}
if (shareCtx > 0) {
/* translate to server ctx id */
shareCtx -= MAGIC_OFFSET;
}
}
/* Pack the command */
else
/* Flush buffer and get return value */
{
/* HUMUNGOUS HACK TO MATCH SERVER NUMBERING
*
* The hack exists solely to make file networking work for now. This
* is totally gross, but since the server expects the numbers to start
* from 5000, we need to write them out this way. This would be
* marginally less gross if the numbers (500 and 5000) were maybe
* some sort of #define'd constants somewhere so the client and the
* server could be aware of how each other were numbering things in
* cases like file networking where they actually
* care.
*
* -Humper
*
*/
serverCtx = 5000;
}
else {
while (writeback)
crNetRecv();
}
if (serverCtx < 0) {
#ifdef CHROMIUM_THREADSAFE
#endif
crWarning("Failure in packspu_CreateContext");
return -1; /* failed */
}
}
/* find an empty context slot */
/* found empty slot */
break;
}
}
}
/* Fill in the new context info */
/* XXX fix-up sharedCtx param here */
#ifdef CHROMIUM_THREADSAFE
#endif
return MAGIC_OFFSET + slot;
}
{
else
}
}
{
if (!thread) {
}
if (ctx) {
if (newCtx->fAutoFlush)
{
{
/* do a flush for the previusly assigned thread
* to ensure all commands issued there are submitted */
if (newCtx->currentThread
{
}
}
}
//crStateSetCurrentPointers(newCtx->clientState, &thread->packer->current);
}
else {
serverCtx = 0;
}
else
{
GET_THREAD(t);
(void) t;
CRASSERT(t);
}
}