Skip to content

Commit

Permalink
baremetal: implement calloc libc function
Browse files Browse the repository at this point in the history
This simply calls runtime.alloc, because the memory will be
zero-initialized anyway.
  • Loading branch information
aykevl committed Sep 27, 2021
1 parent 21a2d5a commit 213cdf6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/runtime/baremetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ func libc_free(ptr unsafe.Pointer) {
free(ptr)
}

//export calloc
func libc_calloc(nmemb, size uintptr) unsafe.Pointer {
// Note: we could be even more correct here and check that nmemb * size
// doesn't overflow. However the current implementation should normally work
// fine.
return alloc(nmemb * size)
}

//export abort
func libc_abort() {
abort()
Expand Down

0 comments on commit 213cdf6

Please sign in to comment.