Skip to content

Commit

Permalink
fix: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
enghitalo committed Jan 17, 2024
1 parent 3a66355 commit 96336a2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
15 changes: 8 additions & 7 deletions vlib/picoev/loop_default.c.v
Expand Up @@ -72,13 +72,14 @@ fn (mut pv Picoev) poll_once(max_wait int) int {
} else if r > 0 {
for target in pv.file_descriptors {
if target.loop_id == pv.loop.id {
// vfmt off
read_events := (
(if C.FD_ISSET(target.fd, &readfds) != 0 { picoev_read } else { 0 })
|
(if C.FD_ISSET(target.fd, &writefds) != 0 { picoev_write } else { 0 })
)
// vfmt on
mut read_events := 0
if C.FD_ISSET(target.fd, &readfds) != 0 {
read_events |= picoev_read
}
if C.FD_ISSET(target.fd, &writefds) != 0 {
read_events |= picoev_write
}

if read_events != 0 {
$if trace_fd ? {
eprintln('do callback ${target.fd}')
Expand Down
16 changes: 9 additions & 7 deletions vlib/picoev/loop_freebsd.c.v
Expand Up @@ -51,13 +51,15 @@ pub fn create_kqueue_loop(id int) !&KqueueLoop {
// ev_set sets a new `kevent` with file descriptor `index`
@[inline]
pub fn (mut pv Picoev) ev_set(index int, operation int, events int) {
// vfmt off
filter := i16(
(if events & picoev_read != 0 { C.EVFILT_READ } else { 0 })
|
(if events & picoev_write != 0 { C.EVFILT_WRITE } else { 0 })
)
// vfmt on
mut filter := 0
if events & picoev_read != 0 {
filter |= C.EVFILT_READ
}
if events & picoev_write != 0 {
filter |= C.EVFILT_WRITE
}
filter = i16(filter)

C.EV_SET(&pv.loop.changelist[index], pv.loop.changed_fds, filter, operation, 0, 0,
0)
}
Expand Down
15 changes: 8 additions & 7 deletions vlib/picoev/loop_linux.c.v
Expand Up @@ -116,13 +116,14 @@ fn (mut pv Picoev) poll_once(max_wait int) int {
assert event.data.fd < max_fds
}
if pv.loop.id == target.loop_id && target.events & picoev_readwrite != 0 {
// vfmt off
read_events := (
(if event.events & u32(C.EPOLLIN) != 0 { picoev_read } else { 0 })
|
(if event.events & u32(C.EPOLLOUT) != 0 { picoev_write } else { 0 })
)
// vfmt on
mut read_events := 0
if event.events & u32(C.EPOLLIN) != 0 {
read_events |= picoev_read
}
if event.events & u32(C.EPOLLOUT) != 0 {
read_events |= picoev_write
}

if read_events != 0 {
// do callback!
unsafe { target.cb(event.data.fd, read_events, &pv) }
Expand Down
16 changes: 9 additions & 7 deletions vlib/picoev/loop_macos.c.v
Expand Up @@ -51,13 +51,15 @@ pub fn create_kqueue_loop(id int) !&KqueueLoop {
// ev_set sets a new `kevent` with file descriptor `index`
@[inline]
pub fn (mut pv Picoev) ev_set(index int, operation int, events int) {
// vfmt off
filter := i16(
(if events & picoev_read != 0 { C.EVFILT_READ } else { 0 })
|
(if events & picoev_write != 0 { C.EVFILT_WRITE } else { 0 })
)
// vfmt on
mut filter := 0
if events & picoev_read != 0 {
filter |= C.EVFILT_READ
}
if events & picoev_write != 0 {
filter |= C.EVFILT_WRITE
}
filter = i16(filter)

C.EV_SET(&pv.loop.changelist[index], pv.loop.changed_fds, filter, operation, 0, 0,
0)
}
Expand Down

0 comments on commit 96336a2

Please sign in to comment.