void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformfv(GLuint program, GLint location, GLfloat *params) { int size = __GetUniformSize(program, location) * sizeof(GLfloat); GLfloat *pLocal; pLocal = (GLfloat*) crAlloc(size); if (!pLocal) { GLsizei zero=0; crServerReturnValue(&zero, sizeof(zero)); } cr_server.head_spu->dispatch_table.GetUniformfv(crStateGetProgramHWID(program), location, pLocal); crServerReturnValue(pLocal, size); crFree(pLocal); }
DECLEXPORT(void) STATE_APIENTRY crStateBindAttribLocation(GLuint program, GLuint index, const char * name) { CRGLSLProgram *pProgram = crStateGetProgramObj(program); GLuint i; CRGLSLAttrib *pAttribs; if (!pProgram) { crWarning("Unknown program %d", program); return; } if (index>=CR_MAX_VERTEX_ATTRIBS) { crWarning("crStateBindAttribLocation: Index too big %d", index); return; } for (i=0; i<pProgram->currentState.cAttribs; ++i) { if (!crStrcmp(pProgram->currentState.pAttribs[i].name, name)) { pProgram->currentState.pAttribs[i].index = index; return; } } pAttribs = (CRGLSLAttrib*) crAlloc((pProgram->currentState.cAttribs+1)*sizeof(CRGLSLAttrib)); if (!pAttribs) { crWarning("crStateBindAttribLocation: Out of memory!"); return; } if (pProgram->currentState.cAttribs) { crMemcpy(&pAttribs[0], &pProgram->currentState.pAttribs[0], pProgram->currentState.cAttribs*sizeof(CRGLSLAttrib)); } pAttribs[pProgram->currentState.cAttribs].index = index; pAttribs[pProgram->currentState.cAttribs].name = crStrdup(name); pProgram->currentState.cAttribs++; if (pProgram->currentState.pAttribs) crFree(pProgram->currentState.pAttribs); pProgram->currentState.pAttribs = pAttribs; }
/* Semaphore wait */ void SERVER_DISPATCH_APIENTRY crServerDispatchSemaphorePCR( GLuint name ) { CRServerSemaphore *sema; if (cr_server.ignore_papi) { cr_server.head_spu->dispatch_table.SemaphorePCR( name ); return; } sema = (CRServerSemaphore *) crHashtableSearch( cr_server.semaphores, name ); if (!sema) { crError( "No such semaphore: %d", name ); } if (sema->count) { /* go */ if (cr_server.debug_barriers) crDebug("crserver: SemaphoreP(client=%p, id=%d, count=%d) decrement to %d", cr_server.curClient, name, sema->count, sema->count - 1); sema->count--; } else { /* block */ wqnode *node; if (cr_server.debug_barriers) crDebug("crserver: SemaphoreP(client=%p, id=%d, count=%d) - block.", cr_server.curClient, name, sema->count); cr_server.run_queue->blocked = 1; node = (wqnode *) crAlloc( sizeof( *node ) ); node->q = cr_server.run_queue; node->next = NULL; if (sema->tail) { sema->tail->next = node; } else { sema->waiting = node; } sema->tail = node; } }
static void AddVisualInfo(Display *dpy, int screen, VisualID visualid, int visBits) { struct VisualInfo *v; for (v = VisualInfoList; v; v = v->next) { if (v->dpy == dpy && v->screen == screen && v->visualid == visualid) { v->visBits |= visBits; return; } } v = (struct VisualInfo *) crAlloc(sizeof(struct VisualInfo)); v->dpy = dpy; v->screen = screen; v->visualid = visualid; v->visBits = visBits; v->next = VisualInfoList; VisualInfoList = v; }
void SERVER_DISPATCH_APIENTRY crServerDispatchGetInfoLogARB(GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog) { GLsizei *pLocal; GLuint hwid; pLocal = (GLsizei*) crAlloc(maxLength+sizeof(GLsizei)); if (!pLocal) { GLsizei zero=0; crServerReturnValue(&zero, sizeof(zero)); } /*@todo: recheck*/ hwid = crStateGetProgramHWID(obj); if (!hwid) hwid = crStateGetShaderHWID(obj); cr_server.head_spu->dispatch_table.GetInfoLogARB(hwid, maxLength, pLocal, (char*)&pLocal[1]); crServerReturnValue(pLocal, (*pLocal)+sizeof(GLsizei)); crFree(pLocal); }
/** * Allocate the color and depth buffers needed for the glDraw/ReadPixels * commands for the given window. */ static void AllocBuffers(WindowInfo * window) { CRASSERT(window); CRASSERT(window->width >= 0); CRASSERT(window->height >= 0); if (window->msgBuffer) crFree(window->msgBuffer); window->msgBuffer = (GLubyte *) crAlloc(sizeof(BinarySwapMsg) + window->width * window->height * ((window->bytesPerDepth + window->bytesPerColor) * sizeof(GLubyte))); /* Setup message type to keep network layer happy */ ((BinarySwapMsg *) window->msgBuffer)->header.type = CR_MESSAGE_OOB; }
void SERVER_DISPATCH_APIENTRY crServerDispatchReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) { /* Note: this local var overrides the global var in cr_unpack.h */ const unsigned char *cr_unpackData = crUnpackGetDataPointer(); CRMessageReadPixels *rp; const GLint stride = READ_DATA( 24, GLint ); const GLint alignment = READ_DATA( 28, GLint ); const GLint skipRows = READ_DATA( 32, GLint ); const GLint skipPixels = READ_DATA( 36, GLint ); const GLint bytes_per_row = READ_DATA( 40, GLint ); const GLint rowLength = READ_DATA( 44, GLint ); const int msg_len = sizeof(*rp) + bytes_per_row * height; CRASSERT(bytes_per_row > 0); rp = (CRMessageReadPixels *) crAlloc( msg_len ); /* Note: the ReadPixels data gets densely packed into the buffer * (no skip pixels, skip rows, etc. It's up to the receiver (pack spu, * tilesort spu, etc) to apply the real PixelStore packing parameters. */ cr_server.head_spu->dispatch_table.ReadPixels( x, y, width, height, format, type, rp + 1); rp->header.type = CR_MESSAGE_READ_PIXELS; rp->width = width; rp->height = height; rp->bytes_per_row = bytes_per_row; rp->stride = stride; rp->format = format; rp->type = type; rp->alignment = alignment; rp->skipRows = skipRows; rp->skipPixels = skipPixels; rp->rowLength = rowLength; /* <pixels> points to the 8-byte network pointer */ crMemcpy( &rp->pixels, pixels, sizeof(rp->pixels) ); crNetSend( cr_server.curClient->conn, NULL, rp, msg_len ); crFree( rp ); }
GLint PACKSPU_APIENTRY packspu_WindowCreate( const char *dpyName, GLint visBits ) { static int num_calls = 0; int writeback = pack_spu.thread[0].netServer.conn->actual_network; GLint return_val = (GLint) 0; WindowInfo *WInfo; /* WindowCreate is special - just like CreateContext. * GET_THREAD(thread) doesn't work as the thread won't have called * MakeCurrent yet, so we've got to use the first thread's packer * buffer. */ crPackSetContext( pack_spu.thread[0].packer ); if (pack_spu.swap) { crPackWindowCreateSWAP( dpyName, visBits, &return_val, &writeback ); } else { crPackWindowCreate( dpyName, visBits, &return_val, &writeback ); } packspuFlush( &pack_spu.thread[0] ); if (!(pack_spu.thread[0].netServer.conn->actual_network)) { return num_calls++; } else { while (writeback) crNetRecv(); if (pack_spu.swap) { return_val = (GLint) SWAP32(return_val); } WInfo = (WindowInfo *) crAlloc(sizeof(WindowInfo)); WInfo->XWindow = 0; WInfo->visual = visBits; crHashtableAdd(pack_spu.XWindows,return_val,WInfo); return return_val; } }
static void createSubMenu( apiMenu* newMenu ) { int i; /* begin copy subMenus - should re-implement this as a linked list*/ apiMenu** tmp = crAlloc( sizeof(apiMenu*) * (crut_server.endStack->subMenus + 1) ); for ( i=0; i < crut_server.endStack->subMenus; i++ ) tmp[i] = crut_server.endStack->tree[i]; /* end copy subMenus */ tmp[crut_server.endStack->subMenus] = newMenu; crut_server.endStack->tree = tmp; crut_server.endStack->subMenus++; }
/* * Send a Chromium opcode buffer across the given net connection. * size - size of opcode buffer in bytes. * exitFlag - if true, send 'exit' code to server. */ static void SendOpcodes(CRConnection *conn, int size, int exitFlag) { char *buffer, *firstCode; CRMessageOpcodes *msg; if (size <= MTU) { buffer = crNetAlloc(conn); msg = (CRMessageOpcodes *) buffer; msg->header.type = CR_MESSAGE_OPCODES; msg->numOpcodes = size; firstCode = buffer + sizeof(CRMessageOpcodes); if (exitFlag) *firstCode = 42; else *firstCode = 99; crNetSend(conn, NULL, buffer, MTU); crNetFree(conn, buffer); } else { /* send "huge" buffer */ const int totalSize = size + 8 + sizeof(CRMessageOpcodes); unsigned int *uiptr; buffer = crAlloc(totalSize); msg = (CRMessageOpcodes *) buffer; msg->header.type = CR_MESSAGE_OPCODES; msg->numOpcodes = 1; uiptr = (unsigned int *) (buffer + sizeof(CRMessageOpcodes) + 4); uiptr[0] = size; firstCode = buffer + sizeof(CRMessageOpcodes); if (exitFlag) *firstCode = 42; else *firstCode = 99; crNetSend(conn, NULL, buffer, size); crFree(buffer); } }
void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformsLocations(GLuint program, GLsizei maxcbData, GLsizei * cbData, GLvoid * pData) { GLsizei *pLocal; (void) cbData; (void) pData; pLocal = (GLsizei*) crAlloc(maxcbData+sizeof(GLsizei)); if (!pLocal) { GLsizei zero=0; crServerReturnValue(&zero, sizeof(zero)); } crStateGLSLProgramCacheUniforms(program, maxcbData, pLocal, (char*)&pLocal[1]); crServerReturnValue(pLocal, (*pLocal)+sizeof(GLsizei)); crFree(pLocal); }
void SERVER_DISPATCH_APIENTRY crServerDispatchPrioritizeTextures( GLsizei n, const GLuint * textures, const GLclampf * priorities ) { GLuint *newTextures = (GLuint *) crAlloc(n * sizeof(GLuint)); GLint i; if (!newTextures) { crError("crServerDispatchDeleteTextures: out of memory"); return; } for (i = 0; i < n; i++) { newTextures[i] = crStateGetTextureHWID(textures[i]); } crStatePrioritizeTextures(n, textures, priorities); cr_server.head_spu->dispatch_table.PrioritizeTextures(n, newTextures, priorities); crFree(newTextures); }
void PACKSPU_APIENTRY packspu_GetAttachedObjectsARB(GLhandleARB containerObj, GLsizei maxCount, GLsizei * count, GLhandleARB * obj) { GET_THREAD(thread); int writeback = 1; GLsizei *pLocal; if (!obj) return; pLocal = (GLsizei*) crAlloc(maxCount*sizeof(GLhandleARB)+sizeof(GLsizei)); if (!pLocal) return; crPackGetAttachedObjectsARB(containerObj, maxCount, pLocal, NULL, &writeback); packspuFlush((void *) thread); CRPACKSPU_WRITEBACK_WAIT(thread, writeback); if (count) *count=*pLocal; crMemcpy(obj, &pLocal[1], *pLocal*sizeof(GLhandleARB)); crFree(pLocal); }
static void buildValueArray(void) { int i; itemValue* item = crut_server.values; itemValue* temp; crut_server.valueTable = crAlloc( crut_server.numValues * sizeof( itemValue ) ); for ( i=0; i < crut_server.numValues; i++ ) { crut_server.valueTable[i].index = item->index; crut_server.valueTable[i].value = item->value; crut_server.valueTable[i].menuID = item->menuID; temp = item; item = item->next; crFree(temp); } }
void PACKSPU_APIENTRY packspu_GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei * length, char * infoLog) { GET_THREAD(thread); int writeback = 1; GLsizei *pLocal; if (!infoLog) return; pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei)); if (!pLocal) return; crPackGetShaderInfoLog(shader, bufSize, pLocal, NULL, &writeback); packspuFlush((void *) thread); CRPACKSPU_WRITEBACK_WAIT(thread, writeback); if (length) *length=*pLocal; crMemcpy(infoLog, &pLocal[1], (bufSize >= pLocal[0]) ? pLocal[0] : bufSize); crFree(pLocal); }
void PACKSPU_APIENTRY packspu_GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders) { GET_THREAD(thread); int writeback = 1; GLsizei *pLocal; if (!shaders) return; pLocal = (GLsizei*) crAlloc(maxCount*sizeof(GLuint)+sizeof(GLsizei)); if (!pLocal) return; crPackGetAttachedShaders(program, maxCount, pLocal, NULL, &writeback); packspuFlush((void *) thread); CRPACKSPU_WRITEBACK_WAIT(thread, writeback); if (count) *count=*pLocal; crMemcpy(shaders, &pLocal[1], *pLocal*sizeof(GLuint)); crFree(pLocal); }
DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateShader(GLuint hwid, GLenum type) { CRGLSLShader *pShader; CRContext *g = GetCurrentContext(); GLuint stateId = hwid; #ifdef IN_GUEST CRASSERT(!crStateGetShaderObj(stateId)); #else /* the proogram and shader names must not intersect because DeleteObjectARB must distinguish between them * see crStateDeleteObjectARB * this is why use programs table for shader keys allocation */ stateId = crHashtableAllocKeys(g->glsl.programs, 1); if (!stateId) { crWarning("failed to allocate program key"); return 0; } Assert((pShader = crStateGetShaderObj(stateId)) == NULL); #endif pShader = (CRGLSLShader *) crAlloc(sizeof(*pShader)); if (!pShader) { crWarning("crStateCreateShader: Out of memory!"); return 0; } pShader->id = stateId; pShader->hwid = hwid; pShader->type = type; pShader->source = NULL; pShader->compiled = GL_FALSE; pShader->deleted = GL_FALSE; pShader->refCount = 0; crHashtableAdd(g->glsl.shaders, stateId, pShader); return stateId; }
void SERVER_DISPATCH_APIENTRY crServerDispatchSemaphoreCreateCR( GLuint name, GLuint count ) { CRServerSemaphore *sema; if (cr_server.ignore_papi) { cr_server.head_spu->dispatch_table.SemaphoreCreateCR( name, count ); return; } sema = crHashtableSearch(cr_server.semaphores, name); if (sema) return; /* already created */ sema = (CRServerSemaphore *) crAlloc( sizeof( *sema ) ); crHashtableAdd( cr_server.semaphores, name, sema ); sema->count = count; sema->waiting = sema->tail = NULL; if (cr_server.debug_barriers) crDebug("crserver: SemaphoreCreate(id=%d, count=%d)", name, count); }
void crServerAddToRunQueue( CRClient *client ) { RunQueue *q = (RunQueue *) crAlloc( sizeof( *q ) ); #ifdef VBOX_WITH_CRHGSMI client->conn->pClient = client; CRVBOXHGSMI_CMDDATA_CLEANUP(&client->conn->CmdData); #endif /* give this client a unique number if needed */ if (!client->number) { client->number = client->conn->u32ClientID; } crDebug("Adding client %p to the run queue", client); if (FindClientInQueue(client)) { crError("CRServer: client %p already in the queue!", client); } q->client = client; q->blocked = 0; if (!cr_server.run_queue) { /* adding to empty queue */ cr_server.run_queue = q; q->next = q; q->prev = q; } else { /* insert in doubly-linked list */ q->next = cr_server.run_queue->next; cr_server.run_queue->next->prev = q; q->prev = cr_server.run_queue; cr_server.run_queue->next = q; } }
void CRUT_APIENTRY crutConnectToClients( CRUTAPI *crut_api ) { int i, ind; char response[8096], hostname[4096], protocol[4096]; char **newclients; char* client; unsigned short port; crMothershipGetCRUTClients(crut_api->mothershipConn, response); newclients = crStrSplit(response, " "); crut_api->numclients = crStrToInt(newclients[0]); ind = 1; crut_api->crutclients = crAlloc(crut_api->numclients*sizeof(CRUTClientPointer)); for (i=0; i<crut_api->numclients; i++) { client = newclients[ind++]; if ( !crParseURL( client, protocol, hostname, &port, DEFAULT_CRUT_PORT ) ) { crError( "Malformed URL: \"%s\"", response ); } crut_api->crutclients[i].mtu = crMothershipGetMTU( crut_api->mothershipConn ); crut_api->crutclients[i].send_conn = crNetAcceptClient( protocol, hostname, port, crut_api->crutclients[i].mtu, 0 ); if (!crut_api->crutclients[i].send_conn) { crError("Couldn't connect to the CRUT client"); } } }
void PACKSPU_APIENTRY packspu_GetInfoLogARB(GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog) { GET_THREAD(thread); int writeback = 1; GLsizei *pLocal; if (!infoLog) return; pLocal = (GLsizei*) crAlloc(maxLength+sizeof(GLsizei)); if (!pLocal) return; crPackGetInfoLogARB(obj, maxLength, pLocal, NULL, &writeback); packspuFlush((void *) thread); CRPACKSPU_WRITEBACK_WAIT(thread, writeback); CRASSERT((pLocal[0]) <= maxLength); if (length) *length=*pLocal; crMemcpy(infoLog, &pLocal[1], (maxLength >= (pLocal[0])) ? pLocal[0] : maxLength); crFree(pLocal); }
void PACKSPU_APIENTRY packspu_GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, char * name) { GET_THREAD(thread); int writeback = 1; crGetActive_t *pLocal; if (!size || !type || !name) return; pLocal = (crGetActive_t*) crAlloc(bufSize+sizeof(crGetActive_t)); if (!pLocal) return; crPackGetActiveUniform(program, index, bufSize, (GLsizei*)pLocal, NULL, NULL, NULL, &writeback); packspuFlush((void *) thread); CRPACKSPU_WRITEBACK_WAIT(thread, writeback); if (length) *length = pLocal->length; *size = pLocal->size; *type = pLocal->type; crMemcpy(name, &pLocal[1], pLocal->length+1); crFree(pLocal); }
void SERVER_DISPATCH_APIENTRY glStubDispatchGetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) { GLint size; GLvoid *buffer=NULL; cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &size); if (size && (buffer = crAlloc(size))) { /* XXX the pixel PACK parameter should be OK at this point */ cr_server.head_spu->dispatch_table.GetCompressedTexImageARB(target, level, buffer); glStubReturnValue( buffer, size ); crFree(buffer); } else { /* need to return _something_ to avoid blowing up */ GLuint dummy = 0; glStubReturnValue( (GLvoid *) &dummy, sizeof(dummy) ); } }
GLint PACKSPU_APIENTRY packspu_GetAttribLocation(GLuint program, const char * name) { if (!(CR_VBOX_CAP_GETATTRIBSLOCATIONS & g_u32VBoxHostCaps)) return packspu_GetAttribLocationUnchached(program, name); if (!crStateIsProgramAttribsCached(program)) { GET_THREAD(thread); int writeback = 1; GLsizei maxcbData; GLsizei *pData; GLint mu; packspu_GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &mu); maxcbData = 4*32*mu*sizeof(char); pData = (GLsizei *) crAlloc(maxcbData+sizeof(GLsizei)); if (!pData) { crWarning("packspu_GetAttribLocation: not enough memory, fallback to single query"); return packspu_GetAttribLocationUnchached(program, name); } crPackGetAttribsLocations(program, maxcbData, pData, NULL, &writeback); packspuFlush((void *) thread); CRPACKSPU_WRITEBACK_WAIT(thread, writeback); crStateGLSLProgramCacheAttribs(program, pData[0], &pData[1]); CRASSERT(crStateIsProgramAttribsCached(program)); crFree(pData); } /*crDebug("packspu_GetAttribLocation(%d, %s)=%i", program, name, crStateGetAttribLocation(program, name));*/ return crStateGetAttribLocation(program, name); }
void SERVER_DISPATCH_APIENTRY crServerDispatchGetAttachedObjectsARB(GLhandleARB containerObj, GLsizei maxCount, GLsizei * count, GLhandleARB * obj) { GLsizei *pLocal; pLocal = (GLsizei*) crAlloc(maxCount*sizeof(GLhandleARB)+sizeof(GLsizei)); if (!pLocal) { GLsizei zero=0; crServerReturnValue(&zero, sizeof(zero)); } cr_server.head_spu->dispatch_table.GetAttachedObjectsARB(crStateGetProgramHWID(containerObj), maxCount, pLocal, (GLhandleARB*)&pLocal[1]); { GLsizei i; GLuint *ids=(GLuint*)&pLocal[1]; for (i=0; i<*pLocal; ++i) ids[i] = crStateGLSLShaderHWIDtoID(ids[i]); } crServerReturnValue(pLocal, (*pLocal)*sizeof(GLhandleARB)+sizeof(GLsizei)); crFree(pLocal); }
void SERVER_DISPATCH_APIENTRY crServerDispatchGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders) { GLsizei *pLocal; pLocal = (GLsizei*) crAlloc(maxCount*sizeof(GLuint)+sizeof(GLsizei)); if (!pLocal) { GLsizei zero=0; crServerReturnValue(&zero, sizeof(zero)); } cr_server.head_spu->dispatch_table.GetAttachedShaders(crStateGetProgramHWID(program), maxCount, pLocal, (GLuint*)&pLocal[1]); { GLsizei i; GLuint *ids=(GLuint*)&pLocal[1]; for (i=0; i<*pLocal; ++i); ids[i] = crStateGLSLShaderHWIDtoID(ids[i]); } crServerReturnValue(pLocal, (*pLocal)*sizeof(GLuint)+sizeof(GLsizei)); crFree(pLocal); }
CRDLMContextState DLM_APIENTRY *crDLMNewContext(CRDLM *dlm) { CRDLMContextState *state; /* Get a record for our own internal state structure */ state = (CRDLMContextState *)crAlloc(sizeof(CRDLMContextState)); if (!state) { return NULL; } state->dlm = dlm; state->currentListIdentifier = 0; state->currentListInfo = NULL; state->currentListMode = GL_FALSE; state->listBase = 0; /* Increment the use count of the DLM provided. This guarantees that * the DLM won't be released until all the contexts have released it. */ crDLMUseDLM(dlm); return state; }
/* * Allocate a BufList object and initialize it with the given parameters. * Add it to the tail of the linked list anchored to frame_head. * The idea is that we're building a linked list of OpenGL command * buffers which we'll replay later. * Called by the Flush/Huge functions below. */ static void hiddenlineRecord( void *buf, void *data, void *opcodes, unsigned int num_opcodes, int can_reclaim ) { GET_CONTEXT(context); BufList *bl; bl = (BufList *) crAlloc( sizeof( *bl ) ); bl->buf = buf; bl->data = data; bl->opcodes = opcodes; bl->num_opcodes = num_opcodes; bl->can_reclaim = can_reclaim; bl->next = NULL; CRASSERT(context); if (context->frame_tail == NULL) { context->frame_head = bl; } else { context->frame_tail->next = bl; } context->frame_tail = bl; }
static void set_peers( void *foo, const char *response ) { char *nodes; char *token; int i; /* figure out peer information! */ /* grab network configuration */ /* get count of things first so we can allocate space */ int count = 0; nodes = crStrdup(response); if((token = strtok(nodes, ",\n\t\0 ")) != NULL){ count = 1; while((token = strtok(NULL, ",\n\t\0 ")) != NULL){ count++; } } else{ crError("Bad mojo: I can't figure out how many peers you have!"); } crFree(nodes); /* actually store the network peer list */ nodes = crStrdup(response); binaryswap_spu.peer_names = crAlloc(count*sizeof(char*)); if((token = strtok(nodes, ",\n\t ")) != NULL){ i = 0; binaryswap_spu.peer_names[i++] = crStrdup(token); while((token = strtok(NULL, ",\n\t ")) != NULL){ binaryswap_spu.peer_names[i++] = crStrdup(token); } } crFree(nodes); /* figure out how many stages we have */ binaryswap_spu.stages = (int)(log(count)/log(2)+0.1); }
static void vboxPatchMesaGLAPITable() { void *pGLTable; pGLTable = (void *)_glapi_get_dispatch(); vbox_glapi_table = crAlloc(_glapi_get_dispatch_table_size() * sizeof (void *)); if (!vbox_glapi_table) { crError("Not enough memory to allocate dispatch table"); } crMemcpy(vbox_glapi_table, pGLTable, _glapi_get_dispatch_table_size() * sizeof (void *)); #include "fakedri_glfuncsList.h" VBOX_SET_MESA_FUNC(vbox_glapi_table, "glBlendEquationSeparateEXT", cr_glBlendEquationSeparate); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glSampleMaskSGIS", cr_glSampleMaskEXT); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glSamplePatternSGIS", cr_glSamplePatternEXT); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos2dMESA", cr_glWindowPos2d); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos2dvMESA", cr_glWindowPos2dv); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos2fMESA", cr_glWindowPos2f); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos2fvMESA", cr_glWindowPos2fv); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos2iMESA", cr_glWindowPos2i); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos2ivMESA", cr_glWindowPos2iv); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos2sMESA", cr_glWindowPos2s); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos2svMESA", cr_glWindowPos2sv); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos3dMESA", cr_glWindowPos3d); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos3dvMESA", cr_glWindowPos3dv); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos3fMESA", cr_glWindowPos3f); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos3fvMESA", cr_glWindowPos3fv); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos3iMESA", cr_glWindowPos3i); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos3ivMESA", cr_glWindowPos3iv); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos3sMESA", cr_glWindowPos3s); VBOX_SET_MESA_FUNC(vbox_glapi_table, "glWindowPos3svMESA", cr_glWindowPos3sv); _glapi_set_dispatch(vbox_glapi_table); };