Thread: mitsy

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    657

    mitsy

    Figured this be the right board for a project in C, anyways some people might have been interested in joining my hobby project they've seen me mention:
    GitHub - awsdert/mitsy: MIT licensed C compiler
    This thread is ONLY for mentioning your github username and any details that would identify your account from similar accounts, as a side note you'll need to have at least one open source repository if you're not a regular helper here since I will need to see you at least have enough experience programming to not make things worse on a regular basis.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    3,688
    I think that me helping could hurt the project; since, I have done a few GCC debugging and applying other peoples patches I have seen GCC code base enough to make a accidental code copying a possible compliant. Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    657
    Quote Originally Posted by stahta01 View Post
    I think that me helping could hurt the project; since, I have done a few GCC debugging and applying other peoples patches I have seen GCC code base enough to make a accidental code copying a possible compliant. Tim S.
    Fair doos, well either way will be a while before I start encouraging others to join, this was mearly a chance for me to take notice of anyone that did want to join in, I'm aiming to get as far as the addon support stage before I really start to look for help since a compiler is too big a project to take on by oneself especially with my end goals at the moment

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    3,688
    Are you going to be using binutils or another similar library?
    Edit: like The elfutils project
    Or is it just going to target a single CPU family?

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    3,688
    musl - Wikipedia

    musl is a C standard library intended for operating systems based on the Linux kernel, released under the MIT License.[3] It was developed by Rich Felker with the goal to write a clean, efficient and standards-conformant libc implementation.[4]
    Just want to make sure you know about MUSL
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  6. #6
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    657
    Quote Originally Posted by stahta01 View Post
    Are you going to be using binutils or another similar library?
    Edit: like The elfutils project
    Or is it just going to target a single CPU family?

    Tim S.
    I might use 'em, depends if they meat my needs, and no not gonna target just a single CPU, I'm starting with AMD64 cause that's what I got on my computer so I can test my code and resulting binaries before making more permanent changes, stability before portability is my motto here
    Quote Originally Posted by stahta01 View Post
    musl - Wikipedia



    Just want to make sure you know about MUSL
    Didn't know about it, should be helpful I reckon

  7. #7
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    657
    Quote Originally Posted by stahta01 View Post
    musl - Wikipedia



    Just want to make sure you know about MUSL
    Now that I've actually looked at it (was on bus when made 1st answer) it's not greatly suitable for a compiler that aims to be able to compile kernels, in user space it is fine so I will start with that until I can build & run elf files from code (so that I know any bugs come from my code) but after that I will have to build in support for finding system libraries and redirecting to those when available, anyways thanks for the tip, I'll use it in other hobby projects anyways

  8. #8
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,493
    I've forgotten my github password and keys lmao

  9. #9
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    657
    Quote Originally Posted by Hodor View Post
    I've forgotten my github password and keys lmao
    How'd ya get in ya house without ya keys then?

  10. #10
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,493
    mcc_get.c line 272 (see also line 325 which I think exhibits the same problem)

    Code:
    if ( c >= 0xD000 || c <= 0xDFFF )
    Surely this always evaluates to true. As an example, I'll change it to some different numbers so it's easier to type an example

    Code:
    if ( c >= 10 || c <= 100 )
    Now, choose any random number and the expression will be true. c = 1, that's <= 100, so yep. c = 15, that's >= 10, so yep. c = 200, that's >= 10, so yep.

    Maybe it's meant to be
    Code:
    if ( c >= 0xD000 && c <= 0xDFFF )
    Edit:
    I wrote a test program but gcc and clang don't spit out a warning (but all the numbers do result in the condition being true). Hmm.
    Code:
    #include <stdio.h>
    
    int main(void)
    {
        int i;
        
        for (i = 0; i < 1000; i++) {
            if (i >= 100 || i <= 200)
                printf("%3d Condition true\n", i);
        }
        
        return 0;
    }
    Edit 2: splint doesn't warn either. So maybe my logic is broken this morning (but I don't think so, and at least for the example program I wrote the condition is always true as I suspected)
    Last edited by Hodor; 10-27-2019 at 06:51 PM.

  11. #11
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    657
    Quote Originally Posted by Hodor View Post
    mcc_get.c line 272 (see also line 325 which I think exhibits the same problem)

    Code:
    if ( c >= 0xD000 || c <= 0xDFFF )
    Surely this always evaluates to true. As an example, I'll change it to some different numbers so it's easier to type an example

    Code:
    if ( c >= 10 || c <= 100 )
    Now, choose any random number and the expression will be true. c = 1, that's <= 100, so yep. c = 15, that's >= 10, so yep. c = 200, that's >= 10, so yep.

    Maybe it's meant to be
    Code:
    if ( c >= 0xD000 && c <= 0xDFFF )
    That's right thanks for pointing it out, didn't realise I slipped up there

  12. #12
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,493
    I see you applied the fix. You may have missed it, but I mentioned another line in the first post (kind of easy to miss consider I only mentioned it in parenthesis on the first line of the post hehe). It's now line 272

    Code:
        if ( c >= 0xD000 || c <= 0xDFFF )          /* Same typo as previous typo (?); i.e. condition always true */
            return MCC_CHAR_TYPE_24BIT;

  13. #13
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,493
    Changes I made to get it to build

    Code:
    @@ -1,5 +1,6 @@
    +#include <float.h>
     #include "mcc_get.h"
     int mcc_encoding_type = 0;
     int mcc_encoding_node = mcc_encoding_count;
     char const *env_LANG = NULL;
     mcc_char_info_t mcc_common_char_info[ mcc_encoding_count ] = {{0}};
    @@ -442,14 +443,16 @@ int mcc_getall( MCC_POS *src, MCC_CH8 *dst,
         tok.src = mcc_iconv_tok_mem( tok.src, srcm->addr,
             srcv->use * mcc_char_info.size );
         if ( mcc_char_info.enc == mcc_encoding_ch8 ) {
             if ( srcv->use > (dstv->cap - dstv->use) ) {
                 ret = mcc_vecsize( dstv,
    -                (dstv->use + srcv->use) * sizeof(mcc_ch8_t),
    +                (dstv->use + srcv->use + 1) * sizeof(mcc_ch8_t),
                     sizeof(mcc_ch8_t) );
                 if ( ret != EXIT_SUCCESS ) return ret;
    -        }
    +        } else {
    +            ret = EXIT_SUCCESS;
    +        }
             tok.dst = mcc_iconv_tok_mem( tok.dst, dstm->addr, dstm->size );
             (void)memcpy( tok.dst.addr, srcm->addr, tok.src.size );
             dstv->use += srcv->use;
             goto mcc_getall_done;
         }
    @@ -976,11 +979,11 @@ int mcc_getnum(
         long len = 0;
         ullong rev = 0, num = 0, dec, pos, bit, no_mul = 0;
         sllong exp;
         if ( !dst ) return EDESTADDRREQ;
         (void)memset( dst, 0, sizeof(MCC_NUM) );
    -    if ( !src || !src->text.use ) return ENODATA;
    +    if ( !src || !src->text.vec.use ) return ENODATA;
         if ( !base ) {
             if ( mcc_ch8ctype( C[0] ) == MCC_CHAR_TYPE_SPACE ) {
                 mcc_getnum_sign:
                 while ( (ret = mcc_getc(src, C, &len )) == EXIT_SUCCESS ) {
                     if ( len != 1 ) break;
    The only dubious change is
    Code:
    (dstv->use + srcv->use + 1) * sizeof(mcc_ch8_t),
    Which I merely added so that there's room for the '\0' character. The other changes were required to get it to actually build (apart from the ret = EXIT_SUCCESS; which is necessary to make sure it's initialised if the preceding condition is false)

  14. #14
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    657
    Quote Originally Posted by Hodor View Post
    Changes I made to get it to build

    Code:
    @@ -1,5 +1,6 @@
    +#include <float.h>
     #include "mcc_get.h"
     int mcc_encoding_type = 0;
     int mcc_encoding_node = mcc_encoding_count;
     char const *env_LANG = NULL;
     mcc_char_info_t mcc_common_char_info[ mcc_encoding_count ] = {{0}};
    @@ -442,14 +443,16 @@ int mcc_getall( MCC_POS *src, MCC_CH8 *dst,
         tok.src = mcc_iconv_tok_mem( tok.src, srcm->addr,
             srcv->use * mcc_char_info.size );
         if ( mcc_char_info.enc == mcc_encoding_ch8 ) {
             if ( srcv->use > (dstv->cap - dstv->use) ) {
                 ret = mcc_vecsize( dstv,
    -                (dstv->use + srcv->use) * sizeof(mcc_ch8_t),
    +                (dstv->use + srcv->use + 1) * sizeof(mcc_ch8_t),
                     sizeof(mcc_ch8_t) );
                 if ( ret != EXIT_SUCCESS ) return ret;
    -        }
    +        } else {
    +            ret = EXIT_SUCCESS;
    +        }
             tok.dst = mcc_iconv_tok_mem( tok.dst, dstm->addr, dstm->size );
             (void)memcpy( tok.dst.addr, srcm->addr, tok.src.size );
             dstv->use += srcv->use;
             goto mcc_getall_done;
         }
    @@ -976,11 +979,11 @@ int mcc_getnum(
         long len = 0;
         ullong rev = 0, num = 0, dec, pos, bit, no_mul = 0;
         sllong exp;
         if ( !dst ) return EDESTADDRREQ;
         (void)memset( dst, 0, sizeof(MCC_NUM) );
    -    if ( !src || !src->text.use ) return ENODATA;
    +    if ( !src || !src->text.vec.use ) return ENODATA;
         if ( !base ) {
             if ( mcc_ch8ctype( C[0] ) == MCC_CHAR_TYPE_SPACE ) {
                 mcc_getnum_sign:
                 while ( (ret = mcc_getc(src, C, &len )) == EXIT_SUCCESS ) {
                     if ( len != 1 ) break;
    The only dubious change is
    Code:
    (dstv->use + srcv->use + 1) * sizeof(mcc_ch8_t),
    Which I merely added so that there's room for the '\0' character. The other changes were required to get it to actually build (apart from the ret = EXIT_SUCCESS; which is necessary to make sure it's initialised if the preceding condition is false)
    Could've sworn I already added that 1 elsewhere, whatever it's probably better to that anyways, also thanks for the point out on that typo with src->text.vec.use, finally the reason I didn't explicitly set ret was cause I was supposed to have filled it with mcc_char_info_test() return code and checked that first, thanks for indirectly pointing that out to me , Gotta post my intended thread this time.

Popular pages Recent additions subscribe to a feed

Tags for this Thread