This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Help with global partitions
- To: "'gcc at gcc dot gnu dot org'" <gcc at gcc dot gnu dot org>
- Subject: Help with global partitions
- From: "GUTIERREZ, MARK L" <mgutierrez at oppd dot com>
- Date: Thu, 4 May 2000 13:53:55 -0500
This is a first time post to the list, so I'm not sure this is where it
belongs...
But here goes:
Our application is a Nuclear Power Station Training Simulator.
The main simulator task is written in C and controls
simulator models written in FORTRAN. The user interface is also
written in C.
The computer environment is a SGI Challenge R4400 processor
running IRIX 6.5.4, N32 ABI, MIPS3.
Data sharing is performed using SGI shared memory segments
The following statement is an example of how the shared memory
segments are defined and logical address assigned in C
This C routine is used to attach the globals to the correct
logical location for the FORTRAN models.
.globl global_snp_
global_snp_ = 0x8300000
Using gcc this does not work. It does not assign the logical
address of global_snp to 8300000. During debugging of this
problem I created a small FORTRAN pgm and a C definition source
as follows:
C routine:-> Filename bshareG.s
.globl global_snp_
global_snp_ = 0x8300000
FORTRAN routine:-> Filename bshare.f
program bshare
integer *4 shmat
integer*4 shmid /3/
integer*4 shmflg
integer*4 ibob
integer*4 ikey /334/
COMMON/global_snp/G_snp(0:196607)
CHARACTER*1 G_snp
real*4 R_snp(49152)
equivalence(G_snp,R_snp)
COMMON/global_sys/G_sys(0:65535)
CHARACTER*1 G_sys
REAL*4 xrecao(4)
EQUIVALENCE (xrecao,G_snp(9720))
ibob = %loc(G_snp)
write(6,1001)ibob
iret = shmat (shmid, ibob, shmflg)
write(6,1000)iret
write(6,1000)iret,xrecao(1),xrecao(2)
iret = shmdt (ibob)
stop
1000 format(1x,'bshare ',z8,2x,f10.6,2x,f10.6)
1001 format(1x,'ibob ',z8)
3000 format(i5)
end
I compile C routine using:
gcc -o bshareG.o bshareG.s
Then compile and link using
g77 -o bshare bshare.f bshareG.o -lftn
Note: The -lftn is required to find the shmat function.
The program will die with a Segmentation fault.
It runs correctly if the SGI cc and f77 are used.
The simulator application also runs correctly under the SGI
compilers. Under gcc the simulator application does
not abort but the commons are not attached correctly.
Is there a way we are not aware of to use global shared memory under gcc?
We appreciate any help that may be offered with this problem.
Mark L. Gutierrez
Simulator Computer Specialist