Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* help, malloc 32 vs malloc 64
@ 1994-10-15 13:41 Teak 'Teakster' Min
  1994-10-15 23:38 ` Dirk Grunwald
  1994-10-17 16:53 ` Peter da Silva
  0 siblings, 2 replies; 6+ messages in thread
From: Teak 'Teakster' Min @ 1994-10-15 13:41 UTC (permalink / raw)



If anyone has any information or possible solution to this question, I would 
be very appreciative. 

Problem:  I am working on a DEC Alpha using OSF/1.  I need to know
if there is anyway to #define an int in C to a long.  What I am 
having problems is that when I malloc and I get a memory location, 
the address is assigned to a pointer of type int which is 32bit but
the system gives back an address with is greater than 32bit address.
I know that OSF is a 64 bit architecture.  What I need to know is
how to compile my program which will use only address in the
32bit range OR set on option that will make int larger than 32bit.
This program (or I should say environment) is compiled using both
cc and gcc.  I was TOLD that c was a portable code, was I lied to?
Why not change all my int to long? Well this program has over a
hundred if not more files in several directories and I wish not
to go in all those files and change int to long.

I thank all those who took the time to read this message.  Thanks.


_/_/_/_/_/ _/_/_/     _/     _/   _/       Teak Min
   _/     _/        _/_/    _/  _/   Virginia Tech (VPI&SU) 
  _/     _/_/_/   _/  _/   _/_/          (703) 953-3998
 _/     _/      _/_/_/_/  _/  _/     teak@csugrad.cs.vt.edu 
_/     _/_/_/ _/      _/ _/    _/    teak@cray-ymp.acm.stuorg.vt.edu 
2713 Newton Court                    http://csugrad.cs.vt.edu/~teak/ 
Blacksburg, VA. 24060     	     #include<std.disclaimer>




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: help, malloc 32 vs malloc 64
  1994-10-15 13:41 help, malloc 32 vs malloc 64 Teak 'Teakster' Min
@ 1994-10-15 23:38 ` Dirk Grunwald
  1994-10-17 16:53 ` Peter da Silva
  1 sibling, 0 replies; 6+ messages in thread
From: Dirk Grunwald @ 1994-10-15 23:38 UTC (permalink / raw)



C is a portable language, but only if you use it in a portable
fashion, and you're not.

You can fix the problem by linking your program with the "-taso"
option. However, when you move it to the next 64 bit machine, it'll
break again.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: help, malloc 32 vs malloc 64
  1994-10-15 13:41 help, malloc 32 vs malloc 64 Teak 'Teakster' Min
  1994-10-15 23:38 ` Dirk Grunwald
@ 1994-10-17 16:53 ` Peter da Silva
  1994-10-17 23:18   ` Dirk Grunwald
  1 sibling, 1 reply; 6+ messages in thread
From: Peter da Silva @ 1994-10-17 16:53 UTC (permalink / raw)


In article <37om6o$s79@csugrad.cs.vt.edu>,
Teak 'Teakster' Min <teak@csugrad.cs.vt.edu> wrote:
> Problem:  I am working on a DEC Alpha using OSF/1.  I need to know
> if there is anyway to #define an int in C to a long.  What I am 
> having problems is that when I malloc and I get a memory location, 
> the address is assigned to a pointer of type int which is 32bit but
> the system gives back an address with is greater than 32bit address.

No, a pointer to an integer is 64 bits wide. An integer is 32 bits wide.
It is not possible in general to assign a pointer to an integer. For
about 8-10 years the majority of high performance platforms did have
an integer that was the same size as a pointer, and people have written
code that depends on this implementation detail, but the language itself
does not guarantee it.

The fix is to change your code so it no longer tries to store a pointer
in an integer.

> I know that OSF is a 64 bit architecture.  What I need to know is
> how to compile my program which will use only address in the
> 32bit range OR set on option that will make int larger than 32bit.

Neither is possible or desirable.

> This program (or I should say environment) is compiled using both
> cc and gcc.  I was TOLD that c was a portable code, was I lied to?

If you were told that this program was portable, you were lied to.

If you were told that it is possible to write portable code in C, that
is the truth. It is possible to write portable code in C, however that
doesn't imply that all code written in C is portable.

> Why not change all my int to long? Well this program has over a
> hundred if not more files in several directories and I wish not
> to go in all those files and change int to long.

That's good, because that's not what you need to do. What you need to
do is fix the broken code that assumes that you can store a pointer in
an integer. If you don't wish to do that, there's no doubt many people
on the net who will be willing to do it for you for a reasonable fee.
-- 
Peter da Silva                                            `-_-'
Network Management Technology Incorporated                 'U`
1601 Industrial Blvd.     Sugar Land, TX  77478  USA
+1 713 274 5180                       "Hast Du heute schon Deinen Wolf umarmt?"


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: help, malloc 32 vs malloc 64
  1994-10-17 16:53 ` Peter da Silva
@ 1994-10-17 23:18   ` Dirk Grunwald
  1994-10-18 14:28     ` Peter da Silva
  1994-10-18 17:41     ` oberman
  0 siblings, 2 replies; 6+ messages in thread
