正在显示
5 个修改的文件
包含
85 行增加
和
87 行删除
trunk/research/st/public.h
100644 → 100755
@@ -53,15 +53,15 @@ | @@ -53,15 +53,15 @@ | ||
53 | #define ST_SWITCH_CB | 53 | #define ST_SWITCH_CB |
54 | 54 | ||
55 | #ifndef ETIME | 55 | #ifndef ETIME |
56 | -#define ETIME ETIMEDOUT | 56 | + #define ETIME ETIMEDOUT |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | #ifndef ST_UTIME_NO_TIMEOUT | 59 | #ifndef ST_UTIME_NO_TIMEOUT |
60 | -#define ST_UTIME_NO_TIMEOUT ((st_utime_t) -1LL) | 60 | + #define ST_UTIME_NO_TIMEOUT ((st_utime_t) -1LL) |
61 | #endif | 61 | #endif |
62 | 62 | ||
63 | #ifndef ST_UTIME_NO_WAIT | 63 | #ifndef ST_UTIME_NO_WAIT |
64 | -#define ST_UTIME_NO_WAIT 0 | 64 | + #define ST_UTIME_NO_WAIT 0 |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #define ST_EVENTSYS_DEFAULT 0 | 67 | #define ST_EVENTSYS_DEFAULT 0 |
@@ -72,110 +72,108 @@ | @@ -72,110 +72,108 @@ | ||
72 | #ifdef __cplusplus | 72 | #ifdef __cplusplus |
73 | extern "C" { | 73 | extern "C" { |
74 | #endif | 74 | #endif |
75 | - | ||
76 | -typedef unsigned long long st_utime_t; | ||
77 | -typedef struct _st_thread * st_thread_t; | ||
78 | -typedef struct _st_cond * st_cond_t; | ||
79 | -typedef struct _st_mutex * st_mutex_t; | ||
80 | -typedef struct _st_netfd * st_netfd_t; | ||
81 | -#ifdef ST_SWITCH_CB | ||
82 | -typedef void (*st_switch_cb_t)(void); | ||
83 | -#endif | ||
84 | - | ||
85 | -extern int st_init(void); | ||
86 | -extern int st_getfdlimit(void); | ||
87 | - | ||
88 | -extern int st_set_eventsys(int eventsys); | ||
89 | -extern int st_get_eventsys(void); | ||
90 | -extern const char *st_get_eventsys_name(void); | ||
91 | - | ||
92 | -#ifdef ST_SWITCH_CB | ||
93 | -extern st_switch_cb_t st_set_switch_in_cb(st_switch_cb_t cb); | ||
94 | -extern st_switch_cb_t st_set_switch_out_cb(st_switch_cb_t cb); | ||
95 | -#endif | ||
96 | - | ||
97 | -extern st_thread_t st_thread_self(void); | ||
98 | -extern void st_thread_exit(void *retval); | ||
99 | -extern int st_thread_join(st_thread_t thread, void **retvalp); | ||
100 | -extern void st_thread_interrupt(st_thread_t thread); | ||
101 | -extern st_thread_t st_thread_create(void *(*start)(void *arg), void *arg, | 75 | + typedef unsigned long long st_utime_t; |
76 | + typedef struct _st_thread * st_thread_t; | ||
77 | + typedef struct _st_cond * st_cond_t; | ||
78 | + typedef struct _st_mutex * st_mutex_t; | ||
79 | + typedef struct _st_netfd * st_netfd_t; | ||
80 | + #ifdef ST_SWITCH_CB | ||
81 | + typedef void (*st_switch_cb_t)(void); | ||
82 | + #endif | ||
83 | + | ||
84 | + extern int st_init(void); | ||
85 | + extern int st_getfdlimit(void); | ||
86 | + | ||
87 | + extern int st_set_eventsys(int eventsys); | ||
88 | + extern int st_get_eventsys(void); | ||
89 | + extern const char *st_get_eventsys_name(void); | ||
90 | + | ||
91 | + #ifdef ST_SWITCH_CB | ||
92 | + extern st_switch_cb_t st_set_switch_in_cb(st_switch_cb_t cb); | ||
93 | + extern st_switch_cb_t st_set_switch_out_cb(st_switch_cb_t cb); | ||
94 | + #endif | ||
95 | + | ||
96 | + extern st_thread_t st_thread_self(void); | ||
97 | + extern void st_thread_exit(void *retval); | ||
98 | + extern int st_thread_join(st_thread_t thread, void **retvalp); | ||
99 | + extern void st_thread_interrupt(st_thread_t thread); | ||
100 | + extern st_thread_t st_thread_create(void *(*start)(void *arg), void *arg, | ||
102 | int joinable, int stack_size); | 101 | int joinable, int stack_size); |
103 | -extern int st_randomize_stacks(int on); | ||
104 | -extern int st_set_utime_function(st_utime_t (*func)(void)); | ||
105 | - | ||
106 | -extern st_utime_t st_utime(void); | ||
107 | -extern st_utime_t st_utime_last_clock(void); | ||
108 | -extern int st_timecache_set(int on); | ||
109 | -extern time_t st_time(void); | ||
110 | -extern int st_usleep(st_utime_t usecs); | ||
111 | -extern int st_sleep(int secs); | ||
112 | -extern st_cond_t st_cond_new(void); | ||
113 | -extern int st_cond_destroy(st_cond_t cvar); | ||
114 | -extern int st_cond_timedwait(st_cond_t cvar, st_utime_t timeout); | ||
115 | -extern int st_cond_wait(st_cond_t cvar); | ||
116 | -extern int st_cond_signal(st_cond_t cvar); | ||
117 | -extern int st_cond_broadcast(st_cond_t cvar); | ||
118 | -extern st_mutex_t st_mutex_new(void); | ||
119 | -extern int st_mutex_destroy(st_mutex_t lock); | ||
120 | -extern int st_mutex_lock(st_mutex_t lock); | ||
121 | -extern int st_mutex_unlock(st_mutex_t lock); | ||
122 | -extern int st_mutex_trylock(st_mutex_t lock); | ||
123 | - | ||
124 | -extern int st_key_create(int *keyp, void (*destructor)(void *)); | ||
125 | -extern int st_key_getlimit(void); | ||
126 | -extern int st_thread_setspecific(int key, void *value); | ||
127 | -extern void *st_thread_getspecific(int key); | ||
128 | - | ||
129 | -extern st_netfd_t st_netfd_open(int osfd); | ||
130 | -extern st_netfd_t st_netfd_open_socket(int osfd); | ||
131 | -extern void st_netfd_free(st_netfd_t fd); | ||
132 | -extern int st_netfd_close(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, | 102 | + extern int st_randomize_stacks(int on); |
103 | + extern int st_set_utime_function(st_utime_t (*func)(void)); | ||
104 | + | ||
105 | + extern st_utime_t st_utime(void); | ||
106 | + extern st_utime_t st_utime_last_clock(void); | ||
107 | + extern int st_timecache_set(int on); | ||
108 | + extern time_t st_time(void); | ||
109 | + extern int st_usleep(st_utime_t usecs); | ||
110 | + extern int st_sleep(int secs); | ||
111 | + extern st_cond_t st_cond_new(void); | ||
112 | + extern int st_cond_destroy(st_cond_t cvar); | ||
113 | + extern int st_cond_timedwait(st_cond_t cvar, st_utime_t timeout); | ||
114 | + extern int st_cond_wait(st_cond_t cvar); | ||
115 | + extern int st_cond_signal(st_cond_t cvar); | ||
116 | + extern int st_cond_broadcast(st_cond_t cvar); | ||
117 | + extern st_mutex_t st_mutex_new(void); | ||
118 | + extern int st_mutex_destroy(st_mutex_t lock); | ||
119 | + extern int st_mutex_lock(st_mutex_t lock); | ||
120 | + extern int st_mutex_unlock(st_mutex_t lock); | ||
121 | + extern int st_mutex_trylock(st_mutex_t lock); | ||
122 | + | ||
123 | + extern int st_key_create(int *keyp, void (*destructor)(void *)); | ||
124 | + extern int st_key_getlimit(void); | ||
125 | + extern int st_thread_setspecific(int key, void *value); | ||
126 | + extern void *st_thread_getspecific(int key); | ||
127 | + | ||
128 | + extern st_netfd_t st_netfd_open(int osfd); | ||
129 | + extern st_netfd_t st_netfd_open_socket(int osfd); | ||
130 | + extern void st_netfd_free(st_netfd_t fd); | ||
131 | + extern int st_netfd_close(st_netfd_t fd); | ||
132 | + extern int st_netfd_fileno(st_netfd_t fd); | ||
133 | + extern void st_netfd_setspecific(st_netfd_t fd, void *value, | ||
135 | void (*destructor)(void *)); | 134 | void (*destructor)(void *)); |
136 | -extern void *st_netfd_getspecific(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); | 135 | + extern void *st_netfd_getspecific(st_netfd_t fd); |
136 | + extern int st_netfd_serialize_accept(st_netfd_t fd); | ||
137 | + extern int st_netfd_poll(st_netfd_t fd, int how, st_utime_t timeout); | ||
139 | 138 | ||
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, | 139 | + extern int st_poll(struct pollfd *pds, int npds, st_utime_t timeout); |
140 | + extern st_netfd_t st_accept(st_netfd_t fd, struct sockaddr *addr, int *addrlen, | ||
142 | st_utime_t timeout); | 141 | st_utime_t timeout); |
143 | -extern int st_connect(st_netfd_t fd, const struct sockaddr *addr, int addrlen, | 142 | + extern int st_connect(st_netfd_t fd, const struct sockaddr *addr, int addrlen, |
144 | st_utime_t timeout); | 143 | st_utime_t timeout); |
145 | -extern ssize_t st_read(st_netfd_t fd, void *buf, size_t nbyte, | 144 | + extern ssize_t st_read(st_netfd_t fd, void *buf, size_t nbyte, |
146 | st_utime_t timeout); | 145 | st_utime_t timeout); |
147 | -extern ssize_t st_read_fully(st_netfd_t fd, void *buf, size_t nbyte, | 146 | + extern ssize_t st_read_fully(st_netfd_t fd, void *buf, size_t nbyte, |
148 | st_utime_t timeout); | 147 | st_utime_t timeout); |
149 | -extern int st_read_resid(st_netfd_t fd, void *buf, size_t *resid, | 148 | + extern int st_read_resid(st_netfd_t fd, void *buf, size_t *resid, |
150 | st_utime_t timeout); | 149 | st_utime_t timeout); |
151 | -extern ssize_t st_readv(st_netfd_t fd, const struct iovec *iov, int iov_size, | 150 | + extern ssize_t st_readv(st_netfd_t fd, const struct iovec *iov, int iov_size, |
152 | st_utime_t timeout); | 151 | st_utime_t timeout); |
153 | -extern int st_readv_resid(st_netfd_t fd, struct iovec **iov, int *iov_size, | 152 | + extern int st_readv_resid(st_netfd_t fd, struct iovec **iov, int *iov_size, |
154 | st_utime_t timeout); | 153 | st_utime_t timeout); |
155 | -extern ssize_t st_write(st_netfd_t fd, const void *buf, size_t nbyte, | 154 | + extern ssize_t st_write(st_netfd_t fd, const void *buf, size_t nbyte, |
156 | st_utime_t timeout); | 155 | st_utime_t timeout); |
157 | -extern int st_write_resid(st_netfd_t fd, const void *buf, size_t *resid, | 156 | + extern int st_write_resid(st_netfd_t fd, const void *buf, size_t *resid, |
158 | st_utime_t timeout); | 157 | st_utime_t timeout); |
159 | -extern ssize_t st_writev(st_netfd_t fd, const struct iovec *iov, int iov_size, | 158 | + extern ssize_t st_writev(st_netfd_t fd, const struct iovec *iov, int iov_size, |
160 | st_utime_t timeout); | 159 | st_utime_t timeout); |
161 | -extern int st_writev_resid(st_netfd_t fd, struct iovec **iov, int *iov_size, | 160 | + extern int st_writev_resid(st_netfd_t fd, struct iovec **iov, int *iov_size, |
162 | st_utime_t timeout); | 161 | st_utime_t timeout); |
163 | -extern int st_recvfrom(st_netfd_t fd, void *buf, int len, | 162 | + extern int st_recvfrom(st_netfd_t fd, void *buf, int len, |
164 | struct sockaddr *from, int *fromlen, | 163 | struct sockaddr *from, int *fromlen, |
165 | st_utime_t timeout); | 164 | st_utime_t timeout); |
166 | -extern int st_sendto(st_netfd_t fd, const void *msg, int len, | 165 | + extern int st_sendto(st_netfd_t fd, const void *msg, int len, |
167 | const struct sockaddr *to, int tolen, st_utime_t timeout); | 166 | const struct sockaddr *to, int tolen, st_utime_t timeout); |
168 | -extern int st_recvmsg(st_netfd_t fd, struct msghdr *msg, int flags, | 167 | + extern int st_recvmsg(st_netfd_t fd, struct msghdr *msg, int flags, |
169 | st_utime_t timeout); | 168 | st_utime_t timeout); |
170 | -extern int st_sendmsg(st_netfd_t fd, const struct msghdr *msg, int flags, | 169 | + extern int st_sendmsg(st_netfd_t fd, const struct msghdr *msg, int flags, |
171 | st_utime_t timeout); | 170 | st_utime_t timeout); |
172 | -extern st_netfd_t st_open(const char *path, int oflags, mode_t mode); | ||
173 | - | ||
174 | -#ifdef DEBUG | ||
175 | -extern void _st_show_thread_stack(st_thread_t thread, const char *messg); | ||
176 | -extern void _st_iterate_threads(void); | ||
177 | -#endif | 171 | + extern st_netfd_t st_open(const char *path, int oflags, mode_t mode); |
178 | 172 | ||
173 | + #ifdef DEBUG | ||
174 | + extern void _st_show_thread_stack(st_thread_t thread, const char *messg); | ||
175 | + extern void _st_iterate_threads(void); | ||
176 | + #endif | ||
179 | #ifdef __cplusplus | 177 | #ifdef __cplusplus |
180 | } | 178 | } |
181 | #endif | 179 | #endif |
-
请 注册 或 登录 后发表评论