From e760faa939b400bf950b13d57f9864a5d7144f2f Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 30 Nov 2022 14:01:06 +0100 Subject: [PATCH] file: remove file_ prefix from set/getuser --- ev/+linux/file.ha | 16 ++++++++++++++-- diff --git a/ev/+linux/file.ha b/ev/+linux/file.ha index 8205365f51e98f6100b21e746d97814573140ea5..5337e503b0c498f878fcf8f33a9e7b727d27df31 100644 --- a/ev/+linux/file.ha +++ b/ev/+linux/file.ha @@ -14,6 +14,7 @@ ev: *loop, // Pending operation on this file object op: op, cb: nullable *void, + user: nullable *void, // Operation-specific data vbuf: rt::iovec, @@ -60,15 +61,26 @@ rt::epoll_ctl(loop.fd, rt::EPOLL_CTL_DEL, file.fd, null)!; free(file); }; +// Sets the user data field on this file object to the provided object. +export fn setuser(file: *file, user: nullable *void) void = { + file.user = user; +}; + +// Returns the user data field from this file object. If the field was null, an +// assertion is raised. +export fn getuser(file: *file) *void = { + return file.user as *void; +}; + // Returns the file descriptor for a given file. Note that ev assumes that it // will be responsible for all I/O on the file and any user modifications may // cause the event loop to enter an invalid state. -export fn file_getfd(file: *file) io::file = { +export fn getfd(file: *file) io::file = { return file.fd; }; // Returns the event loop for a given file. -export fn file_getloop(file: *file) *loop = { +export fn getloop(file: *file) *loop = { return file.ev; }; -- 2.48.1