Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* 64-bit FILE* pointer problem in OSF1
@ 1994-11-21 14:50 Jan A. Duha
  1994-11-22 12:05 ` Dan Pop
  1994-11-22 17:22 ` Peter da Silva
  0 siblings, 2 replies; 3+ messages in thread
From: Jan A. Duha @ 1994-11-21 14:50 UTC (permalink / raw)



Greetings!

 I have a question about the implementation of FILE* pointers in OSF1:

I'm trying to port a file server program (the "iserver" protocol, for
Transputer processors, for those who know) to a DEC Alpha running 
OSF1 v.2.1.  Part of the protocol involves a remote device requesting the
server to open a file.  The server does this, and returns a FILE*
pointer (fp).  Whenever the remote device subsequently wants to access
the file, it passes the server its fp.  Unfortunately, the original
protocol design lacked foresight, and hard-coded FILE* pointers as being
32-bits long!! This means that only the lower 4 bytes of the OSF1
fp will get sent to the remote device.  I don't have access to the
code running on the remote device, and hence can't modify the protocol
to support n-bit fp's.  I think this limits my options to a bad hack:
through much poking around, I've discovered that all fp's (that i've
seen so far, anyway) have only 0x3FF in the upper 4 bytes.  Thus, if I
append this value to all fp's received from the remote device, I can
reconstruct the correct pointer.

 My question, then: is this a valid method?  A longer version of the
question is: how exactly are fp's implemented in OSF1, and what is the
significance of moving from 32-bit to 64-bit pointers for FILE
structures?  Can I have it guaranteed that the OS will place the
pointers in known (constant) locations?  (my guess is that since a FILE* 
pointer is associated to a specific stream, the answer to the last question
would be "yes", but i need this confirmed)

i appreciate any help (as soon as possible, please),

thanks,


jan.

--
--------------------------------------------------------------------------
jan a. duha               			   Office: Lyman-Duff Bldg
duha@ee.mcgill.ca || duha@ralph.biomed.mcgill.ca           Room #328
McGill University, Montreal CANADA                  Phone: 514-398-6734
--
--------------------------------------------------------------------------
jan a. duha               			   Office: Lyman-Duff Bldg
duha@ee.mcgill.ca || duha@ralph.biomed.mcgill.ca           Room #328
McGill University, Montreal CANADA                  Phone: 514-398-6734


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

* Re: 64-bit FILE* pointer problem in OSF1
  1994-11-21 14:50 64-bit FILE* pointer problem in OSF1 Jan A. Duha
@ 1994-11-22 12:05 ` Dan Pop
  1994-11-22 17:22 ` Peter da Silva
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Pop @ 1994-11-22 12:05 UTC (permalink / raw)


In <DUHA.94Nov21095051@ralph.biomed.mcgill.ca> duha@ralph.biomed.mcgill.ca (Jan A. Duha) writes:


> My question, then: is this a valid method?  A longer version of the
>question is: how exactly are fp's implemented in OSF1, and what is the
>significance of moving from 32-bit to 64-bit pointers for FILE
>structures?  Can I have it guaranteed that the OS will place the
>pointers in known (constant) locations?  (my guess is that since a FILE* 
>pointer is associated to a specific stream, the answer to the last question
>would be "yes", but i need this confirmed)

    ues5:~/tmp 218> uname -a
    OSF1 ues5.cern.ch V2.1 250 alpha
    ues5:~/tmp 219> cat test.c
    #include <stdio.h>

    main()
    {
    FILE *fp;

    fp = fopen("test.c", "r");
    printf("%p\n", (void *)fp);
    return 0;
    }
    ues5:~/tmp 220> cc test.c
    ues5:~/tmp 221> ./a.out
    3ffc008ff98
    ues5:~/tmp 222> cc -taso test.c
    ues5:~/tmp 223> ./a.out
    64011f98

For more details about the -taso option see the cc man page.

Dan
--
Dan Pop 
CERN, CN Division
Email: danpop@cernapo.cern.ch
Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland


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

* Re: 64-bit FILE* pointer problem in OSF1
  1994-11-21 14:50 64-bit FILE* pointer problem in OSF1 Jan A. Duha
  1994-11-22 12:05 ` Dan Pop
@ 1994-11-22 17:22 ` Peter da Silva
  1 sibling, 0 replies; 3+ messages in thread
From: Peter da Silva @ 1994-11-22 17:22 UTC (permalink / raw)


In article <DUHA.94Nov21095051@ralph.biomed.mcgill.ca>,
Jan A. Duha <duha@ralph.biomed.mcgill.ca> wrote:
> I'm trying to port a file server program (the "iserver" protocol, for
> Transputer processors, for those who know) to a DEC Alpha running 
> OSF1 v.2.1.  Part of the protocol involves a remote device requesting the
> server to open a file.  The server does this, and returns a FILE*
> pointer (fp).  Whenever the remote device subsequently wants to access
> the file, it passes the server its fp.

ICK! Treating the local address of dynamically allocated memory as a token
is pretty evil.

Well, since the client only uses this as an open file token, add a level of
indirection. Create a table of open files in the server, and stick the file
pointer in there and return the index.

[use the low 32 bits as the token]
>  My question, then: is this a valid method?

There's no guarantee that the top 32 bits will always be 0x3FF. In fact, it's
likely to change.

> A longer version of the
> question is: how exactly are fp's implemented in OSF1,

You don't want to know. Seriously... a file pointer should be treated as an
opaque token. You shouldn't know about its structure nor how it's allocated.

> and what is the
> significance of moving from 32-bit to 64-bit pointers for FILE
> structures?

Same as going from 32-bit to 64-bit pointers in any other context.

> Can I have it guaranteed that the OS will place the
> pointers in known (constant) locations?

No. It's reasonable to *assume* that a straightforward implementation will
use a static table, since that's what V7 did, but it's unreasonable to
expect that. There are implementations of stdio that don't have an _iob
array (the usual name of this array) anywhere.

> i appreciate any help (as soon as possible, please),

See above. Build your own table and pass an index into it. I wouldn't for
a minute consider any other solution. If you can, get this change incorporated
in the original version of the server. This is a really nasty design.
-- 
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] 3+ messages in thread

end of thread, other threads:[~1994-11-22 17:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-11-21 14:50 64-bit FILE* pointer problem in OSF1 Jan A. Duha
1994-11-22 12:05 ` Dan Pop
1994-11-22 17:22 ` Peter da Silva

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