diff --git a/trunk/research/st/common.h b/trunk/research/st/common.h index 4df39e9e4..a37e0b637 100644 --- a/trunk/research/st/common.h +++ b/trunk/research/st/common.h @@ -61,7 +61,7 @@ #ifdef DEBUG #define ST_HIDDEN /*nothing*/ #else -#define ST_HIDDEN static +#define ST_HIDDEN static #endif #include "public.h" @@ -78,21 +78,21 @@ typedef struct _st_clist { } _st_clist_t; /* Insert element "_e" into the list, before "_l" */ -#define ST_INSERT_BEFORE(_e,_l) \ - ST_BEGIN_MACRO \ - (_e)->next = (_l); \ - (_e)->prev = (_l)->prev; \ - (_l)->prev->next = (_e); \ - (_l)->prev = (_e); \ +#define ST_INSERT_BEFORE(_e,_l) \ + ST_BEGIN_MACRO \ + (_e)->next = (_l); \ + (_e)->prev = (_l)->prev; \ + (_l)->prev->next = (_e); \ + (_l)->prev = (_e); \ ST_END_MACRO /* Insert element "_e" into the list, after "_l" */ -#define ST_INSERT_AFTER(_e,_l) \ - ST_BEGIN_MACRO \ - (_e)->next = (_l)->next; \ - (_e)->prev = (_l); \ - (_l)->next->prev = (_e); \ - (_l)->next = (_e); \ +#define ST_INSERT_AFTER(_e,_l) \ + ST_BEGIN_MACRO \ + (_e)->next = (_l)->next; \ + (_e)->prev = (_l); \ + (_l)->next->prev = (_e); \ + (_l)->next = (_e); \ ST_END_MACRO /* Return the element following element "_e" */ @@ -109,10 +109,10 @@ typedef struct _st_clist { #define ST_LIST_TAIL(_l) (_l)->prev /* Remove the element "_e" from it's circular list */ -#define ST_REMOVE_LINK(_e) \ - ST_BEGIN_MACRO \ - (_e)->prev->next = (_e)->next; \ - (_e)->next->prev = (_e)->prev; \ +#define ST_REMOVE_LINK(_e) \ + ST_BEGIN_MACRO \ + (_e)->prev->next = (_e)->next; \ + (_e)->next->prev = (_e)->prev; \ ST_END_MACRO /* Return non-zero if the given circular list "_l" is empty, */ @@ -122,9 +122,9 @@ typedef struct _st_clist { /* Initialize a circular list */ #define ST_INIT_CLIST(_l) \ - ST_BEGIN_MACRO \ - (_l)->next = (_l); \ - (_l)->prev = (_l); \ + ST_BEGIN_MACRO \ + (_l)->next = (_l); \ + (_l)->prev = (_l); \ ST_END_MACRO #define ST_INIT_STATIC_CLIST(_l) \ @@ -153,7 +153,7 @@ typedef struct _st_stack { typedef struct _st_cond { - _st_clist_t wait_q; /* Condition variable wait queue */ + _st_clist_t wait_q; /* Condition variable wait queue */ } _st_cond_t; @@ -167,7 +167,7 @@ struct _st_thread { void *arg; /* Argument of the start function */ void *retval; /* Return value of the start function */ - _st_stack_t *stack; /* Info about thread's stack */ + _st_stack_t *stack; /* Info about thread's stack */ _st_clist_t links; /* For putting on run/sleep/zombie queue */ _st_clist_t wait_links; /* For putting on mutex/condvar wait queue */ @@ -177,7 +177,7 @@ struct _st_thread { st_utime_t due; /* Wakeup time when thread is sleeping */ _st_thread_t *left; /* For putting in timeout heap */ - _st_thread_t *right; /* -- see docs/timeout_heap.txt for details */ + _st_thread_t *right; /* -- see docs/timeout_heap.txt for details */ int heap_index; void **private_data; /* Per thread private data */ @@ -229,11 +229,11 @@ typedef struct _st_vp { int pagesize; _st_thread_t *sleep_q; /* sleep queue for this vp */ - int sleepq_size; /* number of threads on sleep queue */ + int sleepq_size; /* number of threads on sleep queue */ #ifdef ST_SWITCH_CB - st_switch_cb_t switch_out_cb; /* called when a thread is switched out */ - st_switch_cb_t switch_in_cb; /* called when a thread is switched in */ + st_switch_cb_t switch_out_cb; /* called when a thread is switched out */ + st_switch_cb_t switch_in_cb; /* called when a thread is switched in */ #endif } _st_vp_t; @@ -252,7 +252,7 @@ typedef struct _st_netfd { * Current vp, thread, and event system */ -extern _st_vp_t _st_this_vp; +extern _st_vp_t _st_this_vp; extern _st_thread_t *_st_this_thread; extern _st_eventsys_t *_st_eventsys; @@ -287,7 +287,7 @@ extern _st_eventsys_t *_st_eventsys; #define _ST_DEL_RUNQ(_thr) ST_REMOVE_LINK(&(_thr)->links) #define _ST_ADD_SLEEPQ(_thr, _timeout) _st_add_sleep_q(_thr, _timeout) -#define _ST_DEL_SLEEPQ(_thr) _st_del_sleep_q(_thr) +#define _ST_DEL_SLEEPQ(_thr) _st_del_sleep_q(_thr) #define _ST_ADD_ZOMBIEQ(_thr) ST_APPEND_LINK(&(_thr)->links, &_ST_ZOMBIEQ) #define _ST_DEL_ZOMBIEQ(_thr) ST_REMOVE_LINK(&(_thr)->links) @@ -379,17 +379,17 @@ void _st_iterate_threads(void); #endif #ifdef ST_SWITCH_CB -#define ST_SWITCH_OUT_CB(_thread) \ - if (_st_this_vp.switch_out_cb != NULL && \ - _thread != _st_this_vp.idle_thread && \ - _thread->state != _ST_ST_ZOMBIE) { \ - _st_this_vp.switch_out_cb(); \ +#define ST_SWITCH_OUT_CB(_thread) \ + if (_st_this_vp.switch_out_cb != NULL && \ + _thread != _st_this_vp.idle_thread && \ + _thread->state != _ST_ST_ZOMBIE) { \ + _st_this_vp.switch_out_cb(); \ } -#define ST_SWITCH_IN_CB(_thread) \ - if (_st_this_vp.switch_in_cb != NULL && \ - _thread != _st_this_vp.idle_thread && \ - _thread->state != _ST_ST_ZOMBIE) { \ - _st_this_vp.switch_in_cb(); \ +#define ST_SWITCH_IN_CB(_thread) \ + if (_st_this_vp.switch_in_cb != NULL && \ + _thread != _st_this_vp.idle_thread && \ + _thread->state != _ST_ST_ZOMBIE) { \ + _st_this_vp.switch_in_cb(); \ } #else #define ST_SWITCH_OUT_CB(_thread) @@ -457,10 +457,10 @@ int st_cond_timedwait(_st_cond_t *cvar, st_utime_t timeout); int st_cond_signal(_st_cond_t *cvar); ssize_t st_read(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout); ssize_t st_write(_st_netfd_t *fd, const void *buf, size_t nbyte, - st_utime_t timeout); + st_utime_t timeout); int st_poll(struct pollfd *pds, int npds, st_utime_t timeout); _st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, - int joinable, int stk_size); + int joinable, int stk_size); #endif /* !__ST_COMMON_H__ */ diff --git a/trunk/research/st/io.c b/trunk/research/st/io.c index f95ff8c6f..7989112ce 100644 --- a/trunk/research/st/io.c +++ b/trunk/research/st/io.c @@ -148,7 +148,7 @@ static _st_netfd_t *_st_netfd_new(int osfd, int nonblock, int is_socket) return fd; /* Do it the Posix way */ if ((flags = fcntl(osfd, F_GETFL, 0)) < 0 || - fcntl(osfd, F_SETFL, flags | O_NONBLOCK) < 0) { + fcntl(osfd, F_SETFL, flags | O_NONBLOCK) < 0) { st_netfd_free(fd); return NULL; } @@ -187,7 +187,7 @@ int st_netfd_fileno(_st_netfd_t *fd) void st_netfd_setspecific(_st_netfd_t *fd, void *value, - _st_destructor_t destructor) + _st_destructor_t destructor) { if (value != fd->private_data) { /* Free up previously set non-NULL data value */ @@ -248,7 +248,7 @@ static void _st_netfd_free_aux_data(_st_netfd_t *fd) } _st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen, - st_utime_t timeout) + st_utime_t timeout) { int osfd, err; _st_netfd_t *newfd; @@ -335,7 +335,7 @@ static void _st_netfd_free_aux_data(_st_netfd_t *fd) } _st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen, - st_utime_t timeout) + st_utime_t timeout) { int osfd, err; _st_netfd_t *newfd; @@ -350,7 +350,7 @@ _st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen, /* Get the lock */ n = st_read(p[0], &c, 1, timeout); if (n < 0) - return NULL; + return NULL; ST_ASSERT(n == 1); /* Got the lock */ osfd = accept(fd->osfd, addr, (socklen_t *)addrlen); @@ -393,7 +393,7 @@ _st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen, int st_connect(_st_netfd_t *fd, const struct sockaddr *addr, int addrlen, - st_utime_t timeout) + st_utime_t timeout) { int n, err = 0; @@ -408,18 +408,18 @@ int st_connect(_st_netfd_t *fd, const struct sockaddr *addr, int addrlen, * ("Interrupted connect"). */ if (errno != EINPROGRESS && (errno != EADDRINUSE || err == 0)) - return -1; + return -1; /* Wait until the socket becomes writable */ if (st_netfd_poll(fd, POLLOUT, timeout) < 0) - return -1; + return -1; /* Try to find out whether the connection setup succeeded or failed */ n = sizeof(int); if (getsockopt(fd->osfd, SOL_SOCKET, SO_ERROR, (char *)&err, - (socklen_t *)&n) < 0) - return -1; + (socklen_t *)&n) < 0) + return -1; if (err) { - errno = err; - return -1; + errno = err; + return -1; } break; } @@ -449,7 +449,7 @@ ssize_t st_read(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout) int st_read_resid(_st_netfd_t *fd, void *buf, size_t *resid, - st_utime_t timeout) + st_utime_t timeout) { struct iovec iov, *riov; int riov_size, rv; @@ -465,7 +465,7 @@ int st_read_resid(_st_netfd_t *fd, void *buf, size_t *resid, ssize_t st_readv(_st_netfd_t *fd, const struct iovec *iov, int iov_size, - st_utime_t timeout) + st_utime_t timeout) { ssize_t n; @@ -483,7 +483,7 @@ ssize_t st_readv(_st_netfd_t *fd, const struct iovec *iov, int iov_size, } int st_readv_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, - st_utime_t timeout) + st_utime_t timeout) { ssize_t n; @@ -494,23 +494,23 @@ int st_readv_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, n = readv(fd->osfd, *iov, *iov_size); if (n < 0) { if (errno == EINTR) - continue; + continue; if (!_IO_NOT_READY_ERROR) - return -1; + return -1; } else if (n == 0) break; else { while ((size_t) n >= (*iov)->iov_len) { - n -= (*iov)->iov_len; - (*iov)->iov_base = (char *) (*iov)->iov_base + (*iov)->iov_len; - (*iov)->iov_len = 0; - (*iov)++; - (*iov_size)--; - if (n == 0) - break; + n -= (*iov)->iov_len; + (*iov)->iov_base = (char *) (*iov)->iov_base + (*iov)->iov_len; + (*iov)->iov_len = 0; + (*iov)++; + (*iov_size)--; + if (n == 0) + break; } if (*iov_size == 0) - break; + break; (*iov)->iov_base = (char *) (*iov)->iov_base + n; (*iov)->iov_len -= n; } @@ -524,7 +524,7 @@ int st_readv_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, ssize_t st_read_fully(_st_netfd_t *fd, void *buf, size_t nbyte, - st_utime_t timeout) + st_utime_t timeout) { size_t resid = nbyte; return st_read_resid(fd, buf, &resid, timeout) == 0 ? @@ -533,12 +533,12 @@ ssize_t st_read_fully(_st_netfd_t *fd, void *buf, size_t nbyte, int st_write_resid(_st_netfd_t *fd, const void *buf, size_t *resid, - st_utime_t timeout) + st_utime_t timeout) { struct iovec iov, *riov; int riov_size, rv; - iov.iov_base = (void *) buf; /* we promise not to modify buf */ + iov.iov_base = (void *) buf; /* we promise not to modify buf */ iov.iov_len = *resid; riov = &iov; riov_size = 1; @@ -549,7 +549,7 @@ int st_write_resid(_st_netfd_t *fd, const void *buf, size_t *resid, ssize_t st_write(_st_netfd_t *fd, const void *buf, size_t nbyte, - st_utime_t timeout) + st_utime_t timeout) { size_t resid = nbyte; return st_write_resid(fd, buf, &resid, timeout) == 0 ? @@ -558,7 +558,7 @@ ssize_t st_write(_st_netfd_t *fd, const void *buf, size_t nbyte, ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size, - st_utime_t timeout) + st_utime_t timeout) { ssize_t n, rv; size_t nleft, nbyte; @@ -573,40 +573,40 @@ ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size, rv = (ssize_t)nbyte; nleft = nbyte; - tmp_iov = (struct iovec *) iov; /* we promise not to modify iov */ + tmp_iov = (struct iovec *) iov; /* we promise not to modify iov */ iov_cnt = iov_size; while (nleft > 0) { if (iov_cnt == 1) { if (st_write(fd, tmp_iov[0].iov_base, nleft, timeout) != (ssize_t) nleft) - rv = -1; + rv = -1; break; } if ((n = writev(fd->osfd, tmp_iov, iov_cnt)) < 0) { if (errno == EINTR) - continue; + continue; if (!_IO_NOT_READY_ERROR) { - rv = -1; - break; + rv = -1; + break; } } else { if ((size_t) n == nleft) - break; + break; nleft -= n; /* Find the next unwritten vector */ n = (ssize_t)(nbyte - nleft); for (index = 0; (size_t) n >= iov[index].iov_len; index++) - n -= iov[index].iov_len; + n -= iov[index].iov_len; if (tmp_iov == iov) { - /* Must copy iov's around */ - if (iov_size - index <= _LOCAL_MAXIOV) { - tmp_iov = local_iov; - } else { - tmp_iov = calloc(1, (iov_size - index) * sizeof(struct iovec)); - if (tmp_iov == NULL) - return -1; - } + /* Must copy iov's around */ + if (iov_size - index <= _LOCAL_MAXIOV) { + tmp_iov = local_iov; + } else { + tmp_iov = calloc(1, (iov_size - index) * sizeof(struct iovec)); + if (tmp_iov == NULL) + return -1; + } } /* Fill in the first partial read */ @@ -615,8 +615,8 @@ ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size, index++; /* Copy the remaining vectors */ for (iov_cnt = 1; index < iov_size; iov_cnt++, index++) { - tmp_iov[iov_cnt].iov_base = iov[index].iov_base; - tmp_iov[iov_cnt].iov_len = iov[index].iov_len; + tmp_iov[iov_cnt].iov_base = iov[index].iov_base; + tmp_iov[iov_cnt].iov_len = iov[index].iov_len; } } /* Wait until the socket becomes writable */ @@ -634,7 +634,7 @@ ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size, int st_writev_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, - st_utime_t timeout) + st_utime_t timeout) { ssize_t n; @@ -645,21 +645,21 @@ int st_writev_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, n = writev(fd->osfd, *iov, *iov_size); if (n < 0) { if (errno == EINTR) - continue; + continue; if (!_IO_NOT_READY_ERROR) - return -1; + return -1; } else { while ((size_t) n >= (*iov)->iov_len) { - n -= (*iov)->iov_len; - (*iov)->iov_base = (char *) (*iov)->iov_base + (*iov)->iov_len; - (*iov)->iov_len = 0; - (*iov)++; - (*iov_size)--; - if (n == 0) - break; + n -= (*iov)->iov_len; + (*iov)->iov_base = (char *) (*iov)->iov_base + (*iov)->iov_len; + (*iov)->iov_len = 0; + (*iov)++; + (*iov_size)--; + if (n == 0) + break; } if (*iov_size == 0) - break; + break; (*iov)->iov_base = (char *) (*iov)->iov_base + n; (*iov)->iov_len -= n; } @@ -676,12 +676,12 @@ int st_writev_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, * Simple I/O functions for UDP. */ int st_recvfrom(_st_netfd_t *fd, void *buf, int len, struct sockaddr *from, - int *fromlen, st_utime_t timeout) + int *fromlen, st_utime_t timeout) { int n; while ((n = recvfrom(fd->osfd, buf, len, 0, from, (socklen_t *)fromlen)) - < 0) { + < 0) { if (errno == EINTR) continue; if (!_IO_NOT_READY_ERROR) @@ -696,7 +696,7 @@ int st_recvfrom(_st_netfd_t *fd, void *buf, int len, struct sockaddr *from, int st_sendto(_st_netfd_t *fd, const void *msg, int len, - const struct sockaddr *to, int tolen, st_utime_t timeout) + const struct sockaddr *to, int tolen, st_utime_t timeout) { int n; @@ -715,7 +715,7 @@ int st_sendto(_st_netfd_t *fd, const void *msg, int len, int st_recvmsg(_st_netfd_t *fd, struct msghdr *msg, int flags, - st_utime_t timeout) + st_utime_t timeout) { int n; @@ -734,7 +734,7 @@ int st_recvmsg(_st_netfd_t *fd, struct msghdr *msg, int flags, int st_sendmsg(_st_netfd_t *fd, const struct msghdr *msg, int flags, - st_utime_t timeout) + st_utime_t timeout) { int n; diff --git a/trunk/research/st/md.S b/trunk/research/st/md.S index ab4f7b557..f2ac6ce17 100644 --- a/trunk/research/st/md.S +++ b/trunk/research/st/md.S @@ -95,7 +95,7 @@ _st_md_cxt_save: ;; stf.spill.nta [r8] = f2,32 stf.spill.nta [r9] = f3,32 - mov r15 = rp + mov r15 = rp ;; stf.spill.nta [r8] = f4,32 stf.spill.nta [r9] = f5,32 @@ -143,7 +143,7 @@ _st_md_cxt_save: ;; st8.nta [r2] = r18,16 // b2 st8.nta [r3] = r19,16 // b3 - mov r26 = ar.rsc + mov r26 = ar.rsc ;; st8.nta [r2] = r20,16 // b4 st8.nta [r3] = r21,16 // b5 @@ -158,18 +158,18 @@ _st_md_cxt_save: st8.nta [r3] = in0,16 // &__jmp_buf (just in case) ;; st8.nta [r2] = r26 // ar.rsc - ;; - flushrs // flush dirty regs to backing store - ;; - and r27 = ~0x3,r26 // clear ar.rsc.mode - ;; - mov ar.rsc = r27 // put RSE in enforced lazy mode - ;; - mov r28 = ar.rnat - ;; - st8.nta [r3] = r28 // ar.rnat - mov ar.rsc = r26 // restore ar.rsc - ;; + ;; + flushrs // flush dirty regs to backing store + ;; + and r27 = ~0x3,r26 // clear ar.rsc.mode + ;; + mov ar.rsc = r27 // put RSE in enforced lazy mode + ;; + mov r28 = ar.rnat + ;; + st8.nta [r3] = r28 // ar.rnat + mov ar.rsc = r26 // restore ar.rsc + ;; mov r8 = 0 br.ret.sptk.few b0 .endp _st_md_cxt_save @@ -183,31 +183,31 @@ _st_md_cxt_save: _st_md_cxt_restore: alloc r8 = ar.pfs,2,0,0,0 add r2 = 0x88,in0 // r2 <- &jmpbuf.ar_bsp - mov r16 = ar.rsc - ;; - flushrs // flush dirty regs to backing store + mov r16 = ar.rsc + ;; + flushrs // flush dirty regs to backing store ;; - and r17 = ~0x3,r16 // clear ar.rsc.mode - ;; - mov ar.rsc = r17 // put RSE in enforced lazy mode + and r17 = ~0x3,r16 // clear ar.rsc.mode + ;; + mov ar.rsc = r17 // put RSE in enforced lazy mode ;; - invala // invalidate the ALAT - ;; + invala // invalidate the ALAT + ;; ld8 r23 = [r2],8 // r23 <- jmpbuf.ar_bsp ;; - mov ar.bspstore = r23 // write BSPSTORE + mov ar.bspstore = r23 // write BSPSTORE ld8 r25 = [r2],24 // r25 <- jmpbuf.ar_unat - ;; - ld8 r26 = [r2],-8 // r26 <- jmpbuf.ar_rnat + ;; + ld8 r26 = [r2],-8 // r26 <- jmpbuf.ar_rnat ;; - mov ar.rnat = r26 // write RNAT - ld8 r27 = [r2] // r27 <- jmpbuf.ar_rsc - ;; - mov ar.rsc = r27 // write RSE control + mov ar.rnat = r26 // write RNAT + ld8 r27 = [r2] // r27 <- jmpbuf.ar_rsc + ;; + mov ar.rsc = r27 // write RSE control mov r2 = in0 - ;; - mov ar.unat = r25 // write ar.unat - add r3 = 8,in0 + ;; + mov ar.unat = r25 // write ar.unat + add r3 = 8,in0 ;; ld8.fill.nta sp = [r2],16 // r12 (sp) ld8.fill.nta gp = [r3],16 // r1 (gp) diff --git a/trunk/research/st/public.h b/trunk/research/st/public.h index e0cc58dc4..968b4d17c 100644 --- a/trunk/research/st/public.h +++ b/trunk/research/st/public.h @@ -45,7 +45,7 @@ #include #include -#define ST_VERSION "1.9" +#define ST_VERSION "1.9" #define ST_VERSION_MAJOR 1 #define ST_VERSION_MINOR 9 @@ -99,7 +99,7 @@ extern void st_thread_exit(void *retval); extern int st_thread_join(st_thread_t thread, void **retvalp); extern void st_thread_interrupt(st_thread_t thread); extern st_thread_t st_thread_create(void *(*start)(void *arg), void *arg, - int joinable, int stack_size); + int joinable, int stack_size); extern int st_randomize_stacks(int on); extern int st_set_utime_function(st_utime_t (*func)(void)); @@ -132,43 +132,43 @@ extern void st_netfd_free(st_netfd_t fd); extern int st_netfd_close(st_netfd_t fd); extern int st_netfd_fileno(st_netfd_t fd); extern void st_netfd_setspecific(st_netfd_t fd, void *value, - void (*destructor)(void *)); + void (*destructor)(void *)); extern void *st_netfd_getspecific(st_netfd_t fd); extern int st_netfd_serialize_accept(st_netfd_t fd); extern int st_netfd_poll(st_netfd_t fd, int how, st_utime_t timeout); extern int st_poll(struct pollfd *pds, int npds, st_utime_t timeout); extern st_netfd_t st_accept(st_netfd_t fd, struct sockaddr *addr, int *addrlen, - st_utime_t timeout); + st_utime_t timeout); extern int st_connect(st_netfd_t fd, const struct sockaddr *addr, int addrlen, - st_utime_t timeout); + st_utime_t timeout); extern ssize_t st_read(st_netfd_t fd, void *buf, size_t nbyte, - st_utime_t timeout); + st_utime_t timeout); extern ssize_t st_read_fully(st_netfd_t fd, void *buf, size_t nbyte, - st_utime_t timeout); + st_utime_t timeout); extern int st_read_resid(st_netfd_t fd, void *buf, size_t *resid, - st_utime_t timeout); + st_utime_t timeout); extern ssize_t st_readv(st_netfd_t fd, const struct iovec *iov, int iov_size, - st_utime_t timeout); + st_utime_t timeout); extern int st_readv_resid(st_netfd_t fd, struct iovec **iov, int *iov_size, - st_utime_t timeout); + st_utime_t timeout); extern ssize_t st_write(st_netfd_t fd, const void *buf, size_t nbyte, - st_utime_t timeout); + st_utime_t timeout); extern int st_write_resid(st_netfd_t fd, const void *buf, size_t *resid, - st_utime_t timeout); + st_utime_t timeout); extern ssize_t st_writev(st_netfd_t fd, const struct iovec *iov, int iov_size, - st_utime_t timeout); + st_utime_t timeout); extern int st_writev_resid(st_netfd_t fd, struct iovec **iov, int *iov_size, - st_utime_t timeout); + st_utime_t timeout); extern int st_recvfrom(st_netfd_t fd, void *buf, int len, - struct sockaddr *from, int *fromlen, - st_utime_t timeout); + struct sockaddr *from, int *fromlen, + st_utime_t timeout); extern int st_sendto(st_netfd_t fd, const void *msg, int len, - const struct sockaddr *to, int tolen, st_utime_t timeout); + const struct sockaddr *to, int tolen, st_utime_t timeout); extern int st_recvmsg(st_netfd_t fd, struct msghdr *msg, int flags, - st_utime_t timeout); + st_utime_t timeout); extern int st_sendmsg(st_netfd_t fd, const struct msghdr *msg, int flags, - st_utime_t timeout); + st_utime_t timeout); extern st_netfd_t st_open(const char *path, int oflags, mode_t mode); #ifdef DEBUG diff --git a/trunk/research/st/sched.c b/trunk/research/st/sched.c index d9c393ca1..43830a24b 100644 --- a/trunk/research/st/sched.c +++ b/trunk/research/st/sched.c @@ -94,7 +94,7 @@ int st_poll(struct pollfd *pds, int npds, st_utime_t timeout) /* Count the number of ready descriptors */ for (pd = pds; pd < epd; pd++) { if (pd->revents) - n++; + n++; } } @@ -165,7 +165,7 @@ int st_init(void) * Create idle thread */ _st_this_vp.idle_thread = st_thread_create(_st_idle_thread_start, - NULL, 0, 0); + NULL, 0, 0); if (!_st_this_vp.idle_thread) return -1; _st_this_vp.idle_thread->flags = _ST_FL_IDLE_THREAD; @@ -176,7 +176,7 @@ int st_init(void) * Initialize primordial thread */ thread = (_st_thread_t *) calloc(1, sizeof(_st_thread_t) + - (ST_KEYS_MAX * sizeof(void *))); + (ST_KEYS_MAX * sizeof(void *))); if (!thread) return -1; thread->private_data = (void **) (thread + 1); @@ -414,33 +414,33 @@ static void heap_delete(_st_thread_t *thread) { _st_thread_t *y; /* The younger child */ int index_tmp; if (t->left == NULL) - break; + break; else if (t->right == NULL) - y = t->left; + y = t->left; else if (t->left->due < t->right->due) - y = t->left; + y = t->left; else - y = t->right; + y = t->right; if (t->due > y->due) { - _st_thread_t *tl = y->left; - _st_thread_t *tr = y->right; - *p = y; - if (y == t->left) { - y->left = t; - y->right = t->right; - p = &y->left; - } else { - y->left = t->left; - y->right = t; - p = &y->right; - } - t->left = tl; - t->right = tr; - index_tmp = t->heap_index; - t->heap_index = y->heap_index; - y->heap_index = index_tmp; + _st_thread_t *tl = y->left; + _st_thread_t *tr = y->right; + *p = y; + if (y == t->left) { + y->left = t; + y->right = t->right; + p = &y->left; + } else { + y->left = t->left; + y->right = t; + p = &y->right; + } + t->left = tl; + t->right = tr; + index_tmp = t->heap_index; + t->heap_index = y->heap_index; + y->heap_index = index_tmp; } else { - break; + break; } } } @@ -518,7 +518,7 @@ void st_thread_interrupt(_st_thread_t *thread) _st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, - int joinable, int stk_size) + int joinable, int stk_size) { _st_thread_t *thread; _st_stack_t *stack; diff --git a/trunk/research/st/stk.c b/trunk/research/st/stk.c index 344552eb6..34769697f 100644 --- a/trunk/research/st/stk.c +++ b/trunk/research/st/stk.c @@ -48,7 +48,7 @@ /* How much space to leave between the stacks, at each end */ -#define REDZONE _ST_PAGE_SIZE +#define REDZONE _ST_PAGE_SIZE _st_clist_t _st_free_stacks = ST_INIT_STATIC_CLIST(&_st_free_stacks); int _st_num_free_stacks = 0; diff --git a/trunk/research/st/sync.c b/trunk/research/st/sync.c index a71876c5f..2303f8a5b 100644 --- a/trunk/research/st/sync.c +++ b/trunk/research/st/sync.c @@ -143,7 +143,7 @@ int st_usleep(st_utime_t usecs) int st_sleep(int secs) { return st_usleep((secs >= 0) ? secs * (st_utime_t) 1000000LL : - ST_UTIME_NO_TIMEOUT); + ST_UTIME_NO_TIMEOUT); } @@ -230,13 +230,13 @@ static int _st_cond_signal(_st_cond_t *cvar, int broadcast) thread = _ST_THREAD_WAITQ_PTR(q); if (thread->state == _ST_ST_COND_WAIT) { if (thread->flags & _ST_FL_ON_SLEEPQ) - _ST_DEL_SLEEPQ(thread); + _ST_DEL_SLEEPQ(thread); /* Make thread runnable */ thread->state = _ST_ST_RUNNABLE; _ST_ADD_RUNQ(thread); if (!broadcast) - break; + break; } }