Fixed crash and 64-bit porting issues

1. "emugen" generates four *dec.cpp files containing code like this
   to decode offset to pointer in stream

   tmp = *(T *)(ptr + 8 + 4 + 4 + 4 + *(size_t *)(ptr +8 + 4 + 4));

   If *dec.cpp are compiled in 64-bit, size_t is 8-byte and dereferencing of
   it is likley to get wild offset for dereferencing of *(T *) to crash the
   code.  Solution is to define tsize_t for "target size_t" instead
   of using host size_t.

2. Cast pointer to "uintptr_t" instead of "unsigned int" for 2nd param of
   ShareGroup::getGlobalName(NamedObjectType, ObjectLocalName/*64bit*/).
3. Instance of EGLSurface, EGLContext and EGLImageKHR are used as 32-bit
   key for std::map< unsigned int, * > SurfacesHndlMap, ContextsHndlMap,
   and ImagesHndlMap, respectively.  Cast pointer to uintptr_t and assert
   upper 32-bit is zero before passing to map::find().
4. Instance of GLeglImageOES is used to eglAttachEGLImage() which expect
   "unsigned int".  Cast it to uintptr_t and assert upper 32-bit is zero.
5. The 5th param to GLEScontext::setPointer is GLvoid* but contains 32-bit
   offset to vbo if bufferName exists.  Cast it to uintptr_t and assert
   upper 32-bit is zero.
6. Use %zu instead of %d to print size_t
7. Cast pointer to (uintptr_t) in many other places

Change-Id: Iba6e5bda08c43376db5b011e9d781481ee1f5a12
This commit is contained in:
Andrew Hsieh
2012-02-29 13:53:37 -08:00
parent a3b1c78767
commit b100b6fd6a
10 changed files with 76 additions and 30 deletions

View File

