diff options
author | Josef 'Jeff' Sipek <josef.sipek@nexenta.com> | 2014-10-31 20:49:13 -0400 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2014-11-10 21:21:26 -0800 |
commit | de710d24d2fae4468e64da999e1d952a247f142c (patch) | |
tree | be58a948ed9109a8dea89302c0bfecec604f1c7e | |
parent | 59b0aa363020bcc817969e1c15ac920d3f866e83 (diff) | |
download | illumos-joyent-de710d24d2fae4468e64da999e1d952a247f142c.tar.gz |
5255 uts shouldn't open-code ISP2
Reviewed by: Marcel Telka <marcel@telka.sk>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Robert Mustacchi <rm@joyent.com>
43 files changed, 110 insertions, 109 deletions
diff --git a/usr/src/uts/common/dtrace/dtrace.c b/usr/src/uts/common/dtrace/dtrace.c index 00fbc0a0dd..0d2d6f524c 100644 --- a/usr/src/uts/common/dtrace/dtrace.c +++ b/usr/src/uts/common/dtrace/dtrace.c @@ -13039,7 +13039,7 @@ dtrace_dof_slurp(dof_hdr_t *dof, dtrace_vstate_t *vstate, cred_t *cr, if (!(sec->dofs_flags & DOF_SECF_LOAD)) continue; /* just ignore non-loadable sections */ - if (sec->dofs_align & (sec->dofs_align - 1)) { + if (!ISP2(sec->dofs_align)) { dtrace_dof_error(dof, "bad section alignment"); return (-1); } diff --git a/usr/src/uts/common/dtrace/fasttrap.c b/usr/src/uts/common/dtrace/fasttrap.c index ce7b1c40e6..fc3d87574a 100644 --- a/usr/src/uts/common/dtrace/fasttrap.c +++ b/usr/src/uts/common/dtrace/fasttrap.c @@ -2156,7 +2156,7 @@ fasttrap_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) if (nent == 0 || nent > 0x1000000) nent = FASTTRAP_TPOINTS_DEFAULT_SIZE; - if ((nent & (nent - 1)) == 0) + if (ISP2(nent)) fasttrap_tpoints.fth_nent = nent; else fasttrap_tpoints.fth_nent = 1 << fasttrap_highbit(nent); @@ -2169,7 +2169,7 @@ fasttrap_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) * ... and the providers hash table... */ nent = FASTTRAP_PROVIDERS_DEFAULT_SIZE; - if ((nent & (nent - 1)) == 0) + if (ISP2(nent)) fasttrap_provs.fth_nent = nent; else fasttrap_provs.fth_nent = 1 << fasttrap_highbit(nent); @@ -2182,7 +2182,7 @@ fasttrap_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) * ... and the procs hash table. */ nent = FASTTRAP_PROCS_DEFAULT_SIZE; - if ((nent & (nent - 1)) == 0) + if (ISP2(nent)) fasttrap_procs.fth_nent = nent; else fasttrap_procs.fth_nent = 1 << fasttrap_highbit(nent); diff --git a/usr/src/uts/common/fs/dcfs/dc_vnops.c b/usr/src/uts/common/fs/dcfs/dc_vnops.c index 5a32a9a566..bd0edcbcd4 100644 --- a/usr/src/uts/common/fs/dcfs/dc_vnops.c +++ b/usr/src/uts/common/fs/dcfs/dc_vnops.c @@ -948,8 +948,7 @@ decompvp(struct vnode *vp, cred_t *cred, caller_context_t *ctp) if (error || hdr->ch_magic != CH_MAGIC_ZLIB || hdr->ch_version != CH_VERSION || hdr->ch_algorithm != CH_ALG_ZLIB || hdr->ch_fsize == 0 || hdr->ch_blksize < PAGESIZE || - hdr->ch_blksize > ptob(DCCACHESIZE) || - (hdr->ch_blksize & (hdr->ch_blksize - 1)) != 0) + hdr->ch_blksize > ptob(DCCACHESIZE) || !ISP2(hdr->ch_blksize)) return (NULL); /* get underlying file size */ diff --git a/usr/src/uts/common/fs/zfs/zio.c b/usr/src/uts/common/fs/zfs/zio.c index d67e1361b4..7cb6953845 100644 --- a/usr/src/uts/common/fs/zfs/zio.c +++ b/usr/src/uts/common/fs/zfs/zio.c @@ -24,6 +24,7 @@ * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved. */ +#include <sys/sysmacros.h> #include <sys/zfs_context.h> #include <sys/fm/fs/zfs.h> #include <sys/spa.h> @@ -121,7 +122,7 @@ zio_init(void) size_t align = 0; size_t cflags = (size > zio_buf_debug_limit) ? KMC_NODEBUG : 0; - while (p2 & (p2 - 1)) + while (!ISP2(p2)) p2 &= p2 - 1; #ifndef _KERNEL diff --git a/usr/src/uts/common/inet/ilb/ilb.c b/usr/src/uts/common/inet/ilb/ilb.c index f1340df195..8ab2a90116 100644 --- a/usr/src/uts/common/inet/ilb/ilb.c +++ b/usr/src/uts/common/inet/ilb/ilb.c @@ -24,6 +24,7 @@ * Use is subject to license terms. */ +#include <sys/sysmacros.h> #include <sys/kmem.h> #include <sys/ksynch.h> #include <sys/systm.h> @@ -284,7 +285,7 @@ ilb_rule_hash_init(ilb_stack_t *ilbs) * If ilbs->ilbs_rule_hash_size is not a power of 2, bump it up to * the next power of 2. */ - if (ilbs->ilbs_rule_hash_size & (ilbs->ilbs_rule_hash_size - 1)) { + if (!ISP2(ilbs->ilbs_rule_hash_size)) { for (i = 0; i < 31; i++) { if (ilbs->ilbs_rule_hash_size < (1 << i)) break; diff --git a/usr/src/uts/common/inet/ilb/ilb_conn.c b/usr/src/uts/common/inet/ilb/ilb_conn.c index 450adab5f4..5029552f19 100644 --- a/usr/src/uts/common/inet/ilb/ilb_conn.c +++ b/usr/src/uts/common/inet/ilb/ilb_conn.c @@ -24,6 +24,7 @@ * Use is subject to license terms. */ +#include <sys/sysmacros.h> #include <sys/types.h> #include <sys/conf.h> #include <sys/time.h> @@ -300,7 +301,7 @@ ilb_conn_hash_init(ilb_stack_t *ilbs) * If ilbs->ilbs_conn_hash_size is not a power of 2, bump it up to * the next power of 2. */ - if (ilbs->ilbs_conn_hash_size & (ilbs->ilbs_conn_hash_size - 1)) { + if (!ISP2(ilbs->ilbs_conn_hash_size)) { for (i = 0; i < 31; i++) { if (ilbs->ilbs_conn_hash_size < (1 << i)) break; @@ -1359,7 +1360,7 @@ ilb_sticky_hash_init(ilb_stack_t *ilbs) char tq_name[TASKQ_NAMELEN]; ilb_timer_t *tm; - if (ilbs->ilbs_sticky_hash_size & (ilbs->ilbs_sticky_hash_size - 1)) { + if (!ISP2(ilbs->ilbs_sticky_hash_size)) { for (i = 0; i < 31; i++) { if (ilbs->ilbs_sticky_hash_size < (1 << i)) break; diff --git a/usr/src/uts/common/inet/sctp/sctp_hash.c b/usr/src/uts/common/inet/sctp/sctp_hash.c index 50be40c692..488fe151e1 100644 --- a/usr/src/uts/common/inet/sctp/sctp_hash.c +++ b/usr/src/uts/common/inet/sctp/sctp_hash.c @@ -23,6 +23,7 @@ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. */ +#include <sys/sysmacros.h> #include <sys/socket.h> #include <sys/ddi.h> #include <sys/sunddi.h> @@ -66,7 +67,7 @@ sctp_hash_init(sctp_stack_t *sctps) /* Start with /etc/system value */ sctps->sctps_conn_hash_size = sctp_conn_hash_size; - if (sctps->sctps_conn_hash_size & (sctps->sctps_conn_hash_size - 1)) { + if (!ISP2(sctps->sctps_conn_hash_size)) { /* Not a power of two. Round up to nearest power of two */ for (i = 0; i < 31; i++) { if (sctps->sctps_conn_hash_size < (1 << i)) diff --git a/usr/src/uts/common/inet/udp/udp.c b/usr/src/uts/common/inet/udp/udp.c index c919563289..5a15aea4de 100644 --- a/usr/src/uts/common/inet/udp/udp.c +++ b/usr/src/uts/common/inet/udp/udp.c @@ -25,6 +25,7 @@ */ /* Copyright (c) 1990 Mentat Inc. */ +#include <sys/sysmacros.h> #include <sys/types.h> #include <sys/stream.h> #include <sys/stropts.h> @@ -4384,7 +4385,7 @@ udp_stack_init(netstackid_t stackid, netstack_t *ns) us->us_bind_fanout_size = udp_bind_fanout_size; /* Roundup variable that might have been modified in /etc/system */ - if (us->us_bind_fanout_size & (us->us_bind_fanout_size - 1)) { + if (!ISP2(us->us_bind_fanout_size)) { /* Not a power of two. Round up to nearest power of two */ for (i = 0; i < 31; i++) { if (us->us_bind_fanout_size < (1 << i)) diff --git a/usr/src/uts/common/io/1394/t1394.c b/usr/src/uts/common/io/1394/t1394.c index 99c544bbf7..4cc56bac29 100644 --- a/usr/src/uts/common/io/1394/t1394.c +++ b/usr/src/uts/common/io/1394/t1394.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * t1394.c * 1394 Target Driver Interface @@ -32,6 +30,7 @@ * by target drivers */ +#include <sys/sysmacros.h> #include <sys/conf.h> #include <sys/ddi.h> #include <sys/sunddi.h> @@ -1909,7 +1908,7 @@ t1394_alloc_isoch_cec(t1394_handle_t t1394_hdl, t1394_isoch_cec_props_t *props, temp = props->cec_channel_mask; if (props->cec_options & T1394_NO_IRM_ALLOC) { /* If T1394_NO_IRM_ALLOC, then only one bit should be set */ - if ((temp & (temp - 1)) != 0) { + if (!ISP2(temp)) { TNF_PROBE_1(t1394_alloc_isoch_cec_error, S1394_TNF_SL_ISOCH_ERROR, "", tnf_string, msg, "Invalid channel mask"); diff --git a/usr/src/uts/common/io/arn/arn_main.c b/usr/src/uts/common/io/arn/arn_main.c index 68e61a6773..0aed5d40c8 100644 --- a/usr/src/uts/common/io/arn/arn_main.c +++ b/usr/src/uts/common/io/arn/arn_main.c @@ -19,6 +19,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/sysmacros.h> #include <sys/param.h> #include <sys/types.h> #include <sys/signal.h> @@ -2645,12 +2646,8 @@ arn_setup_ht_cap(struct arn_softc *sc) /* set up supported mcs set */ (void) memset(&ht_info->rx_mcs_mask, 0, sizeof (ht_info->rx_mcs_mask)); - tx_streams = - !(sc->sc_ah->ah_caps.tx_chainmask & - (sc->sc_ah->ah_caps.tx_chainmask - 1)) ? 1 : 2; - rx_streams = - !(sc->sc_ah->ah_caps.rx_chainmask & - (sc->sc_ah->ah_caps.rx_chainmask - 1)) ? 1 : 2; + tx_streams = ISP2(sc->sc_ah->ah_caps.tx_chainmask) ? 1 : 2; + rx_streams = ISP2(sc->sc_ah->ah_caps.rx_chainmask) ? 1 : 2; ht_info->rx_mcs_mask[0] = 0xff; if (rx_streams >= 2) diff --git a/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c b/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c index 0a25fdac4b..e8a4b13138 100644 --- a/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c +++ b/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c @@ -25,6 +25,7 @@ * Copyright (c) 2013 by Delphix. All rights reserved. */ +#include <sys/sysmacros.h> #include <sys/conf.h> #include <sys/file.h> #include <sys/ddi.h> @@ -1836,7 +1837,7 @@ sbd_create_register_lu(sbd_create_and_reg_lu_t *slu, int struct_sz, sl->sl_flags |= SL_WRITE_PROTECTED; } if (slu->slu_blksize_valid) { - if ((slu->slu_blksize & (slu->slu_blksize - 1)) || + if (!ISP2(slu->slu_blksize) || (slu->slu_blksize > (32 * 1024)) || (slu->slu_blksize == 0)) { *err_ret = SBD_RET_INVALID_BLKSIZE; diff --git a/usr/src/uts/common/io/comstar/port/fct/discovery.c b/usr/src/uts/common/io/comstar/port/fct/discovery.c index 71fc1ed564..8d6a539acc 100644 --- a/usr/src/uts/common/io/comstar/port/fct/discovery.c +++ b/usr/src/uts/common/io/comstar/port/fct/discovery.c @@ -22,6 +22,7 @@ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. */ +#include <sys/sysmacros.h> #include <sys/conf.h> #include <sys/file.h> #include <sys/ddi.h> @@ -219,7 +220,7 @@ fct_li_to_txt(fct_link_info_t *li, char *topology, char *speed) (void) strcpy(topology, topologies[li->port_topology]); } - if ((s == 0) || ((s & 0xf00) != 0) || ((s & (s - 1)) != 0)) { + if ((s == 0) || ((s & 0xf00) != 0) || !ISP2(s)) { speed[0] = '?'; } else if (s == PORT_SPEED_10G) { speed[0] = '1'; diff --git a/usr/src/uts/common/io/drm/drmP.h b/usr/src/uts/common/io/drm/drmP.h index 5c617380f0..77bc2f7a8e 100644 --- a/usr/src/uts/common/io/drm/drmP.h +++ b/usr/src/uts/common/io/drm/drmP.h @@ -41,6 +41,7 @@ #ifndef _DRMP_H #define _DRMP_H +#include <sys/sysmacros.h> #include <sys/types.h> #include <sys/conf.h> #include <sys/modctl.h> @@ -326,9 +327,6 @@ typedef uint_t irqreturn_t; #define __OS_HAS_AGP 1 -#define __offsetof(type, field) ((size_t)(&((type *)0)->field)) -#define offsetof(type, field) __offsetof(type, field) - typedef struct drm_pci_id_list { int vendor; diff --git a/usr/src/uts/common/io/ib/adapters/hermon/hermon_cfg.c b/usr/src/uts/common/io/ib/adapters/hermon/hermon_cfg.c index 0a2c125dc7..3f7df30be7 100644 --- a/usr/src/uts/common/io/ib/adapters/hermon/hermon_cfg.c +++ b/usr/src/uts/common/io/ib/adapters/hermon/hermon_cfg.c @@ -31,6 +31,7 @@ * down the list of Hermon configuration information. */ +#include <sys/sysmacros.h> #include <sys/types.h> #include <sys/conf.h> #include <sys/ddi.h> @@ -437,7 +438,7 @@ hermon_cfg_wqe_sizes(hermon_state_t *state, hermon_cfg_profile_t *cp) */ max_size = (HERMON_QP_WQE_MLX_QP1_HDRS + (max_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } max_size = (1 << log2); diff --git a/usr/src/uts/common/io/ib/adapters/hermon/hermon_qp.c b/usr/src/uts/common/io/ib/adapters/hermon/hermon_qp.c index 6a09d45a30..510de4a9ac 100644 --- a/usr/src/uts/common/io/ib/adapters/hermon/hermon_qp.c +++ b/usr/src/uts/common/io/ib/adapters/hermon/hermon_qp.c @@ -404,13 +404,12 @@ hermon_qp_alloc(hermon_state_t *state, hermon_qp_info_t *qpinfo, */ log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes); /* if the total is a power of two, reduce it */ - if (((attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes) & - (attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes - 1)) == 0) { + if (ISP2(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes)) { log_qp_sq_size = log_qp_sq_size - 1; } log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq); - if ((attr_p->qp_sizes.cs_rq & (attr_p->qp_sizes.cs_rq - 1)) == 0) { + if (ISP2(attr_p->qp_sizes.cs_rq)) { log_qp_rq_size = log_qp_rq_size - 1; } @@ -921,11 +920,11 @@ hermon_special_qp_alloc(hermon_state_t *state, hermon_qp_info_t *qpinfo, attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq, HERMON_QP_MIN_SIZE); log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq); - if ((attr_p->qp_sizes.cs_sq & (attr_p->qp_sizes.cs_sq - 1)) == 0) { + if (ISP2(attr_p->qp_sizes.cs_sq)) { log_qp_sq_size = log_qp_sq_size - 1; } log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq); - if ((attr_p->qp_sizes.cs_rq & (attr_p->qp_sizes.cs_rq - 1)) == 0) { + if (ISP2(attr_p->qp_sizes.cs_rq)) { log_qp_rq_size = log_qp_rq_size - 1; } @@ -1521,13 +1520,12 @@ for_each_qp: */ log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes); /* if the total is a power of two, reduce it */ - if (((attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes) & - (attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes - 1)) == 0) { + if (ISP2(attr_p->qp_sizes.cs_sq + qp->qp_sq_hdrmwqes)) { log_qp_sq_size = log_qp_sq_size - 1; } log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq); - if ((attr_p->qp_sizes.cs_rq & (attr_p->qp_sizes.cs_rq - 1)) == 0) { + if (ISP2(attr_p->qp_sizes.cs_rq)) { log_qp_rq_size = log_qp_rq_size - 1; } @@ -2831,7 +2829,7 @@ hermon_qp_sgl_to_logwqesz(hermon_state_t *state, uint_t num_sgl, */ max_size = (HERMON_QP_WQE_MLX_SND_HDRS + (num_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } @@ -2851,7 +2849,7 @@ hermon_qp_sgl_to_logwqesz(hermon_state_t *state, uint_t num_sgl, */ max_size = (HERMON_QP_WQE_MLX_SND_HDRS + (num_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } @@ -2868,7 +2866,7 @@ hermon_qp_sgl_to_logwqesz(hermon_state_t *state, uint_t num_sgl, */ max_size = (HERMON_QP_WQE_MLX_RCV_HDRS + (num_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } @@ -2888,7 +2886,7 @@ hermon_qp_sgl_to_logwqesz(hermon_state_t *state, uint_t num_sgl, */ max_size = (HERMON_QP_WQE_MLX_QP0_HDRS + (num_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } @@ -2910,7 +2908,7 @@ hermon_qp_sgl_to_logwqesz(hermon_state_t *state, uint_t num_sgl, */ max_size = (HERMON_QP_WQE_MLX_QP1_HDRS + (num_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } diff --git a/usr/src/uts/common/io/ib/adapters/hermon/hermon_qpmod.c b/usr/src/uts/common/io/ib/adapters/hermon/hermon_qpmod.c index ec7d0701dc..77c2aa4f4a 100644 --- a/usr/src/uts/common/io/ib/adapters/hermon/hermon_qpmod.c +++ b/usr/src/uts/common/io/ib/adapters/hermon/hermon_qpmod.c @@ -33,6 +33,7 @@ * and Error. */ +#include <sys/sysmacros.h> #include <sys/types.h> #include <sys/conf.h> #include <sys/ddi.h> @@ -3375,7 +3376,7 @@ hermon_qp_validate_resp_rsrc(hermon_state_t *state, ibt_qp_rc_attr_t *rc, if (rdma_ra_in == 0) { rdma_ra_in = 1; } - if ((rdma_ra_in & (rdma_ra_in - 1)) == 0) { + if (ISP2(rdma_ra_in)) { *rra_max = highbit(rdma_ra_in) - 1; } else { *rra_max = highbit(rdma_ra_in); @@ -3411,7 +3412,7 @@ hermon_qp_validate_init_depth(hermon_state_t *state, ibt_qp_rc_attr_t *rc, if (rdma_ra_out == 0) { rdma_ra_out = 1; } - if ((rdma_ra_out & (rdma_ra_out - 1)) == 0) { + if (ISP2(rdma_ra_out)) { *sra_max = highbit(rdma_ra_out) - 1; } else { *sra_max = highbit(rdma_ra_out); diff --git a/usr/src/uts/common/io/ib/adapters/hermon/hermon_rsrc.c b/usr/src/uts/common/io/ib/adapters/hermon/hermon_rsrc.c index 9d2a78c10d..6de426041a 100644 --- a/usr/src/uts/common/io/ib/adapters/hermon/hermon_rsrc.c +++ b/usr/src/uts/common/io/ib/adapters/hermon/hermon_rsrc.c @@ -32,6 +32,7 @@ * by Hermon hardware or which live in Hermon's direct attached DDR memory. */ +#include <sys/sysmacros.h> #include <sys/types.h> #include <sys/conf.h> #include <sys/ddi.h> @@ -2666,7 +2667,7 @@ hermon_rsrc_mcg_entry_get_size(hermon_state_t *state, uint_t *mcg_size_shift) */ num_qp_per_mcg = state->hs_cfg_profile->cp_num_qp_per_mcg + 8; log2 = highbit(num_qp_per_mcg); - if ((num_qp_per_mcg & (num_qp_per_mcg - 1)) == 0) { + if (ISP2(num_qp_per_mcg)) { log2 = log2 - 1; } state->hs_cfg_profile->cp_num_qp_per_mcg = (1 << log2) - 8; diff --git a/usr/src/uts/common/io/ib/adapters/hermon/hermon_srq.c b/usr/src/uts/common/io/ib/adapters/hermon/hermon_srq.c index 9c80492b5a..637b7836ca 100644 --- a/usr/src/uts/common/io/ib/adapters/hermon/hermon_srq.c +++ b/usr/src/uts/common/io/ib/adapters/hermon/hermon_srq.c @@ -31,6 +31,7 @@ * modifying and posting shared receive queues. */ +#include <sys/sysmacros.h> #include <sys/types.h> #include <sys/conf.h> #include <sys/ddi.h> @@ -174,7 +175,7 @@ hermon_srq_alloc(hermon_state_t *state, hermon_srq_info_t *srqinfo, */ srq_wr_sz = max(sizes->srq_wr_sz + 1, HERMON_SRQ_MIN_SIZE); log_srq_size = highbit(srq_wr_sz); - if ((srq_wr_sz & (srq_wr_sz - 1)) == 0) { + if (ISP2(srq_wr_sz)) { log_srq_size = log_srq_size - 1; } @@ -623,7 +624,7 @@ hermon_srq_modify(hermon_state_t *state, hermon_srqhdl_t srq, uint_t size, */ size = max(size, HERMON_SRQ_MIN_SIZE); log_srq_size = highbit(size); - if ((size & (size - 1)) == 0) { + if (ISP2(size)) { log_srq_size = log_srq_size - 1; } @@ -974,7 +975,7 @@ hermon_srq_sgl_to_logwqesz(hermon_state_t *state, uint_t num_sgl, */ max_size = (HERMON_QP_WQE_MLX_SRQ_HDRS + (num_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } diff --git a/usr/src/uts/common/io/ib/adapters/tavor/tavor_cfg.c b/usr/src/uts/common/io/ib/adapters/tavor/tavor_cfg.c index 35735ebc8b..319e396b88 100644 --- a/usr/src/uts/common/io/ib/adapters/tavor/tavor_cfg.c +++ b/usr/src/uts/common/io/ib/adapters/tavor/tavor_cfg.c @@ -32,6 +32,7 @@ * down the list of Tavor configuration information. */ +#include <sys/sysmacros.h> #include <sys/types.h> #include <sys/conf.h> #include <sys/ddi.h> @@ -657,7 +658,7 @@ tavor_cfg_wqe_sizes(tavor_cfg_profile_t *cp) */ max_size = (TAVOR_QP_WQE_MLX_QP1_HDRS + (max_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } max_size = (1 << log2); diff --git a/usr/src/uts/common/io/ib/adapters/tavor/tavor_qp.c b/usr/src/uts/common/io/ib/adapters/tavor/tavor_qp.c index 7b9152d642..7c43fb8aaa 100644 --- a/usr/src/uts/common/io/ib/adapters/tavor/tavor_qp.c +++ b/usr/src/uts/common/io/ib/adapters/tavor/tavor_qp.c @@ -317,11 +317,11 @@ tavor_qp_alloc(tavor_state_t *state, tavor_qp_info_t *qpinfo, attr_p->qp_sizes.cs_sq = max(attr_p->qp_sizes.cs_sq, TAVOR_QP_MIN_SIZE); attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq, TAVOR_QP_MIN_SIZE); log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq); - if ((attr_p->qp_sizes.cs_sq & (attr_p->qp_sizes.cs_sq - 1)) == 0) { + if (ISP2(attr_p->qp_sizes.cs_sq)) { log_qp_sq_size = log_qp_sq_size - 1; } log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq); - if ((attr_p->qp_sizes.cs_rq & (attr_p->qp_sizes.cs_rq - 1)) == 0) { + if (ISP2(attr_p->qp_sizes.cs_rq)) { log_qp_rq_size = log_qp_rq_size - 1; } @@ -803,11 +803,11 @@ tavor_special_qp_alloc(tavor_state_t *state, tavor_qp_info_t *qpinfo, attr_p->qp_sizes.cs_sq = max(attr_p->qp_sizes.cs_sq, TAVOR_QP_MIN_SIZE); attr_p->qp_sizes.cs_rq = max(attr_p->qp_sizes.cs_rq, TAVOR_QP_MIN_SIZE); log_qp_sq_size = highbit(attr_p->qp_sizes.cs_sq); - if ((attr_p->qp_sizes.cs_sq & (attr_p->qp_sizes.cs_sq - 1)) == 0) { + if (ISP2(attr_p->qp_sizes.cs_sq)) { log_qp_sq_size = log_qp_sq_size - 1; } log_qp_rq_size = highbit(attr_p->qp_sizes.cs_rq); - if ((attr_p->qp_sizes.cs_rq & (attr_p->qp_sizes.cs_rq - 1)) == 0) { + if (ISP2(attr_p->qp_sizes.cs_rq)) { log_qp_rq_size = log_qp_rq_size - 1; } @@ -1991,7 +1991,7 @@ tavor_qp_sgl_to_logwqesz(tavor_state_t *state, uint_t num_sgl, */ max_size = (TAVOR_QP_WQE_MLX_SND_HDRS + (num_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } @@ -2008,7 +2008,7 @@ tavor_qp_sgl_to_logwqesz(tavor_state_t *state, uint_t num_sgl, */ max_size = (TAVOR_QP_WQE_MLX_RCV_HDRS + (num_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } @@ -2028,7 +2028,7 @@ tavor_qp_sgl_to_logwqesz(tavor_state_t *state, uint_t num_sgl, */ max_size = (TAVOR_QP_WQE_MLX_QP0_HDRS + (num_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } @@ -2050,7 +2050,7 @@ tavor_qp_sgl_to_logwqesz(tavor_state_t *state, uint_t num_sgl, */ max_size = (TAVOR_QP_WQE_MLX_QP1_HDRS + (num_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } diff --git a/usr/src/uts/common/io/ib/adapters/tavor/tavor_qpmod.c b/usr/src/uts/common/io/ib/adapters/tavor/tavor_qpmod.c index b16b00d980..3553f70d01 100644 --- a/usr/src/uts/common/io/ib/adapters/tavor/tavor_qpmod.c +++ b/usr/src/uts/common/io/ib/adapters/tavor/tavor_qpmod.c @@ -33,6 +33,7 @@ * and from Reset, Init, RTR, RTS, SQD, SQErr, and Error. */ +#include <sys/sysmacros.h> #include <sys/types.h> #include <sys/conf.h> #include <sys/ddi.h> @@ -3438,7 +3439,7 @@ tavor_qp_validate_resp_rsrc(tavor_state_t *state, ibt_qp_rc_attr_t *rc, if (rdma_ra_in == 0) { rdma_ra_in = 1; } - if ((rdma_ra_in & (rdma_ra_in - 1)) == 0) { + if (ISP2(rdma_ra_in)) { *rra_max = highbit(rdma_ra_in) - 1; } else { *rra_max = highbit(rdma_ra_in); @@ -3474,7 +3475,7 @@ tavor_qp_validate_init_depth(tavor_state_t *state, ibt_qp_rc_attr_t *rc, if (rdma_ra_out == 0) { rdma_ra_out = 1; } - if ((rdma_ra_out & (rdma_ra_out - 1)) == 0) { + if (ISP2(rdma_ra_out)) { *sra_max = highbit(rdma_ra_out) - 1; } else { *sra_max = highbit(rdma_ra_out); diff --git a/usr/src/uts/common/io/ib/adapters/tavor/tavor_rsrc.c b/usr/src/uts/common/io/ib/adapters/tavor/tavor_rsrc.c index 1cd3d323a4..a79340442d 100644 --- a/usr/src/uts/common/io/ib/adapters/tavor/tavor_rsrc.c +++ b/usr/src/uts/common/io/ib/adapters/tavor/tavor_rsrc.c @@ -33,6 +33,7 @@ * by Tavor hardware or which live in Tavor's direct attached DDR memory. */ +#include <sys/sysmacros.h> #include <sys/types.h> #include <sys/conf.h> #include <sys/ddi.h> @@ -2885,7 +2886,7 @@ tavor_rsrc_mcg_entry_get_size(tavor_state_t *state, uint_t *mcg_size_shift) */ num_qp_per_mcg = state->ts_cfg_profile->cp_num_qp_per_mcg + 8; log2 = highbit(num_qp_per_mcg); - if ((num_qp_per_mcg & (num_qp_per_mcg - 1)) == 0) { + if (ISP2(num_qp_per_mcg)) { log2 = log2 - 1; } state->ts_cfg_profile->cp_num_qp_per_mcg = (1 << log2) - 8; diff --git a/usr/src/uts/common/io/ib/adapters/tavor/tavor_srq.c b/usr/src/uts/common/io/ib/adapters/tavor/tavor_srq.c index 499fc75ee9..3f1e40d0ee 100644 --- a/usr/src/uts/common/io/ib/adapters/tavor/tavor_srq.c +++ b/usr/src/uts/common/io/ib/adapters/tavor/tavor_srq.c @@ -32,6 +32,7 @@ * modifying and posting shared receive queues. */ +#include <sys/sysmacros.h> #include <sys/types.h> #include <sys/conf.h> #include <sys/ddi.h> @@ -172,7 +173,7 @@ tavor_srq_alloc(tavor_state_t *state, tavor_srq_info_t *srqinfo, */ sizes->srq_wr_sz = max(sizes->srq_wr_sz, TAVOR_SRQ_MIN_SIZE); log_srq_size = highbit(sizes->srq_wr_sz); - if ((sizes->srq_wr_sz & (sizes->srq_wr_sz - 1)) == 0) { + if (ISP2(sizes->srq_wr_sz)) { log_srq_size = log_srq_size - 1; } @@ -686,7 +687,7 @@ tavor_srq_modify(tavor_state_t *state, tavor_srqhdl_t srq, uint_t size, */ size = max(size, TAVOR_SRQ_MIN_SIZE); log_srq_size = highbit(size); - if ((size & (size - 1)) == 0) { + if (ISP2(size)) { log_srq_size = log_srq_size - 1; } @@ -1099,7 +1100,7 @@ tavor_srq_sgl_to_logwqesz(tavor_state_t *state, uint_t num_sgl, */ max_size = (TAVOR_QP_WQE_MLX_RCV_HDRS + (num_sgl << 4)); log2 = highbit(max_size); - if ((max_size & (max_size - 1)) == 0) { + if (ISP2(max_size)) { log2 = log2 - 1; } diff --git a/usr/src/uts/common/io/ib/clients/rds/rdssubr.c b/usr/src/uts/common/io/ib/clients/rds/rdssubr.c index f9bbcd092f..a88d42a4a5 100644 --- a/usr/src/uts/common/io/ib/clients/rds/rdssubr.c +++ b/usr/src/uts/common/io/ib/clients/rds/rdssubr.c @@ -23,6 +23,7 @@ * Use is subject to license terms. */ +#include <sys/sysmacros.h> #include <sys/ib/clients/rds/rds.h> #include <sys/ib/clients/rds/rds_kstat.h> @@ -149,7 +150,7 @@ rds_hash_init() { int i; - if (rds_bind_fanout_size & (rds_bind_fanout_size - 1)) { + if (!ISP2(rds_bind_fanout_size)) { /* Not a power of two. Round up to nearest power of two */ for (i = 0; i < UINT_32_BITS; i++) { if (rds_bind_fanout_size < (1 << i)) diff --git a/usr/src/uts/common/io/myri10ge/drv/myri10ge.c b/usr/src/uts/common/io/myri10ge/drv/myri10ge.c index f0af9b76f5..8c416ad2da 100644 --- a/usr/src/uts/common/io/myri10ge/drv/myri10ge.c +++ b/usr/src/uts/common/io/myri10ge/drv/myri10ge.c @@ -2138,7 +2138,7 @@ myri10ge_start_locked(struct myri10ge_priv *mgp) * buffer/pkt, and the mtu will prevent overruns */ big_pow2 = myri10ge_mtu + MXGEFW_PAD; - while ((big_pow2 & (big_pow2 - 1)) != 0) + while (!ISP2(big_pow2)) big_pow2++; /* now give firmware buffers sizes, and MTU */ @@ -5437,7 +5437,7 @@ myri10ge_probe_slices(struct myri10ge_priv *mgp) */ while (mgp->num_slices > 1) { /* make sure it is a power of two */ - while (mgp->num_slices & (mgp->num_slices - 1)) + while (!ISP2(mgp->num_slices)) mgp->num_slices--; if (mgp->num_slices == 1) return (0); diff --git a/usr/src/uts/common/io/ntxn/unm_gem.c b/usr/src/uts/common/io/ntxn/unm_gem.c index 74bc0958ec..c08f99d5ab 100644 --- a/usr/src/uts/common/io/ntxn/unm_gem.c +++ b/usr/src/uts/common/io/ntxn/unm_gem.c @@ -725,8 +725,7 @@ unm_check_options(unm_adapter *adapter) tx_desc = ddi_prop_get_int(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, txringsize_propname, MAX_CMD_DESCRIPTORS_HOST); - if (tx_desc >= 256 && tx_desc <= MAX_CMD_DESCRIPTORS && - !(tx_desc & (tx_desc - 1))) { + if (tx_desc >= 256 && tx_desc <= MAX_CMD_DESCRIPTORS && ISP2(tx_desc)) { adapter->MaxTxDescCount = tx_desc; } else { cmn_err(CE_WARN, "%s%d: TxRingSize defaulting to %d, since " @@ -739,8 +738,7 @@ unm_check_options(unm_adapter *adapter) rx_desc = ddi_prop_get_int(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, rxringsize_propname, maxrx); if (rx_desc >= NX_MIN_DRIVER_RDS_SIZE && - rx_desc <= NX_MAX_SUPPORTED_RDS_SIZE && - !(rx_desc & (rx_desc - 1))) { + rx_desc <= NX_MAX_SUPPORTED_RDS_SIZE && ISP2(rx_desc)) { adapter->MaxRxDescCount = rx_desc; } else { cmn_err(CE_WARN, "%s%d: RxRingSize defaulting to %d, since " @@ -753,8 +751,7 @@ unm_check_options(unm_adapter *adapter) rx_jdesc = ddi_prop_get_int(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, jumborxringsize_propname, MAX_JUMBO_RCV_DESCRIPTORS); if (rx_jdesc >= NX_MIN_DRIVER_RDS_SIZE && - rx_jdesc <= NX_MAX_SUPPORTED_JUMBO_RDS_SIZE && - !(rx_jdesc & (rx_jdesc - 1))) { + rx_jdesc <= NX_MAX_SUPPORTED_JUMBO_RDS_SIZE && ISP2(rx_jdesc)) { adapter->MaxJumboRxDescCount = rx_jdesc; } else { cmn_err(CE_WARN, "%s%d: JumboRingSize defaulting to %d, since " diff --git a/usr/src/uts/common/krtld/kobj.c b/usr/src/uts/common/krtld/kobj.c index d5bcd94c7b..90303d496b 100644 --- a/usr/src/uts/common/krtld/kobj.c +++ b/usr/src/uts/common/krtld/kobj.c @@ -3787,7 +3787,7 @@ kobj_comp_setup(struct _buf *file, struct compinfo *cip) hdr = kobj_comphdr(file); if (hdr->ch_magic != CH_MAGIC_ZLIB || hdr->ch_version != CH_VERSION || hdr->ch_algorithm != CH_ALG_ZLIB || hdr->ch_fsize == 0 || - (hdr->ch_blksize & (hdr->ch_blksize - 1)) != 0) { + !ISP2(hdr->ch_blksize)) { kobj_free(file->_dbuf, cip->fsize); return (-1); } diff --git a/usr/src/uts/common/os/group.c b/usr/src/uts/common/os/group.c index e46e7f600c..7b6fd4ce14 100644 --- a/usr/src/uts/common/os/group.c +++ b/usr/src/uts/common/os/group.c @@ -23,6 +23,7 @@ * Use is subject to license terms. */ +#include <sys/sysmacros.h> #include <sys/systm.h> #include <sys/param.h> #include <sys/debug.h> @@ -131,8 +132,7 @@ group_remove(group_t *g, void *e, int gflag) g->grp_size--; if ((gflag & GRP_RESIZE) && - g->grp_size > GRP_SET_SIZE_DEFAULT && - ((g->grp_size - 1) & g->grp_size) == 0) + g->grp_size > GRP_SET_SIZE_DEFAULT && ISP2(g->grp_size)) group_shrink_set(g); return (0); diff --git a/usr/src/uts/common/os/kmem.c b/usr/src/uts/common/os/kmem.c index ab278ded82..af94c2d16f 100644 --- a/usr/src/uts/common/os/kmem.c +++ b/usr/src/uts/common/os/kmem.c @@ -3766,7 +3766,7 @@ kmem_cache_create( if (align < KMEM_ALIGN) cflags |= KMC_NOTOUCH; - if ((align & (align - 1)) != 0 || align > vmp->vm_quantum) + if (!ISP2(align) || align > vmp->vm_quantum) panic("kmem_cache_create: bad alignment %lu", align); mutex_enter(&kmem_flags_lock); diff --git a/usr/src/uts/common/os/vmem.c b/usr/src/uts/common/os/vmem.c index 9f950c012f..a554f8c3f3 100644 --- a/usr/src/uts/common/os/vmem.c +++ b/usr/src/uts/common/os/vmem.c @@ -920,7 +920,7 @@ vmem_canalloc(vmem_t *vmp, size_t size) int flist = 0; ASSERT(MUTEX_HELD(&vmp->vm_lock)); - if ((size & (size - 1)) == 0) + if (ISP2(size)) flist = lowbit(P2ALIGN(vmp->vm_freemap, size)); else if ((hb = highbit(size)) < VMEM_FREELISTS) flist = lowbit(P2ALIGN(vmp->vm_freemap, 1UL << hb)); @@ -959,8 +959,7 @@ vmem_xalloc(vmem_t *vmp, size_t size, size_t align_arg, size_t phase, (void *)vmp, size, align_arg, phase, nocross, minaddr, maxaddr, vmflag); - if (phase >= align || (align & (align - 1)) != 0 || - (nocross & (nocross - 1)) != 0) + if (phase >= align || !ISP2(align) || !ISP2(nocross)) panic("vmem_xalloc(%p, %lu, %lu, %lu, %lu, %p, %p, %x): " "parameters inconsistent or invalid", (void *)vmp, size, align_arg, phase, nocross, @@ -994,7 +993,7 @@ do_alloc: * * (4) We're doing a best-fit or first-fit allocation. */ - if ((size & (size - 1)) == 0) { + if (ISP2(size)) { flist = lowbit(P2ALIGN(vmp->vm_freemap, size)); } else { hb = highbit(size); @@ -1290,7 +1289,7 @@ vmem_alloc(vmem_t *vmp, size_t size, int vmflag) mutex_enter(&vmp->vm_lock); if (vmp->vm_nsegfree >= VMEM_MINFREE || vmem_populate(vmp, vmflag)) { - if ((size & (size - 1)) == 0) + if (ISP2(size)) flist = lowbit(P2ALIGN(vmp->vm_freemap, size)); else if ((hb = highbit(size)) < VMEM_FREELISTS) flist = lowbit(P2ALIGN(vmp->vm_freemap, 1UL << hb)); diff --git a/usr/src/uts/common/vm/seg_kmem.c b/usr/src/uts/common/vm/seg_kmem.c index dd0d6f5087..205aac9ded 100644 --- a/usr/src/uts/common/vm/seg_kmem.c +++ b/usr/src/uts/common/vm/seg_kmem.c @@ -1288,10 +1288,10 @@ segkmem_alloc_lp(vmem_t *vmp, size_t *sizep, size_t align, int vmflag) * backoff at trying large pages and reaping */ if (lpthrt > segkmem_lpthrottle_start && - (lpthrt & (lpthrt - 1))) { + !ISP2(lpthrt)) { lpcb->allocs_throttled++; lpthrt--; - if ((lpthrt & (lpthrt - 1)) == 0) + if (ISP2(lpthrt)) kmem_reap(); return (segkmem_alloc(vmp, size, vmflag)); } @@ -1475,15 +1475,13 @@ segkmem_lpsetup() } /* set heap_lp quantum if necessary */ - if (segkmem_heaplp_quantum == 0 || - (segkmem_heaplp_quantum & (segkmem_heaplp_quantum - 1)) || + if (segkmem_heaplp_quantum == 0 || !ISP2(segkmem_heaplp_quantum) || P2PHASE(segkmem_heaplp_quantum, segkmem_lpsize)) { segkmem_heaplp_quantum = segkmem_lpsize; } /* set kmem_lp quantum if necessary */ - if (segkmem_kmemlp_quantum == 0 || - (segkmem_kmemlp_quantum & (segkmem_kmemlp_quantum - 1)) || + if (segkmem_kmemlp_quantum == 0 || !ISP2(segkmem_kmemlp_quantum) || segkmem_kmemlp_quantum > segkmem_heaplp_quantum) { segkmem_kmemlp_quantum = segkmem_heaplp_quantum; } diff --git a/usr/src/uts/common/vm/seg_map.c b/usr/src/uts/common/vm/seg_map.c index 2cc53f90ff..a57d202a6a 100644 --- a/usr/src/uts/common/vm/seg_map.c +++ b/usr/src/uts/common/vm/seg_map.c @@ -337,7 +337,7 @@ segmap_create(struct seg *seg, void *argsp) "%d, using %d", nfreelist, max_ncpus); nfreelist = max_ncpus; } - if (nfreelist & (nfreelist - 1)) { + if (!ISP2(nfreelist)) { /* round up nfreelist to the next power of two. */ nfreelist = 1 << (highbit(nfreelist)); } diff --git a/usr/src/uts/common/vm/vpm.c b/usr/src/uts/common/vm/vpm.c index a95ceeebfd..db5fdeda85 100644 --- a/usr/src/uts/common/vm/vpm.c +++ b/usr/src/uts/common/vm/vpm.c @@ -205,7 +205,7 @@ vpm_init() /* * Round it up to the next power of 2 */ - if (vpm_nfreelist & (vpm_nfreelist - 1)) { + if (!ISP2(vpm_nfreelist)) { vpm_nfreelist = 1 << (highbit(vpm_nfreelist)); } vpmd_freemsk = vpm_nfreelist - 1; diff --git a/usr/src/uts/i86pc/io/acpi/drmach_acpi/drmach_acpi.c b/usr/src/uts/i86pc/io/acpi/drmach_acpi/drmach_acpi.c index 29d44de2d2..4323bf7769 100644 --- a/usr/src/uts/i86pc/io/acpi/drmach_acpi/drmach_acpi.c +++ b/usr/src/uts/i86pc/io/acpi/drmach_acpi/drmach_acpi.c @@ -895,7 +895,7 @@ drmach_init(void) "(%d) physical processors on one board.", MAX_CMP_UNITS_PER_BOARD); return (ENXIO); - } else if (MAX_CORES_PER_CMP & (MAX_CORES_PER_CMP - 1)) { + } else if (!ISP2(MAX_CORES_PER_CMP)) { cmn_err(CE_WARN, "!drmach_init: number of logical CPUs (%d) in " "physical processor is not power of 2.", MAX_CORES_PER_CMP); diff --git a/usr/src/uts/i86pc/io/pci/pci_tools.c b/usr/src/uts/i86pc/io/pci/pci_tools.c index 4cdfbf7591..58c5d70509 100644 --- a/usr/src/uts/i86pc/io/pci/pci_tools.c +++ b/usr/src/uts/i86pc/io/pci/pci_tools.c @@ -22,6 +22,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. */ +#include <sys/sysmacros.h> #include <sys/types.h> #include <sys/mkdev.h> #include <sys/stat.h> @@ -588,7 +589,7 @@ pcitool_cfg_access(pcitool_reg_t *prg, boolean_t write_flag, pci_cfgacc_req_t req; uint32_t max_offset; - if ((size <= 0) || (size > 8) || ((size & (size - 1)) != 0)) { + if ((size <= 0) || (size > 8) || !ISP2(size)) { prg->status = PCITOOL_INVALID_SIZE; return (ENOTSUP); } diff --git a/usr/src/uts/i86pc/io/rootnex.c b/usr/src/uts/i86pc/io/rootnex.c index 10b7fcb84b..a36c47b8b9 100644 --- a/usr/src/uts/i86pc/io/rootnex.c +++ b/usr/src/uts/i86pc/io/rootnex.c @@ -1811,7 +1811,7 @@ rootnex_coredma_allochdl(dev_info_t *dip, dev_info_t *rdip, * granularity may or may not be a power of two. If it isn't, we can't * use a simple mask. */ - if (attr->dma_attr_granular & (attr->dma_attr_granular - 1)) { + if (!ISP2(attr->dma_attr_granular)) { dma->dp_granularity_power_2 = B_FALSE; } else { dma->dp_granularity_power_2 = B_TRUE; @@ -3869,7 +3869,7 @@ rootnex_setup_cookie(ddi_dma_obj_t *dmar_object, rootnex_dma_t *dma, #endif /* __amd64 */ /* figure out if the copybuf size is a power of 2 */ - if (dma->dp_copybuf_size & (dma->dp_copybuf_size - 1)) { + if (!ISP2(dma->dp_copybuf_size)) { copybuf_sz_power_2 = B_FALSE; } else { copybuf_sz_power_2 = B_TRUE; diff --git a/usr/src/uts/i86pc/os/ddi_impl.c b/usr/src/uts/i86pc/os/ddi_impl.c index f743336383..fa65b87441 100644 --- a/usr/src/uts/i86pc/os/ddi_impl.c +++ b/usr/src/uts/i86pc/os/ddi_impl.c @@ -1536,7 +1536,7 @@ i_ddi_check_cache_attr(uint_t flags) * the attributes leads to a failure. */ uint_t cache_attr = IOMEM_CACHE_ATTR(flags); - if ((cache_attr != 0) && ((cache_attr & (cache_attr - 1)) != 0)) + if ((cache_attr != 0) && !ISP2(cache_attr)) return (B_FALSE); /* All cache attributes are supported on X86/X64 */ @@ -1627,9 +1627,8 @@ i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attr, } if (attr->dma_attr_minxfer == 0 || attr->dma_attr_align == 0 || - (attr->dma_attr_align & (attr->dma_attr_align - 1)) || - (attr->dma_attr_minxfer & (attr->dma_attr_minxfer - 1))) { - return (DDI_FAILURE); + !ISP2(attr->dma_attr_align) || !ISP2(attr->dma_attr_minxfer)) { + return (DDI_FAILURE); } /* diff --git a/usr/src/uts/intel/io/drm/i915_gem_tiling.c b/usr/src/uts/intel/io/drm/i915_gem_tiling.c index 987d56710c..8681fb6312 100644 --- a/usr/src/uts/intel/io/drm/i915_gem_tiling.c +++ b/usr/src/uts/intel/io/drm/i915_gem_tiling.c @@ -33,6 +33,7 @@ * Use is subject to license terms. */ +#include <sys/sysmacros.h> #include "drmP.h" #include "drm.h" #include "i915_drm.h" @@ -246,7 +247,7 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode) if (stride < tile_width) return 0; - if (stride & (stride - 1)) + if (!ISP2(stride)) return 0; /* We don't handle the aperture area covered by the fence being bigger diff --git a/usr/src/uts/sun4/io/px/px_debug.c b/usr/src/uts/sun4/io/px/px_debug.c index 7c2166c499..6d94288615 100644 --- a/usr/src/uts/sun4/io/px/px_debug.c +++ b/usr/src/uts/sun4/io/px/px_debug.c @@ -23,11 +23,10 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * PCI nexus driver general debug support */ +#include <sys/sysmacros.h> #include <sys/async.h> #include <sys/sunddi.h> /* dev_info_t */ #include <sys/ddi_impldefs.h> @@ -256,7 +255,7 @@ px_dbg_attach(dev_info_t *dip, ddi_softint_handle_t *dbg_hdl) int size = px_dbg_msg_size; /* Check if px_dbg_msg_size is ^2 */ - size = (size & (size - 1)) ? ((size | ~size) + 1) : size; + size = !ISP2(size) ? ((size | ~size) + 1) : size; px_dbg_msg_size = size; px_dbg_qmask = size - 1; px_dbg_msgq = kmem_zalloc(sizeof (px_dbg_msg_t) * size, diff --git a/usr/src/uts/sun4/os/ddi_impl.c b/usr/src/uts/sun4/os/ddi_impl.c index 2c64ae3556..60edae7383 100644 --- a/usr/src/uts/sun4/os/ddi_impl.c +++ b/usr/src/uts/sun4/os/ddi_impl.c @@ -1001,7 +1001,7 @@ i_ddi_check_cache_attr(uint_t flags) * the attributes leads to a failure. */ uint_t cache_attr = IOMEM_CACHE_ATTR(flags); - if ((cache_attr != 0) && ((cache_attr & (cache_attr - 1)) != 0)) + if ((cache_attr != 0) && !ISP2(cache_attr)) return (B_FALSE); /* @@ -1143,14 +1143,14 @@ i_ddi_iomin(dev_info_t *a, int i, int stream) /* * Make sure that the initial value is sane */ - if (i & (i - 1)) + if (!ISP2(i)) return (0); if (i == 0) i = (stream) ? 4 : 1; r = ddi_ctlops(a, a, DDI_CTLOPS_IOMIN, (void *)(uintptr_t)stream, (void *)&i); - if (r != DDI_SUCCESS || (i & (i - 1))) + if (r != DDI_SUCCESS || !ISP2(i)) return (0); return (i); } @@ -1177,8 +1177,7 @@ i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attr, } if (attr->dma_attr_minxfer == 0 || attr->dma_attr_align == 0 || - (attr->dma_attr_align & (attr->dma_attr_align - 1)) || - (attr->dma_attr_minxfer & (attr->dma_attr_minxfer - 1))) { + !ISP2(attr->dma_attr_align) || !ISP2(attr->dma_attr_minxfer)) { return (DDI_FAILURE); } diff --git a/usr/src/uts/sun4v/io/ds_pri.c b/usr/src/uts/sun4v/io/ds_pri.c index 5912bbfcda..3ca831a8cc 100644 --- a/usr/src/uts/sun4v/io/ds_pri.c +++ b/usr/src/uts/sun4v/io/ds_pri.c @@ -910,7 +910,7 @@ ds_get_hv_pri(ds_pri_state_t *sp) * contig_mem_alloc requires size to be a power of 2. * Increase size to next power of 2 if necessary. */ - if ((pri_size & (pri_size - 1)) != 0) + if (!ISP2(pri_size)) buf_size = 1 << highbit(pri_size); DS_PRI_DBG("ds_get_hv_pri: buf_size = 0x%lx\n", buf_size); diff --git a/usr/src/uts/sun4v/os/fillsysinfo.c b/usr/src/uts/sun4v/os/fillsysinfo.c index c243639e02..8e7a4f3b7b 100644 --- a/usr/src/uts/sun4v/os/fillsysinfo.c +++ b/usr/src/uts/sun4v/os/fillsysinfo.c @@ -465,7 +465,7 @@ cpu_setup_common(char **cpu_module_isa_set) ASSERT(ra_limit != 0); - kpm_size_shift = (ra_limit & (ra_limit - 1)) != 0 ? + kpm_size_shift = !ISP2(ra_limit) ? highbit(ra_limit) : highbit(ra_limit) - 1; /* @@ -850,7 +850,7 @@ get_single_q_size(md_t *mdp, mde_cookie_t cpu_node_cookie, entries = MIN(entries, max_entries); /* If not a power of 2, truncate to a power of 2. */ - if ((entries & (entries - 1)) != 0) { + if (!ISP2(entries)) { entries = 1 << (highbit(entries) - 1); } diff --git a/usr/src/uts/sun4v/os/intrq.c b/usr/src/uts/sun4v/os/intrq.c index 62920925be..329956b7dc 100644 --- a/usr/src/uts/sun4v/os/intrq.c +++ b/usr/src/uts/sun4v/os/intrq.c @@ -23,6 +23,7 @@ * Use is subject to license terms. */ +#include <sys/sysmacros.h> #include <sys/machsystm.h> #include <sys/cpu.h> #include <sys/intreg.h> @@ -98,7 +99,7 @@ cpu_intrq_setup(struct cpu *cpu) * contig_mem_alloc() requires size to be a power of 2. * Increase size to a power of 2 if necessary. */ - if ((size & (size - 1)) != 0) { + if (!ISP2(size)) { size = 1 << highbit(size); } @@ -208,7 +209,7 @@ cpu_intrq_cleanup(struct cpu *cpu) * contig_mem_alloc() requires size to be a power of 2. * Increase size to a power of 2 if necessary. */ - if ((cpu_list_size & (cpu_list_size - 1)) != 0) { + if (!ISP2(cpu_list_size)) { cpu_list_size = 1 << highbit(cpu_list_size); } |