diff --git a/bin/package b/bin/package index a96774a77664..edca85421a4c 100755 --- a/bin/package +++ b/bin/package @@ -1407,7 +1407,7 @@ esac # Hack to build on some systems that need an explicit link with libm due to a bug in the build system case `uname` in -NetBSD | SunOS) +NetBSD | SunOS | DragonFly) case " $LDFLAGS " in *" -m "*) ;; diff --git a/src/cmd/INIT/package.sh b/src/cmd/INIT/package.sh index d1dbf990b9de..c1cb94ac6d17 100644 --- a/src/cmd/INIT/package.sh +++ b/src/cmd/INIT/package.sh @@ -1406,7 +1406,7 @@ esac # Hack to build on some systems that need an explicit link with libm due to a bug in the build system case `uname` in -NetBSD | SunOS) +NetBSD | SunOS | DragonFly) case " $LDFLAGS " in *" -m "*) ;; diff --git a/src/cmd/ksh93/sh/main.c b/src/cmd/ksh93/sh/main.c index 6c6fc41f7c0e..e45aae7547e7 100644 --- a/src/cmd/ksh93/sh/main.c +++ b/src/cmd/ksh93/sh/main.c @@ -52,7 +52,7 @@ /* These routines are referenced by this module */ static void exfile(Shell_t*, Sfio_t*,int); static void chkmail(Shell_t *shp, char*); -#if defined(_lib_fork) && !defined(_NEXT_SOURCE) && !defined(__FreeBSD__) && !defined(__sun) +#if defined(_lib_fork) && !defined(_NEXT_SOURCE) && !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__sun) static void fixargs(char**,int); #else # define fixargs(a,b) diff --git a/src/cmd/ksh93/tests/basic.sh b/src/cmd/ksh93/tests/basic.sh index 305ceea34cc5..8b5acf114b24 100755 --- a/src/cmd/ksh93/tests/basic.sh +++ b/src/cmd/ksh93/tests/basic.sh @@ -711,7 +711,7 @@ getPsOutput() { while [[ $actual == [[:space:]]* ]]; do actual=${actual#?}; done while [[ $actual == *[[:space:]] ]]; do actual=${actual%?}; done } -if [[ ! $(uname -s) =~ ^(FreeBSD|SunOS)$ ]] && +if [[ ! $(uname -s) =~ ^(FreeBSD|DragonFly|SunOS)$ ]] && getPsOutput "$$" && [[ "$SHELL $0" == "$actual"* ]] # "$SHELL $0" is how shtests invokes this script then expect='./atest 1 2' diff --git a/src/lib/libast/comp/setlocale.c b/src/lib/libast/comp/setlocale.c index 013f4ef51150..22c3401ecd44 100644 --- a/src/lib/libast/comp/setlocale.c +++ b/src/lib/libast/comp/setlocale.c @@ -36,6 +36,7 @@ #include #include #include +#include #if ( _lib_wcwidth || _lib_wctomb ) && _hdr_wctype #include diff --git a/src/lib/libast/features/standards b/src/lib/libast/features/standards index 50e041a7d918..ba9264d9bfa6 100644 --- a/src/lib/libast/features/standards +++ b/src/lib/libast/features/standards @@ -1,5 +1,19 @@ set stdio -if tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{ +# In FreeBSD, definitions like _POSIX_SOURCE and such are used to *limit* +# functionality to known API; they don't enable anything. The general intent in +# BSD is to enable everything by default (effectively, providing the +# _KITCHEN_SINK_SOURCE mentioned below). So we look for that here, but stay +# careful that we don't get fooled by presence of FreeBSD that underpins some +# subsystems in Mac OS X; there are other Apple-specific portability hacks +# elsewhere we should not interfere with. +if tst note{ FreeBSD or DragonFly BSD }end compile{ + #include + #if (!defined(__FreeBSD__) && !defined(__DragonFly__)) || defined(APPLE) + #error not a FreeBSD or DragonFly BSD system + #endif + }end { + } +elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{ #define _ALL_SOURCE 1 #define _POSIX_SOURCE 1 #define _POSIX_C_SOURCE 21000101L diff --git a/src/lib/libast/features/wchar b/src/lib/libast/features/wchar index 5725f96f4b8c..9153994945c1 100644 --- a/src/lib/libast/features/wchar +++ b/src/lib/libast/features/wchar @@ -6,7 +6,7 @@ set include . cat{ #ifndef _AST_WCHAR_H #define _AST_WCHAR_H 1 - #ifdef __FreeBSD__ + #if defined(__FreeBSD__) || defined(__DragonFly__) #define _STDFILE_DECLARED 1 #endif }end diff --git a/src/lib/libast/include/sfio.h b/src/lib/libast/include/sfio.h index fb1f18970b92..75cbf6da4266 100644 --- a/src/lib/libast/include/sfio.h +++ b/src/lib/libast/include/sfio.h @@ -150,7 +150,7 @@ struct _sffmt_s #define SF_IOINTR 0040000 /* return on interrupts */ #define SF_WCWIDTH 0100000 /* wcwidth display stream */ -#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */ +#define SFIO_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */ #ifdef _typ_struct_sf_hdtr #define _SF_HIDESFFLAGS 1 #endif @@ -458,7 +458,7 @@ __INLINE__ ssize_t sfmaxr(ssize_t n, int s) { return __sf_maxr(n,s); } #endif /* _SFSTR_H */ #ifdef _SF_HIDESFFLAGS -#undef SF_FLAGS -#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */ +#undef SFIO_FLAGS +#define SFIO_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */ #endif #endif /* _SFIO_H */ diff --git a/src/lib/libast/include/sfio_t.h b/src/lib/libast/include/sfio_t.h index 6e3a52c72369..a44439613927 100644 --- a/src/lib/libast/include/sfio_t.h +++ b/src/lib/libast/include/sfio_t.h @@ -75,7 +75,7 @@ (unsigned char*)(data), /* endr */ \ (unsigned char*)(data), /* endb */ \ (Sfio_t*)0, /* push */ \ - (unsigned short)((type)&SF_FLAGS), /* flags */ \ + (unsigned short)((type)&SFIO_FLAGS), /* flags */ \ (short)(file), /* file */ \ (unsigned char*)(data), /* data */ \ (ssize_t)(size), /* size */ \ diff --git a/src/lib/libast/sfio/_sfopen.c b/src/lib/libast/sfio/_sfopen.c index c77f6edb7737..849a1dfea8eb 100644 --- a/src/lib/libast/sfio/_sfopen.c +++ b/src/lib/libast/sfio/_sfopen.c @@ -55,7 +55,7 @@ char* mode; /* mode of the stream */ { SFMTXENTER(f, NIL(Sfio_t*)); if(f->mode&SF_INIT ) /* stream uninitialized, ok to set flags */ - { f->flags |= (sflags & (SF_FLAGS & ~SF_RDWR)); + { f->flags |= (sflags & (SFIO_FLAGS & ~SF_RDWR)); if((sflags &= SF_RDWR) != 0) /* reset read/write modes */ { f->flags = (f->flags & ~SF_RDWR) | sflags; diff --git a/src/lib/libast/sfio/sfclrlock.c b/src/lib/libast/sfio/sfclrlock.c index 711756a15595..984aebfde521 100644 --- a/src/lib/libast/sfio/sfclrlock.c +++ b/src/lib/libast/sfio/sfclrlock.c @@ -57,7 +57,7 @@ Sfio_t *f; /* throw away all lock bits except for stacking state SF_PUSH */ f->mode &= (SF_RDWR|SF_INIT|SF_POOL|SF_PUSH|SF_SYNCED|SF_STDIO); - rv = (f->mode&SF_PUSH) ? 0 : (f->flags&SF_FLAGS); + rv = (f->mode&SF_PUSH) ? 0 : (f->flags&SFIO_FLAGS); SFMTXRETURN(f, rv); } diff --git a/src/lib/libast/sfio/sfhdr.h b/src/lib/libast/sfio/sfhdr.h index 8235d4d98623..629f65b19167 100644 --- a/src/lib/libast/sfio/sfhdr.h +++ b/src/lib/libast/sfio/sfhdr.h @@ -1306,8 +1306,8 @@ extern int poll _ARG_((ulong, struct pollfd*, int)); _END_EXTERNS_ #ifdef _SF_HIDESFFLAGS -#undef SF_FLAGS -#define SF_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */ +#undef SFIO_FLAGS +#define SFIO_FLAGS 0177177 /* PUBLIC FLAGS PASSABLE TO SFNEW() */ #endif #endif /*_SFHDR_H*/ diff --git a/src/lib/libast/sfio/sfnew.c b/src/lib/libast/sfio/sfnew.c index a6feddcf0ff6..65550808884f 100644 --- a/src/lib/libast/sfio/sfnew.c +++ b/src/lib/libast/sfio/sfnew.c @@ -106,7 +106,7 @@ int flags; /* type of file stream */ /* stream type */ f->mode = (flags&SF_READ) ? SF_READ : SF_WRITE; - f->flags = (flags&SF_FLAGS) | (sflags&(SF_MALLOC|SF_STATIC)); + f->flags = (flags&SFIO_FLAGS) | (sflags&(SF_MALLOC|SF_STATIC)); f->bits = (flags&SF_RDWR) == SF_RDWR ? SF_BOTH : 0; f->file = file; f->here = f->extent = 0; diff --git a/src/lib/libast/sfio/sfset.c b/src/lib/libast/sfio/sfset.c index a18662ed193b..e28d7eacc227 100644 --- a/src/lib/libast/sfio/sfset.c +++ b/src/lib/libast/sfio/sfset.c @@ -41,7 +41,7 @@ int set; SFMTXENTER(f,0); if(flags == 0 && set == 0) - SFMTXRETURN(f, (f->flags&SF_FLAGS)); + SFMTXRETURN(f, (f->flags&SFIO_FLAGS)); if((oflags = (f->mode&SF_RDWR)) != (int)f->mode) { /* avoid sfsetbuf() isatty() call if user sets (SF_LINE|SF_WCWIDTH) */ @@ -57,7 +57,7 @@ int set; SFMTXRETURN(f, 0); } if(flags == 0) - SFMTXRETURN(f, (f->flags&SF_FLAGS)); + SFMTXRETURN(f, (f->flags&SFIO_FLAGS)); SFLOCK(f,0); @@ -95,5 +95,5 @@ int set; f->flags &= ~SF_PUBLIC; SFOPEN(f,0); - SFMTXRETURN(f, (oflags&SF_FLAGS)); + SFMTXRETURN(f, (oflags&SFIO_FLAGS)); } diff --git a/src/lib/libast/string/strexpr.c b/src/lib/libast/string/strexpr.c index 23be2f50684b..3e167d06438d 100644 --- a/src/lib/libast/string/strexpr.c +++ b/src/lib/libast/string/strexpr.c @@ -44,7 +44,7 @@ #define peekchr(ex) (*(ex)->nextchr) #define ungetchr(ex) ((ex)->nextchr--) -#define error(ex,msg) return(seterror(ex,msg)) +#define err(ex,msg) return(seterror(ex,msg)) typedef struct /* expression handle */ { @@ -87,7 +87,7 @@ expr(register Expr_t* ex, register int precedence) case 0: ungetchr(ex); if (!precedence) return(0); - error(ex, "more tokens expected"); + err(ex, "more tokens expected"); case '-': n = -expr(ex, 13); break; @@ -113,17 +113,17 @@ expr(register Expr_t* ex, register int precedence) case 0: goto done; case ')': - if (!precedence) error(ex, "too many )'s"); + if (!precedence) err(ex, "too many )'s"); goto done; case '(': n = expr(ex, 1); if (getchr(ex) != ')') { ungetchr(ex); - error(ex, "closing ) expected"); + err(ex, "closing ) expected"); } gotoperand: - if (operand) error(ex, "operator expected"); + if (operand) err(ex, "operator expected"); operand = 1; continue; case '?': @@ -140,7 +140,7 @@ expr(register Expr_t* ex, register int precedence) if (getchr(ex) != ':') { ungetchr(ex); - error(ex, ": expected for ? operator"); + err(ex, ": expected for ? operator"); } if (n) { @@ -189,7 +189,7 @@ expr(register Expr_t* ex, register int precedence) break; case '=': case '!': - if (peekchr(ex) != '=') error(ex, "operator syntax error"); + if (peekchr(ex) != '=') err(ex, "operator syntax error"); if (precedence > 7) goto done; getchr(ex); x = expr(ex, 8); @@ -237,7 +237,7 @@ expr(register Expr_t* ex, register int precedence) if (precedence > 11) goto done; x = expr(ex, 12); if (c == '*') n *= x; - else if (x == 0) error(ex, "divide by zero"); + else if (x == 0) err(ex, "divide by zero"); else if (c == '/') n /= x; else n %= x; break; @@ -246,15 +246,15 @@ expr(register Expr_t* ex, register int precedence) pos = --ex->nextchr; if (isdigit(c)) n = strton(ex->nextchr, &ex->nextchr, NiL, 0); else if (ex->convert) n = (*ex->convert)(ex->nextchr, &ex->nextchr, ex->handle); - if (ex->nextchr == pos) error(ex, "syntax error"); + if (ex->nextchr == pos) err(ex, "syntax error"); goto gotoperand; } if (ex->errmsg) return(0); - if (!operand) error(ex, "operand expected"); + if (!operand) err(ex, "operand expected"); } done: ungetchr(ex); - if (!operand) error(ex, "operand expected"); + if (!operand) err(ex, "operand expected"); return(n); }