[Vm-dev] socketRecordSize is probably not 64-bit friendly
Holger Hans Peter Freyther
holger at freyther.de
Sun Mar 22 18:29:43 UTC 2015
On Sun, Mar 22, 2015 at 01:58:05PM -0400, David T. Lewis wrote:
> On my machine, sizeof(SQSocket) is 16 for both 32 bits and 64 bits. I would
> have expected it to be 12 for the 32-bit case, but maybe the compiler is
> aligning it differently for some reason.
yes, it should be 12 :)
> In any case, "Smalltalk wordSize * 3" would not be right, because the
> actual data structure is this:
>
> typedef struct
> {
> int sessionID;
> int socketType; /* 0 = TCP, 1 = UDP */
> void *privateSocketPtr;
> } SQSocket, *SocketPtr;
$ vi test.c
struct SQSocket {
int sessionID;
int socketType;
void *privateSocketPtr;
};
extern void bla(struct SQSocket*);
int foo(void)
{
struct SQSocket sock;
bla(&sock);
}
$ cc -o test.o -ggdb3 -c test.c
$ pahole test.o
struct SQSocket {
int sessionID; /* 0 4 */
int socketType; /* 4 4 */
void * privateSocketPtr; /* 8 4 */
/* size: 12, cachelines: 1, members: 3 */
/* last cacheline: 12 bytes */
};
Does it really say 16 for you on ia32?
More information about the Vm-dev
mailing list