This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran,patch] Add ACCESS, CHMOD, GMTIME, LTIME, RSHIFT and LSHIFT g77 intrinsics
void mpz_mul_2exp (mpz_t ROP, mpz_t OP1, unsigned long int OP2)
Set ROP to OP1 times 2 raised to OP2. This operation can also be
defined as a left shift by OP2 bits.
For positive N both `mpz_fdiv_q_2exp' and `mpz_tdiv_q_2exp' are
simple bitwise right shifts. For negative N, `mpz_fdiv_q_2exp' is
effectively an arithmetic right shift treating N as twos complement
the same as the bitwise logical functions do, whereas
`mpz_tdiv_q_2exp' effectively treats N as sign and magnitude.
Hum, I'm not sure how we do this. So, if SHIFT >= 0, I << SHIFT is
done using mpz_mul_2exp and I >> SHIFT is done using mpz_fdiv_q_2exp,
right? What about negative shifts?
Of course, pointing out gmp functions exist and actually writing
the simplification routines are different.
Well, if an "algorithm" to relate << and >> to actualy GMP functions
is established, I'll be happy to write the code. I just don't know how
to handle all the cases.
FreeBSD has a library routine named chmod(). I would
be surprised if other Unix-like OSs did not have a similar
library routine.
chmod() takes a mode_t argument, while the g77 CHMOD has to deal with
a string mode, which is a comma-separated list of octal or symbolic
modes, symbolic modes being of the form:
[ugoa...][[+-=][rwxXstugo...]...][,...]. Writing the parser to gives
the mode_t for a given mode string is not a simple task (the glibc
code for that is far from trivial), and I'd better not spend to much
energy on that.
FX
- References:
- [gfortran,patch] Add ACCESS, CHMOD, GMTIME, LTIME, RSHIFT and LSHIFT g77 intrinsics
- From: François-Xavier Coudert
- Re: [gfortran,patch] Add ACCESS, CHMOD, GMTIME, LTIME, RSHIFT and LSHIFT g77 intrinsics