Files
llgo/internal/runtime/c/c.go

55 lines
1.3 KiB
Go
Raw Normal View History

2024-04-28 07:08:33 +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-04-29 09:51:32 +08:00
package c
2024-04-28 07:08:33 +08:00
2024-04-29 17:58:10 +08:00
import "C"
2024-04-28 07:08:33 +08:00
import "unsafe"
const (
2024-04-29 09:51:32 +08:00
LLGoPackage = "decl"
2024-04-28 07:08:33 +08:00
)
2024-05-01 12:32:09 +08:00
type (
Char = int8
Int = C.int
Pointer = unsafe.Pointer
)
2024-04-30 08:23:55 +08:00
//go:linkname Str llgo.cstr
2024-05-01 12:32:09 +08:00
func Str(string) *Char
2024-04-29 09:51:32 +08:00
2024-04-29 13:59:06 +08:00
//go:linkname Alloca llgo.alloca
2024-05-01 12:32:09 +08:00
func Alloca(size uintptr) Pointer
2024-04-29 09:51:32 +08:00
2024-04-30 18:22:56 +08:00
//go:linkname AllocaCStr llgo.allocaCStr
2024-05-01 12:32:09 +08:00
func AllocaCStr(s string) *Char
2024-04-30 18:22:56 +08:00
2024-04-29 13:59:06 +08:00
//go:linkname Unreachable llgo.unreachable
2024-04-29 09:51:32 +08:00
func Unreachable()
2024-05-01 07:26:51 +08:00
//go:linkname Rand C.rand
2024-05-01 12:32:09 +08:00
func Rand() Int
2024-05-01 07:26:51 +08:00
2024-04-28 07:08:33 +08:00
//go:linkname Malloc C.malloc
2024-05-01 12:32:09 +08:00
func Malloc(size uintptr) Pointer
2024-04-28 07:08:33 +08:00
2024-04-29 09:51:32 +08:00
//go:linkname Memcpy C.memcpy
2024-05-01 12:32:09 +08:00
func Memcpy(dst, src Pointer, n uintptr) Pointer
2024-04-29 09:51:32 +08:00
//go:linkname Printf C.printf
2024-05-01 12:32:09 +08:00
func Printf(format *Char, __llgo_va_list ...any) Int