Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patches to compile on FreeBSD (2017-10-14) #19

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.orig
*.rej
2 changes: 1 addition & 1 deletion lib/package/ast-ksh.ver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ast-ksh 2014-12-24 2014-12-24 1
ast-ksh 2016-06-16 2016-06-16 1
4 changes: 3 additions & 1 deletion src/cmd/ksh93/RELEASE
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
14-12-24 --- Release ksh93v- ---
16-07-17 --- Release ksh93v- ---
16-07-17 A fix to avoid "non-void function 'ls' should return a value" error.
16-07-17 Some patches for compilation on FreeBSD have been added.
14-12-24 A bug which occurred when the undocumented alarm builtin received an
alarm timeout while in the read builtin has been fixed.
14-12-24 A bug in the startup of interactive restricted ksh which give a
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/include/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* David Korn <[email protected]> *
* *
***********************************************************************/
#define SH_RELEASE "93v- 2014-12-24"
#define SH_RELEASE "93v- 2016-07-16"
9 changes: 9 additions & 0 deletions src/cmd/proto/proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,15 @@ proto(char* file, char* license, char* options, char* package, char* copy, char*

#if !PROTO_STANDALONE
#undef error
void
error( int xit, const char *msg, ... )
{
va_list ap;
va_start( ap, msg );
vfprintf( stderr, msg, ap );
va_end( ap );
exit( xit );
}
#endif

typedef struct Sufcom_s
Expand Down
10 changes: 7 additions & 3 deletions src/cmd/std/features/procfs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
hdr kvm,procinfo,pstat,asm/param

sys procfs,sysctl
sys procfs,sysctl,user

lib getprocs
lib kvm_open,kvm_getprocs kvm.h sys/time.h sys/param.h sys/proc.h sys/sysctl.h -lkvm
Expand All @@ -10,7 +10,11 @@ mem extern_proc.p_pid,extern_proc.p_starttime,extern_proc.p_wchan,extern_proc.p_
mem procsinfo64.pi_pri procinfo.h
mem prpsinfo.pr_clname,prpsinfo.pr_cstime,prpsinfo.pr_cstime.tv_sec,prpsinfo.pr_ctime,prpsinfo.pr_cutime,prpsinfo.pr_gid,prpsinfo.pr_lttydev,prpsinfo.pr_ntpid,prpsinfo.pr_pgid,prpsinfo.pr_pgrp,prpsinfo.pr_psargs,prpsinfo.pr_refcount,prpsinfo.pr_rssize,prpsinfo.pr_sid,prpsinfo.pr_sonproc,prpsinfo.pr_start,prpsinfo.pr_start.tv_sec,prpsinfo.pr_starttime,prpsinfo.pr_starttime.tv_sec,prpsinfo.pr_state,prpsinfo.pr_stime,prpsinfo.pr_tgrp,prpsinfo.pr_time,prpsinfo.pr_time.tv_sec,prpsinfo.pr_utime,prpsinfo.pr_zomb,prpsinfo.pr_pctcpu,prpsinfo.pr_cpu,prpsinfo.pr_lwp.pr_pctcpu,prpsinfo.pr_lwp.pr_cpu -D_STRUCTURED_PROC -Dprpsinfo=psinfo sys/types.h sys/procfs.h

num PIOCPSINFO

typ struct.prpsinfo -D_STRUCTURED_PROC -Dprpsinfo=psinfo sys/types.h sys/procfs.h
typ struct.kinfo_proc sys/types.h sys/procfs.h sys/user.h
typ struct.kp_proc sys/types.h sys/procfs.h sys/user.h

tst lib_info note{ info(2) kernel table api }end link{
#include <info.h>
Expand Down Expand Up @@ -587,11 +591,11 @@ cat{
#define PSS_METHOD PSS_METHOD_getprocs
#endif

#if !PSS_METHOD && defined(_PS_dir)
#if !PSS_METHOD && defined(_PS_dir) && (_PS_scan_binary || _num_PIOCPSINFO)
#define PSS_METHOD PSS_METHOD_procfs
#endif

#if !PSS_METHOD && _hdr_kvm && _sys_sysctl && _lib_kvm_open && _lib_kvm_getprocs
#if !PSS_METHOD && _hdr_kvm && _sys_sysctl && _lib_kvm_open && _lib_kvm_getprocs && _typ_struct_kinfo_proc && _typ_struct_kp_proc
#define PSS_METHOD PSS_METHOD_kvm
#endif

Expand Down
3 changes: 3 additions & 0 deletions src/cmd/std/pss-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ NoN(pss_kvm)
#if _sys_proc
#include <sys/proc.h>
#endif
#if _sys_user
#include <sys/user.h>
#endif
#include <sys/sysctl.h>
#include <sys/tty.h>

Expand Down
1 change: 1 addition & 0 deletions src/lib/libast/comp/setlocale.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <namval.h>
#include <iconv.h>
#include <codeset.h>
#include <errno.h>

#if ( _lib_wcwidth || _lib_wctomb ) && _hdr_wctype
#include <wctype.h>
Expand Down
16 changes: 15 additions & 1 deletion src/lib/libast/features/standards
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
set stdio
if tst note{ _GNU_SOURCE 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 }end compile{
#include <sys/param.h>
#if !defined(__FreeBSD__) || defined(APPLE)
#error not a FreeBSD system
#endif
}end {
}
elif tst note{ _GNU_SOURCE works }end compile{
#define _GNU_SOURCE 1
#include <sys/types.h>
#include <sys/stat.h>
Expand Down
1 change: 1 addition & 0 deletions src/lib/libast/features/wchar
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set include .
cat{
#ifndef _AST_WCHAR_H
#define _AST_WCHAR_H 1
#define _STDFILE_DECLARED
}end

lib mbstowcs,wctomb,wcscmp,wcscoll,wcslen,wcstombs,wcsxfrm,wcwidth stdlib.h stdio.h wchar.h
Expand Down
22 changes: 11 additions & 11 deletions src/lib/libast/string/strexpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
{
Expand Down Expand Up @@ -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;
Expand All @@ -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 '?':
Expand All @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down
8 changes: 4 additions & 4 deletions src/lib/libcmd/ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1257,25 +1257,25 @@ ls(State_t* state, register FTSENT* ent)
if (!VISIBLE(state, ent))
{
fts_set(NiL, ent, FTS_SKIP);
return;
return 0;
}
switch (ent->fts_info)
{
case FTS_NS:
if (ent->fts_parent->fts_info == FTS_DNX)
break;
error(2, "%s: not found", ent->fts_path);
return;
return 1;
case FTS_DC:
if (state->lsflags & LS_DIRECTORY)
break;
error(2, "%s: directory causes cycle", ent->fts_path);
return;
return 1;
case FTS_DNR:
if (state->lsflags & LS_DIRECTORY)
break;
error(2, "%s: cannot read directory", ent->fts_path);
return 0;
return 1;
case FTS_DOT:
#if 0
fts_set(NiL, ent, FTS_SKIP);
Expand Down