Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,29 @@
#include <node.h>
#include <uv.h>
#include <v8.h>
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::String;
using v8::Value;
void GetThreadName(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
uv_thread_t thread;
char thread_name[16];
#ifdef _WIN32
/* uv_thread_self isn't defined for the main thread on Windows. */
thread = GetCurrentThread();
#else
thread = uv_thread_self();
#endif
uv_thread_getname(&thread, thread_name, sizeof(thread_name));
args.GetReturnValue().Set(
String::NewFromUtf8(isolate, thread_name).ToLocalChecked());
}
void init(v8::Local<v8::Object> exports) {
NODE_SET_METHOD(exports, "getThreadName", GetThreadName);
}
NODE_MODULE_CONTEXT_AWARE(NODE_GYP_MODULE_NAME, init)

View File

@ -0,0 +1,9 @@
{
'targets': [
{
'target_name': 'binding',
'sources': [ 'binding.cc' ],
'includes': ['../common.gypi'],
}
]
}

View File

@ -0,0 +1,36 @@
'use strict';
const common = require('../../common');
if (common.isAIX || common.isIBMi) {
// see: https://github.com/libuv/libuv/pull/4599#issuecomment-2498376606
common.skip('AIX, IBM i do not support get/set thread name');
}
const assert = require('node:assert');
const { parentPort, Worker, isMainThread } = require('node:worker_threads');
const bindingPath = require.resolve(`./build/${common.buildType}/binding`);
const binding = require(bindingPath);
if (isMainThread) {
assert.strictEqual(binding.getThreadName(), 'MainThread');
const worker = new Worker(__filename);
worker.on('message', common.mustCall((data) => {
assert.strictEqual(data, 'WorkerThread');
}));
worker.on('error', common.mustNotCall());
worker.on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0);
}));
const namedWorker = new Worker(__filename, { name: 'NamedThread' });
namedWorker.on('message', common.mustCall((data) => {
assert.strictEqual(data, 'NamedThread');
}));
namedWorker.on('error', common.mustNotCall());
namedWorker.on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0);
}));
} else {
parentPort.postMessage(binding.getThreadName());
}