@@ -2418,19 +2418,19 @@ wasmtime_ssp_poll_oneoff(
24182418 size_t * nevents ) NO_LOCK_ANALYSIS
24192419{
24202420 // Sleeping.
2421- if (nsubscriptions == 1 && in [0 ].type == __WASI_EVENTTYPE_CLOCK ) {
2421+ if (nsubscriptions == 1 && in [0 ].u . type == __WASI_EVENTTYPE_CLOCK ) {
24222422 out [0 ] = (__wasi_event_t ){
24232423 .userdata = in [0 ].userdata ,
2424- .type = in [0 ].type ,
2424+ .type = in [0 ].u . type ,
24252425 };
24262426#if CONFIG_HAS_CLOCK_NANOSLEEP
24272427 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 )) {
24292429 struct timespec ts ;
2430- convert_timestamp (in [0 ].u .clock .timeout , & ts );
2430+ convert_timestamp (in [0 ].u .u . clock .timeout , & ts );
24312431 int ret = clock_nanosleep (
24322432 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
24342434 ? TIMER_ABSTIME
24352435 : 0 ,
24362436 & ts , NULL );
@@ -2441,9 +2441,9 @@ wasmtime_ssp_poll_oneoff(
24412441 out [0 ].error = __WASI_ENOTSUP ;
24422442 }
24432443#else
2444- switch (in [0 ].u .clock .clock_id ) {
2444+ switch (in [0 ].u .u . clock .clock_id ) {
24452445 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 )
24472447 != 0 ) {
24482448 // TODO(ed): Implement.
24492449 fputs ("Unimplemented absolute sleep on monotonic clock\n" ,
@@ -2454,12 +2454,12 @@ wasmtime_ssp_poll_oneoff(
24542454 // Perform relative sleeps on the monotonic clock also using
24552455 // nanosleep(). This is incorrect, but good enough for now.
24562456 struct timespec ts ;
2457- convert_timestamp (in [0 ].u .clock .timeout , & ts );
2457+ convert_timestamp (in [0 ].u .u . clock .timeout , & ts );
24582458 nanosleep (& ts , NULL );
24592459 }
24602460 break ;
24612461 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 )
24632463 != 0 ) {
24642464 // Sleeping to an absolute point in time can only be done
24652465 // by waiting on a condition variable.
@@ -2473,15 +2473,16 @@ wasmtime_ssp_poll_oneoff(
24732473 return -1 ;
24742474 }
24752475 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);
24772478 mutex_unlock (& mutex );
24782479 mutex_destroy (& mutex );
24792480 cond_destroy (& cond );
24802481 }
24812482 else {
24822483 // Relative sleeps can be done using nanosleep().
24832484 struct timespec ts ;
2484- convert_timestamp (in [0 ].u .clock .timeout , & ts );
2485+ convert_timestamp (in [0 ].u .u . clock .timeout , & ts );
24852486 nanosleep (& ts , NULL );
24862487 }
24872488 break ;
@@ -2519,18 +2520,18 @@ wasmtime_ssp_poll_oneoff(
25192520 const __wasi_subscription_t * clock_subscription = NULL ;
25202521 for (size_t i = 0 ; i < nsubscriptions ; ++ i ) {
25212522 const __wasi_subscription_t * s = & in [i ];
2522- switch (s -> type ) {
2523+ switch (s -> u . type ) {
25232524 case __WASI_EVENTTYPE_FD_READ :
25242525 case __WASI_EVENTTYPE_FD_WRITE :
25252526 {
25262527 __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 ,
25282529 __WASI_RIGHT_POLL_FD_READWRITE , 0 );
25292530 if (error == 0 ) {
25302531 // Proper file descriptor on which we can poll().
25312532 pfds [i ] = (struct pollfd ){
25322533 .fd = fd_number (fos [i ]),
2533- .events = s -> type == __WASI_EVENTTYPE_FD_READ
2534+ .events = s -> u . type == __WASI_EVENTTYPE_FD_READ
25342535 ? POLLRDNORM
25352536 : POLLWRNORM ,
25362537 };
@@ -2542,14 +2543,14 @@ wasmtime_ssp_poll_oneoff(
25422543 out [(* nevents )++ ] = (__wasi_event_t ){
25432544 .userdata = s -> userdata ,
25442545 .error = error ,
2545- .type = s -> type ,
2546+ .type = s -> u . type ,
25462547 };
25472548 }
25482549 break ;
25492550 }
25502551 case __WASI_EVENTTYPE_CLOCK :
25512552 if (clock_subscription == NULL
2552- && (s -> u .clock .flags & __WASI_SUBSCRIPTION_CLOCK_ABSTIME )
2553+ && (s -> u .u . clock .flags & __WASI_SUBSCRIPTION_CLOCK_ABSTIME )
25532554 == 0 ) {
25542555 // Relative timeout.
25552556 fos [i ] = NULL ;
@@ -2565,7 +2566,7 @@ wasmtime_ssp_poll_oneoff(
25652566 out [(* nevents )++ ] = (__wasi_event_t ){
25662567 .userdata = s -> userdata ,
25672568 .error = __WASI_ENOSYS ,
2568- .type = s -> type ,
2569+ .type = s -> u . type ,
25692570 };
25702571 break ;
25712572 }
@@ -2579,7 +2580,7 @@ wasmtime_ssp_poll_oneoff(
25792580 timeout = 0 ;
25802581 }
25812582 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 ;
25832584 timeout = ts > INT_MAX ? -1 : (int )ts ;
25842585 }
25852586 else {
@@ -2603,7 +2604,7 @@ wasmtime_ssp_poll_oneoff(
26032604 for (size_t i = 0 ; i < nsubscriptions ; ++ i ) {
26042605 if (pfds [i ].fd >= 0 ) {
26052606 __wasi_filesize_t nbytes = 0 ;
2606- if (in [i ].type == __WASI_EVENTTYPE_FD_READ ) {
2607+ if (in [i ].u . type == __WASI_EVENTTYPE_FD_READ ) {
26072608 int l ;
26082609 if (ioctl (fd_number (fos [i ]), FIONREAD , & l ) == 0 )
26092610 nbytes = (__wasi_filesize_t )l ;
@@ -2622,22 +2623,22 @@ wasmtime_ssp_poll_oneoff(
26222623#else
26232624 .error = __WASI_EBADF ,
26242625#endif
2625- .type = in [i ].type ,
2626+ .type = in [i ].u . type ,
26262627 };
26272628 }
26282629 else if ((pfds [i ].revents & POLLERR ) != 0 ) {
26292630 // File descriptor is in an error state.
26302631 out [(* nevents )++ ] = (__wasi_event_t ){
26312632 .userdata = in [i ].userdata ,
26322633 .error = __WASI_EIO ,
2633- .type = in [i ].type ,
2634+ .type = in [i ].u . type ,
26342635 };
26352636 }
26362637 else if ((pfds [i ].revents & POLLHUP ) != 0 ) {
26372638 // End-of-file.
26382639 out [(* nevents )++ ] = (__wasi_event_t ){
26392640 .userdata = in [i ].userdata ,
2640- .type = in [i ].type ,
2641+ .type = in [i ].u . type ,
26412642 .u .fd_readwrite .nbytes = nbytes ,
26422643 .u .fd_readwrite .flags =
26432644 __WASI_EVENT_FD_READWRITE_HANGUP ,
@@ -2647,7 +2648,7 @@ wasmtime_ssp_poll_oneoff(
26472648 // Read or write possible.
26482649 out [(* nevents )++ ] = (__wasi_event_t ){
26492650 .userdata = in [i ].userdata ,
2650- .type = in [i ].type ,
2651+ .type = in [i ].u . type ,
26512652 .u .fd_readwrite .nbytes = nbytes ,
26522653 };
26532654 }
0 commit comments