Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8535 → Rev 8536

/programs/develop/ktcc/trunk/libc/gcc compile programs/README.txt
File deleted
/programs/develop/ktcc/trunk/libc/gcc compile programs/start.asm
File deleted
/programs/develop/ktcc/trunk/libc/gcc compile programs/makefile
File deleted
/programs/develop/ktcc/trunk/libc/include/errno.h
1,6 → 1,42
#ifndef _ERRNO_H
#define _ERRNO_H
 
#include <stdio.h>
extern int errno;
/* errors codes from KOS, but minus */
# define E_SUCCESS (0)
# define E_UNSUPPORTED (-2)
# define E_UNKNOWNFS (-3)
# define E_NOTFOUND (-5)
# define E_EOF (-6)
# define E_INVALIDPTR (-7)
# define E_DISKFULL (-8)
# define E_FSYSERROR (-9)
# define E_ACCESS (-10)
# define E_HARDWARE (-11)
# define E_NOMEM (-12)
/* conversion errors */
# define ERANGE (-20)
# define EINVAL (-21)
/* program run and pipe errors */
# define E_NOMEM2 (-30)
# define E_FILEFMT (-31)
# define E_TOOMANY (-32)
# define E_PARAM (-33)
/* socket error codes*/
#define ENOBUFS 1
#define EINPROGRESS 2
#define EOPNOTSUPP 4
#define EWOULDBLOCK 6
#define ENOTCONN 9
#define EALREADY 10
#define EINVALUE 11
#define EMSGSIZE 12
#define ENOMEM 18
#define EADDRINUSE 20
#define ECONNREFUSED 61
#define ECONNRESET 52
#define EISCONN 56
#define ETIMEDOUT 60
#define ECONNABORTED 53
 
#endif
#endif
/programs/develop/ktcc/trunk/libc/include/net/socket.h
2,6 → 2,7
#define __SOCKET_H
 
#include <stddef.h>
#include <errno.h>
 
// Socket Types
#define SOCK_STREAM 1
53,27 → 54,7
//Socket options
#define SO_BINDTODEVICE (1<<9)
#define SO_NONBLOCK (1<<31)
 
// Error Codes
#define ENOBUFS 1
#define EINPROGRESS 2
#define EOPNOTSUPP 4
#define EWOULDBLOCK 6
#define ENOTCONN 9
#define EALREADY 10
#define EINVALUE 11
#define EMSGSIZE 12
#define ENOMEM 18
#define EADDRINUSE 20
#define ECONNREFUSED 61
#define ECONNRESET 52
#define EISCONN 56
#define ETIMEDOUT 60
#define ECONNABORTED 53
 
 
#define PORT(X) (X<<8)
extern int err_code;
 
#pragma pack(push,1)
struct sockaddr{
/programs/develop/ktcc/trunk/libc/include/stdio.h
2,6 → 2,7
#define stdio_h
 
#include "kolibrisys.h"
#include <errno.h>
#include <stdarg.h>
/* use stdarg.h
typedef char *va_list;
33,7 → 34,6
 
#define stderr ((FILE*)3) /* works only for fprintf!!! */
 
 
#define FILE_OPEN_READ 0
#define FILE_OPEN_WRITE 1
#define FILE_OPEN_APPEND 2
101,30 → 101,5
int tiny_vsnprintf (char * s, size_t n, const char * format, va_list args );
// support %c, %s, %d, %x, %u, %% for 32-bit values only. no width specs, left align
// always zero-ended
 
extern int errno;
/* errors codes from KOS, but minus */
#ifndef E_SUCCESS
 
# define E_SUCCESS (0)
# define E_UNSUPPORTED (-2)
# define E_UNKNOWNFS (-3)
# define E_NOTFOUND (-5)
# define E_EOF (-6)
# define E_INVALIDPTR (-7)
# define E_DISKFULL (-8)
# define E_FSYSERROR (-9)
# define E_ACCESS (-10)
# define E_HARDWARE (-11)
# define E_NOMEM (-12)
/* conversion errors */
# define ERANGE (-20)
# define EINVAL (-21)
/* program run and pipe errors */
# define E_NOMEM2 (-30)
# define E_FILEFMT (-31)
# define E_TOOMANY (-32)
# define E_PARAM (-33)
#endif
 
#endif
/programs/develop/ktcc/trunk/libc/net/socket.c
1,12 → 1,10
#include <net/socket.h>
 
int err_code=0;
 
int socket(int domain, int type, int protocol)
{
asm volatile(
"int $0x40"
:"=b"(err_code)
:"=b"(errno)
:"a"(75), "b"(0), "c"(domain), "d"(type), "S"(protocol)
);
}
15,7 → 13,7
{
asm volatile(
"int $0x40"
:"=b"(err_code)
:"=b"(errno)
:"a"(75), "b"(1), "c"(socket)
);
}
23,7 → 21,7
{
asm volatile(
"int $0x40"
:"=b"(err_code)
:"=b"(errno)
:"a"(75), "b"(2), "c"(socket), "d"(addres), "S"(addres_len)
);
}
32,7 → 30,7
{
asm volatile(
"int $0x40"
:"=b"(err_code)
:"=b"(errno)
:"a"(75), "b"(3), "c"(socket), "d"(backlog)
);
}
41,7 → 39,7
{
asm volatile(
"int $0x40"
:"=b"(err_code)
:"=b"(errno)
:"a"(75), "b"(4), "c"(socket), "d"(address), "S"(socket_len)
);
}
50,7 → 48,7
{
asm volatile(
"int $0x40"
:"=b"(err_code)
:"=b"(errno)
:"a"(75), "b"(5), "c"(socket), "d"(address), "S"(address_len)
);
}
59,7 → 57,7
{
asm volatile(
"int $0x40"
:"=b"(err_code)
:"=b"(errno)
:"a"(75), "b"(6), "c"(socket), "d"(message), "S"(msg_len), "D"(flag)
);
}
68,7 → 66,7
{
asm volatile(
"int $0x40"
:"=b"(err_code)
:"=b"(errno)
:"a"(75), "b"(7), "c"(socket), "d"(buffer), "S"(buff_len), "D"(flag)
);
}
77,7 → 75,7
{
asm volatile(
"int $0x40"
:"=b"(err_code)
:"=b"(errno)
:"a"(75), "b"(8), "c"(socket),"d"(opt)
);
}
86,7 → 84,7
{
asm volatile(
"int $0x40"
:"=b"(err_code)
:"=b"(errno)
:"a"(75), "b"(9), "c"(socket),"d"(opt)
);
}
98,6 → 96,6
:"=b"(*sock2), "=a"(*sock1)
:"a"(75), "b"(10)
);
err_code = *sock2;
errno = *sock2;
return *sock1;
}