[PATCH 13 of 14] chg: extra the logic opening current directory to opencwdx()
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Mon Apr 18 08:16:25 EDT 2016
At Thu, 14 Apr 2016 09:59:06 -0700,
Sean Farley wrote:
> Yuya Nishihara <yuya at tcha.org> writes:
>
> > On Wed, 13 Apr 2016 17:55:55 +0100, Jun Wu wrote:
> >> Do you think it's okay to have a marco for all "*x", or "*at" stuff? It will
> >> make the code shorter. Although I'm not a big fan of macros, I think current
> >> code duplication is a bit too much and macro can help.
> >
> > Using macros should be fine if that makes sense.
>
> Agreed.
>
> >> And about OS X feature detection. What do you think is the best way to do
> >> feature detection here? I personally dislike autoconf. But is compiling
> >> a dummy C program okay? Or should I use "#ifdef SYS_openat"? I think the
> >> C library and system header may not in sync though.
> >
> > No idea, and I don't like autoconf, too. It would be too complicated for small
> > tools like chg.
>
> I, too, hate autotools.
>
> > I think manually-set HAVE_OPENAT macro is good start. Then, we can add a dummy
> > C program later when we're sure it is the best way.
>
> In our other C files, we have #ifdef for Mac OS X vs Windows vs Linux,
> so I'm ok with macros and preprocessors.
As far as I confirm actual header files, "#if defined(AT_FDCWD)" after
"#include <fcntl.h>" can detect availability of "openat()" on Linux,
(Open)Solaris, FreeBSD and MacOS X (10.10).
Defining HAVE_OPENAT macro according to existence of AT_FDCWD macro
can avoid manually-setting it on almost all platforms.
BTW, #3 of this series uses AT_FDCWD macro without any feature
examination. But for portability, it should examine availability of
AT_FDCWD, and define dummy AT_FDCWD if it isn't defined, shouldn't it ?
https://www.mercurial-scm.org/repo/hg-committed/rev/7b5f5a1b4b41
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
----------------------------------------------------------------------
[FUJIWARA Katsunori] foozy at lares.dti.ne.jp
More information about the Mercurial-devel
mailing list