All of lore.kernel.org
 help / color / mirror / Atom feed
* 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

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.