Index: trunk/src/VBox/GuestHost/OpenGL/util/bbox.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/bbox.c	(revision 78116)
+++ 	(revision )
@@ -1,229 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include <float.h>
-#include "cr_bbox.h"
-
-/**
- * \mainpage Util 
- *
- * \section UtilIntroduction Introduction
- *
- * Chromium consists of all the top-level files in the cr
- * directory.  The util module basically takes care of API dispatch,
- * and OpenGL state management.
- *
- */
-static float _vmult(const float *m, float x, float y, float z) 
-{
-	return m[0]*x + m[4]*y + m[8]*z + m[12];
-}
-
-void
-crTransformBBox( float xmin, float ymin, float zmin,
-                 float xmax, float ymax, float zmax,
-                 const CRmatrix *m,
-                 float *out_xmin, float *out_ymin, float *out_zmin,
-                 float *out_xmax, float *out_ymax, float *out_zmax )
-{
-	float x[8], y[8], z[8], w[8];
-	int i,j;
-    
-	/*  Here is the arrangement of the bounding box
-	 *  
-	 *           0 --- 1
-	 *           |\    .\
-	 *           | 2 --- 3 
-	 *           | |   . |
-	 *           | |   . |
-	 *           4.|...5 |
-	 *            \|    .|
-	 *             6 --- 7
-	 *  
-	 *  c array contains the edge connectivity list
-	 */
-
-	static const int c[8][3] = {	
-		{1, 2, 4}, 
-		{0, 3, 5}, 
-		{0, 3, 6}, 
-		{1, 2, 7},
-		{0, 5, 6}, 
-		{1, 4, 7}, 
-		{2, 4, 7}, 
-		{3, 5, 6} 
-	};
-
-	x[0] = _vmult(&(m->m00), xmin, ymin, zmin);
-	x[1] = _vmult(&(m->m00), xmax, ymin, zmin);
-	x[2] = _vmult(&(m->m00), xmin, ymax, zmin);
-	x[3] = _vmult(&(m->m00), xmax, ymax, zmin);
-	x[4] = _vmult(&(m->m00), xmin, ymin, zmax);
-	x[5] = _vmult(&(m->m00), xmax, ymin, zmax);
-	x[6] = _vmult(&(m->m00), xmin, ymax, zmax);
-	x[7] = _vmult(&(m->m00), xmax, ymax, zmax);
-
-	y[0] = _vmult(&(m->m01), xmin, ymin, zmin);
-	y[1] = _vmult(&(m->m01), xmax, ymin, zmin);
-	y[2] = _vmult(&(m->m01), xmin, ymax, zmin);
-	y[3] = _vmult(&(m->m01), xmax, ymax, zmin);
-	y[4] = _vmult(&(m->m01), xmin, ymin, zmax);
-	y[5] = _vmult(&(m->m01), xmax, ymin, zmax);
-	y[6] = _vmult(&(m->m01), xmin, ymax, zmax);
-	y[7] = _vmult(&(m->m01), xmax, ymax, zmax);
-
-	z[0] = _vmult(&(m->m02), xmin, ymin, zmin);
-	z[1] = _vmult(&(m->m02), xmax, ymin, zmin);
-	z[2] = _vmult(&(m->m02), xmin, ymax, zmin);
-	z[3] = _vmult(&(m->m02), xmax, ymax, zmin);
-	z[4] = _vmult(&(m->m02), xmin, ymin, zmax);
-	z[5] = _vmult(&(m->m02), xmax, ymin, zmax);
-	z[6] = _vmult(&(m->m02), xmin, ymax, zmax);
-	z[7] = _vmult(&(m->m02), xmax, ymax, zmax);
-
-	w[0] = _vmult(&(m->m03), xmin, ymin, zmin);
-	w[1] = _vmult(&(m->m03), xmax, ymin, zmin);
-	w[2] = _vmult(&(m->m03), xmin, ymax, zmin);
-	w[3] = _vmult(&(m->m03), xmax, ymax, zmin);
-	w[4] = _vmult(&(m->m03), xmin, ymin, zmax);
-	w[5] = _vmult(&(m->m03), xmax, ymin, zmax);
-	w[6] = _vmult(&(m->m03), xmin, ymax, zmax);
-	w[7] = _vmult(&(m->m03), xmax, ymax, zmax);
-
-	/* Now, the object-space bbox has been transformed into 
-	 * clip-space. */
-
-	/* Find the 2D bounding box of the 3D bounding box */
-	xmin = ymin = zmin = FLT_MAX;
-	xmax = ymax = zmax = -FLT_MAX;
-
-	for (i=0; i<8; i++) 
-	{
-		float xp = x[i];
-		float yp = y[i];
-		float zp = z[i];
-		float wp = w[i];
-
-		/* If corner is to be clipped... */
-		if (zp < -wp) 
-		{
-
-			/* Point has three edges */
-			for (j=0; j<3; j++) 
-			{
-				/* Handle the clipping... */
-				int k = c[i][j];
-				float xk = x[k];
-				float yk = y[k];
-				float zk = z[k];
-				float wk = w[k];
-				float t;
-
-				if (zp+wp-zk-wk == 0.0)
-					continue; /* avoid divide by zero */
-				else 
-					t = (wp + zp) / (zp+wp-zk-wk);
-
-				if (t < 0.0f || t > 1.0f)
-				{
-					continue;
-				}
-				wp = wp + (wk-wp) * t;
-				xp = xp + (xk-xp) * t;
-				yp = yp + (yk-yp) * t;
-				zp = -wp;
-
-				xp /= wp;
-				yp /= wp;
-				zp /= wp;
-
-				if (xp < xmin) xmin = xp;
-				if (xp > xmax) xmax = xp;
-				if (yp < ymin) ymin = yp;
-				if (yp > ymax) ymax = yp;
-				if (zp < zmin) zmin = zp;
-				if (zp > zmax) zmax = zp;
-			}
-		} 
-		else 
-		{
-			/* corner was not clipped.. */
-			xp /= wp;
-			yp /= wp;
-			zp /= wp;
-			if (xp < xmin) xmin = xp;
-			if (xp > xmax) xmax = xp;
-			if (yp < ymin) ymin = yp;
-			if (yp > ymax) ymax = yp;
-			if (zp < zmin) zmin = zp;
-			if (zp > zmax) zmax = zp;
-		}
-	}
-
-	/* Copy for export */
-	if (out_xmin) *out_xmin = xmin;
-	if (out_ymin) *out_ymin = ymin;
-	if (out_zmin) *out_zmin = zmin;
-	if (out_xmax) *out_xmax = xmax;
-	if (out_ymax) *out_ymax = ymax;
-	if (out_zmax) *out_zmax = zmax;
-}
-
-/**
- * Given the coordinates of the two opposite corners of a bounding box
- * in object space (x1,y1,z1) and (x2,y2,z2), use the given modelview
- * and projection matrices to transform the coordinates to NDC space.
- * Find the 3D bounding bounding box of those eight coordinates and
- * return the min/max in (x1,y1,x1) and (x2,y2,z2).
- */
-void
-crProjectBBox(const GLfloat modl[16], const GLfloat proj[16], 
-              GLfloat *x1, GLfloat *y1, GLfloat *z1,
-              GLfloat *x2, GLfloat *y2, GLfloat *z2) 
-{
-	CRmatrix m;
-	
-	/* compute product of modl and proj matrices */
-	m.m00  = proj[0] * modl[0]  + proj[4] * modl[1]  + proj[8]  * modl[2]  + proj[12] * modl[3];	
-	m.m01  = proj[1] * modl[0]  + proj[5] * modl[1]  + proj[9]  * modl[2]  + proj[13] * modl[3];	
-	m.m02  = proj[2] * modl[0]  + proj[6] * modl[1]  + proj[10] * modl[2]  + proj[14] * modl[3];	
-	m.m03  = proj[3] * modl[0]  + proj[7] * modl[1]  + proj[11] * modl[2]  + proj[15] * modl[3];	
-	m.m10  = proj[0] * modl[4]  + proj[4] * modl[5]  + proj[8]  * modl[6]  + proj[12] * modl[7];	
-	m.m11  = proj[1] * modl[4]  + proj[5] * modl[5]  + proj[9]  * modl[6]  + proj[13] * modl[7];	
-	m.m12  = proj[2] * modl[4]  + proj[6] * modl[5]  + proj[10] * modl[6]  + proj[14] * modl[7];	
-	m.m13  = proj[3] * modl[4]  + proj[7] * modl[5]  + proj[11] * modl[6]  + proj[15] * modl[7];	
-	m.m20  = proj[0] * modl[8]  + proj[4] * modl[9]  + proj[8]  * modl[10] + proj[12] * modl[11];	
-	m.m21  = proj[1] * modl[8]  + proj[5] * modl[9]  + proj[9]  * modl[10] + proj[13] * modl[11];
-	m.m22  = proj[2] * modl[8]  + proj[6] * modl[9]  + proj[10] * modl[10] + proj[14] * modl[11];	
-	m.m23  = proj[3] * modl[8]  + proj[7] * modl[9]  + proj[11] * modl[10] + proj[15] * modl[11];	
-	m.m30  = proj[0] * modl[12] + proj[4] * modl[13] + proj[8]  * modl[14] + proj[12] * modl[15];	
-	m.m31  = proj[1] * modl[12] + proj[5] * modl[13] + proj[9]  * modl[14] + proj[13] * modl[15];	
-	m.m32  = proj[2] * modl[12] + proj[6] * modl[13] + proj[10] * modl[14] + proj[14] * modl[15];	
-	m.m33  = proj[3] * modl[12] + proj[7] * modl[13] + proj[11] * modl[14] + proj[15] * modl[15]; 
-	
-    crTransformBBox( *x1, *y1, *z1,
-                     *x2, *y2, *z2,
-                     &m,
-                     x1, y1, z1,
-                     x2, y2, z2 );
-}
-
-
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-
-
-/**
- * Compute union of a and b and put in result.
- */
-void
-crRectiUnion(CRrecti *result, const CRrecti *a, const CRrecti *b)
-{
-	result->x1 = MIN(a->x1, b->x1);
-	result->x2 = MAX(a->x2, b->x2);
-	result->y1 = MIN(a->y1, b->y1);
-	result->y2 = MAX(a->y2, b->y2);
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp	(revision 78116)
+++ trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp	(revision 78190)
@@ -34,5 +34,4 @@
 # include "cr_error.h"
 # include "cr_net.h"
-# include "cr_rand.h"
 # include "cr_mem.h"
 # include "cr_string.h"
Index: trunk/src/VBox/GuestHost/OpenGL/util/calllists.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/calllists.c	(revision 78116)
+++ 	(revision )
@@ -1,81 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "chromium.h"
-#include "cr_calllists.h"
-
-#define EXPAND(typeEnum, typeCast, increment, value)     \
-    case typeEnum:                                       \
-      {                                                  \
-        const typeCast *array = (const typeCast *) lists; \
-        for (i = 0; i < (GLuint)n; i++, array increment) {        \
-          (*callListFunc)(base + (GLuint) value); 	 \
-        }                                                \
-      }                                                  \
-      break
-
-#define EXPAND_WITH_DATA(typeEnum, typeCast, increment, value)     \
-    case typeEnum:                                       	\
-      {                                                  \
-        const typeCast *array = (const typeCast *) lists; \
-        for (i = 0; i < (GLuint)n; i++, array increment) {\
-          (*callListFunc)(base + (GLuint) value, i, data); \
-        }                                                 \
-      }                                                    \
-      break
-
-
-int
-crExpandCallLists(GLsizei n, GLenum type, const GLvoid *lists, 
-    GLuint base, void (*callListFunc)(GLuint list))
-{
-	GLuint i;
-
-	switch (type) {
-		EXPAND(GL_BYTE, GLbyte,++,*array);
-		EXPAND(GL_UNSIGNED_BYTE, GLubyte,++,*array);
-		EXPAND(GL_SHORT, GLshort,++,*array);
-		EXPAND(GL_UNSIGNED_SHORT, GLushort,++,*array);
-		EXPAND(GL_INT, GLint,++,*array);
-		EXPAND(GL_UNSIGNED_INT, GLuint,++,*array);
-		EXPAND(GL_FLOAT, GLfloat,++,*array);
-
-		EXPAND(GL_2_BYTES, GLubyte, +=2, 256*array[0] + array[1]);
-		EXPAND(GL_3_BYTES, GLubyte, +=3, 256 * (256 * array[0] + array[1]) + array[2]);
-		EXPAND(GL_4_BYTES, GLubyte, +=4, 256 * (256 * (256 * array[0] + array[1]) + array[2]) + array[3]);
-
-		default:
-			return GL_INVALID_ENUM;
-	}
-
-	return GL_NO_ERROR;
-}
-
-int
-crExpandCallListsWithData(GLsizei n, GLenum type, const GLvoid *lists, 
-    GLuint base, void (*callListFunc)(GLuint list, GLuint index, GLvoid *data), GLvoid *data)
-{
-	GLuint i;
-
-	switch (type) {
-		EXPAND_WITH_DATA(GL_BYTE, GLbyte,++,*array);
-		EXPAND_WITH_DATA(GL_UNSIGNED_BYTE, GLubyte,++,*array);
-		EXPAND_WITH_DATA(GL_SHORT, GLshort,++,*array);
-		EXPAND_WITH_DATA(GL_UNSIGNED_SHORT, GLushort,++,*array);
-		EXPAND_WITH_DATA(GL_INT, GLint,++,*array);
-		EXPAND_WITH_DATA(GL_UNSIGNED_INT, GLuint,++,*array);
-		EXPAND_WITH_DATA(GL_FLOAT, GLfloat,++,*array);
-
-		EXPAND_WITH_DATA(GL_2_BYTES, GLubyte, +=2, 256*array[0] + array[1]);
-		EXPAND_WITH_DATA(GL_3_BYTES, GLubyte, +=3, 256 * (256 * array[0] + array[1]) + array[2]);
-		EXPAND_WITH_DATA(GL_4_BYTES, GLubyte, +=4, 256 * (256 * (256 * array[0] + array[1]) + array[2]) + array[3]);
-
-		default:
-			return GL_INVALID_ENUM;
-	}
-
-	return GL_NO_ERROR;
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/debug_opcodes.py
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/debug_opcodes.py	(revision 78116)
+++ 	(revision )
@@ -1,42 +1,0 @@
-# Copyright (c) 2001, Stanford University
-# All rights reserved.
-#
-# See the file LICENSE.txt for information on redistributing this software.
-
-from __future__ import print_function
-import sys;
-import string;
-import re;
-
-import apiutil
-
-apiutil.CopyrightC()
-
-print("""
-#include "cr_debugopcodes.h"
-#include <stdio.h>
-""")
-
-print("""void crDebugOpcodes( FILE *fp, unsigned char *ptr, unsigned int num_opcodes )
-{
-\tunsigned int i;
-\tfor (i = 0; i < num_opcodes; i++)
-\t{
-\t\tswitch(*(ptr--))
-\t\t{
-""")
-
-keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
-keys.sort()
-
-for func_name in keys:
-	if "pack" in apiutil.ChromiumProps(func_name):
-		print('\t\tcase %s:' % apiutil.OpcodeName( func_name ))
-		print('\t\t\tfprintf(fp, "%s\\n"); ' % apiutil.OpcodeName( func_name ))
-		print( '\t\t\tbreak;')
-
-print("""
-\t\t}
-\t}
-}
-""")
Index: trunk/src/VBox/GuestHost/OpenGL/util/devnull.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/devnull.c	(revision 78116)
+++ 	(revision )
@@ -1,118 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_net.h"
-#include "cr_mem.h"
-#include "cr_error.h"
-#include "net_internals.h"
-
-static void
-crDevnullWriteExact( CRConnection *conn, const void *buf, unsigned int len )
-{
-	(void) conn;
-	(void) buf;
-	(void) len;
-}
-
-static void *
-crDevnullAlloc( CRConnection *conn )
-{
-	return crAlloc( conn->buffer_size );
-}
-
-static void
-crDevnullSingleRecv( CRConnection *conn, void *buf, unsigned int len )
-{
-	crError( "You can't receive data on a devnull connection!" );
-	(void) conn;
-	(void) buf;
-	(void) len;
-}
-
-static void
-crDevnullFree( CRConnection *conn, void *buf )
-{
-	crFree( buf );
-	(void) conn;
-}
-
-static void
-crDevnullSend( CRConnection *conn, void **bufp,
-				 const void *start, unsigned int len )
-{
-	
-	if (bufp)
-	{
-		/* We're sending something we've allocated.  It's now ours. 
-		 * If the callers wants to send something else, he'll allocate 
-		 * something else. 
-		 * 
-		 * ENFORCE IT! */
-
-		crDevnullFree( conn, *bufp );
-	}
-	(void) conn;
-	(void) bufp;
-	(void) start;
-	(void) len;
-}
-
-int
-crDevnullRecv( void )
-{
-	crError( "You can't receive data on a DevNull network, stupid." );
-	return 0;
-}
-
-void
-crDevnullInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu )
-{
-	(void) rfl;
-	(void) cfl;
-	(void) mtu;
-}
-
-static void
-crDevnullAccept( CRConnection *conn, const char *hostname, unsigned short port )
-{
-	crError( "Well, you *could* accept a devnull client, but you'd be disappointed. ");
-	(void) conn;
-	(void) port;
-        (void) hostname;
-}
-
-static int
-crDevnullDoConnect( CRConnection *conn )
-{
-	(void) conn; 
-	return 1;
-}
-
-static void
-crDevnullDoDisconnect( CRConnection *conn )
-{
-	(void) conn;
-}
-
-void crDevnullConnection( CRConnection *conn )
-{
-	conn->type  = CR_DROP_PACKETS;
-	conn->Alloc = crDevnullAlloc;
-	conn->Send  = crDevnullSend;
-	conn->SendExact  = crDevnullWriteExact;
-	conn->Recv  = crDevnullSingleRecv;
-	conn->Free  = crDevnullFree;
-	conn->Accept = crDevnullAccept;
-	conn->Connect = crDevnullDoConnect;
-	conn->Disconnect = crDevnullDoDisconnect;
-	conn->actual_network = 0;
-}
-
-CRConnection** crDevnullDump( int * num )
-{
-	*num = 0;
-	return NULL;
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/endian.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/endian.c	(revision 78116)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#include "chromium.h"
-#include "cr_endian.h"
-
-char crDetermineEndianness( void )
-{
-	union {
-		struct {
-			char c1;
-			char c2;
-			char c3;
-			char c4;
-		} c;
-		unsigned int i;
-	} e_test;
-
-	e_test.c.c1 = 1;
-	e_test.c.c2 = 2;
-	e_test.c.c3 = 3;
-	e_test.c.c4 = 4;
-
-	if (e_test.i == 0x01020304)
-	{
-		return CR_BIG_ENDIAN;
-	}
-	return CR_LITTLE_ENDIAN;
-}  
-
-double SWAPDOUBLE( double d )
-{
-	CR64BitType *ptr = (CR64BitType *) (&d);
-#ifdef __STDC__
-	CR64BitType swapped;
-	SWAP64( *ptr );
-	swapped = *ptr;
-#else
-	CR64BitType swapped = SWAP64( *ptr );
-#endif
-	return *((double *) (&swapped));
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/environment.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/environment.c	(revision 78116)
+++ 	(revision )
@@ -1,34 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_environment.h"
-#include "cr_string.h"
-#include "cr_mem.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-void crSetenv( const char *var, const char *value )
-{
-#if defined(LINUX) || defined(FREEBSD) || defined(DARWIN)
-	setenv( var, value, 1 /* replace */ );
-#else
-	unsigned long len;
-	char *buf;
-
-	len = crStrlen(var) + 1 + crStrlen(value) + 1;
-	buf = (char *) crAlloc( len );
-	sprintf( buf, "%s=%s", var, value );
-	putenv( buf );
-
-	/* don't free the buf, the string is *part* of the environment,
-	 * and can't be reclaimed */
-#endif
-}
-
-const char *crGetenv( const char *var )
-{
-	return getenv( var );
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/error.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/error.c	(revision 78116)
+++ trunk/src/VBox/GuestHost/OpenGL/util/error.c	(revision 78190)
@@ -25,9 +25,10 @@
 #include <iprt/buildconfig.h>
 
+
 #include <VBox/log.h>
+#include <iprt/env.h>
 
 #ifdef RT_OS_WINDOWS
 # include <iprt/win/windows.h>
-# include "cr_environment.h"
 # include "cr_error.h"
 # include "VBox/VBoxGuestLib.h"
@@ -100,5 +101,5 @@
     /* Log last error on windows. */
     dwLastErr = GetLastError();
-    if (dwLastErr != 0 && crGetenv("CR_WINDOWS_ERRORS") != NULL)
+    if (dwLastErr != 0 && RTEnvGet("CR_WINDOWS_ERRORS") != NULL)
     {
         LPTSTR pszWindowsMessage;
Index: trunk/src/VBox/GuestHost/OpenGL/util/filenet.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/filenet.c	(revision 78116)
+++ 	(revision )
@@ -1,385 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#ifdef WINDOWS
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_string.h"
-#include "cr_bufpool.h"
-#include "cr_net.h"
-#include "cr_endian.h"
-#include "cr_threads.h"
-#include "net_internals.h"
-
-typedef enum {
-	CRFileMemory,
-	CRFileMemoryBig
-} CRFileBufferKind;
-
-#define CR_FILE_BUFFER_MAGIC 0x89134539
-
-#ifndef WINDOWS
-#define O_BINARY 0
-#endif
-
-typedef struct CRFileBuffer {
-	unsigned int          magic;
-	CRFileBufferKind     kind;
-	unsigned int          len;
-	unsigned int          allocated;
-	unsigned int          pad;
-} CRFileBuffer;
-
-static struct {
-	int                  initialized;
-	int                  num_conns;
-	CRConnection         **conns;
-	CRBufferPool         *bufpool;
-#ifdef CHROMIUM_THREADSAFE
-	CRmutex              mutex;
-#endif
-	CRNetReceiveFuncList *recv_list;
-	CRNetCloseFuncList   *close_list;
-} cr_file;
-
-static void
-crFileReadExact( CRConnection *conn, void *buf, unsigned int len )
-{
-	char *dst = (char *) buf;
-
-	while ( len > 0 )
-	{
-		int num_read = read( conn->fd, buf, len );
-
-		if ( num_read < 0 )
-		{
-			crError( "Bad bad bad file error!" );
-		}
-		if (num_read == 0)
-		{
-			crError( "END OF FILE!" );
-		}
-
-		dst += num_read;
-		len -= num_read;
-	}
-}
-
-static void
-crFileWriteExact( CRConnection *conn, const void *buf, unsigned int len )
-{
-	int retval = write( conn->fd, buf, len );
-	if ( retval < (int) len )
-	{
-		crError( "crFileWriteExact: %s (tried to write %d bytes, actually wrote %d)", conn->filename, len, retval );
-	}
-}
-
-static void
-crFileAccept( CRConnection *conn, const char *hostname, unsigned short port )
-{
-	(void)hostname;
-	conn->file_direction = CR_FILE_READ;
-	conn->fd = open( conn->filename, O_RDONLY | O_BINARY );
-	if (conn->fd < 0)
-	{
-		crError( "Couldn't open %s for reading!", conn->filename );
-	}
-	(void) port;
-}
-
-static void
-*crFileAlloc( CRConnection *conn )
-{
-	CRFileBuffer *buf;
-
-#ifdef CHROMIUM_THREADSAFE
-	crLockMutex(&cr_file.mutex);
-#endif
-
-	buf  = (CRFileBuffer *) crBufferPoolPop( cr_file.bufpool, conn->buffer_size );
-
-	if ( buf == NULL )
-	{
-		crDebug( "Buffer pool was empty, so I allocated %d bytes", 
-			(int)(sizeof(CRFileBuffer) + conn->buffer_size) );
-		buf = (CRFileBuffer *) 
-			crAlloc( sizeof(CRFileBuffer) + conn->buffer_size );
-		buf->magic = CR_FILE_BUFFER_MAGIC;
-		buf->kind  = CRFileMemory;
-		buf->pad   = 0;
-		buf->allocated = conn->buffer_size;
-	}
-
-#ifdef CHROMIUM_THREADSAFE
-	crUnlockMutex(&cr_file.mutex);
-#endif
-
-	return (void *)( buf + 1 );
-}
-
-static void
-crFileSingleRecv( CRConnection *conn, void *buf, unsigned int len )
-{
-	crFileReadExact( conn, buf, len );
-}
-
-static void
-crFileSend( CRConnection *conn, void **bufp, const void *start, unsigned int len )
-{
-	CRFileBuffer *file_buffer;
-	unsigned int      *lenp;
-
-	if ( bufp == NULL )
-	{
-		/* we are doing synchronous sends from user memory, so no need
-		 * to get fancy.  Simply write the length & the payload and
-		 * return. */
-		if (conn->swap)
-		{
-			len = SWAP32(len);
-		}
-		crFileWriteExact( conn, &len, sizeof(len) );
-		crFileWriteExact( conn, start, len );
-		return;
-	}
-
-	file_buffer = (CRFileBuffer *)(*bufp) - 1;
-
-	CRASSERT( file_buffer->magic == CR_FILE_BUFFER_MAGIC );
-
-	/* All of the buffers passed to the send function were allocated
-	 * with crFileAlloc(), which includes a header with a 4 byte
-	 * length field, to insure that we always have a place to write
-	 * the length field, even when start == *bufp. */
-	lenp = (unsigned int *) start - 1;
-	*lenp = len;
-
-	crFileWriteExact(conn, lenp, len + sizeof(int) );
-
-	/* reclaim this pointer for reuse and try to keep the client from
-		 accidentally reusing it directly */
-#ifdef CHROMIUM_THREADSAFE
-	crLockMutex(&cr_file.mutex);
-#endif
-	crBufferPoolPush( cr_file.bufpool, file_buffer, conn->buffer_size );
-#ifdef CHROMIUM_THREADSAFE
-	crUnlockMutex(&cr_file.mutex);
-#endif
-	*bufp = NULL;
-}
-
-static void
-crFileFree( CRConnection *conn, void *buf )
-{
-	CRFileBuffer *file_buffer = (CRFileBuffer *) buf - 1;
-
-	CRASSERT( file_buffer->magic == CR_FILE_BUFFER_MAGIC );
-	conn->recv_credits += file_buffer->len;
-
-	switch ( file_buffer->kind )
-	{
-		case CRFileMemory:
-#ifdef CHROMIUM_THREADSAFE
-			crLockMutex(&cr_file.mutex);
-#endif
-			crBufferPoolPush( cr_file.bufpool, file_buffer, conn->buffer_size );
-#ifdef CHROMIUM_THREADSAFE
-			crUnlockMutex(&cr_file.mutex);
-#endif
-			break;
-
-		case CRFileMemoryBig:
-			crFree( file_buffer );
-			break;
-
-		default:
-			crError( "Weird buffer kind trying to free in crFileFree: %d", file_buffer->kind );
-	}
-}
-
-int
-crFileRecv( void )
-{
-	CRMessage *msg;
-	int i;
-
-	if (!cr_file.num_conns)
-	{
-		return 0;
-	}
-	for ( i = 0; i < cr_file.num_conns; i++ )
-	{
-		CRFileBuffer *file_buffer;
-		unsigned int   len;
-		CRConnection  *conn = cr_file.conns[i];
-
-		crFileReadExact( conn, &len, sizeof( len ) );
-
-		CRASSERT( len > 0 );
-
-		if ( len <= conn->buffer_size )
-		{
-			file_buffer = (CRFileBuffer *) crFileAlloc( conn ) - 1;
-		}
-		else
-		{
-			file_buffer = (CRFileBuffer *) 
-				crAlloc( sizeof(*file_buffer) + len );
-			file_buffer->magic = CR_FILE_BUFFER_MAGIC;
-			file_buffer->kind  = CRFileMemoryBig;
-			file_buffer->pad   = 0;
-		}
-
-		file_buffer->len = len;
-
-		crFileReadExact( conn, file_buffer + 1, len );
-
-		conn->recv_credits -= len;
-
-		msg = (CRMessage *) (file_buffer + 1);
-		crNetDispatchMessage( cr_file.recv_list, conn, msg, len );
-
-		/* CR_MESSAGE_OPCODES is freed in
-		 * crserverlib/server_stream.c 
-		 *
-		 * OOB messages are the programmer's problem.  -- Humper 12/17/01 */
-		if (msg->header.type != CR_MESSAGE_OPCODES && msg->header.type != CR_MESSAGE_OOB)
-		{
-			crFileFree( conn, file_buffer + 1 );
-		}
-	}
-
-	return 1;
-}
-
-static void
-crFileHandleNewMessage( CRConnection *conn, CRMessage *msg,
-		unsigned int len )
-{
-	CRFileBuffer *buf = ((CRFileBuffer *) msg) - 1;
-
-	/* build a header so we can delete the message later */
-	buf->magic = CR_FILE_BUFFER_MAGIC;
-	buf->kind  = CRFileMemory;
-	buf->len   = len;
-	buf->pad   = 0;
-
-	crNetDispatchMessage( cr_file.recv_list, conn, msg, len );
-}
-
-static void
-crFileInstantReclaim( CRConnection *conn, CRMessage *mess )
-{
-	crFileFree( conn, mess );
-}
-
-void
-crFileInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu )
-{
-	(void) mtu;
-
-	cr_file.recv_list = rfl;
-	cr_file.close_list = cfl;
-
-	if (cr_file.initialized)
-	{
-		return;
-	}
-
-	cr_file.num_conns = 0;
-	cr_file.conns     = NULL;
-	
-#ifdef CHROMIUM_THREADSAFE
-	crInitMutex(&cr_file.mutex);
-#endif
-	cr_file.bufpool = crBufferPoolInit(16);
-
-
-	cr_file.initialized = 1;
-}
-
-static int
-crFileDoConnect( CRConnection *conn )
-{
-	conn->file_direction = CR_FILE_WRITE;
-	/* NOTE: the third parameter (file permissions) is only used/required when
-	 * we specify O_CREAT as part of the flags.  The permissions will be
-	 * masked according to the effective user's umask setting.
-	 */
-#ifdef WINDOWS
-	conn->fd = open( conn->filename, O_CREAT | O_WRONLY | O_BINARY |
-									 S_IREAD | S_IWRITE);
-#else
-	conn->fd = open( conn->filename, O_CREAT | O_WRONLY | O_BINARY,
-								     S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
-#endif
-	if (conn->fd < 0)
-	{
-		crWarning( "Couldn't open %s for writing!", conn->filename );
-		return 0;
-	}
-	return 1;
-}
-
-static void
-crFileDoDisconnect( CRConnection *conn )
-{
-	close( conn->fd );
-	conn->type = CR_NO_CONNECTION;
-	crMemcpy( cr_file.conns + conn->index, cr_file.conns + conn->index+1, 
-		(cr_file.num_conns - conn->index - 1)*sizeof(*(cr_file.conns)) );
-	cr_file.num_conns--;
-}
-
-void
-crFileConnection( CRConnection *conn )
-{
-	int n_bytes;
-
-	CRASSERT( cr_file.initialized );
-
-	conn->type  = CR_FILE;
-	conn->Alloc = crFileAlloc;
-	conn->Send  = crFileSend;
-	conn->SendExact  = crFileWriteExact;
-	conn->Recv  = crFileSingleRecv;
-	conn->Free  = crFileFree;
-	conn->Accept = crFileAccept;
-	conn->Connect = crFileDoConnect;
-	conn->Disconnect = crFileDoDisconnect;
-	conn->InstantReclaim = crFileInstantReclaim;
-	conn->HandleNewMessage = crFileHandleNewMessage;
-	conn->index = cr_file.num_conns;
-	conn->sizeof_buffer_header = sizeof( CRFileBuffer );
-	conn->actual_network = 0;
-
-	conn->filename = crStrdup( conn->hostname );
-
-	n_bytes = ( cr_file.num_conns + 1 ) * sizeof(*cr_file.conns);
-	crRealloc( (void **) &cr_file.conns, n_bytes );
-
-	cr_file.conns[cr_file.num_conns++] = conn;
-}
-
-CRConnection**
-crFileDump( int* num )
-{
-	*num = cr_file.num_conns;
-
-	return cr_file.conns;
-}
-
Index: trunk/src/VBox/GuestHost/OpenGL/util/htable.cpp
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/htable.cpp	(revision 78116)
+++ trunk/src/VBox/GuestHost/OpenGL/util/htable.cpp	(revision 78190)
@@ -28,5 +28,4 @@
 #include "cr_error.h"
 #include "cr_net.h"
-#include "cr_rand.h"
 #include "cr_mem.h"
 #include "cr_string.h"
Index: trunk/src/VBox/GuestHost/OpenGL/util/hull.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/hull.c	(revision 78116)
+++ 	(revision )
@@ -1,315 +1,0 @@
-
-#include <stdlib.h>
-#include <math.h>
-
-#include "cr_mem.h"
-#include "cr_hull.h"
-#include "cr_error.h"
-
-#ifdef WINDOWS
-/* I know while(1) is constant */
-#pragma warning( disable: 4127 )
-#endif
-
-/*==================================================
- *
- * Do S1 & S2 intersect? if so, return t for s1
- */
-static double
-_segment_segment_intersection(const double *s1a, const double *s1b,
-															const double *s2a, const double *s2b)
-{
-	double r1[2], r2[2];
-	double A, B, s, t;
-	double epsilon = .0000000001;
-
-	r1[0] = s1b[0] - s1a[0];
-	r1[1] = s1b[1] - s1a[1];
-	r2[0] = s2b[0] - s2a[0];
-	r2[1] = s2b[1] - s2a[1];
-
-	if (r1[0] == 0)
-		return -1;
-
-	A = s1a[1] - s2a[1] + (r1[1] / r1[0]) * (s2a[0] - s1a[0]);
-	B = r2[1] - (r1[1] / r1[0]) * r2[0];
-
-	if (B == 0)
-		return -1;
-	s = A / B;
-
-	if ((s <= epsilon) || (s > 1. + epsilon))
-		return -1;
-
-	t = (s2a[0] - s1a[0] + s * r2[0]) / r1[0];
-	if ((t < epsilon) || (t > 1. + epsilon))
-		return -1;
-
-	return t;
-}
-
-static int
-_segment_hull_intersect(double *sa, double *sb, const double *pnts,
-												int *hull, int hull_len, double *hits)
-{
-	int a, hitnum;
-	double result;
-	double d[2];
-
-	hitnum = 0;
-	for (a = 0; a < hull_len - 1; a++)
-	{
-		result = _segment_segment_intersection(sa, sb, pnts + 2 * hull[a],
-																					 pnts + 2 * hull[a + 1]);
-
-		if (result >= 0)
-		{
-			d[0] = sb[0] - sa[0];
-			d[1] = sb[1] - sa[1];
-			hits[2 * hitnum] = sa[0] + result * d[0];
-			hits[2 * hitnum + 1] = sa[1] + result * d[1];
-			hitnum++;
-		}
-	}
-
-	return hitnum;
-}
-
-/* 
- * given 4 points, find a rectangle that lays w/i the quad
- */
-static void
-_four_point_box(double *points, double *min, double *max)
-{
-	int a, b, tmp, sort[4];
-	double npnts[8], pnt[2], retval, d[2];
-
-	for (a = 0; a < 4; a++)
-		sort[a] = a;
-
-	for (a = 0; a < 4; a++)
-		for (b = a + 1; b < 4; b++)
-		{
-			if (points[2 * sort[a] + 1] > points[2 * sort[b] + 1])
-			{
-				tmp = sort[a];
-				sort[a] = sort[b];
-				sort[b] = tmp;
-			}
-		}
-
-	npnts[0] = points[2 * sort[1]];
-	npnts[1] = points[2 * sort[1] + 1];
-	npnts[2] = points[2 * sort[2]];
-	npnts[3] = points[2 * sort[2] + 1];
-
-	/* now, intersect a horizontal ray from sort[1] with the quad */
-	for (b = 0; b < 2; b++)
-	{
-		for (a = 0; a < 4; a++)
-		{
-			pnt[0] = points[2 * sort[b + 1]] + 10;
-			pnt[1] = points[2 * sort[b + 1] + 1];
-
-			retval = _segment_segment_intersection(points + 2 * sort[b + 1], pnt,
-																						 points + 2 * a,
-																						 points + 2 * ((a + 1) % 4));
-			if (retval <= 0.001)
-			{
-				pnt[0] = points[2 * sort[b + 1]] - 10;
-				retval = _segment_segment_intersection(points + 2 * sort[b + 1], pnt,
-																							 points + 2 * a,
-																							 points + 2 * ((a + 1) % 4));
-			}
-
-			if (retval > 0.001)
-			{
-				d[0] = pnt[0] - points[2 * sort[b + 1]];
-				d[1] = pnt[1] - points[2 * sort[b + 1] + 1];
-				npnts[2 * b + 4] = points[2 * sort[b + 1]] + retval * d[0];
-				npnts[2 * b + 5] = points[2 * sort[b + 1] + 1] + retval * d[1];
-			}
-		}
-	}
-
-	min[1] = points[2 * sort[1] + 1];
-	max[1] = points[2 * sort[2] + 1];
-
-	/* finally, sort npnts by x */
-	for (a = 0; a < 4; a++)
-		sort[a] = a;
-
-	for (a = 0; a < 4; a++)
-		for (b = a + 1; b < 4; b++)
-		{
-			if (npnts[2 * sort[a]] > npnts[2 * sort[b]])
-			{
-				tmp = sort[a];
-				sort[a] = sort[b];
-				sort[b] = tmp;
-			}
-		}
-
-	/* and grab the x coord of the box */
-	min[0] = npnts[2 * sort[1]];
-	max[0] = npnts[2 * sort[2]];
-
-}
-
-/* 
- * Given the convex hull, find a rectangle w/i it. 
- *
- * Finding the rect from 4 pnts isn't too bad. Find the bbox
- * of the CH, then intersect the diagonals of the bbox with
- * the CH. Use those 4 points to compute the box
- */
-static void
-_bound(const double *pnts, int npnts, int *hull, int hull_len, double *bbox)
-{
-	double max[2], min[2], cent[2], dir[2], pnt[2];
-	double x, y, intr_pnts[8];
-	int a, retval;
-
-	(void) npnts;
-
-	max[0] = max[1] = -9999;
-	min[0] = min[1] = 9999;
-	for (a = 0; a < hull_len; a++)
-	{
-		x = pnts[2 * hull[a]];
-		y = pnts[2 * hull[a] + 1];
-		if (x < min[0])
-			min[0] = x;
-		if (x > max[0])
-			max[0] = x;
-		if (y < min[1])
-			min[1] = y;
-		if (y > max[1])
-			max[1] = y;
-	}
-
-	/* push the bbox out just a hair to make intersection
-	 * a bit more sane */
-	cent[0] = (min[0] + max[0]) / 2.;
-	cent[1] = (min[1] + max[1]) / 2.;
-	dir[0] = max[0] - cent[0];
-	dir[1] = max[1] - cent[1];
-	max[0] = cent[0] + 1.01 * dir[0];
-	max[1] = cent[1] + 1.01 * dir[1];
-	dir[0] = min[0] - cent[0];
-	dir[1] = min[1] - cent[1];
-	min[0] = cent[0] + 1.01 * dir[0];
-	min[1] = cent[1] + 1.01 * dir[1];
-
-	retval = _segment_hull_intersect(min, max, pnts, hull, hull_len, intr_pnts);
-	if (retval != 2)
-		crError("Bad hull intersection");
-
-	dir[0] = min[0];
-	dir[1] = max[1];
-	pnt[0] = max[0];
-	pnt[1] = min[1];
-	retval =
-		_segment_hull_intersect(dir, pnt, pnts, hull, hull_len, intr_pnts + 4);
-	if (retval != 2)
-		crError("Bad hull intersection");
-
-	/* swap points to get them in some order */
-	cent[0] = intr_pnts[2];
-	cent[1] = intr_pnts[3];
-	intr_pnts[2] = intr_pnts[4];
-	intr_pnts[3] = intr_pnts[5];
-	intr_pnts[4] = cent[0];
-	intr_pnts[5] = cent[1];
-
-	_four_point_box(intr_pnts, bbox, bbox + 2);
-}
-
-/*==================================================*/
-void
-crHullInteriorBox(const double *pnts, int npnts, double *bbox)
-{
-	int lowest, a;
-	int *hull, idx, low_idx = 0;
-	double low_dot;
-	const double *p0, *p1;
-	double v[2], A, B, vnew[2], vlow[2];
-
-	vlow[0] = vlow[1] = 0.0;
-
-	hull = (int *) crAlloc((npnts + 1) * sizeof(int));
-
-	/* find the lowest */
-	lowest = 0;
-	for (a = 0; a < 2 * npnts; a += 2)
-	{
-		if (pnts[a + 1] < pnts[2 * lowest + 1])
-			lowest = a / 2;
-	}
-
-	hull[0] = lowest;
-	p0 = pnts + 2 * lowest;
-	idx = 1;
-
-	v[0] = 1;
-	v[1] = 0;
-
-	while (1)
-	{
-		low_dot = -10;
-
-		for (a = 0; a < npnts; a++)
-		{
-			if (a == hull[idx - 1])
-				continue;
-
-			p1 = pnts + 2 * a;
-			if (v[0] == 0.0)
-				A = 0.0;
-			else
-				A = p0[1] - p1[1] + (v[1] / v[0]) * (p1[0] - p0[0]);
-			if (v[0] == 0.0)
-				B = 0.0;
-			else
-				B = v[1] * v[1] / v[0] + v[0];
-
-			if (B != 0.0 && A / B > 0)
-			{
-				continue;
-			}
-
-			vnew[0] = p1[0] - p0[0];
-			vnew[1] = p1[1] - p0[1];
-			B = sqrt(vnew[0] * vnew[0] + vnew[1] * vnew[1]);
-
-			vnew[0] /= B;
-			vnew[1] /= B;
-
-			A = vnew[0] * v[0] + vnew[1] * v[1];
-
-			if (A > low_dot)
-			{
-				low_dot = A;
-				low_idx = a;
-				vlow[0] = vnew[0];
-				vlow[1] = vnew[1];
-			}
-		}
-
-		p0 = pnts + 2 * low_idx;
-		hull[idx] = low_idx;
-		idx++;
-
-		v[0] = vlow[0];
-		v[1] = vlow[1];
-
-		if (low_idx == lowest)
-		{
-			break;
-		}
-	} 
-
-	_bound(pnts, npnts, hull, idx, bbox);
-
-	crFree(hull);
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/idpool.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/idpool.c	(revision 78116)
+++ 	(revision )
@@ -1,288 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "chromium.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_idpool.h"
-
-
-#define CR_MAXUINT             ((GLuint) 0xFFFFFFFF)
-
-typedef struct FreeElemRec {
-	GLuint min;
-	GLuint max;
-	struct FreeElemRec *next;
-	struct FreeElemRec *prev;
-} FreeElem;
-
-struct CRIdPoolRec {
-	FreeElem *freeList;
-};
-
-
-
-CRIdPool *crAllocIdPool( void )
-{
-	CRIdPool *pool = (CRIdPool *) crCalloc(sizeof(CRIdPool));
-	pool->freeList = (FreeElem *) crCalloc(sizeof(FreeElem));
-	pool->freeList->min = 1;
-	pool->freeList->max = CR_MAXUINT;
-	pool->freeList->next = NULL;
-	pool->freeList->prev = NULL;
-	return pool;
-}
-
-void crFreeIdPool( CRIdPool *pool )
-{
-	FreeElem *i, *next;
-	for (i = pool->freeList; i; i = next)
-	{
-		next = i->next;
-		crFree(i);
-	}
-	crFree(pool);
-}
-
-/*
- * Allocate a block of <count> IDs.  Return index of first one.
- * Return 0 if we fail.
- */
-GLuint crIdPoolAllocBlock( CRIdPool *pool, GLuint count )
-{
-	FreeElem *f;
-	GLuint ret;
-
-	CRASSERT(count > 0);
-
-	f = pool->freeList;
-	while (f)
-	{
-		if (f->max - f->min + 1 >= (GLuint) count)
-		{
-			/* found a sufficiently large enough block */
-			ret = f->min;
-			f->min += count;
-
-			if (f->min == f->max)
-			{
-				/* remove this block from linked list */
-				if (f == pool->freeList) 
-				{
-					/* remove from head */
-					pool->freeList = pool->freeList->next;
-					pool->freeList->prev = NULL;
-				}
-				else 
-				{
-					/* remove from elsewhere */
-					f->prev->next = f->next;
-					f->next->prev = f->prev;
-				}
-				crFree(f);
-			}
-
-#ifdef DEBUG
-			/* make sure the IDs really are allocated */
-			{
-				GLuint i;
-				for (i = 0; i < count; i++)
-				{
-					CRASSERT(crIdPoolIsIdUsed(pool, ret + i));
-				}
-			}
-#endif
-
-			return ret;
-		}
-		else {
-			f = f->next;
-		}
-	}
-
-	/* failed to find free block */
-	return 0;
-}
-
-
-/*
- * Free a block of <count> IDs starting at <first>.
- */
-void crIdPoolFreeBlock( CRIdPool *pool, GLuint first, GLuint count )
-{
-	FreeElem *i;
-	FreeElem *newelem;
-
-	/*********************************/
-	/* Add the name to the freeList  */
-	/* Find the bracketing sequences */
-
-	for (i = pool->freeList; i && i->next && i->next->min < first; i = i->next)
-	{
-		/* EMPTY BODY */
-	}
-
-	/* j will always be valid */
-	if (!i)
-		return;
-	if (!i->next && i->max == first)
-		return;
-
-	/* Case:  j:(~,first-1) */
-	if (i->max + 1 == first) 
-	{
-		i->max += count;
-		if (i->next && i->max+1 >= i->next->min) 
-		{
-			/* Collapse */
-			i->next->min = i->min;
-			i->next->prev = i->prev;
-			if (i->prev)
-			{
-				i->prev->next = i->next;
-			}
-			if (i == pool->freeList)
-			{
-				pool->freeList = i->next;
-			}
-			crFree(i);
-		}
-		return;
-	}
-
-	/* Case: j->next: (first+1, ~) */
-	if (i->next && i->next->min - count == first) 
-	{
-		i->next->min -= count;
-		if (i->max + 1 >= i->next->min) 
-		{
-			/* Collapse */
-			i->next->min = i->min;
-			i->next->prev = i->prev;
-			if (i->prev)
-			{
-				i->prev->next = i->next;
-			}
-			if (i == pool->freeList) 
-			{
-				pool->freeList = i->next;
-			}
-			crFree(i);
-		}
-		return;
-	}
-
-	/* Case: j: (first+1, ~) j->next: null */
-	if (!i->next && i->min - count == first) 
-	{
-		i->min -= count;
-		return;
-	}
-
-	/* allocate a new FreeElem node */
-	newelem = (FreeElem *) crCalloc(sizeof(FreeElem));
-	newelem->min = first;
-	newelem->max = first + count - 1;
-
-	/* Case: j: (~,first-(2+))  j->next: (first+(2+), ~) or null */
-	if (first > i->max) 
-	{
-		newelem->prev = i;
-		newelem->next = i->next;
-		if (i->next)
-		{
-			i->next->prev = newelem;
-		}
-		i->next = newelem;
-		return;
-	}
-
-	/* Case: j: (first+(2+), ~) */
-	/* Can only happen if j = t->freeList! */
-	if (i == pool->freeList && i->min > first) 
-	{
-		newelem->next = i;
-		newelem->prev = i->prev;
-		i->prev = newelem;
-		pool->freeList = newelem;
-		return;
-	}
-}
-
-
-
-/*
- * Mark the given Id as being allocated.
- */
-void crIdPoolAllocId( CRIdPool *pool, GLuint id )
-{
-	FreeElem *f;
-
-	CRASSERT(id > 0);
-
-	f = pool->freeList;
-	while (f)
-	{
-		if (id >= f->min && id <= f->max)
-		{
-			/* found the block */
-			if (id == f->min)
-			{
-				f->min++;
-			}
-			else if (id == f->max)
-			{
-				f->max--;
-			}
-			else
-			{
-				/* somewhere in the middle - split the block */
-				FreeElem *newelem = (FreeElem *) crCalloc(sizeof(FreeElem));
-				newelem->min = id + 1;
-				newelem->max = f->max;
-				f->max = id - 1;
-				newelem->next = f->next;
-				if (f->next)
-				   f->next->prev = newelem;
-				newelem->prev = f;
-				f->next = newelem;
-			}
-			return;
-		}
-		f = f->next;
-	}
-
-	/* if we get here, the ID was already allocated - that's OK */
-}
-
-
-/*
- * Determine if the given id is free.  Return GL_TRUE if so.
- */
-GLboolean crIdPoolIsIdFree( const CRIdPool *pool, GLuint id )
-{
-	FreeElem *i;
-
-	/* First find which region it fits in */
-	for (i = pool->freeList; i && !(i->min <= id && id <= i->max); i=i->next)
-	{
-		/* EMPTY BODY */
-	}
-
-	if (i)
-		return GL_TRUE;
-	else
-		return GL_FALSE;
-}
-
-
-/*
- * Determine if the given id is used.  Return GL_TRUE if so.
- */
-GLboolean crIdPoolIsIdUsed( const CRIdPool *pool, GLuint id )
-{
-	return (GLboolean) !crIdPoolIsIdFree( pool, id);
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/libteac.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/libteac.c	(revision 78116)
+++ 	(revision )
@@ -1,1213 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/fcntl.h>
-#include <string.h>
-#include <time.h>
-
-#include "teac.h"
-
-/* Notes-
- * -Why is elan3_fini dropping core?  It's intermittent, and seems to
- *  depend on relative timing of multiple calls.
- */
-
-#ifdef CHROMIUM
-#include <cr_string.h>
-#include <cr_mem.h>
-#include <cr_error.h>
-#else
-#define crAlloc(sz) malloc(sz)
-#define crStrncpy(out,in,sz) strncpy(out,in,sz)
-#define crMemcpy(out,in,bytes) memcpy(out,in,bytes)
-#define crStrchr(instr,inchr) strchr(instr,inchr)
-#define crFree(ptr) free(ptr)
-#define crRealloc( pp, size ) { \
-  if (!(*pp=realloc(*pp,size))) { \
-    fprintf(stderr,"failed to reallocate %d bytes!\n",size); \
-    abort(); \
-  } \
-}
-#include <stdarg.h>
-static void crDebug( const char* fmt, ... ) { 
-  va_list ap;
-  va_start(ap,fmt);
-  vfprintf(stderr, fmt, ap); 
-  va_end(ap);
-}
-#endif
-
-#define EADDR_ALLOC_ELAN            0x200000
-#define ALLOC_ELAN_SIZE	            0x200000
-#define EADDR_ALLOC_MAIN            0x400000
-#define ALLOC_MAIN_SIZE	            0x2000000
-
-/* We need some defs to handle changes in structures between software
- * revisions.  
- */
-/* Capability shape is the same between KITE and pre-KITE */
-#ifdef ELAN_PRE_KITE
-
-/* software level is PRE_KITE */
-#define TEAC_DEVINFO_TYPE 0
-#define TEAC_CAP_TYPE 0
-
-#else
-#ifdef ELAN_PRE_EAGLE
-
-/* software level is KITE */
-
-#ifdef LINUX
-#define TEAC_DEVINFO_TYPE 1
-#define TEAC_CREATE_TYPE 1
-#else
-#define TEAC_DEVINFO_TYPE 0
-#define TEAC_CREATE_TYPE 0
-#endif
-#define TEAC_CAP_TYPE 1
-
-#else
-/* software level is EAGLE */
-#define TEAC_DEVINFO_TYPE 2
-#define TEAC_CAP_TYPE 2
-#define TEAC_CREATE_TYPE 2
-
-#endif
-#endif
-
-#if (TEAC_CAP_TYPE == 2)
-#define TEAC_CAP_ENTRIES(cap) ELAN_CAP_ENTRIES(cap)
-#else
-#define TEAC_CAP_ENTRIES(cap) (cap->Entries)
-#endif
-
-/* In the future we will use the bitwise AND of the rail masks */
-#define RAIL 0
-
-#ifndef HOST_TABLE_FILENAME
-#define HOST_TABLE_FILENAME "/usr/users/8/welling/elanstuff/teac/teac_host_map.t"
-#endif
-
-#define INITIAL_HOST_TABLE_SIZE 256
-
-static host_t* hosts= NULL; /* this one ends up sorted by host name */
-static int* hostsIndex= NULL; /* this is sorted by node ID */
-static sdramaddr_t* sdramAddrBase= NULL;
-static E3_Addr* elanAddrBase= NULL;
-
-static int nodeTablesInitialized= 0;
-static int nodeTableSize= 0;
-static int nodeCount= 0;
-
-static int read_node_map()
-{
-  FILE* f= NULL;
-  int i;
-  int iLine;
-  char buf[256];
-
-  if (hosts) crFree(hosts);
-  if (!(hosts= (host_t*)crAlloc(INITIAL_HOST_TABLE_SIZE*sizeof(host_t)))) {
-    fprintf(stderr,"libteac: read_node_map: unable to allocate %d bytes!\n",
-	    INITIAL_HOST_TABLE_SIZE*sizeof(host_t));
-    abort();
-  }
-  nodeTableSize= INITIAL_HOST_TABLE_SIZE;
-
-  if (!(f=fopen(HOST_TABLE_FILENAME,"r"))) {
-    fprintf(stderr,"libteac: read_node_map: cannot open <%s> for reading!\n",
-	    HOST_TABLE_FILENAME);
-    abort();
-  }
-
-  i= 0;
-  iLine= 0;
-  buf[sizeof(buf)-1]= '\0';
-  while (!feof(f) && !ferror(f)) {
-    char* tmp;
-    char* string;
-    if (!fgets(buf, sizeof(buf)-1, f)) break;
-    iLine++;
-    if (buf[0]=='#' || buf[0]=='\n' || buf[0]=='\0') continue;
-    if (i>=nodeTableSize) {
-      /* We need to grow the table */
-      int newSize= 2*nodeTableSize;
-      crRealloc((void**)&hosts,newSize*sizeof(host_t));
-      nodeTableSize= newSize;      
-    }
-    if (!(string=strtok_r(buf," ,;\t\n",&tmp))) {
-      fprintf(stderr,"libteac: read_node_map: Bad machine name at line %d of %s!\n",
-	      iLine, HOST_TABLE_FILENAME);
-      abort();
-    }
-    if (strlen(string)==0) continue; /* blank line */
-    hosts[i].name= strdup(string);
-
-    if (!(string=strtok_r(NULL," ,;\t\n",&tmp))) {
-      fprintf(stderr,"libteac: read_node_map: bad integer string at line %d of %s!\n",
-	      iLine, HOST_TABLE_FILENAME);
-      abort();
-    }
-    errno= 0;
-    hosts[i].railMask= atoi(string);
-    if (errno != 0) {
-      fprintf(stderr,"libteac: read_node_map: bad integer %s at %s line %d!\n",
-	      string, HOST_TABLE_FILENAME, iLine);
-      abort();
-    }
-
-    if (!(string=strtok_r(NULL," ,;\t\n",&tmp))) {
-      fprintf(stderr,"libteac: read_node_map: bad integer string at line %d of %s!\n",
-	      iLine, HOST_TABLE_FILENAME);
-      abort();
-    }
-    errno= 0;
-    hosts[i].id= atoi(string);
-    if (errno != 0) {
-      fprintf(stderr,"libteac: read_node_map: bad integer %s at %s line %d!\n",
-	      string, HOST_TABLE_FILENAME, iLine);
-      abort();
-    }
-
-    if (!(string=strtok_r(NULL," ,;\t\n",&tmp))) {
-      fprintf(stderr,"libteac: read_node_map: bad hex value at line %d of %s!\n",
-	      iLine, HOST_TABLE_FILENAME);
-      abort();
-    }
-    errno= 0;
-    hosts[i].sdramAddrBase= (sdramaddr_t)strtol(string, (char**)NULL, 0);
-    if (errno != 0) {
-      fprintf(stderr,"libteac: read_node_map: bad hex address %s at %s line %d!\n",
-	      string, HOST_TABLE_FILENAME, iLine);
-      abort();
-    }
-
-    if (!(string=strtok_r(NULL," ,;\t\n",&tmp))) {
-      fprintf(stderr,"libteac: read_node_map: bad hex value at line %d of %s!\n",
-	      iLine, HOST_TABLE_FILENAME);
-      abort();
-    }
-    errno= 0;
-    hosts[i].elanAddrBase= (E3_Addr)strtol(string, (char**)NULL, 0);
-    if (errno != 0) {
-      fprintf(stderr,"libteac: read_node_map: bad hex address %s at %s line %d!\n",
-	      string, HOST_TABLE_FILENAME, iLine);
-      abort();
-    }
-
-#if 0
-    crDebug("line %d: %d: got <%s> %d %d 0x%x 0x%x\n",
-	    iLine, i, hosts[i].name, hosts[i].railMask, hosts[i].id, 
-	    hosts[i].sdramAddrBase, hosts[i].elanAddrBase);
-#endif
-
-    i++;
-  }
-  if (ferror(f)) {
-    perror("Error reading host table");
-    fprintf(stderr,"libteac: read_node_map: error reading <%s>!\n",
-	    HOST_TABLE_FILENAME);
-    abort();
-  }
-
-  (void)fclose(f);
-  return i;
-}
-
-static int hostnameCompare(const void* h1, const void* h2)
-{
-  return strcmp(((host_t*)h1)->name, ((host_t*)h2)->name);
-}
-
-static int hostnameLookup(const void* h1, const void* h2)
-{
-  return strcmp((const char*)h1, ((host_t*)h2)->name);
-}
-
-static void initialize_node_tables()
-{
-  if (!nodeTablesInitialized) {
-    int nodeMin;
-    int nodeMax;
-    int nodeRange;
-    int i;
-
-    crDebug("Loading Quadrics network map from <%s>\n",HOST_TABLE_FILENAME);
-
-    /* Load information about Quadrics network */
-    nodeCount= read_node_map();
-    if (nodeCount==0) {
-      fprintf(stderr,
-	      "libteac: initialize_node_tables: no valid nodes in %s!\n",
-	      HOST_TABLE_FILENAME);
-      abort();
-    }
-
-    /* 
-     * Build the offset tables.  Offsets are looked up by node ID, so we
-     * have to avoid redundant IDs and order the tables correctly.
-     */
-    nodeMin= nodeMax= hosts[0].id;
-    for (i=1; i<nodeCount; i++) {
-      if (hosts[i].id<nodeMin) nodeMin= hosts[i].id;
-      if (hosts[i].id>nodeMax) nodeMax= hosts[i].id;
-    }
-    nodeRange= (nodeMax-nodeMin) + 1;
-    if (!(sdramAddrBase=(sdramaddr_t*)crAlloc(nodeRange*sizeof(sdramaddr_t)))) {
-      fprintf(stderr,
-	    "libteac: initialize_node_tables: unable to allocate %d bytes!\n",
-	      nodeRange*sizeof(sdramaddr_t));
-      abort();
-    }
-    if (!(elanAddrBase=(E3_Addr*)crAlloc(nodeRange*sizeof(E3_Addr)))) {
-      fprintf(stderr,
-	    "libteac: initialize_node_tables: unable to allocate %d bytes!\n",
-	      nodeRange*sizeof(E3_Addr));
-      abort();
-    }
-    for (i=0; i<nodeRange; i++) {
-      sdramAddrBase[i]= (sdramaddr_t)0;
-      elanAddrBase[i]= (E3_Addr)0;
-    }
-    for (i=0; i<nodeCount; i++) {
-      sdramAddrBase[hosts[i].id]= hosts[i].sdramAddrBase;
-      elanAddrBase[hosts[i].id]= hosts[i].elanAddrBase;
-    }
-
-    /* Sort the host table alphabetically by host name for faster lookup */
-    qsort( hosts, nodeCount, sizeof(host_t), hostnameCompare );
-
-    /* Build an ordered index into the hosts table */
-    if (hostsIndex) crFree(hostsIndex);
-    if (!(hostsIndex= (int*)crAlloc(nodeRange*sizeof(int)))) {
-      fprintf(stderr,"libteac: read_node_map: unable to allocate %d bytes!\n",
-	      nodeCount*sizeof(int));
-      abort();
-    }
-    for (i=0; i<nodeRange; i++) hostsIndex[i]= 0;
-    for (i=0; i<nodeCount; i++) hostsIndex[hosts[i].id]= i;
-
-    nodeTablesInitialized= 1;
-  }
-}
-
-static int trans_host(const char *hn)  {
-  host_t* h= NULL;
-
-  if (!nodeTablesInitialized) initialize_node_tables();
-
-#if 0
-  char buf[128];
-  int i;
-  i= 0;
-  while (i<sizeof(buf)-1 && hn[i] && hn[i]!='.') { buf[i]= hn[i]; i++; };
-  buf[i]= '\0';
-#endif
-
-  h=(host_t*)bsearch(hn, hosts, nodeCount, sizeof(host_t), hostnameLookup);
-#if 0
-  if (h) {
-    crDebug("Lookup <%s> got <%s> <%d> <%x> <%x>\n",
-	    hn,h->name,h->id,(int)h->sdramAddrBase,(int)h->elanAddrBase);
-  }
-  else fprintf(stderr,"Lookup <%s> returned NULL!\n",hn);
-#endif
-  if (h) return h->id;
-  else return -1;
-}
-
-/*
- * A version of address translation with some safety checks
- */
-static E3_Addr teac_main2elan( ELAN3_CTX *ctx, void* main_addr )
-{
-  E3_Addr result= elan3_main2elan(ctx,main_addr);
-  /*
-  crDebug("mapping %0lx -> %d; addressable %d\n",
-	  main_addr,result,elan3_addressable(ctx,main_addr,64));
-  */
-  if (result==ELAN_BAD_ADDR) {
-    fprintf(stderr,"Address translation error: %0x has no elan equivalent\n",
-	    (int)main_addr);
-    abort();
-  }
-  return result;
-}
-
-Tcomm *teac_Init(char *lh, char *hh, int lctx, int hctx, int myrank, 
-		 const unsigned char key[TEAC_KEY_SIZE])
-{
-#if (TEAC_DEVINFO_TYPE == 2)
-  ELAN_DEVINFO info;
-  ELAN_POSITION position;
-#else
-  ELAN3_DEVINFO	info;
-#endif
-  ELAN_CAPABILITY *cap;
-  Tcomm* result= NULL;
-  int i;
-  int j;
-  int a;
-  int b;
-  char buf[256];
-  char* here;
-#if ( TEAC_CREATE_TYPE == 0 )
-  void* control;
-#endif
-
-  if (!nodeTablesInitialized) initialize_node_tables();
-
-  if (!(result= (Tcomm*)crAlloc(sizeof(Tcomm)))) {
-    fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n",
-	    sizeof(Tcomm));
-    return(NULL);
-  }
-  result->ctx = NULL;
-  result->dma = NULL;
-  result->e_dma = 0;
-  result->s_event = 0;
-  result->r_event = NULL;
-  for (i=0; i<NUM_SEND_BUFFERS; i++) result->sbuf_pull_event[i] = 0;
-  result->rbuf_pull_event = 0;
-  result->m_snd = NULL;
-  result->m_rcv = NULL;
-  for (i=0; i<NUM_SEND_BUFFERS; i++) result->sbuf_ready[i]= NULL;
-  result->rbuf_ready = NULL;
-  result->mbuff= NULL;
-  for (i=0; i<NUM_SEND_BUFFERS; i++) result->sendWrappers[i]= NULL;
-  result->vp = -1;
-  result->hhost = result->lhost = -1;
-  result->hctx = result->lctx = -1;
-  result->msgnum = 0;
-  result->poll_shift = 0;
-  result->totalSendBufferBytesAllocated= 0;
-  result->totalRecvBufferBytesAllocated= 0;
-      
-  a = trans_host(lh);
-  b = trans_host(hh);
-  result->lhost = (a < b)? a : b;
-  result->hhost = (a > b) ? a : b;
-  
-  result->lctx = (lctx<hctx) ? lctx : hctx;
-  result->hctx = (hctx>lctx) ? hctx : lctx;
-  
-  cap = &(result->cap);
-#if (TEAC_CAP_TYPE == 2)
-  elan_nullcap(cap);
-  /* Initialize the UserKey to the given value */
-  crMemcpy((void*)&(cap->cap_userkey.key_values),key,TEAC_KEY_SIZE);
-  cap->cap_lowcontext = lctx;
-  cap->cap_mycontext = lctx + (myrank%4);
-  cap->cap_highcontext = hctx;
-  cap->cap_lownode = result->lhost;
-  cap->cap_highnode = result->hhost;
-  cap->cap_type = 
-    ELAN_CAP_TYPE_BLOCK | ELAN_CAP_TYPE_NO_BITMAP | ELAN_CAP_TYPE_MULTI_RAIL;
-#else
-  elan3_nullcap(cap);
-  /* Initialize the UserKey to the given value */
-  crMemcpy((void*)&(cap->UserKey),key,TEAC_KEY_SIZE);
-  cap->LowContext = lctx;
-  cap->MyContext = lctx + (myrank%4);
-  cap->HighContext = hctx;
-  cap->LowNode = result->lhost;
-  cap->HighNode = result->hhost;
-  cap->Entries = (hctx - lctx + 1) * (cap->HighNode - cap->LowNode + 1);
-  cap->Type = 
-    ELAN_CAP_TYPE_BLOCK | ELAN_CAP_TYPE_NO_BITMAP | ELAN_CAP_TYPE_MULTI_RAIL;
-#endif
-  
-  if ((result->ctx = elan3_init( 0, EADDR_ALLOC_MAIN, ALLOC_MAIN_SIZE, 
-				 EADDR_ALLOC_ELAN, ALLOC_ELAN_SIZE))
-      == NULL)  {
-    fprintf(stderr, "teac_Init: elan3_init returned NULL context\n");
-    return(NULL);
-  }
-  elan3_block_inputter (result->ctx, 1);
-  
-#if ( TEAC_CREATE_TYPE == 0 )
-  if ((control = elan3_control_open (RAIL)) != NULL)  {
-    if (elan3_create(control, &(result->cap)))  {
-      crDebug("elan3_create failed with <%s>, but that's OK!\n",
-	      strerror(errno));
-      errno= 0;
-    }
-  }  
-  else  {
-    perror("elan3_control_open failed");
-    teac_Close(result);
-    return NULL;
-  }                                                                       
-#elif ( TEAC_CREATE_TYPE == 1 )
-  if (elan3_create(result->ctx, &(result->cap)))  {
-    crDebug("elan3_create failed with <%s>, but that's OK!\n",
-	    strerror(errno));
-    errno= 0;
-  }
-#else
-  /* I don't think we have to do anything here! */
-#endif
-
-#if (TEAC_DEVINFO_TYPE == 2)
-  (void)elan3_get_devinfo(result->ctx, &info);
-  (void)elan3_get_position(result->ctx, &position);
-  crDebug("Position mode %d, NodeID %d, NumNodes %d, NumLevels %d\n",
-	  position.pos_mode,position.pos_nodeid, position.pos_nodes,
-	  position.pos_levels);
-  if (position.pos_mode != ELAN_POS_MODE_SWITCHED)
-    crDebug("WARNING: position mode is not %d!\n",ELAN_POS_MODE_SWITCHED);
-  crDebug("Rail %d\n",info.dev_rail);
-#elif (TEAC_DEVINFO_TYPE == 1)
-  elan3_devinfo(0, &info);
-  crDebug("NodeId: %d, NumNodes: %d, NumLevels: %d, NodeLevel: %d\n",
-	  info.Position.NodeId, info.Position.NumNodes, 
-	  info.Position.NumLevels, info.Position.NodeLevel);
-#else
-  elan3_devinfo(0, &info);
-  crDebug("NodeId: %d, NumLevels: %d, NodeLevel: %d\n",
-	  info.NodeId, info.NumLevels, info.NodeLevel);
-#endif
-
-#if 0
-  {
-    static char junkString[256];
-#if (TEAC_CAP_TYPE == 2)
-    crDebug("Capability: <%s>\n",
-	    elan_capability_string(&(result->cap),junkString));
-    crDebug("railmask is %d\n",result->cap.cap_railmask);
-    crDebug("bitmap is %x\n",result->cap.cap_bitmap[0]);
-#else
-  crDebug("Capability: <%s>\n",
-	  elan3_capability_string(&(result->cap),junkString));
-  crDebug("railmask is %d\n",result->cap.RailMask);
-  crDebug("bitmap is %x\n",result->cap.Bitmap[0]);
-#endif
-  }
-#endif
-
-  /* Reality check. */
-  if (gethostname(buf,sizeof(buf)-1)) {
-    perror("Can't get my own host name");
-    teac_Close(result);
-    return NULL;
-  }
-  if ((here= crStrchr(buf,'.')) != NULL) *here= '\0';
-
-#if (TEAC_DEVINFO_TYPE == 2)
-  if (trans_host(buf) != (int)position.pos_nodeid) {
-    fprintf(stderr,
- "teac_Init: Expected Quadrics port id %d does not match real value %d!\n",
-	    trans_host(buf), position.pos_nodeid);
-    teac_Close(result);
-    return NULL;
-  }
-#elif (TEAC_DEVINFO_TYPE == 1)
-  if (trans_host(buf) != info.Position.NodeId) {
-    fprintf(stderr,
- "teac_Init: Expected Quadrics port id %d does not match real value %d!\n",
-	    trans_host(buf), info.Position.NodeId);
-    teac_Close(result);
-    return NULL;
-  }
-#else
-  if (trans_host(buf) != info.NodeId) {
-    fprintf(stderr,
- "teac_Init: Expected Quadrics port id %d does not match real value %d!\n",
-	    trans_host(buf), info.NodeId);
-    teac_Close(result);
-    return NULL;
-  }
-#endif
-
-  if (elan3_attach(result->ctx, &(result->cap)))  {
-    fprintf(stderr, "teac_Init: elan3_attach failed\n");
-    teac_Close(result);
-    return(NULL);
-  }
-
-  if (elan3_addvp(result->ctx, 0, &(result->cap)))  {
-    fprintf(stderr, "teac_Init: elan3_addvp failed\n");
-    teac_Close(result);
-    return(NULL);
-  }
-  
-  result->vp = elan3_process(result->ctx);
-  
-  if (! elan3_set_required_mappings (result->ctx))  {
-    fprintf(stderr, "teac_Init: elan3_set_required_mappings failed\n");
-    teac_Close(result);
-    return(NULL);
-  }
-  
-  if (!(result->r_event= 
-	(sdramaddr_t**)crAlloc( TEAC_CAP_ENTRIES(cap)*sizeof(sdramaddr_t*) ))) {
-    fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n",
-	    TEAC_CAP_ENTRIES(cap)*sizeof(sdramaddr_t*));
-    teac_Close(result);
-    return(NULL);
-  }
-  if (!(result->r_event[0]=
-	(sdramaddr_t*)crAlloc( TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS
-			      * sizeof(sdramaddr_t) ))) {
-    fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n",
-	    TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS*sizeof(sdramaddr_t));
-    teac_Close(result);
-    return(NULL);
-  }
-  if (!(result->r_event[0][0]=
-	elan3_allocElan(result->ctx, E3_EVENT_ALIGN, 
-		TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS*sizeof(E3_BlockCopyEvent)))) {
-    perror("teac_Init: elan3_allocElan failed for r_event block");
-    teac_Close(result);
-    return(NULL);
-  }
-  for (j=1; j<TEAC_CAP_ENTRIES(cap); j++) {
-    result->r_event[j]= result->r_event[0] + j*NUM_SEND_BUFFERS;
-    result->r_event[j][0]= 
-      result->r_event[0][0]+j*NUM_SEND_BUFFERS*sizeof(E3_BlockCopyEvent);
-  }
-  for (j=0; j<TEAC_CAP_ENTRIES(cap); j++) 
-    for (i=1; i<NUM_SEND_BUFFERS; i++) {
-      result->r_event[j][i]= 
-	result->r_event[j][0] + i*sizeof(E3_BlockCopyEvent);
-    }
-#if 0
-  crDebug("r_event[0][0] is %x\n",(int)result->r_event[0][0]);
-#endif
-
-  if (!(result->m_rcv= 
-	(volatile E3_uint32**)crAlloc( TEAC_CAP_ENTRIES(cap)*sizeof(E3_uint32*) ))) {
-    fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n",
-	    TEAC_CAP_ENTRIES(cap)*sizeof(E3_uint32*));
-    teac_Close(result);
-    return(NULL);
-  }
-  if (!(result->m_rcv[0]= (volatile E3_uint32*)
-	elan3_allocMain(result->ctx, 0, 
-			TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS*sizeof(E3_uint32)))) {
-    perror("teac_Init: elan3_allocMain failed for m_rcv block");
-    teac_Close(result);
-    return(NULL);
-  }
-  for (i=1; i<TEAC_CAP_ENTRIES(cap); i++)
-    result->m_rcv[i]= result->m_rcv[0] + i*NUM_SEND_BUFFERS;
-#if 0
-  crDebug("Base of m_rcv is %lx -> %lx\n",
-	  (long)(result->m_rcv[0]),
-	  (long)teac_main2elan(result->ctx,(void*)(result->m_rcv[0])));
-#endif
-  
-  if (!(result->mbuff= (teacMsg**)crAlloc( TEAC_CAP_ENTRIES(cap)*sizeof(teacMsg*) ))) {
-    fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n",
-	    TEAC_CAP_ENTRIES(cap)*sizeof(teacMsg*));
-    teac_Close(result);
-    return(NULL);
-  }
-  if (!(result->mbuff[0]= (teacMsg*)
-	elan3_allocMain(result->ctx, 8, 
-			TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS*sizeof(teacMsg)))) {
-    perror("teac_Init: elan3_allocMain failed for mbuff block");
-    teac_Close(result);
-    return(NULL);
-  }
-  for (i=1; i<TEAC_CAP_ENTRIES(cap); i++)
-    result->mbuff[i]= result->mbuff[0] + i*NUM_SEND_BUFFERS;
-#if 0
-  crDebug("Base of mbuff is %lx -> %lx\n",
-	  (long)(result->mbuff[0]), 
-	  (long)teac_main2elan(result->ctx,result->mbuff[0]));
-#endif
-  
-  if (!(result->dma= (E3_DMA_MAIN *)
-	elan3_allocMain(result->ctx, 
-			E3_DMA_ALIGN, sizeof(E3_DMA_MAIN)))) {
-    perror("teac_Init: elan3_allocMain failed for dma");
-    teac_Close(result);
-    return(NULL);
-  }
-  
-  if (!(result->e_dma= 
-	elan3_allocElan(result->ctx, E3_DMA_ALIGN, sizeof(E3_DMA)))) {
-    perror("teac_Init: elan3_allocElan failed for e_dma");
-    teac_Close(result);
-    return(NULL);
-  }
-  
-  if (!(result->s_event= 
-	elan3_allocElan(result->ctx, E3_EVENT_ALIGN, 
-			sizeof(E3_BlockCopyEvent)))) {
-    perror("teac_Init: elan3_allocElan failed for s_event");
-    teac_Close(result);
-    return(NULL);
-  }
-#if 0
-  crDebug("s_event is %x\n",(int)result->s_event);
-#endif
-  
-  if (!(result->sbuf_pull_event[0]= 
-	elan3_allocElan(result->ctx, E3_EVENT_ALIGN, 
-			NUM_SEND_BUFFERS*sizeof(E3_BlockCopyEvent)))) {
-    perror("teac_Init: elan3_allocElan failed for sbuf_pull_event block");
-    teac_Close(result);
-    return(NULL);
-  }
-  for (i=1; i<NUM_SEND_BUFFERS; i++) 
-    result->sbuf_pull_event[i]= 
-      result->sbuf_pull_event[0]+i*sizeof(E3_BlockCopyEvent);
-  
-  if (!(result->rbuf_pull_event= 
-	elan3_allocElan(result->ctx, E3_EVENT_ALIGN, 
-			sizeof(E3_BlockCopyEvent)))) {
-    perror("teac_Init: elan3_allocElan failed for rbuf_pull_event");
-    teac_Close(result);
-    return(NULL);
-  }
-  
-  if (!(result->m_snd= (E3_uint32 *)
-	elan3_allocMain(result->ctx, 0, 
-			sizeof(E3_uint32)))) {
-    perror("teac_Init: elan3_allocMain failed for m_snd");
-    teac_Close(result);
-    return(NULL);
-  }
-
-  if (!(result->sbuf_ready[0]= (E3_uint32 *)
-	elan3_allocMain(result->ctx, 0, 
-			NUM_SEND_BUFFERS*sizeof(E3_uint32)))) {
-    perror("teac_Init: elan3_allocMain failed for sbuf_ready block");
-    teac_Close(result);
-    return(NULL);
-  }
-  for (i=1; i<NUM_SEND_BUFFERS; i++)
-    result->sbuf_ready[i]= result->sbuf_ready[0] + i;
-  
-  if (!(result->sendWrappers[0]= 
-	(SBuffer*)crAlloc(NUM_SEND_BUFFERS*sizeof(SBuffer)))) {
-    fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n",
-	    NUM_SEND_BUFFERS*sizeof(SBuffer));
-    teac_Close(result);
-    return(NULL);
-  }
-  for (i=1; i<NUM_SEND_BUFFERS; i++)
-    result->sendWrappers[i]= result->sendWrappers[0] + i;
-
-  if (!(result->rbuf_ready= (E3_uint32 *)
-	elan3_allocMain(result->ctx, 0, 
-			sizeof(E3_uint32)))) {
-    perror("teac_Init: elan3_allocMain failed for rbuf_ready");
-    teac_Close(result);
-    return(NULL);
-  }
-
-  for (i=0; i<NUM_SEND_BUFFERS; i++) {
-    char* buf;
-    if (!(buf= (char*)elan3_allocMain(result->ctx, 8, 
-				      E_BUFFER_INITIAL_SIZE))) {
-      perror("teac_Init: elan3_allocMain failed for buffer block");
-      teac_Close(result);
-      return(NULL);
-    }
-    result->sendWrappers[i]->bufId= i;
-    result->sendWrappers[i]->totSize= E_BUFFER_INITIAL_SIZE;
-    result->sendWrappers[i]->validSize= 0;
-    result->sendWrappers[i]->buf= buf;
-    result->totalSendBufferBytesAllocated += result->sendWrappers[i]->totSize; 
-  }
-  
-  elan3_initevent_word (result->ctx, 
-			result->s_event, result->m_snd);
-  elan3_initevent_word (result->ctx, 
-			result->rbuf_pull_event, result->rbuf_ready);
-  
-  for (i=0; i<NUM_SEND_BUFFERS; i++) {
-    elan3_initevent_word (result->ctx, 
-			  result->sbuf_pull_event[i], result->sbuf_ready[i]);
-  }
-
-  for (j=0; j<TEAC_CAP_ENTRIES(cap); j++) 
-    for (i=0; i<NUM_SEND_BUFFERS; i++) {
-      elan3_initevent_word (result->ctx, 
-			    result->r_event[j][i], &(result->m_rcv[j][i]));
-    }
-  
-  /* Get the message receive events ready to fire, in case something
-   * comes in before receive gets called.
-   */
-  for (j=0; j<TEAC_CAP_ENTRIES(cap); j++)
-    for (i=0; i<NUM_SEND_BUFFERS; i++) {
-      elan3_primeevent(result->ctx, result->r_event[j][i], 1);
-    }
-
-  /* Fire the sbuffer free events, so that the buffers look free when 
-   * the first call to send happens.
-   */
-  for (i=0; i<NUM_SEND_BUFFERS; i++) {
-    elan3_primeevent(result->ctx, result->sbuf_pull_event[i], 1);
-    elan3_setevent( result->ctx, result->sbuf_pull_event[i] );
-  }
-  
-  /* And now we're ready to face the world. */
-  elan3_block_inputter (result->ctx, 0);
-  
-  return(result);
-}
-  
-void teac_Close(Tcomm *tcomm)
-{
-  int i;
-
-  if (tcomm) {
-    /* First we have to wait until all pending messages have been
-     * pulled (assuming they got initialized in the first place).
-     */
-    if ((tcomm->sbuf_pull_event[0] != 0) && (tcomm->sbuf_ready[0] != NULL)) {
-      for (i=0; i<NUM_SEND_BUFFERS; i++) {
-	elan3_waitevent_word(tcomm->ctx, tcomm->sbuf_pull_event[i],
-			     tcomm->sbuf_ready[i], 10);
-      }
-      crDebug("All TEAC messages have reported home!\n");
-    }
-    elan3_block_inputter (tcomm->ctx, 1);
-
-    if (tcomm->e_dma != 0) elan3_freeElan(tcomm->ctx, tcomm->e_dma);
-    if (tcomm->s_event != 0) elan3_freeElan(tcomm->ctx, tcomm->s_event);
-    if (tcomm->r_event != NULL) {
-      if (tcomm->r_event[0] != NULL) {
-	if (tcomm->r_event[0][0] != 0) elan3_freeElan(tcomm->ctx, 
-						      tcomm->r_event[0][0]);
-	crFree(tcomm->r_event[0]);
-      }
-      crFree(tcomm->r_event);
-    }
-    if (tcomm->sbuf_pull_event[0] != 0) 
-      elan3_freeElan(tcomm->ctx, tcomm->sbuf_pull_event[0]);
-    if (tcomm->sendWrappers[0] != NULL) {
-      for (i=0; i<NUM_SEND_BUFFERS; i++) {
-	if (tcomm->sendWrappers[i]->buf != NULL) {
-	  elan3_free(tcomm->ctx, tcomm->sendWrappers[i]->buf);
-	  tcomm->totalSendBufferBytesAllocated -= 
-	    tcomm->sendWrappers[i]->totSize;
-	}
-      }
-      crFree(tcomm->sendWrappers[0]);
-    }
-    if (tcomm->rbuf_pull_event != 0) 
-      elan3_freeElan(tcomm->ctx, tcomm->rbuf_pull_event);
-    if (tcomm->m_snd != NULL) elan3_free(tcomm->ctx, 
-					 (E3_uint32*)tcomm->m_snd);
-    if (tcomm->m_rcv != NULL) {
-      if (tcomm->m_rcv[0] != NULL) elan3_free(tcomm->ctx,
-					      (E3_uint32*)tcomm->m_rcv[0]);
-      crFree(tcomm->m_rcv);
-    }
-    if (tcomm->sbuf_ready[0] != NULL) 
-      elan3_free(tcomm->ctx, (E3_uint32*)tcomm->sbuf_ready[0]);
-    if (tcomm->rbuf_ready != NULL) elan3_free(tcomm->ctx, 
-					    (E3_uint32*)tcomm->rbuf_ready);
-    if (tcomm->mbuff != NULL) {
-      if (tcomm->mbuff[0] != NULL) elan3_free(tcomm->ctx, tcomm->mbuff[0]);
-      crFree(tcomm->mbuff);
-    }
-#if (TEAC_CREATE_TYPE==2)
-    elan3_detach(tcomm->ctx);
-    elan3_fini(tcomm->ctx);
-#else
-    /* elan3_detach and elan3_destroy seem to crash sometimes in 
-     * these versions. 
-     */
-#endif
-  }
-}
-
-int teac_Select(Tcomm* tcomm, int *ids, int num_ids, int timeout)
-{
-  int id;
-  while (timeout-- > 0) {
-    if ((id= teac_Poll(tcomm, ids, num_ids)) >= 0) return id;
-  }
-
-  return -1;
-}
-
-int teac_Poll(Tcomm* tcomm, int *ids, int num_ids)
-{
-  int i;
-  int j;
-
-  for (j=0; j<num_ids; j++) {
-    int index= (j+tcomm->poll_shift) % num_ids;
-    int thisId= ids[index];
-    for (i=0; i<NUM_SEND_BUFFERS; i++) {
-      if (elan3_pollevent_word(tcomm->ctx, &(tcomm->m_rcv[thisId][i]), 1)) {
-#ifdef never
-	tcomm->poll_shift= index;
-#endif
-	return thisId;
-      }
-    }
-  }
-  
-  return -1;
-}
-
-int teac_sendBufferAvailable(Tcomm* tcomm)
-{
-  int i;
-  for (i=0; i<NUM_SEND_BUFFERS; i++) {
-    if (elan3_pollevent_word(tcomm->ctx, tcomm->sbuf_ready[i], 1))
-      return 1;
-  }
-  return 0;
-}
-
-SBuffer* teac_getSendBuffer( Tcomm* tcomm, long size )
-{
-  /* Find a free send buffer.  We'll busy wait in this poll loop
-   * if necessary.
-   */
-  int i= 0;
-  while (1) {
-    if (elan3_pollevent_word(tcomm->ctx, tcomm->sbuf_ready[i],
-			     1)) break;
-    if (++i == NUM_SEND_BUFFERS) i= 0;
-  }
-  /* We will use this buffer! */
-#if 0
-  crDebug("Allocated message buffer %d\n",i);
-#endif
-  *(tcomm->sbuf_ready[i])= 0; /* mark it busy */
-
-  /* If the associated chunk of memory is smaller than that requested,
-   * replace it with something larger.
-   */
-  if (tcomm->sendWrappers[i]->totSize < size) {
-    tcomm->totalSendBufferBytesAllocated -= tcomm->sendWrappers[i]->totSize;
-    elan3_free( tcomm->ctx, tcomm->sendWrappers[i]->buf );
-    if (!(tcomm->sendWrappers[i]->buf= 
-	  (char*)elan3_allocMain(tcomm->ctx, 8, size))) {
-      perror("teac_getSendBuffer: failed to grow send buffer");
-      exit(-1);
-    }
-    tcomm->totalSendBufferBytesAllocated += size;
-  }
-  tcomm->sendWrappers[i]->totSize= size;
-  tcomm->sendWrappers[i]->validSize= 0;
-  return tcomm->sendWrappers[i];
-}
-
-SBuffer* teac_getUnreadySendBuffer( Tcomm* tcomm, long size )
-{
-  SBuffer* result= NULL;
-  if (!(result= (SBuffer*)crAlloc(sizeof(SBuffer)))) {
-    fprintf(stderr,"libteac: read_node_map: unable to allocate %d bytes!\n",
-	    sizeof(SBuffer));
-    abort();
-  }
-  result->bufId= -1; /* this marks it unready */
-#if 0
-  crDebug("Allocated an unready message buffer!\n");
-#endif
-  
-  /* Allocate some DMA-able memory */
-  if (!(result->buf= (char*)elan3_allocMain(tcomm->ctx, 8, size))) {
-    perror("teac_getUnreadySendBuffer: failed to allocate elan3 memory");
-    exit(-1);
-  }
-  result->totSize= size;
-  result->validSize= 0;
-  tcomm->totalSendBufferBytesAllocated += result->totSize;
-
-  return result;
-}
-
-SBuffer* teac_makeSendBufferReady( Tcomm* tcomm, SBuffer* buf )
-{
-  int i= 0;
-  /* If the input buffer is already ready, just return it */
-  if (buf->bufId >= 0 && buf->bufId<NUM_SEND_BUFFERS) return buf;
-
-  /* Find a free send buffer.  We'll busy wait in this poll loop
-   * if necessary.
-   */
-  while (1) {
-    if (elan3_pollevent_word(tcomm->ctx, tcomm->sbuf_ready[i],
-			     1)) break;
-    if (++i == NUM_SEND_BUFFERS) i= 0;
-  }
-  /* We will use this buffer! */
-#if 0
-  crDebug("Allocated message buffer %d in makeSendBufferReady\n",i);
-#endif
-  *(tcomm->sbuf_ready[i])= 0; /* mark it busy */
-
-  /* Substitute the unready payload for the old payload */
-  tcomm->totalSendBufferBytesAllocated -= tcomm->sendWrappers[i]->totSize;
-  elan3_free( tcomm->ctx, tcomm->sendWrappers[i]->buf );
-  tcomm->sendWrappers[i]->buf= buf->buf;
-  
-  tcomm->sendWrappers[i]->totSize= buf->totSize;
-  tcomm->sendWrappers[i]->validSize= buf->validSize;
-  crFree(buf);
-  return tcomm->sendWrappers[i];
-  
-}
-
-int teac_Send( Tcomm* tcomm, int* ids, int num_ids, SBuffer* buf, void *start )
-{
-  int	vp = tcomm->vp;
-  int	iBuf;
-  int   iDest;
-  teacMsg *msg;
-
-  /* Complain loudly if this is an unready buffer */
-  if (buf->bufId==-1) {
-    fprintf(stderr,"teac_Send: tried to send an unready buffer!\n");
-    return 0;
-  }
-
-  /* Reality check: is this one of my buffers? */
-  if (buf->bufId<0 || buf->bufId>=NUM_SEND_BUFFERS) {
-    fprintf(stderr,"teac_Send: I don't know this buffer!\n");
-    return 0;
-  }
-
-  /* Reality check: did they write too much into the message? */
-  if (buf->validSize > buf->totSize) {
-    fprintf(stderr,"teac_Send: message too large! (%ld vs %ld)\n",
-	    buf->validSize, buf->totSize);
-    abort();
-    return 0;
-  }
-
-  iBuf= buf->bufId;
-  msg = &(tcomm->mbuff[vp][iBuf]);
-  msg->msgnum = tcomm->msgnum++;
-  msg->size = buf->validSize;
-  msg->host = vp;
-  if ( start != NULL )
-	  msg->mptr = teac_main2elan( tcomm->ctx, start );
-  else
-  	msg->mptr = teac_main2elan(tcomm->ctx, buf->buf);
-  msg->clr_event = elan3_sdram2elan(tcomm->ctx, tcomm->ctx->sdram,
-				    tcomm->sbuf_pull_event[iBuf]);
-  msg->new= 1;
-  
-  /* Set up the parts of the DMA that are not specific to destination */
-  tcomm->dma->dma_type = E3_DMA_TYPE(DMA_BYTE,DMA_WRITE,DMA_NORMAL,0);
-  tcomm->dma->dma_size = sizeof(teacMsg);
-  tcomm->dma->dma_srcEvent = 
-    elan3_sdram2elan(tcomm->ctx,tcomm->ctx->sdram,tcomm->s_event);
-  tcomm->dma->dma_source = teac_main2elan(tcomm->ctx, msg);
-  elan3_primeevent(tcomm->ctx, tcomm->sbuf_pull_event[buf->bufId], num_ids);
-
-  /* Send this message off to each destination */
-  for (iDest=0; iDest<num_ids; iDest++) {
-    tcomm->dma->dma_srcCookieVProc = 
-      elan3_local_cookie(tcomm->ctx, vp, ids[iDest]);
-    tcomm->dma->dma_destCookieVProc = ids[iDest];
-    tcomm->dma->dma_destEvent = 
-      elan3_sdram2elan(tcomm->ctx,tcomm->ctx->sdram,
-		       tcomm->r_event[vp][iBuf])
-      + sdramAddrBase[(ids[iDest]/NUM_SEND_BUFFERS) + tcomm->lhost] 
-      - sdramAddrBase[(vp/NUM_SEND_BUFFERS) + tcomm->lhost];
-    tcomm->dma->dma_dest = teac_main2elan(tcomm->ctx, msg)
-      + elanAddrBase[(ids[iDest]/NUM_SEND_BUFFERS) + tcomm->lhost] 
-      - elanAddrBase[(vp/NUM_SEND_BUFFERS) + tcomm->lhost];
-    elan3_primeevent(tcomm->ctx, tcomm->s_event, 1);
-    *(tcomm->m_snd)= 0;
-    elan3_putdma_main(tcomm->ctx, tcomm->dma, tcomm->e_dma);
-#if 0
-    crDebug("DMA dest event %x, dest mem %lx\n",
-	    tcomm->dma->dma_destEvent, 
-	    (long)tcomm->dma->dma_dest);
-    crDebug("Mem shifts are %x %x based on %d %d\n",
-	    elanAddrBase[(ids[iDest]/NUM_SEND_BUFFERS) + tcomm->lhost],
-	    elanAddrBase[(vp/NUM_SEND_BUFFERS) + tcomm->lhost],
-	    ids[iDest],vp);
-    crDebug("Send msg %d in buffer %d to %d (list index %d)...",
-	    msg->msgnum,iBuf, ids[iDest],iDest);
-#endif
-    elan3_waitevent_word(tcomm->ctx,
-			 tcomm->s_event, tcomm->m_snd, ELAN_WAIT_EVENT);
-#if 0
-    crDebug("message away!\n");
-#endif
-  }
-  return 1;
-}
-
-RBuffer* teac_Recv(Tcomm* tcomm, int id)
-{
-  int	vp = tcomm->vp;
-  RBuffer* result= NULL;
-  int iEvent= 0;
-  int iBuf= 0;
-  int i;
-  int lowestMsgnum;
-  
-  /* poll until we get an incoming message from the given sender */
-  while (1) {
-    if (elan3_pollevent_word(tcomm->ctx, &(tcomm->m_rcv[id][iEvent]), 1)) 
-      break;
-    if (++iEvent == NUM_SEND_BUFFERS) iEvent= 0;
-  }
-
-  /* This may not be the earliest event, however. */
-  lowestMsgnum= -1;
-  for (i=0; i<NUM_SEND_BUFFERS; i++) {
-#if 0
-    crDebug("Testing for new msg at %lx -> %lx\n",
-	    (long)&(tcomm->mbuff[id][i]), 
-	    (long)teac_main2elan(tcomm->ctx,(void*)(&tcomm->mbuff[id][i])));
-#endif
-    if (tcomm->mbuff[id][i].new) {
-      if ((lowestMsgnum < 0) 
-	  || (tcomm->mbuff[id][i].msgnum < (E3_uint32)lowestMsgnum)) {
-	lowestMsgnum= tcomm->mbuff[id][i].msgnum;
-	iBuf= i;
-      }
-    }
-  }
-  if (lowestMsgnum<0) {
-    fprintf(stderr,
-	    "teac_Recv: internal error: can't find message I just got!\n");
-    return NULL;
-  }
-  tcomm->mbuff[id][iBuf].new= 0; 
-  tcomm->m_rcv[id][iBuf]= 0;
-  elan3_primeevent(tcomm->ctx, tcomm->r_event[id][iBuf],1);
-#if 0
-  crDebug("got msg %d in buffer %d from %d!\n",
-	  tcomm->mbuff[id][iBuf].msgnum, iBuf, id);
-#endif
-
-  /* Make some space to put the message when it arrives */
-  if (!(result= (RBuffer*)crAlloc(sizeof(RBuffer)))) {
-    fprintf(stderr,"teac_Recv: unable to allocate %d bytes!\n",
-	    sizeof(RBuffer));
-    return NULL;
-  }
-#if 0
-  if (!(result->buf= (void*)elan3_allocMain(tcomm->ctx, 8,E_BUFFER_SIZE))) {
-    perror("teac_Recv: elan3_allocMain failed for buffer");
-    return(NULL);
-  }
-  result->totSize= E_BUFFER_SIZE;
-#endif
-  if (!(result->buf= (void*)elan3_allocMain(tcomm->ctx, 8, 
-					    tcomm->mbuff[id][iBuf].size))) {
-    perror("teac_Recv: elan3_allocMain failed for buffer");
-    return(NULL);
-  }
-  result->totSize= tcomm->mbuff[id][iBuf].size;
-  tcomm->totalRecvBufferBytesAllocated+= result->totSize;
-  result->validSize= tcomm->mbuff[id][iBuf].size;
-  result->from= tcomm->mbuff[id][iBuf].host;
-  result->senderMsgnum= tcomm->mbuff[id][iBuf].msgnum;
-		
-  /* Set up the DMA to pull the message */
-  tcomm->dma->dma_type = E3_DMA_TYPE(DMA_BYTE,DMA_READ,DMA_NORMAL,0);
-  tcomm->dma->dma_size = tcomm->mbuff[id][iBuf].size;
-  tcomm->dma->dma_source = tcomm->mbuff[id][iBuf].mptr;
-  tcomm->dma->dma_dest = teac_main2elan(tcomm->ctx,result->buf);
-  tcomm->dma->dma_srcCookieVProc = 
-    elan3_remote_cookie(tcomm->ctx, vp, tcomm->mbuff[id][iBuf].host);
-  tcomm->dma->dma_destCookieVProc = 
-    elan3_local_cookie(tcomm->ctx, vp, tcomm->mbuff[id][iBuf].host);
-  tcomm->dma->dma_srcEvent = tcomm->mbuff[id][iBuf].clr_event; 
-  tcomm->dma->dma_destEvent = 
-    elan3_sdram2elan(tcomm->ctx,tcomm->ctx->sdram,
-		     tcomm->rbuf_pull_event);
-
-  
-  elan3_primeevent(tcomm->ctx, tcomm->rbuf_pull_event,1);
-  *(tcomm->rbuf_ready)= 0;
-  elan3_getdma_main(tcomm->ctx, tcomm->dma, tcomm->e_dma);
-  elan3_waitevent_word(tcomm->ctx,
-		       tcomm->rbuf_pull_event, 
-		       tcomm->rbuf_ready, ELAN_WAIT_EVENT);
-
-  return(result);
-}
-
-int teac_Dispose( Tcomm* tcomm, RBuffer* buf )
-{
-  tcomm->totalRecvBufferBytesAllocated -= buf->totSize;
-  elan3_free(tcomm->ctx, buf->buf);
-  crFree(buf);
-  return 0;
-}
-
-char* teac_getTcommString(Tcomm *c, char* buf, int buflen)
-{
-  snprintf(buf,buflen-1,
-	   "<vp= %d, host range %d-%d, ctxnum range %d-%d, msg %d>",
-	   c->vp,c->lhost,c->hhost,c->lctx,c->hctx,c->msgnum);
-  buf[buflen-1]= '\0';
-  return buf;
-}
-
-char* teac_getConnString(Tcomm *c, int id, char* buf, int buflen)
-{
-  int rel_rank= id%4;
-  int node= ((id-rel_rank)/4) + c->lhost;
-  snprintf(buf,buflen-1,"vp %d, <%s>:%d",id,
-	   hosts[hostsIndex[node]].name,rel_rank);
-  buf[buflen-1]= '\0';
-#if 0
-  crDebug("getConnString: lookup id %d -> %d %d -> %s\n",id,rel_rank,node,buf);
-#endif
-  return buf;
-}
-
-int teac_getConnId(Tcomm *c, const char* host, int rank)
-{
-  int node= trans_host(host);
-#if 0
-  crDebug("getConnId: <%s> %d %d maps to %d %d\n",
-	  host, rank, c->lhost, node, (4*(node - c->lhost) + (rank%4)));
-#endif
-  return (4*(node - c->lhost) + (rank%4));
-}
-
-int teac_getHostInfo(Tcomm *c, char* host, const int hostLength,
-		     int* railMask, int *nodeId, 
-		     long* sdramBaseAddr, long* elanBaseAddr)
-{
-#if (TEAC_DEVINFO_TYPE == 2)
-  ELAN_DEVINFO info;
-  ELAN_POSITION position;
-#else
-  ELAN3_DEVINFO	info;
-#endif
-  char* here;
-
-  if (gethostname(host,hostLength-1)) {
-    perror("Can't get my own host name");
-    return 0;
-  }
-  host[hostLength-1]= '\0';
-  if ((here= crStrchr(host,'.')) != NULL) *here= '\0';
-
-#if (TEAC_DEVINFO_TYPE == 2)
-  (void)elan3_get_devinfo(c->ctx, &info);
-  (void)elan3_get_position(c->ctx, &position);
-  *nodeId= position.pos_nodeid;
-#elif (TEAC_DEVINFO_TYPE == 1)
-  elan3_devinfo(0, &info);
-  *nodeId= info.Position.NodeId;
-#else
-  elan3_devinfo(0, &info);
-  *nodeId= info.NodeId;
-#endif
-
-#if (TEAC_CAP_TYPE == 2)
-  *railMask= c->cap.cap_railmask;
-#else
-  *railMask= c->cap.RailMask;
-#endif
-
-  *sdramBaseAddr= (int)c->r_event[0][0];
-	  
-  *elanBaseAddr= (long)teac_main2elan(c->ctx,(void*)c->m_rcv[0]);
-  return 1;
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/list.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/list.c	(revision 78116)
+++ 	(revision )
@@ -1,314 +1,0 @@
-#include "cr_list.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-
-#ifndef CR_TESTING_LIST			/* vbox */
-# define CR_TESTING_LIST 0      	/* vbox */
-#endif  				/* vbox */
-#if CR_TESTING_LIST
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#endif
-
-struct CRListIterator {
-	void *element;
-	CRListIterator *prev;
-	CRListIterator *next;
-};
-
-struct CRList {
-	CRListIterator *head;
-	CRListIterator *tail;
-	unsigned size;
-};
-
-CRList *crAllocList( void )
-{
-	CRList *l = crAlloc( sizeof( CRList ) );
-	CRASSERT( l );
-
-	l->head = crAlloc( sizeof( CRListIterator ) );
-	CRASSERT( l->head );
-
-	l->tail = crAlloc( sizeof( CRListIterator ) );
-	CRASSERT( l->tail );
-
-	l->head->prev = NULL;
-	l->head->next = l->tail;
-
-	l->tail->prev = l->head;
-	l->tail->next = NULL;
-
-	l->size = 0;
-
-	return l;
-}
-
-void crFreeList( CRList *l )
-{
-	CRListIterator *t1;
-
-	CRASSERT( l != NULL );
-	t1 = l->head;
-	while ( t1 != NULL )
-	{
-		CRListIterator *t2 = t1;
-		t1 = t1->next;
-		t2->prev = NULL;
-		t2->next = NULL;
-		t2->element = NULL;
-		crFree( t2 );
-	}
-	l->size = 0;
-	crFree( l );
-}
-
-unsigned crListSize( const CRList *l )
-{
-	return l->size;
-}
-
-int crListIsEmpty( const CRList *l )
-{
-	CRASSERT( l != NULL );
-	return l->size == 0;
-}
-
-void crListInsert( CRList *l, CRListIterator *iter, void *elem )
-{
-	CRListIterator *p;
-
-	CRASSERT( l != NULL );
-	CRASSERT( iter != NULL );
-	CRASSERT( iter != l->head );
-
-	p = crAlloc( sizeof( CRListIterator ) );
-	CRASSERT( p != NULL );
-	p->prev = iter->prev;
-	p->next = iter;
-	p->prev->next = p;
-	iter->prev = p;
-
-	p->element = elem;
-	l->size++;
-}
-
-void crListErase( CRList *l, CRListIterator *iter )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( iter != NULL );
-	CRASSERT( iter != l->head );
-	CRASSERT( iter != l->tail );
-	CRASSERT( l->size > 0 );
-
-	iter->next->prev = iter->prev;
-	iter->prev->next = iter->next;
-
-	iter->prev = NULL;
-	iter->next = NULL;
-	iter->element = NULL;
-	crFree( iter );
-
-	l->size--;
-}
-
-void crListClear( CRList *l )
-{
-	CRASSERT( l != NULL );
-	while ( !crListIsEmpty( l ) )
-	{
-		crListPopFront( l );
-	}
-}
-
-void crListPushBack( CRList *l, void *elem )
-{
-	CRASSERT( l != NULL );
-	crListInsert( l, l->tail, elem );
-}
-
-void crListPushFront( CRList *l, void *elem )
-{
-	CRASSERT( l != NULL );
-	crListInsert( l, l->head->next, elem );
-}
-
-void crListPopBack( CRList *l )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( l->size > 0 );
-	crListErase( l, l->tail->prev );
-}
-
-void crListPopFront( CRList *l )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( l->size > 0 );
-	crListErase( l, l->head->next );
-}
-
-void *crListFront( CRList *l )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( l->size > 0 );
-	CRASSERT( l->head != NULL );
-	CRASSERT( l->head->next != NULL );
-	return l->head->next->element;
-}
-
-void *crListBack( CRList *l )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( l->size > 0 );
-	CRASSERT( l->tail != NULL );
-	CRASSERT( l->tail->prev != NULL );
-	return l->tail->prev->element;
-}
-
-CRListIterator *crListBegin( CRList *l )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( l->head != NULL );
-	CRASSERT( l->head->next != NULL );
-	return l->head->next;
-}
-
-CRListIterator *crListEnd( CRList *l )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( l->tail != NULL );
-	return l->tail;
-}
-
-CRListIterator *crListNext( CRListIterator *iter )
-{
-	CRASSERT( iter != NULL );
-	CRASSERT( iter->next != NULL );
-	return iter->next;
-}
-
-CRListIterator *crListPrev( CRListIterator *iter )
-{
-	CRASSERT( iter != NULL );
-	CRASSERT( iter->prev != NULL );
-	return iter->prev;
-}
-
-void *crListElement( CRListIterator *iter )
-{
-	CRASSERT( iter != NULL );
-	return iter->element;
-}
-
-CRListIterator *crListFind( CRList *l, void *element, CRListCompareFunc compare )
-{
-	CRListIterator *iter;
-
-	CRASSERT( l != NULL );
-	CRASSERT( compare );
-
-	for ( iter = crListBegin( l ); iter != crListEnd( l ); iter = crListNext( iter ) )
-	{
-		if ( compare( element, iter->element ) == 0 )
-		{
-			return iter;
-		}
-	}
-	return NULL;
-}
-
-void crListApply( CRList *l, CRListApplyFunc apply, void *arg )
-{
-	CRListIterator *iter;
-
-	CRASSERT( l != NULL );
-	for ( iter = crListBegin( l ); iter != crListEnd( l ); iter = crListNext( iter ) )
-	{
-		apply( iter->element, arg );
-	}
-}
-
-#if CR_TESTING_LIST
-
-static void printElement( void *elem, void *arg )
-{
-	char *s = elem;
-	FILE *fp = arg;
-
-	CRASSERT( s != NULL );
-	CRASSERT( fp != NULL );
-	fprintf( fp, "%s ", s );
-}
-
-static void printList( CRList *l )
-{
-	CRASSERT( l != NULL );
-	crListApply( l, printElement, stderr );
-	fprintf( stderr, "\n" );
-}
-
-static int elementCompare( void *a, void *b )
-{
-	return strcmp( a, b );
-}
-
-int main( void )
-{
-	char *names[] = { "a", "b", "c", "d", "e", "f" };
-	CRList *l;
-	CRListIterator *iter;
-	int i, n;
-
-	n = sizeof( names ) / sizeof( names[0] );
-	fprintf( stderr, "n=%d\n", n );
-
-	l = crAllocList(  );
-	for ( i = 0; i < n; ++i )
-	{
-		crListPushBack( l, names[i] );
-	}
-	printList( l );
-
-	crListPushFront( l, "x" );
-	printList( l );
-
-	crListPushBack( l, "y" );
-	printList( l );
-
-	crListPopFront( l );
-	printList( l );
-
-	crListPopBack( l );
-	printList( l );
-
-	iter = crListFind( l, "c", elementCompare );
-	CRASSERT( iter != NULL );
-	crListInsert( l, iter, "z" );
-	printList( l );
-
-	iter = crListFind( l, "d", elementCompare );
-	CRASSERT( iter != NULL );
-	crListErase( l, iter );
-	printList( l );
-
-	crListClear( l );
-	printList( l );
-	fprintf( stderr, "size: %u\n", crListSize( l ) );
-	fprintf( stderr, "is empty: %d\n", crListIsEmpty( l ) );
-
-	crListPushBack( l, "w" );
-	crListPushBack( l, "t" );
-	crListPushBack( l, "c" );
-	printList( l );
-
-	fprintf( stderr, "front: %s\n", ( char * ) crListFront( l ) );
-	fprintf( stderr, "back: %s\n", ( char * ) crListBack( l ) );
-	fprintf( stderr, "size: %u\n", crListSize( l ) );
-	fprintf( stderr, "is empty: %d\n", crListIsEmpty( l ) );
-
-	crFreeList( l );
-	return 0;
-}
-
-#endif /* CR_TESTING_LIST */
Index: trunk/src/VBox/GuestHost/OpenGL/util/lowercase.py
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/lowercase.py	(revision 78116)
+++ 	(revision )
@@ -1,27 +1,0 @@
-# Copyright (c) 2001, Stanford University
-# All rights reserved.
-#
-# See the file LICENSE.txt for information on redistributing this software.
-
-import sys,string
-
-stub_common.CopyrightC()
-
-print "char lowercase[256] = {"
-
-NUM_COLS = 8
-
-count = 0
-for num in range(256):
-	if count%NUM_COLS == 0:
-		sys.stdout.write( '\t' )
-	the_char = chr(num);
-	if num != 255:
-		print ("'\%03o'," % ord(string.lower(the_char))),
-	else:
-		print ("'\%03o'" % ord(string.lower(the_char))),
-	count += 1
-	if count%NUM_COLS == 0:
-		print ""
-
-print "};"
Index: trunk/src/VBox/GuestHost/OpenGL/util/mem.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/mem.c	(revision 78116)
+++ trunk/src/VBox/GuestHost/OpenGL/util/mem.c	(revision 78190)
@@ -8,46 +8,11 @@
 #include "cr_error.h"
 
