Source file src/runtime/cgo/cgo_linux_glibc.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build goexperiment.runtimecgopurego && !msan && !tsan && linux && !android
     6  
     7  package cgo
     8  
     9  import "unsafe"
    10  
    11  // cSigaction matches libc's struct sigaction on Linux (glibc and musl) across
    12  // 32-bit and 64-bit architectures supporting cgoSigaction.
    13  type cSigaction struct {
    14  	handler  uintptr
    15  	mask     [128 / unsafe.Sizeof(uintptr(0))]uintptr // sigset_t
    16  	flags    int32
    17  	restorer uintptr
    18  }
    19  
    20  //go:cgo_ldflag "-pthread"
    21  
    22  // Specify "libc.so.6" so internal linking without C host objects emits a
    23  // DT_NEEDED entry for glibc's dynamic loader; external linking ignores the
    24  // library field, !android excludes bionic, and musl treats any "libc.so.*"
    25  // SONAME as libc itself.
    26  //go:cgo_import_dynamic _ _ "libpthread.so.0"
    27  //go:cgo_import_dynamic _cgo_libc_mmap mmap "libc.so.6"
    28  //go:cgo_import_dynamic _cgo_libc_munmap munmap "libc.so.6"
    29  //go:cgo_import_dynamic _cgo_libc_sigaction sigaction "libc.so.6"
    30  //go:cgo_import_dynamic _cgo_libc_sigfillset sigfillset "libc.so.6"
    31  //go:cgo_import_dynamic _cgo_libc_errno_location __errno_location "libc.so.6"
    32  //go:cgo_import_dynamic _cgo_libc_setenv setenv "libc.so.6"
    33  //go:cgo_import_dynamic _cgo_libc_unsetenv unsetenv "libc.so.6"
    34  //go:cgo_import_dynamic _cgo_libc_clearenv clearenv "libc.so.6"
    35  //go:cgo_import_dynamic _cgo_libc_pthread_create pthread_create "libpthread.so.0"
    36  //go:cgo_import_dynamic _cgo_libc_pthread_attr_init pthread_attr_init "libpthread.so.0"
    37  //go:cgo_import_dynamic _cgo_libc_pthread_attr_setdetachstate pthread_attr_setdetachstate "libpthread.so.0"
    38  //go:cgo_import_dynamic _cgo_libc_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so.0"
    39  //go:cgo_import_dynamic _cgo_libc_pthread_attr_destroy pthread_attr_destroy "libpthread.so.0"
    40  //go:cgo_import_dynamic _cgo_libc_pthread_key_create pthread_key_create "libpthread.so.0"
    41  //go:cgo_import_dynamic _cgo_libc_pthread_setspecific pthread_setspecific "libpthread.so.0"
    42  //go:cgo_import_dynamic _cgo_libc_pthread_self pthread_self "libpthread.so.0"
    43  //go:cgo_import_dynamic _cgo_libc_pthread_getattr_np pthread_getattr_np "libpthread.so.0"
    44  //go:cgo_import_dynamic _cgo_libc_pthread_attr_getstack pthread_attr_getstack "libpthread.so.0"
    45  //go:cgo_import_dynamic _cgo_libc_pthread_sigmask pthread_sigmask "libpthread.so.0"
    46  //go:cgo_import_dynamic _cgo_libc_setegid setegid "libc.so.6"
    47  //go:cgo_import_dynamic _cgo_libc_seteuid seteuid "libc.so.6"
    48  //go:cgo_import_dynamic _cgo_libc_setgid setgid "libc.so.6"
    49  //go:cgo_import_dynamic _cgo_libc_setgroups setgroups "libc.so.6"
    50  //go:cgo_import_dynamic _cgo_libc_setregid setregid "libc.so.6"
    51  //go:cgo_import_dynamic _cgo_libc_setresgid setresgid "libc.so.6"
    52  //go:cgo_import_dynamic _cgo_libc_setresuid setresuid "libc.so.6"
    53  //go:cgo_import_dynamic _cgo_libc_setreuid setreuid "libc.so.6"
    54  //go:cgo_import_dynamic _cgo_libc_setuid setuid "libc.so.6"
    55  

View as plain text