...

Source file src/github.com/cloudwego/base64x/native_amd64.go

Documentation: github.com/cloudwego/base64x

     1  /*
     2   * Copyright 2024 CloudWeGo Authors
     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  //go:generate make
    18  package base64x
    19  
    20  import (
    21      `unsafe`
    22  
    23      `github.com/bytedance/sonic/loader`
    24  )
    25  
    26  //go:nosplit
    27  func b64encode(out *[]byte, src *[]byte, mode int) {
    28      __b64encode(noEscape(unsafe.Pointer(out)), noEscape(unsafe.Pointer(src)), mode)
    29  }
    30  
    31  //go:nosplit
    32  func b64decode(out *[]byte, src unsafe.Pointer, len int, mode int) (ret int) {
    33      return __b64decode(noEscape(unsafe.Pointer(out)), noEscape(unsafe.Pointer(src)), len, mode)
    34  }
    35  
    36  // asm2asm templates
    37  var (
    38      __b64encode func(out unsafe.Pointer, src unsafe.Pointer, mod int)
    39      __b64decode func(out unsafe.Pointer, src unsafe.Pointer, len int, mod int) (ret int)
    40  )
    41  
    42  // directly jump PCs
    43  var (
    44      _subr__b64encode uintptr
    45      _subr__b64decode uintptr
    46  )
    47  
    48  var stubs = []loader.GoC{
    49      {"_b64encode", &_subr__b64encode, &__b64encode},
    50      {"_b64decode", &_subr__b64decode, &__b64decode},
    51  }
    52  
    53  func init() {
    54      if hasAVX2() {
    55          archFlags = _MODE_AVX2
    56      }
    57      loader.WrapGoC(text__native_entry__, funcs, stubs, "base64x", "base64x/native.c")
    58  }
    59  

View as plain text