@@ -17,6 +17,7 @@
#include "EglOsApi.h" #include "EglOsApi.h"
#include <GLcommon/GLutils.h> #include <GLcommon/GLutils.h>
#include <utils/threads.h> #include <utils/threads.h>
#include <assert.h>
EglDisplay::EglDisplay(EGLNativeInternalDisplayType dpy,bool isDefault) : EglDisplay::EglDisplay(EGLNativeInternalDisplayType dpy,bool isDefault) :
m_dpy(dpy), m_dpy(dpy),
@@ -141,8 +142,12 @@ EglConfig* EglDisplay::getConfig(EGLConfig conf) {
SurfacePtr EglDisplay::getSurface(EGLSurface surface) { SurfacePtr EglDisplay::getSurface(EGLSurface surface) {
android::Mutex::Autolock mutex(m_lock); android::Mutex::Autolock mutex(m_lock);
/* surface is "key" in map<unsigned int, SurfacePtr>.
SurfacesHndlMap::iterator it = m_surfaces.find(reinterpret_cast<unsigned int>(surface)); In 64-bit the upper 32-bit should be all zero. Assert for that. */
uintptr_t hndlptr = (uintptr_t)surface;
unsigned int hndl = (unsigned int)hndlptr;
assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
SurfacesHndlMap::iterator it = m_surfaces.find(hndl);
return it != m_surfaces.end() ? return it != m_surfaces.end() ?
(*it).second : (*it).second :
SurfacePtr(NULL); SurfacePtr(NULL);
@@ -150,8 +155,12 @@ SurfacePtr EglDisplay::getSurface(EGLSurface surface) {
ContextPtr EglDisplay::getContext(EGLContext ctx) { ContextPtr EglDisplay::getContext(EGLContext ctx) {
android::Mutex::Autolock mutex(m_lock); android::Mutex::Autolock mutex(m_lock);
/* ctx is "key" in map<unsigned int, ContextPtr>.
ContextsHndlMap::iterator it = m_contexts.find(reinterpret_cast<unsigned int>(ctx)); In 64-bit the upper 32-bit should be all zero. Assert for that. */
uintptr_t hndlptr = (uintptr_t)ctx;
unsigned int hndl = (unsigned int)hndlptr;
assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
ContextsHndlMap::iterator it = m_contexts.find(hndl);
return it != m_contexts.end() ? return it != m_contexts.end() ?
(*it).second : (*it).second :
ContextPtr(NULL); ContextPtr(NULL);
@@ -159,8 +168,12 @@ ContextPtr EglDisplay::getContext(EGLContext ctx) {
bool EglDisplay::removeSurface(EGLSurface s) { bool EglDisplay::removeSurface(EGLSurface s) {
android::Mutex::Autolock mutex(m_lock); android::Mutex::Autolock mutex(m_lock);
/* s is "key" in map<unsigned int, SurfacePtr>.
SurfacesHndlMap::iterator it = m_surfaces.find(reinterpret_cast<unsigned int>(s)); In 64-bit the upper 32-bit should be all zero. Assert for that. */
uintptr_t hndlptr = (uintptr_t)s;
unsigned int hndl = (unsigned int)hndlptr;
assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
SurfacesHndlMap::iterator it = m_surfaces.find(hndl);
if(it != m_surfaces.end()) { if(it != m_surfaces.end()) {
m_surfaces.erase(it); m_surfaces.erase(it);
return true; return true;
@@ -187,8 +200,12 @@ bool EglDisplay::removeSurface(SurfacePtr s) {
bool EglDisplay::removeContext(EGLContext ctx) { bool EglDisplay::removeContext(EGLContext ctx) {
android::Mutex::Autolock mutex(m_lock); android::Mutex::Autolock mutex(m_lock);
/* ctx is "key" in map<unsigned int, ContextPtr>.
ContextsHndlMap::iterator it = m_contexts.find(reinterpret_cast<unsigned int>(ctx)); In 64-bit the upper 32-bit should be all zero. Assert for that. */
uintptr_t hndlptr = (uintptr_t)ctx;
unsigned int hndl = (unsigned int)hndlptr;
assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
ContextsHndlMap::iterator it = m_contexts.find(hndl);
if(it != m_contexts.end()) { if(it != m_contexts.end()) {
m_contexts.erase(it); m_contexts.erase(it);
return true; return true;
@@ -254,7 +271,7 @@ int EglDisplay::doChooseConfigs(const EglConfig& dummy,EGLConfig* configs,int co
} }
EGLSurface EglDisplay::addSurface(SurfacePtr s ) { EGLSurface EglDisplay::addSurface(SurfacePtr s ) {
android::Mutex::Autolock mutex(m_lock); android::Mutex::Autolock mutex(m_lock);
unsigned int hndl = s.Ptr()->getHndl(); unsigned int hndl = s.Ptr()->getHndl();
EGLSurface ret =reinterpret_cast<EGLSurface> (hndl); EGLSurface ret =reinterpret_cast<EGLSurface> (hndl);
@@ -290,13 +307,23 @@ EGLImageKHR EglDisplay::addImageKHR(ImagePtr img) {
ImagePtr EglDisplay::getImage(EGLImageKHR img) { ImagePtr EglDisplay::getImage(EGLImageKHR img) {
android::Mutex::Autolock mutex(m_lock); android::Mutex::Autolock mutex(m_lock);
ImagesHndlMap::iterator i( m_eglImages.find((unsigned int)img) ); /* img is "key" in map<unsigned int, ImagePtr>.
In 64-bit the upper 32-bit should be all zero. Assert for that. */
uintptr_t hndlptr = (uintptr_t)img;
unsigned int hndl = (unsigned int)hndlptr;
assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
ImagesHndlMap::iterator i( m_eglImages.find(hndl) );
return (i != m_eglImages.end()) ? (*i).second :ImagePtr(NULL); return (i != m_eglImages.end()) ? (*i).second :ImagePtr(NULL);
} }
bool EglDisplay:: destroyImageKHR(EGLImageKHR img) { bool EglDisplay:: destroyImageKHR(EGLImageKHR img) {
android::Mutex::Autolock mutex(m_lock); android::Mutex::Autolock mutex(m_lock);
ImagesHndlMap::iterator i( m_eglImages.find((unsigned int)img) ); /* img is "key" in map<unsigned int, ImagePtr>.
In 64-bit the upper 32-bit should be all zero. Assert for that. */
uintptr_t hndlptr = (uintptr_t)img;
unsigned int hndl = (unsigned int)hndlptr;
assert(sizeof(hndl) == sizeof(hndlptr) || hndl == hndlptr);
ImagesHndlMap::iterator i( m_eglImages.find(hndl) );
if (i != m_eglImages.end()) if (i != m_eglImages.end())
{ {
m_eglImages.erase(i); m_eglImages.erase(i);

View File

@@ -1041,13 +1041,13 @@ EGLImageKHR eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum ta
ThreadInfo* thread = getThreadInfo(); ThreadInfo* thread = getThreadInfo();
ShareGroupPtr sg = thread->shareGroup; ShareGroupPtr sg = thread->shareGroup;
if (sg.Ptr() != NULL) { if (sg.Ptr() != NULL) {
unsigned int globalTexName = sg->getGlobalName(TEXTURE, (unsigned int)buffer); unsigned int globalTexName = sg->getGlobalName(TEXTURE, (uintptr_t)buffer);
if (!globalTexName) return EGL_NO_IMAGE_KHR; if (!globalTexName) return EGL_NO_IMAGE_KHR;
ImagePtr img( new EglImage() ); ImagePtr img( new EglImage() );
if (img.Ptr() != NULL) { if (img.Ptr() != NULL) {
ObjectDataPtr objData = sg->getObjectData(TEXTURE, (unsigned int)buffer); ObjectDataPtr objData = sg->getObjectData(TEXTURE, (uintptr_t)buffer);
if (!objData.Ptr()) return EGL_NO_IMAGE_KHR; if (!objData.Ptr()) return EGL_NO_IMAGE_KHR;
TextureData *texData = (TextureData *)objData.Ptr(); TextureData *texData = (TextureData *)objData.Ptr();

View File

@@ -35,6 +35,7 @@
#include <GLES/glext.h> #include <GLES/glext.h>
#include <cmath> #include <cmath>
#include <map> #include <map>
#include <assert.h>
extern "C" { extern "C" {
@@ -586,7 +587,7 @@ GL_API void GL_APIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type
GLESConversionArrays tmpArrs; GLESConversionArrays tmpArrs;
if(ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)) { // if vbo is binded take the indices from the vbo if(ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)) { // if vbo is binded take the indices from the vbo
const unsigned char* buf = static_cast<unsigned char *>(ctx->getBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)); const unsigned char* buf = static_cast<unsigned char *>(ctx->getBindedBuffer(GL_ELEMENT_ARRAY_BUFFER));
indices = buf+reinterpret_cast<unsigned int>(elementsIndices); indices = buf+reinterpret_cast<uintptr_t>(elementsIndices);
} }
ctx->setupArraysPointers(tmpArrs,0,count,type,indices,false); ctx->setupArraysPointers(tmpArrs,0,count,type,indices,false);
@@ -1656,7 +1657,10 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE
{ {
GET_CTX(); GET_CTX();
SET_ERROR_IF(!GLEScmValidate::textureTargetLimited(target),GL_INVALID_ENUM); SET_ERROR_IF(!GLEScmValidate::textureTargetLimited(target),GL_INVALID_ENUM);
EglImage *img = s_eglIface->eglAttachEGLImage((unsigned int)image); uintptr_t imagehndlptr = (uintptr_t)image;
unsigned int imagehndl = (unsigned int)imagehndlptr;
assert(sizeof(imagehndl) == sizeof(imagehndlptr) || imagehndl == imagehndlptr);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
if (img) { if (img) {
// Create the texture object in the underlying EGL implementation, // Create the texture object in the underlying EGL implementation,
// flag to the OpenGL layer to skip the image creation and map the // flag to the OpenGL layer to skip the image creation and map the
@@ -1680,7 +1684,7 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE
texData->height = img->height; texData->height = img->height;
texData->border = img->border; texData->border = img->border;
texData->internalFormat = img->internalFormat; texData->internalFormat = img->internalFormat;
texData->sourceEGLImage = (unsigned int)image; texData->sourceEGLImage = imagehndl;
texData->eglImageDetach = s_eglIface->eglDetachEGLImage; texData->eglImageDetach = s_eglIface->eglDetachEGLImage;
texData->oldGlobal = oldGlobal; texData->oldGlobal = oldGlobal;
} }
@@ -1691,7 +1695,10 @@ GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GL
{ {
GET_CTX(); GET_CTX();
SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM); SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM);
EglImage *img = s_eglIface->eglAttachEGLImage((unsigned int)image); uintptr_t imagehndlptr = (uintptr_t)image;
unsigned int imagehndl = (unsigned int)imagehndlptr;
assert(sizeof(imagehndl) == sizeof(imagehndlptr) || imagehndl == imagehndlptr);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
SET_ERROR_IF(!img,GL_INVALID_VALUE); SET_ERROR_IF(!img,GL_INVALID_VALUE);
SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION); SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION);
@@ -1706,7 +1713,7 @@ GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GL
// //
// flag in the renderbufferData that it is an eglImage target // flag in the renderbufferData that it is an eglImage target
// //
rbData->sourceEGLImage = (unsigned int)image; rbData->sourceEGLImage = imagehndl;
rbData->eglImageDetach = s_eglIface->eglDetachEGLImage; rbData->eglImageDetach = s_eglIface->eglDetachEGLImage;
rbData->eglImageGlobalTexName = img->globalTexName; rbData->eglImageGlobalTexName = img->globalTexName;

View File

@@ -32,6 +32,7 @@
#include "ProgramData.h" #include "ProgramData.h"
#include <GLcommon/TextureUtils.h> #include <GLcommon/TextureUtils.h>
#include <GLcommon/FramebufferData.h> #include <GLcommon/FramebufferData.h>
#include <assert.h>
extern "C" { extern "C" {
@@ -593,7 +594,7 @@ GL_APICALL void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum t
const GLvoid* indices = elementsIndices; const GLvoid* indices = elementsIndices;
if(ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)) { // if vbo is binded take the indices from the vbo if(ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)) { // if vbo is binded take the indices from the vbo
const unsigned char* buf = static_cast<unsigned char *>(ctx->getBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)); const unsigned char* buf = static_cast<unsigned char *>(ctx->getBindedBuffer(GL_ELEMENT_ARRAY_BUFFER));
indices = buf+reinterpret_cast<unsigned int>(elementsIndices); indices = buf+reinterpret_cast<uintptr_t>(elementsIndices);
} }
GLESConversionArrays tmpArrs; GLESConversionArrays tmpArrs;
@@ -2009,7 +2010,10 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglIma
{ {
GET_CTX(); GET_CTX();
SET_ERROR_IF(!GLESv2Validate::textureTargetLimited(target),GL_INVALID_ENUM); SET_ERROR_IF(!GLESv2Validate::textureTargetLimited(target),GL_INVALID_ENUM);
EglImage *img = s_eglIface->eglAttachEGLImage((unsigned int)image); uintptr_t imagehndlptr = (uintptr_t)image;
unsigned int imagehndl = (unsigned int)imagehndlptr;
assert(sizeof(imagehndl) == sizeof(imagehndlptr) || imagehndl == imagehndlptr);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
if (img) { if (img) {
// Create the texture object in the underlying EGL implementation, // Create the texture object in the underlying EGL implementation,
// flag to the OpenGL layer to skip the image creation and map the // flag to the OpenGL layer to skip the image creation and map the
@@ -2033,7 +2037,7 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglIma
texData->height = img->height; texData->height = img->height;
texData->border = img->border; texData->border = img->border;
texData->internalFormat = img->internalFormat; texData->internalFormat = img->internalFormat;
texData->sourceEGLImage = (unsigned int)image; texData->sourceEGLImage = imagehndl;
texData->eglImageDetach = s_eglIface->eglDetachEGLImage; texData->eglImageDetach = s_eglIface->eglDetachEGLImage;
texData->oldGlobal = oldGlobal; texData->oldGlobal = oldGlobal;
} }
@@ -2044,7 +2048,10 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target
{ {
GET_CTX(); GET_CTX();
SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM); SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM);
EglImage *img = s_eglIface->eglAttachEGLImage((unsigned int)image); uintptr_t imagehndlptr = (uintptr_t)image;
unsigned int imagehndl = (unsigned int)imagehndlptr;
assert(sizeof(imagehndl) == sizeof(imagehndlptr) || imagehndl == imagehndlptr);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
SET_ERROR_IF(!img,GL_INVALID_VALUE); SET_ERROR_IF(!img,GL_INVALID_VALUE);
SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION); SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION);
@@ -2059,7 +2066,7 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target
// //
// flag in the renderbufferData that it is an eglImage target // flag in the renderbufferData that it is an eglImage target
// //
rbData->sourceEGLImage = (unsigned int)image; rbData->sourceEGLImage = imagehndl;
rbData->eglImageDetach = s_eglIface->eglDetachEGLImage; rbData->eglImageDetach = s_eglIface->eglDetachEGLImage;
rbData->eglImageGlobalTexName = img->globalTexName; rbData->eglImageGlobalTexName = img->globalTexName;

View File

@@ -7,6 +7,7 @@
#include <GLcommon/TextureUtils.h> #include <GLcommon/TextureUtils.h>
#include <GLcommon/FramebufferData.h> #include <GLcommon/FramebufferData.h>
#include <strings.h> #include <strings.h>
#include <assert.h>
//decleration //decleration
static void convertFixedDirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,unsigned int nBytes,unsigned int strideOut,int attribSize); static void convertFixedDirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,unsigned int nBytes,unsigned int strideOut,int attribSize);
@@ -172,7 +173,9 @@ GLEScontext::~GLEScontext() {
const GLvoid* GLEScontext::setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize) { const GLvoid* GLEScontext::setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize) {
GLuint bufferName = m_arrayBuffer; GLuint bufferName = m_arrayBuffer;
if(bufferName) { if(bufferName) {
unsigned int offset = reinterpret_cast<unsigned int>(data); uintptr_t offsetptr = (uintptr_t)data;
unsigned int offset = offsetptr;
assert(sizeof(offset) == sizeof(offsetptr) || offset == offsetptr);
GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr()); GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr());
m_map[arrType]->setBuffer(size,type,stride,vbo,bufferName,offset,normalize); m_map[arrType]->setBuffer(size,type,stride,vbo,bufferName,offset,normalize);
return static_cast<const unsigned char*>(vbo->getData()) + offset; return static_cast<const unsigned char*>(vbo->getData()) + offset;

View File

@@ -50,7 +50,7 @@ int ReadBuffer::getData()
new_buf = (unsigned char*)realloc(m_buf, new_size); new_buf = (unsigned char*)realloc(m_buf, new_size);
if (!new_buf) { if (!new_buf) {
ERR("Failed to alloc %d bytes for ReadBuffer\n", new_size); ERR("Failed to alloc %zu bytes for ReadBuffer\n", new_size);
return -1; return -1;
} }
m_size = new_size; m_size = new_size;

View File

@@ -520,7 +520,7 @@ int ApiGen::genEncoderImpl(const std::string &filename)
npointers += writeVarEncodingSize(evars[j], fp); npointers += writeVarEncodingSize(evars[j], fp);
} }
if (npointers > 0) { if (npointers > 0) {
fprintf(fp, " + %u*4", npointers); fprintf(fp, " + %zu*4", npointers);
} }
fprintf(fp, ";\n"); fprintf(fp, ";\n");
@@ -562,7 +562,7 @@ int ApiGen::genEncoderImpl(const std::string &filename)
npointers += writeVarEncodingSize(evars[j], fp); npointers += writeVarEncodingSize(evars[j], fp);
} }
if (npointers > 0) { if (npointers > 0) {
fprintf(fp, "%s%u*4", plus, npointers); plus = " + "; fprintf(fp, "%s%zu*4", plus, npointers); plus = " + ";
} }
} }
fprintf(fp,");\n"); fprintf(fp,");\n");
@@ -761,6 +761,7 @@ int ApiGen::genDecoderImpl(const std::string &filename)
fprintf(fp, "#include \"%s_opcodes.h\"\n\n", m_basename.c_str()); fprintf(fp, "#include \"%s_opcodes.h\"\n\n", m_basename.c_str());
fprintf(fp, "#include \"%s_dec.h\"\n\n\n", m_basename.c_str()); fprintf(fp, "#include \"%s_dec.h\"\n\n\n", m_basename.c_str());
fprintf(fp, "#include <stdio.h>\n\n"); fprintf(fp, "#include <stdio.h>\n\n");
fprintf(fp, "typedef unsigned int tsize_t; // Target \"size_t\", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.\n\n");
// decoder switch; // decoder switch;
fprintf(fp, "size_t %s::decode(void *buf, size_t len, IOStream *stream)\n{\n", classname.c_str()); fprintf(fp, "size_t %s::decode(void *buf, size_t len, IOStream *stream)\n{\n", classname.c_str());
@@ -860,7 +861,7 @@ int ApiGen::genDecoderImpl(const std::string &filename)
v->type()->name().c_str(), varoffset.c_str(), v->type()->name().c_str(), varoffset.c_str(),
varoffset.c_str()); varoffset.c_str());
} }
varoffset += " + 4 + *(size_t *)(ptr +" + varoffset + ")"; varoffset += " + 4 + *(tsize_t *)(ptr +" + varoffset + ")";
} else { // out pointer; } else { // out pointer;
if (pass == PASS_TmpBuffAlloc) { if (pass == PASS_TmpBuffAlloc) {
fprintf(fp, "\t\t\tsize_t tmpPtr%uSize = (size_t)*(unsigned int *)(ptr + %s);\n", fprintf(fp, "\t\t\tsize_t tmpPtr%uSize = (size_t)*(unsigned int *)(ptr + %s);\n",

View File

@@ -73,7 +73,7 @@ void *SocketStream::allocBuffer(size_t minSize)
m_buf = p; m_buf = p;
m_bufsize = allocSize; m_bufsize = allocSize;
} else { } else {
ERR("%s: realloc (%d) failed\n", __FUNCTION__, allocSize); ERR("%s: realloc (%zu) failed\n", __FUNCTION__, allocSize);
free(m_buf); free(m_buf);
m_buf = NULL; m_buf = NULL;
m_bufsize = 0; m_bufsize = 0;

View File

@@ -20,6 +20,7 @@
#include <windows.h> #include <windows.h>
#else // !WIN32 #else // !WIN32
#include <pthread.h> #include <pthread.h>
#include <inttypes.h>
#endif #endif
namespace osUtils { namespace osUtils {

View File

@@ -84,7 +84,7 @@ Thread::thread_main(void *p_arg)
pthread_mutex_lock(&self->m_lock); pthread_mutex_lock(&self->m_lock);
self->m_isRunning = false; self->m_isRunning = false;
self->m_exitStatus = (int)ret; self->m_exitStatus = (int)(intptr_t)ret;
pthread_mutex_unlock(&self->m_lock); pthread_mutex_unlock(&self->m_lock);
return ret; return ret;