Revision 0776590d

b/exec.c
234 234
        FILE *f;
235 235
        int n;
236 236

  
237
        last_brk = (unsigned long)sbrk(0);
237 238
        f = fopen("/proc/self/maps", "r");
238 239
        if (f) {
239 240
            do {
b/linux-user/mmap.c
157 157
static abi_ulong mmap_next_start = 0x40000000;
158 158
#endif
159 159

  
160
unsigned long last_brk;
161

  
160 162
/* find a free memory area of size 'size'. The search starts at
161 163
   'start'. If 'start' == 0, then a default start address is used.
162 164
   Return -1 if error.
......
167 169
{
168 170
    abi_ulong addr, addr1, addr_start;
169 171
    int prot;
172
    unsigned long new_brk;
173

  
174
    new_brk = (unsigned long)sbrk(0);
175
    if (last_brk && last_brk < new_brk && last_brk == (target_ulong)last_brk) {
176
        /* This is a hack to catch the host allocating memory with brk().
177
           If it uses mmap then we loose.
178
           FIXME: We really want to avoid the host allocating memory in
179
           the first place, and maybe leave some slack to avoid switching
180
           to mmap.  */
181
        page_set_flags(last_brk & TARGET_PAGE_MASK,
182
                       TARGET_PAGE_ALIGN(new_brk),
183
                       PAGE_RESERVED); 
184
    }
185
    last_brk = new_brk;
170 186

  
171 187
    size = HOST_PAGE_ALIGN(size);
172 188
    start = start & qemu_host_page_mask;
b/linux-user/qemu.h
232 232
                       abi_ulong new_size, unsigned long flags,
233 233
                       abi_ulong new_addr);
234 234
int target_msync(abi_ulong start, abi_ulong len, int flags);
235
extern unsigned long last_brk;
235 236

  
236 237
/* user access */
237 238

  

Also available in: Unified diff