stubs_go115.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // +build !go1.20
  2. /*
  3. * Copyright 2021 ByteDance Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package ast
  18. import (
  19. `unsafe`
  20. `unicode/utf8`
  21. `github.com/bytedance/sonic/internal/rt`
  22. )
  23. //go:noescape
  24. //go:linkname memmove runtime.memmove
  25. //goland:noinspection GoUnusedParameter
  26. func memmove(to unsafe.Pointer, from unsafe.Pointer, n uintptr)
  27. //go:linkname unsafe_NewArray reflect.unsafe_NewArray
  28. //goland:noinspection GoUnusedParameter
  29. func unsafe_NewArray(typ *rt.GoType, n int) unsafe.Pointer
  30. //go:linkname growslice runtime.growslice
  31. //goland:noinspection GoUnusedParameter
  32. func growslice(et *rt.GoType, old rt.GoSlice, cap int) rt.GoSlice
  33. //go:nosplit
  34. func mem2ptr(s []byte) unsafe.Pointer {
  35. return (*rt.GoSlice)(unsafe.Pointer(&s)).Ptr
  36. }
  37. var (
  38. //go:linkname safeSet encoding/json.safeSet
  39. safeSet [utf8.RuneSelf]bool
  40. //go:linkname hex encoding/json.hex
  41. hex string
  42. )
  43. //go:linkname unquoteBytes encoding/json.unquoteBytes
  44. func unquoteBytes(s []byte) (t []byte, ok bool)