This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: g++ compiler flag usage


On Monday 06 June 2005 13:56, Eljay Love-Jensen wrote:
> Hi Marcel,
> 
> FD_SET is a C macro function that happens to work in C++.
> 
> >any opinions? or did i miss something?
> 
> Yes:  #undef the FD_SET macro function, and create the C++ equivalent that complies to the rigorous settings you are using.
> 
> Alternatively, use FD_SET in C code, and think compile your C++ code against your C code thunk layer.


yes it works, but not with the -W flags i mentioned.

e.g. compilation will fail on x86 but not on ppc

(given i as fd and rfds as fd_set)

FD_SET(i, &rfds);

is expanded on x86 architecture to 

__asm__ __volatile__ ("btsl %1,%0" : "=m" ((&rfds)->fds_bits)[((i) / (8 * sizeof (__fd_mask)))]) : "r" (((int) (i)) % (8 * sizeof (__fd_mask))) : "cc","memory");

and  on mpc/ppc architecture to

(((&rfds)->fds_bits)[((i->first) / (8 * sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((i->first) % (8 * sizeof (__fd_mask)))));



as i want to have ( as that seems to be possible without using supporting warning flags ) platform independ code, 
i do not like the alternative you offered me, cause i would have to redesign a given wheel :)

would you like to read a 

#ifdef X86VERSION
	__asm__ __volatile__ ("btsl %1,%0" : "=m" ((&rfds)->fds_bits)[((i) / (8 * sizeof (__fd_mask)))]) : "r" ((static_cast<int>(i)) % (8 * sizeof (__fd_mask))) : "cc","memory");
#endif
#ifdef PPCVERSION
	(((&rfds)->fds_bits)[((i->first) / (8 * sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((i->first) % (8 * sizeof (__fd_mask)))));
#endif
#ifdef MIPSVERSION
	......
#endif

i think the advantages is that you just can just write 

FD_SET(i, &rfds);

instead having those constructs mentioned above.

i do not want to do a compilers work, so i think if there isn't a applicable of FD_SET(...,...) in c++ and you
are forced to use c functions - the compiler should be 
a) able to detect it on his own, or
b) let the coder declare critic sections

regards
marcel





Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]