winlin

research st: replace the TAB with 4spaces

@@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
61 #ifdef DEBUG 61 #ifdef DEBUG
62 #define ST_HIDDEN /*nothing*/ 62 #define ST_HIDDEN /*nothing*/
63 #else 63 #else
64 -#define ST_HIDDEN static 64 +#define ST_HIDDEN static
65 #endif 65 #endif
66 66
67 #include "public.h" 67 #include "public.h"
@@ -78,21 +78,21 @@ typedef struct _st_clist { @@ -78,21 +78,21 @@ typedef struct _st_clist {
78 } _st_clist_t; 78 } _st_clist_t;
79 79
80 /* Insert element "_e" into the list, before "_l" */ 80 /* Insert element "_e" into the list, before "_l" */
81 -#define ST_INSERT_BEFORE(_e,_l) \  
82 - ST_BEGIN_MACRO \  
83 - (_e)->next = (_l); \  
84 - (_e)->prev = (_l)->prev; \  
85 - (_l)->prev->next = (_e); \  
86 - (_l)->prev = (_e); \ 81 +#define ST_INSERT_BEFORE(_e,_l) \
  82 + ST_BEGIN_MACRO \
  83 + (_e)->next = (_l); \
  84 + (_e)->prev = (_l)->prev; \
  85 + (_l)->prev->next = (_e); \
  86 + (_l)->prev = (_e); \
87 ST_END_MACRO 87 ST_END_MACRO
88 88
89 /* Insert element "_e" into the list, after "_l" */ 89 /* Insert element "_e" into the list, after "_l" */
90 -#define ST_INSERT_AFTER(_e,_l) \  
91 - ST_BEGIN_MACRO \  
92 - (_e)->next = (_l)->next; \  
93 - (_e)->prev = (_l); \  
94 - (_l)->next->prev = (_e); \  
95 - (_l)->next = (_e); \ 90 +#define ST_INSERT_AFTER(_e,_l) \
  91 + ST_BEGIN_MACRO \
  92 + (_e)->next = (_l)->next; \
  93 + (_e)->prev = (_l); \
  94 + (_l)->next->prev = (_e); \
  95 + (_l)->next = (_e); \
