diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-06-05 11:40:04 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-06-05 11:45:17 -0400 |
commit | 3f7440a6b771169e1f11fa582e53a4259b682809 (patch) | |
tree | 4d91c07abf4269de4f681b821b594f5ad3d4f79a /include/sound/pcm.h | |
parent | 3218911f839b6c85acbf872ad264ea69aa4d89ad (diff) |
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>
Diffstat (limited to 'include/sound/pcm.h')
-rw-r--r-- | include/sound/pcm.h | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index c17296891617..0caf71e16944 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h | |||
@@ -486,80 +486,6 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream); | |||
486 | void snd_pcm_vma_notify_data(void *client, void *data); | 486 | void snd_pcm_vma_notify_data(void *client, void *data); |
487 | int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area); | 487 | int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area); |
488 | 488 | ||
489 | #if BITS_PER_LONG >= 64 | ||
490 | |||
491 | static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem) | ||
492 | { | ||
493 | *rem = *n % div; | ||
494 | *n /= div; | ||
495 | } | ||
496 | |||
497 | #elif defined(i386) | ||
498 | |||
499 | static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem) | ||
500 | { | ||
501 | u_int32_t low, high; | ||
502 | low = *n & 0xffffffff; | ||
503 | high = *n >> 32; | ||
504 | if (high) { | ||
505 | u_int32_t high1 = high % div; | ||
506 | high /= div; | ||
507 | asm("divl %2":"=a" (low), "=d" (*rem):"rm" (div), "a" (low), "d" (high1)); | ||
508 | *n = (u_int64_t)high << 32 | low; | ||
509 | } else { | ||
510 | *n = low / div; | ||
511 | *rem = low % div; | ||
512 | } | ||
513 | } | ||
514 | #else | ||
515 | |||
516 | static inline void divl(u_int32_t high, u_int32_t low, | ||
517 | u_int32_t div, | ||
518 | u_int32_t *q, u_int32_t *r) | ||
519 | { | ||
520 | u_int64_t n = (u_int64_t)high << 32 | low; | ||
521 | u_int64_t d = (u_int64_t)div << 31; | ||
522 | u_int32_t q1 = 0; | ||
523 | int c = 32; | ||
524 | while (n > 0xffffffffU) { | ||
525 | q1 <<= 1; | ||
526 | if (n >= d) { | ||
527 | n -= d; | ||
528 | q1 |= 1; | ||
529 | } | ||
530 | d >>= 1; | ||
531 | c--; | ||
532 | } | ||
533 | q1 <<= c; | ||
534 | if (n) { | ||
535 | low = n; | ||
536 | *q = q1 | (low / div); | ||
537 | *r = low % div; | ||
538 | } else { | ||
539 | *r = 0; | ||
540 | *q = q1; | ||
541 | } | ||
542 | return; | ||
543 | } | ||
544 | |||
545 | static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem) | ||
546 | { | ||
547 | u_int32_t low, high; | ||
548 | low = *n & 0xffffffff; | ||
549 | high = *n >> 32; | ||
550 | if (high) { | ||
551 | u_int32_t high1 = high % div; | ||
552 | u_int32_t low1 = low; | ||
553 | high /= div; | ||
554 | divl(high1, low1, div, &low, rem); | ||
555 | *n = (u_int64_t)high << 32 | low; | ||
556 | } else { | ||
557 | *n = low / div; | ||
558 | *rem = low % div; | ||
559 | } | ||
560 | } | ||
561 | #endif | ||
562 | |||
563 | /* | 489 | /* |
564 | * PCM library | 490 | * PCM library |
565 | */ | 491 | */ |