From: Dirk Grunwald @ 1994-10-17 23:18 UTC (permalink / raw)


>>>>> "PdS" == Peter da Silva <peter@nmti.com> writes:
In article <id.RVXD1.W0L@nmti.com> peter@nmti.com (Peter da Silva) writes:
>> I know that OSF is a 64 bit architecture.  What I need to know is
>> how to compile my program which will use only address in the 32bit
>> range OR set on option that will make int larger than 32bit.

PdS> Neither is possible or desirable.
--

Aww, you're being too harsh on OSF/1.

You can link the program with the '-taso' option and it'll probably
work.  Not because integers are larger, but because memory would only
be located in the lower part of the address space.

Also, in OSF/1 V3, you can use -xtaso and -xtaso_short to force (some)
pointers to be 32 bits. Useful for some things. Me, I'm trying to
recompile Emacs this way.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: help, malloc 32 vs malloc 64
  1994-10-17 23:18   ` Dirk Grunwald
@ 1994-10-18 14:28     ` Peter da Silva
  1994-10-18 17:41     ` oberman
  1 sibling, 0 replies; 6+ messages in thread
From: Peter da Silva @ 1994-10-18 14:28 UTC (permalink / raw)


In article <GRUNWALD.94Oct17171831@foobar.cs.colorado.edu>,
Dirk Grunwald <grunwald@foobar.cs.colorado.edu> wrote:
> Aww, you're being too harsh on OSF/1.

I'm not being harsh on OSF/1 at all. I think it's GREAT that someone finally
had the guts to break all those vaxocentric dusty decks and I'm delighted that
it's DEC of all people that has done so.
-- 
Peter da Silva                                            `-_-'
Network Management Technology Incorporated                 'U`
1601 Industrial Blvd.     Sugar Land, TX  77478  USA
+1 713 274 5180                       "Hast Du heute schon Deinen Wolf umarmt?"


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: help, malloc 32 vs malloc 64
  1994-10-17 23:18   ` Dirk Grunwald
  1994-10-18 14:28     ` Peter da Silva
@ 1994-10-18 17:41     ` oberman
  1 sibling, 0 replies; 6+ messages in thread
From: oberman @ 1994-10-18 17:41 UTC (permalink / raw)


In Article <GRUNWALD.94Oct17171831@foobar.cs.colorado.edu>
grunwald@foobar.cs.colorado.edu (Dirk Grunwald) writes:

>Also, in OSF/1 V3, you can use -xtaso and -xtaso_short to force (some)
>pointers to be 32 bits. Useful for some things. Me, I'm trying to
>recompile Emacs this way.

Why not get 19.27 and all the Alpha patches from gatekeeper.dec.com? It's
really much easier. (I have not confirmed whether this works for V1.3, but it
looks like it should. Works for 2.0.)

R. Kevin Oberman			
Energy Sciences Network (ESnet)
National Energy Research Supercomputer Center (NERSC)
Lawrence Livermore National Laboratory (LLNL)
Internet: koberman@llnl.gov		+1 510-422-6955


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1994-10-18 17:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-10-15 13:41 help, malloc 32 vs malloc 64 Teak 'Teakster' Min
1994-10-15 23:38 ` Dirk Grunwald
1994-10-17 16:53 ` Peter da Silva
1994-10-17 23:18   ` Dirk Grunwald
1994-10-18 14:28     ` Peter da Silva
1994-10-18 17:41     ` oberman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox