Clever C Preprocessor Definitions Sought

Steve Summit scs at hstbme.mit.edu
Sun Sep 3 04:03:53 AEST 1989


In article <1424 at atanasoff.cs.iastate.edu> hascall at atanasoff.cs.iastate.edu.UUCP (John Hascall) writes:
>   Here is one I use on VMS where system calls return odd values for OK
>   and even values for various errors:
>      #define ODD(x)             ((x)&1)
>      #define EVEN(x)            (!ODD(x))
>      #define ERROR(cond)        EVEN(cond)

If you do these right (I forget the exact form I used, but at
least John's ODD macro would probably work) you can get the VAXC
compiler to generate a single BLBS or BLBC instruction, those
being two of the instructions (so the story goes) that the VAX
hardware designers put in specifically at the request of the VMS
software developers.  (I try not to worry about such machine-
level optimizations, but it's nice to know that, since the
instructions are there, they're being used as intended.)



More information about the Comp.lang.c mailing list