structure padding

Dag-ErlingSmørgrav des at des.no
Thu Jan 8 12:14:22 PST 2004


In -STABLE, struct kinfo_proc is currently defined as follows:

struct kinfo_proc {
	struct	proc kp_proc;
	struct	eproc {
                /* ... */
		char	e_login[roundup(MAXLOGNAME, sizeof(long))];
		long	e_spare[2];
	} kp_eproc;
};

I want to add an e_sid field to hold the process's session ID:

struct kinfo_proc {
	struct	proc kp_proc;
	struct	eproc {
                /* ... */
		char	e_login[roundup(MAXLOGNAME, sizeof(long))];
                pid_t   e_sid;
		long	e_spare[1];
	} kp_eproc;
};

However, a pid_t is an int, and sizeof int != sizeof long on Alpha.
I'm not sure what will happen: will alignment rules cause gcc to add
four bytes of padding before e_spare, conserving the size of struct
kinfo_proc, or will struct kinfo_proc shrink by four bytes?

DES
-- 
Dag-Erling Smørgrav - des at des.no


More information about the freebsd-alpha mailing list