This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [gfortran,patch] Add ACCESS, CHMOD, GMTIME, LTIME, RSHIFT and LSHIFT g77 intrinsics
- From: "François-Xavier Coudert" <fxcoudert at gmail dot com>
- To: "Steve Kargl" <sgk at troutmask dot apl dot washington dot edu>
- Cc: gfortran <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 27 Jul 2006 16:35:30 +0200
- Subject: Re: [gfortran,patch] Add ACCESS, CHMOD, GMTIME, LTIME, RSHIFT and LSHIFT g77 intrinsics
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=NUwenApv/DYt0+q6nmSt+y/xTM6D7d1eMse9hpYULBU+9630ufi8Slvw5bZ/2lScJBtcVPIyQD2FPX2Uk23vEW8J3hqGQyfo+X4/hs4y7Z2B1K397qMFOMdj6YRcHR71txS3SL1r2T6KLJvC8np4jQhCo3+AveneN2aY0VUunbM=
- References: <19c433eb0607270244q2eceb303h3f5a5dd30ce94d5c@mail.gmail.com> <20060727142544.GA10934@troutmask.apl.washington.edu>
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