Changeset 344402c in rtems


Ignore:
Timestamp:
Aug 3, 2010, 10:02:30 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
7f77810
Parents:
5714bc5
Message:

2010-08-03 Joel Sherrill <joel.sherrilL@…>

  • shared/startup/sbrk.c: Make bsp's sbrk a weak reference so that the test of having sbrk() support in malloc can link.
Location:
c/src/lib/libbsp/powerpc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/ChangeLog

    r5714bc5 r344402c  
     12010-08-03      Joel Sherrill <joel.sherrilL@OARcorp.com>
     2
     3        * shared/startup/sbrk.c: Make bsp's sbrk a weak reference so that the
     4        test of having sbrk() support in malloc can link.
     5
    162010-07-07      Joel Sherrill <joel.sherrill@oarcorp.com>
    27
  • c/src/lib/libbsp/powerpc/shared/startup/sbrk.c

    r5714bc5 r344402c  
    88 * This software was created by
    99 *     Till Straumann <strauman@slac.stanford.edu>, 2002,
    10  *         Stanford Linear Accelerator Center, Stanford University.
     10 *        Stanford Linear Accelerator Center, Stanford University.
    1111 *
    1212 * Acknowledgement of sponsorship
     
    1414 * This software was produced by
    1515 *     the Stanford Linear Accelerator Center, Stanford University,
    16  *         under Contract DE-AC03-76SFO0515 with the Department of Energy.
     16 *        under Contract DE-AC03-76SFO0515 with the Department of Energy.
    1717 *
    1818 * Government disclaimer of liability
     
    101101    rval = remaining_start + remaining_size - LIMIT_32M;
    102102    *heap_size_p = LIMIT_32M - remaining_start;
    103         remaining_start = LIMIT_32M;
    104         remaining_size  = rval;
     103    remaining_start = LIMIT_32M;
     104    remaining_size  = rval;
    105105  }
    106106
    107107  if ( 0 != &BSP_sbrk_policy ) {
    108         switch ( BSP_sbrk_policy ) {
    109                 case (uint32_t)(-1):
    110                         *heap_size_p    += rval;
    111                         remaining_start  = heap_start + *heap_size_p;
    112                         remaining_size   = 0;
    113                         /* return a nonzero sbrk_amount because the libsupport code
    114                         * at some point divides by this number prior to trying an
    115                         * sbrk() which will fail.
    116                         */
    117                         rval = 1;
    118                 break;
     108    switch ( BSP_sbrk_policy ) {
     109      case (uint32_t)(-1):
     110        *heap_size_p    += rval;
     111        remaining_start  = heap_start + *heap_size_p;
     112        remaining_size   = 0;
     113        /* return a nonzero sbrk_amount because the libsupport code
     114        * at some point divides by this number prior to trying an
     115        * sbrk() which will fail.
     116        */
     117        rval = 1;
     118        break;
    119119
    120                 case 0:
    121                         remaining_size = 0;
    122                         /* see above for why we return 1 */
    123                         rval = 1;
    124                 break;
     120      case 0:
     121        remaining_size = 0;
     122        /* see above for why we return 1 */
     123        rval = 1;
     124        break;
    125125
    126                 default:
    127                         if ( rval > BSP_sbrk_policy )
    128                                 rval = BSP_sbrk_policy;
    129                 break;
    130         }
     126      default:
     127        if ( rval > BSP_sbrk_policy )
     128            rval = BSP_sbrk_policy;
     129        break;
     130    }
    131131  }
    132132
     
    134134}
    135135
    136 void * sbrk(ptrdiff_t incr)
     136/*
     137 * This is just so the sbrk test can force its magic. All normal applications
     138 * should just use the default implementation in this file.
     139 */
     140void *sbrk(ptrdiff_t incr) __attribute__ (( weak, alias("bsp_sbrk") ));
     141void *bsp_sbrk(ptrdiff_t incr)
    137142{
    138143  void *rval=(void*)-1;
     
    146151    errno = ENOMEM;
    147152  }
    148 #ifdef DEBUG
    149   printk("************* SBRK 0x%08x (ret 0x%08x) **********\n", incr, rval);
    150 #endif
     153  #ifdef DEBUG
     154    printk("************* SBRK 0x%08x (ret 0x%08x) **********\n", incr, rval);
     155  #endif
    151156  return rval;
    152157}
Note: See TracChangeset for help on using the changeset viewer.