About _EM_WSIZE - Minix

This is a discussion on About _EM_WSIZE - Minix ; hello, everybody: I read the source code of Minix3 and met this problem, _EM_WSIZE is called to be a compiler-generated symbol giving the word size in bytes, so I want to test it like this: #include int main() { #if ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: About _EM_WSIZE

  1. About _EM_WSIZE

    hello, everybody:
    I read the source code of Minix3 and met this problem, _EM_WSIZE is
    called to be a compiler-generated symbol giving the word size in
    bytes, so I want to test it like this:

    #include

    int main()
    {
    #if _EM_WSIZE == 4
    printf("Right!\n");
    #endif
    }

    In my opinion, word is four bytes, It will print "Right!" to screen,
    but I did not see this statement. I have changed the value to 2 and 8,
    also no any output. My OS is Windows XP SP3 and my compiler version is
    blow:
    gcc version 3.3.1 (mingw special 20030804-1)

    BTW: I did not find _EM_WSIZE in MSDN, does it a compiler-dependence
    symbol and how can I use it to judge the CPU size?
    Thank you all!

  2. Re: About _EM_WSIZE

    fetag wrote:
    > hello, everybody:
    > I read the source code of Minix3 and met this problem, _EM_WSIZE is
    > called to be a compiler-generated symbol giving the word size in
    > bytes, so I want to test it like this:


    > #include


    > int main()
    > {
    > #if _EM_WSIZE == 4
    > printf("Right!\n");
    > #endif
    > }


    > In my opinion, word is four bytes, It will print "Right!" to screen,
    > but I did not see this statement. I have changed the value to 2 and 8,
    > also no any output. My OS is Windows XP SP3 and my compiler version is
    > blow:
    > gcc version 3.3.1 (mingw special 20030804-1)


    > BTW: I did not find _EM_WSIZE in MSDN, does it a compiler-dependence
    > symbol and how can I use it to judge the CPU size?
    > Thank you all!


    Hi,

    This is actually more of a C question than a Minix question but anyways...
    Try

    printf("%d\n", _EM_WSIZE);

    Most likely, the compiler will complain that _EM_WSIZE is undeclared (it
    does to me). I guess it's either defined by ack (the default Minix
    compiler) or in one of the Minix header files. The reason your printf
    statement never gets compiled is that the test

    #if _EM_WSIZE == 4

    evaluates to

    #if == 4

    if _EM_WSIZE is undefined. Although this looks weird, it is a
    syntactically correct preprocessor statement and evaluates to false.

    Bottom line: if you want to compile Minix code, use ack on a Minix box (or
    virtual machine running Minix) unless you have a very good reason not to.


    Regards,

    Jens

    --
    Jens de Smit
    Student Computer Science | Vrije Universiteit Amsterdam
    jfdsmit@few.vu.nl | http://www.few.vu.nl/~jfdsmit
    "[In the end, people] get furious at IT that the goddamn magic isn't working"
    -- Stewart Dean

  3. Re: About _EM_WSIZE

    On 9月26日, 下午8时05分, "J.F. de Smit" wrote:
    > fetag wrote:
    > > hello, everybody:
    > > I read the source code of Minix3 and met this problem, _EM_WSIZE is
    > > called to be a compiler-generated symbol giving the word size in
    > > bytes, so I want to test it like this:
    > > #include
    > > int main()
    > > {
    > > #if _EM_WSIZE == 4
    > > printf("Right!\n");
    > > #endif
    > > }
    > > In my opinion, word is four bytes, It will print "Right!" to screen,
    > > but I did not see this statement. I have changed the value to 2 and 8,
    > > also no any output. My OS is Windows XP SP3 and my compiler version is
    > > blow:
    > > gcc version 3.3.1 (mingw special 20030804-1)
    > > BTW: I did not find _EM_WSIZE in MSDN, does it a compiler-dependence
    > > symbol and how can I use it to judge the CPU size?
    > > Thank you all!

    >
    > Hi,
    >
    > This is actually more of a C question than a Minix question but anyways....
    > Try
    >
    > printf("%d\n", _EM_WSIZE);
    >
    > Most likely, the compiler will complain that _EM_WSIZE is undeclared (it
    > does to me). I guess it's either defined by ack (the default Minix
    > compiler) or in one of the Minix header files. The reason your printf
    > statement never gets compiled is that the test
    >
    > #if _EM_WSIZE == 4
    >
    > evaluates to
    >
    > #if == 4
    >
    > if _EM_WSIZE is undefined. Although this looks weird, it is a
    > syntactically correct preprocessor statement and evaluates to false.
    >
    > Bottom line: if you want to compile Minix code, use ack on a Minix box (or
    > virtual machine running Minix) unless you have a very good reason not to.
    >
    > Regards,
    >
    > Jens
    >
    > --
    > Jens de Smit
    > Student Computer Science | Vrije Universiteit Amsterdam
    > jfds...@few.vu.nl |http://www.few.vu.nl/~jfdsmit
    > "[In the end, people] get furious at IT that the goddamn magic isn't working"
    > -- Stewart Dean


    Hi, Dean
    I compiled the code by gcc, there is no error, even no warning. but
    when start the program, it is no output. I am puzzled about it. If the
    compiler does not recognise the symbol, it will failed in compile
    time. and now, compile successfully and the output is not correct.

  4. Re: About _EM_WSIZE

    On 09/25/08 17:25, fetag wrote:
    > hello, everybody:
    > I read the source code of Minix3 and met this problem, _EM_WSIZE is
    > called to be a compiler-generated symbol giving the word size in
    > bytes, so I want to test it like this:
    >
    > #include
    >
    > int main()
    > {
    > #if _EM_WSIZE == 4
    > printf("Right!\n");
    > #endif
    > }
    >
    > In my opinion, word is four bytes, It will print "Right!" to screen,
    > but I did not see this statement. I have changed the value to 2 and 8,
    > also no any output. My OS is Windows XP SP3 and my compiler version is
    > blow:
    > gcc version 3.3.1 (mingw special 20030804-1)
    >
    > BTW: I did not find _EM_WSIZE in MSDN, does it a compiler-dependence
    > symbol and how can I use it to judge the CPU size?
    > Thank you all!


    The preprocessor macro _EM_WSIZE is from the ACK compiler and is
    definded in the file /usr/lib/descr which is the compiler description
    file. It is used to describe the passes and the arguments to each pass.

    It is indeed a compiler specific macro and if you need it for gcc you
    have to find the gnu compiler description file. Usually it is in the
    compiler lib directory (/usr/lib/i486-slackware/4.2.3 in my linux box)
    with the name 'specs'.
    Try adding the -v option to the gcc command and you'll get the info on
    the compiler passes.

    Ciao
    Giovanni
    --
    A computer is like an air conditioner,
    it stops working when you open Windows.
    Registered Linux user #337974 < http://giovanni.homelinux.net/ >

  5. Re: About _EM_WSIZE

    On 9月27日, 上午12时03分, Giovanni wrote:
    > On 09/25/08 17:25, fetag wrote:
    >
    >
    >
    > > hello, everybody:
    > > I read the source code of Minix3 and met this problem, _EM_WSIZE is
    > > called to be a compiler-generated symbol giving the word size in
    > > bytes, so I want to test it like this:

    >
    > > #include

    >
    > > int main()
    > > {
    > > #if _EM_WSIZE == 4
    > > printf("Right!\n");
    > > #endif
    > > }

    >
    > > In my opinion, word is four bytes, It will print "Right!" to screen,
    > > but I did not see this statement. I have changed the value to 2 and 8,
    > > also no any output. My OS is Windows XP SP3 and my compiler version is
    > > blow:
    > > gcc version 3.3.1 (mingw special 20030804-1)

    >
    > > BTW: I did not find _EM_WSIZE in MSDN, does it a compiler-dependence
    > > symbol and how can I use it to judge the CPU size?
    > > Thank you all!

    >
    > The preprocessor macro _EM_WSIZE is from the ACK compiler and is
    > definded in the file /usr/lib/descr which is the compiler description
    > file. It is used to describe the passes and the arguments to each pass.
    >
    > It is indeed a compiler specific macro and if you need it for gcc you
    > have to find the gnu compiler description file. Usually it is in the
    > compiler lib directory (/usr/lib/i486-slackware/4.2.3 in my linux box)
    > with the name 'specs'.
    > Try adding the -v option to the gcc command and you'll get the info on
    > the compiler passes.
    >
    > Ciao
    > Giovanni
    > --
    > A computer is like an air conditioner,
    > it stops working when you open Windows.
    > Registered Linux user #337974


    Hi, all:
    I think I know the reason. Indeed, This is a compiler-dependency
    macro, compile this code by gcc, it will no output warning about
    ""_EM_SIZE" is not defined" by default. but when add a compile option,
    -Wundef, this warning will be shown. As blow:

    [root@pcp495237pcs ~]# cat test_em_size.c
    #include

    int main()
    {
    #if _EM_SIZE == 4
    printf("Right!\n");
    #endif
    }
    [root@pcp495237pcs ~]# gcc -Wundef test_em_size.c -o test_em_size
    test_em_size.c:5:5: warning: "_EM_SIZE" is not defined
    [root@pcp495237pcs ~]# ./test_em_size
    [root@pcp495237pcs ~]#

  6. Re: About _EM_WSIZE

    En news:gbij5h$93d$1@star.cs.vu.nl, J.F. de Smit va escriure:
    > This is actually more of a C question than a Minix question


    Yep.


    > the test
    >
    > #if _EM_WSIZE == 4
    >
    > evaluates to
    >
    > #if == 4
    >
    > if _EM_WSIZE is undefined.


    Well, if your compiler behaves this way, you ought to change it.
    Rather, it probably evaluates as

    #if 0 == 4

    (which in turn ealuates clearly to false, so avoids the #if'ed code): the
    Standard C rules in preprocessor #if expressions for undefined symbol is to
    replace it with 0; this way there is no way to invoke "looking weird
    expression".


    Actually, when preprocessors did not behave this way (20 years ago), one
    would write
    : #if _EM_WSIZE-0 == 4

    So then, if cpp remove altogether the symbol, it remains a syntaxly correct
    expression (which evaluates to false); note taht it used -0, since by the
    same timeframe unary + was not always part of the C language...



    > Bottom line: if you want to compile Minix code, use ack on a Minix
    > box (or virtual machine running Minix) unless you have a very good
    > reason not to.


    Yes.


    Antoine


+ Reply to Thread