diff --git a/programs/develop/ktcc/trunk/bin/lib/libck.a b/programs/develop/ktcc/trunk/bin/lib/libck.a index f65f75c707..81cdd3484f 100644 Binary files a/programs/develop/ktcc/trunk/bin/lib/libck.a and b/programs/develop/ktcc/trunk/bin/lib/libck.a differ diff --git a/programs/develop/ktcc/trunk/libc/gcc compile programs/README.txt b/programs/develop/ktcc/trunk/libc/gcc compile programs/README.txt deleted file mode 100644 index 2177efb488..0000000000 --- a/programs/develop/ktcc/trunk/libc/gcc compile programs/README.txt +++ /dev/null @@ -1,3 +0,0 @@ -В этом каталоге содержится 2 файла, необходимых для сборки программ для KolibriOS при помощи gcc. - -In this catalogue contains 2 files necessary for assembly of programs for KolibriOS with the help gcc. diff --git a/programs/develop/ktcc/trunk/libc/gcc compile programs/makefile b/programs/develop/ktcc/trunk/libc/gcc compile programs/makefile deleted file mode 100644 index 79397d5ec9..0000000000 --- a/programs/develop/ktcc/trunk/libc/gcc compile programs/makefile +++ /dev/null @@ -1,22 +0,0 @@ -OUTFILE = test.kex -INPUT = test.c -OUTPUT = test.o -OBJS = start.o test.o - - -.SUFFIXES: .asm .o - -$(OUTFILE) : $(OBJS) - fasm start.asm start.o - gcc -c $(INPUT) -nostdinc -m32 -I/home/andrew/kolibri/develop/include/ - ld -nostdlib -T kolibri.ld -n -m elf_i386 -L/home/andrew/kolibri/develop/lib/ -o $(OUTFILE) $(OBJS) -lck - objcopy $(OUTFILE) -O binary - -.asm.o: - fasm $*.asm - -.c.o: - gcc -c $*.c - -clean : - del *.o diff --git a/programs/develop/ktcc/trunk/libc/gcc compile programs/start.asm b/programs/develop/ktcc/trunk/libc/gcc compile programs/start.asm deleted file mode 100644 index b90ad4f909..0000000000 --- a/programs/develop/ktcc/trunk/libc/gcc compile programs/start.asm +++ /dev/null @@ -1,102 +0,0 @@ -format ELF - -section '.text' executable - -public start_ - -extrn main - -buf_len = 0x400 -max_parameters=0x20 - -start_: - db 'MENUET01' ; 1. Magic number (8 bytes) - dd 0x01 ; 2. Version of executable file - dd start__ ; 3. Start address - dd 0x0 ; 4. Size of image - dd 0x100000 ; 5. Size of needed memory - dd 0x100000 ; 6. Pointer to stack -hparams dd params ; 7. Pointer to program arguments -hpath dd path ; 8. Pointer to program path - - start__: - - ;init heap of memory - mov eax,68 - mov ebx,11 - int 0x40 - - mov ebx,path - mov ecx,dword buf_len - add ebx,ecx - - next_simbol_check: - xor eax,eax - mov al,[ebx] - cmp al,'/' - je simbol_fined - dec ebx - dec ecx - jnz next_simbol_check - - simbol_fined: - inc ebx - - mov [argc],dword 1 - mov edx,argv - mov [edx],ebx ;argument number 0 - program name - - cmp [params],byte 0 - je exit_find_params - - mov [argc],dword 2 - mov ebx,params - add edx,4 - mov [edx],ebx - - next_symbol_parse: - xor eax,eax - mov al,[ebx] - test al,al - jz exit_find_params - cmp al,' ' - je save_param - - inc ebx - jmp next_symbol_parse - save_param: - - mov [ebx],byte 0 - inc ebx - add edx,4 - mov [edx],ebx - inc [argc] - - cmp [argc],max_parameters - jae exit_find_params - - jmp next_symbol_parse - - exit_find_params: - - push argv - push [argc] - - call main -exit: - - xor eax,eax - dec eax - int 0x40 - dd -1 -crash: - jmp exit - -public params as '__argv' -public path as '__path' - -section '.bss' -argc rd 1 -argv rd max_parameters -path rb buf_len -params rb buf_len diff --git a/programs/develop/ktcc/trunk/libc/include/errno.h b/programs/develop/ktcc/trunk/libc/include/errno.h index b77b5f0c7b..5890ae5305 100644 --- a/programs/develop/ktcc/trunk/libc/include/errno.h +++ b/programs/develop/ktcc/trunk/libc/include/errno.h @@ -1,6 +1,42 @@ #ifndef _ERRNO_H #define _ERRNO_H -#include +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 \ No newline at end of file +#endif diff --git a/programs/develop/ktcc/trunk/libc/include/net/socket.h b/programs/develop/ktcc/trunk/libc/include/net/socket.h index e233b96841..8867fdaa9b 100644 --- a/programs/develop/ktcc/trunk/libc/include/net/socket.h +++ b/programs/develop/ktcc/trunk/libc/include/net/socket.h @@ -2,6 +2,7 @@ #define __SOCKET_H #include +#include // 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{ diff --git a/programs/develop/ktcc/trunk/libc/include/stdio.h b/programs/develop/ktcc/trunk/libc/include/stdio.h index 57183c9ab3..5fd83e151d 100644 --- a/programs/develop/ktcc/trunk/libc/include/stdio.h +++ b/programs/develop/ktcc/trunk/libc/include/stdio.h @@ -2,6 +2,7 @@ #define stdio_h #include "kolibrisys.h" +#include #include /* use stdarg.h typedef char *va_list; @@ -33,7 +34,6 @@ typedef struct { #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_snprintf (char * s, size_t n, const char * format, ... ); 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 diff --git a/programs/develop/ktcc/trunk/libc/net/socket.c b/programs/develop/ktcc/trunk/libc/net/socket.c index 495b8681f7..b05b8d8c91 100644 --- a/programs/develop/ktcc/trunk/libc/net/socket.c +++ b/programs/develop/ktcc/trunk/libc/net/socket.c @@ -1,12 +1,10 @@ #include -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 @@ int close(int socket) { asm volatile( "int $0x40" - :"=b"(err_code) + :"=b"(errno) :"a"(75), "b"(1), "c"(socket) ); } @@ -23,7 +21,7 @@ int bind(int socket, const struct sockaddr *addres, int addres_len) { asm volatile( "int $0x40" - :"=b"(err_code) + :"=b"(errno) :"a"(75), "b"(2), "c"(socket), "d"(addres), "S"(addres_len) ); } @@ -32,7 +30,7 @@ int listen(int socket, int backlog) { asm volatile( "int $0x40" - :"=b"(err_code) + :"=b"(errno) :"a"(75), "b"(3), "c"(socket), "d"(backlog) ); } @@ -41,7 +39,7 @@ int connect(int socket,const struct sockaddr* address, int socket_len) { asm volatile( "int $0x40" - :"=b"(err_code) + :"=b"(errno) :"a"(75), "b"(4), "c"(socket), "d"(address), "S"(socket_len) ); } @@ -50,7 +48,7 @@ int accept(int socket, const struct sockaddr *address, int address_len) { asm volatile( "int $0x40" - :"=b"(err_code) + :"=b"(errno) :"a"(75), "b"(5), "c"(socket), "d"(address), "S"(address_len) ); } @@ -59,7 +57,7 @@ int send(int socket, const void *message, size_t msg_len, int flag) { 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 @@ int recv(int socket, void *buffer, size_t buff_len, int flag) { 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 @@ int setsockopt(int socket,const optstruct* opt) { asm volatile( "int $0x40" - :"=b"(err_code) + :"=b"(errno) :"a"(75), "b"(8), "c"(socket),"d"(opt) ); } @@ -86,7 +84,7 @@ int getsockopt(int socket, optstruct* opt) { asm volatile( "int $0x40" - :"=b"(err_code) + :"=b"(errno) :"a"(75), "b"(9), "c"(socket),"d"(opt) ); } @@ -98,6 +96,6 @@ int socketpair(int *sock1, int *sock2) :"=b"(*sock2), "=a"(*sock1) :"a"(75), "b"(10) ); - err_code = *sock2; + errno = *sock2; return *sock1; } diff --git a/programs/develop/ktcc/trunk/samples/net/http_tcp_demo.c b/programs/develop/ktcc/trunk/samples/net/http_tcp_demo.c index 2764f91f5d..b0924ef9c8 100644 --- a/programs/develop/ktcc/trunk/samples/net/http_tcp_demo.c +++ b/programs/develop/ktcc/trunk/samples/net/http_tcp_demo.c @@ -35,22 +35,22 @@ int main() { puts("Connecting...\n"); if (connect(sock, addr_info->ai_addr, addr_info->ai_addrlen) != 0) { - printf("Connection failed, err_code = %d\n", err_code); - exit(err_code); + printf("Connection failed, errno = %d\n", errno); + exit(errno); } puts("Connected successfully\n"); puts("Sending request...\n"); if (send(sock, request, strlen(request), MSG_NOFLAG) == -1) { - printf("Sending failed, err_code = %d\n", err_code); - exit(err_code); + printf("Sending failed, errno = %d\n", errno); + exit(errno); } puts("Request sended successfully, waiting for response...\n"); char buf[512 + 1]; if (recv(sock, buf, 512, MSG_NOFLAG) == -1) { - printf("Receive failed, err_code = %d\n", err_code); - exit(err_code); + printf("Receive failed, errno = %d\n", errno); + exit(errno); } printf("Response = %s\n", buf); @@ -61,4 +61,4 @@ int main() { puts("\n goodbye)\n"); con_exit(0); return 0; -} \ No newline at end of file +} diff --git a/programs/develop/ktcc/trunk/samples/net/tcpsrv_demo.c b/programs/develop/ktcc/trunk/samples/net/tcpsrv_demo.c index 439b79f90e..405198ddae 100644 --- a/programs/develop/ktcc/trunk/samples/net/tcpsrv_demo.c +++ b/programs/develop/ktcc/trunk/samples/net/tcpsrv_demo.c @@ -11,18 +11,18 @@ int main() struct sockaddr addr={AF_INET4, PORT(23) , 0, 0}; int sk1=socket(AF_INET4, SOCK_STREAM, IPPROTO_TCP); - printf("Open socket: %d. Error: %d\n",sk1, err_code); + printf("Open socket: %d. Error: %d\n",sk1, errno); bind(sk1, &addr,sizeof(addr)); - printf("Socket binding. Error: %d\n", err_code); + printf("Socket binding. Error: %d\n", errno); listen(sk1, 1); - printf("Listening to a socket. Error: %d\n", err_code); + printf("Listening to a socket. Error: %d\n", errno); int sk2 = accept(sk1, &addr, sizeof(addr)); - printf("Accept done. Error: %d\n", err_code); + printf("Accept done. Error: %d\n", errno); send(sk2, msg1, strlen(msg1),MSG_NOFLAG); - printf("Send message: '%s' Error: %d\n", msg1, err_code); + printf("Send message: '%s' Error: %d\n", msg1, errno); puts("Received data:"); while(msg2!='!') {