$63 GRAYBYTE WORDPRESS FILE MANAGER $58

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/lib/golang/src/runtime/cgo/

HOME
Current File : /lib/golang/src/runtime/cgo//gcc_libinit_windows.c
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#ifdef __CYGWIN__
#error "don't use the cygwin compiler to build native Windows programs; use MinGW instead"
#endif

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#include <stdio.h>
#include <stdlib.h>

#include "libcgo.h"
#include "libcgo_windows.h"

// Ensure there's one symbol marked __declspec(dllexport).
// If there are no exported symbols, the unfortunate behavior of
// the binutils linker is to also strip the relocations table,
// resulting in non-PIE binary. The other option is the
// --export-all-symbols flag, but we don't need to export all symbols
// and this may overflow the export table (#40795).
// See https://sourceware.org/bugzilla/show_bug.cgi?id=19011
__declspec(dllexport) int _cgo_dummy_export;

static volatile LONG runtime_init_once_gate = 0;
static volatile LONG runtime_init_once_done = 0;

static CRITICAL_SECTION runtime_init_cs;

static HANDLE runtime_init_wait;
static int runtime_init_done;

uintptr_t x_cgo_pthread_key_created;
void (*x_crosscall2_ptr)(void (*fn)(void *), void *, int, size_t);

// Pre-initialize the runtime synchronization objects
void
_cgo_preinit_init() {
	 runtime_init_wait = CreateEvent(NULL, TRUE, FALSE, NULL);
	 if (runtime_init_wait == NULL) {
		fprintf(stderr, "runtime: failed to create runtime initialization wait event.\n");
		abort();
	 }

	 InitializeCriticalSection(&runtime_init_cs);
}

// Make sure that the preinit sequence has run.
void
_cgo_maybe_run_preinit() {
	 if (!InterlockedExchangeAdd(&runtime_init_once_done, 0)) {
			if (InterlockedIncrement(&runtime_init_once_gate) == 1) {
				 _cgo_preinit_init();
				 InterlockedIncrement(&runtime_init_once_done);
			} else {
				 // Decrement to avoid overflow.
				 InterlockedDecrement(&runtime_init_once_gate);
				 while(!InterlockedExchangeAdd(&runtime_init_once_done, 0)) {
						Sleep(0);
				 }
			}
	 }
}

void
x_cgo_sys_thread_create(unsigned long (__stdcall *func)(void*), void* arg) {
	_cgo_beginthread(func, arg);
}

int
_cgo_is_runtime_initialized() {
	 int status;

	 EnterCriticalSection(&runtime_init_cs);
	 status = runtime_init_done;
	 LeaveCriticalSection(&runtime_init_cs);
	 return status;
}

uintptr_t
_cgo_wait_runtime_init_done(void) {
	void (*pfn)(struct context_arg*);

	 _cgo_maybe_run_preinit();
	while (!_cgo_is_runtime_initialized()) {
			WaitForSingleObject(runtime_init_wait, INFINITE);
	}
	pfn = _cgo_get_context_function();
	if (pfn != nil) {
		struct context_arg arg;

		arg.Context = 0;
		(*pfn)(&arg);
		return arg.Context;
	}
	return 0;
}

// Should not be used since x_cgo_pthread_key_created will always be zero.
void x_cgo_bindm(void* dummy) {
	fprintf(stderr, "unexpected cgo_bindm on Windows\n");
	abort();
}

void
x_cgo_notify_runtime_init_done(void* dummy) {
	 _cgo_maybe_run_preinit();

	 EnterCriticalSection(&runtime_init_cs);
	runtime_init_done = 1;
	 LeaveCriticalSection(&runtime_init_cs);

	 if (!SetEvent(runtime_init_wait)) {
		fprintf(stderr, "runtime: failed to signal runtime initialization complete.\n");
		abort();
	}
}

// The context function, used when tracing back C calls into Go.
static void (*cgo_context_function)(struct context_arg*);

// Sets the context function to call to record the traceback context
// when calling a Go function from C code. Called from runtime.SetCgoTraceback.
void x_cgo_set_context_function(void (*context)(struct context_arg*)) {
	EnterCriticalSection(&runtime_init_cs);
	cgo_context_function = context;
	LeaveCriticalSection(&runtime_init_cs);
}

// Gets the context function.
void (*(_cgo_get_context_function(void)))(struct context_arg*) {
	void (*ret)(struct context_arg*);

	EnterCriticalSection(&runtime_init_cs);
	ret = cgo_context_function;
	LeaveCriticalSection(&runtime_init_cs);
	return ret;
}

