optimise structure size calculation to take alignment into account
This commit is contained in:
27
jobs.c
27
jobs.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.122 2017/04/27 19:33:50 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.123 2017/08/08 14:29:23 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
#define mksh_killpg killpg
|
#define mksh_killpg killpg
|
||||||
@ -39,14 +39,27 @@ __RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.122 2017/04/27 19:33:50 tg Exp $");
|
|||||||
#define PSTOPPED 3
|
#define PSTOPPED 3
|
||||||
|
|
||||||
typedef struct proc Proc;
|
typedef struct proc Proc;
|
||||||
struct proc {
|
/* to take alignment into consideration */
|
||||||
Proc *next; /* next process in pipeline (if any) */
|
struct proc_dummy {
|
||||||
pid_t pid; /* process id */
|
Proc *next;
|
||||||
|
pid_t pid;
|
||||||
int state;
|
int state;
|
||||||
int status; /* wait status */
|
int status;
|
||||||
|
char command[128];
|
||||||
|
};
|
||||||
|
/* real structure */
|
||||||
|
struct proc {
|
||||||
|
/* next process in pipeline (if any) */
|
||||||
|
Proc *next;
|
||||||
|
/* process id of this Unix process in the job */
|
||||||
|
pid_t pid;
|
||||||
|
/* one of the four P… above */
|
||||||
|
int state;
|
||||||
|
/* wait status */
|
||||||
|
int status;
|
||||||
/* process command string from vistree */
|
/* process command string from vistree */
|
||||||
char command[256 - (ALLOC_OVERHEAD + sizeof(Proc *) +
|
char command[256 - (ALLOC_OVERHEAD +
|
||||||
sizeof(pid_t) + 2 * sizeof(int))];
|
offsetof(struct proc_dummy, command[0]))];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Notify/print flag - j_print() argument */
|
/* Notify/print flag - j_print() argument */
|
||||||
|
Reference in New Issue
Block a user