From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,8153c81143361581 X-Google-Attributes: gidfee84,public From: Craig Neth USG Subject: Re: Q: The perils of 32-bit mode? Date: 1996/11/18 Message-ID: <329082FA.ABD@zk3.dec.com>#1/1 X-Deja-AN: 197470704 references: <56eh4a$9d@fountain.mindlink.net> cc: mario content-type: text/plain; charset=us-ascii organization: CTG mime-version: 1.0 newsgroups: comp.unix.osf.osf1 x-mailer: Mozilla 3.0Gold (X11; I; OSF1 V4.0 alpha) mischa_sandberg@mindlink.bc.ca wrote: > > I'm in the process of porting a system from 32-bit Unixes to an Alpha > running OSF/1. The code makes many assumptions about LONG and POINTER > types being 32 bits. The first attempt at simply letting the chips > fall where they might in 64-bit mode were pretty dismal. > > I've recompiled the system using "cc -c -xtaso_short" and "cc -taso" > to (per the documentation) create a program that uses 32-bit pointers > and is loaded into the 32bit address space. This doesn't solve my > problem with longs, but, one step at a time, right? [... stuff deleted ...] > This posting amounts to three questions: > > (1) What the heck might I doing wrong? A simple "hello, world" > program, predictably, does NOT betray this same weirdness related to > argv[1]. You didn't read all the documentation :-). The system interfaces are all 64 bits. But the system header files are NOT by default set up to describe this - you need to do something to either fix the system header files or the application including them. The -xtaso_short switch tells the compiler to treat *all* pointers as 32 bits, but that doesn't work so well for the pointers described in the system header files... This is all described in the "Programmer's Guide", but the basic technique is to use the #pragma pointer_size pragma to control the sizes of pointers. When including system headers, you want something like this: #pragma pointer_size save #pragma pointer_size long #include /* or whatever */ #pragma pointer_size restore The programmers guide has a script that will put that stuff into the system header files for you if you would rather do it that way. We're planning on making this simpler in a future release but for now that's all we have to offer. > (2) Are there are any hidden gotchas in using -taso/-xtaso_short? What > happens if I need to use a library that was compiled for 64 bits --- > are pointers properly coerced, or am I out of luck? > See above for how to get the interfaces correct. The -taso linker switch causes your program to be linked so that it runs in the 31 bit addressable address space so no pointer value will ever be greater than 2^31 - and the sign extension rules in the calling standard guarantee that interfaces that expect 64 bit pointers will get a valid value. > (3) Should I expect a significant performance hit? This is a > network-traffic-intensive application, not a compute-intensive one. No. There aren't any conversions going on or 'jackets' or anything like that. Hope this helps. -- -------------------------------------------------------------------------------- Craig Neth ! neth@zk3.dec.com Digital Equipment Corporation ! 110 Spit Brook Road ZKO3-3/Y25 ! Nashua, NH 03062 ! Opinions expressed herein are my own. ================================================================================