Skip to content

Commit e2b8983

Browse files
ngotxicilion
authored andcommitted
os, break: rename os.CPUInfo() to os.cpus() & rename os.CPUs() to os.cpuNumbers()
1 parent 74154a4 commit e2b8983

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

fibjs/include/ifs/os.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class os_base : public object_base {
3434
static result_t loadavg(v8::Local<v8::Array>& retVal);
3535
static result_t totalmem(int64_t& retVal);
3636
static result_t freemem(int64_t& retVal);
37-
static result_t CPUInfo(v8::Local<v8::Array>& retVal);
38-
static result_t CPUs(int32_t& retVal);
37+
static result_t cpus(v8::Local<v8::Array>& retVal);
38+
static result_t cpuNumbers(int32_t& retVal);
3939
static result_t tmpdir(exlib::string& retVal);
4040
static result_t networkInterfaces(v8::Local<v8::Object>& retVal);
4141
static result_t printerInfo(v8::Local<v8::Array>& retVal);
@@ -68,8 +68,8 @@ class os_base : public object_base {
6868
static void s_loadavg(const v8::FunctionCallbackInfo<v8::Value>& args);
6969
static void s_totalmem(const v8::FunctionCallbackInfo<v8::Value>& args);
7070
static void s_freemem(const v8::FunctionCallbackInfo<v8::Value>& args);
71-
static void s_CPUInfo(const v8::FunctionCallbackInfo<v8::Value>& args);
72-
static void s_CPUs(const v8::FunctionCallbackInfo<v8::Value>& args);
71+
static void s_cpus(const v8::FunctionCallbackInfo<v8::Value>& args);
72+
static void s_cpuNumbers(const v8::FunctionCallbackInfo<v8::Value>& args);
7373
static void s_tmpdir(const v8::FunctionCallbackInfo<v8::Value>& args);
7474
static void s_networkInterfaces(const v8::FunctionCallbackInfo<v8::Value>& args);
7575
static void s_printerInfo(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -97,8 +97,8 @@ inline ClassInfo& os_base::class_info()
9797
{ "loadavg", s_loadavg, true },
9898
{ "totalmem", s_totalmem, true },
9999
{ "freemem", s_freemem, true },
100-
{ "CPUInfo", s_CPUInfo, true },
101-
{ "CPUs", s_CPUs, true },
100+
{ "cpus", s_cpus, true },
101+
{ "cpuNumbers", s_cpuNumbers, true },
102102
{ "tmpdir", s_tmpdir, true },
103103
{ "networkInterfaces", s_networkInterfaces, true },
104104
{ "printerInfo", s_printerInfo, true },
@@ -252,28 +252,28 @@ inline void os_base::s_freemem(const v8::FunctionCallbackInfo<v8::Value>& args)
252252
METHOD_RETURN();
253253
}
254254

255-
inline void os_base::s_CPUInfo(const v8::FunctionCallbackInfo<v8::Value>& args)
255+
inline void os_base::s_cpus(const v8::FunctionCallbackInfo<v8::Value>& args)
256256
{
257257
v8::Local<v8::Array> vr;
258258

259259
METHOD_ENTER();
260260

261261
METHOD_OVER(0, 0);
262262

263-
hr = CPUInfo(vr);
263+
hr = cpus(vr);
264264

265265
METHOD_RETURN();
266266
}
267267

268-
inline void os_base::s_CPUs(const v8::FunctionCallbackInfo<v8::Value>& args)
268+
inline void os_base::s_cpuNumbers(const v8::FunctionCallbackInfo<v8::Value>& args)
269269
{
270270
int32_t vr;
271271

272272
METHOD_ENTER();
273273

274274
METHOD_OVER(0, 0);
275275

276-
hr = CPUs(vr);
276+
hr = cpuNumbers(vr);
277277

278278
METHOD_RETURN();
279279
}

fibjs/include/ifs/os.idl

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ module os
5252
/*! @brief 查询当前运行环境 cpu 个数和参数
5353
@return 返回包含 cpu 参数的数组,每一项对应一个 cpu
5454
*/
55-
static Array CPUInfo();
55+
static Array cpus();
5656

5757
/*! @brief 查询当前运行环境 cpu 个数
5858
@return 返回 cpu 个数
5959
*/
60-
static Integer CPUs();
60+
static Integer cpuNumbers();
6161

6262
/*! @brief 查询当前运行环境临时文件目录
6363
@return 返回临时文件目录

fibjs/src/base/fibjs.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void init(int32_t& argc, char* argv[])
3535

3636
int32_t cpus = 0;
3737

38-
os_base::CPUs(cpus);
38+
os_base::cpuNumbers(cpus);
3939
if (cpus < 2)
4040
cpus = 2;
4141

fibjs/src/os/os_freebsd.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ result_t os_base::freemem(int64_t& retVal)
107107
return 0;
108108
}
109109

110-
result_t os_base::CPUs(int32_t& retVal)
110+
result_t os_base::cpuNumbers(int32_t& retVal)
111111
{
112112
static int32_t cpus = 0;
113113

@@ -128,7 +128,7 @@ result_t os_base::CPUs(int32_t& retVal)
128128
return 0;
129129
}
130130

131-
result_t os_base::CPUInfo(v8::Local<v8::Array>& retVal)
131+
result_t os_base::cpus(v8::Local<v8::Array>& retVal)
132132
{
133133
Isolate* isolate = Isolate::current();
134134

@@ -258,8 +258,8 @@ result_t os_base::memoryUsage(v8::Local<v8::Object>& retVal)
258258
void* handle = dlopen("libkvm.so", RTLD_LAZY);
259259

260260
if (handle) {
261-
_kvm_open = (kvm_t * (*)(char*, const char*, char*, int32_t, const char*))dlsym(handle, "kvm_open");
262-
_kvm_getprocs = (struct kinfo_proc * (*)(kvm_t*, int32_t, int32_t, int32_t*))dlsym(handle, "kvm_getprocs");
261+
_kvm_open = (kvm_t * (*)(char*, const char*, char*, int32_t, const char*)) dlsym(handle, "kvm_open");
262+
_kvm_getprocs = (struct kinfo_proc * (*)(kvm_t*, int32_t, int32_t, int32_t*)) dlsym(handle, "kvm_getprocs");
263263
_kvm_close = (void (*)(kvm_t*))dlsym(handle, "kvm_close");
264264
}
265265
}

fibjs/src/os/os_linux.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ result_t os_base::freemem(int64_t& retVal)
9292
return 0;
9393
}
9494

95-
result_t os_base::CPUs(int32_t& retVal)
95+
result_t os_base::cpuNumbers(int32_t& retVal)
9696
{
9797
static int32_t cpus = 0;
9898

@@ -118,7 +118,7 @@ result_t os_base::CPUs(int32_t& retVal)
118118
return 0;
119119
}
120120

121-
result_t os_base::CPUInfo(v8::Local<v8::Array>& retVal)
121+
result_t os_base::cpus(v8::Local<v8::Array>& retVal)
122122
{
123123
Isolate* isolate = Isolate::current();
124124
retVal = v8::Array::New(isolate->m_isolate);

fibjs/src/os/os_osx.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ result_t os_base::freemem(int64_t& retVal)
8585
return 0;
8686
}
8787

88-
result_t os_base::CPUs(int32_t& retVal)
88+
result_t os_base::cpuNumbers(int32_t& retVal)
8989
{
9090
static int32_t cpus = 0;
9191

@@ -110,7 +110,7 @@ result_t os_base::CPUs(int32_t& retVal)
110110
return 0;
111111
}
112112

113-
result_t os_base::CPUInfo(v8::Local<v8::Array>& retVal)
113+
result_t os_base::cpus(v8::Local<v8::Array>& retVal)
114114
{
115115
Isolate* isolate = Isolate::current();
116116
retVal = v8::Array::New(isolate->m_isolate);

fibjs/src/os/os_win.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ result_t os_base::freemem(int64_t& retVal)
244244
return 0;
245245
}
246246

247-
result_t os_base::CPUs(int32_t& retVal)
247+
result_t os_base::cpuNumbers(int32_t& retVal)
248248
{
249249
static int32_t cpus = 0;
250250

@@ -263,7 +263,7 @@ result_t os_base::CPUs(int32_t& retVal)
263263
return 0;
264264
}
265265

266-
result_t os_base::CPUInfo(v8::Local<v8::Array>& retVal)
266+
result_t os_base::cpus(v8::Local<v8::Array>& retVal)
267267
{
268268
Isolate* isolate = Isolate::current();
269269
retVal = v8::Array::New(isolate->m_isolate);

test/os_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ describe('os', () => {
1111
console.dir({
1212
type: os.type,
1313
version: os.version,
14-
CPUs: os.CPUs(),
14+
CPUs: os.cpuNumbers(),
1515
uptime: os.uptime(),
1616
loadavg: os.loadavg(),
1717
totalmem: os.totalmem(),
1818
freemem: os.freemem()
1919
});
20-
console.dir(os.CPUInfo());
20+
console.dir(os.cpus());
2121
console.dir(os.networkInterfaces());
2222
});
2323

0 commit comments

Comments
 (0)