Print this page
patch as-lock-macro-simplification


 836 static int
 837 segmap_checkprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot)
 838 {
 839         struct segmap_data *smd = (struct segmap_data *)seg->s_data;
 840 
 841         ASSERT(seg->s_as && RW_LOCK_HELD(&seg->s_as->a_lock));
 842 
 843         /*
 844          * Need not acquire the segment lock since
 845          * "smd_prot" is a read-only field.
 846          */
 847         return (((smd->smd_prot & prot) != prot) ? EACCES : 0);
 848 }
 849 
 850 static int
 851 segmap_getprot(struct seg *seg, caddr_t addr, size_t len, uint_t *protv)
 852 {
 853         struct segmap_data *smd = (struct segmap_data *)seg->s_data;
 854         size_t pgno = seg_page(seg, addr + len) - seg_page(seg, addr) + 1;
 855 
 856         ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
 857 
 858         if (pgno != 0) {
 859                 do {
 860                         protv[--pgno] = smd->smd_prot;
 861                 } while (pgno != 0);
 862         }
 863         return (0);
 864 }
 865 
 866 static u_offset_t
 867 segmap_getoffset(struct seg *seg, caddr_t addr)
 868 {
 869         struct segmap_data *smd = (struct segmap_data *)seg->s_data;
 870 
 871         ASSERT(seg->s_as && RW_READ_HELD(&seg->s_as->a_lock));
 872 
 873         return ((u_offset_t)smd->smd_sm->sm_off + (addr - seg->s_base));
 874 }
 875 
 876 /*ARGSUSED*/




 836 static int
 837 segmap_checkprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot)
 838 {
 839         struct segmap_data *smd = (struct segmap_data *)seg->s_data;
 840 
 841         ASSERT(seg->s_as && RW_LOCK_HELD(&seg->s_as->a_lock));
 842 
 843         /*
 844          * Need not acquire the segment lock since
 845          * "smd_prot" is a read-only field.
 846          */
 847         return (((smd->smd_prot & prot) != prot) ? EACCES : 0);
 848 }
 849 
 850 static int
 851 segmap_getprot(struct seg *seg, caddr_t addr, size_t len, uint_t *protv)
 852 {
 853         struct segmap_data *smd = (struct segmap_data *)seg->s_data;
 854         size_t pgno = seg_page(seg, addr + len) - seg_page(seg, addr) + 1;
 855 
 856         ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as));
 857 
 858         if (pgno != 0) {
 859                 do {
 860                         protv[--pgno] = smd->smd_prot;
 861                 } while (pgno != 0);
 862         }
 863         return (0);
 864 }
 865 
 866 static u_offset_t
 867 segmap_getoffset(struct seg *seg, caddr_t addr)
 868 {
 869         struct segmap_data *smd = (struct segmap_data *)seg->s_data;
 870 
 871         ASSERT(seg->s_as && RW_READ_HELD(&seg->s_as->a_lock));
 872 
 873         return ((u_offset_t)smd->smd_sm->sm_off + (addr - seg->s_base));
 874 }
 875 
 876 /*ARGSUSED*/