| 1 |
// Copyright 2023 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package runtime |
| 6 |
|
| 7 |
import "unsafe" |
| 8 |
|
| 9 |
func sbrk(n uintptr) unsafe.Pointer { |
| 10 |
bl := bloc |
| 11 |
n = memRound(n) |
| 12 |
if bl+n > blocMax { |
| 13 |
grow := (bl + n - blocMax) / physPageSize |
| 14 |
size := growMemory(int32(grow)) |
| 15 |
if size < 0 { |
| 16 |
return nil |
| 17 |
} |
| 18 |
resetMemoryDataView() |
| 19 |
blocMax = bl + n |
| 20 |
} |
| 21 |
bloc += n |
| 22 |
return unsafe.Pointer(bl) |
| 23 |
} |
| 24 |
|
| 25 |
// Implemented in src/runtime/sys_wasm.s |
| 26 |
func growMemory(pages int32) int32 |
| 27 |
func currentMemory() int32 |