ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/header.c
(Generate patch)

Comparing ray/src/common/header.c (file contents):
Revision 2.40 by greg, Sat Jul 25 01:10:38 2020 UTC vs.
Revision 2.43 by greg, Fri Mar 4 17:16:12 2022 UTC

# Line 57 | Line 57 | newheader(             /* identifying line of information header
57   {
58          fputs(HDRSTR, fp);
59          fputs(s, fp);
60 <        putc('\n', fp);
60 >        fputc('\n', fp);
61   }
62  
63  
# Line 209 | Line 209 | fputformat(            /* put out a format value */
209          FILE  *fp
210   )
211   {
212 +        int     align = 0;
213 +
214          fputs(FMTSTR, fp);
215          fputs(s, fp);
216 <        putc('\n', fp);
216 >                        /* pad to align binary type for mmap() */
217 >        if (!strncmp(s, "float", 5))
218 >                align = sizeof(float);
219 >        else if (!strncmp(s, "double", 6))
220 >                align = sizeof(double);
221 >        else if (!strncmp(s, "16-bit", 6))
222 >                align = 2;
223 >        else if (!strncmp(s, "32-bit", 6))
224 >                align = 4;
225 >        else if (!strncmp(s, "64-bit", 6))
226 >                align = 8;
227 >        if (align) {
228 >                long    pos = ftell(fp);
229 >                if (pos >= 0) {
230 >                        pos = (pos + 2) % align;
231 >                        if (pos) align -= pos;
232 >                        else align = 0;
233 >                } else
234 >                        align = 0;
235 >        }
236 >        while (align-- > 0)
237 >                putc(' ', fp);
238 >        fputc('\n', fp);
239   }
240  
241  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines