[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
openat: conditional dependencies
From: |
Bruno Haible |
Subject: |
openat: conditional dependencies |
Date: |
Sat, 5 Nov 2011 12:06:52 +0100 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
Hi Jim,
Now that the module structure of the *at functions is cleaned up - one
function provided per module (except for mkfifoat and mknodat which can
stay in a single module because they are nearly the same thing) -, let
me try to improve what's built with --conditional-dependencies.
Here's the first proposed patch, for the 'openat' replacement.
The save-cwd code is only needed when $HAVE_OPENAT = 0 (i.e. when the system
does not have openat()), not when $REPLACE_OPENAT = 1 (i.e. when gnulib
overrides the system's openat() function). But the .c file currently includes
save-cwd.h in both cases. Since we cannot include save-cwd.h without having
invoked gl_SAVE_CWD, we need to depend on 'save-cwd' (and thus compile the
code of save-cwd.c) _just_ for the sake of the position of the #include
statement.
Here's the proposed patch. While it is a good general guideline to do all
#includes before all function definitions and all #ifs, I think it's worth
deviating from that practice if it can avoid to compile unused compilation
units.
2011-11-05 Bruno Haible <address@hidden>
openat: Conditionalize dependencies.
* lib/openat.c: Reduce the scope of some #includes.
* modules/openat (Depends-on): Add conditions.
--- lib/openat.c.orig Sat Nov 5 11:53:34 2011
+++ lib/openat.c Sat Nov 5 11:48:57 2011
@@ -47,10 +47,6 @@
#include <string.h>
#include <sys/stat.h>
-#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
-#include "openat-priv.h"
-#include "save-cwd.h"
-
#if HAVE_OPENAT
/* Like openat, but work around Solaris 9 bugs with trailing slash. */
@@ -144,6 +140,10 @@
#else /* !HAVE_OPENAT */
+# include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
+# include "openat-priv.h"
+# include "save-cwd.h"
+
/* Replacement for Solaris' openat function.
<http://www.google.com/search?q=openat+site:docs.sun.com>
First, try to simulate it via open ("/proc/self/fd/FD/FILE").
--- modules/openat.orig Sat Nov 5 11:53:34 2011
+++ modules/openat Sat Nov 5 11:52:40 2011
@@ -9,20 +9,20 @@
m4/mode_t.m4
Depends-on:
-at-internal
-dosname
-errno
-extensions
-fchdir
fcntl-h
-fstat
+extensions
largefile
-open
-openat-die
-openat-h
-save-cwd
-stdbool
-sys_stat
+openat-h [test $HAVE_OPENAT = 0 || test $REPLACE_OPENAT = 1]
+stdbool [test $HAVE_OPENAT = 0 || test $REPLACE_OPENAT = 1]
+sys_stat [test $HAVE_OPENAT = 0 || test $REPLACE_OPENAT = 1]
+fstat [test $REPLACE_OPENAT = 1]
+at-internal [test $HAVE_OPENAT = 0]
+dosname [test $HAVE_OPENAT = 0]
+errno [test $HAVE_OPENAT = 0]
+fchdir [test $HAVE_OPENAT = 0]
+open [test $HAVE_OPENAT = 0]
+openat-die [test $HAVE_OPENAT = 0]
+save-cwd [test $HAVE_OPENAT = 0]
configure.ac:
gl_FUNC_OPENAT
--
In memoriam Bernhard Lichtenberg
<http://en.wikipedia.org/wiki/Bernhard_Lichtenberg>
- openat: conditional dependencies,
Bruno Haible <=