From a61177b2aedb575fc36870b970630bce2de05287 Mon Sep 17 00:00:00 2001 From: superturbocat2001 Date: Fri, 15 Jan 2021 21:48:24 +0000 Subject: [PATCH] - Moved error codes to errno.h - Removed non-working files for compilation via gcc. git-svn-id: svn://kolibrios.org@8536 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/develop/ktcc/trunk/bin/lib/libck.a | Bin 135718 -> 135698 bytes .../libc/gcc compile programs/README.txt | 3 - .../trunk/libc/gcc compile programs/makefile | 22 ---- .../trunk/libc/gcc compile programs/start.asm | 102 ------------------ .../develop/ktcc/trunk/libc/include/errno.h | 40 ++++++- .../ktcc/trunk/libc/include/net/socket.h | 21 +--- .../develop/ktcc/trunk/libc/include/stdio.h | 27 +---- programs/develop/ktcc/trunk/libc/net/socket.c | 24 ++--- .../ktcc/trunk/samples/net/http_tcp_demo.c | 14 +-- .../ktcc/trunk/samples/net/tcpsrv_demo.c | 10 +- 10 files changed, 63 insertions(+), 200 deletions(-) delete mode 100644 programs/develop/ktcc/trunk/libc/gcc compile programs/README.txt delete mode 100644 programs/develop/ktcc/trunk/libc/gcc compile programs/makefile delete mode 100644 programs/develop/ktcc/trunk/libc/gcc compile programs/start.asm diff --git a/programs/develop/ktcc/trunk/bin/lib/libck.a b/programs/develop/ktcc/trunk/bin/lib/libck.a index f65f75c7075423d4f64bfbf28aa36dd2d2bc41fc..81cdd3484fbef225bab41d256915a10028700fb5 100644 GIT binary patch delta 1787 zcmcK2eMnVz7zgn0_o(^O+g&I-l=N!m9Jeb?E94@**b7mTWYiyP2qqbVmBrj2(Fx{X zW0Z8lW3MPkS;&Rkwd}>hUTosrh+bvQWiZUO*e+45T&q35opX2ZHH*gR!smR?^Zd^5 z<(_+wG$!n6OsL5<=44O)=Tn>na224pgryb(@0s!M2AM&?-2`Mc1D`Afa;ky3lY!hT zKwg?{;Q;V9RdV2v-7;4(cLKG^z&$>E0Tl(}7fz;|U~H)KwvJF@8y-L~F?KonzW!>OOY0A9#}UbTT*8W`I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ihApVUc<`( 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!='!') {