-#include <stdlib.h>
-#include <memory.h>
-
 #include <iprt/types.h>
 #include <iprt/mem.h>
 
-#if DEBUG_MEM
-#include <stdio.h>
-#define THRESHOLD 100 * 1024
 
-#undef crAlloc
-#undef crCalloc
-
-/* Need these stubs because util.def says we're always exporting crAlloc
- * and crCalloc.
- */
-extern void *crAlloc( unsigned int bytes );
-void *crAlloc( unsigned int bytes )
+DECLEXPORT(void) *crAlloc( unsigned int nbytes )
 {
-   return NULL;
-}
-
-extern void *crCalloc( unsigned int bytes );
-void *crCalloc( unsigned int bytes )
-{
-   return NULL;
-}
-#endif /* DEBUG_MEM */
-
-
-
-#if DEBUG_MEM
-static void *_crAlloc( unsigned int nbytes )
-#else
-DECLEXPORT(void) *crAlloc( unsigned int nbytes )
-#endif
-{
-#ifdef VBOX
 	void *ret = RTMemAlloc( nbytes );
-#else
-	void *ret = malloc( nbytes );
-#endif
 	if (!ret) {
 		crError( "Out of memory trying to allocate %d bytes!", nbytes );
@@ -57,27 +22,7 @@
 }
 
-void *crAllocDebug( unsigned int nbytes, const char *file, int line )
+DECLEXPORT(void) *crCalloc( unsigned int nbytes )
 {
-#if DEBUG_MEM
-	if (nbytes >= THRESHOLD)
-		fprintf(stderr, "crAllocDebug(%d bytes) in %s at %d\n", nbytes, file, line);
-	return _crAlloc(nbytes);
-#else
-	RT_NOREF2(file, line);
-	return crAlloc(nbytes);
-#endif
-}
-
-#if DEBUG_MEM
-static void *_crCalloc( unsigned int nbytes )
-#else
-DECLEXPORT(void) *crCalloc( unsigned int nbytes )
-#endif
-{
-#ifdef VBOX
 	void *ret = RTMemAlloc( nbytes );
-#else
-	void *ret = malloc( nbytes );
-#endif
 	if (!ret) {
 		crError( "Out of memory trying to (c)allocate %d bytes!", nbytes );
@@ -88,33 +33,11 @@
 }
 
-void *crCallocDebug( unsigned int nbytes, const char *file, int line )
-{
-#if DEBUG_MEM
-	if (nbytes >= THRESHOLD)
-		fprintf(stderr, "crCallocDebug(%d bytes) in %s at %d\n", nbytes, file, line);
-	return _crCalloc(nbytes);
-#else
-	RT_NOREF2(file, line);
-	return crCalloc(nbytes);
-#endif
-}
-
 DECLEXPORT(void) crRealloc( void **ptr, unsigned int nbytes )
 {
 	if ( *ptr == NULL )
-	{
-#if DEBUG_MEM
-		*ptr = _crAlloc( nbytes );
-#else
 		*ptr = crAlloc( nbytes );
-#endif
-	}
 	else
 	{
-#ifdef VBOX
 		*ptr = RTMemRealloc( *ptr, nbytes );
-#else
-		*ptr = realloc( *ptr, nbytes );
-#endif
 		if (*ptr == NULL)
 			crError( "Couldn't realloc %d bytes!", nbytes );
@@ -124,37 +47,5 @@
 DECLEXPORT(void) crFree( void *ptr )
 {
-#ifdef VBOX
 	if (ptr)
 		RTMemFree(ptr);
-#else
-	if (ptr)
-		free(ptr);
-#endif
 }
-
-DECLEXPORT(void) crMemcpy( void *dst, const void *src, unsigned int bytes )
-{
-	CRASSERT(dst || 0==bytes);
-	CRASSERT(src || 0==bytes);
-	(void) memcpy( dst, src, bytes );
-}
-
-DECLEXPORT(void) crMemset( void *ptr, int value, unsigned int bytes )
-{
-	CRASSERT(ptr);
-	memset( ptr, value, bytes );
-}
-
-DECLEXPORT(void) crMemZero( void *ptr, unsigned int bytes )
-{
-	CRASSERT(ptr);
-	memset( ptr, 0, bytes );
-}
-
-DECLEXPORT(int) crMemcmp( const void *p1, const void *p2, unsigned int bytes )
-{
-	CRASSERT(p1);
-	CRASSERT(p2);
-	return memcmp( p1, p2, bytes );
-}
-
Index: trunk/src/VBox/GuestHost/OpenGL/util/net.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/net.c	(revision 78116)
+++ trunk/src/VBox/GuestHost/OpenGL/util/net.c	(revision 78190)
@@ -22,10 +22,7 @@
 #include "cr_error.h"
 #include "cr_string.h"
-#include "cr_url.h"
 #include "cr_net.h"
 #include "cr_netserver.h"
 #include "cr_pixeldata.h"
-#include "cr_environment.h"
-#include "cr_endian.h"
 #include "cr_bufpool.h"
 #include "cr_threads.h"
@@ -47,12 +44,4 @@
 
     /* Number of connections using each type of interface: */
-    int                  use_tcpip;
-    int                  use_ib;
-    int                  use_file;
-    int                  use_udp;
-    int                  use_gm;
-    int                  use_sdp;
-    int                  use_teac;
-    int                  use_tcscomm;
     int                  use_hgcm;
 
@@ -60,7 +49,6 @@
 
 #ifdef CHROMIUM_THREADSAFE
-    CRmutex          mutex;
-#endif
-    int                  my_rank;  /* Teac/TSComm only */
+    CRmutex              mutex;
+#endif
 } cr_net;
 
@@ -73,5 +61,5 @@
  */
 static void
-InitConnection(CRConnection *conn, const char *protocol, unsigned int mtu
+InitConnection(CRConnection *conn
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
                 , struct VBOXUHGSMI *pHgsmi
@@ -79,101 +67,13 @@
         )
 {
-    if (!crStrcmp(protocol, "devnull"))
-    {
-        crDevnullInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crDevnullConnection(conn);
-    }
-    else if (!crStrcmp(protocol, "file"))
-    {
-        cr_net.use_file++;
-        crFileInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crFileConnection(conn);
-    }
-    else if (!crStrcmp(protocol, "swapfile"))
-    {
-        /* file with byte-swapping */
-        cr_net.use_file++;
-        crFileInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crFileConnection(conn);
-        conn->swap = 1;
-    }
-    else if (!crStrcmp(protocol, "tcpip"))
-    {
-        cr_net.use_tcpip++;
-        crTCPIPInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crTCPIPConnection(conn);
-    }
-    else if (!crStrcmp(protocol, "udptcpip"))
-    {
-        cr_net.use_udp++;
-        crUDPTCPIPInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crUDPTCPIPConnection(conn);
-    }
 #ifdef VBOX_WITH_HGCM
-    else if (!crStrcmp(protocol, "vboxhgcm"))
-    {
-        cr_net.use_hgcm++;
-        crVBoxHGCMInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crVBoxHGCMConnection(conn
-#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
-                    , pHgsmi
-#endif
-                );
-    }
-#endif
-#ifdef GM_SUPPORT
-    else if (!crStrcmp(protocol, "gm"))
-    {
-        cr_net.use_gm++;
-        crGmInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crGmConnection(conn);
-    }
-#endif
-#ifdef TEAC_SUPPORT
-    else if (!crStrcmp(protocol, "quadrics"))
-    {
-        cr_net.use_teac++;
-        crTeacInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crTeacConnection(conn);
-    }
-#endif
-#ifdef TCSCOMM_SUPPORT
-    else if (!crStrcmp(protocol, "quadrics-tcscomm"))
-    {
-        cr_net.use_tcscomm++;
-        crTcscommInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crTcscommConnection(conn);
-    }
-#endif
-#ifdef SDP_SUPPORT
-    else if (!crStrcmp(protocol, "sdp"))
-    {
-        cr_net.use_sdp++;
-        crSDPInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crSDPConnection(conn);
-    }
-#endif
-#ifdef IB_SUPPORT
-    else if (!crStrcmp(protocol, "ib"))
-    {
-        cr_net.use_ib++;
-        crDebug("Calling crIBInit()");
-        crIBInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crIBConnection(conn);
-        crDebug("Done Calling crIBInit()");
-    }
-#endif
-#ifdef HP_MULTICAST_SUPPORT
-    else if (!crStrcmp(protocol, "hpmc"))
-    {
-        cr_net.use_hpmc++;
-        crHPMCInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crHPMCConnection(conn);
-    }
-#endif
-    else
-    {
-        crError("Unknown protocol: \"%s\"", protocol);
-    }
+    cr_net.use_hgcm++;
+    crVBoxHGCMInit(cr_net.recv_list, cr_net.close_list);
+    crVBoxHGCMConnection(conn
+#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
+                         , pHgsmi
+#endif
+                         );
+#endif
 }
 
@@ -192,5 +92,5 @@
  *                the mothership
  */
-CRConnection * crNetConnectToServer( const char *server, unsigned short default_port, int mtu, int broker
+CRConnection * crNetConnectToServer( const char *server, int mtu, int broker
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
                 , struct VBOXUHGSMI *pHgsmi
@@ -198,10 +98,8 @@
 )
 {
-    char hostname[4096], protocol[4096];
-    unsigned short port;
     CRConnection *conn;
 
-    crDebug( "In crNetConnectToServer( \"%s\", port=%d, mtu=%d, broker=%d )",
-                     server, default_port, mtu, broker );
+    crDebug( "In crNetConnectToServer( \"%s\", mtu=%d, broker=%d )",
+                     server, mtu, broker );
 
     CRASSERT( cr_net.initialized );
@@ -212,47 +110,4 @@
                          "but the minimum MTU is %d", server, mtu, CR_MINIMUM_MTU );
     }
-
-    /* Tear the URL apart into relevant portions. */
-    if ( !crParseURL( server, protocol, hostname, &port, default_port ) ) {
-         crError( "Malformed URL: \"%s\"", server );
-    }
-
-    /* If the host name is "localhost" replace it with the _real_ name
-     * of the localhost.  If we don't do this, there seems to be
-     * confusion in the mothership as to whether or not "localhost" and
-     * "foo.bar.com" are the same machine.
-     */
-    if (crStrcmp(hostname, "localhost") == 0) {
-        int rv = crGetHostname(hostname, 4096);
-        CRASSERT(rv == 0);
-        (void) rv;
-    }
-
-    /* XXX why is this here???  I think it could be moved into the
-     * crTeacConnection() function with no problem. I.e. change the
-     * connection's port, teac_rank and tcscomm_rank there.  (BrianP)
-     */
-    if ( !crStrcmp( protocol, "quadrics" ) ||
-         !crStrcmp( protocol, "quadrics-tcscomm" ) ) {
-      /* For Quadrics protocols, treat "port" as "rank" */
-      if ( port > CR_QUADRICS_HIGHEST_RANK ) {
-        crWarning( "Invalid crserver rank, %d, defaulting to %d\n",
-               port, CR_QUADRICS_LOWEST_RANK );
-        port = CR_QUADRICS_LOWEST_RANK;
-      }
-    }
-    crDebug( "Connecting to %s on port %d, with protocol %s",
-                     hostname, port, protocol );
-
-#ifdef SDP_SUPPORT
-    /* This makes me ill, but we need to "fix" the hostname for sdp. MCH */
-    if (!crStrcmp(protocol, "sdp")) {
-        char* temp;
-        temp = strtok(hostname, ".");
-        crStrcat(temp, crGetSDPHostnameSuffix());
-        crStrcpy(hostname, temp);
-        crDebug("SDP rename hostname: %s", hostname);    
-    }
-#endif
 
     conn = (CRConnection *) crCalloc( sizeof(*conn) );
@@ -263,22 +118,12 @@
     conn->type               = CR_NO_CONNECTION; /* we don't know yet */
     conn->recv_credits       = CR_INITIAL_RECV_CREDITS;
-    conn->hostname           = crStrdup( hostname );
-    conn->port               = port;
     conn->mtu                = mtu;
     conn->buffer_size        = mtu;
     conn->broker             = broker;
-    conn->endianness         = crDetermineEndianness();
-    /* XXX why are these here??? Move them into the crTeacConnection()
-     * and crTcscommConnection() functions.
-     */
-    conn->teac_id            = -1;
-    conn->teac_rank          = port;
-    conn->tcscomm_id         = -1;
-    conn->tcscomm_rank       = port;
 
     crInitMessageList(&conn->messageList);
 
     /* now, just dispatch to the appropriate protocol's initialization functions. */
-    InitConnection(conn, protocol, mtu
+    InitConnection(conn
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
                 , pHgsmi
@@ -311,18 +156,4 @@
 )
 {
-    /*
-    unsigned int len = sizeof(CRMessageNewClient);
-    CRMessageNewClient msg;
-
-    CRASSERT( conn );
-
-    if (conn->swap)
-        msg.header.type = (CRMessageType) SWAP32(CR_MESSAGE_NEWCLIENT);
-    else
-        msg.header.type = CR_MESSAGE_NEWCLIENT;
-
-    crNetSend( conn, NULL, &msg, len );
-    */
-
     crNetServerConnect( ns
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
@@ -349,4 +180,5 @@
     CRConnection *conn;
 
+    RT_NOREF(hostname);
     CRASSERT( cr_net.initialized );
 
@@ -358,13 +190,7 @@
     conn->type               = CR_NO_CONNECTION; /* we don't know yet */
     conn->recv_credits       = CR_INITIAL_RECV_CREDITS;
-    conn->port               = port;
     conn->mtu                = mtu;
     conn->buffer_size        = mtu;
     conn->broker             = broker;
-    conn->endianness         = crDetermineEndianness();
-    conn->teac_id            = -1;
-    conn->teac_rank          = -1;
-    conn->tcscomm_id         = -1;
-    conn->tcscomm_rank       = -1;
 
     crInitMessageList(&conn->messageList);
@@ -374,35 +200,12 @@
                     protocol, (int) port, (int) mtu);
 
-    /* special case */
-    if ( !crStrncmp( protocol, "file", crStrlen( "file" ) ) ||
-             !crStrncmp( protocol, "swapfile", crStrlen( "swapfile" ) ) )
-    {
-        char filename[4096];
-    char protocol_only[4096];
-
-        cr_net.use_file++;
-        if (!crParseURL(protocol, protocol_only, filename, NULL, 0))
-        {
-            crError( "Malformed URL: \"%s\"", protocol );
-        }
-        conn->hostname = crStrdup( filename );
-
-    /* call the protocol-specific init routines */  /* ktd (add) */
-    InitConnection(conn, protocol_only, mtu
+    /* call the protocol-specific init routines */
+      InitConnection(conn
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
                 , NULL
 #endif
-            );       /* ktd (add) */
-    }
-    else {
-    /* call the protocol-specific init routines */
-      InitConnection(conn, protocol, mtu
-#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
-                , NULL
-#endif
               );
-    }
-
-    crNetAccept( conn, hostname, port );
+
+    crNetAccept(conn);
     return conn;
 }
@@ -416,5 +219,4 @@
 {
     conn->Disconnect(conn);
-    crFree( conn->hostname );
     #ifdef CHROMIUM_THREADSAFE
         crFreeMutex( &conn->messageList.lock );
@@ -440,22 +242,4 @@
     else
     {
-#ifdef WINDOWS
-        /** @todo do we actually need that WSA stuff with VBox at all? */
-        WORD wVersionRequested = MAKEWORD(2, 0);
-        WSADATA wsaData;
-        int err;
-
-        err = WSAStartup(wVersionRequested, &wsaData);
-        if (err != 0)
-            crError("Couldn't initialize sockets on WINDOWS");
-#endif
-
-        cr_net.use_gm      = 0;
-        cr_net.use_udp     = 0;
-        cr_net.use_tcpip   = 0;
-        cr_net.use_sdp     = 0;
-        cr_net.use_tcscomm = 0;
-        cr_net.use_teac    = 0;
-        cr_net.use_file    = 0;
         cr_net.use_hgcm    = 0;
         cr_net.num_clients = 0;
@@ -555,27 +339,6 @@
     CRConnection **c;
 
-    c = crTCPIPDump( num );
-    if ( c ) return c;
-
-    c = crDevnullDump( num );
-    if ( c ) return c;
-
-    c = crFileDump( num );
-    if ( c ) return c;
-
 #ifdef VBOX_WITH_HGCM
     c = crVBoxHGCMDump( num );
-    if ( c ) return c;
-#endif
-#ifdef GM_SUPPORT
-    c = crGmDump( num );
-    if ( c ) return c;
-#endif
-#ifdef IB_SUPPORT
-    c = crIBDump( num );
-    if ( c ) return c;
-#endif
-#ifdef SDP_SUPPORT
-    c = crSDPDump( num );
     if ( c ) return c;
 #endif
@@ -866,5 +629,5 @@
 )
 {
-    ns->conn = crNetConnectToServer( ns->name, DEFAULT_SERVER_PORT,
+    ns->conn = crNetConnectToServer( ns->name,
                                      ns->buffer_size, 0
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
@@ -890,5 +653,4 @@
 {
     conn->Disconnect( conn );
-    crFree( conn->hostname );
 #ifdef CHROMIUM_THREADSAFE
     crFreeMutex( &conn->messageList.lock );
@@ -902,7 +664,7 @@
  * Apparently, this is only called from the crNetConnectToServer function.
  */
-void crNetAccept( CRConnection *conn, const char *hostname, unsigned short port )
-{
-    conn->Accept( conn, hostname, port );
+void crNetAccept( CRConnection *conn)
+{
+    conn->Accept( conn);
 }
 
@@ -916,8 +678,6 @@
 void crNetSingleRecv( CRConnection *conn, void *buf, unsigned int len )
 {
-    if (conn->type != CR_TCPIP)
-    {
-        crError( "Can't do a crNetSingleReceive on anything other than TCPIP." );
-    }
+    /** @todo Remove after users have been identified and eliminated .*/
+    crError( "Can't do a crNetSingleReceive on anything other than TCPIP." );
     conn->Recv( conn, buf, len );
 }
@@ -987,5 +747,5 @@
 {
     CRASSERT( len == sizeof(CRMessageFlowControl) );
-    conn->send_credits += (conn->swap ? SWAP32(msg->credits) : msg->credits);
+    conn->send_credits += msg->credits;
     conn->InstantReclaim( conn, (CRMessage *) msg );
 }
@@ -1095,9 +855,4 @@
         case CR_MESSAGE_OPCODES:
         case CR_MESSAGE_OOB:
-            {
-                /*CRMessageOpcodes *ops = (CRMessageOpcodes *) msg;
-                 *unsigned char *data_ptr = (unsigned char *) ops + sizeof( *ops) + ((ops->numOpcodes + 3 ) & ~0x03);
-                 *crDebugOpcodes( stdout, data_ptr-1, ops->numOpcodes ); */
-            }
             break;
         case CR_MESSAGE_READ_PIXELS:
@@ -1251,24 +1006,11 @@
 void crNetReadline( CRConnection *conn, void *buf )
 {
-    char *temp, c;
+    RT_NOREF(buf);
 
     if (!conn || conn->type == CR_NO_CONNECTION)
         return;
 
-    if (conn->type != CR_TCPIP)
-    {
-        crError( "Can't do a crNetReadline on anything other than TCPIP (%d).",conn->type );
-    }
-    temp = (char*)buf;
-    for (;;)
-    {
-        conn->Recv( conn, &c, 1 );
-        if (c == '\n')
-        {
-            *temp = '\0';
-            return;
-        }
-        *(temp++) = c;
-    }
+    /** @todo Remove after users have been found and eliminated. */
+    crError( "Can't do a crNetReadline on anything other than TCPIP (%d).",conn->type );
 }
 
@@ -1301,6 +1043,4 @@
     int found_work = 0;
 
-    if ( cr_net.use_tcpip )
-        found_work += crTCPIPRecv();
 #ifdef VBOX_WITH_HGCM
     if ( cr_net.use_hgcm )
@@ -1311,96 +1051,6 @@
                 );
 #endif
-#ifdef SDP_SUPPORT
-    if ( cr_net.use_sdp )
-        found_work += crSDPRecv();
-#endif
-#ifdef IB_SUPPORT
-    if ( cr_net.use_ib )
-        found_work += crIBRecv();
-#endif
-    if ( cr_net.use_udp )
-        found_work += crUDPTCPIPRecv();
-    
-    if ( cr_net.use_file )
-        found_work += crFileRecv();
-
-#ifdef GM_SUPPORT
-    if ( cr_net.use_gm )
-        found_work += crGmRecv();
-#endif
-
-#ifdef TEAC_SUPPORT
-    if ( cr_net.use_teac )
-        found_work += crTeacRecv();
-#endif
-
-#ifdef TCSCOMM_SUPPORT
-    if ( cr_net.use_tcscomm )
-        found_work += crTcscommRecv();
-#endif
 
     return found_work;
 }
 
-
-/**
- * Teac/TSComm only
- */
-void
-crNetSetRank( int my_rank )
-{
-    cr_net.my_rank = my_rank;
-#ifdef TEAC_SUPPORT
-    crTeacSetRank( cr_net.my_rank );
-#endif
-#ifdef TCSCOMM_SUPPORT
-    crTcscommSetRank( cr_net.my_rank );
-#endif
-}
-
-/**
- * Teac/TSComm only
- */
-void
-crNetSetContextRange( int low_context, int high_context )
-{
-#if !defined(TEAC_SUPPORT) && !defined(TCSCOMM_SUPPORT)
-    (void)low_context; (void)high_context;
-#endif
-#ifdef TEAC_SUPPORT
-    crTeacSetContextRange( low_context, high_context );
-#endif
-#ifdef TCSCOMM_SUPPORT
-    crTcscommSetContextRange( low_context, high_context );
-#endif
-}
-
-/**
- * Teac/TSComm only
- */
-void
-crNetSetNodeRange( const char *low_node, const char *high_node )
-{
-#if !defined(TEAC_SUPPORT) && !defined(TCSCOMM_SUPPORT)
-    (void)low_node; (void)high_node;
-#endif
-#ifdef TEAC_SUPPORT
-    crTeacSetNodeRange( low_node, high_node );
-#endif
-#ifdef TCSCOMM_SUPPORT
-    crTcscommSetNodeRange( low_node, high_node );
-#endif
-}
-
-/**
- * Teac/TSComm only
- */
-void
-crNetSetKey( const unsigned char* key, const int keyLength )
-{
-#ifdef TEAC_SUPPORT
-    crTeacSetKey( key, keyLength );
-#else
-    (void)key; (void)keyLength;
-#endif
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/net_internals.h
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/net_internals.h	(revision 78116)
+++ trunk/src/VBox/GuestHost/OpenGL/util/net_internals.h	(revision 78190)
@@ -10,86 +10,8 @@
 
 /*
- * DevNull network interface
- */
-extern void crDevnullInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crDevnullConnection( CRConnection *conn );
-extern int crDevnullRecv( void );
-extern CRConnection** crDevnullDump( int *num );
-
-
-/*
- * File network interface
- */
-extern void crFileInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crFileConnection( CRConnection *conn );
-extern int crFileRecv( void );
-extern CRConnection** crFileDump( int *num );
-
-
-/*
- * TCP/IP network interface
- */
-typedef enum {
-    CRTCPIPMemory,
-    CRTCPIPMemoryBig
-} CRTCPIPBufferKind;
-
-#define CR_TCPIP_BUFFER_MAGIC 0x89134532
-
-typedef struct CRTCPIPBuffer {
-    unsigned int          magic;
-    CRTCPIPBufferKind     kind;
-    unsigned int          len;
-    unsigned int          allocated;
-    unsigned int          pad;  /* may be clobbered by crTCPIPSend() */
-} CRTCPIPBuffer;
-
-typedef struct {
-    int                  initialized;
-    int                  num_conns;
-    CRConnection         **conns;
-    CRBufferPool         *bufpool;
-#ifdef CHROMIUM_THREADSAFE
-    CRmutex              mutex;
-    CRmutex              recvmutex;
-#endif
-    CRNetReceiveFuncList *recv_list;
-    CRNetCloseFuncList *close_list;
-    CRSocket             server_sock;
-} cr_tcpip_data;
-
-extern cr_tcpip_data cr_tcpip;
-
-extern void crTCPIPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crTCPIPConnection( CRConnection *conn );
-extern int crTCPIPRecv( void );
-extern CRConnection** crTCPIPDump( int *num );
-extern int crTCPIPDoConnect( CRConnection *conn );
-extern void crTCPIPDoDisconnect( CRConnection *conn );
-extern int crTCPIPErrno( void );
-extern char *crTCPIPErrorString( int err );
-extern void crTCPIPAccept( CRConnection *conn, const char *hostname, unsigned short port );
-extern void crTCPIPWriteExact( CRConnection *conn, const void *buf, unsigned int len );
-extern void crTCPIPFree( CRConnection *conn, void *buf );
-extern void *crTCPIPAlloc( CRConnection *conn );
-extern void crTCPIPReadExact( CRConnection *conn, void *buf, unsigned int len );
-extern int __tcpip_write_exact( CRSocket sock, const void *buf, unsigned int len );
-extern int __tcpip_read_exact( CRSocket sock, void *buf, unsigned int len );
-extern void __tcpip_dead_connection( CRConnection *conn );
-extern int __crSelect( int n, fd_set *readfds, int sec, int usec );
-
-
-/*
- * UDP network interface
- */
-extern void crUDPTCPIPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crUDPTCPIPConnection( CRConnection *conn );
-extern int crUDPTCPIPRecv( void );
-
-/*
  * VirtualBox HGCM
  */
 #ifdef VBOX_WITH_HGCM
-extern void crVBoxHGCMInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
+extern void crVBoxHGCMInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl);
 extern void crVBoxHGCMConnection( CRConnection *conn
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
@@ -111,78 +33,4 @@
 #endif
 
-/*
- * TEAC network interface
- */
-#ifdef TEAC_SUPPORT
-extern void crTeacInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl,
-            unsigned int mtu );
-extern void crTeacConnection( CRConnection *conn );
-extern int crTeacRecv( void );
-extern void crTeacSetRank( int );
-extern void crTeacSetContextRange( int, int );
-extern void crTeacSetNodeRange( const char *, const char * );
-extern void crTeacSetKey( const unsigned char *key, const int keyLength );
-#endif /* TEAC_SUPPORT */
-
-
-/*
- * Tcscomm network interface
- */
-#ifdef TCSCOMM_SUPPORT
-extern void crTcscommInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl,
-                           unsigned int mtu );
-extern void crTcscommConnection( CRConnection *conn );
-extern int crTcscommRecv( void );
-#endif /* TCSCOMM_SUPPORT */
-
-
-/*
- * SDP network interface
- */
-#ifdef SDP_SUPPORT
-extern const char *crGetSDPHostnameSuffix(void);
-extern void crSDPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crSDPConnection( CRConnection *conn );
-extern int crSDPRecv( void );
-extern CRConnection** crSDPDump( int *num );
-#endif /* SDP_SUPPORT */
-
-
-/*
- * Infiniband network interface
- */
-#ifdef IB_SUPPORT
-extern void crIBInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crIBConnection( CRConnection *conn );
-extern int crIBRecv( void );
-extern CRConnection** crIBDump( int *num );
-#endif /* IB_SUPPORT */
-
-
-/*
- * GM network interface
- */
-#ifdef GM_SUPPORT
-extern void crGmInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crGmConnection( CRConnection *conn );
-extern int crGmRecv( void );
-extern CRConnection** crGmDump( int *num );
-extern int crGmDoConnect( CRConnection *conn );
-extern void crGmDoDisconnect( CRConnection *conn );
-extern int crGmErrno( void );
-extern char *crGmErrorString( int err );
-extern void crGmAccept( CRConnection *conn, const char *hostname, unsigned short port );
-extern void crGmSendExact( CRConnection *conn, const void *buf, unsigned int len );
-extern void crGmFree( CRConnection *conn, void *buf );
-extern void *crGmAlloc( CRConnection *conn );
-extern void crGmReadExact( CRConnection *conn, void *buf, unsigned int len );
-extern void crGmBogusRecv( CRConnection *conn, void *buf, unsigned int len );
-extern void crGmHandleNewMessage( CRConnection *conn, CRMessage *msg, unsigned int len );
-extern void crGmInstantReclaim( CRConnection *conn, CRMessage *msg );
-extern unsigned int crGmNodeId( void );
-extern unsigned int crGmPortNum( void );
-#endif /* GM_SUPPORT */
-
-
 extern CRConnection** crNetDump( int *num );
 
Index: trunk/src/VBox/GuestHost/OpenGL/util/process.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/process.c	(revision 78116)
+++ trunk/src/VBox/GuestHost/OpenGL/util/process.c	(revision 78190)
@@ -22,86 +22,4 @@
 #define snprintf _snprintf
 #endif
-
-/**
- * Sleep/pause for the given number of seconds.
- */
-void crSleep( unsigned int seconds )
-{
-#ifdef WINDOWS
-  Sleep(seconds*1000); /* milliseconds */
-#else
-  sleep(seconds);
-#endif
-}
-
-/**
- * Sleep/pause for the given number of milliseconds.
- */
-void crMsleep( unsigned int msec )
-{
-#ifdef WINDOWS
-     Sleep(msec); 
-#else
-     usleep(msec*1000); /* usecs */
-#endif
-}
-
-
-/*
- * Spawn (i.e. fork/exec) a new process.
- */
-CRpid crSpawn( const char *command, const char *argv[] )
-{
-#ifdef WINDOWS
-	char newargv[1000];
-	int i;
-	STARTUPINFO si;
-	PROCESS_INFORMATION pi;
-
-	(void) command;
-
-	ZeroMemory( &si, sizeof(si) );
-	si.cb = sizeof(si);
-	ZeroMemory( &pi, sizeof(pi) );
-
-	crStrncpy(newargv, argv[0], 1000 );
-	for (i = 1; argv[i]; i++) {
-		crStrcat(newargv, " ");
-		crStrcat(newargv, argv[i]);
-	}
-
-	if ( !CreateProcess(NULL, newargv, NULL, NULL, FALSE, 0, NULL,
-				NULL, &si, &pi) )
-	{
-		crWarning("crSpawn failed, %d", GetLastError());
-		return 0;
-	}
-	return pi.hProcess;
-#else
-	pid_t pid;
-	if ((pid = fork()) == 0)
-	{
-		/* I'm the child */
-		int err = execvp(command, (char * const *) argv);
-		crWarning("crSpawn failed (return code: %d)", err);
-		return 0;
-	}
-	return (unsigned long) pid;
-#endif
-}
-
-
-/*
- * Kill the named process.
- */
-void crKill( CRpid pid )
-{
-#ifdef WINDOWS
-	TerminateProcess( pid, 0 );
-#else
-	kill((pid_t) pid, SIGKILL);
-#endif
-}
-
 
 /*
@@ -208,19 +126,4 @@
 
 
-/*
- * Return current directory string.
- */
-void crGetCurrentDir( char *dir, int maxLen )
-{
-#ifdef WINDOWS
-  if (!GetCurrentDirectory(maxLen, dir))
-	dir[0] = 0;
-#else
-  if (!getcwd(dir, maxLen))
-	dir[0] = 0;
-#endif
-}
-
-
 /**
  * Return current process ID number.
Index: trunk/src/VBox/GuestHost/OpenGL/util/rand.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/rand.c	(revision 78116)
+++ 	(revision )
@@ -1,115 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_rand.h"
-
-#ifdef WINDOWS
-#define WIN32_LEAN_AND_MEAN
-# ifdef VBOX
-#  include <iprt/win/windows.h>
-# else
-#include <windows.h>
-# endif
-#else
-#include <sys/time.h>
-#endif
-
-
-/* Period parameters */
-#define N 624
-#define M 397
-#define MATRIX_A 0x9908b0df   /* constant vector a */
-#define UPPER_MASK 0x80000000 /* most significant w-r bits */
-#define LOWER_MASK 0x7fffffff /* least significant r bits */
-
-/* Tempering parameters */
-#define TEMPERING_MASK_B 0x9d2c5680
-#define TEMPERING_MASK_C 0xefc60000
-#define TEMPERING_SHIFT_U(y)  (y >> 11)
-#define TEMPERING_SHIFT_S(y)  (y << 7)
-#define TEMPERING_SHIFT_T(y)  (y << 15)
-#define TEMPERING_SHIFT_L(y)  (y >> 18)
-
-static unsigned long mt[N]; /* the array for the state vector  */
-static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
-
-void crRandSeed(unsigned long seed)
-{
-	/* setting initial seeds to mt[N] using the generator Line 25 of Table 1
-	   in [KNUTH 1981, The Art of Computer Programming Vol. 2 (2nd Ed.),
-	   pp102
-	*/
-	if (seed == 0)
-		seed = 4357;   /* pick default seed if seed=0 (Guy Zadickario) */
-	mt[0]= seed & 0xffffffff;
-	for (mti=1; mti<N; mti++)
-		mt[mti] = (69069 * mt[mti-1]) & 0xffffffff;
-}
-
-
-/*
- * Seed the generator based on time of day or a system counter.
- */
-void crRandAutoSeed(void)
-{
-#if defined(WINDOWS)
-	LARGE_INTEGER counter;
-	QueryPerformanceCounter( &counter );
-	crRandSeed((unsigned long) counter.QuadPart);
-#else
-	struct timeval timeofday;
-	gettimeofday( &timeofday, 0 );	
-	crRandSeed((unsigned long) timeofday.tv_usec);
-#endif
-}
-
-
-static double genrand( void ) 
-{
-	unsigned long y;
-	static unsigned long mag01[2]={0x0, MATRIX_A};
-	/* mag01[x] = x * MATRIX_A  for x=0,1 */
-
-	if (mti >= N) { /* generate N words at one time */
-		int kk;
-		if (mti == N+1)   /* if sgenrand() has not been called, */
-			crRandSeed(4357); /* a default initial seed is used   */
-
-		for (kk=0;kk<N-M;kk++) {
-			y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
-			mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1];
-		}
-		for (;kk<N-1;kk++) {
-			y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
-			mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1];
-		}
-		y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
-		mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1];
-		mti = 0;
-	}
-
-	y = mt[mti++];
-	y ^= TEMPERING_SHIFT_U(y);
-	y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B;
-	y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C;
-	y ^= TEMPERING_SHIFT_L(y);
-
-	return ( (double)y / (unsigned long)0xffffffff ); /* reals */
-	/* return y; */ /* for integer generation */
-}
-
-float crRandFloat(float min, float max) 
-{
-	double t = genrand();
-	return (float) (t*min + (1-t)*max);
-}
-
-/* return a random integer in [min, max] (inclusive). */
-int crRandInt(int min, int max)
-{
-	double t = genrand();
-	return min + (int) (t * (max - min + 1));
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/sortarray.cpp
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/sortarray.cpp	(revision 78116)
+++ 	(revision )
@@ -1,414 +1,0 @@
-/* $Id$ */
-
-/** @file
- * Sorted array impl
- */
-
-/*
- * Copyright (C) 2014-2019 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#include <cr_sortarray.h>
-#include <cr_error.h>
-#include <iprt/err.h>
-#include <iprt/mem.h>
-
-#include <memory.h>
-
-VBOXSADECL(int) CrSaInit(CR_SORTARRAY *pArray, uint32_t cInitBuffer)
-{
-    pArray->cBufferSize = cInitBuffer;
-    pArray->cSize = 0;
-    if (cInitBuffer)
-    {
-        pArray->pElements = (uint64_t*)RTMemAlloc(cInitBuffer * sizeof (pArray->pElements[0]));
-        if (!pArray->pElements)
-        {
-            WARN(("no memory"));
-            /* sanity */
-            pArray->cBufferSize = 0;
-            return VERR_NO_MEMORY;
-        }
-    }
-    else
-        pArray->pElements = NULL;
-
-    return VINF_SUCCESS;
-}
-
-VBOXSADECL(void) CrSaCleanup(CR_SORTARRAY *pArray)
-{
-    if (pArray->pElements)
-        RTMemFree(pArray->pElements);
-
-    CrSaInit(pArray, 0);
-}
-
-static int crSaSearch(const CR_SORTARRAY *pArray, uint64_t element)
-{
-    int iMin = 0;
-    int iMax = pArray->cSize;
-    int i = 0;
-
-    while (iMin < iMax)
-    {
-        i = (iMax + iMin) / 2;
-
-        uint64_t el = pArray->pElements[i];
-        if (el == element)
-            return i;
-        else if (el < element)
-            iMin = i + 1;
-        else
-            iMax = i;
-    }
-
-    return -1;
-}
-
-static void crSaDbgValidate(const CR_SORTARRAY *pArray)
-{
-    Assert(pArray->cSize <= pArray->cBufferSize);
-    Assert(!pArray->pElements == !pArray->cBufferSize);
-    if (!pArray->cSize)
-        return;
-    uint64_t cur = pArray->pElements[0];
-    for (uint32_t i = 1; i < pArray->cSize; ++i)
-    {
-        Assert(pArray->pElements[i] > cur);
-        cur = pArray->pElements[i];
-    }
-}
-
-#ifdef DEBUG
-# define crSaValidate crSaDbgValidate
-#else
-# define crSaValidate(_a) do {} while (0)
-#endif
-
-static int crSaInsAt(CR_SORTARRAY *pArray, uint32_t iPos, uint64_t element)
-{
-    if (pArray->cSize == pArray->cBufferSize)
-    {
-        uint32_t cNewBufferSize = pArray->cBufferSize + 16;
-        uint64_t *pNew;
-        if (pArray->pElements)
-            pNew = (uint64_t*)RTMemRealloc(pArray->pElements, cNewBufferSize * sizeof (pArray->pElements[0]));
-        else
-            pNew = (uint64_t*)RTMemAlloc(cNewBufferSize * sizeof (pArray->pElements[0]));
-        if (!pNew)
-        {
-            WARN(("no memory"));
-            return VERR_NO_MEMORY;
-        }
-
-        pArray->pElements = pNew;
-        pArray->cBufferSize = cNewBufferSize;
-        crSaValidate(pArray);
-    }
-
-    for (int32_t i = (int32_t)pArray->cSize - 1; i >= (int32_t)iPos; --i)
-    {
-        pArray->pElements[i+1] = pArray->pElements[i];
-    }
-
-    pArray->pElements[iPos] = element;
-    ++pArray->cSize;
-
-    crSaValidate(pArray);
-
-    return VINF_SUCCESS;
-}
-
-static void crSaDelAt(CR_SORTARRAY *pArray, uint32_t iPos)
-{
-    Assert(pArray->cSize > iPos);
-
-    for (uint32_t i = iPos; i < pArray->cSize - 1; ++i)
-    {
-        pArray->pElements[i] = pArray->pElements[i+1];
-    }
-
-    --pArray->cSize;
-}
-
-static int crSaAdd(CR_SORTARRAY *pArray, uint64_t element)
-{
-    int iMin = 0;
-    int iMax = pArray->cSize;
-    int i = 0;
-    uint64_t el;
-
-    if (!iMax)
-        return crSaInsAt(pArray, 0, element);
-
-    el = element; /* Shup up MSC. */
-    while (iMin < iMax)
-    {
-        i = (iMax + iMin) / 2;
-
-        el = pArray->pElements[i];
-        if (el == element)
-            return VINF_ALREADY_INITIALIZED;
-        else if (el < element)
-            iMin = i + 1;
-        else
-            iMax = i;
-    }
-
-    if (el < element)
-        return crSaInsAt(pArray, i+1, element);
-    return crSaInsAt(pArray, i, element);
-}
-
-static int crSaRemove(CR_SORTARRAY *pArray, uint64_t element)
-{
-    int i = crSaSearch(pArray, element);
-    if (i >= 0)
-    {
-        crSaDelAt(pArray, i);
-        return VINF_SUCCESS;
-    }
-    return VINF_ALREADY_INITIALIZED;
-}
-
-/*
- *  * @return true if element is found */
-VBOXSADECL(bool) CrSaContains(const CR_SORTARRAY *pArray, uint64_t element)
-{
-    return crSaSearch(pArray, element) >= 0;
-}
-
-VBOXSADECL(int) CrSaAdd(CR_SORTARRAY *pArray, uint64_t element)
-{
-    return crSaAdd(pArray, element);
-}
-
-VBOXSADECL(int) CrSaRemove(CR_SORTARRAY *pArray, uint64_t element)
-{
-    return crSaRemove(pArray, element);
-}
-
-static int crSaIntersected(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult)
-{
-    int rc = VINF_SUCCESS;
-    CrSaClear(pResult);
-
-    for (uint32_t i = 0, j = 0; i < pArray1->cSize && j < pArray2->cSize; )
-    {
-        if (pArray1->pElements[i] == pArray2->pElements[j])
-        {
-            rc = CrSaAdd(pResult, pArray1->pElements[i]);
-            if (rc < 0)
-            {
-                WARN(("CrSaAdd failed"));
-                return rc;
-            }
-
-            ++i;
-            ++j;
-        }
-        else if (pArray1->pElements[i] < pArray2->pElements[j])
-        {
-            ++i;
-        }
-        else
-        {
-            ++j;
-        }
-    }
-
-    return VINF_SUCCESS;
-}
-
-static void crSaIntersect(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
-{
-    for (uint32_t i = 0, j = 0; i < pArray1->cSize && j < pArray2->cSize; )
-    {
-        if (pArray1->pElements[i] == pArray2->pElements[j])
-        {
-            ++i;
-            ++j;
-        }
-        else if (pArray1->pElements[i] < pArray2->pElements[j])
-            crSaDelAt(pArray1, i);
-        else
-            ++j;
-    }
-}
-
-/*
- * @return >= 0 success
- * < 0 - no memory
- *  */
-VBOXSADECL(void) CrSaIntersect(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
-{
-    crSaIntersect(pArray1, pArray2);
-}
-
-VBOXSADECL(int) CrSaIntersected(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult)
-{
-    return crSaIntersected(pArray1, pArray2, pResult);
-}
-
-static int crSaUnited(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult)
-{
-    int rc = VINF_SUCCESS;
-    CrSaClear(pResult);
-
-    uint32_t i = 0, j = 0;
-    uint32_t cResult = 0;
-    while (i < pArray1->cSize && j < pArray2->cSize)
-    {
-        uint64_t element;
-        if (pArray1->pElements[i] == pArray2->pElements[j])
-        {
-            element = pArray1->pElements[i];
-            ++i;
-            ++j;
-        }
-        else if (pArray1->pElements[i] < pArray2->pElements[j])
-        {
-            element = pArray1->pElements[i];
-            ++i;
-        }
-        else
-        {
-            element = pArray1->pElements[j];
-            ++j;
-        }
-
-        rc = crSaInsAt(pResult, cResult++, element);
-        if (rc < 0)
-        {
-            WARN(("crSaInsAt failed"));
-            return rc;
-        }
-    }
-
-    uint32_t iTail;
-    const CR_SORTARRAY *pTail;
-
-    if (i < pArray1->cSize)
-    {
-        iTail = i;
-        pTail = pArray1;
-    }
-    else if (j < pArray2->cSize)
-    {
-        iTail = j;
-        pTail = pArray2;
-    }
-    else
-    {
-        iTail = 0;
-        pTail = 0;
-    }
-
-    if (pTail)
-    {
-        for (;iTail < pTail->cSize; ++iTail)
-        {
-            rc = crSaInsAt(pResult, cResult++, pTail->pElements[iTail]);
-            if (rc < 0)
-            {
-                WARN(("crSaInsAt failed"));
-                return rc;
-            }
-        }
-    }
-
-    return VINF_SUCCESS;
-}
-
-VBOXSADECL(int) CrSaUnited(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult)
-{
-    return crSaUnited(pArray1, pArray2, pResult);
-}
-
-static int crSaClone(const CR_SORTARRAY *pArray1, CR_SORTARRAY *pResult)
-{
-    CrSaClear(pResult);
-
-    if (pArray1->cSize > pResult->cBufferSize)
-    {
-        CrSaCleanup(pResult);
-        uint32_t cNewBufferSize = pArray1->cSize;
-        uint64_t *pNew = (uint64_t*)RTMemAlloc(cNewBufferSize * sizeof (pResult->pElements[0]));
-        if (!pNew)
-        {
-            WARN(("no memory"));
-            return VERR_NO_MEMORY;
-        }
-
-        pResult->pElements = pNew;
-        pResult->cBufferSize = cNewBufferSize;
-        crSaValidate(pResult);
-    }
-
-    pResult->cSize = pArray1->cSize;
-    memcpy(pResult->pElements, pArray1->pElements, pArray1->cSize * sizeof (pArray1->pElements[0]));
-    return VINF_SUCCESS;
-}
-
-/*
- * @return VINF_SUCCESS on success
- * VERR_NO_MEMORY - no memory
- *  */
-VBOXSADECL(int) CrSaClone(const CR_SORTARRAY *pArray1, CR_SORTARRAY *pResult)
-{
-    return crSaClone(pArray1, pResult);
-}
-
-static int crSaCmp(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
-{
-    int diff = CrSaGetSize(pArray1) - CrSaGetSize(pArray2);
-    if (diff)
-        return diff;
-
-    return memcmp(pArray1->pElements, pArray2->pElements, pArray1->cSize * sizeof (pArray1->pElements[0]));
-}
-
-VBOXSADECL(int) CrSaCmp(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
-{
-    return crSaCmp(pArray1, pArray2);
-}
-
-static bool crSaCovers(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
-{
-    if (CrSaGetSize(pArray1) < CrSaGetSize(pArray2))
-        return false;
-
-    uint32_t i = 0, j = 0;
-    while (j < pArray2->cSize)
-    {
-        if (i == pArray1->cSize)
-            return false;
-
-        if (pArray1->pElements[i] == pArray2->pElements[j])
-        {
-            ++i;
-            ++j;
-        }
-        else if (pArray1->pElements[i] < pArray2->pElements[j])
-            ++i;
-        else
-            return false;
-    }
-
-    return true;
-}
-
-VBOXSADECL(bool) CrSaCovers(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
-{
-    return crSaCovers(pArray1, pArray2);
-}
-
Index: trunk/src/VBox/GuestHost/OpenGL/util/tcpip.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/tcpip.c	(revision 78116)
+++ 	(revision )
@@ -1,1472 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifdef WINDOWS
-#define WIN32_LEAN_AND_MEAN
-# ifdef VBOX
-#  include <iprt/win/winsock2.h>
-# else /* !VBOX */
-#pragma warning( push, 3 )
-#include <winsock2.h>
-#pragma warning( pop )
-#pragma warning( disable : 4514 )
-#pragma warning( disable : 4127 )
-typedef int ssize_t;
-# endif /* !VBOX */
-#else
-#include <sys/types.h>
-#include <sys/wait.h>
-#ifdef OSF1
-typedef int socklen_t;
-#endif
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#endif
-
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
-#ifdef AIX
-#include <strings.h>
-#endif
-
-#ifdef LINUX
-#include <sys/ioctl.h>
-#include <unistd.h>
-#endif
-
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_string.h"
-#include "cr_bufpool.h"
-#include "cr_net.h"
-#include "cr_endian.h"
-#include "cr_threads.h"
-#include "cr_environment.h"
-#include "net_internals.h"
-
-#ifdef ADDRINFO
-#define PF PF_UNSPEC
-#endif
-
-#ifdef WINDOWS
-# undef EADDRINUSE
-#define EADDRINUSE   WSAEADDRINUSE
-# undef ECONNREFUSED
-#define ECONNREFUSED WSAECONNREFUSED
-#endif
-
-#ifdef WINDOWS
-
-#undef  ECONNRESET
-#define ECONNRESET  WSAECONNRESET
-#undef  EINTR
-#define EINTR       WSAEINTR
-
-int crTCPIPErrno( void )
-{
-    return WSAGetLastError( );
-}
-
-char *crTCPIPErrorString( int err )
-{
-    static char buf[512], *temp;
-    
-    sprintf( buf, "err=%d", err );
-    
-#define X(x)    crStrcpy(buf,x); break
-
-    switch ( err )
-    {
-        case WSAECONNREFUSED: X( "connection refused" );
-        case WSAECONNRESET:   X( "connection reset" );
-        default:
-            FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
-                           FORMAT_MESSAGE_FROM_SYSTEM |
-                           FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, err,
-                           MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
-                           (LPTSTR) &temp, 0, NULL );
-            if ( temp )
-            {
-                crStrncpy( buf, temp, sizeof(buf)-1 );
-                buf[sizeof(buf)-1] = 0;
-            }
-    }
-
-#undef X
-
-    temp = buf + crStrlen(buf) - 1;
-    while ( temp > buf && isspace( *temp ) )
-    {
-        *temp = '\0';
-        temp--;
-    }
-
-    return buf;
-}
-
-#else /* WINDOWS */
-
-int crTCPIPErrno( void )
-{
-    int err = errno;
-    errno = 0;
-    return err;
-}
-
-char *crTCPIPErrorString( int err )
-{
-    static char buf[512], *temp;
-    
-    temp = strerror( err );
-    if ( temp )
-    {
-        crStrncpy( buf, temp, sizeof(buf)-1 );
-        buf[sizeof(buf)-1] = 0;
-    }
-    else
-    {
-        sprintf( buf, "err=%d", err );
-    }
-
-    return buf;
-}
-
-#endif /* WINDOWS */
-
-
-/*
- * Socket callbacks.  When a socket is created or destroyed we will
- * call these callback functions.
- * XXX Currently only implemented for TCP/IP.
- * XXX Maybe have lists of callbacks?
- */
-static CRSocketCallbackProc SocketCreateCallback = NULL;
-static CRSocketCallbackProc SocketDestroyCallback = NULL;
-
-void
-crRegisterSocketCallback(int mode, CRSocketCallbackProc proc)
-{
-    if (mode == CR_SOCKET_CREATE) {
-        SocketCreateCallback = proc;
-    }
-    else if (mode == CR_SOCKET_DESTROY) {
-        SocketDestroyCallback = proc;
-    }
-    else {
-        crError("Invalid crRegisterSocketCallbac mode=%d", mode);
-    }
-}
-
-
-
-void crCloseSocket( CRSocket sock )
-{
-    int fail;
-
-    if (sock <= 0)
-        return;
-
-    if (SocketDestroyCallback) {
-        SocketDestroyCallback(CR_SOCKET_DESTROY, sock);
-    }
-
-#ifdef WINDOWS
-    fail = ( closesocket( sock ) != 0 );
-#else
-    shutdown( sock, 2 /* RDWR */ );
-    fail = ( close( sock ) != 0 );
-#endif
-    if ( fail )
-    {
-        int err = crTCPIPErrno( );
-        crWarning( "crCloseSocket( sock=%d ): %s",
-                             sock, crTCPIPErrorString( err ) );
-    }
-}
-
-cr_tcpip_data cr_tcpip;
-
-/**
- * Read len bytes from socket, and store in buffer.
- * \return 1 if success, -1 if error, 0 if sender exited.
- */
-int
-__tcpip_read_exact( CRSocket sock, void *buf, unsigned int len )
-{
-    char *dst = (char *) buf;
-    /* 
-     * Shouldn't write to a non-existent socket, ie when 
-     * crTCPIPDoDisconnect has removed it from the pool
-     */
-    if ( sock <= 0 )
-        return 1;
-
-    while ( len > 0 )
-    {
-        const int num_read = recv( sock, dst, (int) len, 0 );
-
-#ifdef WINDOWS_XXXX
-        /* MWE: why is this necessary for windows???  Does it return a
-             "good" value for num_bytes despite having a reset
-             connection? */
-        if ( crTCPIPErrno( ) == ECONNRESET )
-            return -1;
-#endif
-
-        if ( num_read < 0 )
-        {
-            int error = crTCPIPErrno();
-            switch( error )
-            {
-                case EINTR:
-                    crWarning( "__tcpip_read_exact(TCPIP): "
-                            "caught an EINTR, looping for more data" );
-                    continue;
-                case EFAULT:
-                    crWarning( "EFAULT" );
-                    break;
-                case EINVAL:
-                    crWarning( "EINVAL" );
-                    break;
-                default:
-                    break;
-            }
-            crWarning( "Bad bad bad socket error: %s", crTCPIPErrorString( error ) );
-            return -1;
-        }
-
-        if ( num_read == 0 ) 
-        {
-            /* client exited gracefully */
-            return 0;
-        }
-
-        dst += num_read;
-        len -= num_read;
-    }
-
-    return 1;
-}
-
-void
-crTCPIPReadExact( CRConnection *conn, void *buf, unsigned int len )
-{
-    if ( __tcpip_read_exact( conn->tcp_socket, buf, len ) <= 0 )
-    {
-        __tcpip_dead_connection( conn );
-    }
-}
-
-/**
- * Write the given buffer of len bytes on the socket.
- * \return 1 if OK, negative value if error.
- */
-int
-__tcpip_write_exact( CRSocket sock, const void *buf, unsigned int len )
-{
-    const char *src = (const char *) buf;
-
-    /* 
-     * Shouldn't write to a non-existent socket, ie when 
-     * crTCPIPDoDisconnect has removed it from the pool
-     */
-    if ( sock <= 0 )
-        return 1;
-
-    while ( len > 0 )
-    {
-        const int num_written = send( sock, src, len, 0 );
-        if ( num_written <= 0 )
-        {
-            int err;
-          if ( (err = crTCPIPErrno( )) == EINTR )
-          {
-                crWarning("__tcpip_write_exact(TCPIP): caught an EINTR, continuing");
-                continue;
-          }
-          
-          return -err;
-        }
-         
-        len -= num_written;
-        src += num_written;
-    }
-         
-    return 1;
-}
-
-void
-crTCPIPWriteExact( CRConnection *conn, const void *buf, unsigned int len )
-{
-    if ( __tcpip_write_exact( conn->tcp_socket, buf, len) <= 0 )
-    {
-        __tcpip_dead_connection( conn );
-    }
-}
-
-
-/**
- * Make sockets do what we want: 
- * 
- * 1) Change the size of the send/receive buffers to 64K 
- * 2) Turn off Nagle's algorithm
- */
-static void
-spankSocket( CRSocket sock )
-{
-    /* why do we do 1) ? things work much better for me to push the
-     * the buffer size way up -- karl
-     */
-#ifdef LINUX
-    int sndbuf = 1*1024*1024;
-#else
-    int sndbuf = 64*1024;
-#endif  
-
-    int rcvbuf = sndbuf;
-    int so_reuseaddr = 1;
-    int tcp_nodelay = 1;
-
-    if ( setsockopt( sock, SOL_SOCKET, SO_SNDBUF, 
-             (char *) &sndbuf, sizeof(sndbuf) ) )
-    {
-        int err = crTCPIPErrno( );
-        crWarning( "setsockopt( SO_SNDBUF=%d ) : %s",
-               sndbuf, crTCPIPErrorString( err ) );
-    }
-    
-    if ( setsockopt( sock, SOL_SOCKET, SO_RCVBUF,
-             (char *) &rcvbuf, sizeof(rcvbuf) ) )
-    {
-        int err = crTCPIPErrno( );
-        crWarning( "setsockopt( SO_RCVBUF=%d ) : %s",
-               rcvbuf, crTCPIPErrorString( err ) );
-    }
-    
-    
-    if ( setsockopt( sock, SOL_SOCKET, SO_REUSEADDR,
-             (char *) &so_reuseaddr, sizeof(so_reuseaddr) ) )
-    {
-        int err = crTCPIPErrno( );
-        crWarning( "setsockopt( SO_REUSEADDR=%d ) : %s",
-               so_reuseaddr, crTCPIPErrorString( err ) );
-    }
-    
-    if ( setsockopt( sock, IPPROTO_TCP, TCP_NODELAY,
-             (char *) &tcp_nodelay, sizeof(tcp_nodelay) ) )
-    {
-        int err = crTCPIPErrno( );
-        crWarning( "setsockopt( TCP_NODELAY=%d )"
-               " : %s", tcp_nodelay, crTCPIPErrorString( err ) );
-    }
-}
-
-
-#if defined( WINDOWS ) || defined( IRIX ) || defined( IRIX64 )
-typedef int socklen_t;
-#endif
-
-
-/**
- * Create a listening socket using the given port.
- * Caller can then pass the socket to accept().
- * If the port is one that's been seen before, we'll reuse/return the
- * previously create socket.
- */
-static int
-CreateListeningSocket(int port)
-{
-    /* XXX should use an unbounded list here instead of parallel arrays... */
-#define MAX_PORTS 100
-    static int ports[MAX_PORTS];
-    static int sockets[MAX_PORTS];
-    static int count = 0;
-    int i, sock = -1;
-
-    /* search to see if we've seen this port before */
-    for (i = 0; i < count; i++) {
-        if (ports[i] == port) {
-            return sockets[i];
-        }
-    }
-
-    /* new port so create new socket */
-    {
-        int err;
-#ifndef ADDRINFO
-        struct sockaddr_in  servaddr;
-#endif
-
-        /* with the new OOB stuff, we can have multiple ports being 
-         * accepted on, so we need to redo the server socket every time.
-         */
-#ifndef ADDRINFO
-        sock = socket( AF_INET, SOCK_STREAM, 0 );
-        if ( sock == -1 )
-        {
-            err = crTCPIPErrno( );
-            crError( "Couldn't create socket: %s", crTCPIPErrorString( err ) );
-        }
-        spankSocket( sock );
-
-        servaddr.sin_family = AF_INET;
-        servaddr.sin_addr.s_addr = INADDR_ANY;
-        servaddr.sin_port = htons( (short) port );
-
-        if ( bind( sock, (struct sockaddr *) &servaddr, sizeof(servaddr) ) )
-        {
-            err = crTCPIPErrno( );
-            crError( "Couldn't bind to socket (port=%d): %s",
-                             port, crTCPIPErrorString( err ) );
-        }
-
-        if ( listen( sock, 100 /* max pending connections */ ) )
-        {
-            err = crTCPIPErrno( );
-            crError( "Couldn't listen on socket: %s", crTCPIPErrorString( err ) );
-        }
-#else
-        char port_s[NI_MAXSERV];
-        struct addrinfo *res,*cur;
-        struct addrinfo hints;
-
-        sprintf(port_s, "%u", (short unsigned) port);
-
-        crMemset(&hints, 0, sizeof(hints));
-        hints.ai_flags = AI_PASSIVE;
-        hints.ai_family = PF;
-        hints.ai_socktype = SOCK_STREAM;
-
-        err = getaddrinfo( NULL, port_s, &hints, &res );
-        if ( err )
-            crError( "Couldn't find local TCP port %s: %s",
-                             port_s, gai_strerror(err) );
-
-        for (cur=res;cur;cur=cur->ai_next)
-        {
-            sock = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol );
-            if ( sock == -1 )
-            {
-                err = crTCPIPErrno( );
-                if (err != EAFNOSUPPORT)
-                    crWarning("Couldn't create socket of family %i: %s, trying another", 
-                                        cur->ai_family, crTCPIPErrorString( err ) );
-                continue;
-            }
-            spankSocket( sock );
-
-            if ( bind( sock, cur->ai_addr, cur->ai_addrlen ) )
-            {
-                err = crTCPIPErrno( );
-                crWarning( "Couldn't bind to socket (port=%d): %s", 
-                       port, crTCPIPErrorString( err ) );
-                crCloseSocket( sock );
-                continue;
-            }
-
-            if ( listen( sock, 100 /* max pending connections */ ) )
-            {
-                err = crTCPIPErrno( );
-                crWarning("Couldn't listen on socket: %s", crTCPIPErrorString(err));
-                crCloseSocket( sock );
-                continue;
-            }
-            break;
-        }
-        freeaddrinfo(res);
-        if (!cur)
-            crError( "Couldn't find/bind local TCP port %s", port_s);
-#endif
-    }
-    
-    /* save the new port/socket */
-    if (count == MAX_PORTS) {
-        crError("Fatal error in tcpip layer: too many listening ports/sockets");
-    }
-    ports[count] = port;
-    sockets[count] = sock;
-    count++;
-
-    return sock;
-}
-
-
-
-
-void
-crTCPIPAccept( CRConnection *conn, const char *hostname, unsigned short port )
-{
-    int err;
-    socklen_t       addr_length;
-#ifndef ADDRINFO
-    struct hostent      *host;
-    struct in_addr      sin_addr;
-    struct sockaddr     addr;
-#else
-    struct sockaddr_storage addr;
-    char            host[NI_MAXHOST];
-#endif
-    (void)hostname;
-
-    cr_tcpip.server_sock = CreateListeningSocket(port);
-
-    /* If brokered, we'll contact the mothership to broker the network
-     * connection.  We'll send the mothership our hostname, the port and
-     * our endianness and will get in return a connection ID number.
-     */
-    if (conn->broker) {
-        crError("There shouldn't be any brokered connections in VirtualBox");
-    }
-    
-    addr_length =   sizeof( addr );
-    conn->tcp_socket = accept( cr_tcpip.server_sock, (struct sockaddr *) &addr, &addr_length );
-    if (conn->tcp_socket == -1)
-    {
-        err = crTCPIPErrno( );
-        crError( "Couldn't accept client: %s", crTCPIPErrorString( err ) );
-    }
-    
-    if (SocketCreateCallback) {
-        SocketCreateCallback(CR_SOCKET_CREATE, conn->tcp_socket);
-    }
-
-#ifndef ADDRINFO
-    sin_addr = ((struct sockaddr_in *) &addr)->sin_addr;
-    host = gethostbyaddr( (char *) &sin_addr, sizeof( sin_addr), AF_INET );
-    if (host == NULL )
-    {
-        char *temp = inet_ntoa( sin_addr );
-        conn->hostname = crStrdup( temp );
-    }
-#else
-    err = getnameinfo ( (struct sockaddr *) &addr, addr_length,
-                host, sizeof( host),
-                NULL, 0, NI_NAMEREQD);
-    if ( err )
-    {
-        err = getnameinfo ( (struct sockaddr *) &addr, addr_length,
-                    host, sizeof( host),
-                    NULL, 0, NI_NUMERICHOST);
-        if ( err )  /* shouldn't ever happen */
-            conn->hostname = crStrdup("unknown ?!");
-        else
-            conn->hostname = crStrdup( host );
-    }
-#endif
-    else
-    {
-        char *temp;
-#ifndef ADDRINFO
-        conn->hostname = crStrdup( host->h_name );
-#else
-        conn->hostname = crStrdup( host );
-#endif
-
-        temp = conn->hostname;
-        while (*temp && *temp != '.' )
-            temp++;
-        *temp = '\0';
-    }
-
-#ifdef RECV_BAIL_OUT 
-    err = sizeof(unsigned int);
-    if ( getsockopt( conn->tcp_socket, SOL_SOCKET, SO_RCVBUF,
-            (char *) &conn->krecv_buf_size, &err ) )
-    {
-        conn->krecv_buf_size = 0;   
-    }
-#endif
-
-    crDebug( "Accepted connection from \"%s\".", conn->hostname );
-}
-
-
-void *
-crTCPIPAlloc( CRConnection *conn )
-{
-    CRTCPIPBuffer *buf;
-
-#ifdef CHROMIUM_THREADSAFE
-    crLockMutex(&cr_tcpip.mutex);
-#endif
-
-    buf = (CRTCPIPBuffer *) crBufferPoolPop( cr_tcpip.bufpool, conn->buffer_size );
-
-    if ( buf == NULL )
-    {
-        crDebug("Buffer pool %p was empty; allocated new %d byte buffer.", 
-                        cr_tcpip.bufpool,
-                        (unsigned int)sizeof(CRTCPIPBuffer) + conn->buffer_size);
-        buf = (CRTCPIPBuffer *) 
-            crAlloc( sizeof(CRTCPIPBuffer) + conn->buffer_size );
-        buf->magic = CR_TCPIP_BUFFER_MAGIC;
-        buf->kind  = CRTCPIPMemory;
-        buf->pad   = 0;
-        buf->allocated = conn->buffer_size;
-    }
-    
-#ifdef CHROMIUM_THREADSAFE
-    crUnlockMutex(&cr_tcpip.mutex);
-#endif
-
-    return (void *)( buf + 1 );
-}
-
-
-static void
-crTCPIPSingleRecv( CRConnection *conn, void *buf, unsigned int len )
-{
-    crTCPIPReadExact( conn, buf, len );
-}
-
-
-static void
-crTCPIPSend( CRConnection *conn, void **bufp,
-                         const void *start, unsigned int len )
-{
-    if ( !conn || conn->type == CR_NO_CONNECTION )
-        return;
-
-    if (!bufp) {
-        /* We're sending a user-allocated buffer.
-         * Simply write the length & the payload and return.
-         */
-        const int sendable_len = conn->swap ? SWAP32(len) : len;
-        crTCPIPWriteExact( conn, &sendable_len, sizeof(len) );
-        if (conn->type == CR_NO_CONNECTION)
-            return;
-        crTCPIPWriteExact( conn, start, len );
-    }
-    else {
-        /* The region [start .. start + len + 1] lies within a buffer that
-         * was allocated with crTCPIPAlloc() and can be put into the free
-         * buffer pool when we're done sending it.
-         */
-        CRTCPIPBuffer *tcpip_buffer;
-        unsigned int *lenp;
-
-        tcpip_buffer = (CRTCPIPBuffer *)(*bufp) - 1;
-
-        CRASSERT( tcpip_buffer->magic == CR_TCPIP_BUFFER_MAGIC );
-
-        /* All of the buffers passed to the send function were allocated
-         * with crTCPIPAlloc(), which includes a header with a 4 byte
-         * pad field, to insure that we always have a place to write
-         * the length field, even when start == *bufp.
-         */
-        lenp = (unsigned int *) start - 1;
-        *lenp = conn->swap ? SWAP32(len) : len;
-
-        crTCPIPWriteExact(conn, lenp, len + sizeof(unsigned int));
-
-        /* Reclaim this pointer for reuse */
-#ifdef CHROMIUM_THREADSAFE
-        crLockMutex(&cr_tcpip.mutex);
-#endif
-        crBufferPoolPush(cr_tcpip.bufpool, tcpip_buffer, tcpip_buffer->allocated);
-#ifdef CHROMIUM_THREADSAFE
-        crUnlockMutex(&cr_tcpip.mutex);
-#endif
-        /* Since the buffer's now in the 'free' buffer pool, the caller can't
-         * use it any more.  Setting bufp to NULL will make sure the caller
-         * doesn't try to re-use the buffer.
-         */
-        *bufp = NULL;
-    }
-}
-
-
-void
-__tcpip_dead_connection( CRConnection *conn )
-{
-    crDebug( "Dead connection (sock=%d, host=%s), removing from pool",
-                   conn->tcp_socket, conn->hostname );
-    /* remove from connection pool */
-    crTCPIPDoDisconnect( conn );
-}
-
-
-int
-__crSelect( int n, fd_set *readfds, int sec, int usec )
-{
-    for ( ; ; ) 
-    { 
-        int err, num_ready;
-
-        if (sec || usec)
-        {
-            /* We re-init everytime for Linux, as it corrupts
-             * the timeout structure, but other OS's
-             * don't have a problem with it.
-             */
-            struct timeval timeout;
-            timeout.tv_sec = sec;
-            timeout.tv_usec = usec;
-            num_ready = select( n, readfds, NULL, NULL, &timeout );
-        } 
-        else
-            num_ready = select( n, readfds, NULL, NULL, NULL );
-
-        if ( num_ready >= 0 )
-        {
-            return num_ready;
-        }
-
-        err = crTCPIPErrno( );
-        if ( err == EINTR )
-        {
-            crWarning( "select interrupted by an unblocked signal, trying again" );
-        }
-        else
-        {
-            crError( "select failed: %s", crTCPIPErrorString( err ) );
-        }
-    }
-}
-
-
-void
-crTCPIPFree( CRConnection *conn, void *buf )
-{
-    CRTCPIPBuffer *tcpip_buffer = (CRTCPIPBuffer *) buf - 1;
-
-    CRASSERT( tcpip_buffer->magic == CR_TCPIP_BUFFER_MAGIC );
-    conn->recv_credits += tcpip_buffer->len;
-
-    switch ( tcpip_buffer->kind )
-    {
-        case CRTCPIPMemory:
-#ifdef CHROMIUM_THREADSAFE
-            crLockMutex(&cr_tcpip.mutex);
-#endif
-            if (cr_tcpip.bufpool) {
-                /* pool may have been deallocated just a bit earlier in response
-                 * to a SIGPIPE (Broken Pipe) signal.
-                 */
-                crBufferPoolPush( cr_tcpip.bufpool, tcpip_buffer, tcpip_buffer->allocated );
-            }
-#ifdef CHROMIUM_THREADSAFE
-            crUnlockMutex(&cr_tcpip.mutex);
-#endif
-            break;
-
-        case CRTCPIPMemoryBig:
-            crFree( tcpip_buffer );
-            break;
-
-        default:
-            crError( "Weird buffer kind trying to free in crTCPIPFree: %d", tcpip_buffer->kind );
-    }
-}
-
-
-/**
- * Check if message type is GATHER.  If so, process it specially.
- * \return number of bytes which were consumed
- */ 
-static int
-crTCPIPUserbufRecv(CRConnection *conn, CRMessage *msg)
-{
-    if (msg->header.type == CR_MESSAGE_GATHER) {
-        /* grab the offset and the length */
-        const int len = 2 * sizeof(unsigned int); /* was unsigned long!!!! */
-        unsigned int buf[2];
-
-        if (__tcpip_read_exact(conn->tcp_socket, buf, len) <= 0)
-        {
-            __tcpip_dead_connection( conn );
-        }
-        msg->gather.offset = buf[0];
-        msg->gather.len = buf[1];
-
-        /* read the rest into the userbuf */
-        if (buf[0] + buf[1] > (unsigned int) conn->userbuf_len)
-        {
-            crDebug("userbuf for Gather Message is too small!");
-            return len;
-        }
-
-        if (__tcpip_read_exact(conn->tcp_socket,
-                                                     conn->userbuf + buf[0], buf[1]) <= 0)
-        {
-            __tcpip_dead_connection( conn );
-        }
-        return len + buf[1];
-    }
-    else {
-        return 0;
-    }
-}
-
-
-/**
- * Receive the next message on the given connection.
- * If we're being called by crTCPIPRecv(), we already know there's
- * something to receive.
- */
-static void
-crTCPIPReceiveMessage(CRConnection *conn)
-{
-    CRMessage *msg;
-    CRMessageType cached_type;
-    CRTCPIPBuffer *tcpip_buffer;
-    unsigned int len, total, leftover;
-    const int sock = conn->tcp_socket;
-
-    /* Our gigE board is acting odd. If we recv() an amount
-     * less than what is already in the RECVBUF, performance
-     * goes into the toilet (somewhere around a factor of 3).
-     * This is an ugly hack, but seems to get around whatever
-     * funk is being produced  
-     *
-     * Remember to set your kernel recv buffers to be bigger
-     * than the framebuffer 'chunk' you are sending (see
-     * sysctl -a | grep rmem) , or this will really have no
-     * effect.   --karl 
-     */      
-#ifdef RECV_BAIL_OUT 
-    {
-        int inbuf;
-        (void) recv(sock, &len, sizeof(len), MSG_PEEK);
-        ioctl(conn->tcp_socket, FIONREAD, &inbuf);
-
-        if ((conn->krecv_buf_size > len) && (inbuf < len))
-            return;
-    }
-#endif
-
-    /* this reads the length of the message */
-    if ( __tcpip_read_exact( sock, &len, sizeof(len)) <= 0 )
-    {
-        __tcpip_dead_connection( conn );
-        return;
-    }
-
-    if (conn->swap)
-        len = SWAP32(len);
-
-    CRASSERT( len > 0 );
-
-    if ( len <= conn->buffer_size )
-    {
-        /* put in pre-allocated buffer */
-        tcpip_buffer = (CRTCPIPBuffer *) crTCPIPAlloc( conn ) - 1;
-    }
-    else
-    {
-        /* allocate new buffer */
-        tcpip_buffer = (CRTCPIPBuffer *) crAlloc( sizeof(*tcpip_buffer) + len );
-        tcpip_buffer->magic = CR_TCPIP_BUFFER_MAGIC;
-        tcpip_buffer->kind  = CRTCPIPMemoryBig;
-        tcpip_buffer->pad   = 0;
-    }
-
-    tcpip_buffer->len = len;
-
-    /* if we have set a userbuf, and there is room in it, we probably 
-     * want to stick the message into that, instead of our allocated
-     * buffer.
-     */
-    leftover = 0;
-    total = len;
-    if ((conn->userbuf != NULL)
-            && (conn->userbuf_len >= (int) sizeof(CRMessageHeader)))
-    {
-        leftover = len - sizeof(CRMessageHeader);
-        total = sizeof(CRMessageHeader);
-    }
-
-    if ( __tcpip_read_exact( sock, tcpip_buffer + 1, total) <= 0 )
-    {
-        crWarning( "Bad juju: %d %d on socket 0x%x", tcpip_buffer->allocated,
-                             total, sock );
-        crFree( tcpip_buffer );
-        __tcpip_dead_connection( conn );
-        return;
-    }
-
-    conn->recv_credits -= total;
-    conn->total_bytes_recv +=  total;
-
-    msg = (CRMessage *) (tcpip_buffer + 1);
-    cached_type = msg->header.type;
-    if (conn->swap)
-    {
-        msg->header.type = (CRMessageType) SWAP32( msg->header.type );
-        msg->header.conn_id = (CRMessageType) SWAP32( msg->header.conn_id );
-    }
-    
-    /* if there is still data pending, it should go into the user buffer */
-    if (leftover)
-    {
-        const unsigned int handled = crTCPIPUserbufRecv(conn, msg);
-
-        /* if there is anything left, plop it into the recv_buffer */
-        if (leftover - handled)
-        {
-            if ( __tcpip_read_exact( sock, tcpip_buffer + 1 + total, leftover-handled) <= 0 )
-            {
-                crWarning( "Bad juju: %d %d", tcpip_buffer->allocated, leftover-handled);
-                crFree( tcpip_buffer );
-                __tcpip_dead_connection( conn );
-                return;
-            }
-        }
-
-        conn->recv_credits -= handled;
-        conn->total_bytes_recv +=  handled;
-    }
-
-    crNetDispatchMessage( cr_tcpip.recv_list, conn, msg, len );
-#if 0
-    crLogRead( len );
-#endif
-
-    /* CR_MESSAGE_OPCODES is freed in crserverlib/server_stream.c with crNetFree.
-     * OOB messages are the programmer's problem.  -- Humper 12/17/01
-     */
-    if (cached_type != CR_MESSAGE_OPCODES
-            && cached_type != CR_MESSAGE_OOB
-            && cached_type != CR_MESSAGE_GATHER) 
-    {
-        crTCPIPFree( conn, tcpip_buffer + 1 );
-    }
-}
-
-
-/**
- * Loop over all TCP/IP connections, reading incoming data on those
- * that are ready.
- */
-int
-crTCPIPRecv( void )
-{
-    /* ensure we don't get caught with a new thread connecting */
-    const int num_conns = cr_tcpip.num_conns;
-    int num_ready, max_fd, i;
-    fd_set read_fds;
-    int msock = -1; /* assumed mothership socket */
-#if CRAPPFAKER_SHOULD_DIE
-    int none_left = 1;
-#endif
-
-#ifdef CHROMIUM_THREADSAFE
-    crLockMutex(&cr_tcpip.recvmutex);
-#endif
-
-    /*
-     * Loop over all connections and determine which are TCP/IP connections
-     * that are ready to be read.
-     */
-    max_fd = 0;
-    FD_ZERO( &read_fds );
-    for ( i = 0; i < num_conns; i++ )
-    {
-        CRConnection *conn = cr_tcpip.conns[i];
-        if ( !conn || conn->type == CR_NO_CONNECTION )
-            continue;
-
-#if CRAPPFAKER_SHOULD_DIE
-        none_left = 0;
-#endif
-
-        if ( conn->recv_credits > 0 || conn->type != CR_TCPIP )
-        {
-            /* 
-             * NOTE: may want to always put the FD in the descriptor
-             * set so we'll notice broken connections.  Down in the
-             * loop that iterates over the ready sockets only peek
-             * (MSG_PEEK flag to recv()?) if the connection isn't
-             * enabled. 
-             */
-#if 0 /* not used - see below */
-#ifndef ADDRINFO
-            struct sockaddr s;
-#else
-            struct sockaddr_storage s;
-#endif
-            socklen_t slen;
-#endif
-            fd_set only_fd; /* testing single fd */
-            CRSocket sock = conn->tcp_socket;
-
-            if ( (int) sock + 1 > max_fd )
-                max_fd = (int) sock + 1;
-            FD_SET( sock, &read_fds );
-
-            /* KLUDGE CITY......
-             *
-             * With threads there's a race condition between
-             * TCPIPRecv and TCPIPSingleRecv when new
-             * clients are connecting, thus new mothership
-             * connections are also being established.
-             * This code below is to check that we're not
-             * in a state of accepting the socket without
-             * connecting to it otherwise we fail with
-             * ENOTCONN later. But, this is really a side
-             * effect of this routine catching a motherships
-             * socket connection and reading data that wasn't
-             * really meant for us. It was really meant for
-             * TCPIPSingleRecv. So, if we detect an
-             * in-progress connection we set the msock id
-             * so that we can assume the motherships socket
-             * and skip over them.
-             */
-            
-            FD_ZERO(&only_fd);
-            FD_SET( sock, &only_fd );
-
-#if 0 /* Disabled on Dec 13 2005 by BrianP - seems to cause trouble */
-            slen = sizeof( s );
-            /* Check that the socket is REALLY connected */
-            /* Doesn't this call introduce some inefficiency??? (BP) */
-            if (getpeername(sock, (struct sockaddr *) &s, &slen) < 0) {
-                /* Another kludge.....
-                 * If we disconnect a socket without writing
-                 * anything to it, we end up here. Detect
-                 * the disconnected socket by checking if
-                 * we've ever sent something and then
-                 * disconnect it.
-                 * 
-                 * I think the networking layer needs
-                 * a bit of a re-write.... Alan.
-                 */
-                if (conn->total_bytes_sent > 0) {
-                    crTCPIPDoDisconnect( conn );
-                }
-                FD_CLR(sock, &read_fds);
-                msock = sock;
-            }
-#endif
-            /* 
-             * Nope, that last socket we've just caught in
-             * the connecting phase. We've probably found
-             * a mothership connection here, and we shouldn't
-             * process it 
-             */
-            if ((int)sock == msock+1)
-                FD_CLR(sock, &read_fds);
-        }
-    }
-
-#if CRAPPFAKER_SHOULD_DIE
-    if (none_left) {
-        /*
-         * Caught no more connections.
-         * Review this if we want to try 
-         * restarting crserver's dynamically.
-         */
-#ifdef CHROMIUM_THREADSAFE
-        crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-        crError("No more connections to process, terminating...\n");
-        exit(0); /* shouldn't get here */
-    }
-#endif
-
-    if (!max_fd) {
-#ifdef CHROMIUM_THREADSAFE
-        crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-        return 0;
-    }
-
-    if ( num_conns ) {
-        num_ready = __crSelect( max_fd, &read_fds, 0, 500 );
-    }
-    else {
-        crWarning( "Waiting for first connection..." );
-        num_ready = __crSelect( max_fd, &read_fds, 0, 0 );
-    }
-
-    if ( num_ready == 0 ) {
-#ifdef CHROMIUM_THREADSAFE
-        crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-        return 0;
-    }
-
-    /*
-     * Loop over connections, receive data on the TCP/IP connections that
-     * we determined are ready above.
-     */
-    for ( i = 0; i < num_conns; i++ )
-    {
-        CRConnection *conn = cr_tcpip.conns[i];
-        CRSocket sock;
-
-        if ( !conn || conn->type == CR_NO_CONNECTION )
-            continue;
-
-        /* Added by Samuel Thibault during TCP/IP / UDP code factorization */
-        if ( conn->type != CR_TCPIP )
-            continue;
-
-        sock = conn->tcp_socket;
-        if ( !FD_ISSET( sock, &read_fds ) )
-            continue;
-
-        if (conn->threaded)
-            continue;
-
-        crTCPIPReceiveMessage(conn);
-    }
-
-#ifdef CHROMIUM_THREADSAFE
-    crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-
-    return 1;
-}
-
-
-static void
-crTCPIPHandleNewMessage( CRConnection *conn, CRMessage *msg, unsigned int len )
-{
-    CRTCPIPBuffer *buf = ((CRTCPIPBuffer *) msg) - 1;
-
-    /* build a header so we can delete the message later */
-    buf->magic = CR_TCPIP_BUFFER_MAGIC;
-    buf->kind  = CRTCPIPMemory;
-    buf->len   = len;
-    buf->pad   = 0;
-
-    crNetDispatchMessage( cr_tcpip.recv_list, conn, msg, len );
-}
-
-
-static void
-crTCPIPInstantReclaim( CRConnection *conn, CRMessage *mess )
-{
-    crTCPIPFree( conn, mess );
-}
-
-
-void
-crTCPIPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl,
-                         unsigned int mtu )
-{
-    (void) mtu;
-
-    cr_tcpip.recv_list = rfl;
-    cr_tcpip.close_list = cfl;
-    if ( cr_tcpip.initialized )
-    {
-        return;
-    }
-
-    cr_tcpip.initialized = 1;
-
-    cr_tcpip.num_conns = 0;
-    cr_tcpip.conns     = NULL;
-    
-    cr_tcpip.server_sock    = -1;
-
-#ifdef CHROMIUM_THREADSAFE
-    crInitMutex(&cr_tcpip.mutex);
-    crInitMutex(&cr_tcpip.recvmutex);
-#endif
-    cr_tcpip.bufpool = crBufferPoolInit(16);
-}
-
-
-/**
- * The function that actually connects.  This should only be called by clients 
- * Servers have another way to set up the socket.
- */
-int
-crTCPIPDoConnect( CRConnection *conn )
-{
-    int err;
-#ifndef ADDRINFO
-    struct sockaddr_in servaddr;
-    struct hostent *hp;
-    int i;
-
-    conn->tcp_socket = socket( AF_INET, SOCK_STREAM, 0 );
-    if ( conn->tcp_socket < 0 )
-    {
-        int err = crTCPIPErrno( );
-        crWarning( "socket error: %s", crTCPIPErrorString( err ) );
-        cr_tcpip.conns[conn->index] = NULL; /* remove from table */
-        return 0;
-    }
-
-    if (SocketCreateCallback) {
-        SocketCreateCallback(CR_SOCKET_CREATE, conn->tcp_socket);
-    }
-
-    /* Set up the socket the way *we* want. */
-    spankSocket( conn->tcp_socket );
-
-    /* Standard Berkeley sockets mumbo jumbo */
-    hp = gethostbyname( conn->hostname );
-    if ( !hp )
-    {
-        crWarning( "Unknown host: \"%s\"", conn->hostname );
-        cr_tcpip.conns[conn->index] = NULL; /* remove from table */
-        return 0;
-    }
-
-    crMemset( &servaddr, 0, sizeof(servaddr) );
-    servaddr.sin_family = AF_INET;
-    servaddr.sin_port = htons( (short) conn->port );
-
-    crMemcpy((char *) &servaddr.sin_addr, hp->h_addr, sizeof(servaddr.sin_addr));
-#else
-    char port_s[NI_MAXSERV];
-    struct addrinfo *res,*cur;
-    struct addrinfo hints;
-
-    sprintf(port_s, "%u", (short unsigned) conn->port);
-
-    crMemset(&hints, 0, sizeof(hints));
-    hints.ai_family = PF;
-    hints.ai_socktype = SOCK_STREAM;
-
-    err = getaddrinfo( conn->hostname, port_s, &hints, &res);
-    if ( err )
-    {
-        crWarning( "Unknown host: \"%s\": %s", conn->hostname, gai_strerror(err) );
-        cr_tcpip.conns[conn->index] = NULL; /* remove from table */
-        return 0;
-    }
-#endif
-
-    /* If brokered, we'll contact the mothership to broker the network
-     * connection.  We'll send the mothership our hostname, the port and
-     * our endianness and will get in return a connection ID number.
-     */
-    if (conn->broker)
-    {
-        crError("There shouldn't be any brokered connections in VirtualBox");
-    }
-
-#ifndef ADDRINFO
-    for (i=1;i;)
-#else
-    for (cur=res;cur;)
-#endif
-    {
-#ifndef ADDRINFO
-
-#ifdef RECV_BAIL_OUT        
-        err = sizeof(unsigned int);
-        if ( getsockopt( conn->tcp_socket, SOL_SOCKET, SO_RCVBUF,
-                (char *) &conn->krecv_buf_size, &err ) )
-        {
-            conn->krecv_buf_size = 0;   
-        }
-#endif
-        if ( !connect( conn->tcp_socket, (struct sockaddr *) &servaddr,
-                    sizeof(servaddr) ) )
-            return 1;
-#else
-
-        conn->tcp_socket = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol );
-        if ( conn->tcp_socket < 0 )
-        {
-            int err2 = crTCPIPErrno( );
-            if (err2 != EAFNOSUPPORT)
-                crWarning( "socket error: %s, trying another way", crTCPIPErrorString( err2 ) );
-            cur=cur->ai_next;
-            continue;
-        }
-
-        if (SocketCreateCallback) {
-            SocketCreateCallback(CR_SOCKET_CREATE, conn->tcp_socket);
-        }
-
-        err = 1;
-        setsockopt(conn->tcp_socket, SOL_SOCKET, SO_REUSEADDR,  &err, sizeof(int));
-
-        /* Set up the socket the way *we* want. */
-        spankSocket( conn->tcp_socket );
-
-#if RECV_BAIL_OUT       
-        err = sizeof(unsigned int);
-        if ( getsockopt( conn->tcp_socket, SOL_SOCKET, SO_RCVBUF,
-                (char *) &conn->krecv_buf_size, &err ) )
-        {
-            conn->krecv_buf_size = 0;   
-        }
-#endif
-
-        if ( !connect( conn->tcp_socket, cur->ai_addr, cur->ai_addrlen ) ) {
-            freeaddrinfo(res);
-            return 1;
-        }
-#endif
-
-        err = crTCPIPErrno( );
-        if ( err == EADDRINUSE || err == ECONNREFUSED )
-            crWarning( "Connection refused to %s:%d, %s",
-                    conn->hostname, conn->port, crTCPIPErrorString( err ) );
-
-        else if ( err == EINTR )
-        {
-            crWarning( "connection to %s:%d "
-                    "interrupted, trying again", conn->hostname, conn->port );
-            continue;
-        }
-        else
-            crWarning( "Couldn't connect to %s:%d, %s",
-                    conn->hostname, conn->port, crTCPIPErrorString( err ) );
-        crCloseSocket( conn->tcp_socket );
-#ifndef ADDRINFO
-        i=0;
-#else
-        cur=cur->ai_next;
-#endif
-    }
-#ifdef ADDRINFO
-    freeaddrinfo(res);
-    crWarning( "Couldn't find any suitable way to connect to %s", conn->hostname );
-#endif
-    cr_tcpip.conns[conn->index] = NULL; /* remove from table */
-    return 0;
-}
-
-
-/**
- * Disconnect this connection, but don't free(conn).
- */
-void
-crTCPIPDoDisconnect( CRConnection *conn )
-{
-    int num_conns = cr_tcpip.num_conns;
-    int none_left = 1;
-    int i;
-
-    /* If this connection has already been disconnected (e.g.
-     * if the connection has been lost and disabled through
-     * a call to __tcpip_dead_connection(), which will then
-     * call this routine), don't disconnect it again; if we
-     * do, and if a new valid connection appears in the same
-     * slot (conn->index), we'll effectively disable the
-     * valid connection by mistake, leaving us unable to
-     * receive inbound data on that connection.
-     */
-    if (conn->type == CR_NO_CONNECTION) return;
-
-    crCloseSocket( conn->tcp_socket );
-    if (conn->hostname) {
-        crFree(conn->hostname);
-        conn->hostname = NULL;
-    }
-    conn->tcp_socket = 0;
-    conn->type = CR_NO_CONNECTION;
-    cr_tcpip.conns[conn->index] = NULL;
-
-    /* see if any connections remain */
-    for (i = 0; i < num_conns; i++) 
-    {
-        if ( cr_tcpip.conns[i] && cr_tcpip.conns[i]->type != CR_NO_CONNECTION )
-            none_left = 0; /* found a live connection */
-    }
-
-#if 0 /* disabled on 13 Dec 2005 by BrianP - this prevents future client
-             * connections after the last one goes away.
-             */
-    if (none_left && cr_tcpip.server_sock != -1)
-    {
-        crDebug("Closing master socket (probably quitting).");
-        crCloseSocket( cr_tcpip.server_sock );
-        cr_tcpip.server_sock = -1;
-#ifdef CHROMIUM_THREADSAFE
-        crFreeMutex(&cr_tcpip.mutex);
-        crFreeMutex(&cr_tcpip.recvmutex);
-#endif
-        crBufferPoolFree( cr_tcpip.bufpool );
-        cr_tcpip.bufpool = NULL;
-        last_port = 0;
-        cr_tcpip.initialized = 0;
-    }
-#endif
-}
-
-
-/**
- * Initialize a CRConnection for tcp/ip.  This is called via the
- * InitConnection() function (and from the UDP module).
- */
-void
-crTCPIPConnection( CRConnection *conn )
-{
-    int i, found = 0;
-    int n_bytes;
-
-    CRASSERT( cr_tcpip.initialized );
-
-    conn->type = CR_TCPIP;
-    conn->Alloc = crTCPIPAlloc;
-    conn->Send = crTCPIPSend;
-    conn->SendExact = crTCPIPWriteExact;
-    conn->Recv = crTCPIPSingleRecv;
-    conn->RecvMsg = crTCPIPReceiveMessage;
-    conn->Free = crTCPIPFree;
-    conn->Accept = crTCPIPAccept;
-    conn->Connect = crTCPIPDoConnect;
-    conn->Disconnect = crTCPIPDoDisconnect;
-    conn->InstantReclaim = crTCPIPInstantReclaim;
-    conn->HandleNewMessage = crTCPIPHandleNewMessage;
-    conn->index = cr_tcpip.num_conns;
-    conn->sizeof_buffer_header = sizeof( CRTCPIPBuffer );
-    conn->actual_network = 1;
-
-    conn->krecv_buf_size = 0;
-
-    /* Find a free slot */
-    for (i = 0; i < cr_tcpip.num_conns; i++) {
-        if (cr_tcpip.conns[i] == NULL) {
-            conn->index = i;
-            cr_tcpip.conns[i] = conn;
-            found = 1;
-            break;
-        }
-    }
-    
-    /* Realloc connection stack if we couldn't find a free slot */
-    if (found == 0) {
-        n_bytes = ( cr_tcpip.num_conns + 1 ) * sizeof(*cr_tcpip.conns);
-        crRealloc( (void **) &cr_tcpip.conns, n_bytes );
-        cr_tcpip.conns[cr_tcpip.num_conns++] = conn;
-    }
-}
-
-
-int crGetHostname( char *buf, unsigned int len )
-{
-    const char *override;
-    int ret;
-
-    override = crGetenv("CR_HOSTNAME");
-    if (override)
-    {
-        crStrncpy(buf, override, len);
-        ret = 0;    
-    }
-    else
-        ret = gethostname( buf, len );
-    return ret;
-}
-
-
-CRConnection** crTCPIPDump( int *num )
-{
-    *num = cr_tcpip.num_conns;
-
-    return cr_tcpip.conns;
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/timer.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/timer.c	(revision 78116)
+++ 	(revision )
@@ -1,129 +1,0 @@
-
-#ifndef WINDOWS
-#include <stddef.h>
-#include <fcntl.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#if defined( IRIX ) || defined( IRIX64 )
-#include <sys/syssgi.h>
-#endif
-#include <sys/errno.h>
-#include <unistd.h>
-#else
-#define WIN32_LEAN_AND_MEAN
-# ifdef VBOX
-#  include <iprt/win/windows.h>
-# else
-#include <windows.h>
-# endif
-#endif
-
-#include "cr_timer.h"
-#include "cr_mem.h"
-#include "cr_error.h"
-
-static double crTimerGetTime( CRTimer *t )
-{
-#if defined( IRIX ) || defined( IRIX64 )
-	if (t->iotimer_addr64) {
-		volatile iotimer64_t counter_value;
-		counter_value = *(t->iotimer_addr64);
-		return ((double) counter_value * .000000000001) * (double) t->cycleval;
-	}
-	else {
-		volatile iotimer32_t counter_value;
-		counter_value = *(t->iotimer_addr32);
-		return ((double) counter_value * .000000000001) * (double) t->cycleval;
-	}
-#elif defined( WINDOWS )
-	QueryPerformanceCounter( &t->performance_counter );
-	return ((double) t->performance_counter.QuadPart)*t->one_over_frequency;
-#elif defined( Linux ) || defined( FreeBSD ) || defined(DARWIN) || defined(AIX) || defined(SunOS) || defined(OSF1)
-	gettimeofday( &t->timeofday, NULL );	
-	return t->timeofday.tv_sec + t->timeofday.tv_usec / 1000000.0;
-#else
-#error TIMERS
-#endif
-}
-
-CRTimer *crTimerNewTimer( void )
-{
-	CRTimer *t = (CRTimer *) crAlloc( sizeof(*t) );
-#if defined(IRIX) || defined( IRIX64 )
-	__psunsigned_t phys_addr, raddr;
-	int poffmask = getpagesize() - 1;
-	int counterSize = syssgi(SGI_CYCLECNTR_SIZE);
-
-	phys_addr = syssgi(SGI_QUERY_CYCLECNTR, &(t->cycleval));
-	if (phys_addr == ENODEV) {
-		crError( "Sorry, this SGI doesn't support timers." );
-	}
-
-	raddr = phys_addr & ~poffmask;
-	t->fd = open("/dev/mmem", O_RDONLY);
-
-	if (counterSize == 64) {
-		t->iotimer_addr64 =
-			(volatile iotimer64_t *)mmap(0, poffmask, PROT_READ,
-																	 MAP_PRIVATE, t->fd, (off_t)raddr);
-		t->unmapLocation = (void *)t->iotimer_addr64;
-		t->unmapSize = poffmask;
-		t->iotimer_addr64 = (iotimer64_t *)((__psunsigned_t)t->iotimer_addr64 +
-				(phys_addr & poffmask));
-	}
-	else if (counterSize == 32) {
-		t->iotimer_addr32 = (volatile iotimer32_t *)mmap(0, poffmask, PROT_READ,
-				MAP_PRIVATE, t->fd,
-				(off_t)raddr);
-		t->unmapLocation = (void *)t->iotimer_addr32;
-		t->unmapSize = poffmask;
-		t->iotimer_addr32 = (iotimer32_t *)((__psunsigned_t)t->iotimer_addr32 +
-				(phys_addr & poffmask));
-	}
-	else {
-		crError( "Fatal timer init error" );
-	}
-#elif defined( WINDOWS )
-	QueryPerformanceFrequency( &t->performance_frequency );
-	t->one_over_frequency = 1.0/((double)t->performance_frequency.QuadPart);
-#endif
-	t->time0 = t->elapsed = 0;
-	t->running = 0;
-	return t;
-}
-
-void crDestroyTimer( CRTimer *t )
-{
-#if defined( IRIX ) || defined( IRIX64 )
-	close( t->fd );
-#endif
-	crFree( t );
-}
-
-void crStartTimer( CRTimer *t )
-{
-    t->running = 1;
-    t->time0 = crTimerGetTime( t );
-}
-
-void crStopTimer( CRTimer *t )
-{
-    t->running = 0;
-    t->elapsed += crTimerGetTime( t ) - t->time0;
-}
-
-void crResetTimer( CRTimer *t )
-{
-    t->running = 0;
-    t->elapsed = 0;
-}
-
-double crTimerTime( CRTimer *t )
-{
-	if (t->running) {
-		crStopTimer( t );
-		crStartTimer( t );
-	}
-	return t->elapsed;
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/udptcpip.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/udptcpip.c	(revision 78116)
+++ 	(revision )
@@ -1,753 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifdef WINDOWS
-#define WIN32_LEAN_AND_MEAN
-#pragma warning( push, 3 )
-#include <winsock2.h>
-#include <ws2tcpip.h> /* for ipv6 */
-#include <time.h>
-#pragma warning( pop )
-#pragma warning( disable : 4514 )
-#pragma warning( disable : 4127 )
-# ifndef VBOX
-typedef int ssize_t;
-# endif
-#define write(a,b,c) send(a,b,c,0)
-#else
-#include <sys/types.h>
-#if defined(OSF1)
-typedef int socklen_t;
-#endif
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#ifdef LINUX
-#define IP_MTU	14
-#endif
-#include <netinet/in.h>
-#if !defined(IRIX) /* ip6.h might not be present on other unix variants either */
-#include <netinet/ip6.h>
-#endif
-#include <netinet/udp.h>
-#ifndef DARWIN
-#include <netinet/tcp.h>
-#endif
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#endif
-
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
-#ifdef AIX
-#include <strings.h>
-#endif
-
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_string.h"
-#include "cr_bufpool.h"
-#include "cr_net.h"
-#include "cr_endian.h"
-#include "cr_threads.h"
-#include "net_internals.h"
-
-#ifdef ADDRINFO
-#define PF PF_UNSPEC
-#endif
-
-#ifndef MSG_TRUNC
-#define MSG_TRUNC 0
-#endif
-
-#ifdef IRIX
-/* IRIX defines this token, but appears to be missing the related types
- * and functions.  Turn it off.
- */
-#undef AF_INET6
-#endif
-
-#if defined( WINDOWS ) || defined( IRIX ) || defined( IRIX64 )
-typedef int socklen_t;
-#endif
-
-static void
-crUDPIPWriteExact( CRConnection *conn, const void *buf, unsigned int len )
-{
-	int retval;
-	if ( len > conn->mtu + sizeof(conn->seq) )
-	{
-		crWarning( "crUDPIPWriteExact(%d): too big a packet for mtu %d, dropping !", len, (int)(conn->mtu + sizeof(conn->seq)) );
-		return;
-	}
-	retval = sendto( conn->udp_socket, buf, len, 0,
-		(struct sockaddr *) &(conn->remoteaddr), sizeof(conn->remoteaddr));
-	if ( retval <= 0 )
-	{
-		int err = crTCPIPErrno( );
-		crWarning( "crUDPIPWriteExact(%d): %s", len, crTCPIPErrorString( err ) );
-#ifdef LINUX
-		if ( err == EMSGSIZE )
-		{
-			int opt;
-			socklen_t leno = sizeof(opt);
-			crDebug( "Too big a UDP packet(%d), looking at new MTU...", len );
-			if ( getsockopt( conn->udp_socket, SOL_IP, IP_MTU_DISCOVER, &opt, &leno) == -1)
-			{
-				err = crTCPIPErrno( );
-				crWarning( "Couldn't determine whether PMTU discovery is used : %s", crTCPIPErrorString( err ) );
-				return;
-			}
-			if ( leno != sizeof(opt) )
-			{
-				crWarning( "Unexpected length %d for PMTU_DISCOVERY option length", leno );
-				return;
-			}
-			if ( opt == IP_PMTUDISC_DONT )
-			{
-				crWarning( "Uh, PMTU discovery isn't enabled ?!" );
-				return;
-			}
-			if ( getsockopt( conn->udp_socket, SOL_IP, IP_MTU, &opt, &leno) == -1 )
-			{
-				err = crTCPIPErrno( );
-				crWarning( "Couldn't determine the MTU : %s", crTCPIPErrorString( err ) );
-				return;
-			}
-			if ( leno != sizeof(opt) )
-			{
-				crWarning( "Unexpected length %d for MTU option length", leno );
-				return;
-			}
-			opt -= sizeof(conn->seq) + sizeof(struct udphdr) + sizeof(struct ip6_hdr);
-			if (opt >= (int) conn->mtu)
-			{
-				crWarning( "But MTU discovery is still bigger ! Narrowing it by hand to %d", conn->mtu = (conn->mtu * 2 / 3) & ~0x3 );
-			}
-			else
-			{
-				crDebug( "new MTU is %d", opt );
-				conn->mtu = opt & ~0x3;
-			}
-		}
-#endif
-	}
-}
-
-static void
-crUDPTCPIPAccept( CRConnection *conn, const char *hostname, unsigned short port )
-{
-	int err;
-	socklen_t		addr_length;
-#ifndef ADDRINFO
-	struct sockaddr		addr;
-	struct sockaddr_in	udpaddr;
-#else
-	struct sockaddr_storage addr;
-	struct addrinfo         *res,*cur;
-	struct addrinfo         hints;
-#endif
-
-	crTCPIPAccept( conn, hostname, port );
-
-#ifndef ADDRINFO
-	conn->udp_socket = socket( AF_INET, SOCK_DGRAM, 0 );
-	if ( conn->udp_socket >= 0 )
-	{
-		memset(&udpaddr, 0, sizeof(udpaddr));
-		udpaddr.sin_family = AF_INET;
-		udpaddr.sin_addr.s_addr = INADDR_ANY;
-		udpaddr.sin_port = htons(0);
-		if ( bind( conn->udp_socket, (struct sockaddr *) &udpaddr, sizeof(udpaddr) ) )
-		{
-			err = crTCPIPErrno( );
-			crWarning( "Couldn't bind socket: %s", crTCPIPErrorString( err ) );
-			crCloseSocket( conn->udp_socket );
-			conn->udp_socket = -1;
-		}
-	}
-#else
-	memset(&hints, 0, sizeof(hints));
-	hints.ai_flags = AI_PASSIVE;
-	hints.ai_family = PF;
-	hints.ai_socktype = SOCK_DGRAM;
-
-	err = getaddrinfo( NULL, "0", &hints, &res);
-	if ( err )
-		crError( "Couldn't find local UDP port: %s", gai_strerror(err));
-
-	conn->udp_socket = -1;
-
-	for (cur=res;cur;cur=cur->ai_next)
-	{
-		conn->udp_socket = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol );
-		if ( conn->udp_socket == -1 )
-		{
-			err = crTCPIPErrno( );
-			if (err != EAFNOSUPPORT)
-				crWarning( "Couldn't create socket of family %i: %s, trying another one", cur->ai_family, crTCPIPErrorString( err ) );
-			continue;
-		}
-		if ( bind( conn->udp_socket, cur->ai_addr, cur->ai_addrlen ) )
-		{
-			err = crTCPIPErrno( );
-			crWarning( "Couldn't bind socket: %s", crTCPIPErrorString( err ) );
-			crCloseSocket( conn->udp_socket );
-			conn->udp_socket = -1;
-			continue;
-		}
-		break;
-
-	}
-	freeaddrinfo(res);
-#endif
-
-	if ( conn->udp_socket < 0 )
-		crError( "Couldn't find local UDP port" );
-	
-	addr_length = sizeof(addr);
-	err = getsockname( conn->udp_socket, (struct sockaddr *) &addr, &addr_length );
-
-	if ( err == -1 )
-		crError( "Couldn't get our local UDP port: %s", crTCPIPErrorString( crTCPIPErrno( ) ) );
-
-	switch (((struct sockaddr *) &addr)->sa_family) {
-	case AF_INET:
-		crTCPIPWriteExact( conn, &((struct sockaddr_in *)&addr)->sin_port,
-				sizeof(((struct sockaddr_in *)&addr)->sin_port));
-		break;
-#ifdef AF_INET6
-	case AF_INET6:
-		crTCPIPWriteExact( conn, &((struct sockaddr_in6 *)&addr)->sin6_port,
-				sizeof(((struct sockaddr_in6 *)&addr)->sin6_port));
-		break;
-#endif
-	default:
-		crError( "Unknown address family: %d", ((struct sockaddr *) &addr)->sa_family);
-	}
-}
-
-
-static unsigned int safelen=0;
-static void crUDPTCPIPSend( CRConnection *conn, void **bufp,
-				const void *start, unsigned int len )
-{
-	static unsigned int safedone=0;
-	CRTCPIPBuffer *udptcpip_buffer;
-	unsigned int      *lenp;
-
-	if ( !conn || conn->type == CR_NO_CONNECTION )
-		return;
-
-	if ( safelen+len > safelen )
-	{
-		safelen+=len;
-		if (safelen-safedone>100000)
-		{
-			safedone=safelen;
-			crDebug( "%dKo safe", safelen/1024 );
-		}
-	}
-
-	conn->seq++;
-	if ( bufp == NULL )
-	{
-		unsigned int len_swap = conn->swap ? SWAP32(len) : len;
-		/* we are doing synchronous sends from user memory, so no need
-		 * to get fancy.  Simply write the length & the payload and
-		 * return. */
-		crTCPIPWriteExact( conn, &len_swap, sizeof(len_swap) );
-		if ( conn->type == CR_NO_CONNECTION ) return;
-		crTCPIPWriteExact( conn, start, len );
-		return;
-	}
-
-	udptcpip_buffer = (CRTCPIPBuffer *)(*bufp) - 1;
-
-	CRASSERT( udptcpip_buffer->magic == CR_TCPIP_BUFFER_MAGIC );
-
-	/* All of the buffers passed to the send function were allocated
-	 * with crTCPIPAlloc(), which includes a header with a 4 byte
-	 * length field, to insure that we always have a place to write
-	 * the length field, even when start == *bufp. */
-	lenp = (unsigned int *) start - 1;
-	if (conn->swap)
-	{
-		*lenp = SWAP32(len);
-	}
-	else
-	{
-		*lenp = len;
-	}
-
-	if ( __tcpip_write_exact( conn->tcp_socket, lenp, len + sizeof(*lenp) ) < 0 )
-	{
-		__tcpip_dead_connection( conn );
-	}
-
-	/* reclaim this pointer for reuse and try to keep the client from
-		 accidentally reusing it directly */
-#ifdef CHROMIUM_THREADSAFE
-	crLockMutex(&cr_tcpip.mutex);
-#endif
-	crBufferPoolPush( cr_tcpip.bufpool, udptcpip_buffer, conn->buffer_size );
-	/* Since the buffer's now in the 'free' buffer pool, the caller can't
-	 * use it any more.  Setting bufp to NULL will make sure the caller
-	 * doesn't try to re-use the buffer.
-	 */
-	*bufp = NULL;
-#ifdef CHROMIUM_THREADSAFE
-	crUnlockMutex(&cr_tcpip.mutex);
-#endif
-}
-
-static unsigned int barflen=0;
-static void crUDPTCPIPBarf( CRConnection *conn, void **bufp,
-				const void *start, unsigned int len)
-{
-	static unsigned int barfdone=0;
-	static const unsigned int sizes[]={
-		0,10,50,100,500,1000,5000,10000,UINT_MAX
-	};
-	static unsigned int nbs[sizeof(sizes)/sizeof(int)] = {
-		0, 0, 0,  0,  0,   0,   0,    0,       0
-	};
-	static unsigned int nb;
-	unsigned int      *seqp;
-	CRTCPIPBuffer *udptcpip_buffer;
-	int i;
-
-	if (!bufp) {
-		crDebug("writing safely %d bytes because from user memory",len);
-		crUDPTCPIPSend( conn, bufp, start, len);
-		return;
-	}
-	if (len > conn->mtu) {
-		crDebug("writing safely %d bytes because that is too much for MTU %d", len, conn->mtu);
-		crUDPTCPIPSend( conn, bufp, start, len);
-		return;
-	}
-
-	if ( barflen+len > barflen )
-	{
-		barflen+=len;
-		nb++;
-		for(i=0;;i++)
-			if (len > sizes[i] && len <= sizes[i+1]) {
-				nbs[i]++;
-				break;
-			}
-		if (barflen-barfdone>1<<22) {
-			barfdone=barflen;
-			crDebug( "send traffic: %d%sMo barfed %dKo safe", barflen/(1024*1024), barflen?"":".0", safelen/1024 );
-			if (nb) {
-				for (i=0; i < (int) (sizeof(sizes)/sizeof(int)-1); i++)
-					fprintf(stderr,"%u:%u%s%% ",sizes[i],(nbs[i]*100)/nb,nbs[i]==0?".0":"");
-				fprintf(stderr,"\n");
-			}
-		}
-	}
-
-	udptcpip_buffer = (CRTCPIPBuffer *)(*bufp) - 1;
-
-	CRASSERT( udptcpip_buffer->magic == CR_TCPIP_BUFFER_MAGIC );
-
-	seqp = (unsigned int *) start - 1;
-	if (conn->swap)
-	{
-		*seqp = SWAP32(conn->seq);
-	}
-	else
-	{
-		*seqp = conn->seq;
-	}
-	crUDPIPWriteExact( conn, seqp, len + sizeof(*seqp) );
-
-	/* reclaim this pointer for reuse and try to keep the client from
-		 accidentally reusing it directly */
-#ifdef CHROMIUM_THREADSAFE
-	crLockMutex(&cr_tcpip.mutex);
-#endif
-	crBufferPoolPush( cr_tcpip.bufpool, udptcpip_buffer, conn->buffer_size );
-#ifdef CHROMIUM_THREADSAFE
-	crUnlockMutex(&cr_tcpip.mutex);
-#endif
-	*bufp = NULL;
-}
-
-static void
-crUDPTCPIPReceive( CRConnection *conn, CRTCPIPBuffer *buf, int len )
-{
-	CRMessage *msg;
-	CRMessageType cached_type;
-#if 0
-	crLogRead( len );
-#endif
-
-	conn->recv_credits -= len;
-
-	conn->total_bytes_recv +=  len;
-
-	msg = (CRMessage *) (buf + 1);
-	cached_type = msg->header.type;
-	if (conn->swap)
-	{
-		msg->header.type = (CRMessageType) SWAP32( msg->header.type );
-		msg->header.conn_id = (CRMessageType) SWAP32( msg->header.conn_id );
-	}
-
-	crNetDispatchMessage( cr_tcpip.recv_list, conn, msg, len );
-
-	/* CR_MESSAGE_OPCODES is freed in
-	 * crserverlib/server_stream.c 
-	 *
-	 * OOB messages are the programmer's problem.  -- Humper 12/17/01 */
-	if (cached_type != CR_MESSAGE_OPCODES && cached_type != CR_MESSAGE_OOB)
-	{
-		crTCPIPFree( conn, buf + 1 );
-	}
-}
-
-int
-crUDPTCPIPRecv( void )
-{
-	int    num_ready, max_fd;
-	fd_set read_fds;
-	int i;
-	/* ensure we don't get caught with a new thread connecting */
-	int num_conns = cr_tcpip.num_conns;
-
-#ifdef CHROMIUM_THREADSAFE
-	crLockMutex(&cr_tcpip.recvmutex);
-#endif
-
-	max_fd = 0;
-	FD_ZERO( &read_fds );
-	for ( i = 0; i < num_conns; i++ )
-	{
-		CRConnection *conn = cr_tcpip.conns[i];
-		if ( !conn || conn->type == CR_NO_CONNECTION ) continue;
-		if ( conn->recv_credits > 0 || conn->type != CR_UDPTCPIP )
-		{
-			/* 
-			 * NOTE: may want to always put the FD in the descriptor
-               		 * set so we'll notice broken connections.  Down in the
-               		 * loop that iterates over the ready sockets only peek
-               		 * (MSG_PEEK flag to recv()?) if the connection isn't
-               		 * enabled. 
-			 */
-			CRSocket sock = conn->tcp_socket;
-
-			if (conn->type != CR_UDPTCPIP)
-				continue;
-
-			if ( (int) sock + 1 > max_fd )
-				max_fd = (int) sock + 1;
-			FD_SET( sock, &read_fds );
-
-			sock = conn->udp_socket;
-			if ( (int) sock + 1 > max_fd )
-				max_fd = (int) sock + 1;
-			FD_SET( sock, &read_fds );
-		}
-	}
-
-	if (!max_fd) {
-#ifdef CHROMIUM_THREADSAFE
-		crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-		return 0;
-	}
-
-	if ( num_conns )
-	{
-		num_ready = __crSelect( max_fd, &read_fds, 0, 500 );
-	}
-	else
-	{
-		crWarning( "Waiting for first connection..." );
-		num_ready = __crSelect( max_fd, &read_fds, 0, 0 );
-	}
-
-	if ( num_ready == 0 ) {
-#ifdef CHROMIUM_THREADSAFE
-		crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-		return 0;
-	}
-
-	for ( i = 0; i < num_conns; i++ )
-	{
-		CRConnection     *conn = cr_tcpip.conns[i];
-		CRTCPIPBuffer *buf;
-		int len;
-		int sock;
-
-		if ( !conn || conn->type == CR_NO_CONNECTION ) continue;
-
-		if ( conn->type != CR_UDPTCPIP )
-			continue;
-
-		if ( conn->udp_packet ) {
-			unsigned int *seq;
-			buf = conn->udp_packet;
-			seq = (unsigned int *)(buf + 1) - 1;
-			if ( *seq == conn->ack )
-			{
-				crUDPTCPIPReceive( conn, buf,
-						conn->udp_packetlen );
-				conn->udp_packet = NULL;
-				i--;	/* can now read other packets */
-				continue;
-			}
-			if ( *seq - conn->ack > (~(0U)) >> 1 )
-			{
-				crError( "%u is older than %u ?!", *seq, conn->ack );
-				crTCPIPFree( conn, buf + 1 );
-				conn->udp_packet = NULL;
-				i--;	/* can now read other packets */
-				continue;
-			}
-			/* still too early, wait for TCP data */
-		}
-		else if ( FD_ISSET(conn->udp_socket, &read_fds ) )
-		{
-			unsigned int *seq;
-			buf = ((CRTCPIPBuffer *) crTCPIPAlloc( conn )) - 1;
-			seq = ((unsigned int *) (buf + 1)) - 1;
-
-			len = recv( conn->udp_socket, (void *)seq,
-				buf->allocated + sizeof(*seq), MSG_TRUNC );
-
-			CRASSERT( len > 0 );
-			CRASSERT( (unsigned int)len <= buf->allocated + sizeof(*seq) );
-			if ( len < (int) sizeof(*seq) )
-			{
-				crWarning( "too short a UDP packet : %d", len);
-				crTCPIPFree( conn, buf + 1 );
-				continue;
-			}
-
-			buf->len = len;
-
-			if ( *seq == conn->ack)
-			{
-				crUDPTCPIPReceive( conn, buf, len );
-				continue;
-			}
-
-			if ( *seq - conn->ack > (~(0U)) >> 1 )
-			{
-				crWarning( "%u is older than %u, dropping", *seq, conn->ack );
-				crTCPIPFree( conn, buf + 1 );
-				continue;
-			}
-			conn->udp_packet = buf;
-			conn->udp_packetlen = len;
-		}
-
-		sock = conn->tcp_socket;
-		if ( !FD_ISSET( sock, &read_fds ) )
-			continue;
-
-		if ( __tcpip_read_exact( sock, &len, sizeof(len)) <= 0 )
-		{
-			__tcpip_dead_connection( conn );
-			i--;
-			continue;
-		}
-
-		if (conn->swap)
-		{
-			len = SWAP32(len);
-		}
-
-		CRASSERT( len > 0 );
-
-		if ( (unsigned int)len <= conn->buffer_size )
-		{
-			buf = (CRTCPIPBuffer *) crTCPIPAlloc( conn ) - 1;
-		}
-		else
-		{
-			buf = (CRTCPIPBuffer *) 
-				crAlloc( sizeof(*buf) + len );
-			buf->magic = CR_TCPIP_BUFFER_MAGIC;
-			buf->kind  = CRTCPIPMemoryBig;
-			buf->pad   = 0;
-		}
-
-		buf->len = len;
-
-		if ( __tcpip_read_exact( sock, buf + 1, len ) <= 0 )
-		{
-			crWarning( "Bad juju: %d %d", buf->allocated, len );
-			crFree( buf );
-			__tcpip_dead_connection( conn );
-			i--;
-			continue;
-		}
-
-		crUDPTCPIPReceive( conn, buf, len );
-		conn->ack++;
-	}
-
-#ifdef CHROMIUM_THREADSAFE
-	crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-
-	return 1;
-}
-
-void crUDPTCPIPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu )
-{
-	crTCPIPInit( rfl, cfl, mtu );
-}
-
-/* The function that actually connects.  This should only be called by clients 
- * Servers have another way to set up the socket. */
-
-static int crUDPTCPIPDoConnect( CRConnection *conn )
-{
-#ifdef WINDOWS
-	unsigned short port;
-#else
-	in_port_t port;
-#endif
-#ifdef LINUX
-	int opt = IP_PMTUDISC_DO;
-#endif
-#ifndef ADDRINFO
-	struct hostent *hp;
-#else
-	int err;
-	char port_s[NI_MAXSERV];
-	struct addrinfo *res,*cur;
-	struct addrinfo hints;
-#endif
-	
-	/* first connect to its tcp port */
-	if ( !crTCPIPDoConnect( conn ) )
-		return 0;
-
-	/* read its UDP port */
-	crTCPIPReadExact( conn, &port, sizeof( port ) );
-	port = ntohs(port);
-
-	crDebug( "Server's UDP port is %d", port);
-
-	/* and connect to it */
-#ifndef ADDRINFO
-	hp = gethostbyname( conn->hostname );
-	if ( !hp )
-	{
-		crWarning( "Unknown host: \"%s\"", conn->hostname );
-		return 0;
-	}
-	conn->udp_socket = socket( AF_INET, SOCK_DGRAM, 0 );
-	memset(&conn->remoteaddr, 0, sizeof(conn->remoteaddr));
-	conn->remoteaddr.sin_family = AF_INET;
-	conn->remoteaddr.sin_port = htons( (short) port );
-
-	memcpy( (char *) &conn->remoteaddr.sin_addr, hp->h_addr,
-			sizeof(conn->remoteaddr.sin_addr) );
-	if ( conn->udp_socket >= 0 ) {
-		if ( connect( conn->udp_socket, (struct sockaddr *) &conn->remoteaddr,
-					sizeof(conn->remoteaddr) ) == -1 )
-			crWarning( "Couldn't connect UDP socket : %s", crTCPIPErrorString( crTCPIPErrno( ) ) );
-	} else {
-#else
-	sprintf(port_s, "%u", port);
-
-	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = PF;
-	hints.ai_socktype = SOCK_DGRAM;
-
-	err = getaddrinfo( conn->hostname, port_s, &hints, &res);
-	if ( err )
-	{
-		crWarning( "Unknown host: \"%s\": %s", conn->hostname, gai_strerror(err) );
-		return 0;
-	}
-
-	for (cur=res;cur;)
-	{
-		conn->udp_socket = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol );
-		if ( conn->udp_socket >= 0 )
-		{
-			if ( connect( conn->udp_socket, cur->ai_addr, cur->ai_addrlen ) == -1 )
-				crWarning( "Couldn't connect UDP socket : %s", crTCPIPErrorString( crTCPIPErrno( ) ) );
-			break;
-		}
-		err = crTCPIPErrno( );
-		if (err != EAFNOSUPPORT)
-			crWarning( "socket error: %s, trying another way", crTCPIPErrorString( err ) );
-		cur=cur->ai_next;
-	}
-	if (!cur) {
-		freeaddrinfo(res);
-#endif
-		crWarning( "Couldn't find any suitable way to connect to %s:%d", conn->hostname, port );
-		return 0;
-	}
-
-#ifdef LINUX
-	if ( setsockopt(conn->udp_socket, SOL_IP, IP_MTU_DISCOVER, &opt, sizeof(opt)) == -1 )
-	{
-		err = crTCPIPErrno( );
-		crWarning( "MTU discovery can't be activated : %s", crTCPIPErrorString( err ) );
-	}
-	else
-	{
-		socklen_t len = sizeof(opt);
-		if ( getsockopt(conn->udp_socket, SOL_IP, IP_MTU, &opt, &len) == -1 )
-			crWarning( "MTU couldn't be got : %s", crTCPIPErrorString( crTCPIPErrno ( ) ) );
-		else
-			if ( len != sizeof(opt) )
-				crWarning( "Unexpected length %d for MTU option length", len );
-			else
-			{
-				opt -= sizeof(conn->seq) + sizeof(struct udphdr) + sizeof(struct ip6_hdr);
-				crDebug( "MTU is (for now) %d", opt );
-				conn->mtu = opt;
-			}
-	}
-#endif
-#ifdef ADDRINFO
-	crMemcpy(&conn->remoteaddr, cur->ai_addr, cur->ai_addrlen);
-	freeaddrinfo(res);
-#endif
-	return 1;
-}
-
-static void crUDPTCPIPDoDisconnect( CRConnection *conn )
-{
-	crCloseSocket( conn->udp_socket );
-	crTCPIPDoDisconnect( conn );
-}
-
-void crUDPTCPIPConnection( CRConnection *conn )
-{
-	crTCPIPConnection( conn );
-
-	conn->type  = CR_UDPTCPIP;
-	conn->Send  = crUDPTCPIPSend;
-	conn->Barf  = crUDPTCPIPBarf;
-	conn->SendExact  = NULL;
-	conn->Recv  = NULL;	/* none for UDP : *must* multiplex ! */
-	conn->Accept = crUDPTCPIPAccept;
-	conn->Connect = crUDPTCPIPDoConnect;
-	conn->Disconnect = crUDPTCPIPDoDisconnect;
-	conn->seq   = 0;
-	conn->ack   = 0;
-	conn->udp_packet = NULL;
-	conn->mtu  -= sizeof(conn->seq); /* some room for seq */
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/url.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/url.c	(revision 78116)
+++ 	(revision )
@@ -1,94 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include "cr_string.h"
-#include "cr_url.h"
-#include "cr_error.h"
-
-static int is_digit_string( const char *s )
-{
-     if (!isdigit( (int) *s))
-	{
-		return 0;
-	}
-
-     while (*s && isdigit ( (int) *s))
-	{
-		s++;
-	}
-
-	return ( *s == 0 );
-}
-
-int crParseURL( const char *url, char *protocol, char *hostname,
-				unsigned short *port, unsigned short default_port )
-{
-	const char *temp, *temp2;
-
-	/* pull off the protocol */
-	temp = crStrstr( url, "://" );
-	if ( temp == NULL && protocol != NULL )
-	{
-		crStrcpy( protocol, "tcpip" );
-		temp = url;
-	}
-	else 
-	{
-		if (protocol != NULL) {
-			int len = temp - url;
-			crStrncpy( protocol, url, len );
-			protocol[len] = 0;
-		}
-		temp += 3;
-	}
-
-	/* handle a trailing :<digits> to specify the port */
-
-	/* there might be a filename here */
-	temp2 = crStrrchr( temp, '/' );
-	if ( temp2 == NULL )
-	{
-		temp2 = crStrrchr( temp, '\\' );
-	}
-	if ( temp2 == NULL )
-	{
-		temp2 = temp;
-	}
-
-	temp2 = crStrrchr( temp2, ':' );
-	if ( temp2 )
-	{
-		if (hostname != NULL) {
-			int len = temp2 - temp;
-			crStrncpy( hostname, temp, len );
-			hostname[len] = 0;
-		}
-		temp2++;
-		if ( !is_digit_string( temp2 ) )
-			goto bad_url;
-
-		if (port != NULL)
-			*port = (unsigned short) atoi( temp2 );
-	}
-	else
-	{
-		if (hostname != NULL)
-			crStrcpy( hostname, temp );
-		if (port != NULL)
-		*port = default_port;
-	}
-
-	return 1;
-
- bad_url:
-	crWarning( "URL: expected <protocol>://"
-				   "<destination>[:<port>], what is \"%s\"?", url );
-	return 0;
-}
Index: trunk/src/VBox/GuestHost/OpenGL/util/util.def
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/util.def	(revision 78116)
+++ trunk/src/VBox/GuestHost/OpenGL/util/util.def	(revision 78190)
@@ -12,12 +12,4 @@
 crDebug
 crInfo
-crParseURL
-crAlloc
-crCalloc
-crAllocDebug
-crCallocDebug
-crRealloc
-crMemset
-crFree
 crStrSplit
 crStrSplitn
@@ -43,5 +35,4 @@
 crBytesToString
 crWordsToString
-crGetHostname
 crGetPID
 crNetAcceptClient
@@ -74,6 +65,4 @@
 crImageSize
 crTextureSize
-crGetenv
-crSetenv
 crHashtableAdd
 crHashtableDelete
@@ -90,22 +79,10 @@
 crFreeHashtableEx
 crHashtableGetDataKey
-crDetermineEndianness
-SWAPDOUBLE
 crBufferPoolInit
 crBufferPoolPush
 crBufferPoolPop
 crBufferPoolFree
-crTimerNewTimer
 crBufferPoolGetNumBuffers
 crBufferPoolGetMaxBuffers
-crDestroyTimer
-crStartTimer
-crStopTimer
-crResetTimer
-crTimerTime
-crMemcpy
-crMemcmp
-crMemZero
-crCalloc
 crSetTSD
 crGetTSD
@@ -129,22 +106,5 @@
 crGetTSD
 crFreeTSD
-crRandFloat
-crRandInt
-crRandSeed
-crRandAutoSeed
-crTransformBBox
-crProjectBBox
-crRectiUnion
-crWarpPoint
-crHullInteriorBox
-crNetSetNodeRange
-crNetSetContextRange
-crNetSetRank
-crNetSetKey
-crSleep
-crSpawn
-crKill
 crGetProcName
-crGetCurrentDir
 crHashtableAllocKeys
 crHashtableDeleteBlock
Index: trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c	(revision 78116)
+++ trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c	(revision 78190)
@@ -32,5 +32,4 @@
 #include "cr_mem.h"
 #include "cr_string.h"
-#include "cr_endian.h"
 #include "cr_threads.h"
 #include "net_internals.h"
@@ -1185,7 +1184,6 @@
  * Called on host side only, to "accept" client connection
  */
-static void crVBoxHGCMAccept( CRConnection *conn, const char *hostname, unsigned short port )
-{
-    RT_NOREF(hostname, port);
+static void crVBoxHGCMAccept( CRConnection *conn)
+{
     VBOXCRHGSMIPROFILE_FUNC_PROLOGUE();
     CRASSERT(conn && conn->pHostBuffer);
@@ -2067,5 +2065,5 @@
  * Called on host side only, to "accept" client connection
  */
-static void crVBoxHGSMIAccept( CRConnection *conn, const char *hostname, unsigned short port )
+static void crVBoxHGSMIAccept( CRConnection *conn)
 {
     VBOXCRHGSMIPROFILE_FUNC_PROLOGUE();
@@ -2186,8 +2184,6 @@
 #endif
 
-void crVBoxHGCMInit(CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu)
-{
-    (void) mtu;
-
+void crVBoxHGCMInit(CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl)
+{
     g_crvboxhgcm.recv_list = rfl;
     g_crvboxhgcm.close_list = cfl;
Index: trunk/src/VBox/GuestHost/OpenGL/util/warp.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/warp.c	(revision 78116)
+++ 	(revision )
@@ -1,24 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_error.h"
-#include "cr_warp.h"
-
-void
-crWarpPoint(const float *align, const float *point, float *result)
-{
-	float w, x, y;
-
-	x = align[0] * point[0] + align[1] * point[1] + align[2];
-	y = align[3] * point[0] + align[4] * point[1] + align[5];
-	w = align[6] * point[0] + align[7] * point[1] + align[8];
-
-	if (w == 0)
-		crError("Crud in alignment matrix --> w == 0. bleh!");
-
-	result[0] = x / w;
-	result[1] = y / w;
-}
