Opinions on getting existing code 64-bit ready

Opinions on getting existing code 64-bit ready

Post by David Schwart » Sat, 05 Jul 2003 10:51:16



    I'm curious if anyone has any opinions on the best way to get existing
32-bit UNIX code ready for forthcoming 64-bit OSes and processors. What I've
been thinking about doing is requiring that code be changed to tolerate both
ILP32 and LP64 models. This seems to me to be both realistically doable as
well as sufficient.

    It seems to me that 64-bit int's will likely be a loss overall.
Presumably, 64-bit processors will be able to manipulate 32-bit quantities
about as fast as they can manipulate 32-bit quantities and any possible loss
will be made up for by the benefits of smaller structures easing memory
bandwidth usage.

    I don't really want to start a religious war. I'm just looking for
practical suggestions about how to draft coding standards so that code will
work with minimal pain on future platforms.

    DS

 
 
 

Opinions on getting existing code 64-bit ready

Post by Frank Cusac » Sat, 05 Jul 2003 12:48:04



Quote:>     I'm curious if anyone has any opinions on the best way to get
> existing 32-bit UNIX code ready for forthcoming 64-bit OSes and
> processors.

ISTM Sun has already produced a lot of documentation addressing this.
I would use that as a starting point.

Are there any ILP64 platforms?

/fc

 
 
 

Opinions on getting existing code 64-bit ready

Post by M?ns Rullg? » Sat, 05 Jul 2003 18:01:06



>     I'm curious if anyone has any opinions on the best way to get existing
> 32-bit UNIX code ready for forthcoming 64-bit OSes and processors. What I've

Forthcoming?  They've been around for a decade.

Quote:> been thinking about doing is requiring that code be changed to tolerate both
> ILP32 and LP64 models. This seems to me to be both realistically doable as
> well as sufficient.

>     It seems to me that 64-bit int's will likely be a loss overall.
> Presumably, 64-bit processors will be able to manipulate 32-bit quantities
> about as fast as they can manipulate 32-bit quantities and any possible loss
> will be made up for by the benefits of smaller structures easing memory
> bandwidth usage.

>     I don't really want to start a religious war. I'm just looking for
> practical suggestions about how to draft coding standards so that code will
> work with minimal pain on future platforms.

It's rather easy when writing new code.  Whenever you require a
particular size for a variable, use one of the intXX_t types.  Never
cast a pointer to an integer and expect to be able to get back the
right value.

Fixing up old code can be a real PITA, though.  Your best bet might be
to compile it with a compiler that generates warnings for 64-bit
unsafe things.  Supplement with heavy testing, of course.

--
M?ns Rullg?rd

 
 
 

Opinions on getting existing code 64-bit ready

Post by David Schwart » Sat, 05 Jul 2003 20:00:35




Quote:> >     I'm curious if anyone has any opinions on the best way to get
> > existing 32-bit UNIX code ready for forthcoming 64-bit OSes and
> > processors.
> ISTM Sun has already produced a lot of documentation addressing this.
> I would use that as a starting point.

    I only found a few FAQs that seemed to suggest that supporting both
ILP32 and LP64 would be the best way to go.

Quote:> Are there any ILP64 platforms?

    Not that I know of.

    DS

 
 
 

Opinions on getting existing code 64-bit ready

Post by j.. » Sat, 05 Jul 2003 23:19:10





> > On Thu, 3 Jul 2003 18:51:16 -0700 "David Schwartz"


> > >     I'm curious if anyone has any opinions on the best way to
> > > get existing 32-bit UNIX code ready for forthcoming 64-bit OSes
> > > and processors.

> > ISTM Sun has already produced a lot of documentation addressing
> > this.  I would use that as a starting point.

>     I only found a few FAQs that seemed to suggest that supporting
> both ILP32 and LP64 would be the best way to go.

I don't know if you saw this, but it might have some relevant things
in it.

http://docs.sun.com/db/doc/806-0477?q=lp64&a=load

Joe

 
 
 

Opinions on getting existing code 64-bit ready

Post by Bjorn Rees » Sun, 06 Jul 2003 05:37:05



> Are there any ILP64 platforms?

IIRC, Cray C90 was an ILP64 platform.
 
 
 

Opinions on getting existing code 64-bit ready

Post by Alan Coopersmit » Mon, 07 Jul 2003 11:59:10



|Are there any ILP64 platforms?

A handful of rare ones.  Of the platforms X11/XFree86 has been ported
to, the only ifdef for ILP64 mode is for CRAY - there's a sizable list
for LP64 mode though.  There was also a short lived custom port of
Solaris using ILP64 that HaL did for their SPARC64 machines before Sun
came out with the LP64 support in Solaris.

--
________________________________________________________________________


  Working for, but definitely not speaking for, Sun Microsystems, Inc.

 
 
 

Opinions on getting existing code 64-bit ready

Post by Fritz » Thu, 10 Jul 2003 00:26:19



> Forthcoming?  They've been around for a decade.

I thought the same thing, but then it occurred to me that the original
poster is probably living in the world of Intel and AMD.

