ALSA: Clean up 64bit division functions
Replace the house-made div64_32() with the standard div_u64*() functions. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
@ -486,80 +486,6 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream);
|
||||
void snd_pcm_vma_notify_data(void *client, void *data);
|
||||
int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area);
|
||||
|
||||
#if BITS_PER_LONG >= 64
|
||||
|
||||
static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem)
|
||||
{
|
||||
*rem = *n % div;
|
||||
*n /= div;
|
||||
}
|
||||
|
||||
#elif defined(i386)
|
||||
|
||||
static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem)
|
||||
{
|
||||
u_int32_t low, high;
|
||||
low = *n & 0xffffffff;
|
||||
high = *n >> 32;
|
||||
if (high) {
|
||||
u_int32_t high1 = high % div;
|
||||
high /= div;
|
||||
asm("divl %2":"=a" (low), "=d" (*rem):"rm" (div), "a" (low), "d" (high1));
|
||||
*n = (u_int64_t)high << 32 | low;
|
||||
} else {
|
||||
*n = low / div;
|
||||
*rem = low % div;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
static inline void divl(u_int32_t high, u_int32_t low,
|
||||
u_int32_t div,
|
||||
u_int32_t *q, u_int32_t *r)
|
||||
{
|
||||
u_int64_t n = (u_int64_t)high << 32 | low;
|
||||
u_int64_t d = (u_int64_t)div << 31;
|
||||
u_int32_t q1 = 0;
|
||||
int c = 32;
|
||||
while (n > 0xffffffffU) {
|
||||
q1 <<= 1;
|
||||
if (n >= d) {
|
||||
n -= d;
|
||||
q1 |= 1;
|
||||
}
|
||||
d >>= 1;
|
||||
c--;
|
||||
}
|
||||
q1 <<= c;
|
||||
if (n) {
|
||||
low = n;
|
||||
*q = q1 | (low / div);
|
||||
*r = low % div;
|
||||
} else {
|
||||
*r = 0;
|
||||
*q = q1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem)
|
||||
{
|
||||
u_int32_t low, high;
|
||||
low = *n & 0xffffffff;
|
||||
high = *n >> 32;
|
||||
if (high) {
|
||||
u_int32_t high1 = high % div;
|
||||
u_int32_t low1 = low;
|
||||
high /= div;
|
||||
divl(high1, low1, div, &low, rem);
|
||||
*n = (u_int64_t)high << 32 | low;
|
||||
} else {
|
||||
*n = low / div;
|
||||
*rem = low % div;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PCM library
|
||||
*/
|
||||
|
Reference in New Issue
Block a user