Files
llgo/c/bdwgc/bdwgc.go

104 lines
3.0 KiB
Go
Raw Normal View History

2024-06-08 23:06:55 +08:00
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2024-06-06 20:51:45 +08:00
package bdwgc
import (
_ "unsafe"
"github.com/goplus/llgo/c"
)
const (
LLGoPackage = "link: $(pkg-config --libs bdw-gc); -lgc"
2024-06-06 20:51:45 +08:00
)
// -----------------------------------------------------------------------------
//go:linkname Init C.GC_init
func Init()
//go:linkname Malloc C.GC_malloc
func Malloc(size uintptr) c.Pointer
//go:linkname Realloc C.GC_realloc
func Realloc(ptr c.Pointer, size uintptr) c.Pointer
//go:linkname Free C.GC_free
func Free(ptr c.Pointer)
// -----------------------------------------------------------------------------
//go:linkname RegisterFinalizer C.GC_register_finalizer
2024-06-08 22:30:06 +08:00
func RegisterFinalizer(
obj c.Pointer,
fn func(c.Pointer, c.Pointer), cd c.Pointer,
oldFn *func(c.Pointer, c.Pointer), oldCd *c.Pointer)
2024-06-06 20:51:45 +08:00
//go:linkname RegisterFinalizerNoOrder C.GC_register_finalizer_no_order
2024-06-08 22:30:06 +08:00
func RegisterFinalizerNoOrder(
obj c.Pointer,
fn func(c.Pointer, c.Pointer), cd c.Pointer,
oldFn *func(c.Pointer, c.Pointer), oldCd *c.Pointer)
2024-06-06 20:51:45 +08:00
//go:linkname RegisterFinalizerIgnoreSelf C.GC_register_finalizer_ignore_self
2024-06-08 22:30:06 +08:00
func RegisterFinalizerIgnoreSelf(
obj c.Pointer,
fn func(c.Pointer, c.Pointer), cd c.Pointer,
oldFn *func(c.Pointer, c.Pointer), oldCd *c.Pointer)
2024-06-06 20:51:45 +08:00
//go:linkname RegisterFinalizerUnreachable C.GC_register_finalizer_unreachable
2024-06-08 22:30:06 +08:00
func RegisterFinalizerUnreachable(
obj c.Pointer,
fn func(c.Pointer, c.Pointer), cd c.Pointer,
oldFn *func(c.Pointer, c.Pointer), oldCd *c.Pointer)
2024-06-06 20:51:45 +08:00
// -----------------------------------------------------------------------------
//go:linkname Enable C.GC_enable
func Enable()
//go:linkname Disable C.GC_disable
func Disable()
//go:linkname IsDisabled C.GC_is_disabled
2024-06-08 22:30:06 +08:00
func IsDisabled() c.Int
2024-06-06 20:51:45 +08:00
//go:linkname Gcollect C.GC_gcollect
func Gcollect()
//go:linkname GetMemoryUse C.GC_get_memory_use
func GetMemoryUse() uintptr
// -----------------------------------------------------------------------------
//go:linkname EnableIncremental C.GC_enable_incremental
func EnableIncremental()
//go:linkname IsIncrementalMode C.GC_is_incremental_mode
2024-06-08 22:30:06 +08:00
func IsIncrementalMode() c.Int
2024-06-06 20:51:45 +08:00
//go:linkname IncrementalProtectionNeeds C.GC_incremental_protection_needs
2024-06-08 22:30:06 +08:00
func IncrementalProtectionNeeds() c.Int
2024-06-06 20:51:45 +08:00
//go:linkname StartIncrementalCollection C.GC_start_incremental_collection
func StartIncrementalCollection()
//go:linkname CollectALittle C.GC_collect_a_little
func CollectALittle()
// -----------------------------------------------------------------------------