96 ST_END_MACRO 96 ST_END_MACRO
97 97
98 /* Return the element following element "_e" */ 98 /* Return the element following element "_e" */
@@ -109,10 +109,10 @@ typedef struct _st_clist { @@ -109,10 +109,10 @@ typedef struct _st_clist {
109 #define ST_LIST_TAIL(_l) (_l)->prev 109 #define ST_LIST_TAIL(_l) (_l)->prev
110 110
111 /* Remove the element "_e" from it's circular list */ 111 /* Remove the element "_e" from it's circular list */
112 -#define ST_REMOVE_LINK(_e) \  
113 - ST_BEGIN_MACRO \  
114 - (_e)->prev->next = (_e)->next; \  
115 - (_e)->next->prev = (_e)->prev; \ 112 +#define ST_REMOVE_LINK(_e) \
  113 + ST_BEGIN_MACRO \
  114 + (_e)->prev->next = (_e)->next; \
  115 + (_e)->next->prev = (_e)->prev; \
116 ST_END_MACRO 116 ST_END_MACRO
117 117
118 /* Return non-zero if the given circular list "_l" is empty, */ 118 /* Return non-zero if the given circular list "_l" is empty, */
@@ -122,9 +122,9 @@ typedef struct _st_clist { @@ -122,9 +122,9 @@ typedef struct _st_clist {
122 122
123 /* Initialize a circular list */ 123 /* Initialize a circular list */
124 #define ST_INIT_CLIST(_l) \ 124 #define ST_INIT_CLIST(_l) \
125 - ST_BEGIN_MACRO \  
126 - (_l)->next = (_l); \  
127 - (_l)->prev = (_l); \ 125 + ST_BEGIN_MACRO \
  126 + (_l)->next = (_l); \
  127 + (_l)->prev = (_l); \
128 ST_END_MACRO 128 ST_END_MACRO
129 129
130 #define ST_INIT_STATIC_CLIST(_l) \ 130 #define ST_INIT_STATIC_CLIST(_l) \
@@ -153,7 +153,7 @@ typedef struct _st_stack { @@ -153,7 +153,7 @@ typedef struct _st_stack {
153 153
154 154
155 typedef struct _st_cond { 155 typedef struct _st_cond {
156 - _st_clist_t wait_q; /* Condition variable wait queue */ 156 + _st_clist_t wait_q; /* Condition variable wait queue */
157 } _st_cond_t; 157 } _st_cond_t;
158 158
159 159
@@ -167,7 +167,7 @@ struct _st_thread { @@ -167,7 +167,7 @@ struct _st_thread {
167 void *arg; /* Argument of the start function */ 167 void *arg; /* Argument of the start function */
168 void *retval; /* Return value of the start function */ 168 void *retval; /* Return value of the start function */
169 169
170 - _st_stack_t *stack; /* Info about thread's stack */ 170 + _st_stack_t *stack; /* Info about thread's stack */
171 171
172 _st_clist_t links; /* For putting on run/sleep/zombie queue */ 172 _st_clist_t links; /* For putting on run/sleep/zombie queue */
173 _st_clist_t wait_links; /* For putting on mutex/condvar wait queue */ 173 _st_clist_t wait_links; /* For putting on mutex/condvar wait queue */
@@ -177,7 +177,7 @@ struct _st_thread { @@ -177,7 +177,7 @@ struct _st_thread {
177 177
178 st_utime_t due; /* Wakeup time when thread is sleeping */ 178 st_utime_t due; /* Wakeup time when thread is sleeping */
179 _st_thread_t *left; /* For putting in timeout heap */ 179 _st_thread_t *left; /* For putting in timeout heap */
180 - _st_thread_t *right; /* -- see docs/timeout_heap.txt for details */ 180 + _st_thread_t *right; /* -- see docs/timeout_heap.txt for details */
181 int heap_index; 181 int heap_index;
182 182
183 void **private_data; /* Per thread private data */ 183 void **private_data; /* Per thread private data */
@@ -229,11 +229,11 @@ typedef struct _st_vp { @@ -229,11 +229,11 @@ typedef struct _st_vp {
229 int pagesize; 229 int pagesize;
230 230
231 _st_thread_t *sleep_q; /* sleep queue for this vp */ 231 _st_thread_t *sleep_q; /* sleep queue for this vp */
232 - int sleepq_size; /* number of threads on sleep queue */ 232 + int sleepq_size; /* number of threads on sleep queue */
233 233
234 #ifdef ST_SWITCH_CB 234 #ifdef ST_SWITCH_CB
235 - st_switch_cb_t switch_out_cb; /* called when a thread is switched out */  
236 - st_switch_cb_t switch_in_cb; /* called when a thread is switched in */ 235 + st_switch_cb_t switch_out_cb; /* called when a thread is switched out */
  236 + st_switch_cb_t switch_in_cb; /* called when a thread is switched in */
237 #endif 237 #endif
238 } _st_vp_t; 238 } _st_vp_t;
239 239
@@ -252,7 +252,7 @@ typedef struct _st_netfd { @@ -252,7 +252,7 @@ typedef struct _st_netfd {
252 * Current vp, thread, and event system 252 * Current vp, thread, and event system
253 */ 253 */
254 254
255 -extern _st_vp_t _st_this_vp; 255 +extern _st_vp_t _st_this_vp;
256 extern _st_thread_t *_st_this_thread; 256 extern _st_thread_t *_st_this_thread;
257 extern _st_eventsys_t *_st_eventsys; 257 extern _st_eventsys_t *_st_eventsys;
258 258
@@ -287,7 +287,7 @@ extern _st_eventsys_t *_st_eventsys; @@ -287,7 +287,7 @@ extern _st_eventsys_t *_st_eventsys;
287 #define _ST_DEL_RUNQ(_thr) ST_REMOVE_LINK(&(_thr)->links) 287 #define _ST_DEL_RUNQ(_thr) ST_REMOVE_LINK(&(_thr)->links)
288 288
289 #define _ST_ADD_SLEEPQ(_thr, _timeout) _st_add_sleep_q(_thr, _timeout) 289 #define _ST_ADD_SLEEPQ(_thr, _timeout) _st_add_sleep_q(_thr, _timeout)
290 -#define _ST_DEL_SLEEPQ(_thr) _st_del_sleep_q(_thr) 290 +#define _ST_DEL_SLEEPQ(_thr) _st_del_sleep_q(_thr)
291 291
292 #define _ST_ADD_ZOMBIEQ(_thr) ST_APPEND_LINK(&(_thr)->links, &_ST_ZOMBIEQ) 292 #define _ST_ADD_ZOMBIEQ(_thr) ST_APPEND_LINK(&(_thr)->links, &_ST_ZOMBIEQ)
293 #define _ST_DEL_ZOMBIEQ(_thr) ST_REMOVE_LINK(&(_thr)->links) 293 #define _ST_DEL_ZOMBIEQ(_thr) ST_REMOVE_LINK(&(_thr)->links)
@@ -379,17 +379,17 @@ void _st_iterate_threads(void); @@ -379,17 +379,17 @@ void _st_iterate_threads(void);
379 #endif 379 #endif
380 380
381 #ifdef ST_SWITCH_CB 381 #ifdef ST_SWITCH_CB
382 -#define ST_SWITCH_OUT_CB(_thread) \  
383 - if (_st_this_vp.switch_out_cb != NULL && \  
384 - _thread != _st_this_vp.idle_thread && \  
385 - _thread->state != _ST_ST_ZOMBIE) { \  
386 - _st_this_vp.switch_out_cb(); \ 382 +#define ST_SWITCH_OUT_CB(_thread) \
  383 + if (_st_this_vp.switch_out_cb != NULL && \
  384 + _thread != _st_this_vp.idle_thread && \
  385 + _thread->state != _ST_ST_ZOMBIE) { \
  386 + _st_this_vp.switch_out_cb(); \
387 } 387 }
388 -#define ST_SWITCH_IN_CB(_thread) \  
389 - if (_st_this_vp.switch_in_cb != NULL && \  
390 - _thread != _st_this_vp.idle_thread && \  
391 - _thread->state != _ST_ST_ZOMBIE) { \  
392 - _st_this_vp.switch_in_cb(); \ 388 +#define ST_SWITCH_IN_CB(_thread) \
  389 + if (_st_this_vp.switch_in_cb != NULL && \
  390 + _thread != _st_this_vp.idle_thread && \
  391 + _thread->state != _ST_ST_ZOMBIE) { \
  392 + _st_this_vp.switch_in_cb(); \
393 } 393 }
394 #else 394 #else
395 #define ST_SWITCH_OUT_CB(_thread) 395 #define ST_SWITCH_OUT_CB(_thread)
@@ -457,10 +457,10 @@ int st_cond_timedwait(_st_cond_t *cvar, st_utime_t timeout); @@ -457,10 +457,10 @@ int st_cond_timedwait(_st_cond_t *cvar, st_utime_t timeout);
457 int st_cond_signal(_st_cond_t *cvar); 457 int st_cond_signal(_st_cond_t *cvar);
458 ssize_t st_read(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout); 458 ssize_t st_read(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout);
459 ssize_t st_write(_st_netfd_t *fd, const void *buf, size_t nbyte, 459 ssize_t st_write(_st_netfd_t *fd, const void *buf, size_t nbyte,
460 - st_utime_t timeout); 460 + st_utime_t timeout);
461 int st_poll(struct pollfd *pds, int npds, st_utime_t timeout); 461 int st_poll(struct pollfd *pds, int npds, st_utime_t timeout);
462 _st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, 462 _st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg,
463 - int joinable, int stk_size); 463 + int joinable, int stk_size);
464 464
465 #endif /* !__ST_COMMON_H__ */ 465 #endif /* !__ST_COMMON_H__ */
466 466
@@ -148,7 +148,7 @@ static _st_netfd_t *_st_netfd_new(int osfd, int nonblock, int is_socket) @@ -148,7 +148,7 @@ static _st_netfd_t *_st_netfd_new(int osfd, int nonblock, int is_socket)
148 return fd; 148 return fd;
149 /* Do it the Posix way */ 149 /* Do it the Posix way */
150 if ((flags = fcntl(osfd, F_GETFL, 0)) < 0 || 150 if ((flags = fcntl(osfd, F_GETFL, 0)) < 0 ||
151 - fcntl(osfd, F_SETFL, flags | O_NONBLOCK) < 0) { 151 + fcntl(osfd, F_SETFL, flags | O_NONBLOCK) < 0) {
152 st_netfd_free(fd); 152 st_netfd_free(fd);
153 return NULL; 153 return NULL;
154 } 154 }
@@ -187,7 +187,7 @@ int st_netfd_fileno(_st_netfd_t *fd) @@ -187,7 +187,7 @@ int st_netfd_fileno(_st_netfd_t *fd)
187 187
188 188
189 void st_netfd_setspecific(_st_netfd_t *fd, void *value, 189 void st_netfd_setspecific(_st_netfd_t *fd, void *value,
190 - _st_destructor_t destructor) 190 + _st_destructor_t destructor)
191 { 191 {
192 if (value != fd->private_data) { 192 if (value != fd->private_data) {
193 /* Free up previously set non-NULL data value */ 193 /* Free up previously set non-NULL data value */
@@ -248,7 +248,7 @@ static void _st_netfd_free_aux_data(_st_netfd_t *fd) @@ -248,7 +248,7 @@ static void _st_netfd_free_aux_data(_st_netfd_t *fd)
248 } 248 }
249 249
250 _st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen, 250 _st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen,
251 - st_utime_t timeout) 251 + st_utime_t timeout)
252 { 252 {
253 int osfd, err; 253 int osfd, err;
254 _st_netfd_t *newfd; 254 _st_netfd_t *newfd;
@@ -335,7 +335,7 @@ static void _st_netfd_free_aux_data(_st_netfd_t *fd) @@ -335,7 +335,7 @@ static void _st_netfd_free_aux_data(_st_netfd_t *fd)
335 } 335 }
336 336
337 _st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen, 337 _st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen,
338 - st_utime_t timeout) 338 + st_utime_t timeout)
339 { 339 {
340 int osfd, err; 340 int osfd, err;
341 _st_netfd_t *newfd; 341 _st_netfd_t *newfd;
@@ -350,7 +350,7 @@ _st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen, @@ -350,7 +350,7 @@ _st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen,
350 /* Get the lock */ 350 /* Get the lock */
351 n = st_read(p[0], &c, 1, timeout); 351 n = st_read(p[0], &c, 1, timeout);
352 if (n < 0) 352 if (n < 0)
353 - return NULL; 353 + return NULL;
354 ST_ASSERT(n == 1); 354 ST_ASSERT(n == 1);
355 /* Got the lock */ 355 /* Got the lock */
356 osfd = accept(fd->osfd, addr, (socklen_t *)addrlen); 356 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, @@ -393,7 +393,7 @@ _st_netfd_t *st_accept(_st_netfd_t *fd, struct sockaddr *addr, int *addrlen,
393 393
394 394
395 int st_connect(_st_netfd_t *fd, const struct sockaddr *addr, int addrlen, 395 int st_connect(_st_netfd_t *fd, const struct sockaddr *addr, int addrlen,
396 - st_utime_t timeout) 396 + st_utime_t timeout)
397 { 397 {
398 int n, err = 0; 398 int n, err = 0;
399 399
@@ -408,18 +408,18 @@ int st_connect(_st_netfd_t *fd, const struct sockaddr *addr, int addrlen, @@ -408,18 +408,18 @@ int st_connect(_st_netfd_t *fd, const struct sockaddr *addr, int addrlen,
408 * ("Interrupted connect"). 408 * ("Interrupted connect").
409 */ 409 */
410 if (errno != EINPROGRESS && (errno != EADDRINUSE || err == 0)) 410 if (errno != EINPROGRESS && (errno != EADDRINUSE || err == 0))
411 - return -1; 411 + return -1;
412 /* Wait until the socket becomes writable */ 412 /* Wait until the socket becomes writable */
413 if (st_netfd_poll(fd, POLLOUT, timeout) < 0) 413 if (st_netfd_poll(fd, POLLOUT, timeout) < 0)
414 - return -1; 414 + return -1;
415 /* Try to find out whether the connection setup succeeded or failed */ 415 /* Try to find out whether the connection setup succeeded or failed */
416 n = sizeof(int); 416 n = sizeof(int);
417 if (getsockopt(fd->osfd, SOL_SOCKET, SO_ERROR, (char *)&err, 417 if (getsockopt(fd->osfd, SOL_SOCKET, SO_ERROR, (char *)&err,
418 - (socklen_t *)&n) < 0)  
419 - return -1; 418 + (socklen_t *)&n) < 0)
  419 + return -1;
420 if (err) { 420 if (err) {
421 - errno = err;  
422 - return -1; 421 + errno = err;
  422 + return -1;
423 } 423 }
424 break; 424 break;
425 } 425 }
@@ -449,7 +449,7 @@ ssize_t st_read(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout) @@ -449,7 +449,7 @@ ssize_t st_read(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout)
449 449
450 450
451 int st_read_resid(_st_netfd_t *fd, void *buf, size_t *resid, 451 int st_read_resid(_st_netfd_t *fd, void *buf, size_t *resid,
452 - st_utime_t timeout) 452 + st_utime_t timeout)
453 { 453 {
454 struct iovec iov, *riov; 454 struct iovec iov, *riov;
455 int riov_size, rv; 455 int riov_size, rv;
@@ -465,7 +465,7 @@ int st_read_resid(_st_netfd_t *fd, void *buf, size_t *resid, @@ -465,7 +465,7 @@ int st_read_resid(_st_netfd_t *fd, void *buf, size_t *resid,
465 465
466 466
467 ssize_t st_readv(_st_netfd_t *fd, const struct iovec *iov, int iov_size, 467 ssize_t st_readv(_st_netfd_t *fd, const struct iovec *iov, int iov_size,
468 - st_utime_t timeout) 468 + st_utime_t timeout)
469 { 469 {
470 ssize_t n; 470 ssize_t n;
471 471
@@ -483,7 +483,7 @@ ssize_t st_readv(_st_netfd_t *fd, const struct iovec *iov, int iov_size, @@ -483,7 +483,7 @@ ssize_t st_readv(_st_netfd_t *fd, const struct iovec *iov, int iov_size,
483 } 483 }
484 484
485 int st_readv_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, 485 int st_readv_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size,
486 - st_utime_t timeout) 486 + st_utime_t timeout)
487 { 487 {
488 ssize_t n; 488 ssize_t n;
489 489
@@ -494,23 +494,23 @@ int st_readv_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, @@ -494,23 +494,23 @@ int st_readv_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size,
494 n = readv(fd->osfd, *iov, *iov_size); 494 n = readv(fd->osfd, *iov, *iov_size);
495 if (n < 0) { 495 if (n < 0) {
496 if (errno == EINTR) 496 if (errno == EINTR)
497 - continue; 497 + continue;
498 if (!_IO_NOT_READY_ERROR) 498 if (!_IO_NOT_READY_ERROR)
499 - return -1; 499 + return -1;
500 } else if (n == 0) 500 } else if (n == 0)
501 break; 501 break;
502 else { 502 else {
503 while ((size_t) n >= (*iov)->iov_len) { 503 while ((size_t) n >= (*iov)->iov_len) {
504 - n -= (*iov)->iov_len;  
505 - (*iov)->iov_base = (char *) (*iov)->iov_base + (*iov)->iov_len;  
506 - (*iov)->iov_len = 0;  
507 - (*iov)++;  
508 - (*iov_size)--;  
509 - if (n == 0)  
510 - break; 504 + n -= (*iov)->iov_len;
  505 + (*iov)->iov_base = (char *) (*iov)->iov_base + (*iov)->iov_len;
  506 + (*iov)->iov_len = 0;
  507 + (*iov)++;
  508 + (*iov_size)--;
  509 + if (n == 0)
  510 + break;
511 } 511 }
512 if (*iov_size == 0) 512 if (*iov_size == 0)
513 - break; 513 + break;
514 (*iov)->iov_base = (char *) (*iov)->iov_base + n; 514 (*iov)->iov_base = (char *) (*iov)->iov_base + n;
515 (*iov)->iov_len -= n; 515 (*iov)->iov_len -= n;
516 } 516 }
@@ -524,7 +524,7 @@ int st_readv_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, @@ -524,7 +524,7 @@ int st_readv_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size,
524 524
525 525
526 ssize_t st_read_fully(_st_netfd_t *fd, void *buf, size_t nbyte, 526 ssize_t st_read_fully(_st_netfd_t *fd, void *buf, size_t nbyte,
527 - st_utime_t timeout) 527 + st_utime_t timeout)
528 { 528 {
529 size_t resid = nbyte; 529 size_t resid = nbyte;
530 return st_read_resid(fd, buf, &resid, timeout) == 0 ? 530 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, @@ -533,12 +533,12 @@ ssize_t st_read_fully(_st_netfd_t *fd, void *buf, size_t nbyte,
533 533
534 534
535 int st_write_resid(_st_netfd_t *fd, const void *buf, size_t *resid, 535 int st_write_resid(_st_netfd_t *fd, const void *buf, size_t *resid,
536 - st_utime_t timeout) 536 + st_utime_t timeout)
537 { 537 {
538 struct iovec iov, *riov; 538 struct iovec iov, *riov;
539 int riov_size, rv; 539 int riov_size, rv;
540 540
541 - iov.iov_base = (void *) buf; /* we promise not to modify buf */ 541 + iov.iov_base = (void *) buf; /* we promise not to modify buf */
542 iov.iov_len = *resid; 542 iov.iov_len = *resid;
543 riov = &iov; 543 riov = &iov;
544 riov_size = 1; 544 riov_size = 1;
@@ -549,7 +549,7 @@ int st_write_resid(_st_netfd_t *fd, const void *buf, size_t *resid, @@ -549,7 +549,7 @@ int st_write_resid(_st_netfd_t *fd, const void *buf, size_t *resid,
549 549
550 550
551 ssize_t st_write(_st_netfd_t *fd, const void *buf, size_t nbyte, 551 ssize_t st_write(_st_netfd_t *fd, const void *buf, size_t nbyte,
552 - st_utime_t timeout) 552 + st_utime_t timeout)
553 { 553 {
554 size_t resid = nbyte; 554 size_t resid = nbyte;
555 return st_write_resid(fd, buf, &resid, timeout) == 0 ? 555 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, @@ -558,7 +558,7 @@ ssize_t st_write(_st_netfd_t *fd, const void *buf, size_t nbyte,
558 558
559 559
560 ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size, 560 ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size,
561 - st_utime_t timeout) 561 + st_utime_t timeout)
562 { 562 {
563 ssize_t n, rv; 563 ssize_t n, rv;
564 size_t nleft, nbyte; 564 size_t nleft, nbyte;
@@ -573,40 +573,40 @@ ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size, @@ -573,40 +573,40 @@ ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size,
573 573
574 rv = (ssize_t)nbyte; 574 rv = (ssize_t)nbyte;
575 nleft = nbyte; 575 nleft = nbyte;
576 - tmp_iov = (struct iovec *) iov; /* we promise not to modify iov */ 576 + tmp_iov = (struct iovec *) iov; /* we promise not to modify iov */
577 iov_cnt = iov_size; 577 iov_cnt = iov_size;
578 578
579 while (nleft > 0) { 579 while (nleft > 0) {
580 if (iov_cnt == 1) { 580 if (iov_cnt == 1) {
581 if (st_write(fd, tmp_iov[0].iov_base, nleft, timeout) != (ssize_t) nleft) 581 if (st_write(fd, tmp_iov[0].iov_base, nleft, timeout) != (ssize_t) nleft)
582 - rv = -1; 582 + rv = -1;
583 break; 583 break;
584 } 584 }
585 if ((n = writev(fd->osfd, tmp_iov, iov_cnt)) < 0) { 585 if ((n = writev(fd->osfd, tmp_iov, iov_cnt)) < 0) {
586 if (errno == EINTR) 586 if (errno == EINTR)
587 - continue; 587 + continue;
588 if (!_IO_NOT_READY_ERROR) { 588 if (!_IO_NOT_READY_ERROR) {
589 - rv = -1;  
590 - break; 589 + rv = -1;
  590 + break;
591 } 591 }
592 } else { 592 } else {
593 if ((size_t) n == nleft) 593 if ((size_t) n == nleft)
594 - break; 594 + break;
595 nleft -= n; 595 nleft -= n;
596 /* Find the next unwritten vector */ 596 /* Find the next unwritten vector */
597 n = (ssize_t)(nbyte - nleft); 597 n = (ssize_t)(nbyte - nleft);
598 for (index = 0; (size_t) n >= iov[index].iov_len; index++) 598 for (index = 0; (size_t) n >= iov[index].iov_len; index++)
599 - n -= iov[index].iov_len; 599 + n -= iov[index].iov_len;
600 600
601 if (tmp_iov == iov) { 601 if (tmp_iov == iov) {
602 - /* Must copy iov's around */  
603 - if (iov_size - index <= _LOCAL_MAXIOV) {  
604 - tmp_iov = local_iov;  
605 - } else {  
606 - tmp_iov = calloc(1, (iov_size - index) * sizeof(struct iovec));  
607 - if (tmp_iov == NULL)  
608 - return -1;  
609 - } 602 + /* Must copy iov's around */
  603 + if (iov_size - index <= _LOCAL_MAXIOV) {
  604 + tmp_iov = local_iov;
  605 + } else {
  606 + tmp_iov = calloc(1, (iov_size - index) * sizeof(struct iovec));
  607 + if (tmp_iov == NULL)
  608 + return -1;
  609 + }
610 } 610 }
611 611
612 /* Fill in the first partial read */ 612 /* 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, @@ -615,8 +615,8 @@ ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size,
615 index++; 615 index++;
616 /* Copy the remaining vectors */ 616 /* Copy the remaining vectors */
617 for (iov_cnt = 1; index < iov_size; iov_cnt++, index++) { 617 for (iov_cnt = 1; index < iov_size; iov_cnt++, index++) {
618 - tmp_iov[iov_cnt].iov_base = iov[index].iov_base;  
619 - tmp_iov[iov_cnt].iov_len = iov[index].iov_len; 618 + tmp_iov[iov_cnt].iov_base = iov[index].iov_base;
  619 + tmp_iov[iov_cnt].iov_len = iov[index].iov_len;
620 } 620 }
621 } 621 }
622 /* Wait until the socket becomes writable */ 622 /* 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, @@ -634,7 +634,7 @@ ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size,
634 634
635 635
636 int st_writev_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, 636 int st_writev_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size,
637 - st_utime_t timeout) 637 + st_utime_t timeout)
638 { 638 {
639 ssize_t n; 639 ssize_t n;
640 640
@@ -645,21 +645,21 @@ int st_writev_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, @@ -645,21 +645,21 @@ int st_writev_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size,
645 n = writev(fd->osfd, *iov, *iov_size); 645 n = writev(fd->osfd, *iov, *iov_size);
646 if (n < 0) { 646 if (n < 0) {
647 if (errno == EINTR) 647 if (errno == EINTR)
648 - continue; 648 + continue;
649 if (!_IO_NOT_READY_ERROR) 649 if (!_IO_NOT_READY_ERROR)
650 - return -1; 650 + return -1;
651 } else { 651 } else {
652 while ((size_t) n >= (*iov)->iov_len) { 652 while ((size_t) n >= (*iov)->iov_len) {
653 - n -= (*iov)->iov_len;  
654 - (*iov)->iov_base = (char *) (*iov)->iov_base + (*iov)->iov_len;  
655 - (*iov)->iov_len = 0;  
656 - (*iov)++;  
657 - (*iov_size)--;  
658 - if (n == 0)  
659 - break; 653 + n -= (*iov)->iov_len;
  654 + (*iov)->iov_base = (char *) (*iov)->iov_base + (*iov)->iov_len;
  655 + (*iov)->iov_len = 0;
  656 + (*iov)++;
  657 + (*iov_size)--;
  658 + if (n == 0)
  659 + break;
660 } 660 }
661 if (*iov_size == 0) 661 if (*iov_size == 0)
662 - break; 662 + break;
663 (*iov)->iov_base = (char *) (*iov)->iov_base + n; 663 (*iov)->iov_base = (char *) (*iov)->iov_base + n;
664 (*iov)->iov_len -= n; 664 (*iov)->iov_len -= n;
665 } 665 }
@@ -676,12 +676,12 @@ int st_writev_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, @@ -676,12 +676,12 @@ int st_writev_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size,
676 * Simple I/O functions for UDP. 676 * Simple I/O functions for UDP.
677 */ 677 */
678 int st_recvfrom(_st_netfd_t *fd, void *buf, int len, struct sockaddr *from, 678 int st_recvfrom(_st_netfd_t *fd, void *buf, int len, struct sockaddr *from,
679 - int *fromlen, st_utime_t timeout) 679 + int *fromlen, st_utime_t timeout)
680 { 680 {
681 int n; 681 int n;
682 682
683 while ((n = recvfrom(fd->osfd, buf, len, 0, from, (socklen_t *)fromlen)) 683 while ((n = recvfrom(fd->osfd, buf, len, 0, from, (socklen_t *)fromlen))
684 - < 0) { 684 + < 0) {
685 if (errno == EINTR) 685 if (errno == EINTR)
686 continue; 686 continue;
687 if (!_IO_NOT_READY_ERROR) 687 if (!_IO_NOT_READY_ERROR)
@@ -696,7 +696,7 @@ int st_recvfrom(_st_netfd_t *fd, void *buf, int len, struct sockaddr *from, @@ -696,7 +696,7 @@ int st_recvfrom(_st_netfd_t *fd, void *buf, int len, struct sockaddr *from,
696 696
697 697
698 int st_sendto(_st_netfd_t *fd, const void *msg, int len, 698 int st_sendto(_st_netfd_t *fd, const void *msg, int len,
699 - const struct sockaddr *to, int tolen, st_utime_t timeout) 699 + const struct sockaddr *to, int tolen, st_utime_t timeout)
700 { 700 {
701 int n; 701 int n;
702 702
@@ -715,7 +715,7 @@ int st_sendto(_st_netfd_t *fd, const void *msg, int len, @@ -715,7 +715,7 @@ int st_sendto(_st_netfd_t *fd, const void *msg, int len,
715 715
716 716
717 int st_recvmsg(_st_netfd_t *fd, struct msghdr *msg, int flags, 717 int st_recvmsg(_st_netfd_t *fd, struct msghdr *msg, int flags,
718 - st_utime_t timeout) 718 + st_utime_t timeout)
719 { 719 {
720 int n; 720 int n;
721 721
@@ -734,7 +734,7 @@ int st_recvmsg(_st_netfd_t *fd, struct msghdr *msg, int flags, @@ -734,7 +734,7 @@ int st_recvmsg(_st_netfd_t *fd, struct msghdr *msg, int flags,
734 734
735 735
736 int st_sendmsg(_st_netfd_t *fd, const struct msghdr *msg, int flags, 736 int st_sendmsg(_st_netfd_t *fd, const struct msghdr *msg, int flags,
737 - st_utime_t timeout) 737 + st_utime_t timeout)
738 { 738 {
739 int n; 739 int n;
740 740
@@ -95,7 +95,7 @@ _st_md_cxt_save: @@ -95,7 +95,7 @@ _st_md_cxt_save:
95 ;; 95 ;;
96 stf.spill.nta [r8] = f2,32 96 stf.spill.nta [r8] = f2,32
97 stf.spill.nta [r9] = f3,32 97 stf.spill.nta [r9] = f3,32
98 - mov r15 = rp 98 + mov r15 = rp
99 ;; 99 ;;
100 stf.spill.nta [r8] = f4,32 100 stf.spill.nta [r8] = f4,32
101 stf.spill.nta [r9] = f5,32 101 stf.spill.nta [r9] = f5,32
@@ -143,7 +143,7 @@ _st_md_cxt_save: @@ -143,7 +143,7 @@ _st_md_cxt_save:
143 ;; 143 ;;
144 st8.nta [r2] = r18,16 // b2 144 st8.nta [r2] = r18,16 // b2
145 st8.nta [r3] = r19,16 // b3 145 st8.nta [r3] = r19,16 // b3
146 - mov r26 = ar.rsc 146 + mov r26 = ar.rsc
147 ;; 147 ;;
148 st8.nta [r2] = r20,16 // b4 148 st8.nta [r2] = r20,16 // b4
149 st8.nta [r3] = r21,16 // b5 149 st8.nta [r3] = r21,16 // b5
@@ -158,18 +158,18 @@ _st_md_cxt_save: @@ -158,18 +158,18 @@ _st_md_cxt_save:
158 st8.nta [r3] = in0,16 // &__jmp_buf (just in case) 158 st8.nta [r3] = in0,16 // &__jmp_buf (just in case)
159 ;; 159 ;;
160 st8.nta [r2] = r26 // ar.rsc 160 st8.nta [r2] = r26 // ar.rsc
161 - ;;  
162 - flushrs // flush dirty regs to backing store  
163 - ;;  
164 - and r27 = ~0x3,r26 // clear ar.rsc.mode  
165 - ;;  
166 - mov ar.rsc = r27 // put RSE in enforced lazy mode  
167 - ;;  
168 - mov r28 = ar.rnat  
169 - ;;  
170 - st8.nta [r3] = r28 // ar.rnat  
171 - mov ar.rsc = r26 // restore ar.rsc  
172 - ;; 161 + ;;
  162 + flushrs // flush dirty regs to backing store
  163 + ;;
  164 + and r27 = ~0x3,r26 // clear ar.rsc.mode
  165 + ;;
  166 + mov ar.rsc = r27 // put RSE in enforced lazy mode
  167 + ;;
  168 + mov r28 = ar.rnat
  169 + ;;
  170 + st8.nta [r3] = r28 // ar.rnat
  171 + mov ar.rsc = r26 // restore ar.rsc
  172 + ;;
173 mov r8 = 0 173 mov r8 = 0
174 br.ret.sptk.few b0 174 br.ret.sptk.few b0
175 .endp _st_md_cxt_save 175 .endp _st_md_cxt_save
@@ -183,31 +183,31 @@ _st_md_cxt_save: @@ -183,31 +183,31 @@ _st_md_cxt_save:
183 _st_md_cxt_restore: 183 _st_md_cxt_restore:
184 alloc r8 = ar.pfs,2,0,0,0 184 alloc r8 = ar.pfs,2,0,0,0
185 add r2 = 0x88,in0 // r2 <- &jmpbuf.ar_bsp 185 add r2 = 0x88,in0 // r2 <- &jmpbuf.ar_bsp
186 - mov r16 = ar.rsc  
187 - ;;  
188 - flushrs // flush dirty regs to backing store 186 + mov r16 = ar.rsc
  187 + ;;
  188 + flushrs // flush dirty regs to backing store
189 ;; 189 ;;
190 - and r17 = ~0x3,r16 // clear ar.rsc.mode  
191 - ;;  
192 - mov ar.rsc = r17 // put RSE in enforced lazy mode 190 + and r17 = ~0x3,r16 // clear ar.rsc.mode
  191 + ;;
  192 + mov ar.rsc = r17 // put RSE in enforced lazy mode
193 ;; 193 ;;
194 - invala // invalidate the ALAT  
195 - ;; 194 + invala // invalidate the ALAT
  195 + ;;
196 ld8 r23 = [r2],8 // r23 <- jmpbuf.ar_bsp 196 ld8 r23 = [r2],8 // r23 <- jmpbuf.ar_bsp
197 ;; 197 ;;
198 - mov ar.bspstore = r23 // write BSPSTORE 198 + mov ar.bspstore = r23 // write BSPSTORE
199 ld8 r25 = [r2],24 // r25 <- jmpbuf.ar_unat 199 ld8 r25 = [r2],24 // r25 <- jmpbuf.ar_unat
200 - ;;  
201 - ld8 r26 = [r2],-8 // r26 <- jmpbuf.ar_rnat 200 + ;;
  201 + ld8 r26 = [r2],-8 // r26 <- jmpbuf.ar_rnat
202 ;; 202 ;;
203 - mov ar.rnat = r26 // write RNAT  
204 - ld8 r27 = [r2] // r27 <- jmpbuf.ar_rsc  
205 - ;;  
206 - mov ar.rsc = r27 // write RSE control 203 + mov ar.rnat = r26 // write RNAT
  204 + ld8 r27 = [r2] // r27 <- jmpbuf.ar_rsc
  205 + ;;
  206 + mov ar.rsc = r27 // write RSE control
207 mov r2 = in0 207 mov r2 = in0
208 - ;;  
209 - mov ar.unat = r25 // write ar.unat  
210 - add r3 = 8,in0 208 + ;;
  209 + mov ar.unat = r25 // write ar.unat
  210 + add r3 = 8,in0
211 ;; 211 ;;
212 ld8.fill.nta sp = [r2],16 // r12 (sp) 212 ld8.fill.nta sp = [r2],16 // r12 (sp)
213 ld8.fill.nta gp = [r3],16 // r1 (gp) 213 ld8.fill.nta gp = [r3],16 // r1 (gp)
@@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
45 #include <errno.h> 45 #include <errno.h>
46 #include <poll.h> 46 #include <poll.h>
47 47
48 -#define ST_VERSION "1.9" 48 +#define ST_VERSION "1.9"
49 #define ST_VERSION_MAJOR 1 49 #define ST_VERSION_MAJOR 1
50 #define ST_VERSION_MINOR 9 50 #define ST_VERSION_MINOR 9
51 51
@@ -99,7 +99,7 @@ extern void st_thread_exit(void *retval); @@ -99,7 +99,7 @@ extern void st_thread_exit(void *retval);
99 extern int st_thread_join(st_thread_t thread, void **retvalp); 99 extern int st_thread_join(st_thread_t thread, void **retvalp);
100 extern void st_thread_interrupt(st_thread_t thread); 100 extern void st_thread_interrupt(st_thread_t thread);
101 extern st_thread_t st_thread_create(void *(*start)(void *arg), void *arg, 101 extern st_thread_t st_thread_create(void *(*start)(void *arg), void *arg,
102 - int joinable, int stack_size); 102 + int joinable, int stack_size);
103 extern int st_randomize_stacks(int on); 103 extern int st_randomize_stacks(int on);
104 extern int st_set_utime_function(st_utime_t (*func)(void)); 104 extern int st_set_utime_function(st_utime_t (*func)(void));
105 105
@@ -132,43 +132,43 @@ extern void st_netfd_free(st_netfd_t fd); @@ -132,43 +132,43 @@ extern void st_netfd_free(st_netfd_t fd);
132 extern int st_netfd_close(st_netfd_t fd); 132 extern int st_netfd_close(st_netfd_t fd);
133 extern int st_netfd_fileno(st_netfd_t fd); 133 extern int st_netfd_fileno(st_netfd_t fd);
134 extern void st_netfd_setspecific(st_netfd_t fd, void *value, 134 extern void st_netfd_setspecific(st_netfd_t fd, void *value,
135 - void (*destructor)(void *)); 135 + void (*destructor)(void *));
136 extern void *st_netfd_getspecific(st_netfd_t fd); 136 extern void *st_netfd_getspecific(st_netfd_t fd);
137 extern int st_netfd_serialize_accept(st_netfd_t fd); 137 extern int st_netfd_serialize_accept(st_netfd_t fd);
138 extern int st_netfd_poll(st_netfd_t fd, int how, st_utime_t timeout); 138 extern int st_netfd_poll(st_netfd_t fd, int how, st_utime_t timeout);
139 139
140 extern int st_poll(struct pollfd *pds, int npds, st_utime_t timeout); 140 extern int st_poll(struct pollfd *pds, int npds, st_utime_t timeout);
141 extern st_netfd_t st_accept(st_netfd_t fd, struct sockaddr *addr, int *addrlen, 141 extern st_netfd_t st_accept(st_netfd_t fd, struct sockaddr *addr, int *addrlen,
142 - st_utime_t timeout); 142 + st_utime_t timeout);
143 extern int st_connect(st_netfd_t fd, const struct sockaddr *addr, int addrlen, 143 extern int st_connect(st_netfd_t fd, const struct sockaddr *addr, int addrlen,
144 - st_utime_t timeout); 144 + st_utime_t timeout);
145 extern ssize_t st_read(st_netfd_t fd, void *buf, size_t nbyte, 145 extern ssize_t st_read(st_netfd_t fd, void *buf, size_t nbyte,
146 - st_utime_t timeout); 146 + st_utime_t timeout);
147 extern ssize_t st_read_fully(st_netfd_t fd, void *buf, size_t nbyte, 147 extern ssize_t st_read_fully(st_netfd_t fd, void *buf, size_t nbyte,
148 - st_utime_t timeout); 148 + st_utime_t timeout);
149 extern int st_read_resid(st_netfd_t fd, void *buf, size_t *resid, 149 extern int st_read_resid(st_netfd_t fd, void *buf, size_t *resid,
150 - st_utime_t timeout); 150 + st_utime_t timeout);
151 extern ssize_t st_readv(st_netfd_t fd, const struct iovec *iov, int iov_size, 151 extern ssize_t st_readv(st_netfd_t fd, const struct iovec *iov, int iov_size,
152 - st_utime_t timeout); 152 + st_utime_t timeout);
153 extern int st_readv_resid(st_netfd_t fd, struct iovec **iov, int *iov_size, 153 extern int st_readv_resid(st_netfd_t fd, struct iovec **iov, int *iov_size,
154 - st_utime_t timeout); 154 + st_utime_t timeout);
155 extern ssize_t st_write(st_netfd_t fd, const void *buf, size_t nbyte, 155 extern ssize_t st_write(st_netfd_t fd, const void *buf, size_t nbyte,
156 - st_utime_t timeout); 156 + st_utime_t timeout);
157 extern int st_write_resid(st_netfd_t fd, const void *buf, size_t *resid, 157 extern int st_write_resid(st_netfd_t fd, const void *buf, size_t *resid,
158 - st_utime_t timeout); 158 + st_utime_t timeout);
159 extern ssize_t st_writev(st_netfd_t fd, const struct iovec *iov, int iov_size, 159 extern ssize_t st_writev(st_netfd_t fd, const struct iovec *iov, int iov_size,
160 - st_utime_t timeout); 160 + st_utime_t timeout);
161 extern int st_writev_resid(st_netfd_t fd, struct iovec **iov, int *iov_size, 161 extern int st_writev_resid(st_netfd_t fd, struct iovec **iov, int *iov_size,
162 - st_utime_t timeout); 162 + st_utime_t timeout);
163 extern int st_recvfrom(st_netfd_t fd, void *buf, int len, 163 extern int st_recvfrom(st_netfd_t fd, void *buf, int len,
164 - struct sockaddr *from, int *fromlen,  
165 - st_utime_t timeout); 164 + struct sockaddr *from, int *fromlen,
  165 + st_utime_t timeout);
166 extern int st_sendto(st_netfd_t fd, const void *msg, int len, 166 extern int st_sendto(st_netfd_t fd, const void *msg, int len,
167 - const struct sockaddr *to, int tolen, st_utime_t timeout); 167 + const struct sockaddr *to, int tolen, st_utime_t timeout);
168 extern int st_recvmsg(st_netfd_t fd, struct msghdr *msg, int flags, 168 extern int st_recvmsg(st_netfd_t fd, struct msghdr *msg, int flags,
169 - st_utime_t timeout); 169 + st_utime_t timeout);
170 extern int st_sendmsg(st_netfd_t fd, const struct msghdr *msg, int flags, 170 extern int st_sendmsg(st_netfd_t fd, const struct msghdr *msg, int flags,
171 - st_utime_t timeout); 171 + st_utime_t timeout);
172 extern st_netfd_t st_open(const char *path, int oflags, mode_t mode); 172 extern st_netfd_t st_open(const char *path, int oflags, mode_t mode);
173 173
174 #ifdef DEBUG 174 #ifdef DEBUG
@@ -94,7 +94,7 @@ int st_poll(struct pollfd *pds, int npds, st_utime_t timeout) @@ -94,7 +94,7 @@ int st_poll(struct pollfd *pds, int npds, st_utime_t timeout)
94 /* Count the number of ready descriptors */ 94 /* Count the number of ready descriptors */
95 for (pd = pds; pd < epd; pd++) { 95 for (pd = pds; pd < epd; pd++) {
96 if (pd->revents) 96 if (pd->revents)
97 - n++; 97 + n++;
98 } 98 }
99 } 99 }
100 100
@@ -165,7 +165,7 @@ int st_init(void) @@ -165,7 +165,7 @@ int st_init(void)
165 * Create idle thread 165 * Create idle thread
166 */ 166 */
167 _st_this_vp.idle_thread = st_thread_create(_st_idle_thread_start, 167 _st_this_vp.idle_thread = st_thread_create(_st_idle_thread_start,
168 - NULL, 0, 0); 168 + NULL, 0, 0);
169 if (!_st_this_vp.idle_thread) 169 if (!_st_this_vp.idle_thread)
170 return -1; 170 return -1;
171 _st_this_vp.idle_thread->flags = _ST_FL_IDLE_THREAD; 171 _st_this_vp.idle_thread->flags = _ST_FL_IDLE_THREAD;
@@ -176,7 +176,7 @@ int st_init(void) @@ -176,7 +176,7 @@ int st_init(void)
176 * Initialize primordial thread 176 * Initialize primordial thread
177 */ 177 */
178 thread = (_st_thread_t *) calloc(1, sizeof(_st_thread_t) + 178 thread = (_st_thread_t *) calloc(1, sizeof(_st_thread_t) +
179 - (ST_KEYS_MAX * sizeof(void *))); 179 + (ST_KEYS_MAX * sizeof(void *)));
180 if (!thread) 180 if (!thread)
181 return -1; 181 return -1;
182 thread->private_data = (void **) (thread + 1); 182 thread->private_data = (void **) (thread + 1);
@@ -414,33 +414,33 @@ static void heap_delete(_st_thread_t *thread) { @@ -414,33 +414,33 @@ static void heap_delete(_st_thread_t *thread) {
414 _st_thread_t *y; /* The younger child */ 414 _st_thread_t *y; /* The younger child */
415 int index_tmp; 415 int index_tmp;
416 if (t->left == NULL) 416 if (t->left == NULL)
417 - break; 417 + break;
418 else if (t->right == NULL) 418 else if (t->right == NULL)
419 - y = t->left; 419 + y = t->left;
420 else if (t->left->due < t->right->due) 420 else if (t->left->due < t->right->due)
421 - y = t->left; 421 + y = t->left;
422 else 422 else
423 - y = t->right; 423 + y = t->right;
424 if (t->due > y->due) { 424 if (t->due > y->due) {
425 - _st_thread_t *tl = y->left;  
426 - _st_thread_t *tr = y->right;  
427 - *p = y;  
428 - if (y == t->left) {  
429 - y->left = t;  
430 - y->right = t->right;  
431 - p = &y->left;  
432 - } else {  
433 - y->left = t->left;  
434 - y->right = t;  
435 - p = &y->right;  
436 - }  
437 - t->left = tl;  
438 - t->right = tr;  
439 - index_tmp = t->heap_index;  
440 - t->heap_index = y->heap_index;  
441 - y->heap_index = index_tmp; 425 + _st_thread_t *tl = y->left;
  426 + _st_thread_t *tr = y->right;
  427 + *p = y;
  428 + if (y == t->left) {
  429 + y->left = t;
  430 + y->right = t->right;
  431 + p = &y->left;
  432 + } else {
  433 + y->left = t->left;
  434 + y->right = t;
  435 + p = &y->right;
  436 + }
  437 + t->left = tl;
  438 + t->right = tr;
  439 + index_tmp = t->heap_index;
  440 + t->heap_index = y->heap_index;
  441 + y->heap_index = index_tmp;
442 } else { 442 } else {
443 - break; 443 + break;
444 } 444 }
445 } 445 }
446 } 446 }
@@ -518,7 +518,7 @@ void st_thread_interrupt(_st_thread_t *thread) @@ -518,7 +518,7 @@ void st_thread_interrupt(_st_thread_t *thread)
518 518
519 519
520 _st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, 520 _st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg,
521 - int joinable, int stk_size) 521 + int joinable, int stk_size)
522 { 522 {
523 _st_thread_t *thread; 523 _st_thread_t *thread;
524 _st_stack_t *stack; 524 _st_stack_t *stack;
@@ -48,7 +48,7 @@ @@ -48,7 +48,7 @@
48 48
49 49
50 /* How much space to leave between the stacks, at each end */ 50 /* How much space to leave between the stacks, at each end */
51 -#define REDZONE _ST_PAGE_SIZE 51 +#define REDZONE _ST_PAGE_SIZE
52 52
53 _st_clist_t _st_free_stacks = ST_INIT_STATIC_CLIST(&_st_free_stacks); 53 _st_clist_t _st_free_stacks = ST_INIT_STATIC_CLIST(&_st_free_stacks);
54 int _st_num_free_stacks = 0; 54 int _st_num_free_stacks = 0;
@@ -143,7 +143,7 @@ int st_usleep(st_utime_t usecs) @@ -143,7 +143,7 @@ int st_usleep(st_utime_t usecs)
143 int st_sleep(int secs) 143 int st_sleep(int secs)
144 { 144 {
145 return st_usleep((secs >= 0) ? secs * (st_utime_t) 1000000LL : 145 return st_usleep((secs >= 0) ? secs * (st_utime_t) 1000000LL :
146 - ST_UTIME_NO_TIMEOUT); 146 + ST_UTIME_NO_TIMEOUT);
147 } 147 }
148 148
149 149
@@ -230,13 +230,13 @@ static int _st_cond_signal(_st_cond_t *cvar, int broadcast) @@ -230,13 +230,13 @@ static int _st_cond_signal(_st_cond_t *cvar, int broadcast)
230 thread = _ST_THREAD_WAITQ_PTR(q); 230 thread = _ST_THREAD_WAITQ_PTR(q);
231 if (thread->state == _ST_ST_COND_WAIT) { 231 if (thread->state == _ST_ST_COND_WAIT) {
232 if (thread->flags & _ST_FL_ON_SLEEPQ) 232 if (thread->flags & _ST_FL_ON_SLEEPQ)
233 - _ST_DEL_SLEEPQ(thread); 233 + _ST_DEL_SLEEPQ(thread);
234 234
235 /* Make thread runnable */ 235 /* Make thread runnable */
236 thread->state = _ST_ST_RUNNABLE; 236 thread->state = _ST_ST_RUNNABLE;
237 _ST_ADD_RUNQ(thread); 237 _ST_ADD_RUNQ(thread);
238 if (!broadcast) 238 if (!broadcast)
239 - break; 239 + break;
240 } 240 }
241 } 241 }
242 242