Skip to content

Commit d1163e1

Browse files
committed
doc: add maintaining-libuv guide
This commit adds a document to describe the steps needed for updating the libuv dependency.
1 parent 30388fc commit d1163e1

File tree

2 files changed

+231
-0
lines changed

2 files changed

+231
-0
lines changed

deps/uv/src/unix/hurd.c

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/* Copyright libuv project contributors. All rights reserved.
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"), to
5+
* deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
* sell copies of the Software, and to permit persons to whom the Software is
8+
* furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
* IN THE SOFTWARE.
20+
*/
21+
22+
#define _GNU_SOURCE 1
23+
24+
#include "uv.h"
25+
#include "internal.h"
26+
27+
#include <hurd.h>
28+
#include <hurd/process.h>
29+
#include <mach/task_info.h>
30+
#include <mach/vm_statistics.h>
31+
#include <mach/vm_param.h>
32+
33+
#include <inttypes.h>
34+
#include <stddef.h>
35+
#include <unistd.h>
36+
#include <string.h>
37+
#include <limits.h>
38+
39+
int uv_exepath(char* buffer, size_t* size) {
40+
kern_return_t err;
41+
/* XXX in current Hurd, strings are char arrays of 1024 elements */
42+
string_t exepath;
43+
ssize_t copied;
44+
45+
if (buffer == NULL || size == NULL || *size == 0)
46+
return UV_EINVAL;
47+
48+
if (*size - 1 > 0) {
49+
/* XXX limited length of buffer in current Hurd, this API will probably
50+
* evolve in the future */
51+
err = proc_get_exe(getproc(), getpid(), exepath);
52+
53+
if (err)
54+
return UV__ERR(err);
55+
}
56+
57+
copied = uv__strscpy(buffer, exepath, *size);
58+
59+
/* do not return error on UV_E2BIG failure */
60+
*size = copied < 0 ? strlen(buffer) : (size_t) copied;
61+
62+
return 0;
63+
}
64+
65+
int uv_resident_set_memory(size_t* rss) {
66+
kern_return_t err;
67+
struct task_basic_info bi;
68+
mach_msg_type_number_t count;
69+
70+
count = TASK_BASIC_INFO_COUNT;
71+
err = task_info(mach_task_self(), TASK_BASIC_INFO,
72+
(task_info_t) &bi, &count);
73+
74+
if (err)
75+
return UV__ERR(err);
76+
77+
*rss = bi.resident_size;
78+
79+
return 0;
80+
}
81+
82+
uint64_t uv_get_free_memory(void) {
83+
kern_return_t err;
84+
struct vm_statistics vmstats;
85+
86+
err = vm_statistics(mach_task_self(), &vmstats);
87+
88+
if (err)
89+
return 0;
90+
91+
return vmstats.free_count * vm_page_size;
92+
}
93+
94+
95+
uint64_t uv_get_total_memory(void) {
96+
kern_return_t err;
97+
host_basic_info_data_t hbi;
98+
mach_msg_type_number_t cnt;
99+
100+
cnt = HOST_BASIC_INFO_COUNT;
101+
err = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t) &hbi, &cnt);
102+
103+
if (err)
104+
return 0;
105+
106+
return hbi.memory_size;
107+
}
108+
109+
110+
int uv_uptime(double* uptime) {
111+
char buf[128];
112+
113+
/* Try /proc/uptime first */
114+
if (0 == uv__slurp("/proc/uptime", buf, sizeof(buf)))
115+
if (1 == sscanf(buf, "%lf", uptime))
116+
return 0;
117+
118+
/* Reimplement here code from procfs to calculate uptime if not mounted? */
119+
120+
return UV__ERR(EIO);
121+
}
122+
123+
void uv_loadavg(double avg[3]) {
124+
char buf[128]; /* Large enough to hold all of /proc/loadavg. */
125+
126+
if (0 == uv__slurp("/proc/loadavg", buf, sizeof(buf)))
127+
if (3 == sscanf(buf, "%lf %lf %lf", &avg[0], &avg[1], &avg[2]))
128+
return;
129+
130+
/* Reimplement here code from procfs to calculate loadavg if not mounted? */
131+
}
132+
133+
134+
int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
135+
kern_return_t err;
136+
host_basic_info_data_t hbi;
137+
mach_msg_type_number_t cnt;
138+
139+
/* Get count of cpus */
140+
cnt = HOST_BASIC_INFO_COUNT;
141+
err = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t) &hbi, &cnt);
142+
143+
if (err) {
144+
err = UV__ERR(err);
145+
goto abort;
146+
}
147+
148+
/* XXX not implemented on the Hurd */
149+
*cpu_infos = uv__calloc(hbi.avail_cpus, sizeof(**cpu_infos));
150+
if (*cpu_infos == NULL) {
151+
err = UV_ENOMEM;
152+
goto abort;
153+
}
154+
155+
*count = hbi.avail_cpus;
156+
157+
return 0;
158+
159+
abort:
160+
*cpu_infos = NULL;
161+
*count = 0;
162+
return err;
163+
}
164+
165+
uint64_t uv_get_constrained_memory(void) {
166+
return 0; /* Memory constraints are unknown. */
167+
}

doc/contributing/maintaining-libuv.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Maintaining libuv
2+
3+
This documents contains instructions about how to update libuv.
4+
5+
## Updating libuv
6+
7+
[Download](https://github.com/libuv/libuv/releases) the distribution and
8+
signature file of the version to update to.
9+
10+
### Verify the download
11+
12+
Import the public key of the person who signed the distribution:
13+
14+
```console
15+
git tag -l | grep pubkey
16+
pubkey-bnoordhuis
17+
pubkey-cjihrig
18+
pubkey-cjihrig-kb
19+
pubkey-indutny
20+
pubkey-iwuzhere
21+
pubkey-richardlau
22+
pubkey-saghul
23+
pubkey-santigimeno
24+
pubkey-vtjnash
25+
pubkey2022-vtjnash
26+
27+
git show <pubkey-signer> | gpg --import
28+
gpg --verify /path/to/download/libuv-v1.44.1-dist.tar.gz.sign libuv-v1.44.1-dist.tar.gz
29+
gpg: Signature made Wed 09 Mar 2022 06:58:08 PM CET
30+
gpg: using RSA key CFBB9CA9A5BEAFD70E2B3C5A79A67C55A3679C8B
31+
gpg: Good signature from "Jameson Nash <[email protected]>" [unknown]
32+
gpg: WARNING: This key is not certified with a trusted signature!
33+
gpg: There is no indication that the signature belongs to the owner.
34+
Primary key fingerprint: CFBB 9CA9 A5BE AFD7 0E2B 3C5A 79A6 7C55 A367 9C8B
35+
```
36+
37+
### Extract the distribution into deps/uv
38+
39+
```bash
40+
cd /path/to/nodejs/node
41+
tar xvzf /path/to/download/libuv-v1.44.1-dist.tar.gz -C deps/uv --strip 1
42+
```
43+
44+
### Check that Node.js still builds and tests
45+
46+
```console
47+
./configure && make -j8 test
48+
./node -p process.versions.uv
49+
1.44.1
50+
```
51+
52+
### Committing zlib
53+
54+
```console
55+
git add --all deps/uv
56+
```
57+
58+
Commit the changes with a message like:
59+
60+
```text
61+
deps: update libuv to upstream version
62+
63+
Updated as described in doc/contributing/maintaining-libuv.md.
64+
```

0 commit comments

Comments
 (0)