github.com/goplus/llgo@v0.8.3/internal/runtime/c/c.go (about)

     1  /*
     2   * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package c
    18  
    19  import "C"
    20  import "unsafe"
    21  
    22  const (
    23  	LLGoPackage = "decl"
    24  )
    25  
    26  type (
    27  	Char    = int8
    28  	Int     = C.int
    29  	Pointer = unsafe.Pointer
    30  	FilePtr = unsafe.Pointer
    31  )
    32  
    33  //go:linkname Stdin __stdinp
    34  var Stdin FilePtr
    35  
    36  //go:linkname Stdout __stdoutp
    37  var Stdout FilePtr
    38  
    39  //go:linkname Stderr __stderrp
    40  var Stderr FilePtr
    41  
    42  //go:linkname Str llgo.cstr
    43  func Str(string) *Char
    44  
    45  //go:linkname Advance llgo.advance
    46  func Advance(ptr Pointer, offset int) Pointer
    47  
    48  //go:linkname Alloca llgo.alloca
    49  func Alloca(size uintptr) Pointer
    50  
    51  //go:linkname AllocaCStr llgo.allocaCStr
    52  func AllocaCStr(s string) *Char
    53  
    54  //go:linkname Unreachable llgo.unreachable
    55  func Unreachable()
    56  
    57  //go:linkname Rand C.rand
    58  func Rand() Int
    59  
    60  //go:linkname Malloc C.malloc
    61  func Malloc(size uintptr) Pointer
    62  
    63  //go:linkname Memcpy C.memcpy
    64  func Memcpy(dst, src Pointer, n uintptr) Pointer
    65  
    66  //go:linkname Memset C.memset
    67  func Memset(s Pointer, c Int, n uintptr) Pointer
    68  
    69  //go:linkname Printf C.printf
    70  func Printf(format *Char, __llgo_va_list ...any) Int
    71  
    72  //go:linkname Fprintf C.fprintf
    73  func Fprintf(fp FilePtr, format *Char, __llgo_va_list ...any) Int