Skip to content

Commit 83adae7

Browse files
authored
Merge pull request #767 from squeek502/libuv-1.51.0
Bump Libuv to 1.51.0
2 parents 891ba33 + 5aed641 commit 83adae7

File tree

10 files changed

+307
-40
lines changed

10 files changed

+307
-40
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10)
33
project (luv C ASM)
44

55
set(LUV_VERSION_MAJOR 1)
6-
set(LUV_VERSION_MINOR 50)
6+
set(LUV_VERSION_MINOR 51)
77
set(LUV_VERSION_PATCH 0)
88
set(LUV_VERSION ${LUV_VERSION_MAJOR}.${LUV_VERSION_MINOR}.${LUV_VERSION_PATCH})
99

docs.lua

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ local constants = {
321321
{ 'TTY_MODE_NORMAL', 'normal' },
322322
{ 'TTY_MODE_RAW', 'raw' },
323323
{ 'TTY_MODE_IO', 'io' },
324+
{ 'TTY_MODE_RAW_VT', 'raw_vt' },
325+
},
326+
fs_utime = {
327+
{ 'FS_UTIME_NOW', 'now' },
328+
{ 'FS_UTIME_OMIT', 'omit' },
324329
},
325330
}
326331

@@ -617,6 +622,10 @@ local doc = {
617622
title = 'TTY Modes',
618623
constants = constants.tty_modes,
619624
},
625+
{
626+
title = 'FS Modification Times',
627+
constants = constants.fs_utime,
628+
},
620629
},
621630
},
622631
{
@@ -3595,35 +3604,65 @@ local doc = {
35953604
},
35963605
{
35973606
name = 'fs_utime',
3598-
desc = 'Equivalent to `utime(2)`.',
3607+
desc = [[
3608+
Equivalent to `utime(2)`.
3609+
3610+
See [Constants][] for supported FS Modification Time constants.
3611+
3612+
Passing `"now"` or `uv.constants.FS_UTIME_NOW` as the atime or mtime sets the timestamp to the
3613+
current time.
3614+
3615+
Passing `nil`, `"omit"`, or `uv.constants.FS_UTIME_OMIT` as the atime or mtime leaves the timestamp
3616+
untouched.
3617+
]],
35993618
params = {
36003619
{ name = 'path', type = 'string' },
3601-
{ name = 'atime', type = 'number' },
3602-
{ name = 'mtime', type = 'number' },
3620+
{ name = 'atime', type = opt(union('number', 'string')) },
3621+
{ name = 'mtime', type = opt(union('number', 'string')) },
36033622
async_cb(),
36043623
},
36053624
returns_sync = ret_or_fail('boolean', 'success'),
36063625
returns_async = 'uv_fs_t',
36073626
},
36083627
{
36093628
name = 'fs_futime',
3610-
desc = 'Equivalent to `futime(2)`.',
3629+
desc = [[
3630+
Equivalent to `futimes(3)`.
3631+
3632+
See [Constants][] for supported FS Modification Time constants.
3633+
3634+
Passing `"now"` or `uv.constants.FS_UTIME_NOW` as the atime or mtime sets the timestamp to the
3635+
current time.
3636+
3637+
Passing `nil`, `"omit"`, or `uv.constants.FS_UTIME_OMIT` as the atime or mtime leaves the timestamp
3638+
untouched.
3639+
]],
36113640
params = {
36123641
{ name = 'fd', type = 'integer' },
3613-
{ name = 'atime', type = 'number' },
3614-
{ name = 'mtime', type = 'number' },
3642+
{ name = 'atime', type = opt(union('number', 'string')) },
3643+
{ name = 'mtime', type = opt(union('number', 'string')) },
36153644
async_cb(),
36163645
},
36173646
returns_sync = ret_or_fail('boolean', 'success'),
36183647
returns_async = 'uv_fs_t',
36193648
},
36203649
{
36213650
name = 'fs_lutime',
3622-
desc = 'Equivalent to `lutime(2)`.',
3651+
desc = [[
3652+
Equivalent to `lutimes(3)`.
3653+
3654+
See [Constants][] for supported FS Modification Time constants.
3655+
3656+
Passing `"now"` or `uv.constants.FS_UTIME_NOW` as the atime or mtime sets the timestamp to the
3657+
current time.
3658+
3659+
Passing `nil`, `"omit"`, or `uv.constants.FS_UTIME_OMIT` as the atime or mtime leaves the timestamp
3660+
untouched.
3661+
]],
36233662
params = {
36243663
{ name = 'path', type = 'string' },
3625-
{ name = 'atime', type = 'number' },
3626-
{ name = 'mtime', type = 'number' },
3664+
{ name = 'atime', type = opt(union('number', 'string')) },
3665+
{ name = 'mtime', type = opt(union('number', 'string')) },
36273666
async_cb(),
36283667
},
36293668
returns_sync = ret_or_fail('boolean', 'success'),

docs.md

Lines changed: 41 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

meta.lua

Lines changed: 40 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/constants.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,10 @@ static int luv_constants(lua_State* L) {
355355
lua_setfield(L, -2, "TTY_MODE_RAW");
356356
lua_pushinteger(L, UV_TTY_MODE_IO);
357357
lua_setfield(L, -2, "TTY_MODE_IO");
358+
#if LUV_UV_VERSION_GEQ(1, 51, 0)
359+
lua_pushinteger(L, UV_TTY_MODE_RAW_VT);
360+
lua_setfield(L, -2, "TTY_MODE_RAW_VT");
361+
#endif
358362
#endif
359363

360364
#if LUV_UV_VERSION_GEQ(1, 48, 0)
@@ -370,6 +374,13 @@ static int luv_constants(lua_State* L) {
370374
lua_setfield(L, -2, "THREAD_PRIORITY_LOWEST");
371375
#endif
372376

377+
#if LUV_UV_VERSION_GEQ(1, 51, 0)
378+
lua_pushnumber(L, UV_FS_UTIME_NOW);
379+
lua_setfield(L, -2, "FS_UTIME_NOW");
380+
lua_pushnumber(L, UV_FS_UTIME_OMIT);
381+
lua_setfield(L, -2, "FS_UTIME_OMIT");
382+
#endif
383+
373384
return 1;
374385
}
375386

src/fs.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -779,11 +779,25 @@ static int luv_fs_fchmod(lua_State* L) {
779779
FS_CALL(uv_fs_fchmod, req, file, mode);
780780
}
781781

782+
static double luv_fs_check_modification_time(lua_State* L, int index) {
783+
#if LUV_UV_VERSION_GEQ(1, 51, 0)
784+
const char* special_value_strings[] = { "now", "omit", NULL};
785+
double special_values[] = { UV_FS_UTIME_NOW, UV_FS_UTIME_OMIT };
786+
if (lua_isnoneornil(L, index)) return UV_FS_UTIME_OMIT;
787+
if (lua_isnumber(L, index)) return lua_tonumber(L, index);
788+
789+
int special_value_index = luaL_checkoption(L, index, NULL, special_value_strings);
790+
return special_values[special_value_index];
791+
#else
792+
return luaL_checknumber(L, index);
793+
#endif
794+
}
795+
782796
static int luv_fs_utime(lua_State* L) {
783797
luv_ctx_t* ctx = luv_context(L);
784798
const char* path = luaL_checkstring(L, 1);
785-
double atime = luaL_checknumber(L, 2);
786-
double mtime = luaL_checknumber(L, 3);
799+
double atime = luv_fs_check_modification_time(L, 2);
800+
double mtime = luv_fs_check_modification_time(L, 3);
787801
int ref = luv_check_continuation(L, 4);
788802
uv_fs_t* req = (uv_fs_t*)lua_newuserdata(L, uv_req_size(UV_FS));
789803
req->data = luv_setup_req(L, ctx, ref);
@@ -793,8 +807,8 @@ static int luv_fs_utime(lua_State* L) {
793807
static int luv_fs_futime(lua_State* L) {
794808
luv_ctx_t* ctx = luv_context(L);
795809
uv_file file = luaL_checkinteger(L, 1);
796-
double atime = luaL_checknumber(L, 2);
797-
double mtime = luaL_checknumber(L, 3);
810+
double atime = luv_fs_check_modification_time(L, 2);
811+
double mtime = luv_fs_check_modification_time(L, 3);
798812
int ref = luv_check_continuation(L, 4);
799813
uv_fs_t* req = (uv_fs_t*)lua_newuserdata(L, uv_req_size(UV_FS));
800814
req->data = luv_setup_req(L, ctx, ref);
@@ -805,8 +819,8 @@ static int luv_fs_futime(lua_State* L) {
805819
static int luv_fs_lutime(lua_State* L) {
806820
luv_ctx_t* ctx = luv_context(L);
807821
const char* path = luaL_checkstring(L, 1);
808-
double atime = luaL_checknumber(L, 2);
809-
double mtime = luaL_checknumber(L, 3);
822+
double atime = luv_fs_check_modification_time(L, 2);
823+
double mtime = luv_fs_check_modification_time(L, 3);
810824
int ref = luv_check_continuation(L, 4);
811825
uv_fs_t* req = (uv_fs_t*)lua_newuserdata(L, uv_req_size(UV_FS));
812826
req->data = luv_setup_req(L, ctx, ref);

src/tty.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,22 @@ static int luv_new_tty(lua_State* L) {
4040
}
4141

4242
static int luv_check_tty_mode(lua_State *L, int i) {
43+
#if LUV_UV_VERSION_GEQ(1, 51, 0)
44+
const char* modes[] = { "normal", "raw", "io", "raw_vt", NULL};
45+
#else
4346
const char* modes[] = { "normal", "raw", "io", NULL};
47+
#endif
4448
int mode;
4549

4650
if (lua_isnumber(L, i))
4751
mode = lua_tonumber(L, i);
4852
else
4953
mode = luaL_checkoption(L, i, NULL, modes);
5054

51-
#if LUV_UV_VERSION_GEQ(1, 2, 0)
55+
#if LUV_UV_VERSION_GEQ(1, 51, 0)
56+
luaL_argcheck(L, mode >= UV_TTY_MODE_NORMAL && mode <= UV_TTY_MODE_RAW_VT,
57+
i, "Unknown tty mode value");
58+
#elif LUV_UV_VERSION_GEQ(1, 2, 0)
5259
luaL_argcheck(L, mode >= UV_TTY_MODE_NORMAL && mode <= UV_TTY_MODE_IO,
5360
i, "Unknown tty mode value");
5461
#endif

0 commit comments

Comments
 (0)