void _cgo_beginthread(unsigned long (__stdcall *func)(void*), void* arg) {
	int tries;
	HANDLE thandle;

	for (tries = 0; tries < 20; tries++) {
		thandle = CreateThread(NULL, 0, func, arg, 0, NULL);
		if (thandle == 0 && GetLastError() == ERROR_NOT_ENOUGH_MEMORY) {
			// "Insufficient resources", try again in a bit.
			//
			// Note that the first Sleep(0) is a yield.
			Sleep(tries); // milliseconds
			continue;
		} else if (thandle == 0) {
			break;
		}
		CloseHandle(thandle);
		return; // Success!
	}

	fprintf(stderr, "runtime: failed to create new OS thread (%lu)\n", GetLastError());
	abort();
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
16 Dec 2025 9.34 PM
root / root
0755
abi_amd64.h
2.729 KB
4 Dec 2025 6.06 PM
root / root
0644
abi_arm64.h
1.495 KB
4 Dec 2025 6.06 PM
root / root
0644
abi_loong64.h
1.947 KB
4 Dec 2025 6.06 PM
root / root
0644
abi_ppc64x.h
6.552 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_386.s
1.156 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_amd64.s
1.352 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_arm.s
2.23 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_arm64.s
1.444 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_loong64.s
1.513 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_mips64x.s
2.465 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_mipsx.s
2.399 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_ppc64x.s
2.4 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_riscv64.s
2.307 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_s390x.s
1.749 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_wasm.s
0.264 KB
4 Dec 2025 6.06 PM
root / root
0644
callbacks.go
5.578 KB
4 Dec 2025 6.06 PM
root / root
0644
callbacks_aix.go
0.393 KB
4 Dec 2025 6.06 PM
root / root
0644
callbacks_traceback.go
0.464 KB
4 Dec 2025 6.06 PM
root / root
0644
cgo.go
1.161 KB
4 Dec 2025 6.06 PM
root / root
0644
dragonfly.go
0.474 KB
4 Dec 2025 6.06 PM
root / root
0644
freebsd.go
0.536 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_386.S
0.937 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_aix_ppc64.S
2.682 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_aix_ppc64.c
1.254 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_amd64.S
1.129 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_android.c
2.578 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_arm.S
0.829 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_arm64.S
1.747 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_context.c
0.455 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_darwin_amd64.c
1.347 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_darwin_arm64.c
3.729 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_dragonfly_amd64.c
1.266 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_fatalf.c
0.514 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_freebsd.c
1.566 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_freebsd_amd64.c
1.573 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_freebsd_sigaction.c
1.991 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_libinit.c
5.847 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_libinit_windows.c
4.396 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_linux.c
1.465 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_linux_amd64.c
2.354 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_linux_arm64.c
2.227 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_linux_ppc64x.S
1.951 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_linux_s390x.c
1.32 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_loong64.S
1.548 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_mips64x.S
1.788 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_mipsx.S
1.535 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_mmap.c
0.895 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_netbsd.c
1.764 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_openbsd.c
1.297 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_ppc64x.c
1.392 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_riscv64.S
1.579 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_s390x.S
1.394 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_setenv.c
0.476 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_sigaction.c
2.174 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_signal2_ios_arm64.c
0.496 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_signal_ios_arm64.c
5.978 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_signal_ios_nolldb.c
0.305 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_solaris_amd64.c
1.985 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_stack_darwin.c
0.603 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_stack_unix.c
1.455 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_stack_windows.c
0.239 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_traceback.c
1.524 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_util.c
1.85 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_windows_386.c
1.171 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_windows_amd64.c
1.067 KB
4 Dec 2025 6.06 PM
root / root
0644
gcc_windows_arm64.c
0.794 KB
4 Dec 2025 6.06 PM
root / root
0644
handle.go
3.87 KB
4 Dec 2025 6.06 PM
root / root
0644
iscgo.go
0.631 KB
4 Dec 2025 6.06 PM
root / root
0644
libcgo.h
3.521 KB
4 Dec 2025 6.06 PM
root / root
0644
libcgo_unix.h
0.668 KB
4 Dec 2025 6.06 PM
root / root
0644
libcgo_windows.h
0.271 KB
4 Dec 2025 6.06 PM
root / root
0644
linux.go
2.744 KB
4 Dec 2025 6.06 PM
root / root
0644
linux_syscall.c
1.88 KB
4 Dec 2025 6.06 PM
root / root
0644
mmap.go
1.027 KB
4 Dec 2025 6.06 PM
root / root
0644
netbsd.go
0.533 KB
4 Dec 2025 6.06 PM
root / root
0644
openbsd.go
0.553 KB
4 Dec 2025 6.06 PM
root / root
0644
setenv.go
0.583 KB
4 Dec 2025 6.06 PM
root / root
0644
sigaction.go
0.848 KB
4 Dec 2025 6.06 PM
root / root
0644
signal_ios_arm64.go
0.264 KB
4 Dec 2025 6.06 PM
root / root
0644
signal_ios_arm64.s
1.805 KB
4 Dec 2025 6.06 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF