Subversion Repositories Kolibri OS

Rev

Rev 8514 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8315 superturbo 1
#include 
2
 
3
int socket(int domain, int type, int protocol)
4
{
5
    asm volatile(
6
    "int $0x40"
8536 superturbo 7
    :"=b"(errno)
8315 superturbo 8
    :"a"(75), "b"(0), "c"(domain), "d"(type), "S"(protocol)
9
    );
10
}
11
 
12
int close(int socket)
13
{
14
    asm volatile(
15
    "int $0x40"
8536 superturbo 16
    :"=b"(errno)
8315 superturbo 17
    :"a"(75), "b"(1), "c"(socket)
18
    );
19
}
8514 superturbo 20
int bind(int socket, const struct sockaddr *addres, int addres_len)
8315 superturbo 21
{
22
    asm volatile(
23
    "int $0x40"
8536 superturbo 24
    :"=b"(errno)
8315 superturbo 25
    :"a"(75), "b"(2), "c"(socket), "d"(addres), "S"(addres_len)
26
    );
27
}
28
 
29
int listen(int socket, int backlog)
30
{
31
    asm volatile(
32
    "int $0x40"
8536 superturbo 33
    :"=b"(errno)
8315 superturbo 34
    :"a"(75), "b"(3), "c"(socket), "d"(backlog)
35
    );
36
}
37
 
8514 superturbo 38
int connect(int socket,const struct sockaddr* address, int socket_len)
8315 superturbo 39
{
40
    asm volatile(
41
    "int $0x40"
8536 superturbo 42
    :"=b"(errno)
8315 superturbo 43
    :"a"(75), "b"(4), "c"(socket), "d"(address), "S"(socket_len)
44
    );
45
}
46
 
8514 superturbo 47
int accept(int socket, const struct sockaddr *address, int address_len)
8315 superturbo 48
{
49
    asm volatile(
50
    "int $0x40"
8536 superturbo 51
    :"=b"(errno)
8315 superturbo 52
    :"a"(75), "b"(5), "c"(socket), "d"(address), "S"(address_len)
53
    );
54
}
55
 
56
int send(int socket, const void *message, size_t msg_len, int flag)
57
{
58
    asm volatile(
59
    "int $0x40"
8536 superturbo 60
    :"=b"(errno)
8315 superturbo 61
    :"a"(75), "b"(6), "c"(socket), "d"(message), "S"(msg_len), "D"(flag)
62
    );
63
}
64
 
65
int recv(int socket, void *buffer, size_t buff_len, int flag)
66
{
67
    asm volatile(
68
    "int $0x40"
8536 superturbo 69
    :"=b"(errno)
8315 superturbo 70
    :"a"(75), "b"(7), "c"(socket), "d"(buffer), "S"(buff_len), "D"(flag)
71
    );
72
}
73
 
74
int setsockopt(int socket,const optstruct* opt)
75
{
76
    asm volatile(
77
        "int $0x40"
8536 superturbo 78
        :"=b"(errno)
8315 superturbo 79
        :"a"(75), "b"(8), "c"(socket),"d"(opt)
80
    );
81
}
82
 
83
int getsockopt(int socket, optstruct* opt)
84
{
85
    asm volatile(
86
        "int $0x40"
8536 superturbo 87
        :"=b"(errno)
8315 superturbo 88
        :"a"(75), "b"(9), "c"(socket),"d"(opt)
89
    );
90
}
91
 
8344 superturbo 92
int socketpair(int *sock1, int *sock2)
8315 superturbo 93
{
94
    asm volatile(
95
        "int $0x40"
8344 superturbo 96
        :"=b"(*sock2), "=a"(*sock1)
8317 superturbo 97
        :"a"(75), "b"(10)
8344 superturbo 98
    );
8536 superturbo 99
    errno = *sock2;
8344 superturbo 100
    return *sock1;
8315 superturbo 101
}