Ticket #200: libbasic_fix_1_of_1_rev_574962856f04_Issue__200__fixed___basicAt_______basicAt_put___to_work_with_objects_bigger_than_2GB.patch

File libbasic_fix_1_of_1_rev_574962856f04_Issue__200__fixed___basicAt_______basicAt_put___to_work_with_objects_bigger_than_2GB.patch, 31.3 KB (added by jan vrany, 6 years ago)
  • Behavior.st

    # HG changeset patch
    # User Jan Vrany <jan.vrany@fit.cvut.cz>
    # Date 1523608628 -3600
    #      Fri Apr 13 09:37:08 2018 +0100
    # Branch jv
    # Node ID 574962856f042b0a8dce930e144727927ecf1976
    # Parent  cd0581d5639bd0608c7e6aae7aa486ce6bd82dd4
    Issue #200: fixed `#basicAt:` / `#basicAt:put:` to work with objects bigger than 2GB
    
    Some methods or their part used only 32bit `int` as an index to an object. If object
    was larger than 2GB, 32bit index suddenly become negative, causing `#basicAt:put:`
    writing outside the object itself.
    
    To fix that we have to use `INT` (`intptr_t`). However, there can be other cases
    like this both n the smalltalk code and in the VM. We may use GCC's
    `-Wconversion` to catch this, see issue #204.
    
    https://swing.fit.cvut.cz/projects/stx-jv/ticket/200
    
    diff -r cd0581d5639b -r 574962856f04 Behavior.st
    a b  
    45354535%{
    45364536    INT nBytes = __intVal(nInstvars) * sizeof(OBJ) + OHDR_SIZE;
    45374537    if (__isSmallInteger(n)) {
    4538         int nIndex;
     4538        unsigned INT nIndex;
    45394539
    45404540        nIndex = __intVal(n);
    45414541        switch (__intVal(__INST(flags)) & ARRAYMASK) {
  • ByteArray.st

    diff -r cd0581d5639b -r 574962856f04 ByteArray.st
    a b  
    232232
    233233%{  /* NOCONTEXT */
    234234
    235     REGISTER int indx;
     235    REGISTER INT indx;
    236236    REGISTER OBJ slf;
    237237    REGISTER OBJ cls;
    238     REGISTER int nIndex;
     238    REGISTER INT nIndex;
    239239
    240240    if (__isSmallInteger(index)) {
    241241        indx = __intVal(index) - 1;
     
    249249            indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
    250250        }
    251251        nIndex = __byteArraySize(slf);
    252         if ((unsigned)indx < (unsigned)nIndex) {
     252        if ((unsigned INT)indx < (unsigned INT)nIndex) {
    253253            RETURN ( __mkSmallInteger((__ByteArrayInstPtr(slf)->ba_element[indx])) );
    254254        }
    255255    }
     
    266266
    267267%{  /* NOCONTEXT */
    268268
    269     REGISTER int indx;
    270     int nIndex;
     269    REGISTER INT indx;
     270    unsigned INT nIndex;
    271271    int val;
    272272    REGISTER OBJ slf;
    273273    REGISTER OBJ cls;
     
    286286                indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
    287287            }
    288288            nIndex = __byteArraySize(slf);
    289             if ((unsigned)indx < (unsigned)nIndex) {
     289            if ((unsigned INT)indx < (unsigned INT)nIndex) {
    290290                __ByteArrayInstPtr(slf)->ba_element[indx] = val;
    291291                RETURN ( value );
    292292            }
     
    306306
    307307%{  /* NOCONTEXT */
    308308
    309     REGISTER int indx;
     309    REGISTER INT indx;
    310310    REGISTER int byte;
    311     int nIndex;
     311    unsigned INT nIndex;
    312312    REGISTER OBJ slf;
    313313    REGISTER OBJ cls;
    314314
     
    324324            byte += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
    325325        }
    326326        nIndex = __byteArraySize(slf);
    327         if ((unsigned)byte < (unsigned)nIndex) {
     327        if ((unsigned)byte < (unsigned INT)nIndex) {
    328328            RETURN ( __mkSmallInteger(((__ByteArrayInstPtr(slf)->ba_element[byte] & (1 << indx)) != 0)) );
    329329        }
    330330    }
     
    349349
    350350%{  /* NOCONTEXT */
    351351
    352     REGISTER int indx;
     352    REGISTER INT indx;
    353353    REGISTER int byte;
    354     int nIndex;
     354    unsigned INT nIndex;
    355355    REGISTER OBJ slf;
    356356    REGISTER OBJ cls;
    357357
     
    367367            byte += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
    368368        }
    369369        nIndex = __byteArraySize(slf);
    370         if ((unsigned)byte < (unsigned)nIndex) {
     370        if ((unsigned)byte < (unsigned INT)nIndex) {
    371371            __ByteArrayInstPtr(slf)->ba_element[byte] &= ~(1 << indx);
    372372            RETURN (slf);
    373373        }
     
    414414        if (indx >= 0) {
    415415            int byteIndex;
    416416            int bitIndex;
    417             int nIndex;
     417            unsigned INT nIndex;
    418418
    419419            byteIndex = indx / 8;
    420420            bitIndex = indx % 8;
    421421
    422422            nIndex = __byteArraySize(self);
    423             if ((unsigned)byteIndex < (unsigned)nIndex) {
     423            if ((unsigned)byteIndex < (unsigned INT)nIndex) {
    424424                __ByteArrayInstPtr(self)->ba_element[byteIndex] |= (1 << bitIndex);
    425425                RETURN (self);
    426426            }
     
    462462
    463463%{  /* NOCONTEXT */
    464464
    465     REGISTER int indx;
    466     int nIndex;
     465    REGISTER INT indx;
     466    unsigned INT nIndex;
    467467    REGISTER OBJ slf;
    468468    REGISTER OBJ cls;
    469469
     
    475475            indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
    476476        }
    477477        nIndex = __byteArraySize(slf);
    478         if ((unsigned)indx < (unsigned)nIndex) {
     478        if ((unsigned INT)indx < (unsigned INT)nIndex) {
    479479            RETURN ( __mkSmallInteger((__ByteArrayInstPtr(slf)->ba_element[indx])) );
    480480        }
    481481    }
     
    490490
    491491%{  /* NOCONTEXT */
    492492
    493     REGISTER int indx;
    494     int nIndex;
     493    REGISTER INT indx;
     494    unsigned INT nIndex;
    495495    int val;
    496496    REGISTER OBJ slf;
    497497    REGISTER OBJ cls;
     
    507507                indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
    508508            }
    509509            nIndex = __byteArraySize(slf);
    510             if ((unsigned)indx < (unsigned)nIndex) {
     510            if ((unsigned INT)indx < (unsigned INT)nIndex) {
    511511                __ByteArrayInstPtr(slf)->ba_element[indx] = val;
    512512                RETURN ( value );
    513513            }
     
    532532%{  /* NOCONTEXT */
    533533
    534534    REGISTER INT indx;
    535     int nIndex;
     535    unsigned INT nIndex;
    536536    union {
    537537        unsigned char u_char[4];
    538538        unsigned int u_uint;
     
    596596%{  /* NOCONTEXT */
    597597
    598598    REGISTER INT indx;
    599     int nIndex;
     599    unsigned INT nIndex;
    600600    int val;
    601601    OBJ cls;
    602602    unsigned char *byteP;
     
    688688%{  /* NOCONTEXT */
    689689
    690690    REGISTER INT indx;
    691     int nIndex;
     691    unsigned INT nIndex;
    692692    union {
    693693        unsigned char u_char[2];
    694694        unsigned short u_ushort;
     
    728728
    729729%{  /* NOCONTEXT */
    730730    REGISTER INT indx;
    731     int nIndex;
     731    unsigned INT nIndex;
    732732    int val;
    733733    unsigned char *byteP;
    734734
     
    805805%{  /* NOCONTEXT */
    806806
    807807    REGISTER INT indx;
    808     int nIndex;
     808    unsigned INT nIndex;
    809809    int v;
    810810    union {
    811811        unsigned char u_char[2];
     
    874874%{  /* NOCONTEXT */
    875875
    876876    REGISTER INT indx;
    877     int nIndex;
     877    unsigned INT nIndex;
    878878    int val;
    879879    OBJ cls;
    880880    unsigned char *byteP;
  • ExternalBytes.st

    diff -r cd0581d5639b -r 574962856f04 ExternalBytes.st
    a b  
    799799%{  /* NOCONTEXT */
    800800
    801801    unsigned char *cp = (unsigned char *)(__INST(address_));
    802     int idx;
     802    INT indx;
    803803    OBJ sz;
    804804
    805805    if (cp && __isSmallInteger(index)) {
    806         idx = __intVal(index);
    807         if (idx > 0) {
     806        indx = __intVal(index);
     807        if (indx > 0) {
    808808            if (((sz = __INST(size)) == nil)
    809              || (__intVal(sz) >= idx)) {
    810                 cp = cp + idx - 1;
     809             || (__intVal(sz) >= indx)) {
     810                cp = cp + indx - 1;
    811811                RETURN ( __mkSmallInteger((*cp)) );
    812812            }
    813813        }
     
    832832
    833833    unsigned char *cp = (unsigned char *)(__INST(address_));
    834834    int val;
    835     int idx;
     835    INT indx;
    836836    OBJ sz;
    837837
    838838    if (__isSmallInteger(value)) {
     
    843843        goto badArg;
    844844
    845845    if (cp && __isSmallInteger(index)) {
    846         idx = __intVal(index);
    847         if (idx > 0) {
     846        indx = __intVal(index);
     847        if (indx > 0) {
    848848            if (((sz = __INST(size)) == nil)
    849              || (__intVal(sz) >= idx)) {
     849             || (__intVal(sz) >= indx)) {
    850850                if ((val & ~0xFF) == 0) /* i.e. (val >= 0) && (val <= 255) */  {
    851                     cp[idx-1] = val;
     851                    cp[indx-1] = val;
    852852                    RETURN ( value );
    853853                }
    854854            }
     
    967967
    968968%{  /* NOCONTEXT */
    969969
    970     int nIndex, repNIndex;
     970    unsigned INT nIndex, repNIndex;
    971971    int startIndex, stopIndex;
    972972    REGISTER unsigned char *src;
    973973    REGISTER int repStartIndex;
  • Float.st

    diff -r cd0581d5639b -r 574962856f04 Float.st
    a b  
    21732173
    21742174%{  /* NOCONTEXT */
    21752175
    2176     register int indx;
     2176    REGISTER INT indx;
    21772177    unsigned char *cp;
    21782178
    21792179    /*
     
    21832183     */
    21842184    if (__isSmallInteger(index)) {
    21852185        indx = __intVal(index) - 1;
    2186         if (((unsigned)(indx)) < sizeof(double)) {
     2186        if (((unsigned INT)(indx)) < sizeof(double)) {
    21872187            cp = (unsigned char *)(& (__FloatInstPtr(self)->f_floatvalue));
    21882188            RETURN ( __mkSmallInteger(cp[indx] & 0xFF) );
    21892189        }
     
    22062206        values as if this filler wasnt present."
    22072207
    22082208%{  /* NOCONTEXT */
    2209     register int indx, val;
     2209    REGISTER INT indx, val;
    22102210    unsigned char *cp;
    22112211
    22122212    /*
     
    22182218        val = __intVal(value);
    22192219        if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) {
    22202220            indx = __intVal(index) - 1;
    2221             if (((unsigned)(indx)) < sizeof(double)) {
     2221            if (((unsigned INT)(indx)) < sizeof(double)) {
    22222222                cp = (unsigned char *)(& (__FloatInstPtr(self)->f_floatvalue));
    22232223                cp[indx] = val;
    22242224                RETURN ( value );
  • LongFloat.st

    diff -r cd0581d5639b -r 574962856f04 LongFloat.st
    a b  
    17891789
    17901790%{  /* NOCONTEXT */
    17911791
    1792     register int indx;
     1792    REGISTER INT indx;
    17931793    unsigned char *cp;
    17941794
    17951795    /*
     
    17991799     */
    18001800    if (__isSmallInteger(index)) {
    18011801        indx = __intVal(index) - 1;
    1802         if (((unsigned)(indx)) < sizeof(LONGFLOAT)) {
     1802        if (((unsigned INT)(indx)) < sizeof(LONGFLOAT)) {
    18031803            cp = (unsigned char *)(& (__LongFloatInstPtr(self)->f_longfloatvalue));
    18041804            RETURN ( __mkSmallInteger(cp[indx] & 0xFF) );
    18051805        }
     
    18221822        values as if this filler wasnt present."
    18231823
    18241824%{  /* NOCONTEXT */
    1825     register int indx, val;
     1825    REGISTER INT indx, val;
    18261826    unsigned char *cp;
    18271827
    18281828    /*
     
    18341834        val = __intVal(value);
    18351835        if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) {
    18361836            indx = __intVal(index) - 1;
    1837             if (((unsigned)(indx)) < sizeof(LONGFLOAT)) {
     1837            if (((unsigned INT)(indx)) < sizeof(LONGFLOAT)) {
    18381838                cp = (unsigned char *)(& (__LongFloatInstPtr(self)->f_longfloatvalue));
    18391839                cp[indx] = val;
    18401840                RETURN ( value );
  • Object.st

    diff -r cd0581d5639b -r 574962856f04 Object.st
    a b  
    749749    }
    750750    /* NOTREACHED */
    751751#else
    752     REGISTER int nbytes, indx;
     752    REGISTER INT indx;
     753    REGISTER INT nBytes;
    753754    OBJ myClass;
    754755    REGISTER char *pFirst;
    755756    REGISTER int n;
     
    764765        indx = __intVal(index) - 1;
    765766        n /* nInstVars */ = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
    766767        n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* nInstVars */);
    767         nbytes = __qSize(self) - n /* nInstBytes */;
     768        nBytes = __qSize(self) - n /* nInstBytes */;
    768769        pFirst = (char *)(__InstPtr(self)) + n /* nInstBytes */;
    769770
    770771        switch ((INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK)) {
     
    772773                /*
    773774                 * pointers
    774775                 */
    775                 if ((unsigned)indx < (__BYTES2OBJS__(nbytes))) {
     776                if ((unsigned INT)indx < (unsigned INT)(__BYTES2OBJS__(nBytes))) {
    776777                    OBJ *op;
    777778
    778779                    op = (OBJ *)pFirst + indx;
     
    781782                break;
    782783
    783784            case __MASKSMALLINT(WKPOINTERARRAY):
    784                 if ((unsigned)indx < (__BYTES2OBJS__(nbytes))) {
     785                if ((unsigned INT)indx < (unsigned INT)(__BYTES2OBJS__(nBytes))) {
    785786                    OBJ *op;
    786787                    OBJ el;
    787788
     
    796797                /*
    797798                 * (unsigned) bytes
    798799                 */
    799                 if ((unsigned)indx < nbytes) {
     800                if ((unsigned INT)indx < (unsigned INT)nBytes) {
    800801                    unsigned char *cp;
    801802
    802803                    cp = (unsigned char *)pFirst + indx;
     
    813814                    int delta = __FLOATARRAY_ALIGN - ((INT)pFirst & (__FLOATARRAY_ALIGN-1));
    814815
    815816                    pFirst += delta;
    816                     nbytes -= delta;
     817                    nBytes -= delta;
    817818                }
    818819# endif
    819                 if ((unsigned)indx < (nbytes / sizeof(float))) {
     820                if ((unsigned INT)indx < (unsigned INT)(nBytes / sizeof(float))) {
    820821                    float *fp;
    821822                    float f;
    822823                    OBJ v;
     
    841842                    int delta = __DOUBLE_ALIGN - ((INT)pFirst & (__DOUBLE_ALIGN-1));
    842843
    843844                    pFirst += delta;
    844                     nbytes -= delta;
     845                    nBytes -= delta;
    845846                }
    846847# endif
    847                 if ((unsigned)indx < (nbytes / sizeof(double))) {
     848                if ((unsigned INT)indx < (unsigned INT)(nBytes / sizeof(double))) {
    848849                    double *dp;
    849850                    double d;
    850851                    OBJ v;
     
    867868                /* Notice: the hard coded shifts are by purpose;
    868869                 * it makes us independent of the short-size of the machine
    869870                 */
    870                 if ((unsigned)indx < (nbytes>>1)) {
     871                if ((unsigned INT)indx < (unsigned INT)(nBytes>>1)) {
    871872                    unsigned short *sp;
    872873
    873874                    sp = (unsigned short *)(pFirst + (indx<<1));
     
    882883                /* Notice: the hard coded shifts are by purpose;
    883884                 * it makes us independent of the short-size of the machine
    884885                 */
    885                 if ((unsigned)indx < (nbytes>>1)) {
     886                if ((unsigned INT)indx < (unsigned INT)(nBytes>>1)) {
    886887                    short *ssp;
    887888
    888889                    ssp = (short *)(pFirst + (indx<<1));
     
    897898                /* Notice: the hard coded shifts are by purpose;
    898899                 * it makes us independent of the int-size of the machine
    899900                 */
    900                 if ((unsigned)indx < (nbytes>>2)) {
     901                if ((unsigned INT)indx < (unsigned INT)(nBytes>>2)) {
    901902                    unsigned int32 ul;
    902903                    unsigned int32 *lp;
    903904
     
    924925                /* Notice: the hard coded shifts are by purpose;
    925926                 * it makes us independent of the int-size of the machine
    926927                 */
    927                 if ((unsigned)indx < (nbytes>>2)) {
     928                if ((unsigned INT)indx < (unsigned INT)(nBytes>>2)) {
    928929                    int32 *slp;
    929930                    int32 l;
    930931
     
    953954                    int delta = __LONGLONG_ALIGN - ((INT)pFirst & (__LONGLONG_ALIGN-1));
    954955
    955956                    pFirst += delta;
    956                     nbytes -= delta;
     957                    nBytes -= delta;
    957958                }
    958959# endif
    959960                /* Notice: the hard coded shifts are by purpose;
    960961                 * it makes us independent of the long/longlong-size of the machine
    961962                 */
    962                 if ((unsigned)indx < (nbytes>>3)) {
     963                if ((unsigned INT)indx < (unsigned INT)(nBytes>>3)) {
    963964# if __POINTER_SIZE__ == 8
    964965                    INT *slp, ll;
    965966
     
    987988                    int delta = __LONGLONG_ALIGN - ((INT)pFirst & (__LONGLONG_ALIGN-1));
    988989
    989990                    pFirst += delta;
    990                     nbytes -= delta;
     991                    nBytes -= delta;
    991992                }
    992993# endif
    993994                /* Notice: the hard coded shifts are by purpose;
    994995                 * it makes us independent of the long/longlong-size of the machine
    995996                 */
    996                 if ((unsigned)indx < (nbytes>>3)) {
     997                if ((unsigned INT)indx < (unsigned INT)(nBytes>>3)) {
    997998# if __POINTER_SIZE__ == 8
    998999                    unsigned INT *ulp, ul;
    9991000
     
    10351036    }
    10361037    /* NOTREACHED */
    10371038#else
    1038     register int nbytes, indx;
     1039    REGISTER INT indx;
     1040    REGISTER INT nBytes;
    10391041    OBJ myClass;
    1040     register char *pFirst;
     1042    REGISTER char *pFirst;
    10411043    /* int nInstBytes, ninstvars, flags; */
    10421044    REGISTER int n;
    10431045    unsigned int u;
     
    10521054        myClass = __qClass(self);
    10531055        n /* ninstvars */ = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
    10541056        n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* ninstvars */);
    1055         nbytes = __qSize(self) - n /* nInstBytes */;
     1057        nBytes = __qSize(self) - n /* nInstBytes */;
    10561058        pFirst = (char *)(__InstPtr(self)) + n /* nInstBytes */;
    10571059
    10581060        switch ((INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK)) {
    10591061            case __MASKSMALLINT(POINTERARRAY):
    1060                 if ((unsigned)indx < (__BYTES2OBJS__(nbytes))) {
     1062                if ((unsigned INT)indx < (unsigned INT)(__BYTES2OBJS__(nBytes))) {
    10611063                    OBJ *op;
    10621064
    10631065                    op = (OBJ *)pFirst + indx;
     
    10681070                break;
    10691071
    10701072            case __MASKSMALLINT(WKPOINTERARRAY):
    1071                 if ((unsigned)indx < (__BYTES2OBJS__(nbytes))) {
     1073                if ((unsigned INT)indx < (unsigned INT)(__BYTES2OBJS__(nBytes))) {
    10721074                    OBJ *op;
    10731075
    10741076                    op = (OBJ *)pFirst + indx;
     
    10831085                if (__isSmallInteger(anObject)) {
    10841086                    val = __intVal(anObject);
    10851087                    if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) {
    1086                         if ((unsigned)indx < nbytes) {
     1088                        if ((unsigned INT)indx < (unsigned INT)nBytes) {
    10871089                            char *cp;
    10881090
    10891091                            cp = pFirst + indx;
     
    11001102                    int delta = __FLOATARRAY_ALIGN - ((INT)pFirst & (__FLOATARRAY_ALIGN-1));
    11011103
    11021104                    pFirst += delta;
    1103                     nbytes -= delta;
     1105                    nBytes -= delta;
    11041106                }
    11051107# endif
    1106                 if ((unsigned)indx < (nbytes / sizeof(float))) {
     1108                if ((unsigned INT)indx < (unsigned INT)(nBytes / sizeof(float))) {
    11071109                    float *fp;
    11081110
    11091111                    fp = (float *)pFirst + indx;
     
    11311133                    int delta = __DOUBLE_ALIGN - ((INT)pFirst & (__DOUBLE_ALIGN-1));
    11321134
    11331135                    pFirst += delta;
    1134                     nbytes -= delta;
     1136                    nBytes -= delta;
    11351137                }
    11361138# endif
    1137                 if ((unsigned)indx < (nbytes / sizeof(double))) {
     1139                if ((unsigned INT)indx < (unsigned INT)(nBytes / sizeof(double))) {
    11381140                    double *dp;
    11391141
    11401142                    dp = (double *)pFirst + indx;
     
    11601162                if (__isSmallInteger(anObject)) {
    11611163                    val = __intVal(anObject);
    11621164                    if ((unsigned)val <= 0xFFFF) {
    1163                         if ((unsigned)indx < (nbytes>>1)) {
     1165                        if ((unsigned INT)indx < (unsigned INT)(nBytes>>1)) {
    11641166                            unsigned short *sp;
    11651167
    11661168                            sp = (unsigned short *)(pFirst + (indx<<1));
     
    11751177                if (__isSmallInteger(anObject)) {
    11761178                    val = __intVal(anObject);
    11771179                    if ((val >= -32768) && (val < 32768)) {
    1178                         if ((unsigned)indx < (nbytes>>1)) {
     1180                        if ((unsigned INT)indx < (unsigned INT)(nBytes>>1)) {
    11791181                            short *ssp;
    11801182
    11811183                            ssp = (short *)(pFirst + (indx<<1));
     
    11871189                break;
    11881190
    11891191            case __MASKSMALLINT(SLONGARRAY):
    1190                 if ((unsigned)indx < (nbytes>>2)) {
     1192                if ((unsigned INT)indx < (unsigned INT)(nBytes>>2)) {
    11911193                    int32 *slp;
    11921194
    11931195                    slp = (int32 *)(pFirst + (indx<<2));
     
    12131215                break;
    12141216
    12151217            case __MASKSMALLINT(LONGARRAY):
    1216                 if ((unsigned)indx < (nbytes>>2)) {
     1218                if ((unsigned INT)indx < (unsigned INT)(nBytes>>2)) {
    12171219                    unsigned int32 *lp;
    12181220
    12191221                    lp = (unsigned int32 *)(pFirst + (indx<<2));
     
    12441246                    int delta = __LONGLONG_ALIGN - ((INT)pFirst & (__LONGLONG_ALIGN-1));
    12451247
    12461248                    pFirst += delta;
    1247                     nbytes -= delta;
     1249                    nBytes -= delta;
    12481250                }
    12491251# endif
    1250                 if ((unsigned)indx < (nbytes>>3)) {
     1252                if ((unsigned INT)indx < (unsigned INT)(nBytes>>3)) {
    12511253                    __int64__ ll;
    12521254                    __int64__ *sllp;
    12531255
     
    12831285                    int delta = __LONGLONG_ALIGN - ((INT)pFirst & (__LONGLONG_ALIGN-1));
    12841286
    12851287                    pFirst += delta;
    1286                     nbytes -= delta;
     1288                    nBytes -= delta;
    12871289                }
    12881290# endif
    1289                 if ((unsigned)indx < (nbytes>>3)) {
     1291                if ((unsigned INT)indx < (unsigned INT)(nBytes>>3)) {
    12901292                    __uint64__ ll;
    12911293                    __uint64__ *llp;
    12921294
     
    14121414                case __MASKSMALLINT(SWORDARRAY):
    14131415                case __MASKSMALLINT(SLONGARRAY):
    14141416            common:
    1415                     if ((unsigned)indx < (unsigned)nIndex) {
     1417                    if ((unsigned INT)indx < (unsigned INT)nIndex) {
    14161418                        RETURN ( __mkSmallInteger( (INT)(pFirst[indx])) );
    14171419                    }
    14181420                    break;
     
    14461448
    14471449%{  /* NOCONTEXT */
    14481450
    1449     REGISTER int indx;
     1451    REGISTER INT indx;
    14501452    int val, nIndex;
    14511453    REGISTER OBJ slf;
    14521454    REGISTER OBJ cls;
     
    14881490                common:
    14891491                        indx += nInstBytes;
    14901492                        nIndex = __byteArraySize(slf);
    1491                         if ((unsigned)indx < (unsigned)nIndex) {
     1493                        if ((unsigned INT)indx < (unsigned INT)nIndex) {
    14921494                            __ByteArrayInstPtr(slf)->ba_element[indx] = val;
    14931495                            RETURN ( byteValue );
    14941496                        }
     
    79427944#ifdef __SCHTEAM__
    79437945    return context._RETURN( STInteger._new( self.basicSize() ) );
    79447946#else
    7945     REGISTER INT nbytes;
     7947    REGISTER INT nBytes;
    79467948    REGISTER OBJ myClass;
    79477949    int nInstBytes;
    79487950
     
    79527954     * and SmallInteger
    79537955     */
    79547956    myClass = __qClass(self);
    7955     nbytes = __qSize(self);
     7957    nBytes = __qSize(self);
    79567958    nInstBytes = OHDR_SIZE + __OBJS2BYTES__( __intVal(__ClassInstPtr(myClass)->c_ninstvars) );
    79577959
    79587960    switch ((INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK)) {
    79597961        case __MASKSMALLINT(POINTERARRAY):
    79607962        case __MASKSMALLINT(WKPOINTERARRAY):
    7961             nbytes -= nInstBytes;
    7962             RETURN ( __mkSmallInteger(__BYTES2OBJS__(nbytes)) );
     7963            nBytes -= nInstBytes;
     7964            RETURN ( __mkSmallInteger(__BYTES2OBJS__(nBytes)) );
    79637965
    79647966        case __MASKSMALLINT(BYTEARRAY):
    7965             nbytes -= nInstBytes;
    7966             RETURN ( __mkSmallInteger(nbytes / sizeof(char)) );
     7967            nBytes -= nInstBytes;
     7968            RETURN ( __mkSmallInteger(nBytes / sizeof(char)) );
    79677969
    79687970        case __MASKSMALLINT(FLOATARRAY):
    79697971# ifdef __NEED_FLOATARRAY_ALIGN
    79707972            nInstBytes = (nInstBytes-1+__FLOATARRAY_ALIGN) &~ (__FLOATARRAY_ALIGN-1);
    79717973# endif
    7972             nbytes -= nInstBytes;
    7973             RETURN ( __mkSmallInteger(nbytes / sizeof(float)) );
     7974            nBytes -= nInstBytes;
     7975            RETURN ( __mkSmallInteger(nBytes / sizeof(float)) );
    79747976
    79757977        case __MASKSMALLINT(DOUBLEARRAY):
    79767978# ifdef __NEED_DOUBLE_ALIGN
    79777979            nInstBytes = (nInstBytes-1+__DOUBLE_ALIGN) &~ (__DOUBLE_ALIGN-1);
    79787980# endif
    7979             nbytes -= nInstBytes;
    7980             RETURN ( __mkSmallInteger(nbytes / sizeof(double)) );
     7981            nBytes -= nInstBytes;
     7982            RETURN ( __mkSmallInteger(nBytes / sizeof(double)) );
    79817983
    79827984        case __MASKSMALLINT(WORDARRAY):
    79837985        case __MASKSMALLINT(SWORDARRAY):
    7984             nbytes -= nInstBytes;
    7985             RETURN ( __mkSmallInteger(nbytes>>1) ); /* notice the hardcoded 2 here - not sizeof(short) */
     7986            nBytes -= nInstBytes;
     7987            RETURN ( __mkSmallInteger(nBytes>>1) ); /* notice the hardcoded 2 here - not sizeof(short) */
    79867988
    79877989        case __MASKSMALLINT(LONGARRAY):
    79887990        case __MASKSMALLINT(SLONGARRAY):
    7989             nbytes -= nInstBytes;
    7990             RETURN ( __mkSmallInteger(nbytes>>2) ); /* notice the hardcoded 4 here - not sizeof(int) */
     7991            nBytes -= nInstBytes;
     7992            RETURN ( __mkSmallInteger(nBytes>>2) ); /* notice the hardcoded 4 here - not sizeof(int) */
    79917993
    79927994        case __MASKSMALLINT(LONGLONGARRAY):
    79937995        case __MASKSMALLINT(SLONGLONGARRAY):
    79947996# ifdef __NEED_LONGLONG_ALIGN
    79957997            nInstBytes = (nInstBytes-1+__LONGLONG_ALIGN) &~ (__LONGLONG_ALIGN-1);
    79967998# endif
    7997             nbytes -= nInstBytes;
    7998             RETURN ( __mkSmallInteger(nbytes>>3) ); /* notice the hardcoded 8 here - not sizeof(long long) */
     7999            nBytes -= nInstBytes;
     8000            RETURN ( __mkSmallInteger(nBytes>>3) ); /* notice the hardcoded 8 here - not sizeof(long long) */
    79998001    }
    80008002#endif /* not __SCHTEAM__ */
    80018003%}.
  • ShortFloat.st

    diff -r cd0581d5639b -r 574962856f04 ShortFloat.st
    a b  
    14861486
    14871487%{  /* NOCONTEXT */
    14881488
    1489     register int indx;
     1489    REGISTER INT indx;
    14901490    unsigned char *cp;
    14911491
    14921492    /*
     
    14961496     */
    14971497    if (__isSmallInteger(index)) {
    14981498        indx = __intVal(index) - 1;
    1499         if (((unsigned)(indx)) < sizeof(float)) {
     1499        if (((unsigned INT)(indx)) < sizeof(float)) {
    15001500            cp = (unsigned char *)(& (__ShortFloatInstPtr(self)->f_floatvalue));
    15011501            RETURN ( __mkSmallInteger(cp[indx] & 0xFF) );
    15021502        }
     
    15191519        values as if this filler wasnt present."
    15201520
    15211521%{  /* NOCONTEXT */
    1522     register int indx, val;
     1522    REGISTER INT indx, val;
    15231523    unsigned char *cp;
    15241524
    15251525    /*
     
    15311531        val = __intVal(value);
    15321532        if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) {
    15331533            indx = __intVal(index) - 1;
    1534             if (((unsigned)(indx)) < sizeof(float)) {
     1534            if (((unsigned INT)(indx)) < sizeof(float)) {
    15351535                cp = (unsigned char *)(& (__ShortFloatInstPtr(self)->f_floatvalue));
    15361536                cp[indx] = val;
    15371537                RETURN ( value );
  • SignedByteArray.st

    diff -r cd0581d5639b -r 574962856f04 SignedByteArray.st
    a b  
    7373
    7474%{  /* NOCONTEXT */
    7575
    76     REGISTER int indx;
     76    REGISTER INT indx;
    7777    REGISTER OBJ slf;
    7878    REGISTER OBJ cls;
    79     REGISTER int nIndex;
     79    REGISTER INT nIndex;
    8080
    8181    if (__isSmallInteger(index)) {
    8282        indx = __intVal(index) - 1;
     
    9090            indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
    9191        }
    9292        nIndex = __byteArraySize(slf);
    93         if ((unsigned)indx < (unsigned)nIndex) {
     93        if ((unsigned INT)indx < (unsigned INT)nIndex) {
    9494            int byte = ((signed char *)__ByteArrayInstPtr(slf)->ba_element)[indx];
    9595            RETURN ( __mkSmallInteger(byte));
    9696        }
     
    111111
    112112%{  /* NOCONTEXT */
    113113
    114     REGISTER int indx;
    115     int nIndex;
     114    REGISTER INT indx;
     115    unsigned INT nIndex;
    116116    int val;
    117117    REGISTER OBJ slf;
    118118    REGISTER OBJ cls;
     
    131131                indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
    132132            }
    133133            nIndex = __byteArraySize(slf);
    134             if ((unsigned)indx < (unsigned)nIndex) {
     134            if ((unsigned INT)indx < (unsigned INT)nIndex) {
    135135                __ByteArrayInstPtr(slf)->ba_element[indx] = val;
    136136                RETURN ( value );
    137137            }
  • String.st

    diff -r cd0581d5639b -r 574962856f04 String.st
    a b  
    555555        return context._RETURN( self.basicAt( idx1Based ));
    556556    }
    557557#else
    558     REGISTER int indx;
     558    REGISTER INT indx;
    559559    REGISTER OBJ slf, cls;
    560560
    561561    if (__isSmallInteger(index)) {
     
    564564        indx = __intVal(index) - 1;
    565565        if (cls == String) {
    566566            fetch:
    567             if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
     567            if ((unsigned INT)indx < (unsigned)(__stringSize(slf))) {
    568568                RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
    569569            }       
    570570           goto badIndex;
     
    606606            if (((unsigned)value <= 0xFF)
    607607             && __isSmallInteger(index)) {
    608608                indx = __intVal(index) - 1;
    609                 if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
     609                if ((unsigned INT)indx < (unsigned)(__stringSize(slf))) {
    610610                    __stringVal(slf)[indx] = value;
    611611                    RETURN ( aCharacter );
    612612                }
     
    629629        return context._RETURN( self.basicAt( idx1Based ));
    630630    }
    631631#else
    632     REGISTER int indx;
     632    REGISTER INT indx;
    633633    REGISTER OBJ slf, cls;
    634634
    635635    if (__isSmallInteger(index)) {
     
    640640            if (indx < 0) goto badIndex;
    641641            indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
    642642        }
    643         if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
     643        if ((unsigned INT)indx < (unsigned)(__stringSize(slf))) {
    644644            RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
    645645        }
    646646    }
     
    686686                if (indx < 0) goto badIndex;
    687687                indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
    688688            }
    689             if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
     689            if ((unsigned INT)indx < (unsigned)(__stringSize(slf))) {
    690690                __stringVal(slf)[indx] = value;
    691691                RETURN ( aCharacter );
    692692            }
     
    726726
    727727%{  /* NOCONTEXT */
    728728
    729     REGISTER int indx;
     729    REGISTER INT indx;
    730730    REGISTER OBJ slf, cls;
    731731
    732732    slf = self;
     
    736736        if (indx < 0) goto badIndex;
    737737        indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
    738738    }
    739     if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
     739    if ((unsigned INT)indx < (unsigned)(__stringSize(slf))) {
    740740        RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
    741741    }
    742742badIndex: ;
     
    28032803     */
    28042804    if (__qIsStringLike(self)) {
    28052805        char *cp1 = (char *) __stringVal(self);
    2806         int l1 = __stringSize(self);
    2807         int l2;
     2806        INT l1 = __stringSize(self);
     2807        INT l2;
    28082808        char *cp2 = 0;
    2809         int sz;
     2809        INT sz;
    28102810        OBJ newString;
    28112811        char character;
    28122812
     
    28222822        } else
    28232823            goto out;
    28242824
     2825        /*
     2826         * FIXME: check for overflow!!!
     2827         */
    28252828        sz = OHDR_SIZE + l1 + l2 + 1;
    28262829        __qNew(newString, sz);      /* OBJECT ALLOCATION */
    28272830
     
    28442847             * by 10% on a P5/200.
    28452848             */
    28462849            {
    2847                 int nw = l1 >> 2;
     2850                INT nw = l1 >> 2;
    28482851
    28492852                if (l1 & 3) nw++;
    28502853                bcopy4(cp1, dstp, nw);
     
    28642867
    28652868# ifdef bcopy4
    28662869            if (((INT)dstp & 3) == 0) {
    2867                 int nw = l2 >> 2;
     2870                INT nw = l2 >> 2;
    28682871
    28692872                if (l2 & 3) nw++;
    28702873                bcopy4(cp2, dstp, nw);
  • UninterpretedBytes.st

    diff -r cd0581d5639b -r 574962856f04 UninterpretedBytes.st
    a b  
    43214321
    43224322%{  /* NOCONTEXT */
    43234323
    4324     int nIndex, repNIndex;
     4324    unsigned INT nIndex, repNIndex;
    43254325    int startIndex, stopIndex;
    43264326    REGISTER unsigned char *src;
    43274327    REGISTER int repStartIndex;
  • WeakArray.st

    diff -r cd0581d5639b -r 574962856f04 WeakArray.st
    a b  
    296296
    297297%{  /* NOCONTEXT */
    298298
    299     REGISTER int indx;
    300     REGISTER unsigned int nIndex;
     299    REGISTER INT indx;
     300    REGISTER unsigned INT nIndex;
    301301    OBJ el;
    302302
    303303    if (__isSmallInteger(index)) {
     
    329329    "store someObject in the weakArray at some index."
    330330
    331331%{  /* NOCONTEXT */
    332     REGISTER int indx;
    333     REGISTER unsigned int nIndex;
     332    REGISTER INT indx;
     333    REGISTER unsigned INT nIndex;
    334334
    335335    if (__isSmallInteger(index)) {
    336336        indx = __intVal(index) - 1;
     
    516516
    517517%{
    518518    REGISTER int index;
    519     unsigned int nIndex;
     519    unsigned INT nIndex;
    520520    static struct inlineCache val = _ILC1;
    521521
    522522    index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);
     
    700700    |element|
    701701%{
    702702    REGISTER int index;
    703     int nIndex;
     703    unsigned INT nIndex;
    704704    static struct inlineCache val = _ILC1;
    705705
    706706    index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);
     
    857857    |element|
    858858%{
    859859    REGISTER int index;
    860     int nIndex;
     860    unsigned INT nIndex;
    861861    static struct inlineCache val = _ILC1;
    862862
    863863    index = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars);