Print this page
8627 want ddi_ffsll, ddi_flsll
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>


5886 }
5887 
5888 
5889 int
5890 ddi_in_panic()
5891 {
5892         return (panicstr != NULL);
5893 }
5894 
5895 
5896 /*
5897  * Find first bit set in a mask (returned counting from 1 up)
5898  */
5899 
5900 int
5901 ddi_ffs(long mask)
5902 {
5903         return (ffs(mask));
5904 }
5905 






5906 /*
5907  * Find last bit set. Take mask and clear
5908  * all but the most significant bit, and
5909  * then let ffs do the rest of the work.
5910  *
5911  * Algorithm courtesy of Steve Chessin.
5912  */
5913 
5914 int
5915 ddi_fls(long mask)
5916 {






5917         while (mask) {
5918                 long nx;
5919 
5920                 if ((nx = (mask & (mask - 1))) == 0)
5921                         break;
5922                 mask = nx;
5923         }
5924         return (ffs(mask));
5925 }
5926 
5927 /*
5928  * The ddi_soft_state_* routines comprise generic storage management utilities
5929  * for driver soft state structures (in "the old days," this was done with
5930  * statically sized array - big systems and dynamic loading and unloading
5931  * make heap allocation more attractive).
5932  */
5933 
5934 /*
5935  * Allocate a set of pointers to 'n_items' objects of size 'size'
5936  * bytes.  Each pointer is initialized to nil.
5937  *
5938  * The 'size' and 'n_items' values are stashed in the opaque




5886 }
5887 
5888 
5889 int
5890 ddi_in_panic()
5891 {
5892         return (panicstr != NULL);
5893 }
5894 
5895 
5896 /*
5897  * Find first bit set in a mask (returned counting from 1 up)
5898  */
5899 
5900 int
5901 ddi_ffs(long mask)
5902 {
5903         return (ffs(mask));
5904 }
5905 
5906 int
5907 ddi_ffsll(long long mask)
5908 {
5909         return (ffs(mask));
5910 }
5911 
5912 /*
5913  * Find last bit set. Take mask and clear
5914  * all but the most significant bit, and
5915  * then let ffs do the rest of the work.
5916  *
5917  * Algorithm courtesy of Steve Chessin.
5918  */
5919 
5920 int
5921 ddi_fls(long mask)
5922 {
5923         return (ddi_flsll(mask));
5924 }
5925 
5926 int
5927 ddi_flsll(long long mask)
5928 {
5929         while (mask) {
5930                 long long nx;
5931 
5932                 if ((nx = (mask & (mask - 1))) == 0)
5933                         break;
5934                 mask = nx;
5935         }
5936         return (ffs(mask));
5937 }
5938 
5939 /*
5940  * The ddi_soft_state_* routines comprise generic storage management utilities
5941  * for driver soft state structures (in "the old days," this was done with
5942  * statically sized array - big systems and dynamic loading and unloading
5943  * make heap allocation more attractive).
5944  */
5945 
5946 /*
5947  * Allocate a set of pointers to 'n_items' objects of size 'size'
5948  * bytes.  Each pointer is initialized to nil.
5949  *
5950  * The 'size' and 'n_items' values are stashed in the opaque