Skip to content

Commit

Permalink
fix another error caused by the uapi and libc headers mixup
Browse files Browse the repository at this point in the history
print_epoll_data() expects epoll_event.data to be a union, but the
bundled/uapi linux/eventpoll.h defines it as a __u64 int.

on android, that union is defined in bits/epoll_event.h which is
included from sys/epoll.h via linux/eventpoll.h, but the bundled
linux/eventpoll.h shadows it, and so src/epoll.c ends up with the
uapi definition of 'struct epoll_event' and no definition at all
of the epoll_data_t union.

use a kludge to continue printing the u64 .data as a structure made up
of a u32 and a u64 field -- which was quite dumb in the first place,
but I guess they have tests checking for that *exact* output.
  • Loading branch information
turistu committed Nov 12, 2024
1 parent 4ba9f21 commit 087d22f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "defs.h"
#include "kernel_fcntl.h"
#include <sys/epoll.h>
#include <linux/eventpoll.h>

SYS_FUNC(epoll_create)
{
Expand All @@ -34,16 +34,17 @@ SYS_FUNC(epoll_create1)
#include "xlat/epollevents.h"

static void
print_epoll_data(const epoll_data_t data)
print_epoll_data(const __u64 data)
{
/*
* We cannot know what format the tracee uses, so
* print both u32 and u66 which will cover every value.
* print both u32 and u64 which will cover every value.
*/
union dummy { __u64 u64; __u32 u32; } u; u.u64 = data;
tprint_struct_begin();
PRINT_FIELD_U(data, u32);
PRINT_FIELD_U(u, u32);
tprint_struct_next();
PRINT_FIELD_U(data, u64);
PRINT_FIELD_U(u, u64);
tprint_struct_end();
}

Expand Down

0 comments on commit 087d22f

Please sign in to comment.