[Xorg-driver-geode] [PATCH video-geode] Replace LFS transitional extension API lseek64 and off64_t
Gaetan Nadon
memsize at videotron.ca
Mon Nov 14 11:59:06 PST 2011
The "transitional extension" API is deprecated and is not available on FreeBSD.
It gets replaced with defining _FILE_OFFSET_BITS.
http://www.unix.org/version2/whatsnew/lfs20mar.html#3.0
_LARGEFILE64_SOURCE
Expose definitions for the alternative API specified by the LFS (Large
File Summit) as a "transitional extension" to the Single UNIX
Specification. (See http://opengroup.org/platform/lfs.html.) The
alternative API consists of a set of new objects (i.e., functions and
types) whose names are suffixed with "64" (e.g., off64_t versus off_t,
lseek64() versus lseek(), etc.). New programs should not employ this
interface; instead _FILE_OFFSET_BITS=64 should be employed.
_FILE_OFFSET_BITS
Defining this macro with the value 64 automatically converts references
to 32-bit functions and data types related to file I/O and file system
operations into references to their 64-bit counterparts. This is
useful for performing I/O on large files (> 2 Gigabytes) on 32-bit
systems. (Defining this macro permits correctly written programs to
use large files with only a recompilation being required.) 64-bit
systems naturally permit file sizes greater than 2 Gigabytes, and on
those systems this macro has no effect.
An example using open():
-----------------------------------------------------------------------
int
main (void)
{
return open (".", O_RDONLY) < 0;
}
it should compile and run just fine, with either Sun C or GCC. In the
latter case, the return statement expands via the preprocessor to:
return open64 (".", 0) < 0;
so you don't need to have any instances of open64 in your code.
-------------------------------------------------------------------------
The file _FILE_OFFSET_BITS macro will be defined by AC_SYS_LARGEFILE
which gets included by the generated config.h.
This is consistent with all X.Org modules using large file support,
including the server. Recently large file support was added to xorg
app/sessreg which uses lseek.
Only AC_SYS_LARGEFILE was added in sessreg configure.ac.
It is still unsure if geode driver need support for large file descriptor >2G
Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
---
configure.ac | 1 +
src/durango.c | 2 --
src/geode_msr.c | 9 ++++++---
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac
index 483caff..31e5fe0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,6 +30,7 @@ AC_INIT([xf86-video-geode],
AC_CONFIG_SRCDIR([Makefile.am])
AM_CONFIG_HEADER([config.h])
AC_CONFIG_AUX_DIR(.)
+AC_SYS_LARGEFILE
# Require xorg-macros: XORG_DEFAULT_OPTIONS
m4_ifndef([XORG_MACROS_VERSION],
diff --git a/src/durango.c b/src/durango.c
index 9d6970b..8795d41 100644
--- a/src/durango.c
+++ b/src/durango.c
@@ -32,8 +32,6 @@
#include "config.h"
#endif
-#define _LARGEFILE64_SOURCE
-
#include <unistd.h>
#include <errno.h>
#include <compiler.h>
diff --git a/src/geode_msr.c b/src/geode_msr.c
index 6de693f..26fd78f 100644
--- a/src/geode_msr.c
+++ b/src/geode_msr.c
@@ -1,4 +1,7 @@
-#define _LARGEFILE64_SOURCE
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
@@ -31,7 +34,7 @@ GeodeReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi)
if (fd == -1)
return -1;
- ret = lseek64(fd, (off64_t) addr, SEEK_SET);
+ ret = lseek(fd, (off_t) addr, SEEK_SET);
if (ret == -1)
return -1;
@@ -56,7 +59,7 @@ GeodeWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi)
if (fd == -1)
return -1;
- if (lseek64(fd, (off64_t) addr, SEEK_SET) == -1)
+ if (lseek(fd, (off_t) addr, SEEK_SET) == -1)
return -1;
data[0] = lo;
--
1.7.4.1
More information about the Xorg-driver-geode
mailing list