Print this page
const-ify make segment ops structures
There is no reason to keep the segment ops structures writable.

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/vm/vm_as.c
          +++ new/usr/src/uts/common/vm/vm_as.c
↓ open down ↓ 465 lines elided ↑ open up ↑
 466  466  
 467  467                  /*
 468  468                   * If top of seg is below the requested address, then
 469  469                   * the insertion point is at the end of the linked list,
 470  470                   * and seg points to the tail of the list.  Otherwise,
 471  471                   * the insertion point is immediately before seg.
 472  472                   */
 473  473                  if (base + seg->s_size > addr) {
 474  474                          if (addr >= base || eaddr > base) {
 475  475  #ifdef __sparc
 476      -                                extern struct seg_ops segnf_ops;
      476 +                                extern const struct seg_ops segnf_ops;
 477  477  
 478  478                                  /*
 479  479                                   * no-fault segs must disappear if overlaid.
 480  480                                   * XXX need new segment type so
 481  481                                   * we don't have to check s_ops
 482  482                                   */
 483  483                                  if (seg->s_ops == &segnf_ops) {
 484  484                                          seg_unmap(seg);
 485  485                                          goto again;
 486  486                                  }
↓ open down ↓ 1511 lines elided ↑ open up ↑
1998 1998  }
1999 1999  
2000 2000  /*
2001 2001   * Return the next range within [base, base + len) that is backed
2002 2002   * with "real memory".  Skip holes and non-seg_vn segments.
2003 2003   * We're lazy and only return one segment at a time.
2004 2004   */
2005 2005  int
2006 2006  as_memory(struct as *as, caddr_t *basep, size_t *lenp)
2007 2007  {
2008      -        extern struct seg_ops segspt_shmops;    /* needs a header file */
     2008 +        extern const struct seg_ops segspt_shmops;      /* needs a header file */
2009 2009          struct seg *seg;
2010 2010          caddr_t addr, eaddr;
2011 2011          caddr_t segend;
2012 2012  
2013 2013          AS_LOCK_ENTER(as, &as->a_lock, RW_READER);
2014 2014  
2015 2015          addr = *basep;
2016 2016          eaddr = addr + *lenp;
2017 2017  
2018 2018          seg = as_findseg(as, addr, 0);
↓ open down ↓ 456 lines elided ↑ open up ↑
2475 2475          ulong_t segcnt = 1;
2476 2476          ulong_t cnt;
2477 2477          size_t ssize;
2478 2478          pgcnt_t npages = btop(size);
2479 2479          page_t **plist;
2480 2480          page_t **pl;
2481 2481          int error;
2482 2482          caddr_t eaddr;
2483 2483          faultcode_t fault_err = 0;
2484 2484          pgcnt_t pl_off;
2485      -        extern struct seg_ops segspt_shmops;
     2485 +        extern const struct seg_ops segspt_shmops;
2486 2486  
2487 2487          ASSERT(AS_LOCK_HELD(as, &as->a_lock));
2488 2488          ASSERT(seg != NULL);
2489 2489          ASSERT(addr >= seg->s_base && addr < seg->s_base + seg->s_size);
2490 2490          ASSERT(addr + size > seg->s_base + seg->s_size);
2491 2491          ASSERT(IS_P2ALIGNED(size, PAGESIZE));
2492 2492          ASSERT(IS_P2ALIGNED(addr, PAGESIZE));
2493 2493  
2494 2494          /*
2495 2495           * Count the number of segments covered by the range we are about to
↓ open down ↓ 1035 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX