-
Notifications
You must be signed in to change notification settings - Fork 82
/
lthread.h
81 lines (67 loc) · 2.95 KB
/
lthread.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
lthread
(C) 2011 Hasan Alayli <halayli@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
lthread.h
*/
#ifndef _LTHREAD_H_
#define _LTHREAD_H_
#include <sys/socket.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <stdint.h>
#define DEFINE_LTHREAD (lthread_set_funcname(__func__))
#ifndef _LTHREAD_INT_H_
struct _lthread;
struct _lthread_cond;
typedef struct _lthread lthread_t;
typedef struct _lthread_cond lthread_cond_t;
#endif
char *lthread_summary();
int lthread_create(lthread_t **new_lt, void *fun, void *arg);
void lthread_destroy(lthread_t *lt);
void lthread_run(void);
int lthread_join(lthread_t *lt, void **ptr, uint64_t timeout);
void lthread_detach(void);
void lthread_sleep(uint64_t msecs);
void lthread_wakeup(lthread_t *lt);
int lthread_cond_create(lthread_cond_t **c);
int lthread_cond_wait(lthread_cond_t *c, uint64_t timeout);
void lthread_cond_signal(lthread_cond_t *c);
int lthread_init(size_t size);
void *lthread_get_data(void);
void lthread_set_data(void *data);
lthread_t *lthread_current();
/* socket related functions */
int lthread_socket(int, int, int);
int lthread_accept(int fd, struct sockaddr *, socklen_t *);
int lthread_close(int fd);
void lthread_set_funcname(const char *f);
uint64_t lthread_id();
int lthread_connect(int fd, struct sockaddr *, socklen_t, uint64_t timeout);
ssize_t lthread_recv(int fd, void * buf, size_t buf_len, int flags, uint64_t timeout);
ssize_t lthread_recv_exact(int fd, void * buf, size_t buf_len, int flags, uint64_t timeout);
ssize_t lthread_recvmsg(int fd, struct msghdr *message, int flags, uint64_t timeout);
ssize_t lthread_recvfrom(int fd, void *buffer, size_t length, int flags,
struct sockaddr *address, socklen_t *address_len, uint64_t timeout);
ssize_t lthread_send(int fd, const void *buf, size_t buf_len, int flags);
ssize_t lthread_sendmsg(int fd, const struct msghdr *message, int flags);
ssize_t lthread_sendto(int fd, const void *buffer, size_t length, int flags,
const struct sockaddr *dest_addr, socklen_t dest_len);
ssize_t lthread_writev(int fd, struct iovec *iov, int iovcnt);
#ifdef __FreeBSD__
int lthread_sendfile(int fd, int s, off_t offset, size_t nbytes, struct sf_hdtr *hdtr);
#endif
int lthread_compute_begin(void);
void lthread_compute_end(void);
#endif