@@ -2418,19 +2418,19 @@ wasmtime_ssp_poll_oneoff(
2418
2418
size_t * nevents ) NO_LOCK_ANALYSIS
2419
2419
{
2420
2420
// Sleeping.
2421
- if (nsubscriptions == 1 && in [0 ].type == __WASI_EVENTTYPE_CLOCK ) {
2421
+ if (nsubscriptions == 1 && in [0 ].u . type == __WASI_EVENTTYPE_CLOCK ) {
2422
2422
out [0 ] = (__wasi_event_t ){
2423
2423
.userdata = in [0 ].userdata ,
2424
- .type = in [0 ].type ,
2424
+ .type = in [0 ].u . type ,
2425
2425
};
2426
2426
#if CONFIG_HAS_CLOCK_NANOSLEEP
2427
2427
clockid_t clock_id ;
2428
- if (convert_clockid (in [0 ].u .clock .clock_id , & clock_id )) {
2428
+ if (convert_clockid (in [0 ].u .u . clock .clock_id , & clock_id )) {
2429
2429
struct timespec ts ;
2430
- convert_timestamp (in [0 ].u .clock .timeout , & ts );
2430
+ convert_timestamp (in [0 ].u .u . clock .timeout , & ts );
2431
2431
int ret = clock_nanosleep (
2432
2432
clock_id ,
2433
- (in [0 ].u .clock .flags & __WASI_SUBSCRIPTION_CLOCK_ABSTIME ) != 0
2433
+ (in [0 ].u .u . clock .flags & __WASI_SUBSCRIPTION_CLOCK_ABSTIME ) != 0
2434
2434
? TIMER_ABSTIME
2435
2435
: 0 ,
2436
2436
& ts , NULL );
@@ -2441,9 +2441,9 @@ wasmtime_ssp_poll_oneoff(
2441
2441
out [0 ].error = __WASI_ENOTSUP ;
2442
2442
}
2443
2443
#else
2444
- switch (in [0 ].u .clock .clock_id ) {
2444
+ switch (in [0 ].u .u . clock .clock_id ) {
2445
2445
case __WASI_CLOCK_MONOTONIC :
2446
- if ((in [0 ].u .clock .flags & __WASI_SUBSCRIPTION_CLOCK_ABSTIME )
2446
+ if ((in [0 ].u .u . clock .flags & __WASI_SUBSCRIPTION_CLOCK_ABSTIME )
2447
2447
!= 0 ) {
2448
2448
// TODO(ed): Implement.
2449
2449
fputs ("Unimplemented absolute sleep on monotonic clock\n" ,
@@ -2454,12 +2454,12 @@ wasmtime_ssp_poll_oneoff(
2454
2454
// Perform relative sleeps on the monotonic clock also using
2455
2455
// nanosleep(). This is incorrect, but good enough for now.
2456
2456
struct timespec ts ;
2457
- convert_timestamp (in [0 ].u .clock .timeout , & ts );
2457
+ convert_timestamp (in [0 ].u .u . clock .timeout , & ts );
2458
2458
nanosleep (& ts , NULL );
2459
2459
}
2460
2460
break ;
2461
2461
case __WASI_CLOCK_REALTIME :
2462
- if ((in [0 ].u .clock .flags & __WASI_SUBSCRIPTION_CLOCK_ABSTIME )
2462
+ if ((in [0 ].u .u . clock .flags & __WASI_SUBSCRIPTION_CLOCK_ABSTIME )
2463
2463
!= 0 ) {
2464
2464
// Sleeping to an absolute point in time can only be done
2465
2465
// by waiting on a condition variable.
@@ -2473,15 +2473,16 @@ wasmtime_ssp_poll_oneoff(
2473
2473
return -1 ;
2474
2474
}
2475
2475
mutex_lock (& mutex );
2476
- cond_timedwait (& cond , & mutex , in [0 ].u .clock .timeout , true);
2476
+ cond_timedwait (& cond , & mutex , in [0 ].u .u .clock .timeout ,
2477
+ true);
2477
2478
mutex_unlock (& mutex );
2478
2479
mutex_destroy (& mutex );
2479
2480
cond_destroy (& cond );
2480
2481
}
2481
2482
else {
2482
2483
// Relative sleeps can be done using nanosleep().
2483
2484
struct timespec ts ;
2484
- convert_timestamp (in [0 ].u .clock .timeout , & ts );
2485
+ convert_timestamp (in [0 ].u .u . clock .timeout , & ts );
2485
2486
nanosleep (& ts , NULL );
2486
2487
}
2487
2488
break ;
@@ -2519,18 +2520,18 @@ wasmtime_ssp_poll_oneoff(
2519
2520
const __wasi_subscription_t * clock_subscription = NULL ;
2520
2521
for (size_t i = 0 ; i < nsubscriptions ; ++ i ) {
2521
2522
const __wasi_subscription_t * s = & in [i ];
2522
- switch (s -> type ) {
2523
+ switch (s -> u . type ) {
2523
2524
case __WASI_EVENTTYPE_FD_READ :
2524
2525
case __WASI_EVENTTYPE_FD_WRITE :
2525
2526
{
2526
2527
__wasi_errno_t error =
2527
- fd_object_get_locked (& fos [i ], ft , s -> u .fd_readwrite .fd ,
2528
+ fd_object_get_locked (& fos [i ], ft , s -> u .u . fd_readwrite .fd ,
2528
2529
__WASI_RIGHT_POLL_FD_READWRITE , 0 );
2529
2530
if (error == 0 ) {
2530
2531
// Proper file descriptor on which we can poll().
2531
2532
pfds [i ] = (struct pollfd ){
2532
2533
.fd = fd_number (fos [i ]),
2533
- .events = s -> type == __WASI_EVENTTYPE_FD_READ
2534
+ .events = s -> u . type == __WASI_EVENTTYPE_FD_READ
2534
2535
? POLLRDNORM
2535
2536
: POLLWRNORM ,
2536
2537
};
@@ -2542,14 +2543,14 @@ wasmtime_ssp_poll_oneoff(
2542
2543
out [(* nevents )++ ] = (__wasi_event_t ){
2543
2544
.userdata = s -> userdata ,
2544
2545
.error = error ,
2545
- .type = s -> type ,
2546
+ .type = s -> u . type ,
2546
2547
};
2547
2548
}
2548
2549
break ;
2549
2550
}
2550
2551
case __WASI_EVENTTYPE_CLOCK :
2551
2552
if (clock_subscription == NULL
2552
- && (s -> u .clock .flags & __WASI_SUBSCRIPTION_CLOCK_ABSTIME )
2553
+ && (s -> u .u . clock .flags & __WASI_SUBSCRIPTION_CLOCK_ABSTIME )
2553
2554
== 0 ) {
2554
2555
// Relative timeout.
2555
2556
fos [i ] = NULL ;
@@ -2565,7 +2566,7 @@ wasmtime_ssp_poll_oneoff(
2565
2566
out [(* nevents )++ ] = (__wasi_event_t ){
2566
2567
.userdata = s -> userdata ,
2567
2568
.error = __WASI_ENOSYS ,
2568
- .type = s -> type ,
2569
+ .type = s -> u . type ,
2569
2570
};
2570
2571
break ;
2571
2572
}
@@ -2579,7 +2580,7 @@ wasmtime_ssp_poll_oneoff(
2579
2580
timeout = 0 ;
2580
2581
}
2581
2582
else if (clock_subscription != NULL ) {
2582
- __wasi_timestamp_t ts = clock_subscription -> u .clock .timeout / 1000000 ;
2583
+ __wasi_timestamp_t ts = clock_subscription -> u .u . clock .timeout / 1000000 ;
2583
2584
timeout = ts > INT_MAX ? -1 : (int )ts ;
2584
2585
}
2585
2586
else {
@@ -2603,7 +2604,7 @@ wasmtime_ssp_poll_oneoff(
2603
2604
for (size_t i = 0 ; i < nsubscriptions ; ++ i ) {
2604
2605
if (pfds [i ].fd >= 0 ) {
2605
2606
__wasi_filesize_t nbytes = 0 ;
2606
- if (in [i ].type == __WASI_EVENTTYPE_FD_READ ) {
2607
+ if (in [i ].u . type == __WASI_EVENTTYPE_FD_READ ) {
2607
2608
int l ;
2608
2609
if (ioctl (fd_number (fos [i ]), FIONREAD , & l ) == 0 )
2609
2610
nbytes = (__wasi_filesize_t )l ;
@@ -2622,22 +2623,22 @@ wasmtime_ssp_poll_oneoff(
2622
2623
#else
2623
2624
.error = __WASI_EBADF ,
2624
2625
#endif
2625
- .type = in [i ].type ,
2626
+ .type = in [i ].u . type ,
2626
2627
};
2627
2628
}
2628
2629
else if ((pfds [i ].revents & POLLERR ) != 0 ) {
2629
2630
// File descriptor is in an error state.
2630
2631
out [(* nevents )++ ] = (__wasi_event_t ){
2631
2632
.userdata = in [i ].userdata ,
2632
2633
.error = __WASI_EIO ,
2633
- .type = in [i ].type ,
2634
+ .type = in [i ].u . type ,
2634
2635
};
2635
2636
}
2636
2637
else if ((pfds [i ].revents & POLLHUP ) != 0 ) {
2637
2638
// End-of-file.
2638
2639
out [(* nevents )++ ] = (__wasi_event_t ){
2639
2640
.userdata = in [i ].userdata ,
2640
- .type = in [i ].type ,
2641
+ .type = in [i ].u . type ,
2641
2642
.u .fd_readwrite .nbytes = nbytes ,
2642
2643
.u .fd_readwrite .flags =
2643
2644
__WASI_EVENT_FD_READWRITE_HANGUP ,
@@ -2647,7 +2648,7 @@ wasmtime_ssp_poll_oneoff(
2647
2648
// Read or write possible.
2648
2649
out [(* nevents )++ ] = (__wasi_event_t ){
2649
2650
.userdata = in [i ].userdata ,
2650
- .type = in [i ].type ,
2651
+ .type = in [i ].u . type ,
2651
2652
.u .fd_readwrite .nbytes = nbytes ,
2652
2653
};
2653
2654
}
0 commit comments