[Radiance-general] rholo restart stalls with "bad magic number"

Hi Peter,

The declaration for lseek() is done manually in rtio.h following an inclusion of <sys/types.h>, which is included by standard.h, which is included by holo.h (and thence by rholo.h). So, it should be declared properly. I logged onto radiance-online and checked it with cc -E, and lseek() is declared in rholo.c and holofile.c without the <unistd.h> inclusion.

The reason we did this rather than including <unistd.h> is because this header is not found on all systems, most notably Windows. The declaration in rtio.h appears to match the Linux declaration, unless -D_FILE_OFFSET_BITS=64 is assigned. I noticed that this macro was recently added to the default makeall by schorsch (version 1.7, 2003/07/12), and this seems to be the trouble.

I guess the solution is to include the new "platform.h" for all files that use lseek(), which are the following by my search:

common/preadwrite.c
hd/genrhenv.c
hd/genrhgrid.c
hd/holofile.c
hd/rhcopy.c
hd/rhinfo.c
hd/rholo.c
hd/rhoptimize.c
hd/rhpict.c
px/pinterp.c
rt/ambient.c
rt/persist.c
rt/rpict.c
util/rpiece.c
util/vwrays.c

Since "platform.h" includes <unistd.h> on all UNIX systems, this should solve the problem, I would think. (Schorsch, do you agree?)

-Greg

P.S. For some reason, the source auxiliary files are not included in the HEAD distribution. The following files are missing:

ray/src/common/tmesh.cal
ray/src/cv/lamp.tab
ray/src/cv/source.cal
ray/src/cv/tilt.cal
ray/src/gen/clockface.hex
ray/src/gen/glaze1.cal
ray/src/gen/glaze2.cal
ray/src/gen/illum.cal
ray/src/gen/rev.cal
ray/src/gen/skybright.cal
ray/src/gen/surf.cal
ray/src/rt/rayinit.cal

Please add them, as makeall depends on them for proper operation.

Greg Ward wrote:

I guess the solution is to include the new "platform.h" for all files
that use lseek(), which are the following by my search:

[...]

Since "platform.h" includes <unistd.h> on all UNIX systems, this should
solve the problem, I would think. (Schorsch, do you agree?)

Yes, that looks like the correct thing to do (and we really
shouldn't try to second guess the declarations in any of the
system header files). I think lseek() is declared in <io.h> on
Windows, which already gets included by plaform.h, but I'll
consult the documentation to make sure.

-schorsch

···

--
Georg Mischler -- simulations developer -- schorsch at schorsch com
+schorsch.com+ -- lighting design tools -- http://www.schorsch.com/

Done. I also updated the calls to lseek() to use the officially blessed macros. If these aren't defined for some reason under Windows, we should add the following lines to platform.h:

#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif

-Greg

···

From: Georg Mischler <[email protected]>
Date: Sun Oct 19, 2003 3:18:42 PM US/Pacific

Greg Ward wrote:

I guess the solution is to include the new "platform.h" for all files
that use lseek(), which are the following by my search:

[...]

Since "platform.h" includes <unistd.h> on all UNIX systems, this should
solve the problem, I would think. (Schorsch, do you agree?)

Yes, that looks like the correct thing to do (and we really
shouldn't try to second guess the declarations in any of the
system header files). I think lseek() is declared in <io.h> on
Windows, which already gets included by plaform.h, but I'll
consult the documentation to make sure.