Quote:> Fixing up old code can be a real PITA, though.

I've never had problems, and most of the code I've ported to make 64-bit
safe is kernel code (device drivers and big chunks of the real kernel on
AIX and Solaris).  If you start out with poorly written code --
especially code that makes assumptions about sizeof(int) == sizeof(*void)
-- then you'll have a bit of a headache, but even these are not too hard
to find if you pay attention to compiler warning output.

RFM
--
To reply, translate domain from l33+ 2p33|< to alpha.
                4=a  0=o  3=e  +=t

 
 
 

Opinions on getting existing code 64-bit ready

Post by David Schwart » Thu, 10 Jul 2003 03:12:22




> > Forthcoming?  They've been around for a decade.
> I thought the same thing, but then it occurred to me that the original
> poster is probably living in the world of Intel and AMD.

    More Intel, AMD, MIPS, and R10K. The only 64-bit OS I've used, other
than Solaris, is OSF1.

Quote:> > Fixing up old code can be a real PITA, though.
> I've never had problems, and most of the code I've ported to make 64-bit
> safe is kernel code (device drivers and big chunks of the real kernel on
> AIX and Solaris).  If you start out with poorly written code --
> especially code that makes assumptions about sizeof(int) == sizeof(*void)
> -- then you'll have a bit of a headache, but even these are not too hard
> to find if you pay attention to compiler warning output.

    Yeah, but is it okay to replace that with code that assumes
sizeof(long)==sizeof(void*)? That makes things easier than more general
fixes.

    DS

 
 
 

Opinions on getting existing code 64-bit ready

Post by William Aher » Thu, 10 Jul 2003 03:35:04




>> I've never had problems, and most of the code I've ported to make 64-bit
>> safe is kernel code (device drivers and big chunks of the real kernel on
>> AIX and Solaris).  If you start out with poorly written code --
>> especially code that makes assumptions about sizeof(int) == sizeof(*void)
>> -- then you'll have a bit of a headache, but even these are not too hard
>> to find if you pay attention to compiler warning output.

>     Yeah, but is it okay to replace that with code that assumes
> sizeof(long)==sizeof(void*)? That makes things easier than more general
> fixes.

use intptr_t instead. if it's available, it'll be the proper type. if its
not, then your code won't silently break.

- Bill

 
 
 

Opinions on getting existing code 64-bit ready

Post by Chuck Dillo » Fri, 11 Jul 2003 00:46:47



>     I don't really want to start a religious war. I'm just looking for
> practical suggestions about how to draft coding standards so that code will
> work with minimal pain on future platforms.

I suggest your standards give strong warnings about using loosely typed
interfaces like varargs explicitly.  Not just formatted I/O C functions
but varargs in general.

I worked with a sizable X/Motif code base that had worked for several
years just fine on 64bit OSF/DEC/HP... systems as well as various
flavors of 32 bit systems including IRIX.  We did a port to IRIX64 and
ran into a bunch of crash problems in the GUI code.  It turned out that
the GUI code had a lot of cases where it fetched (int) values from
widgets (XmNuserData) into (int) fields.  XmNuserData stores an
XtPointer type so that it can hold the address of data.  But it's used
a lot to store integer values.  So, we had a lot of code that
implicitly assumed that sizeof(int) == sizeof(void *).

It worked on OSF because the correct 32 bits were mapped between the
two locations and the other 32 bits never clobbered anything
symptomatically.  On IRIX64 you set and got back the wrong 32 bits and
the code didn't validate values when they were returned so we got
crashes.  Not because of the overlooked extra 32 bits but later when
the values returned were unexpected.

-- ced

--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.

 
 
 

1. Compiling 64-bit code on 32-bit machine

Hello,

From the Solaris 7 64-bit Developer's Guide FAQ:

  Can I build a 64-bit application on a system running the 32-bit
  operating system?

    Yes, provided you have the 64-bit library packages installed. However,
    it is not possible to run the 64-bit application on a system running
    the 32-bit operating system.

1.  What are the names of the 64-bit libraries?  How can I ensure
    only those libraries are used during a compile and not any 32-bit
    ones?

2.  What compilers can generate 64-bit code on 32-bit machines?  
    Does GNU CC?

3.  What compiler flags are used to instruct a 64-bit compile?  for
    which compiler?

I realize I wouldn't be able to test the generated 64-bit code on a
32-bit machine.   Perhaps the answers should go in the solaris FAQ.

Thanks,
Sam

2. uugetty/Modems dont hang up

3. 64-bit instructions in 32-bit code

4. CDE 1.0.1 Sol 2.4 losing Style setting

5. code to determine 64-bit vs 32-bit binaries?

6. FTP problem

7. 32-bit code on 64-bit RS/6000

8. Problem with Yamaha CRW 3200E

9. HALstation (64-bit processor running 64-bit Solaris) as webserver

10. IBM announces 64-bit mainframes and 64-bit Linux for S/390

11. Is linux 64-bit ready already?

12. Is 64-bit Linux "true" 64 bit thru-and-thru??

13. 64 bit Unix (esp. 64 bit IO)