コード例 #1
0
pbool PNetworkServer::send(PNetworkPeer *peer, const puint8 *message, pint32 length)
{
    if (m_state == NETWORK_CONNECTED)
    {
        PMap<puint32, PNetworkPeer*>::iterator it = m_peers.find(peer->id());
        if (it != m_peers.end())
        {
            if (length == -1)
            {
                m_data->packet->dataLength = pstrlen((const pchar *)message) + 1;
            }
            else
            {
                m_data->packet->dataLength = length;
            }
            
            pmemcpy(m_data->packet->data, message, m_data->packet->dataLength);
            if (enet_peer_send(peer->data()->peer, 0, m_data->packet) < 0)
            {
                PLOG_ERROR("Failed to send message to peer (%d).", peer->id());
                return false;
            }

            return true;
        }
    }

    return false;
}
コード例 #2
0
static void test_align(int dalign, int salign, int len)
{
	char *src = aligned(buf);
	char *dst = aligned(buf + 128);
	char *want = aligned(buf + 256);
	char *p;
	int i;

	if (salign + len > N || dalign + len > N)
		abort();
	for (i = 0; i < N; i++) {
		src[i] = '#';
		dst[i] = want[i] = ' ';
	}
	for (i = 0; i < len; i++)
		src[salign+i] = want[dalign+i] = '0'+i;
	p = pmemcpy(dst+dalign, src+salign, len);
	if (p != dst+dalign)
		t_error("memcpy(%p,...) returned %p\n", dst+dalign, p);
	for (i = 0; i < N; i++)
		if (dst[i] != want[i]) {
			t_error("memcpy(align %d, align %d, %d) failed\n", dalign, salign, len);
			t_printf("got : %.*s\n", dalign+len+1, dst);
			t_printf("want: %.*s\n", dalign+len+1, want);
			break;
		}
}
コード例 #3
0
void PMaterialParameter::operator=(const PMatrix4x4 *value)
{
    PASSERT(m_size >= 1 && m_uniformType == P_GLSHADERUNIFORM_FLOATMATRIX4X4 ||
            m_uniformType == P_GLSHADERUNIFORM_UNKNOWN);
    if (m_size >= 1 && m_uniformType == P_GLSHADERUNIFORM_FLOATMATRIX4X4)
    {
        pmemcpy(m_value.v, value, sizeof(PMatrix4x4) * m_size);
    }
}
コード例 #4
0
void PMaterialParameter::operator=(const PVector3 *value)
{
    PASSERT(m_size >= 1 && m_uniformType == P_GLSHADERUNIFORM_FLOAT3 ||
            m_uniformType == P_GLSHADERUNIFORM_UNKNOWN);
    if (m_size >= 1 && m_uniformType == P_GLSHADERUNIFORM_FLOAT3)
    {
        pmemcpy(m_value.v, value, sizeof(PVector3) * m_size);
    }
}
コード例 #5
0
void PMaterialParameter::operator=(const pfloat32 *value)
{
    PASSERT(m_size >= 1 && m_uniformType == P_GLSHADERUNIFORM_FLOAT ||
            m_uniformType == P_GLSHADERUNIFORM_UNKNOWN);
    if (m_size >= 1 && m_uniformType == P_GLSHADERUNIFORM_FLOAT)
    {
        pmemcpy(m_value.v, value, sizeof(pfloat32) * m_size);
    }
}
コード例 #6
0
void PMaterialParameter::operator=(const PMatrix3x3 &value)
{
    PASSERT(m_uniformType == P_GLSHADERUNIFORM_FLOATMATRIX3X3 ||
            m_uniformType == P_GLSHADERUNIFORM_UNKNOWN);
    if (m_uniformType == P_GLSHADERUNIFORM_FLOATMATRIX3X3)
    {
        pmemcpy(m_value.v, &value, sizeof(PMatrix3x3));
    }
}
コード例 #7
0
void PMaterialParameter::operator=(const PVector4 &value)
{
    PASSERT(m_uniformType == P_GLSHADERUNIFORM_FLOAT4 ||
            m_uniformType == P_GLSHADERUNIFORM_UNKNOWN);
    if (m_uniformType == P_GLSHADERUNIFORM_FLOAT4)
    {
        pmemcpy(m_value.v, &value, sizeof(PVector4));
    }
}
コード例 #8
0
ファイル: oom_south.c プロジェクト: CumulusNetworks/oom
int oom_get_memory_sff(oom_port_t* port, int address, int page, int offset, int len, uint8_t* data)
{
	int i;
	uint8_t* i2cptr;

	long port_num = (long) port->handle;
	/* comment here to quiet the tracking of this call *
	printf("GET: Port: %d, address: 0x%2X, page: %d, offset: %d, len: %d\n", port_num, 
		address, page, offset, len); 
	 * catcher for comment above */
	
	i2cptr = port_i2c_data[port_num];  /* get the data for this port */
	i2cptr += address*256;  /* select the data at the right i2c address */
	pmemcpy(&i2cptr[128], &port_page_data[port_num][page*128], 128); /* copy page into i2c */

	pmemcpy(data, &i2cptr[offset], len);  /* copy the requested data */
	return(len);
}
コード例 #9
0
ファイル: oom_south.c プロジェクト: CumulusNetworks/oom
int oom_set_memory_sff(oom_port_t* port, int address, int page, int offset, int len, uint8_t* data)
{
	int i, i2clen;
	int pageoffset, pagelen;
	uint8_t* i2cptr;
	uint8_t* pageptr;
	
	long port_num = (long) port->handle;
	/*
	printf("SET: Port: %d, address: 0x%2X, page: %d, offset: %d, len: %d\n", port_num, 
		address, page, offset, len);
	*/
	
	i2cptr = port_i2c_data[port_num];  /* get the data for this port */
	i2cptr += address*256;  /* select the data at the right i2c address */
	pageptr = port_page_data[port_num];  /* point to page data for this port */
	pageptr += page*128; /* select the right page */
	
	i2clen = 0; /* assume skipping over i2c lower range */
	pageoffset = offset - 128; /* assume skipping over i2c lower range */
	pagelen = len;  /* assume skipping over ic2 lower range */

	if (offset <128) {  /* write just to the end of i2c lower */
		if ((offset + len) > 128) {
			i2clen = 128 - offset;
		} else {
			i2clen = len;
		}
	
		pmemcpy(&i2cptr[offset], data, i2clen); /* write the i2c space */

		/* adjust page pointers to account for writing some to i2c space */
		pageoffset = 0; /* start writing page at beginning */
		pagelen = len - i2clen;
	}
	if (pagelen > 0) { /* some data to be copied to the page */
		pmemcpy(&pageptr[pageoffset], &data[i2clen], pagelen);
	}
	
	return(len);
}
コード例 #10
0
ファイル: pimage.cpp プロジェクト: Freedom000/FutureInterface
PImage::PImage(const puint8 *data, puint32 width, puint32 height, 
    PImagePixelFormatEnum pixelFormat)
{
    puint32 b = bpp(pixelFormat);
    puint32 size = width * height * b;
    m_data = PNEWARRAY(puint8, size);
    if (data != P_NULL)
    {
        pmemcpy(m_data, data, size);
    }

    m_width = width;
    m_height = height;
    m_pixelFormat = pixelFormat;
}
コード例 #11
0
ファイル: pimage.cpp プロジェクト: Freedom000/FutureInterface
PImage::PImage(const PImage& other)
{
    m_width = other.m_width;
    m_height = other.m_height;
    m_pixelFormat = other.m_pixelFormat;
    m_data = P_NULL;

    if (other.m_data != P_NULL)
    {
        puint32 b = bpp(m_pixelFormat);
        puint32 size = m_width * m_height * b;
        m_data = PNEWARRAY(puint8, size);
        pmemcpy(m_data, other.m_data, size);
    }
}
コード例 #12
0
void PNetworkServer::broadcast(const puint8 *message, pint32 length)
{
    if (m_state == NETWORK_CONNECTED)
    {
        if (length == -1)
        {
            m_data->packet->dataLength = pstrlen((const pchar *)message) + 1;
        }
        else
        {
            m_data->packet->dataLength = length;
        }
        pmemcpy(m_data->packet->data, message, m_data->packet->dataLength);
        enet_host_broadcast(m_data->server, 0, m_data->packet);
        enet_host_flush(m_data->server);
    }
}
コード例 #13
0
ファイル: oom_south.c プロジェクト: CumulusNetworks/oom
int oom_get_memory_cfp(oom_port_t* port, int address, int len, uint16_t* data)
{

	long port_num = (long) port->handle;
	printf("GET16: Port: %d, address: 0x%2X, len: %d\n", port_num, address, len);
	if (port->oom_class != OOM_PORT_CLASS_CFP) {
		printf("Not a CFP port, not writing to memory\n");
		return(-1);
	}
	
	if ((address < 0x8000) || ((address + len - 1) >0xFFFF)) {
		printf("Not a legal CFP address, not writing to memory\n");
		return(-1);
	}

	pmemcpy(data, &port_CFP_data[port_num][address], len*2);	

	return(len);
}
コード例 #14
0
PMaterialParameter::PMaterialParameter(const PMaterialParameter &other)
    : PAbstractRenderParameter(other.m_name.c_str(), other.m_uniformName.c_str())
    , m_size(other.m_size)
    , m_upload(other.m_upload)
{
    m_uniformType = other.m_uniformType;

    if (m_uniformType == P_GLSHADERUNIFORM_FLOAT ||
        m_uniformType == P_GLSHADERUNIFORM_INT ||
        m_uniformType == P_GLSHADERUNIFORM_BOOL ||
        m_uniformType == P_GLSHADERUNIFORM_SAMPLER2D ||
        m_uniformType == P_GLSHADERUNIFORM_SAMPLERCUBE)
    {
        m_value = other.m_value;
    }
    else 
    {
        puint32 dataTypeSizes[] = 
        {
            4, // P_GLSHADERUNIFORM_FLOAT,
            8, // P_GLSHADERUNIFORM_FLOAT2,
            12, // P_GLSHADERUNIFORM_FLOAT3,
            16, // P_GLSHADERUNIFORM_FLOAT4,
            4, // P_GLSHADERUNIFORM_INT,
            8, // P_GLSHADERUNIFORM_INT2,
            12, // P_GLSHADERUNIFORM_INT3,
            16, // P_GLSHADERUNIFORM_INT4,
            4, // P_GLSHADERUNIFORM_BOOL,
            8, // P_GLSHADERUNIFORM_BOOL2,
            12, // P_GLSHADERUNIFORM_BOOL3,
            16, // P_GLSHADERUNIFORM_BOOL4,
            16, // P_GLSHADERUNIFORM_FLOATMATRIX2X2,
            36, // P_GLSHADERUNIFORM_FLOATMATRIX3X3,
            64, // P_GLSHADERUNIFORM_FLOATMATRIX4X4,
            4, // P_GLSHADERUNIFORM_SAMPLER2D,
            4, // P_GLSHADERUNIFORM_SAMPLERCUBE,
        };
        
        m_value.v = PNEWARRAY(puint8, dataTypeSizes[m_uniformType] * m_size);
        pmemcpy(m_value.v, other.m_value.v, dataTypeSizes[m_uniformType] * m_size);
    }
}
コード例 #15
0
ファイル: pimage.cpp プロジェクト: Freedom000/FutureInterface
const PImage& PImage::operator=(const PImage& other)
{
    if (this != &other)
    {
        m_width = other.m_width;
        m_height = other.m_height;
        m_pixelFormat = other.m_pixelFormat;
        m_data = P_NULL;

        if (other.m_data != P_NULL)
        {
            puint32 b = bpp(m_pixelFormat);
            puint32 size = m_width * m_height * b;
            m_data = PNEWARRAY(puint8, size);
            pmemcpy(m_data, other.m_data, size);
        }
    }

    return *this;
}