From 328ce7ef71937ee9d701a6898de0921f980e5cef Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Mon, 15 Apr 2013 05:42:51 -0400 Subject: [PATCH] compiler/libec: Resolving long type size properly - Solves Distributed Objects that were deadlocking on UNIX due to Thread ID comparison --- compiler/libec/src/ast.ec | 4 ++-- ecere/src/com/String.ec | 2 +- ecere/src/com/dataTypes.ec | 2 +- ecere/src/com/instance.ec | 4 ++-- ecere/src/gfx/bitmaps/PNGFormat.ec | 2 +- ecere/src/gfx/drivers/LFBDisplayDriver.ec | 28 +++++++++++++-------------- ecere/src/gui/dialogs/ColorPicker.ec | 4 ++-- ecere/src/gui/drivers/XInterface.ec | 32 +++++++++++++++---------------- ecere/src/net/Socket.ec | 4 ++-- ecere/src/sys/EARArchive.ec | 10 +++++----- ecere/src/sys/File.ec | 8 ++++---- ecere/src/sys/GlobalAppSettings.ec | 2 +- ecere/src/sys/Time.ec | 2 +- ecere/src/sys/unicode.ec | 4 ++-- 14 files changed, 54 insertions(+), 54 deletions(-) diff --git a/compiler/libec/src/ast.ec b/compiler/libec/src/ast.ec index 5051507..9b9048d 100644 --- a/compiler/libec/src/ast.ec +++ b/compiler/libec/src/ast.ec @@ -2234,7 +2234,7 @@ static Type ProcessTypeSpecs(OldList specs, bool assumeEllipsis, bool keepTypeNa isTypedef = true; else if(spec.specifier == VOID) specType.kind = voidType; else if(spec.specifier == CHAR) specType.kind = charType; - else if(spec.specifier == INT) { if(specType.kind != shortType && specType.kind != longType) specType.kind = intType; } + else if(spec.specifier == INT) { if(specType.kind != shortType && specType.kind != longType && !isLong) specType.kind = intType; } else if(spec.specifier == UINT) { if(specType.kind != shortType && specType.kind != longType) specType.kind = intType; specType.isSigned = false; } else if(spec.specifier == INT64) specType.kind = int64Type; else if(spec.specifier == VALIST) @@ -2242,7 +2242,7 @@ static Type ProcessTypeSpecs(OldList specs, bool assumeEllipsis, bool keepTypeNa else if(spec.specifier == SHORT) specType.kind = shortType; else if(spec.specifier == LONG) { - if(isLong) + if(isLong || (targetBits == 64 && targetPlatform != win32)) specType.kind = int64Type; else specType.kind = intType; diff --git a/ecere/src/com/String.ec b/ecere/src/com/String.ec index 17fa08a..0ce03d4 100644 --- a/ecere/src/com/String.ec +++ b/ecere/src/com/String.ec @@ -1060,7 +1060,7 @@ public uint GetHexValue(char ** buffer) { char string[20]; GetString(buffer,string,20); - return strtoul(string, null, 16); + return (uint)strtoul(string, null, 16); } public char * StripQuotes(char * string, char * output) diff --git a/ecere/src/com/dataTypes.ec b/ecere/src/com/dataTypes.ec index 24e3fe0..b03956b 100644 --- a/ecere/src/com/dataTypes.ec +++ b/ecere/src/com/dataTypes.ec @@ -1334,7 +1334,7 @@ static char * UInteger_OnGetString(Class _class, unsigned int * data, char * str static bool UInteger_OnGetDataFromString(Class _class, unsigned int * data, char * string) { char * end; - uint result = strtoul(string, &end, 0); + uint result = (uint)strtoul(string, &end, 0); if(end > string) { *data = result; diff --git a/ecere/src/com/instance.ec b/ecere/src/com/instance.ec index 4a77e2a..5dadab7 100644 --- a/ecere/src/com/instance.ec +++ b/ecere/src/com/instance.ec @@ -3466,7 +3466,7 @@ static void ComputeClassParameters(Class templatedClass, char * templateParams, } else if(!strcmp(curParam.dataTypeString, "uint")) { - argument.expression.ui = strtoul(value, null, 0); + argument.expression.ui = (uint)strtoul(value, null, 0); } else if(!strcmp(curParam.dataTypeString, "char")) { @@ -3502,7 +3502,7 @@ static void ComputeClassParameters(Class templatedClass, char * templateParams, } else // if(!strcmp(curParam.dataTypeString, "int")) { - argument.expression.i = strtol(value, null, 0); + argument.expression.i = (int)strtol(value, null, 0); } break; } diff --git a/ecere/src/gfx/bitmaps/PNGFormat.ec b/ecere/src/gfx/bitmaps/PNGFormat.ec index dff0233..ee18986 100644 --- a/ecere/src/gfx/bitmaps/PNGFormat.ec +++ b/ecere/src/gfx/bitmaps/PNGFormat.ec @@ -89,7 +89,7 @@ class PNGFormat : BitmapFormat png_set_tRNS_to_alpha(png_ptr); numPasses = png_set_interlace_handling(png_ptr); - if((result = bitmap.Allocate(null, width, height, 0, pixelFormatRGBA, false))) + if((result = bitmap.Allocate(null, (uint)width, (uint)height, 0, pixelFormatRGBA, false))) { int pass; diff --git a/ecere/src/gfx/drivers/LFBDisplayDriver.ec b/ecere/src/gfx/drivers/LFBDisplayDriver.ec index d31a27b..3b820ac 100644 --- a/ecere/src/gfx/drivers/LFBDisplayDriver.ec +++ b/ecere/src/gfx/drivers/LFBDisplayDriver.ec @@ -159,7 +159,7 @@ static HB_Error hb_getSFntTable(void *font, HB_Tag tableTag, HB_Byte *buffer, HB return HB_Err_Invalid_Argument; error = FT_Load_Sfnt_Table(face, tableTag, 0, buffer, &ftlen); - *length = ftlen; + *length = (uint)ftlen; return (HB_Error)error; } @@ -183,8 +183,8 @@ static HB_Error hb_getPointInOutline(HB_Font font, HB_Glyph glyph, int flags, hb if (point > *nPoints) return (HB_Error)HB_Err_Invalid_SubTable; - *xpos = face->glyph->outline.points[point].x; - *ypos = face->glyph->outline.points[point].y; + *xpos = (int)face->glyph->outline.points[point].x; + *ypos = (int)face->glyph->outline.points[point].y; return HB_Err_Ok; } @@ -246,11 +246,11 @@ static HB_FontClass hb_fontClass = hb_getPointInOutline, hb_getGlyphMetrics, hb_getFontMetric }; -static uint FT_stream_load(FT_Stream stream, uint offset, byte * buffer, uint count) +static uint FT_stream_load(FT_Stream stream, long offset, byte * buffer, long count) { File f = stream->descriptor.pointer; - f.Seek(offset, start); - return count ? f.Read(buffer, 1, count) : 0; + f.Seek((int)offset, start); + return count ? f.Read(buffer, 1, (uint)count) : 0; } static void FT_stream_close(FT_Stream stream) @@ -426,8 +426,8 @@ class GlyphPack : BTNode fontEntry.hbFont.x_ppem = fontEntry.face->size->metrics.x_ppem; fontEntry.hbFont.y_ppem = fontEntry.face->size->metrics.y_ppem; - fontEntry.hbFont.x_scale = fontEntry.face->size->metrics.x_scale; - fontEntry.hbFont.y_scale = fontEntry.face->size->metrics.y_scale; + fontEntry.hbFont.x_scale = (int)fontEntry.face->size->metrics.x_scale; + fontEntry.hbFont.y_scale = (int)fontEntry.face->size->metrics.y_scale; } } @@ -521,7 +521,7 @@ class GlyphPack : BTNode //glyph->top = (int)(ascender - slot->bitmap_top); // + ((faces[c]->size->metrics.height >> 6) - (faces[0]->size->metrics.height >> 6)) + (font.height - (faces[c]->size->metrics.height >> 6)); //glyph->top = (int)(ascender - slot->bitmap_top);// + (font.height - maxHeight); - glyph->top = (int)(ascender - slot->bitmap_top) + (font.height - (faces[c]->size->metrics.height >> 6)) / 2; + glyph->top = (int)(ascender - slot->bitmap_top) + (int)(font.height - (faces[c]->size->metrics.height >> 6)) / 2; // printf("[char: %d] mode: %d, width: %d, height: %d, pitch: %d\n", key + c, slot->bitmap.pixel_mode, slot->bitmap.width, slot->bitmap.rows, slot->bitmap.pitch); xMax = x + slot->bitmap.width; @@ -574,12 +574,12 @@ class GlyphPack : BTNode glyph->w = slot->bitmap.width; glyph->h = slot->bitmap.rows; glyph->glyphNo = glyphNo; - glyph->bx = faces[c]->glyph->metrics.horiBearingX; - glyph->by = faces[c]->glyph->metrics.horiBearingY; + glyph->bx = (int)faces[c]->glyph->metrics.horiBearingX; + glyph->by = (int)faces[c]->glyph->metrics.horiBearingY; glyph->scale = scales[c]; - glyph->ax = slot->advance.x; - glyph->ay = slot->advance.y + (64 - slot->advance.y % 64); + glyph->ax = (int)slot->advance.x; + glyph->ay = (int)(slot->advance.y + (64 - slot->advance.y % 64)); } #if 0 { @@ -3070,7 +3070,7 @@ public class LFBDisplayDriver : DisplayDriver } FT_Set_Transform(fontEntry.face, &matrix, &pen ); FaceSetCharSize(fontEntry.face, size); - font.height = ((fontEntry.face->size->metrics.height) >> 6); //* y_scale; + font.height = (int)((fontEntry.face->size->metrics.height) >> 6); //* y_scale; // printf("Font height is %d\n", font.height); font.fakeItalic = fakeItalic; font.size = size; diff --git a/ecere/src/gui/dialogs/ColorPicker.ec b/ecere/src/gui/dialogs/ColorPicker.ec index ef231b1..a013e9c 100644 --- a/ecere/src/gui/dialogs/ColorPicker.ec +++ b/ecere/src/gui/dialogs/ColorPicker.ec @@ -685,10 +685,10 @@ private: bool NotifyModified(EditBox control) { ColorRGB rgb; - int value = strtoul(control.contents, null, 16); + uint value = (uint)strtoul(control.contents, null, 16); if(strlen(control.contents) <= 6) value |= 0xFF000000; - argb = (unsigned int)value; + argb = value; rgb = argb; cmyk = rgb; hsv = rgb; diff --git a/ecere/src/gui/drivers/XInterface.ec b/ecere/src/gui/drivers/XInterface.ec index a77a200..2983be5 100644 --- a/ecere/src/gui/drivers/XInterface.ec +++ b/ecere/src/gui/drivers/XInterface.ec @@ -253,7 +253,7 @@ static void RepositionDesktop(bool updateChildren) if(data) { int desktops = 0; - desktops = *(long *)data; + desktops = (int)*(long *)data; //printf("_NET_NUMBER_OF_DESKTOPS is %d\n", desktops); @@ -273,7 +273,7 @@ static void RepositionDesktop(bool updateChildren) if(data) { - current = *(long *)data; + current = (int)*(long *)data; XFree(data); data = null; @@ -306,10 +306,10 @@ static void RepositionDesktop(bool updateChildren) { workareas = (long *)data; - x = workareas[current * 4]; - y = workareas[current * 4 + 1]; - w = workareas[current * 4 + 2]; - h = workareas[current * 4 + 3]; + x = (int)workareas[current * 4]; + y = (int)workareas[current * 4 + 1]; + w = (int)workareas[current * 4 + 2]; + h = (int)workareas[current * 4 + 3]; //printf("_NET_WORKAREA is x = %d, y = %d, w = %d, h = %d\n", x, y, w, h); XFree(data); @@ -408,14 +408,14 @@ static bool ProcessKeyMessage(Window window, uint keyCode, int release, XKeyEven */ if(!buf) - buf = malloc(bufsize); + buf = malloc((uint)bufsize); if(windowData && windowData.ic) { - buflength = XmbLookupString(windowData.ic, event, buf, bufsize, &keysym, &status); + buflength = XmbLookupString(windowData.ic, event, buf, (int)bufsize, &keysym, &status); if (status == XBufferOverflow) { - buf = realloc(buf, (bufsize = buflength)); - buflength = XmbLookupString(windowData.ic, event, buf, bufsize, &keysym, &status); + buf = realloc(buf, (uint)(bufsize = buflength)); + buflength = XmbLookupString(windowData.ic, event, buf, (int)bufsize, &keysym, &status); } if(status != XLookupKeySym && status != XLookupBoth && release == 1) keysym = XLookupKeysym(event, 0); @@ -1053,7 +1053,7 @@ class XInterface : Interface { XVisualInfo vinfo; XVisualInfo *vinfo_ret; - long numitems; + int numitems = 0; vinfo.visualid = XVisualIDFromVisual(xSystemVisual); vinfo_ret = XGetVisualInfo(xGlobalDisplay, VisualIDMask, &vinfo, &numitems); @@ -1463,7 +1463,7 @@ class XInterface : Interface event->x_root, event->y_root, &keyFlags, false, false); delete window; //*if(xGlobalDisplay) XLockDisplay(xGlobalDisplay); - lastTime = event->time; + lastTime = (uint)event->time; } break; } @@ -1705,7 +1705,7 @@ class XInterface : Interface //if(event->send_event) { X11Window rootChild; - long rootX, rootY; + int rootX, rootY; XTranslateCoordinates(xGlobalDisplay, event->window, RootWindow(xGlobalDisplay, DefaultScreen(xGlobalDisplay)), 0, 0, &rootX, &rootY, &rootChild); @@ -1749,7 +1749,7 @@ class XInterface : Interface bool laterFocus; activeWindow = (X11Window)window.windowHandle; - timeStamp = event->data.l[1]; + timeStamp = (int)event->data.l[1]; windowData = window.windowData; laterFocus = windowData.laterFocus; @@ -1864,8 +1864,8 @@ class XInterface : Interface bool hadFrameExtents = windowData.gotFrameExtents; windowData.decor = { - left = extents[0], right = extents[1], - top = extents[2], bottom = extents[3] + left = (int)extents[0], right = (int)extents[1], + top = (int)extents[2], bottom = (int)extents[3] }; windowData.gotFrameExtents = true; { diff --git a/ecere/src/net/Socket.ec b/ecere/src/net/Socket.ec index e4e5b1d..80f5d4e 100644 --- a/ecere/src/net/Socket.ec +++ b/ecere/src/net/Socket.ec @@ -305,7 +305,7 @@ public: fd_set ws, es; if(s != -1 && ((type == tcp && (count = SendData(buffer, size, 0))) || - (type == udp && (count = sendto(s, buffer, size,0, (SOCKADDR *)&a, sizeof(a)))))) + (type == udp && (count = (int)sendto(s, buffer, size,0, (SOCKADDR *)&a, sizeof(a)))))) { #if defined(__WIN32__) int error = WSAGetLastError(); @@ -618,7 +618,7 @@ private: else { int len = sizeof(a); - count = recvfrom(s, recvBuffer + recvBytes, + count = (int)recvfrom(s, recvBuffer + recvBytes, recvBufferSize - recvBytes, 0, (SOCKADDR *)&a, &len); strcpy(inetAddress, inet_ntoa(this.a.sin_addr)); inetPort = ntohs((uint16)a.sin_port); diff --git a/ecere/src/sys/EARArchive.ec b/ecere/src/sys/EARArchive.ec index 9523261..5004f91 100644 --- a/ecere/src/sys/EARArchive.ec +++ b/ecere/src/sys/EARArchive.ec @@ -537,7 +537,7 @@ class EARArchive : Archive { unsigned long destLen = entry.size; uncompress(uncompressed, &destLen, compressed, entry.cSize); - entry.size = destLen; + entry.size = (FileSize)destLen; // TODO: Support 64 bit file sizes } delete compressed; } @@ -588,7 +588,7 @@ class EARArchive : Archive { unsigned long destLen = entry.size; uncompress(uncompressed, &destLen, compressed, entry.cSize); - entry.size = destLen; + entry.size = (FileSize)destLen; } delete compressed; } @@ -723,7 +723,7 @@ class EARArchiveDir : ArchiveDir { unsigned long destLen = entry.size; uncompress(uncompressed, &destLen, compressed, entry.cSize); - entry.size = destLen; + entry.size = (FileSize)destLen; } delete compressed; } @@ -1127,7 +1127,7 @@ class EARArchiveDir : ArchiveDir if(compressed) { compress2(compressed, &destLen, uncompressed, entry.size, compression); - entry.cSize = destLen; + entry.cSize = (FileSize)destLen; } } delete uncompressed; @@ -1388,7 +1388,7 @@ class EARFileSystem : FileSystem { unsigned long destLen = entry.size; uncompress(uncompressed, &destLen, compressed, entry.cSize); - entry.size = destLen; + entry.size = (FileSize)destLen; } delete compressed; } diff --git a/ecere/src/sys/File.ec b/ecere/src/sys/File.ec index 72915e9..462bed5 100644 --- a/ecere/src/sys/File.ec +++ b/ecere/src/sys/File.ec @@ -470,7 +470,7 @@ public: virtual uint Tell(void) { - return input ? ftell(input) : ftell(output); + return (uint)(input ? ftell(input) : ftell(output)); } virtual int Read(void * buffer, uint size, uint count) @@ -703,7 +703,7 @@ public: { char string[32]; GetString(string, sizeof(string)); - return strtoul(string, null, 16); + return (uint)strtoul(string, null, 16); } float GetFloat(void) @@ -1395,7 +1395,7 @@ static FileDesc FileFind(char * path, char * extensions) if(!stat(file.path, &s)) { file.stats.attribs = (s.st_mode&S_IFDIR) ? FileAttribs { isDirectory = true } : FileAttribs { isFile = true }; - file.stats.size = s.st_size; + file.stats.size = (FileSize)s.st_size; file.stats.accessed = s.st_atime; file.stats.modified = s.st_mtime; file.stats.created = s.st_ctime; @@ -1671,7 +1671,7 @@ private class FileDesc : struct { stats.attribs = FileAttribs { }; stats.attribs = (s.st_mode&S_IFDIR) ? FileAttribs { isDirectory = true } : FileAttribs { isFile = true }; - stats.size = s.st_size; + stats.size = (FileSize)s.st_size; stats.accessed = s.st_atime; stats.modified = s.st_mtime; stats.created = s.st_ctime; diff --git a/ecere/src/sys/GlobalAppSettings.ec b/ecere/src/sys/GlobalAppSettings.ec index 1944fbe..51ef0d1 100644 --- a/ecere/src/sys/GlobalAppSettings.ec +++ b/ecere/src/sys/GlobalAppSettings.ec @@ -514,7 +514,7 @@ public: case integer: { int * integer = value; - *integer = strtoul(string, null, 0); + *integer = (int)strtol(string, null, 0); break; } } diff --git a/ecere/src/sys/Time.ec b/ecere/src/sys/Time.ec index ecd3486..26ea723 100644 --- a/ecere/src/sys/Time.ec +++ b/ecere/src/sys/Time.ec @@ -822,7 +822,7 @@ public Time GetTime(void) if(!secbase) { - secbase = tp.tv_sec; + secbase = (int)tp.tv_sec; return tp.tv_usec / 1000000.0; } return (tp.tv_sec - secbase) + tp.tv_usec / 1000000.0; diff --git a/ecere/src/sys/unicode.ec b/ecere/src/sys/unicode.ec index 317534b..ce0ef92 100644 --- a/ecere/src/sys/unicode.ec +++ b/ecere/src/sys/unicode.ec @@ -409,10 +409,10 @@ static class UnicodeDatabase if(line[0] && line[0] != '#') { char * endPtr; - uint start = strtoul(line, &endPtr, 16); + uint start = (uint)strtoul(line, &endPtr, 16); if(endPtr) { - uint end = (endPtr && *endPtr == '.') ? strtoul(endPtr + 2, &endPtr, 16) : start; + uint end = (endPtr && *endPtr == '.') ? (uint)strtoul(endPtr + 2, &endPtr, 16) : start; if(endPtr) { endPtr = strchr(endPtr, ';'); -- 1.8.3.1