00001 00015 #ifndef __QOS_UL_I386_H__ 00016 #define __QOS_UL_I386_H__ 00017 00018 #ifndef __i386__ 00019 # error "This module only works for i386 architectures" 00020 #endif 00021 00022 #include <linux/types.h> 00023 00041 #define ul_shl_div(num, SHF, den) ({ \ 00042 __volatile__ __u32 _ul_num = (num); \ 00043 __volatile__ __u32 _ul_den = (den); \ 00044 __volatile__ __u32 _ul_res; \ 00045 __asm__ __volatile__("\n" \ 00046 " xorl %%edx, %%edx \n" \ 00047 " shldl %2, %%eax, %%edx \n" \ 00048 " shll %2, %%eax \n" \ 00049 " divl %3 \n" \ 00050 : "=a" (_ul_res) \ 00051 : "0" (_ul_num), "I" ((SHF)), "r" (_ul_den) \ 00052 : "%edx"); \ 00053 _ul_res; \ 00054 }) 00055 00062 #define ul_shl_ceil(num, SHF, den) ({ \ 00063 __volatile__ __u32 _ul_num = (num); \ 00064 __volatile__ __u32 _ul_den = (den); \ 00065 __volatile__ __u32 _ul_res; \ 00066 __asm__ __volatile__("\n" \ 00067 " xorl %%edx, %%edx \n" \ 00068 " shldl %2, %%eax, %%edx \n" \ 00069 " shll %2, %%eax \n" \ 00070 " divl %3 \n" \ 00071 " cmpl $0,%%edx \n" \ 00072 " jz 0f \n" \ 00073 " incl %%eax \n" \ 00074 "0:\n" \ 00075 : "=a" (_ul_res) \ 00076 : "0" (_ul_num), "I" ((SHF)), "r" (_ul_den) \ 00077 : "%edx"); \ 00078 _ul_res; \ 00079 }) 00080 00081 00097 #define ul_mul_div(x, num, den) ({ \ 00098 __volatile__ __u32 _ul_x = (x); \ 00099 __volatile__ __u32 _ul_num = (num); \ 00100 __volatile__ __u32 _ul_den = (den); \ 00101 __volatile__ __u32 _ul_res; \ 00102 __asm__ __volatile__("\n" \ 00103 " mull %%edx \n" \ 00104 " divl %3 \n" \ 00105 : "=a" (_ul_res) \ 00106 : "0" (_ul_x), "d" (_ul_num), "r" (_ul_den)); \ 00107 _ul_res; \ 00108 }) 00109 00110 00130 #define ul_mul_shr(x, y, SHF) ({ \ 00131 __volatile__ __u32 _ul_x = (x); \ 00132 __volatile__ __u32 _ul_y = (y); \ 00133 __volatile__ __u32 _ul_res; \ 00134 __asm__ __volatile__ ("\n" \ 00135 " mull %%edx \n" \ 00136 " shrdl %2, %%edx, %%eax \n" \ 00137 : "=a" (_ul_res) \ 00138 : "0" (_ul_x), "I" ((SHF)), "d" (_ul_y)); \ 00139 _ul_res; \ 00140 }) 00141 00142 #endif