On Mon, Apr 8, 2013 at 8:51 AM, H. Peter Anvin <
h...@zytor.com> wrote:
> On 04/08/2013 08:45 AM, H.J. Lu wrote:
>>
>> One potential change is to make snd_ctl_elem_valueX32 identical
>> to snd_ctl_elem_value32 so that we don't need to change control_compat.c
>> It means we need to change the 64-bit integer alignment in
>> struct snd_ctl_elem_value in user space. Peter, should we do it?
>>
>
> Change it on i386 or x32?
>
User space struct snd_ctl_elem_value has
struct snd_ctl_elem_value {
struct snd_ctl_elem_id id; /* W: element ID */
unsigned int indirect: 1; /* W: indirect access - obsoleted */
union {
union {
long value[128];
long *value_ptr; /* obsoleted */
} integer;
union {
long long value[64];
long long *value_ptr; /* obsoleted */
} integer64;
union {
unsigned int item[128];
unsigned int *item_ptr; /* obsoleted */
} enumerated;
union {
unsigned char data[512];
unsigned char *data_ptr; /* obsoleted */
} bytes;
struct snd_aes_iec958 iec958;
} value; /* RO */
struct timespec tstamp;
unsigned char reserved[128-sizeof(struct timespec)];
};
and the kernel has
struct snd_ctl_elem_value32 {
struct snd_ctl_elem_id id;
unsigned int indirect; /* bit-field causes misalignment */
union {
s32 integer[128];
unsigned char data[512];
#ifndef CONFIG_X86_64
s64 integer64[64];
#endif
} value;
unsigned char reserved[128];
};
The difference between i386 and x32 is:
union {
long long value[64];
long long *value_ptr; /* obsoleted */
} integer64;
which is aligned to 32-bit for i486 and 64-bit for x32. With something
like
--
diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index 1774a5c..c40a1d15 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -866,6 +866,17 @@ struct snd_ctl_elem_info {
unsigned char reserved[64-4*sizeof(unsigned short)];
};
+#if defined(__x86_64__) && defined(__ILP32__)
+typedef long long __kernel_snd_int64_t __attribute__((aligned(4)));
+struct __kernel_snd_timespec
+ __kernel_snd_int64_t tv_sec;
+ __kernel_snd_int64_t tv_nsec;
+};
+#else
+#define __kernel_snd_int64_t long long
+#define __kernel_snd_timespec timespec
+#endif
+
struct snd_ctl_elem_value {
struct snd_ctl_elem_id id; /* W: element ID */
unsigned int indirect: 1; /* W: indirect access - obsoleted */
@@ -875,7 +886,7 @@ struct snd_ctl_elem_value {
long *value_ptr; /* obsoleted */
} integer;
union {
- long long value[64];
+ __kernel_snd_int64_t value[64];
long long *value_ptr; /* obsoleted */
} integer64;
union {
@@ -888,8 +899,8 @@ struct snd_ctl_elem_value {
} bytes;
struct snd_aes_iec958 iec958;
} value; /* RO */
- struct timespec tstamp;
- unsigned char reserved[128-sizeof(struct timespec)];
+ struct __kernel_snd_timespec tstamp;
+ unsigned char reserved[128-sizeof(struct __kernel_snd_timespec)];
};
struct snd_ctl_tlv {
--
we can use snd_ctl_elem_valueX32 for x32 and we don't need to
change sound/core/control_compat.c.
--
H.J.