2 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
4 .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
5 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH LFCOMPILE 5 "Aug 24, 2009"
8 lfcompile \- large file compilation environment for 32-bit applications
12 All 64-bit applications can manipulate large files by default. The methods
13 described on this page allow 32-bit applications to manipulate large files.
16 In the large file compilation environment, source interfaces are bound to
17 appropriate 64-bit functions, structures, and types. Compiling in this
18 environment allows 32-bit applications to access files whose size is greater
19 than or equal to 2 Gbyte ( 2^31 bytes).
22 Each interface named \fIxxx\fR\fB()\fR that needs to access 64-bit entities to
23 access large files maps to a \fIxxx\fR\fB64()\fR call in the resulting binary.
24 All relevant data types are defined to be of correct size (for example,
25 \fBoff_t\fR has a typedef definition for a 64-bit entity).
28 An application compiled in this environment is able to use the
29 \fIxxx\fR\fB()\fR source interfaces to access both large and small files,
30 rather than having to explicitly utilize the transitional \fIxxx\fR\fB64()\fR
31 interface calls to access large files. See the \fBlfcompile64\fR(5) manual page
32 for information regarding the transitional compilation environment.
35 Applications can be compiled in the large file compilation environment by using
36 the following methods:
41 Use the \fBgetconf\fR(1) utility with one or more of the arguments listed in
42 the table below. This method is recommended for portable applications.
50 \fBargument\fR \fBpurpose\fR
53 obtain compilation flags necessary to enable the large file compilation environment
55 \fBLFS_LDFLAGS\fR obtain link editor options
56 \fBLFS_LIBS\fR obtain link library names
57 \fBLFS_LINTFLAGS\fR obtain lint options
65 Set the compile-time flag \fB_FILE_OFFSET_BITS\fR to 64 before including any
66 headers. Applications may combine objects produced in the large file
67 compilation environment with objects produced in the transitional compilation
68 environment, but must be careful with respect to interoperability between those
69 objects. Applications should not declare global variables of types whose sizes
70 change between compilation environments.
72 .SS "Access to Additional Large File Interfaces"
75 The \fBfseek()\fR and \fBftell()\fR functions \fIdo not\fR map to functions
76 named \fBfseek64()\fR and \fBftell64()\fR; rather, the large file additions
77 \fBfseeko()\fR and \fBftello()\fR, have functionality identical to
78 \fBfseek()\fR and \fBftell()\fR and \fIdo\fR map to the 64-bit functions
79 \fBfseeko64()\fR and \fBftello64()\fR. Applications wishing to access large
80 files should use \fBfseeko()\fR and \fBftello()\fR in place of \fBfseek()\fR
81 and \fBftell()\fR. See the \fBfseek\fR(3C) and \fBftell\fR(3C) manual pages for
82 information about \fBfseeko()\fR and \fBftello()\fR.
85 Applications wishing to access \fBfseeko()\fR and \fBftello()\fR as well as
86 the POSIX and X/Open specification-conforming interfaces should define the
87 macro \fB_LARGEFILE_SOURCE\fR to be 1 and set whichever feature test macros are
88 appropriate to obtain the desired environment (see \fBstandards\fR(5)).
92 In the following examples, the large file compilation environment is accessed
93 by invoking the \fBgetconf\fR utility with one of the arguments listed in the
94 table above. The additional large file interfaces are accessed by specifying
95 \fB-D_LARGEFILE_SOURCE\fR\&.
98 The examples that use the form of command substitution specifying the command
99 within parentheses preceded by a dollar sign can be executed only in a
100 POSIX-conforming shell such as the Korn Shell (see \fBksh\fR(1)). In a shell
101 that is not POSIX-conforming, such as the Bourne Shell (see \fBsh\fR(1)) and
102 the C Shell (see \fBcsh\fR(1)), the \fBgetconf\fR calls must be enclosed within
103 grave accent marks, as shown in the second example.
105 \fBExample 1 \fRCompile a program with a "large" \fBoff_t\fR that uses
106 \fBfseeko()\fR, \fBftello()\fR, and \fByacc\fR.
109 The following example compiles a program with a "large" \fBoff_t\fR and uses
110 \fBfseeko()\fR, \fBftello()\fR, and \fByacc\fR(1).
115 $ c89 -D_LARGEFILE_SOURCE \e
116 -D_FILE_OFFSET_BITS=64 -o foo \e
117 $(getconf LFS_CFLAGS) y.tab.c b.o \e
118 $(getconf LFS_LDFLAGS) \e
119 -ly $(getconf LFS_LIBS)
124 \fBExample 2 \fRCompile a program with a "large" \fBoff_t\fR that does not use
125 \fBfseeko()\fR and \fBftello()\fR and has no application specific libraries.
129 % c89 -D_FILE_OFFSET_BITS=64 \e
130 \(gagetconf LFS_CFLAGS\(ga a.c \e
131 \(gagetconf LFS_LDFLAGS\(ga \e
132 \(gagetconf LFS_LIBS\(ga \e
137 \fBExample 3 \fRCompile a program with a "default" \fBoff_t\fR that uses
138 \fBfseeko()\fR and \fBftello()\fR.
142 $ c89 -D_LARGEFILE_SOURCE a.c
149 \fBcsh\fR(1), \fBgetconf\fR(1), \fBksh\fR(1), \fByacc\fR(1), \fBsh\fR(1),
150 \fBfseek\fR(3C), \fBftell\fR(3C), \fBlf64\fR(5), \fBlfcompile64\fR(5),
155 Certain system-specific or non-portable interfaces are not usable in the large
156 file compilation environment. Known cases are:
161 Kernel data structures read from \fB/dev/kmem\fR.
167 Interfaces in the kernel virtual memory library, \fB-lkvm\fR\&.
173 Interfaces in the \fBELF\fR access library, \fB-lelf\fR\&.
179 Interfaces to \fB/proc\fR defined in <\fBprocfs.h\fR>.
185 The \fBustat\fR(2) system call.
189 Programs that use these interfaces should not be compiled in the large file
190 compilation environment. As a partial safeguard against making this mistake,
191 including either of the <\fBlibelf.h\fR> or <\fBsys/procfs.h\fR> header files
192 will induce a compilation error when the large file compilation environment is
196 In general, caution should be exercised when using any separately-compiled
197 library whose interfaces include data items of type \fBoff_t\fR or the other
198 redefined types either directly or indirectly, such as with '\fBstruct
199 stat\fR'. (The redefined types are \fBoff_t\fR, \fBrlim_t\fR, \fBino_t\fR,
200 \fBblkcnt_t\fR, \fBfsblkcnt_t\fR, and \fBfsfilcnt_t\fR.) For the large file
201 compilation environment to work correctly with such a library, the library
202 interfaces must include the appropriate \fIxxx\fR\fB64()\fR binary entry points
203 and must have them mapped to the corresponding primary functions when
204 \fB_FILE_OFFSET_BITS\fR is set to 64.
207 Care should be exercised using any of the \fBprintf()\fR or \fBscanf()\fR
208 routines on variables of the types mentioned above. In the large file
209 compilation environment, these variables should be printed or scanned using
210 \fBlong long\fR formats.
214 Symbolic formats analogous to those found in \fB<sys/int_fmtio.h>\fR do not
215 exist for printing or scanning variables of the types that are redefined in the
216 large file compilation environment.