git » libfiu » commit e88562d

Only generate off64_t variants when using glibc

author Alberto Bertogli
2014-01-23 23:55:44 UTC
committer Alberto Bertogli
2014-01-24 00:28:25 UTC
parent ab0f7062d80049e95a98c2aba99a01de2727e0e3

Only generate off64_t variants when using glibc

The off64_t variants only make sense in a glibc environment, because they
serve as a work around for a glibc LFS implementation trick.

This patch adjust the code generation to surround the off64_t variants with

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

preload/posix/generate +6 -5

diff --git a/preload/posix/generate b/preload/posix/generate
index d578dd3..6e93247 100755
--- a/preload/posix/generate
+++ b/preload/posix/generate
@@ -158,23 +158,24 @@ class Function:
 
 		f = copy.copy(self)
 
-		# NOTE: we don't modify fiu_name here to be able to enable
+		# NOTE: We don't modify fiu_name here to be able to enable
 		# both <func> and <func>64 versions of the function by
-		# enabling just <func>
+		# enabling just <func>.
 		f.name = f.name + "64"
 		f.params = f.params.replace("off_t", "off64_t")
 		f.params_info = [
 			(x, y) if x != "off_t " else ("off64_t ", y)
 			for (x, y) in f.params_info]
-		return f
+
+		# This is glibc-specific, so surround it with #ifdefs.
+		return [Verbatim("#ifdef __GLIBC__"), f, Verbatim("#endif")]
 
 	def get_all_variants(self):
 		"""Returns all variants of the given function provided via
 		'variants:' function directive"""
-
 		variants = [self]
 		for v in self.variants:
-			variants.append(self.apply_variant(v))
+			variants.extend(self.apply_variant(v))
 		return variants
 
 class Include: