try to do some optimum struct packing except for struct env
(pointers, longs, size_t first; time_t next; int etc. then enum, bool)
This commit is contained in:
parent
c7ccde864e
commit
9e83002841
4
Build.sh
4
Build.sh
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.389 2009/04/06 08:37:42 tg Exp $'
|
||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.390 2009/04/07 18:41:32 tg Exp $'
|
||||
#-
|
||||
# Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS
|
||||
# CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NOPWNAM MKSH_NOVI
|
||||
@ -1298,7 +1298,7 @@ mksh_cfg: NSIG' >scn.c
|
||||
test $nr -gt 0 && test $nr -le $NSIG || continue
|
||||
case $sigseen in
|
||||
*:$nr:*) ;;
|
||||
*) echo " { $nr, \"$name\" },"
|
||||
*) echo " { \"$name\", $nr },"
|
||||
sigseen=$sigseen$nr:
|
||||
$printf "$name=$nr " >&2
|
||||
;;
|
||||
|
6
edit.c
6
edit.c
@ -5,7 +5,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.159 2009/04/05 12:35:21 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.160 2009/04/07 18:41:33 tg Exp $");
|
||||
|
||||
/* tty driver characters we are interested in */
|
||||
typedef struct {
|
||||
@ -3362,8 +3362,8 @@ x_mode(bool onoff)
|
||||
#define Ctrl(c) (c&0x1f)
|
||||
|
||||
struct edstate {
|
||||
int winleft;
|
||||
char *cbuf;
|
||||
int winleft;
|
||||
int cbufsize;
|
||||
int linelen;
|
||||
int cursor;
|
||||
@ -3485,7 +3485,7 @@ static void restore_edstate(struct edstate *old, struct edstate *new);
|
||||
static void free_edstate(struct edstate *old);
|
||||
|
||||
static struct edstate ebuf;
|
||||
static struct edstate undobuf = { 0, undocbuf, LINE, 0, 0 };
|
||||
static struct edstate undobuf = { undocbuf, 0, LINE, 0, 0 };
|
||||
|
||||
static struct edstate *es; /* current editor state */
|
||||
static struct edstate *undo;
|
||||
|
8
eval.c
8
eval.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.53 2009/03/22 17:47:35 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.54 2009/04/07 18:41:35 tg Exp $");
|
||||
|
||||
#ifdef MKSH_SMALL
|
||||
#define MKSH_NOPWNAM
|
||||
@ -137,13 +137,13 @@ evalonestr(const char *cp, int f)
|
||||
|
||||
/* for nested substitution: ${var:=$var2} */
|
||||
typedef struct SubType {
|
||||
struct tbl *var; /* variable for ${var..} */
|
||||
struct SubType *prev; /* old type */
|
||||
struct SubType *next; /* poped type (to avoid re-allocating) */
|
||||
short stype; /* [=+-?%#] action after expanded word */
|
||||
short base; /* begin position of expanded word */
|
||||
short f; /* saved value of f (DOPAT, etc) */
|
||||
short quote; /* saved value of quote (for ${..[%#]..}) */
|
||||
struct tbl *var; /* variable for ${var..} */
|
||||
struct SubType *prev; /* old type */
|
||||
struct SubType *next; /* poped type (to avoid re-allocating) */
|
||||
} SubType;
|
||||
|
||||
void
|
||||
|
6
expr.c
6
expr.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.23 2009/03/14 18:12:52 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.24 2009/04/07 18:41:35 tg Exp $");
|
||||
|
||||
/* The order of these enums is constrained by the order of opinfo[] */
|
||||
enum token {
|
||||
@ -108,11 +108,11 @@ typedef struct expr_state Expr_state;
|
||||
struct expr_state {
|
||||
const char *expression; /* expression being evaluated */
|
||||
const char *tokp; /* lexical position */
|
||||
enum token tok; /* token from token() */
|
||||
int noassign; /* don't do assigns (for ?:,&&,||) */
|
||||
struct tbl *val; /* value from token() */
|
||||
struct tbl *evaling; /* variable that is being recursively
|
||||
* expanded (EXPRINEVAL flag set) */
|
||||
int noassign; /* don't do assigns (for ?:,&&,||) */
|
||||
enum token tok; /* token from token() */
|
||||
bool arith; /* evaluating an $(()) expression? */
|
||||
bool natural; /* unsigned arithmetic calculation */
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.77 2009/02/20 13:25:09 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.78 2009/04/07 18:41:35 tg Exp $");
|
||||
|
||||
/*-
|
||||
* MirOS: This is the default mapping type, and need not be specified.
|
||||
@ -980,8 +980,8 @@ sprinkle(int fd)
|
||||
|
||||
#if !HAVE_SYS_SIGNAME
|
||||
static const struct mksh_sigpair {
|
||||
int nr;
|
||||
const char *const name;
|
||||
int nr;
|
||||
} mksh_sigpairs[] = {
|
||||
#include "signames.inc"
|
||||
{ 0, NULL }
|
||||
|
16
jobs.c
16
jobs.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.51 2009/04/05 13:37:37 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.52 2009/04/07 18:41:36 tg Exp $");
|
||||
|
||||
/* Order important! */
|
||||
#define PRUNNING 0
|
||||
@ -13,9 +13,9 @@ __RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.51 2009/04/05 13:37:37 tg Exp $");
|
||||
typedef struct proc Proc;
|
||||
struct proc {
|
||||
Proc *next; /* next process in pipeline (if any) */
|
||||
pid_t pid; /* process id */
|
||||
int state;
|
||||
int status; /* wait status */
|
||||
pid_t pid; /* process id */
|
||||
char command[48]; /* process command string */
|
||||
};
|
||||
|
||||
@ -47,17 +47,17 @@ struct proc {
|
||||
typedef struct job Job;
|
||||
struct job {
|
||||
Job *next; /* next job in list */
|
||||
Proc *proc_list; /* process list */
|
||||
Proc *last_proc; /* last process in list */
|
||||
struct timeval systime; /* system time used by job */
|
||||
struct timeval usrtime; /* user time used by job */
|
||||
pid_t pgrp; /* process group of job */
|
||||
pid_t ppid; /* pid of process that forked job */
|
||||
int job; /* job number: %n */
|
||||
int flags; /* see JF_* */
|
||||
volatile int state; /* job state */
|
||||
int status; /* exit status of last process */
|
||||
pid_t pgrp; /* process group of job */
|
||||
pid_t ppid; /* pid of process that forked job */
|
||||
int32_t age; /* number of jobs started */
|
||||
struct timeval systime; /* system time used by job */
|
||||
struct timeval usrtime; /* user time used by job */
|
||||
Proc *proc_list; /* process list */
|
||||
Proc *last_proc; /* last process in list */
|
||||
Coproc_id coproc_id; /* 0 or id of coprocess output pipe */
|
||||
#ifndef MKSH_UNEMPLOYED
|
||||
struct termios ttystate;/* saved tty state for stopped jobs */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/** $MirOS: src/bin/mksh/setmode.c,v 1.11 2008/04/19 22:15:05 tg Exp $ */
|
||||
/** $MirOS: src/bin/mksh/setmode.c,v 1.12 2009/04/07 18:41:37 tg Rel $ */
|
||||
/* $OpenBSD: setmode.c,v 1.17 2005/08/08 08:05:34 espie Exp $ */
|
||||
/* $NetBSD: setmode.c,v 1.15 1997/02/07 22:21:06 christos Exp $ */
|
||||
|
||||
@ -57,8 +57,8 @@
|
||||
#endif
|
||||
|
||||
__SCCSID("@(#)setmode.c 8.2 (Berkeley) 3/25/94");
|
||||
__RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.11 2008/04/19 22:15:05 tg Exp $");
|
||||
__RCSID("$miros: src/lib/libc/gen/setmode.c,v 1.10 2008/04/19 16:27:23 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.12 2009/04/07 18:41:37 tg Rel $");
|
||||
__RCSID("$miros: src/lib/libc/gen/setmode.c,v 1.12 2009/06/10 18:12:42 tg Exp $");
|
||||
|
||||
/* for mksh */
|
||||
#ifdef ksh_isdigit
|
||||
@ -74,9 +74,9 @@ __RCSID("$miros: src/lib/libc/gen/setmode.c,v 1.10 2008/04/19 16:27:23 tg Exp $"
|
||||
#define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */
|
||||
|
||||
typedef struct bitcmd {
|
||||
mode_t bits;
|
||||
char cmd;
|
||||
char cmd2;
|
||||
mode_t bits;
|
||||
} BITCMD;
|
||||
|
||||
#define CMD2_CLR 0x01
|
||||
|
46
sh.h
46
sh.h
@ -102,7 +102,7 @@
|
||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.289 2009/04/06 08:33:37 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.290 2009/04/07 18:41:37 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R37 2009/04/05"
|
||||
|
||||
@ -554,9 +554,9 @@ typedef enum temp_type Temp_type;
|
||||
struct temp {
|
||||
struct temp *next;
|
||||
struct shf *shf;
|
||||
char *name;
|
||||
int pid; /* pid of process parsed here-doc */
|
||||
Temp_type type;
|
||||
char *name;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -572,14 +572,14 @@ EXTERN int shl_stdout_ok;
|
||||
* trap handlers
|
||||
*/
|
||||
typedef struct trap {
|
||||
int signal; /* signal number */
|
||||
const char *name; /* short name */
|
||||
const char *mess; /* descriptive name */
|
||||
char *trap; /* trap command */
|
||||
volatile sig_atomic_t set; /* trap pending */
|
||||
int flags; /* TF_* */
|
||||
sig_t cursig; /* current handler (valid if TF_ORIG_* set) */
|
||||
sig_t shtrap; /* shell signal handler */
|
||||
int signal; /* signal number */
|
||||
int flags; /* TF_* */
|
||||
volatile sig_atomic_t set; /* trap pending */
|
||||
} Trap;
|
||||
|
||||
/* values for Trap.flags */
|
||||
@ -663,9 +663,9 @@ EXTERN int ifs0 I__(' '); /* for "$*" */
|
||||
#define GI_MINUSMINUS BIT(2) /* arguments were ended with -- */
|
||||
|
||||
typedef struct {
|
||||
const char *optarg;
|
||||
int optind;
|
||||
int uoptind;/* what user sees in $OPTIND */
|
||||
const char *optarg;
|
||||
int flags; /* see GF_* */
|
||||
int info; /* see GI_* */
|
||||
unsigned int p; /* 0 or index into argv[optind - 1] */
|
||||
@ -679,12 +679,12 @@ EXTERN Getopt user_opt; /* parsing state for getopts builtin command */
|
||||
|
||||
typedef int32_t Coproc_id; /* something that won't (realisticly) wrap */
|
||||
struct coproc {
|
||||
void *job; /* 0 or job of co-process using input pipe */
|
||||
int read; /* pipe from co-process's stdout */
|
||||
int readw; /* other side of read (saved temporarily) */
|
||||
int write; /* pipe to co-process's stdin */
|
||||
Coproc_id id; /* id of current output pipe */
|
||||
int njobs; /* number of live jobs using output pipe */
|
||||
void *job; /* 0 or job of co-process using input pipe */
|
||||
Coproc_id id; /* id of current output pipe */
|
||||
};
|
||||
EXTERN struct coproc coproc;
|
||||
|
||||
@ -770,18 +770,18 @@ int shf_putc(int, struct shf *);
|
||||
|
||||
|
||||
struct shf {
|
||||
int flags; /* see SHF_* */
|
||||
Area *areap; /* area shf/buf were allocated in */
|
||||
unsigned char *rp; /* read: current position in buffer */
|
||||
unsigned char *wp; /* write: current position in buffer */
|
||||
unsigned char *buf; /* buffer */
|
||||
int flags; /* see SHF_* */
|
||||
int rbsize; /* size of buffer (1 if SHF_UNBUF) */
|
||||
int rnleft; /* read: how much data left in buffer */
|
||||
unsigned char *wp; /* write: current position in buffer */
|
||||
int wbsize; /* size of buffer (0 if SHF_UNBUF) */
|
||||
int wnleft; /* write: how much space left in buffer */
|
||||
unsigned char *buf; /* buffer */
|
||||
int fd; /* file descriptor */
|
||||
int errno_; /* saved value of errno after error */
|
||||
int bsize; /* actual size of buf */
|
||||
Area *areap; /* area shf/buf were allocated in */
|
||||
};
|
||||
|
||||
extern struct shf shf_iob[];
|
||||
@ -879,8 +879,8 @@ struct tbl { /* table item */
|
||||
|
||||
/* Argument info. Used for $#, $* for shell, functions, includes, etc. */
|
||||
struct arg_info {
|
||||
int flags; /* AF_* */
|
||||
const char **argv;
|
||||
int flags; /* AF_* */
|
||||
int argc_;
|
||||
int skip; /* first arg is argv[0], second is argv[1 + skip] */
|
||||
};
|
||||
@ -891,14 +891,14 @@ struct arg_info {
|
||||
struct block {
|
||||
Area area; /* area to allocate things */
|
||||
const char **argv;
|
||||
int argc;
|
||||
int flags; /* see BF_* */
|
||||
struct table vars; /* local variables */
|
||||
struct table funs; /* local functions */
|
||||
Getopt getopts_state;
|
||||
char *error; /* error handler */
|
||||
char *exit; /* exit handler */
|
||||
struct block *next; /* enclosing block */
|
||||
struct table vars; /* local variables */
|
||||
struct table funs; /* local functions */
|
||||
Getopt getopts_state;
|
||||
int argc;
|
||||
int flags; /* see BF_* */
|
||||
};
|
||||
|
||||
/* Values for struct block.flags */
|
||||
@ -908,8 +908,8 @@ struct block {
|
||||
* Used by ktwalk() and ktnext() routines.
|
||||
*/
|
||||
struct tstate {
|
||||
int left;
|
||||
struct tbl **next;
|
||||
int left;
|
||||
};
|
||||
|
||||
EXTERN struct table taliases; /* tracked aliases */
|
||||
@ -1178,7 +1178,6 @@ typedef struct XPtrV {
|
||||
typedef struct source Source;
|
||||
struct source {
|
||||
const char *str; /* input pointer */
|
||||
int type; /* input type */
|
||||
const char *start; /* start of current buffer */
|
||||
union {
|
||||
const char **strv; /* string [] */
|
||||
@ -1186,13 +1185,14 @@ struct source {
|
||||
struct tbl *tblp; /* alias (SF_HASALIAS) */
|
||||
char *freeme; /* also for SREREAD */
|
||||
} u;
|
||||
const char *file; /* input file name */
|
||||
int type; /* input type */
|
||||
int line; /* line number */
|
||||
int errline; /* line the error occurred on (0 if not set) */
|
||||
const char *file; /* input file name */
|
||||
int flags; /* SF_* */
|
||||
Area *areap;
|
||||
XString xs; /* input buffer */
|
||||
Source *next; /* stacked source */
|
||||
XString xs; /* input buffer */
|
||||
char ugbuf[2]; /* buffer for ungetsc() (SREREAD) and
|
||||
* alias (SALIAS) */
|
||||
};
|
||||
@ -1611,7 +1611,6 @@ typedef enum Test_meta Test_meta;
|
||||
|
||||
typedef struct test_env Test_env;
|
||||
struct test_env {
|
||||
int flags; /* TEF_* */
|
||||
union {
|
||||
const char **wp;/* used by ptest_* */
|
||||
XPtrV *av; /* used by dbtestp_* */
|
||||
@ -1621,6 +1620,7 @@ struct test_env {
|
||||
const char *(*getopnd) (Test_env *, Test_op, bool);
|
||||
int (*eval)(Test_env *, Test_op, const char *, const char *, bool);
|
||||
void (*error)(Test_env *, int, const char *);
|
||||
int flags; /* TEF_* */
|
||||
};
|
||||
|
||||
extern const char *const dbtest_tokens[];
|
||||
|
Loading…
x
Reference in New Issue
Block a user