git » libfiu » commit 7db8847

preload/posix: Avoid using undefined errno values

author Alberto Bertogli
2009-07-03 02:07:54 UTC
committer Alberto Bertogli
2009-07-03 02:07:54 UTC
parent 8509e099e449e824c1db8776abb4e8126cae05cc

preload/posix: Avoid using undefined errno values

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

preload/posix/generate +10 -3

diff --git a/preload/posix/generate b/preload/posix/generate
index dd42e0b..b5a3989 100755
--- a/preload/posix/generate
+++ b/preload/posix/generate
@@ -107,9 +107,7 @@ class Function:
 
 			# We can't put this as a macro parameter, so it has to
 			# be explicit 
-			valid_errnos = '{ ' + ', '.join(self.valid_errnos) \
-				+ ' }'
-			f.write("\tint valid_errnos[] = %s;\n" % valid_errnos)
+			self.write_valid_errnos(f)
 
 			f.write('mkwrap_body_errno("%s", %s, %d)\n' % \
 					(self.fiu_name, self.on_error,
@@ -124,6 +122,15 @@ class Function:
 		f.write('mkwrap_bottom(%s, (%s))\n' % (self.name, paramsn))
 		f.write('\n\n')
 
+	def write_valid_errnos(self, f):
+		"Generates the code for the static list of valid errnos."
+		f.write("\tint valid_errnos[] = {\n")
+		for e in self.valid_errnos:
+			f.write("\t  #ifdef %s\n" % e)
+			f.write("\t\t%s,\n" % e)
+			f.write("\t  #endif\n")
+		f.write("\t};\n");
+
 
 class Include:
 	"Represents an include directive"