* Mac OS X support patch
@ 2008-07-11 21:20 Mark Mentovai
2008-07-12 3:20 ` H. Peter Anvin
2009-01-13 4:19 ` Herbert Xu
0 siblings, 2 replies; 9+ messages in thread
From: Mark Mentovai @ 2008-07-11 21:20 UTC (permalink / raw)
To: dash
[-- Attachment #1: Type: text/plain, Size: 635 bytes --]
Hi, Herbert and friends. I've created a small patch that allows dash
to be built on Mac OS X. I'm contributing it here with the hope that
it's suitable for inclusion in dash.
The changes in this patch are:
- __attribute__((__alias__())) is not supported, add an autoconf check
- open64 is not present although the stat64 family is, separate the
autoconf checks
- A syntax error had slipped into a non-glibc codepath
- mkbuiltins had a nonportable mktemp invocation for the case where
tempfile is not availalble
Nothing in this patch is actually Mac OS X-specific, so it might aid
portability to other platforms as well.
Mark
[-- Attachment #2: dash.macosx.patch --]
[-- Type: application/octet-stream, Size: 4062 bytes --]
diff --git a/configure.ac b/configure.ac
index 4d739c2..e8d89a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,16 +13,28 @@ AC_MSG_CHECKING([for build system compiler])
if test "$cross_compiling" = yes; then
CC_FOR_BUILD=${CC_FOR_BUILD-cc}
else
CC_FOR_BUILD=${CC}
fi
AC_MSG_RESULT(${CC_FOR_BUILD})
AC_SUBST(CC_FOR_BUILD)
+AC_MSG_CHECKING([for __attribute__((__alias__()))])
+dash_cv_have_attribute_alias=no
+AC_LINK_IFELSE([AC_LANG_PROGRAM([void t() {}
+ void a() __attribute__((__alias__("t")));],
+ [a();])],
+ [dash_cv_have_attribute_alias=yes])
+AC_MSG_RESULT($dash_cv_have_attribute_alias)
+if test "x$dash_cv_have_attribute_alias" = xyes; then
+ AC_DEFINE([HAVE_ALIAS_ATTRIBUTE], 1,
+ [Define if __attribute__((__alias__())) is supported])
+fi
+
AC_ARG_ENABLE(static, AS_HELP_STRING(--enable-static, \
[Build statical linked program]))
if test "$enable_static" = "yes"; then
export LDFLAGS="-static -Wl,--fatal-warnings"
fi
AC_ARG_ENABLE(fnmatch, AS_HELP_STRING(--enable-fnmatch, \
[Use fnmatch(3) from libc]))
@@ -54,16 +66,19 @@ if test "$ac_cv_func_signal" != yes; then
[klibc has bsd_signal instead of signal])])
fi
dnl Check for stat64 (dietlibc/klibc).
AC_CHECK_FUNC(stat64,, [
AC_DEFINE(fstat64, fstat, [64-bit operations are the same as 32-bit])
AC_DEFINE(lstat64, lstat, [64-bit operations are the same as 32-bit])
AC_DEFINE(stat64, stat, [64-bit operations are the same as 32-bit])
+])
+
+AC_CHECK_FUNC(open64,, [
AC_DEFINE(open64, open, [64-bit operations are the same as 32-bit])
])
AC_ARG_WITH(libedit, AS_HELP_STRING(--with-libedit, [Compile with libedit support]))
use_libedit=
if test "$with_libedit" = "yes"; then
AC_CHECK_LIB(edit, history_init, [
AC_CHECK_HEADER([histedit.h], [use_libedit="yes"],
diff --git a/src/cd.c b/src/cd.c
index 624801d..3770664 100644
--- a/src/cd.c
+++ b/src/cd.c
@@ -253,17 +253,17 @@ getpwd()
#ifdef __GLIBC__
char *dir = getcwd(0, 0);
if (dir)
return dir;
#else
char buf[PATH_MAX];
- if (getcwd(buf, sizeof(buf))
+ if (getcwd(buf, sizeof(buf)))
return savestr(buf);
#endif
sh_warnx("getcwd() failed: %s", strerror(errno));
return nullstr;
}
int
diff --git a/src/eval.c b/src/eval.c
index 77291b4..c7d5b14 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -321,17 +321,26 @@ exexit:
exraise(EXEXIT);
}
}
#if !defined(__alpha__) || (defined(__GNUC__) && __GNUC__ >= 3)
STATIC
#endif
-void evaltreenr(union node *, int) __attribute__ ((alias("evaltree")));
+void evaltreenr(union node *n, int flags)
+#ifdef HAVE_ATTRIBUTE_ALIAS
+__attribute__ ((alias("evaltree")));
+#else
+{
+ evaltree(n, flags);
+ exraise(EXERROR);
+ /* NOTREACHED */
+}
+#endif
STATIC void
evalloop(union node *n, int flags)
{
int status;
loopnest++;
diff --git a/src/jobs.c b/src/jobs.c
index 40dc8f6..e1a4fcf 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -356,17 +356,24 @@ fgcmd(int argc, char **argv)
}
outstr(jp->ps->cmd, out);
showpipe(jp, out);
retval = restartjob(jp, mode);
} while (*argv && *++argv);
return retval;
}
-int bgcmd(int, char **) __attribute__((__alias__("fgcmd")));
+int bgcmd(int argc, char **argv)
+#ifdef HAVE_ALIAS_ATTRIBUTE
+__attribute__((__alias__("fgcmd")));
+#else
+{
+ return fgcmd(argc, argv);
+}
+#endif
STATIC int
restartjob(struct job *jp, int mode)
{
struct procstat *ps;
int i;
int status;
diff --git a/src/mkbuiltins b/src/mkbuiltins
index 960c61c..3376031 100644
--- a/src/mkbuiltins
+++ b/src/mkbuiltins
@@ -32,17 +32,17 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)mkbuiltins 8.2 (Berkeley) 5/4/95
tempfile=tempfile
if ! type tempfile > /dev/null 2>&1; then
- tempfile=mktemp
+ tempfile="mktemp -t tempfile.XXXXXX"
fi
trap 'rm -f $temp $temp2' EXIT
temp=$($tempfile)
temp2=$($tempfile)
builtins=$1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: Mac OS X support patch
2008-07-11 21:20 Mac OS X support patch Mark Mentovai
@ 2008-07-12 3:20 ` H. Peter Anvin
2008-07-12 14:51 ` Mark Mentovai
2008-07-13 1:07 ` Herbert Xu
2009-01-13 4:19 ` Herbert Xu
1 sibling, 2 replies; 9+ messages in thread
From: H. Peter Anvin @ 2008-07-12 3:20 UTC (permalink / raw)
To: Mark Mentovai; +Cc: dash
Mark Mentovai wrote:
> - open64 is not present although the stat64 family is, separate the
> autoconf checks
This seems like the Wrong Thing anyway; the right thing should be to add
whatever option (like -D_FILE_OFFSET_BITS=64 on Linux) to do
*everything* using the full-sized offsets.
-hpa
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Mac OS X support patch
2008-07-12 3:20 ` H. Peter Anvin
@ 2008-07-12 14:51 ` Mark Mentovai
2008-07-13 11:24 ` Herbert Xu
2008-07-13 1:07 ` Herbert Xu
1 sibling, 1 reply; 9+ messages in thread
From: Mark Mentovai @ 2008-07-12 14:51 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: dash
H. Peter Anvin wrote:
> Mark Mentovai wrote:
>> - open64 is not present although the stat64 family is, separate the
>> autoconf checks
>
> This seems like the Wrong Thing anyway; the right thing should be to add
> whatever option (like -D_FILE_OFFSET_BITS=64 on Linux) to do *everything*
> using the full-sized offsets.
autoconf provides AC_SYS_LARGEFILE for this, but I don't think it
should be part of this patch. Does dash have a bug tracker where this
can be filed?
Mark
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Mac OS X support patch
2008-07-12 3:20 ` H. Peter Anvin
2008-07-12 14:51 ` Mark Mentovai
@ 2008-07-13 1:07 ` Herbert Xu
2008-07-13 1:26 ` H. Peter Anvin
1 sibling, 1 reply; 9+ messages in thread
From: Herbert Xu @ 2008-07-13 1:07 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: mmentovai, dash
H. Peter Anvin <hpa@zytor.com> wrote:
> Mark Mentovai wrote:
>> - open64 is not present although the stat64 family is, separate the
>> autoconf checks
>
> This seems like the Wrong Thing anyway; the right thing should be to add
> whatever option (like -D_FILE_OFFSET_BITS=64 on Linux) to do
> *everything* using the full-sized offsets.
Actually there is a reason for this. Not all open(2) calls in
dash need large file support. For example, doing it on a shell
script or /dev/null makes no sense. Only those dealing with user
files (redirections) need large file support.
So that's we need to differentiate between open(2) calls on user
files as opposed to those for dash itself.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: Mac OS X support patch
2008-07-13 1:07 ` Herbert Xu
@ 2008-07-13 1:26 ` H. Peter Anvin
2008-07-13 2:53 ` Herbert Xu
0 siblings, 1 reply; 9+ messages in thread
From: H. Peter Anvin @ 2008-07-13 1:26 UTC (permalink / raw)
To: Herbert Xu; +Cc: mmentovai, dash
Herbert Xu wrote:
> H. Peter Anvin <hpa@zytor.com> wrote:
>> Mark Mentovai wrote:
>>> - open64 is not present although the stat64 family is, separate the
>>> autoconf checks
>> This seems like the Wrong Thing anyway; the right thing should be to add
>> whatever option (like -D_FILE_OFFSET_BITS=64 on Linux) to do
>> *everything* using the full-sized offsets.
>
> Actually there is a reason for this. Not all open(2) calls in
> dash need large file support. For example, doing it on a shell
> script or /dev/null makes no sense. Only those dealing with user
> files (redirections) need large file support.
>
> So that's we need to differentiate between open(2) calls on user
> files as opposed to those for dash itself.
>
I'm not sure that that makes sense, however. Unless you're hauling a
*lot* of off_t's around the code, the incremental complexity is hardly
worth it.
The *only* reason for the legacy 32-bit off_t mode is because it is an
ABI change, it is necessary to prevent application/library interface
breakage.
FWIW, klibc doesn't even implement the LFS64 APIs, nor does it implement
the legacy 32-bit off_t mode in any way.
-hpa
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Mac OS X support patch
2008-07-13 1:26 ` H. Peter Anvin
@ 2008-07-13 2:53 ` Herbert Xu
0 siblings, 0 replies; 9+ messages in thread
From: Herbert Xu @ 2008-07-13 2:53 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: mmentovai, dash
On Sat, Jul 12, 2008 at 06:26:11PM -0700, H. Peter Anvin wrote:
>
> I'm not sure that that makes sense, however. Unless you're hauling a
> *lot* of off_t's around the code, the incremental complexity is hardly
> worth it.
Either way it's pretty insignificant. Yes the decrease in code
size isn't great but then the increase in complexity isn't large
either. FWIW the decreases all come from stat on directories
and scripts.
> FWIW, klibc doesn't even implement the LFS64 APIs, nor does it implement
> the legacy 32-bit off_t mode in any way.
That's already handled by autoconf.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Mac OS X support patch
2008-07-11 21:20 Mac OS X support patch Mark Mentovai
2008-07-12 3:20 ` H. Peter Anvin
@ 2009-01-13 4:19 ` Herbert Xu
1 sibling, 0 replies; 9+ messages in thread
From: Herbert Xu @ 2009-01-13 4:19 UTC (permalink / raw)
To: Mark Mentovai; +Cc: dash
On Fri, Jul 11, 2008 at 09:20:24PM +0000, Mark Mentovai wrote:
> Hi, Herbert and friends. I've created a small patch that allows dash
> to be built on Mac OS X. I'm contributing it here with the hope that
> it's suitable for inclusion in dash.
Sorry for the late response but please CC me next time on patches.
> The changes in this patch are:
>
> - __attribute__((__alias__())) is not supported, add an autoconf check
Applied with the exraise changed to abort and formatting fixes.
> - open64 is not present although the stat64 family is, separate the
> autoconf checks
Applied.
> - A syntax error had slipped into a non-glibc codepath
Already fixed.
> - mkbuiltins had a nonportable mktemp invocation for the case where
> tempfile is not availalble
Already fixed.
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-01-13 4:19 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-11 21:20 Mac OS X support patch Mark Mentovai
2008-07-12 3:20 ` H. Peter Anvin
2008-07-12 14:51 ` Mark Mentovai
2008-07-13 11:24 ` Herbert Xu
2008-07-14 15:26 ` Mark Mentovai
2008-07-13 1:07 ` Herbert Xu
2008-07-13 1:26 ` H. Peter Anvin
2008-07-13 2:53 ` Herbert Xu
2009-01-13 4:19 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.