diff --git a/src/backend.cmod b/src/backend.cmod index dde3a81c75cc3479e91cfea26c03b3461a90f7e2..d232ddbfc6b59e266889607d1d5bf2ac59d9a775 100644 --- a/src/backend.cmod +++ b/src/backend.cmod @@ -143,7 +143,9 @@ static void really_free_compat_cb_box(struct compat_cb_box * b); static int compat_box_dispatcher (struct fd_callback_box *box, int event); #ifdef BACKEND_USES_CFRUNLOOP -/* used by CoreFoundation backend to get around lack of PDB structures early in the CMOD. */ +/* Used by CoreFoundation backend to get around lack of PDB structures + * early in the CMOD. + */ static void check_set_timer(struct timeval when); #endif /* CALL OUT STUFF */ @@ -193,14 +195,16 @@ static struct Backend_struct **fd_map=0; static int fd_map_size=0; static struct object *default_backend_obj = NULL; PMOD_EXPORT struct Backend_struct *default_backend = NULL; + #ifdef DO_PIKE_CLEANUP static int num_active_backends = 0; #endif #if defined(BACKEND_USES_CFRUNLOOP) -static void noteEvents(CFFileDescriptorRef fdref, CFOptionFlags callBackTypes, void *info); +static void noteEvents(CFFileDescriptorRef fdref, CFOptionFlags callBackTypes, + void *info); void cfObserverCallback(CFRunLoopObserverRef observer, - CFRunLoopActivity activity, void* info); + CFRunLoopActivity activity, void* info); void cfTimerCallback(CFRunLoopTimerRef timer, void * info); #endif /* BACKEND_USES_CFRUNLOOP */ @@ -346,7 +350,8 @@ PIKECLASS Backend #endif /* PIKE_DEBUG */ typedef void update_fd_set_handler_fn (struct Backend_struct *me, void *data, int fd, - int old_events, int new_events, int flags); + int old_events, int new_events, + int flags); CVAR update_fd_set_handler_fn *update_fd_set_handler; CVAR void *handler_data; @@ -496,7 +501,11 @@ PIKECLASS Backend #define CALL(X) ((struct Backend_CallOut_struct *)debug_malloc_pass(CALL_(X))) #define MOVECALL(X,Y) do { INT32 p_=(X); (CALL_(p_)=CALL(Y))->pos=p_; }while(0) #define CMP(X,Y) my_timercmp(& CALL(X)->tv, <, & CALL(Y)->tv) -#define SWAP(X,Y) do{ struct Backend_CallOut_struct *_tmp=CALL(X); (CALL_(X)=CALL(Y))->pos=(X); (CALL_(Y)=_tmp)->pos=(Y); } while(0) +#define SWAP(X,Y) do { \ + struct Backend_CallOut_struct *_tmp=CALL(X); \ + (CALL_(X)=CALL(Y))->pos=(X); \ + (CALL_(Y)=_tmp)->pos=(Y); \ + } while(0) #ifdef PIKE_DEBUG static void do_unprotect_call_outs(struct Backend_struct *me) @@ -1047,7 +1056,8 @@ PIKECLASS Backend IF_CO ( if (me->num_pending_calls) - fprintf (stderr, "BACKEND[%d]: backend_do_call_outs: stopping with %d " + fprintf (stderr, + "BACKEND[%d]: backend_do_call_outs: stopping with %d " "call outs left, closest with time %ld.%ld " "(current_time %ld.%ld, limit at %ld.%ld)\n", me->id, me->num_pending_calls, @@ -1408,7 +1418,8 @@ PIKECLASS Backend GET_ACTIVE_BOX (ME, FD) : NULL) - static struct fd_callback_box *safe_get_box (struct Backend_struct *me, int fd) + static struct fd_callback_box *safe_get_box (struct Backend_struct *me, + int fd) { if (fd < 0) { fd = ~fd; @@ -1416,7 +1427,8 @@ PIKECLASS Backend struct fd_callback_box *box = me->inactive_boxes[fd]; /* Avoid free list pointers. */ if ((struct fd_callback_box **) box < me->inactive_boxes || - (struct fd_callback_box **) box >= me->inactive_boxes + me->inactive_boxes_size) + (struct fd_callback_box **) box >= + (me->inactive_boxes + me->inactive_boxes_size)) return box; } } @@ -1428,7 +1440,8 @@ PIKECLASS Backend return NULL; } - PMOD_EXPORT struct fd_callback_box *get_fd_callback_box_for_fd( struct Backend_struct *me, int fd ) + PMOD_EXPORT struct fd_callback_box + *get_fd_callback_box_for_fd( struct Backend_struct *me, int fd ) { return safe_get_box( me, fd ); } @@ -1474,13 +1487,14 @@ PIKECLASS Backend struct Backend_struct *me; if (!box) return; if (!(me = box->backend)) - Pike_fatal ("fd_callback_box not hooked to any backend.\n"); + Pike_fatal("fd_callback_box not hooked to any backend.\n"); if (fd == INT_MAX) fd = box->fd; else if (fd != box->fd) - Pike_fatal ("fd in callback box doesn't correspond to where it's found.\n"); + Pike_fatal("fd in callback box doesn't contain the expected fd.\n"); if (safe_get_box (me, fd) != box) - Pike_fatal ("fd_callback_box not hooked in correctly for fd %d.\n", box->fd); + Pike_fatal("fd_callback_box not hooked in correctly for fd %d.\n", + box->fd); } #else # define check_box(box, fd) do {} while (0) @@ -1601,7 +1615,8 @@ PIKECLASS Backend } if (!me->inactive_boxes) Pike_fatal ("Out of memory in backend::add_fd_box(): " - "Tried to allocate %d inactive fd_callback_box pointers\n", + "Tried to allocate %d inactive " + "fd_callback_box pointers.\n", me->inactive_boxes_size); me->free_inactive_box = me->inactive_boxes + pos; while (++pos < me->inactive_boxes_size) @@ -1611,7 +1626,8 @@ PIKECLASS Backend } pos = me->free_inactive_box - me->inactive_boxes; - me->free_inactive_box = (struct fd_callback_box **) *me->free_inactive_box; + me->free_inactive_box = + (struct fd_callback_box **)*me->free_inactive_box; me->inactive_boxes[pos] = box; box->fd = ~pos; @@ -1632,7 +1648,8 @@ PIKECLASS Backend } else { fd = ~fd; - me->inactive_boxes[fd] = (struct fd_callback_box *) me->free_inactive_box; + me->inactive_boxes[fd] = + (struct fd_callback_box *)me->free_inactive_box; me->free_inactive_box = me->inactive_boxes + fd; } } @@ -1643,7 +1660,8 @@ PIKECLASS Backend if (fd < 0) return; #ifdef __NT__ - if (new_events && !(fd_query_properties(fd, fd_CAN_NONBLOCK) & fd_CAN_NONBLOCK)) { + if (new_events && + !(fd_query_properties(fd, fd_CAN_NONBLOCK) & fd_CAN_NONBLOCK)) { Pike_fatal("update_fd_set() on non-socket!\n"); } #endif /* __NT__ */ @@ -1709,16 +1727,20 @@ PIKECLASS Backend /* Accept an unhooked box; can happen when we're called from an * object exit hook due to being freed by free_object below. */ if (!box->backend) { - IF_PD(fprintf(stderr, "[%d]BACKEND[unhooked box]: unhook_fd_callback_box: " + IF_PD(fprintf(stderr, + "[%d]BACKEND[unhooked box]: unhook_fd_callback_box: " "fd %d, object %p\n", THR_NO, box->fd, box->ref_obj)); return; } check_box (box, INT_MAX); - IF_PD(fprintf(stderr, "[%d]BACKEND[%d]: unhook_fd_callback_box: fd %d, object %p\n", + IF_PD(fprintf(stderr, + "[%d]BACKEND[%d]: unhook_fd_callback_box: fd %d, object %p\n", THR_NO, box->backend->id, box->fd, box->ref_obj)); - if (box->fd >= 0) update_fd_set (box->backend, box->fd, box->events, 0, box->flags); + if (box->fd >= 0) { + update_fd_set (box->backend, box->fd, box->events, 0, box->flags); + } remove_fd_box (box); box->backend = NULL; /* Make sure no further callbacks are called on this box. */ @@ -1749,7 +1771,8 @@ PIKECLASS Backend } } - PMOD_EXPORT void set_fd_callback_events (struct fd_callback_box *box, int events, int flags) + PMOD_EXPORT void set_fd_callback_events (struct fd_callback_box *box, + int events, int flags) { int old_events = box->events; check_box (box, INT_MAX); @@ -1757,7 +1780,9 @@ PIKECLASS Backend "fd %d, events from 0x%x to 0x%x, object %p\n", THR_NO, box->backend->id, box->fd, old_events, events, box->ref_obj)); - if (box->fd >= 0) update_fd_set (box->backend, box->fd, old_events, events, flags); + if (box->fd >= 0) { + update_fd_set (box->backend, box->fd, old_events, events, flags); + } box->events = events; box->flags = flags; @@ -1793,7 +1818,9 @@ PIKECLASS Backend if (old != new) { if (old) { - if (box->fd >= 0) update_fd_set (old, box->fd, box->events, 0, box->flags); + if (box->fd >= 0) { + update_fd_set (old, box->fd, box->events, 0, box->flags); + } remove_fd_box (box); /* Unlink the box from the active in the old backend, @@ -1805,7 +1832,9 @@ PIKECLASS Backend } box->backend = new; add_fd_box (box); - if (box->fd >= 0) update_fd_set (new, box->fd, 0, box->events, box->flags); + if (box->fd >= 0) { + update_fd_set (new, box->fd, 0, box->events, box->flags); + } } } @@ -1828,18 +1857,23 @@ PIKECLASS Backend check_box (box, INT_MAX); if (old_fd >= 0 ? old_fd != new_fd : new_fd >= 0) { - if (old_fd >= 0) update_fd_set (box->backend, old_fd, box->events, 0, box->flags); + if (old_fd >= 0) { + update_fd_set (box->backend, old_fd, box->events, 0, box->flags); + } remove_fd_box (box); box->fd = new_fd; add_fd_box (box); new_fd = box->fd; box->revents = 0; box->rflags = 0; - if (new_fd >= 0) update_fd_set (box->backend, new_fd, 0, box->events, box->flags); + if (new_fd >= 0) { + update_fd_set (box->backend, new_fd, 0, box->events, box->flags); + } } IF_PD(fprintf(stderr, "[%d]BACKEND[%d]: change_fd_for_box: " - "fd from %d to %d\n", THR_NO, box->backend->id, old_fd, new_fd)); + "fd from %d to %d\n", + THR_NO, box->backend->id, old_fd, new_fd)); } } @@ -2146,7 +2180,8 @@ PIKECLASS Backend if (max_timeout.tv_sec >= 0 && (next_timeout->tv_sec < 0 || my_timercmp (&max_timeout, <, next_timeout))) - Pike_fatal ("Timeout raised from %lu.%lu to %lu.%lu by a backend callback.\n", + Pike_fatal ("Timeout raised from %lu.%lu to %lu.%lu " + "by a backend callback.\n", (unsigned long)max_timeout.tv_sec, (unsigned long)max_timeout.tv_usec, (unsigned long)next_timeout->tv_sec, @@ -2314,7 +2349,8 @@ PIKECLASS Backend * Note: This disables any further callbacks. */ old_events = box->events; - set_fd_callback_events (box, box->events & PIKE_BIT_FD_ERROR, box->flags); + set_fd_callback_events(box, box->events & PIKE_BIT_FD_ERROR, + box->flags); if (WANT_EVENT (box, ERROR)) { IF_PD(fprintf(stderr, "[%d]BACKEND[%d]: error event on fd %d sent to %p\n", @@ -2325,7 +2361,9 @@ PIKECLASS Backend } } /* The following is temporary compat stuff. */ - /* kqueue TODO: shouldn't need to do anything here for fs events, but should verify that. */ + /* kqueue TODO: Shouldn't need to do anything here for fs events, + * but should verify this. + */ else if (old_events & PIKE_BIT_FD_READ) { IF_PD(fprintf(stderr, "[%d]BACKEND[%d]: read_callback(%d, %p) for error %d\n", @@ -3054,7 +3092,7 @@ int pdb_MY_FD_SET2(int *pfd, int fd, int filter, int fflags) { struct kevent ev[2]; - /* VNODE filters seem to need ONESHOT mode, else they just repeat endlessly. */ + /* VNODE filters seem to need ONESHOT mode, else they just repeat endlessly. */ if(filter == EVFILT_VNODE) EV_SET(ev, fd, filter, EV_ADD|EV_ENABLE|EV_CLEAR, fflags, 0, 0); else @@ -3290,7 +3328,9 @@ PIKECLASS PollDeviceBackend nev++; } if (wanted_events & PIKE_BIT_FD_FS_EVENT) { -// kqueue TODO generate fflags from the high bits of the wanted_events argument. + /* kqueue TODO generate fflags from the high bits of + * the wanted_events argument. + */ EV_SET(ev+nev, fd, MY_POLLFSEVENT, EV_ADD, 0, 0, 0); nev++; } @@ -3301,7 +3341,9 @@ PIKECLASS PollDeviceBackend #if defined(BACKEND_USES_CFRUNLOOP) - /* we place this declaration here rather than at the top in order to avoid struct-y unpleasantness */ + /* We place these declarations here rather than at the top + * in order to avoid struct-y unpleasantness + */ int init_cf(struct PollDeviceBackend_struct *me, int i); int init_external_cfrl(struct PollDeviceBackend_struct *me, int i); int low_my_kqueue(struct PollDeviceBackend_struct *me); @@ -3332,8 +3374,8 @@ PIKECLASS PollDeviceBackend CFRunLoopObserverRef beObserver = NULL; - int myActivities = kCFRunLoopBeforeWaiting | kCFRunLoopAfterWaiting | kCFRunLoopBeforeTimers | - kCFRunLoopBeforeSources | kCFRunLoopExit; + int myActivities = kCFRunLoopBeforeWaiting | kCFRunLoopAfterWaiting | + kCFRunLoopBeforeTimers | kCFRunLoopBeforeSources | kCFRunLoopExit; CFRunLoopObserverContext context = {0, me, NULL, NULL, NULL}; @@ -3375,10 +3417,12 @@ PIKECLASS PollDeviceBackend { CFFileDescriptorContext context = {0, me, NULL, NULL, NULL}; - me->fdref = CFFileDescriptorCreate(kCFAllocatorDefault, i, true, noteEvents, &context); + me->fdref = CFFileDescriptorCreate(kCFAllocatorDefault, i, true, + noteEvents, &context); CFRetain(me->fdref); - me->source = CFFileDescriptorCreateRunLoopSource(kCFAllocatorDefault, me->fdref, 0); + me->source = CFFileDescriptorCreateRunLoopSource(kCFAllocatorDefault, + me->fdref, 0); CFFileDescriptorEnableCallBacks(me->fdref, kCFFileDescriptorReadCallBack); CFRetain(me->source); @@ -3436,7 +3480,10 @@ PIKECLASS PollDeviceBackend } #if defined(BACKEND_USES_CFRUNLOOP) -static void noteEvents(CFFileDescriptorRef fdref, CFOptionFlags UNUSED(callBackTypes), void *info) { + static void noteEvents(CFFileDescriptorRef fdref, + CFOptionFlags UNUSED(callBackTypes), + void *info) + { struct kevent kev; struct timespec tv; struct PollDeviceBackend_struct * this_backend; @@ -3448,7 +3495,7 @@ static void noteEvents(CFFileDescriptorRef fdref, CFOptionFlags UNUSED(callBackT fd = CFFileDescriptorGetNativeDescriptor(fdref); kevent(fd, NULL, 0, this_backend->poll_fds, POLL_SET_SIZE, &tv); this_backend->event_count = POLL_SET_SIZE; -} + } #endif /* BACKEND_USES_CFRUNLOOP */ static struct PollDeviceBackend_struct **pdb_backends = NULL; @@ -3489,7 +3536,9 @@ static void noteEvents(CFFileDescriptorRef fdref, CFOptionFlags UNUSED(callBackT } /* Called in the child after fork(). */ - static void reopen_all_pdb_backends(struct callback *UNUSED(cb), void *UNUSED(a), void *UNUSED(b)) + static void reopen_all_pdb_backends(struct callback *UNUSED(cb), + void *UNUSED(a), + void *UNUSED(b)) { int i; for (i=0; i < num_pdb_backends; i++) { @@ -3509,8 +3558,9 @@ static void noteEvents(CFFileDescriptorRef fdref, CFOptionFlags UNUSED(callBackT { int changed_events = old_events ^ new_events; - IF_PD(fprintf (stderr, "[%d]BACKEND[%d]: pdb_update_fd_set(.., %d, %d, %d, %d):\n", - THR_NO, me->id, fd, old_events, new_events, flags)); + IF_PD(fprintf(stderr, + "[%d]BACKEND[%d]: pdb_update_fd_set(.., %d, %d, %d, %d):\n", + THR_NO, me->id, fd, old_events, new_events, flags)); if (changed_events) { @@ -3804,8 +3854,10 @@ static void noteEvents(CFFileDescriptorRef fdref, CFOptionFlags UNUSED(callBackT pdb->event_count = 0; pdb->poll_fds = (poll_fds); - CFFileDescriptorEnableCallBacks(pdb->fdref, kCFFileDescriptorReadCallBack); - CFRunLoopAddSource(CFRunLoopGetCurrent(), pdb->source, kCFRunLoopDefaultMode); + CFFileDescriptorEnableCallBacks(pdb->fdref, + kCFFileDescriptorReadCallBack); + CFRunLoopAddSource(CFRunLoopGetCurrent(), pdb->source, + kCFRunLoopDefaultMode); CFRunLoopRunInMode(kCFRunLoopDefaultMode, cf_timeout, true); i = pdb->event_count; @@ -4410,8 +4462,10 @@ static void check_set_timer(struct timeval tmp) CFRunLoopTimerRef timer; CFTimeInterval when = 0.0; - when = (CFTimeInterval)tmp.tv_sec + (1.0E-6 * (CFTimeInterval) tmp.tv_usec); - timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() + when,0, 0, 0, &cfTimerCallback, &context); + when = (CFTimeInterval)tmp.tv_sec + + (1.0E-6 * (CFTimeInterval) tmp.tv_usec); + timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() + when, 0, + 0, 0, &cfTimerCallback, &context); if(timer) { @@ -4459,12 +4513,14 @@ PIKECLASS PollBackend static void pb_update_fd_set (struct Backend_struct *me, struct PollBackend_struct *pb, int fd, - int old_events, int new_events, int UNUSED(flags)) + int old_events, int new_events, + int UNUSED(flags)) { int changed_events = old_events ^ new_events; - IF_PD(fprintf (stderr, "[%d]BACKEND[%d]: pb_update_fd_set(.., %d, %d, %d):\n", - THR_NO, me->id, fd, old_events, new_events)); + IF_PD(fprintf(stderr, + "[%d]BACKEND[%d]: pb_update_fd_set(.., %d, %d, %d):\n", + THR_NO, me->id, fd, old_events, new_events)); if (changed_events) { @@ -4538,8 +4594,7 @@ PIKECLASS PollBackend int fd = pb->set.poll_fds[e].fd; if (fd >= fd_map_size || fd_map[fd] != me) - Pike_fatal ("Isn't referenced from fd_map for fd %d at %d in poll set.\n", - fd, e); + Pike_fatal("Unmapped fd %d at %d in poll set.\n", fd, e); do { ret=fd_fstat(fd, &tmp); @@ -4652,10 +4707,14 @@ PIKECLASS PollBackend "[%d]BACKEND[%d]: fd %4d: %-4s %-5s %-8s %-9s: 0x%04x\n", THR_NO, me->id, pb->active_set.poll_fds[i].fd, - pb->active_set.poll_fds[i].events & (POLLRDNORM|POLLIN) ? "read" : "", - pb->active_set.poll_fds[i].events & POLLOUT ? "write" : "", - pb->active_set.poll_fds[i].events & POLLRDBAND ? "read_oob" : "", - pb->active_set.poll_fds[i].events & POLLWRBAND ? "write_oob" : "", + pb->active_set.poll_fds[i].events & (POLLRDNORM|POLLIN) ? + "read" : "", + pb->active_set.poll_fds[i].events & POLLOUT ? + "write" : "", + pb->active_set.poll_fds[i].events & POLLRDBAND ? + "read_oob" : "", + pb->active_set.poll_fds[i].events & POLLWRBAND ? + "write_oob" : "", pb->active_set.poll_fds[i].events); } } @@ -4939,7 +4998,7 @@ PIKECLASS PollBackend */ PIKEFUN float|int(0..0) `()(void|float|int(0..0) sleep_time) { - struct timeval timeout; /* Got correct gcc warning on timeout.tv_usec. */ + struct timeval timeout; /* Got correct gcc warning on timeout.tv_usec. */ if (sleep_time && TYPEOF(*sleep_time) == PIKE_T_FLOAT) { timeout.tv_sec = (long) floor (sleep_time->u.float_number); @@ -5066,7 +5125,8 @@ PIKECLASS SelectBackend { int changed_events = old_events ^ new_events; - IF_PD(fprintf (stderr, "[%d]BACKEND[%d]: sb_update_fd_set(.., %d, %d, %d):\n", + IF_PD(fprintf (stderr, + "[%d]BACKEND[%d]: sb_update_fd_set(.., %d, %d, %d):\n", THR_NO, me->id, fd, old_events, new_events)); @@ -5152,7 +5212,7 @@ PIKECLASS SelectBackend int ret; if (e >= fd_map_size || fd_map[e] != me) - Pike_fatal ("Isn't referenced from fd_map for fd %d in select set.\n", e); + Pike_fatal("Unmapped fd %d in select set.\n", e); do { ret = fd_fstat(e, &tmp); @@ -5398,7 +5458,9 @@ PIKECLASS SelectBackend #ifdef DEBUG_MALLOC debug_malloc_dump_fd(box->fd); #endif - Pike_fatal("Filedescriptor %d (%s) caused fatal error %d in backend.\n",box->fd,fd_info(box->fd),errno); + Pike_fatal("Filedescriptor %d (%s) caused fatal error %d " + "in backend.\n", + box->fd, fd_info(box->fd), errno); case EINTR: break; @@ -5665,7 +5727,8 @@ struct compat_cb_box X->box.backend, X->box.fd, X->box.events); \ } while (0) -static struct block_allocator compat_cb_allocator = BA_INIT_PAGES(sizeof(struct compat_cb_box), 1); +static struct block_allocator compat_cb_allocator = + BA_INIT_PAGES(sizeof(struct compat_cb_box), 1); static struct compat_cb_box * alloc_compat_cb_box(void) { return ba_alloc(&compat_cb_allocator); @@ -5700,17 +5763,20 @@ static int compat_box_dispatcher (struct fd_callback_box *box, int event) case PIKE_FD_READ_OOB: IF_PD (fprintf (stderr, "[%d]BACKEND[%d]: compat_box_dispatcher for " "PIKE_FD_READ_OOB to %p %p\n", THR_NO, - cbox->box.backend->id, cbox->read_oob, cbox->read_oob_data)); + cbox->box.backend->id, cbox->read_oob, + cbox->read_oob_data)); return cbox->read_oob (cbox->box.fd, cbox->read_oob_data); case PIKE_FD_WRITE_OOB: IF_PD (fprintf (stderr, "[%d]BACKEND[%d]: compat_box_dispatcher for " "PIKE_FD_WRITE_OOB to %p %p\n", THR_NO, - cbox->box.backend->id, cbox->write_oob, cbox->write_oob_data)); + cbox->box.backend->id, cbox->write_oob, + cbox->write_oob_data)); return cbox->write_oob (cbox->box.fd, cbox->write_oob_data); case PIKE_FD_FS_EVENT: IF_PD (fprintf (stderr, "[%d]BACKEND[%d]: compat_box_dispatcher for " "PIKE_FD_FS_EVENT to %p %p\n", THR_NO, - cbox->box.backend->id, cbox->fs_event, cbox->fs_event_data)); + cbox->box.backend->id, cbox->fs_event, + cbox->fs_event_data)); return cbox->fs_event (cbox->box.fd, cbox->fs_event_data); default: #ifdef PIKE_DEBUG @@ -5721,13 +5787,15 @@ static int compat_box_dispatcher (struct fd_callback_box *box, int event) } #define WRAP(CB, EVENT_BIT) \ - void PIKE_CONCAT3(set_, CB, _callback) (int fd, file_callback cb, void *data) \ + void PIKE_CONCAT3(set_, CB, _callback) \ + (int fd, file_callback cb, void *data) \ { \ struct Backend_struct *b = really_get_backend_for_fd (fd); \ struct fd_callback_box *box = SAFE_GET_ACTIVE_BOX (b, fd); \ struct compat_cb_box *cbox; \ \ - IF_PD (fprintf (stderr, "[%d]BACKEND[%d]: set_" #CB "_callback (%d, %p, %p)\n", \ + IF_PD (fprintf (stderr, \ + "[%d]BACKEND[%d]: set_" #CB "_callback (%d, %p, %p)\n", \ THR_NO, b->id, fd, cb, data)); \ \ if (box) { \ @@ -5750,9 +5818,11 @@ static int compat_box_dispatcher (struct fd_callback_box *box, int event) cbox->PIKE_CONCAT (CB, _data) = data; \ \ if (cb) \ - set_fd_callback_events (&cbox->box, cbox->box.events | EVENT_BIT, cbox->flags); \ + set_fd_callback_events (&cbox->box, cbox->box.events | EVENT_BIT, \ + cbox->flags); \ else { \ - set_fd_callback_events (&cbox->box, cbox->box.events & ~EVENT_BIT, cbox->flags); \ + set_fd_callback_events (&cbox->box, cbox->box.events & ~EVENT_BIT, \ + cbox->flags); \ if (!cbox->box.events) { \ unhook_fd_callback_box (&cbox->box); \ really_free_compat_cb_box (cbox); \ @@ -5801,13 +5871,15 @@ static int compat_box_dispatcher (struct fd_callback_box *box, int event) } #define WRAP2(CB, EVENT_BIT) \ - void PIKE_CONCAT3(set_, CB, _callback) (int fd, file_callback cb, void *data, int flags) \ + void PIKE_CONCAT3(set_, CB, _callback) \ + (int fd, file_callback cb, void *data, int flags) \ { \ struct Backend_struct *b = really_get_backend_for_fd (fd); \ struct fd_callback_box *box = SAFE_GET_ACTIVE_BOX (b, fd); \ struct compat_cb_box *cbox; \ \ - IF_PD (fprintf (stderr, "[%d]BACKEND[%d]: set_" #CB "_callback (%d, %p, %p)\n", \ + IF_PD (fprintf (stderr, \ + "[%d]BACKEND[%d]: set_" #CB "_callback (%d, %p, %p)\n", \ THR_NO, b->id, fd, cb, data)); \ \ if (box) { \ @@ -5823,16 +5895,18 @@ static int compat_box_dispatcher (struct fd_callback_box *box, int event) if (!cb) return; \ cbox = alloc_compat_cb_box(); \ INIT_FD_CALLBACK_BOX (&cbox->box, b, NULL, \ - fd, 0, compat_box_dispatcher, flags); \ + fd, 0, compat_box_dispatcher, flags); \ } \ \ cbox->CB = cb; \ cbox->PIKE_CONCAT (CB, _data) = data; \ \ if (cb) \ - set_fd_callback_events (&cbox->box, cbox->box.events | EVENT_BIT, cbox->flags); \ + set_fd_callback_events (&cbox->box, cbox->box.events | EVENT_BIT, \ + cbox->flags); \ else { \ - set_fd_callback_events (&cbox->box, cbox->box.events & ~EVENT_BIT, cbox->flags); \ + set_fd_callback_events (&cbox->box, cbox->box.events & ~EVENT_BIT, \ + cbox->flags); \ if (!cbox->box.events) { \ unhook_fd_callback_box (&cbox->box); \ really_free_compat_cb_box (cbox); \