[qemu-aarch64-static has the same problem but qemu-armv7-sstatic does not. The 
context here
is FreeBSD head -r341836 based and ports head -r488859 based.]

Note: I assume that "struct target_freebsd_flock" is meant to match the memory 
layout
of the target's native "struct flock". Otherwise the reported differences
below could be irrelevant.

For amd64 and aarch64 the following code:

        printf("sizeof(struct flock) = %lu\n", (unsigned long) sizeof(struct 
flock));
        printf("l_start %lu\n", (unsigned long) offsetof(struct flock, 
l_start));
        printf("l_len %lu\n", (unsigned long) offsetof(struct flock, l_len));
        printf("l_pid %lu\n", (unsigned long) offsetof(struct flock, l_pid));
        printf("l_type %lu\n", (unsigned long) offsetof(struct flock, l_type));
        printf("l_whence %lu\n", (unsigned long) offsetof(struct flock, 
l_whence));
        printf("l_sysid %lu\n", (unsigned long) offsetof(struct flock, 
l_sysid));
 

produces:

sizeof(struct flock) = 32
l_start 0
l_len 8
l_pid 16
l_type 20
l_whence 22
l_sysid 24


However gdb reports for qemu-x86_64-static and qemu-aarch64-static
and qemu-arm-static:

(gdb) p/d sizeof(struct target_freebsd_flock)
$10 = 28
(gdb) p/d &((struct target_freebsd_flock *)0)->l_start  
$11 = 0
(gdb) p/d &((struct target_freebsd_flock *)0)->l_len  
$12 = 8
(gdb) p/d &((struct target_freebsd_flock *)0)->l_pid
$13 = 16
(gdb) p/d &((struct target_freebsd_flock *)0)->l_type
$14 = 20
(gdb) p/d &((struct target_freebsd_flock *)0)->l_whence
$15 = 22
(gdb) p/d &((struct target_freebsd_flock *)0)->l_sysid 
$16 = 24

So only the overall size is different for this information. But:

struct target_freebsd_flock {
    int64_t l_start;
    int64_t l_len;
    int32_t l_pid;
    int16_t l_type;
    int16_t l_whence;
    int32_t l_sysid;
} QEMU_PACKED;

with a potential packed vs. /usr/include/sys/fcntl.h :

struct flock {
        off_t   l_start;        /* starting offset */
        off_t   l_len;          /* len = 0 means until end of file */
        pid_t   l_pid;          /* lock owner */
        short   l_type;         /* lock type: read/write, etc. */
        short   l_whence;       /* type of l_start */
        int     l_sysid;        /* remote system id or zero for local */
};

with no potential __packed.


===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)

_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-emulation
To unsubscribe, send any mail to "[email protected]"

Reply via email to