/programs/develop/ktcc/trunk/bin/lib/libc.def |
---|
66,11 → 66,8 |
strtod |
__assert_fail |
;____STRING____ |
;memcpy |
memchr |
memcmp |
!memmove |
!memset |
strncat |
strchr |
strcat |
90,7 → 87,7 |
strstr |
strtok |
strxfrm |
_errno |
__errno |
;____SYS____ |
closedir |
opendir |
/programs/develop/ktcc/trunk/libc.obj/loader/__lib__.inc |
---|
File deleted |
/programs/develop/ktcc/trunk/libc.obj/loader/__lib__.asm.bak |
---|
File deleted |
/programs/develop/ktcc/trunk/libc.obj/.clang-format |
---|
0,0 → 1,6 |
# Format Style Options - Created with Clang Power Tools |
--- |
BasedOnStyle: WebKit |
AlignTrailingComments: true |
AlignConsecutiveMacros: true |
... |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/ktcc/trunk/libc.obj/include/assert.h |
---|
4,6 → 4,10 |
#include <stddef.h> |
#include <stdlib.h> |
#ifdef NDEBUG |
#define assert(x) (void)0 |
#else |
#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0))) |
#endif |
#endif // _ASSERT_H_ |
#endif // _ASSERT_H_ |
/programs/develop/ktcc/trunk/libc.obj/include/clayer/boxlib.h |
---|
3,9 → 3,9 |
#ifndef KOLIBRI_BOXLIB_H |
#define KOLIBRI_BOXLIB_H |
#include <stddef.h> |
#include <stdint.h> |
#include <sys/ksys.h> |
#include <stdint.h> |
#include <stddef.h> |
typedef unsigned color_t; |
int kolibri_boxlib_init(void); |
/programs/develop/ktcc/trunk/libc.obj/include/clayer/buf2d.h |
---|
1,9 → 1,9 |
#ifndef KOLIBRI_BUF2D_H |
#define KOLIBRI_BUF2D_H |
#include <stddef.h> |
#include <stdint.h> |
#include <sys/ksys.h> |
#include <stddef.h> |
typedef struct { |
unsigned int *buf_pointer; |
/programs/develop/ktcc/trunk/libc.obj/include/clayer/dialog.h |
---|
43,7 → 43,6 |
unsigned short y_start; |
}open_dialog __attribute__ ((__packed__)); |
typedef struct{ |
unsigned int type; |
char* procinfo; |
/programs/develop/ktcc/trunk/libc.obj/include/conio.h |
---|
1,5 → 1,4 |
/* |
This is adapded thunk for console.obj sys library |
.h is equal to svn:\programs\develop\libraries\console\console_en.txt |
/programs/develop/ktcc/trunk/libc.obj/include/errno.h |
---|
3,148 → 3,58 |
#include <stddef.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
#ifdef _BUILD_LIBC |
extern int _errno; |
#define errno _errno |
#define errno __errno |
extern int __errno; |
#else |
extern int* _errno; |
#define errno *_errno |
extern int* __errno; |
#define errno *__errno |
#endif |
#define EPERM 1 /* Operation not permitted */ |
#define ENOENT 2 /* No such file or directory */ |
#define ESRCH 3 /* No such process */ |
#define EINTR 4 /* Interrupted system call */ |
#define EIO 5 /* Input/output error */ |
#define ENXIO 6 /* Device not configured */ |
#define E2BIG 7 /* Argument list too long */ |
#define ENOEXEC 8 /* Exec format error */ |
#define EBADF 9 /* Bad file descriptor */ |
#define ECHILD 10 /* No child processes */ |
#define EDEADLK 11 /* Resource deadlock avoided */ |
/* 11 was EAGAIN */ |
#define ENOMEM 12 /* Cannot allocate memory */ |
#define EACCES 13 /* Permission denied */ |
#define EFAULT 14 /* Bad address */ |
#define ENOTBLK 15 /* Block device required */ |
#define EBUSY 16 /* Device / Resource busy */ |
#define EEXIST 17 /* File exists */ |
#define EXDEV 18 /* Cross-device link */ |
#define ENODEV 19 /* Operation not supported by device */ |
#define ENOTDIR 20 /* Not a directory */ |
#define EISDIR 21 /* Is a directory */ |
#define EINVAL 22 /* Invalid argument */ |
#define ENFILE 23 /* Too many open files in system */ |
#define EMFILE 24 /* Too many open files */ |
#define ENOTTY 25 /* Inappropriate ioctl for device */ |
#define ETXTBSY 26 /* Text file busy */ |
#define EFBIG 27 /* File too large */ |
#define ENOSPC 28 /* No space left on device */ |
#define ESPIPE 29 /* Illegal seek */ |
#define EROFS 30 /* Read-only file system */ |
#define EMLINK 31 /* Too many links */ |
#define EPIPE 32 /* Broken pipe */ |
#define ENOTSUP 2 // Function is not supported |
#define EUNKNFS 3 // Unknown file system |
#define ENOTFOUND 5 // File not found |
#define EEOF 6 // End of file |
#define EFAULT 7 // Pointer lies outside of application memory |
#define EDQUOT 8 // Disk is full |
#define EFS 9 // File system error |
#define EACCES 10 // Access denied |
#define EDEV 11 // Device error |
#define ENOMEMFS 12 // File system requires more memory |
/* math software */ |
#define EDOM 33 /* Numerical argument out of domain */ |
#define ERANGE 34 /* Result too large */ |
#define ENOMEM 30 // Not enough memory |
#define ENOEXEC 31 // Is not executable |
#define EPROCLIM 32 // Too many processes |
#define EINVAL 33 // Invalid argument |
/* non-blocking and interrupt i/o */ |
#define EAGAIN 35 /* Resource temporarily unavailable */ |
#define EWOULDBLOCK EAGAIN /* Operation would block */ |
#define EINPROGRESS 36 /* Operation now in progress */ |
#define EALREADY 37 /* Operation already in progress */ |
#define EDOM 50 // Numerical argument out of domain |
#define ERANGE 51 // Result too large |
#define EILSEQ 52 // Illegal byte sequence |
/* ipc/network software -- argument errors */ |
#define ENOTSOCK 38 /* Socket operation on non-socket */ |
#define EDESTADDRREQ 39 /* Destination address required */ |
#define EMSGSIZE 40 /* Message too long */ |
#define EPROTOTYPE 41 /* Protocol wrong type for socket */ |
#define ENOPROTOOPT 42 /* Protocol not available */ |
#define EPROTONOSUPPORT 43 /* Protocol not supported */ |
#define ESOCKTNOSUPPORT 44 /* Socket type not supported */ |
#define ENOTSUP 45 /* Operation not supported */ |
#define EOPNOTSUPP ENOTSUP /* Operation not supported on socket */ |
#define EPFNOSUPPORT 46 /* Protocol family not supported */ |
#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ |
#define EADDRINUSE 48 /* Address already in use */ |
#define EADDRNOTAVAIL 49 /* Can't assign requested address */ |
#define ENOBUFS 60 // Broken buffer |
#define EINPROGRESS 61 // Operation now in progress |
#define EOPNOTSUPP 62 // Operation not supported on transport endpoint |
#define EWOULDBLOCK 63 // Operation would block |
#define ENOTCONN 64 // Transport endpoint is not connected |
#define EALREADY 65 // Operation already in progress |
#define EMSGSIZE 66 // Message too long |
#define EADDRINUSE 67 // Address already in use |
#define ECONNREFUSED 68 // Connection refused |
#define ECONNRESET 69 // Connection reset by peer |
#define EISCONN 70 // Transport endpoint is already connected |
#define ETIMEDOUT 71 // Connection timed out |
#define ECONNABORTED 72 // Software caused connection abort |
/* ipc/network software -- operational errors */ |
#define ENETDOWN 50 /* Network is down */ |
#define ENETUNREACH 51 /* Network is unreachable */ |
#define ENETRESET 52 /* Network dropped connection on reset */ |
#define ECONNABORTED 53 /* Software caused connection abort */ |
#define ECONNRESET 54 /* Connection reset by peer */ |
#define ENOBUFS 55 /* No buffer space available */ |
#define EISCONN 56 /* Socket is already connected */ |
#define ENOTCONN 57 /* Socket is not connected */ |
#define ESHUTDOWN 58 /* Can't send after socket shutdown */ |
#define ETOOMANYREFS 59 /* Too many references: can't splice */ |
#define ETIMEDOUT 60 /* Operation timed out */ |
#define ECONNREFUSED 61 /* Connection refused */ |
#define ELOOP 62 /* Too many levels of symbolic links */ |
#define ENAMETOOLONG 63 /* File name too long */ |
/* |
* UNIX-like errno |
* Will be removed after changing STDIO. |
*/ |
/* should be rearranged */ |
#define EHOSTDOWN 64 /* Host is down */ |
#define EHOSTUNREACH 65 /* No route to host */ |
#define ENOTEMPTY 66 /* Directory not empty */ |
#define ENOTDIR 80 |
#define EBADF 81 |
#define EIO 82 |
#define EISDIR 83 |
#define ENOENT 84 |
#define EOVERFLOW 85 |
/* quotas & mush */ |
#define EPROCLIM 67 /* Too many processes */ |
#define EUSERS 68 /* Too many users */ |
#define EDQUOT 69 /* Disc quota exceeded */ |
/* Network File System */ |
#define ESTALE 70 /* Stale NFS file handle */ |
#define EREMOTE 71 /* Too many levels of remote in path */ |
#define EBADRPC 72 /* RPC struct is bad */ |
#define ERPCMISMATCH 73 /* RPC version wrong */ |
#define EPROGUNAVAIL 74 /* RPC prog. not avail */ |
#define EPROGMISMATCH 75 /* Program version wrong */ |
#define EPROCUNAVAIL 76 /* Bad procedure for program */ |
#define ENOLCK 77 /* No locks available */ |
#define ENOSYS 78 /* Function not implemented */ |
#define EFTYPE 79 /* Inappropriate file type or format */ |
#define EAUTH 80 /* Authentication error */ |
#define ENEEDAUTH 81 /* Need authenticator */ |
/* Intelligent device errors */ |
#define EPWROFF 82 /* Device power is off */ |
#define EDEVERR 83 /* Device error, e.g. paper out */ |
#define EOVERFLOW 84 /* Value too large to be stored in data type */ |
/* Program loading errors */ |
#define EBADEXEC 85 /* Bad executable */ |
#define EBADARCH 86 /* Bad CPU type in executable */ |
#define ESHLIBVERS 87 /* Shared library version mismatch */ |
#define EBADMACHO 88 /* Malformed Macho file */ |
#define ECANCELED 89 /* Operation canceled */ |
#define EIDRM 90 /* Identifier removed */ |
#define ENOMSG 91 /* No message of desired type */ |
#define EILSEQ 92 /* Illegal byte sequence */ |
#define ENOATTR 93 /* Attribute not found */ |
#define EBADMSG 94 /* Bad message */ |
#define EMULTIHOP 95 /* Reserved */ |
#define ENODATA 96 /* No message available on STREAM */ |
#define ENOLINK 97 /* Reserved */ |
#define ENOSR 98 /* No STREAM resources */ |
#define ENOSTR 99 /* Not a STREAM */ |
#define EPROTO 100 /* Protocol error */ |
#define ETIME 101 /* STREAM ioctl timeout */ |
#define ENOPOLICY 103 /* No such policy registered */ |
#define ENOTRECOVERABLE 104 /* State not recoverable */ |
#define EOWNERDEAD 105 /* Previous owner died */ |
#define EQFULL 106 /* Interface output queue is full */ |
#define ELAST 106 /* Must be equal largest errno */ |
#ifdef __cplusplus |
} |
#endif |
#endif // _ERRNO_H_ |
/programs/develop/ktcc/trunk/libc.obj/include/limits.h |
---|
32,7 → 32,6 |
#define LONG_LONG_MAX LLONG_MAX |
#define ULONG_LONG_MAX ULLONG_MAX |
#ifndef ARG_MAX |
#define ARG_MAX 4096 |
#endif |
/programs/develop/ktcc/trunk/libc.obj/include/math.h |
---|
6,10 → 6,6 |
#include <stddef.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
extern double _FUNC(acos)(double _x); |
extern double _FUNC(asin)(double _x); |
extern double _FUNC(atan)(double _x); |
32,6 → 28,13 |
extern double _FUNC(sqrt)(double _x); |
extern double _FUNC(tan)(double _x); |
extern double _FUNC(tanh)(double _x); |
extern double _FUNC(acosh)(double); |
extern double _FUNC(asinh)(double); |
extern double _FUNC(atanh)(double); |
extern double _FUNC(hypot)(double, double); |
extern long double _FUNC(modfl)(long double _x, long double* _pint); |
extern double _FUNC(pow10)(double _x); |
extern double _FUNC(pow2)(double _x); |
#define M_E 2.7182818284590452354 |
#define M_LOG2E 1.4426950408889634074 |
49,26 → 52,6 |
#define PI M_PI |
#define PI2 M_PI_2 |
extern double _FUNC(acosh)(double); |
extern double _FUNC(asinh)(double); |
extern double _FUNC(atanh)(double); |
extern double _FUNC(cbrt)(double); |
extern double _FUNC(exp10)(double _x); |
extern double _FUNC(exp2)(double _x); |
extern double _FUNC(expm1)(double); |
extern double _FUNC(hypot)(double, double); |
extern double _FUNC(log1p)(double); |
extern double _FUNC(log2)(double _x); |
extern long double _FUNC(modfl)(long double _x, long double *_pint); |
extern double _FUNC(pow10)(double _x); |
extern double _FUNC(pow2)(double _x); |
extern double _FUNC(powi)(double, int); |
extern void _FUNC(sincos)(double, double *, double *); |
/* These are in libm.a (Cygnus). You must link -lm to get these */ |
/* See libm/math.h for comments */ |
#ifndef __cplusplus |
struct exception { |
int type; |
const char *name; |
77,95 → 60,5 |
double retval; |
int err; |
}; |
#endif |
extern double _FUNC(erf)(double); |
extern double _FUNC(erfc)(double); |
extern double _FUNC(gamma)(double); |
extern int _FUNC(isinf)(double); |
extern int _FUNC(isnan)(double); |
extern int _FUNC(finite)(double); |
extern double _FUNC(j0)(double); |
extern double _FUNC(j1)(double); |
extern double _FUNC(jn)(int, double); |
extern double _FUNC(lgamma)(double); |
extern double _FUNC(nan)(const char*); |
extern double _FUNC(y0)(double); |
extern double _FUNC(y1)(double); |
extern double _FUNC(yn)(int, double); |
extern double _FUNC(logb)(double); |
extern double _FUNC(nextafter)(double, double); |
extern double _FUNC(remainder)(double, double); |
extern double _FUNC(scalb)(double, double); |
#ifndef __cplusplus |
extern int _FUNC(matherr)(struct exception *); |
#endif |
extern double _FUNC(significand)(double); |
extern double _FUNC(copysign)(double, double); |
extern int _FUNC(ilogb)(double); |
extern double _FUNC(rint)(double); |
extern double _FUNC(scalbn)(double, int); |
extern double _FUNC(drem)(double, double); |
extern double _FUNC(gamma_r)(double, int *); |
extern double _FUNC(lgamma_r)(double, int *); |
extern float _FUNC(acosf)(float); |
extern float _FUNC(asinf)(float); |
extern float _FUNC(atanf)(float); |
extern float _FUNC(atan2f)(float, float); |
extern float _FUNC(cosf)(float); |
extern float _FUNC(sinf)(float); |
extern float _FUNC(tanf)(float); |
extern float _FUNC(coshf)(float); |
extern float _FUNC(sinhf)(float); |
extern float _FUNC(tanhf)(float); |
extern float _FUNC(expf)(float); |
extern float _FUNC(frexpf)(float, int *); |
extern float _FUNC(ldexpf)(float, int); |
extern float _FUNC(logf)(float); |
extern float _FUNC(log10f)(float); |
extern float _FUNC(modff)(float, float *); |
extern float _FUNC(powf)(float, float); |
extern float _FUNC(sqrtf)(float); |
extern float _FUNC(ceilf)(float); |
extern float _FUNC(fabsf)(float); |
extern float _FUNC(floorf)(float); |
extern float _FUNC(fmodf)(float, float); |
extern float _FUNC(erff)(float); |
extern float _FUNC(erfcf)(float); |
extern float _FUNC(gammaf)(float); |
extern float _FUNC(hypotf)(float, float); |
extern int _FUNC(isinff)(float); |
extern int _FUNC(isnanf)(float); |
extern int _FUNC(finitef)(float); |
extern float _FUNC(j0f)(float); |
extern float _FUNC(j1f)(float); |
extern float _FUNC(jnf)(int, float); |
extern float _FUNC(lgammaf)(float); |
extern float _FUNC(nanf)(const char*); |
extern float _FUNC(y0f)(float); |
extern float _FUNC(y1f)(float); |
extern float _FUNC(ynf)(int, float); |
extern float _FUNC(acoshf)(float); |
extern float _FUNC(asinhf)(float); |
extern float _FUNC(atanhf)(float); |
extern float _FUNC(cbrtf)(float); |
extern float _FUNC(logbf)(float); |
extern float _FUNC(nextafterf)(float, float); |
extern float _FUNC(remainderf)(float, float); |
extern float _FUNC(scalbf)(float, float); |
extern float _FUNC(significandf)(float); |
extern float _FUNC(copysignf)(float, float); |
extern int _FUNC(ilogbf)(float); |
extern float _FUNC(rintf)(float); |
extern float _FUNC(scalbnf)(float, int); |
extern float _FUNC(dremf)(float, float); |
extern float _FUNC(expm1f)(float); |
extern float _FUNC(log1pf)(float); |
extern float _FUNC(gammaf_r)(float, int *); |
extern float _FUNC(lgammaf_r)(float, int *); |
#ifdef __cplusplus |
} |
#endif |
#endif /* _MATH_H_ */ |
/programs/develop/ktcc/trunk/libc.obj/include/shell_api.h |
---|
20,7 → 20,9 |
extern int __shell_is_init; |
extern void __shell_init(); |
#define __SHELL_WAIT() while (*__shell_shm) _ksys_delay(5) |
#define __SHELL_WAIT() \ |
while (*__shell_shm) \ |
_ksys_delay(5) |
extern int shell_ping(); |
extern unsigned shell_get_pid(); |
/programs/develop/ktcc/trunk/libc.obj/include/stdarg.h |
---|
3,75 → 3,14 |
#include <stddef.h> |
#ifdef __x86_64__ |
#ifndef _WIN64 |
//This should be in sync with the declaration on our lib/libtcc1.c |
/* GCC compatible definition of va_list. */ |
typedef struct { |
unsigned int gp_offset; |
unsigned int fp_offset; |
union { |
unsigned int overflow_offset; |
char *overflow_arg_area; |
}; |
char *reg_save_area; |
} __va_list_struct; |
typedef __va_list_struct va_list[1]; |
extern void _FUNC(__va_start)(__va_list_struct *ap, void *fp); |
extern void* _FUNC(__va_arg)(__va_list_struct *ap, int arg_type, int size, int align); |
#define va_start(ap, last) __va_start(ap, __builtin_frame_address(0)) |
#define va_arg(ap, type) \ |
(*(type *)(__va_arg(ap, __builtin_va_arg_types(type), sizeof(type), __alignof__(type)))) |
#define va_copy(dest, src) (*(dest) = *(src)) |
#define va_end(ap) |
#else /* _WIN64 */ |
typedef char *va_list; |
#define va_start(ap,last) __builtin_va_start(ap,last) |
#define va_arg(ap,type) (ap += 8, sizeof(type)<=8 ? *(type*)ap : **(type**)ap) |
#define va_copy(dest, src) ((dest) = (src)) |
#define va_end(ap) |
#endif |
#elif __arm__ |
typedef char *va_list; |
#define _tcc_alignof(type) ((int)&((struct {char c;type x;} *)0)->x) |
#define _tcc_align(addr,type) (((unsigned)addr + _tcc_alignof(type) - 1) \ |
& ~(_tcc_alignof(type) - 1)) |
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3) |
#define va_arg(ap,type) (ap = (void *) ((_tcc_align(ap,type)+sizeof(type)+3) \ |
&~3), *(type *)(ap - ((sizeof(type)+3)&~3))) |
#define va_copy(dest, src) (dest) = (src) |
#define va_end(ap) |
#elif defined(__aarch64__) |
typedef struct { |
void *__stack; |
void *__gr_top; |
void *__vr_top; |
int __gr_offs; |
int __vr_offs; |
} va_list; |
#define va_start(ap, last) __va_start(ap, last) |
#define va_arg(ap, type) __va_arg(ap, type) |
#define va_end(ap) |
#define va_copy(dest, src) ((dest) = (src)) |
#else /* __i386__ */ |
typedef char *va_list; |
/* only correct for i386 */ |
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3) |
#define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3))) |
#define va_copy(dest, src) (dest) = (src) |
#define va_end(ap) |
#endif |
/* fix a buggy dependency on GCC in libio.h */ |
typedef va_list __gnuc_va_list; |
#define _VA_LIST_DEFINED |
#endif /* _STDARG_H */ |
#endif /* _STDARG_H */ |
/programs/develop/ktcc/trunk/libc.obj/include/stddef.h |
---|
8,20 → 8,6 |
typedef __PTRDIFF_TYPE__ intptr_t; |
typedef __SIZE_TYPE__ uintptr_t; |
#ifndef __int8_t_defined |
#define __int8_t_defined |
typedef signed char int8_t; |
typedef signed short int int16_t; |
typedef signed int int32_t; |
typedef signed long long int int64_t; |
typedef unsigned char uint8_t; |
typedef unsigned short int uint16_t; |
typedef unsigned int uint32_t; |
typedef unsigned long long int uint64_t; |
typedef int64_t intmax_t; |
typedef uint64_t uintmax_t; |
#endif |
#ifndef NULL |
#define NULL ((void*)0) |
#endif |
/programs/develop/ktcc/trunk/libc.obj/include/stdint.h |
---|
15,18 → 15,22 |
#define INT32_MAX (2147483647L) |
#define UINT32_MAX (4294967295UL) |
#if __have_long64 |
#define INT64_MIN (-9223372036854775807L-1L) |
#define INT64_MAX (9223372036854775807L) |
#define UINT64_MAX (18446744073709551615U) |
#elif __have_longlong64 |
#define INT64_MIN (-9223372036854775807LL-1LL) |
#define INT64_MAX (9223372036854775807LL) |
#define UINT64_MAX (18446744073709551615ULL) |
#else |
#define INT64_MAX 0x7fffffffffffffffLL |
#define INT64_MIN (-INT64_MAX - 1LL) |
#define UINT64_MAX (__CONCAT(INT64_MAX, U) * 2ULL + 1ULL) |
#ifndef __int8_t_defined |
#define __int8_t_defined |
typedef signed char int8_t; |
typedef signed short int int16_t; |
typedef signed int int32_t; |
typedef signed long long int int64_t; |
typedef unsigned char uint8_t; |
typedef unsigned short int uint16_t; |
typedef unsigned int uint32_t; |
typedef unsigned long long int uint64_t; |
typedef int64_t intmax_t; |
typedef uint64_t uintmax_t; |
#endif |
#define SIZE_MAX UINT32_MAX |
/programs/develop/ktcc/trunk/libc.obj/include/stdlib.h |
---|
11,15 → 11,6 |
#define min(a, b) ((a)<(b) ? (a) : (b)) |
#define max(a, b) ((a)>(b) ? (a) : (b)) |
extern int _FUNC(atoi)(const char *s); |
extern long _FUNC(atol)(const char *); |
extern long long _FUNC(atoll)(const char *); |
extern void _FUNC(itoa)(int n, char* s); |
extern int _FUNC(abs)(int); |
extern long _FUNC(labs)(long); |
extern long long _FUNC(llabs)(long long); |
typedef struct { |
int quot; |
int rem; |
35,18 → 26,18 |
long long rem; |
} lldiv_t; |
static inline |
div_t div(int num, int den) { |
static inline div_t div(int num, int den) |
{ |
return (div_t){ num/den, num%den }; |
} |
static inline |
ldiv_t ldiv(long num, long den) { |
static inline ldiv_t ldiv(long num, long den) |
{ |
return (ldiv_t){ num/den, num%den }; |
} |
static inline |
lldiv_t lldiv(long long num, long long den) { |
static inline lldiv_t lldiv(long long num, long long den) |
{ |
return (lldiv_t){ num/den, num%den }; |
} |
68,4 → 59,13 |
extern double _FUNC(strtod)(const char *s, char **sret); |
extern double _FUNC(atof)(const char *ascii); |
extern int _FUNC(atoi)(const char* s); |
extern long _FUNC(atol)(const char*); |
extern long long _FUNC(atoll)(const char*); |
extern void _FUNC(itoa)(int n, char* s); |
extern int _FUNC(abs)(int); |
extern long _FUNC(labs)(long); |
extern long long _FUNC(llabs)(long long); |
#endif |
/programs/develop/ktcc/trunk/libc.obj/include/string.h |
---|
1,35 → 1,10 |
/* String handling <string.h> |
This file is part of the Public Domain C Library (PDCLib). |
Permission is granted to use, modify, and / or redistribute at will. |
*/ |
#ifndef _STRING_H_ |
#define _STRING_H_ |
#include <stddef.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* String function conventions */ |
/* |
In any of the following functions taking a size_t n to specify the length of |
an array or size of a memory region, n may be 0, but the pointer arguments to |
the call shall still be valid unless otherwise stated. |
*/ |
/* Copying functions */ |
extern void* _FUNC(memccpy)(void *restrict dest, const void *restrict src, int c, size_t n); |
/* Copy a number of n characters from the memory area pointed to by s2 to the |
area pointed to by s1. If the two areas overlap, behaviour is undefined. |
Returns the value of s1. |
*/ |
#ifdef __TINYC__ |
extern void* memcpy(void* s1, const void* s2, size_t n); |
extern void* memset(void* s, int c, size_t n); |
40,142 → 15,26 |
extern void* _FUNC(memmove)(void* s1, const void* s2, size_t n); |
#endif |
/* Copy the character array s2 (including terminating '\0' byte) into the |
character array s1. |
Returns the value of s1. |
*/ |
extern char* _FUNC(strcpy)(char* s1, const char* s2); |
/* Copy a maximum of n characters from the character array s2 into the character |
array s1. If s2 is shorter than n characters, '\0' bytes will be appended to |
the copy in s1 until n characters have been written. If s2 is longer than n |
characters, NO terminating '\0' will be written to s1. If the arrays overlap, |
behaviour is undefined. |
Returns the value of s1. |
*/ |
extern char* _FUNC(strncpy)(char* s1, const char* s2, size_t n); |
/* Concatenation functions */ |
/* Append the contents of the character array s2 (including terminating '\0') to |
the character array s1 (first character of s2 overwriting the '\0' of s1). If |
the arrays overlap, behaviour is undefined. |
Returns the value of s1. |
*/ |
extern char* _FUNC(strcat)(char* s1, const char* s2); |
/* Append a maximum of n characters from the character array s2 to the character |
array s1 (first character of s2 overwriting the '\0' of s1). A terminating |
'\0' is ALWAYS appended, even if the full n characters have already been |
written. If the arrays overlap, behaviour is undefined. |
Returns the value of s1. |
*/ |
extern char* _FUNC(strncat)(char* s1, const char* s2, size_t n); |
/* Comparison functions */ |
/* Compare the first n characters of the memory areas pointed to by s1 and s2. |
Returns 0 if s1 == s2, a negative number if s1 < s2, and a positive number if |
s1 > s2. |
*/ |
extern int _FUNC(memcmp)(const void * s1, const void* s2, size_t n); |
/* Compare the character arrays s1 and s2. |
Returns 0 if s1 == s2, a negative number if s1 < s2, and a positive number if |
s1 > s2. |
*/ |
extern int _FUNC(strcmp)(const char * s1, const char* s2); |
/* Compare the character arrays s1 and s2, interpreted as specified by the |
LC_COLLATE category of the current locale. |
Returns 0 if s1 == s2, a negative number if s1 < s2, and a positive number if |
s1 > s2. |
TODO: Currently a dummy wrapper for strcmp() as PDCLib does not yet support |
locales. |
*/ |
extern int _FUNC(strcoll)(const char* s1, const char* s2); |
/* Compare no more than the first n characters of the character arrays s1 and |
s2. |
Returns 0 if s1 == s2, a negative number if s1 < s2, and a positive number if |
s1 > s2. |
*/ |
extern int _FUNC(strncmp)(const char* s1, const char* s2, size_t n); |
/* Transform the character array s2 as appropriate for the LC_COLLATE setting of |
the current locale. If length of resulting string is less than n, store it in |
the character array pointed to by s1. Return the length of the resulting |
string. |
*/ |
extern size_t _FUNC(strxfrm)(char* s1, const char* s2, size_t n); |
/* Search functions */ |
/* Search the first n characters in the memory area pointed to by s for the |
character c (interpreted as unsigned char). |
Returns a pointer to the first instance found, or NULL. |
*/ |
extern void* _FUNC(memchr)(const void* s, int c, size_t n); |
/* Search the character array s (including terminating '\0') for the character c |
(interpreted as char). |
Returns a pointer to the first instance found, or NULL. |
*/ |
extern char* _FUNC(strchr)(const char* s, int c); |
/* Determine the length of the initial substring of character array s1 which |
consists only of characters not from the character array s2. |
Returns the length of that substring. |
*/ |
extern size_t _FUNC(strcspn)(const char* s1, const char* s2); |
/* Search the character array s1 for any character from the character array s2. |
Returns a pointer to the first occurrence, or NULL. |
*/ |
extern char* _FUNC(strpbrk)(const char* s1, const char* s2); |
/* Search the character array s (including terminating '\0') for the character c |
(interpreted as char). |
Returns a pointer to the last instance found, or NULL. |
*/ |
extern char* _FUNC(strrchr)(const char * s, int c ); |
/* Determine the length of the initial substring of character array s1 which |
consists only of characters from the character array s2. |
Returns the length of that substring. |
*/ |
extern size_t _FUNC(strspn)(const char * s1, const char * s2); |
/* Search the character array s1 for the substring in character array s2. |
Returns a pointer to that sbstring, or NULL. If s2 is of length zero, |
returns s1. |
*/ |
extern char* _FUNC(strstr)(const char * s1, const char * s2); |
/* In a series of subsequent calls, parse a C string into tokens. |
On the first call to strtok(), the first argument is a pointer to the to-be- |
parsed C string. On subsequent calls, the first argument is NULL unless you |
want to start parsing a new string. s2 holds an array of separator characters |
which can differ from call to call. Leading separators are skipped, the first |
trailing separator overwritten with '\0'. |
Returns a pointer to the next token. |
WARNING: This function uses static storage, and as such is not reentrant. |
*/ |
extern char* _FUNC(strtok)(char* s1, const char* s2); |
/* Map an error number to a (locale-specific) error message string. Error |
numbers are typically errno values, but any number is mapped to a message. |
TODO: PDCLib does not yet support locales. |
*/ |
extern char* _FUNC(strerror)(int errnum); |
/* Returns the length of the string s (excluding terminating '\0').*/ |
extern size_t _FUNC(strlen)(const char * s); |
/* The function reverses the sequence of characters in the string pointed to by str. */ |
extern char* _FUNC(strrev)(char *str); |
/* The strdup function executes the function pointed to by the str argument. */ |
extern char* _FUNC(strdup)(const char *str); |
#endif |
/programs/develop/ktcc/trunk/libc.obj/include/sys/dirent.h |
---|
3,8 → 3,8 |
#ifndef _DIRENT_H_ |
#define _DIRENT_H_ |
#include <limits.h> |
#include <stddef.h> |
#include <limits.h> |
#define IS_FOLDER 16 |
#define IS_FILE 0 |
23,7 → 23,6 |
ino_t num_objs; |
}DIR; |
extern int _FUNC(closedir)(DIR *dir); |
extern DIR* _FUNC(opendir)(const char *path); |
extern struct dirent* _FUNC(readdir)(DIR *); |
/programs/develop/ktcc/trunk/libc.obj/include/sys/ksys.h |
---|
20,7 → 20,9 |
#define _KSYS_H_ |
#include <stddef.h> |
#include <stdint.h> |
#define KOSAPI static inline |
#define asm_inline __asm__ __volatile__ |
/*============== General structures ==============*/ |
75,7 → 77,6 |
size_t size; |
}ksys_ufile_t; |
typedef struct{ |
uint32_t p00; |
union{ |
98,6 → 99,11 |
}ksys70_t; |
typedef struct { |
uint32_t status; |
uint32_t rw_bytes; |
} ksys70_status_t; |
typedef struct { |
uint32_t attributes; |
uint32_t name_cp; |
ksys_time_t creation_time; |
106,7 → 112,7 |
ksys_date_t last_access_date; |
ksys_time_t last_modification_time; |
ksys_date_t last_modification_date; |
unsigned long long size; |
uint64_t size; |
char name[0]; |
}ksys_bdfe_t; |
113,7 → 119,7 |
typedef struct { |
int cpu_usage; //+0 |
int window_pos_info; //+4 |
short int reserved1; //+8 |
uint16_t reserved1; //+8 |
char name[12]; //+10 |
int memstart; //+22 |
int memused; //+26 |
122,14 → 128,14 |
int winy_start; //+38 |
int winx_size; //+42 |
int winy_size; //+46 |
short int slot_info; //+50 |
short int reserved2; //+52 |
uint16_t slot_info; //+50 |
uint16_t reserved2; //+52 |
int clientx; //+54 |
int clienty; //+58 |
int clientwidth; //+62 |
int clientheight; //+66 |
unsigned char window_state;//+70 |
char reserved3[1024-71]; //+71 |
uint8_t window_state; //+70 |
uint8_t reserved3[1024 - 71]; //+71 |
}ksys_thread_t; |
typedef unsigned int ksys_color_t; |
218,10 → 224,12 |
KSYS_FILE_UTF8 = 3 |
}; |
static inline |
int __strcmp(const char * s1, const char * s2 ) |
KOSAPI int __strcmp(const char* s1, const char* s2) |
{ |
while ((*s1) && (*s1 == *s2)){ ++s1; ++s2; } |
while ((*s1) && (*s1 == *s2)) { |
++s1; |
++s2; |
} |
return(*(unsigned char*)s1 - *(unsigned char *)s2); |
} |
229,202 → 237,177 |
/* ############### С wrappers for system calls Kolibri OS ################ */ |
/* ####################################################################### */ |
/*=============== Function -1 - terminate thread/process ===============*/ |
static inline |
void _ksys_exit(){ |
KOSAPI void _ksys_exit(void) |
{ |
asm_inline("int $0x40"::"a"(-1)); |
} |
/*============== Function 0 - define and draw the window. ==============*/ |
static inline |
void _ksys_create_window(uint32_t x, uint32_t y, uint32_t w, uint32_t h, const char *name, ksys_color_t workcolor, uint32_t style) { |
KOSAPI void _ksys_create_window(uint32_t x, uint32_t y, uint32_t w, uint32_t h, const char* name, ksys_color_t workcolor, uint32_t style) |
{ |
asm_inline( |
"int $0x40" |
::"a"(0), |
"int $0x40" ::"a"(0), |
"b"((x << 16) | ((w-1) & 0xFFFF)), |
"c"((y << 16) | ((h-1) & 0xFFFF)), |
"d"((style << 24) | (workcolor & 0xFFFFFF)), |
"D"(name), |
"S"(0) |
:"memory" |
); |
: "memory"); |
}; |
/*================ Function 1 - put pixel in the window. ===============*/ |
static inline |
void _ksys_draw_pixel(uint32_t x, uint32_t y, ksys_color_t color){ |
KOSAPI void _ksys_draw_pixel(uint32_t x, uint32_t y, ksys_color_t color) |
{ |
asm_inline( |
"int $0x40" |
::"a"(1), "b"(x), "c"(y), "d"(color) |
); |
"int $0x40" ::"a"(1), "b"(x), "c"(y), "d"(color)); |
} |
/*============ Function 2 - get the code of the pressed key. ===========*/ |
static inline |
ksys_oskey_t _ksys_get_key(void){ |
KOSAPI ksys_oskey_t _ksys_get_key(void) |
{ |
ksys_oskey_t val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(2) |
); |
: "a"(2)); |
return val; |
} |
/*==================== Function 3 - get system time. ===================*/ |
static inline |
ksys_time_t _ksys_get_time(){ |
KOSAPI ksys_time_t _ksys_get_time(void) |
{ |
ksys_time_t c_time; |
asm_inline( |
"int $0x40" |
:"=a"(c_time) |
:"a"(3) |
:"memory" |
); |
: "memory"); |
return c_time; |
} |
/*=================== Function 4 - draw text string. ===================*/ |
static inline |
void _ksys_draw_text(const char *text, uint32_t x, uint32_t y, uint32_t len, ksys_color_t color) { |
KOSAPI void _ksys_draw_text(const char* text, uint32_t x, uint32_t y, uint32_t len, ksys_color_t color) |
{ |
asm_inline( |
"int $0x40" |
::"a"(4),"d"(text), |
"int $0x40" ::"a"(4), "d"(text), |
"b"((x << 16) | y), |
"S"(len),"c"(color) |
:"memory" |
); |
: "memory"); |
} |
/*========================= Function 5 - delay. ========================*/ |
static inline |
void _ksys_delay(uint32_t time){ |
KOSAPI void _ksys_delay(uint32_t time) |
{ |
asm_inline( |
"int $0x40" |
::"a"(5), "b"(time) |
:"memory" |
); |
"int $0x40" ::"a"(5), "b"(time) |
: "memory"); |
} |
/*=============== Function 7 - draw image in the window. ===============*/ |
static inline |
void _ksys_draw_bitmap(void *bitmap, int x, int y, int w, int h) |
KOSAPI void _ksys_draw_bitmap(void* bitmap, int x, int y, int w, int h) |
{ |
asm_inline( |
"int $0x40" |
::"a"(7), "b"(bitmap), |
"int $0x40" ::"a"(7), "b"(bitmap), |
"c"((w << 16) | h), |
"d"((x << 16) | y) |
:"memory" |
); |
: "memory"); |
} |
/*=============== Function 8 - define/delete the button. ===============*/ |
static inline |
void _ksys_define_button(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t id, ksys_color_t color) { |
KOSAPI void _ksys_define_button(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t id, ksys_color_t color) |
{ |
asm_inline( |
"int $0x40" |
::"a"(8), |
"int $0x40" ::"a"(8), |
"b"((x<<16)+w), |
"c"((y<<16)+h), |
"d"(id), |
"S"(color) |
); |
"S"(color)); |
}; |
static inline |
void _ksys_delete_button(uint32_t id){ |
KOSAPI void _ksys_delete_button(uint32_t id) |
{ |
asm_inline( |
"int $0x40" |
::"a"(8),"d"(id & 0x00FFFFFF | 0x80000000) |
); |
"int $0x40" ::"a"(8), "d"(id & 0x00FFFFFF | 0x80000000)); |
} |
/*============ Function 9 - information on execution thread. ===========*/ |
static inline |
int _ksys_thread_info(ksys_thread_t* table, int slot){ |
KOSAPI int _ksys_thread_info(ksys_thread_t* table, int slot) |
{ |
int val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(9), "b"(table), "c"(slot) |
:"memory" |
); |
: "memory"); |
return val; |
} |
/*==================== Function 10 - wait for event. ===================*/ |
static inline |
uint32_t _ksys_wait_event(void){ |
KOSAPI uint32_t _ksys_wait_event(void) |
{ |
uint32_t val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(10) |
); |
: "a"(10)); |
return val; |
} |
/*=============== Function 11 - check for event, no wait. ==============*/ |
static inline |
uint32_t _ksys_check_event(void){ |
KOSAPI uint32_t _ksys_check_event(void) |
{ |
uint32_t val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(11) |
); |
: "a"(11)); |
return val; |
} |
/*=============== Function 12 - begin/end window redraw. ===============*/ |
static inline |
void _ksys_start_draw(){ |
KOSAPI void _ksys_start_draw(void) |
{ |
asm_inline("int $0x40"::"a"(12),"b"(1)); |
} |
static inline |
void _ksys_end_draw(){ |
KOSAPI void _ksys_end_draw(void) |
{ |
asm_inline("int $0x40" ::"a"(12),"b"(2)); |
} |
/*============ Function 13 - draw a rectangle in the window. ===========*/ |
static inline |
void _ksys_draw_bar(uint32_t x, uint32_t y, uint32_t w, uint32_t h, ksys_color_t color){ |
KOSAPI void _ksys_draw_bar(uint32_t x, uint32_t y, uint32_t w, uint32_t h, ksys_color_t color) |
{ |
asm_inline( |
"int $0x40" |
::"a"(13), "d"(color), |
"int $0x40" ::"a"(13), "d"(color), |
"b"((x << 16) | w), |
"c"((y << 16) | h) |
); |
"c"((y << 16) | h)); |
} |
/*=================== Function 14 - get screen size. ===================*/ |
static inline |
ksys_pos_t _ksys_screen_size(){ |
KOSAPI ksys_pos_t _ksys_screen_size(void) |
{ |
ksys_pos_t size; |
ksys_pos_t size_tmp; |
asm_inline( |
"int $0x40" |
:"=a"(size_tmp) |
:"a"(14) |
); |
: "a"(14)); |
size.x = size_tmp.y; |
size.y = size_tmp.x; |
return size; |
432,32 → 415,26 |
/*== Function 15, subfunction 1 - set a size of the background image. ==*/ |
static inline |
void _ksys_bg_set_size(uint32_t w, uint32_t h){ |
KOSAPI void _ksys_bg_set_size(uint32_t w, uint32_t h) |
{ |
asm_inline( |
"int $0x40" |
::"a"(15), "b"(1), "c"(w), "d"(h) |
); |
"int $0x40" ::"a"(15), "b"(1), "c"(w), "d"(h)); |
} |
/*=== Function 15, subfunction 2 - put pixel on the background image. ==*/ |
static inline |
void _ksys_bg_put_pixel(uint32_t x, uint32_t y, uint32_t w, ksys_color_t color){ |
KOSAPI void _ksys_bg_put_pixel(uint32_t x, uint32_t y, uint32_t w, ksys_color_t color) |
{ |
asm_inline( |
"int $0x40" |
::"a"(15), "b"(2), "c"((x+y*w)*3), "d"(color) |
); |
"int $0x40" ::"a"(15), "b"(2), "c"((x + y * w) * 3), "d"(color)); |
} |
/*=========== Function 15, subfunction 3 - redraw background. ==========*/ |
static inline |
void _ksys_bg_redraw(void){ |
KOSAPI void _ksys_bg_redraw(void) |
{ |
asm_inline( |
"int $0x40" |
::"a"(15), "b"(3) |
); |
"int $0x40" ::"a"(15), "b"(3)); |
} |
/*== Function 15, subfunction 4 - set drawing mode for the background. =*/ |
467,51 → 444,43 |
KSYS_BG_MODE_STRETCH=2 |
}; |
static inline |
void _ksys_bg_set_mode(uint32_t mode){ |
KOSAPI void _ksys_bg_set_mode(uint32_t mode) |
{ |
asm_inline( |
"int $0x40" |
::"a"(15), "b"(4), "c"(mode) |
); |
"int $0x40" ::"a"(15), "b"(4), "c"(mode)); |
} |
/*===================== Function 15, subfunction 5 =====================*/ |
/*============ Put block of pixels on the background image. ============*/ |
static inline |
void _ksys_bg_put_bitmap(ksys_bitmap_t* bitmap, size_t bitmap_size, uint32_t x, uint32_t y, uint32_t w){ |
KOSAPI void _ksys_bg_put_bitmap(ksys_bitmap_t* bitmap, size_t bitmap_size, uint32_t x, uint32_t y, uint32_t w) |
{ |
asm_inline( |
"int $0x40" |
::"a"(15), "b"(5), "c"(bitmap), "d"((x+y*w)*3), "S"(bitmap_size) |
); |
"int $0x40" ::"a"(15), "b"(5), "c"(bitmap), "d"((x + y * w) * 3), "S"(bitmap_size)); |
} |
/*===================== Function 15, subfunction 6 =====================*/ |
/*======= Map background data to the address space of process. ==========*/ |
static inline |
ksys_bitmap_t* _ksys_bg_get_map() |
KOSAPI ksys_bitmap_t* _ksys_bg_get_map(void) |
{ |
ksys_bitmap_t *bitmap; |
asm_inline( |
"int $0x40" |
:"=a"(bitmap) |
:"a"(15), "b"(6) |
); |
: "a"(15), "b"(6)); |
return bitmap; |
} |
/*===== Function 15, subfunction 7 - close mapped background data. =====*/ |
static inline |
int _ksys_bg_close_map(ksys_bitmap_t* bitmap) |
KOSAPI int _ksys_bg_close_map(ksys_bitmap_t* bitmap) |
{ |
int status; // 1 - OK, 0 - ERROR |
asm_inline( |
"int $0x40" |
:"=a"(status) |
:"a"(15), "b"(7), "c"(bitmap) |
); |
: "a"(15), "b"(7), "c"(bitmap)); |
return status; |
} |
518,42 → 487,35 |
/*===================== Function 15, subfunction 9 =====================*/ |
/*============= Redraws a rectangular part of the background ===========*/ |
static inline |
void _ksys_bg_redraw_bar(ksys_pos_t angle1, ksys_pos_t angle2) |
KOSAPI void _ksys_bg_redraw_bar(ksys_pos_t angle1, ksys_pos_t angle2) |
{ |
asm_inline( |
"int $0x40" |
::"a"(15), "b"(9), |
"int $0x40" ::"a"(15), "b"(9), |
"c"(angle1.x*(1<<16)+angle2.x), |
"d"(angle1.y*(1<<16)+angle2.y) |
); |
"d"(angle1.y * (1 << 16) + angle2.y)); |
} |
/*=============== Function 16 - save ramdisk on a floppy. ==============*/ |
static inline |
int _ksys_save_ramdisk_fd(uint32_t floppy_id) |
KOSAPI int _ksys_save_ramdisk_fd(uint32_t floppy_id) |
{ |
int status; // 0 - OK, 1 - ERROR |
asm_inline( |
"int $0x40" |
:"=a"(status) |
:"a"(16), "b"(floppy_id) |
); |
: "a"(16), "b"(floppy_id)); |
return status; |
} |
/*======= Function 17 - get the identifier of the pressed button. ======*/ |
static inline |
uint32_t _ksys_get_button() |
KOSAPI uint32_t _ksys_get_button(void) |
{ |
unsigned val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(17) |
); |
: "a"(17)); |
return val>>8; |
} |
560,48 → 522,39 |
/*===================== Function 18, subfunction 1 =====================*/ |
/*============= Make deactive the window of the given thread. ==========*/ |
static inline |
void _ksys_unfocus_window(int slot) |
KOSAPI void _ksys_unfocus_window(int slot) |
{ |
asm_inline( |
"int $0x40" |
::"a"(18), "b"(1), "c"(slot) |
); |
"int $0x40" ::"a"(18), "b"(1), "c"(slot)); |
} |
/*= Function 18, subfunction 2 - terminate process/thread by the slot. =*/ |
static inline |
void _ksys_kill_by_slot(int slot) |
KOSAPI void _ksys_kill_by_slot(int slot) |
{ |
asm_inline( |
"int $0x40" |
::"a"(18), "b"(2), "c"(slot) |
); |
"int $0x40" ::"a"(18), "b"(2), "c"(slot)); |
} |
/*===================== Function 18, subfunction 3 =====================*/ |
/*============= Make active the window of the given thread. ============*/ |
static inline |
void _ksys_focus_window(int slot){ |
KOSAPI void _ksys_focus_window(int slot) |
{ |
asm_inline( |
"int $0x40" |
::"a"(18), "b"(3), "c"(slot) |
); |
"int $0x40" ::"a"(18), "b"(3), "c"(slot)); |
} |
/*===================== Function 18, subfunction 4 =====================*/ |
/*=========== Get counter of idle time units per one second. ===========*/ |
static inline |
uint32_t _ksys_get_idle(void){ |
KOSAPI uint32_t _ksys_get_idle(void) |
{ |
uint32_t sec; |
asm_inline( |
"int $0x40" |
:"=a"(sec) |
:"a"(18), "b"(4) |
); |
: "a"(18), "b"(4)); |
return sec; |
} |
608,27 → 561,25 |
/*========== Function 18, subfunction 5 - get CPU clock rate. ==========*/ |
/*================ modulo 2^32 clock ticks = 4GHz ======================*/ |
static inline |
uint32_t _ksys_get_cpu_clock(void){ |
KOSAPI uint32_t _ksys_get_cpu_clock(void) |
{ |
uint32_t clock; |
asm_inline( |
"int $0x40" |
:"=a"(clock) |
:"a"(18), "b"(5) |
); |
: "a"(18), "b"(5)); |
return clock; |
} |
/* Function 18, subfunction 6 - save ramdisk to the file on hard drive. */ |
static inline |
uint32_t _ksys_save_ramdisk_hd(const char* ramdisk_path){ |
KOSAPI uint32_t _ksys_save_ramdisk_hd(const char* ramdisk_path) |
{ |
uint32_t fs_err; |
asm_inline( |
"int $0x40" |
:"=a"(fs_err) |
:"a"(18), "b"(6), "c"(ramdisk_path) |
); |
: "a"(18), "b"(6), "c"(ramdisk_path)); |
return fs_err; |
} |
640,37 → 591,33 |
KSYS_SHD_RESTART_KRN = 4 |
}; |
static inline |
void _ksys_shutdown(uint32_t shd_param){ |
KOSAPI void _ksys_shutdown(uint32_t shd_param) |
{ |
asm_inline( |
"int $0x40" |
::"a"(18), "b"(9), "c"(shd_param) |
); |
"int $0x40" ::"a"(18), "b"(9), "c"(shd_param)); |
} |
/*========= Function 18, subfunction 16 - get size of free RAM. ========*/ |
static inline |
size_t _ksys_get_ram_size(void){ |
KOSAPI size_t _ksys_get_ram_size(void) |
{ |
size_t size; |
asm_inline( |
"int $0x40" |
:"=a"(size) |
:"a"(18), "b"(16) |
); |
: "a"(18), "b"(16)); |
return size; |
} |
/*======== Function 18, subfunction 17 - get full amount of RAM. =======*/ |
static inline |
size_t _ksys_get_full_ram(void){ |
KOSAPI size_t _ksys_get_full_ram(void) |
{ |
size_t size; |
asm_inline( |
"int $0x40" |
:"=a"(size) |
:"a"(18), "b"(17) |
); |
: "a"(18), "b"(17)); |
return size; |
} |
677,52 → 624,46 |
/*===================== Function 18, subfunction 18 ====================*/ |
/*============= Terminate process/thread by the identifier. ============*/ |
static inline |
void _ksys_kill_by_pid(uint32_t PID) |
KOSAPI void _ksys_kill_by_pid(uint32_t PID) |
{ |
asm_inline( |
"int $0x40" |
::"a"(18), "b"(18), "c"(PID) |
); |
"int $0x40" ::"a"(18), "b"(18), "c"(PID)); |
} |
/*===================== Function 18, subfunction 21 ====================*/ |
/*=====Get the slot number of the process / thread by identifier.. =====*/ |
static inline |
int _ksys_get_thread_slot(int PID){ |
KOSAPI int _ksys_get_thread_slot(int PID) |
{ |
int val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(18), "b"(21), "c"(PID) |
); |
: "a"(18), "b"(21), "c"(PID)); |
return val; |
} |
/*============= Function 23 - wait for event with timeout. =============*/ |
static inline |
uint32_t _ksys_wait_event_timeout(uint32_t timeout){ |
KOSAPI uint32_t _ksys_wait_event_timeout(uint32_t timeout) |
{ |
unsigned val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(23), "b"(timeout) |
); |
: "a"(23), "b"(timeout)); |
return val; |
} |
/*=== Function 26, subfunction 9 - get the value of the time counter. ==*/ |
static inline |
uint32_t _ksys_get_tick_count(){ |
KOSAPI uint32_t _ksys_get_tick_count(void) |
{ |
unsigned val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(26),"b"(9) |
); |
: "a"(26), "b"(9)); |
return val; |
} |
729,23 → 670,24 |
/*===================== Function 26, subfunction 10 ====================*/ |
/*========== Get the value of the high precision time counter. =========*/ |
static inline |
uint64_t _ksys_get_ns_count(){ |
KOSAPI uint64_t _ksys_get_ns_count(void) |
{ |
uint64_t val; |
asm_inline( |
"int $0x40" |
:"=A"(val) |
:"a"(26), "b"(10) |
); |
: "a"(26), "b"(10)); |
return val; |
} |
/*=================== Function 29 - get system date. ===================*/ |
static inline |
ksys_date_t _ksys_get_date(){ |
KOSAPI ksys_date_t _ksys_get_date(void) |
{ |
ksys_date_t val; |
asm_inline("int $0x40":"=a"(val):"a"(29)); |
asm_inline("int $0x40" |
: "=a"(val) |
: "a"(29)); |
return val; |
} |
752,37 → 694,34 |
/*===========+ Function 30 - work with the current folder.==============*/ |
/*--------- Subfunction 1 - set current folder for the thread. ---------*/ |
static inline |
void _ksys_setcwd(char* dir){ |
KOSAPI void _ksys_setcwd(char* dir) |
{ |
asm_inline( |
"int $0x40" |
::"a"(30), "b"(1), "c"(dir) |
); |
"int $0x40" ::"a"(30), "b"(1), "c"(dir)); |
} |
/*--------- Subfunction 2 - get current folder for the thread. ---------*/ |
static inline |
int _ksys_getcwd(char* buf, int bufsize){ |
KOSAPI int _ksys_getcwd(char* buf, int bufsize) |
{ |
register int val; |
asm_inline( |
"int $0x40" |
:"=a"(val):"a"(30), "b"(2), "c"(buf), "d"(bufsize) |
); |
: "=a"(val) |
: "a"(30), "b"(2), "c"(buf), "d"(bufsize)); |
return val; |
} |
/* ---- Subfunction 3 - install the add.system directory for the kernel ------*/ |
static inline |
int _ksys_set_kernel_dir(ksys_dir_key_t *table){ |
KOSAPI int _ksys_set_kernel_dir(ksys_dir_key_t* table) |
{ |
register int val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(30), "b"(3), "c"(table) |
:"memory" |
); |
: "memory"); |
return val; |
} |
793,84 → 732,76 |
KSYS_MOUSE_WINDOW_POS = 1 |
}; |
static inline |
ksys_pos_t _ksys_get_mouse_pos(int origin){ |
KOSAPI ksys_pos_t _ksys_get_mouse_pos(int origin) |
{ |
ksys_pos_t pos; |
asm_inline( |
"int $0x40 \n\t" |
"rol $16, %%eax" |
:"=a"(pos) |
:"a"(37),"b"(origin) |
); |
: "a"(37), "b"(origin)); |
return pos; |
} |
static inline |
uint32_t _ksys_get_mouse_buttons(void){ // subfunction 2 - states of the mouse buttons |
KOSAPI uint32_t _ksys_get_mouse_buttons(void) // subfunction 2 - states of the mouse buttons |
{ |
uint32_t val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(37),"b"(2) |
); |
: "a"(37), "b"(2)); |
return val; |
} |
static inline |
uint32_t _ksys_get_mouse_eventstate(void){ // subfunction 3 - states and events of the mouse buttons |
KOSAPI uint32_t _ksys_get_mouse_eventstate(void) // subfunction 3 - states and events of the mouse buttons |
{ |
uint32_t val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(37),"b"(3) |
); |
: "a"(37), "b"(3)); |
return val; |
} |
static inline |
uint32_t _ksys_load_cursor(void *path, uint32_t flags) { // subfunction 4 - load cursor |
KOSAPI uint32_t _ksys_load_cursor(void* path, uint32_t flags) // subfunction 4 - load cursor |
{ |
uint32_t val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(37), "b"(4), "c"(path), "d"(flags) |
:"memory" |
); |
: "memory"); |
return val; |
} |
static inline |
uint32_t _ksys_set_cursor(uint32_t cursor){ // subfunction 5 - set curso |
KOSAPI uint32_t _ksys_set_cursor(uint32_t cursor) // subfunction 5 - set cursor |
{ |
uint32_t old; |
asm_inline( |
"int $0x40" |
:"=a"(old) |
:"a"(37), "b"(5), "c"(cursor) |
); |
: "a"(37), "b"(5), "c"(cursor)); |
return old; |
} |
static inline |
int _ksys_delete_cursor(uint32_t cursor){ // subfunction 6 - delete curso |
KOSAPI int _ksys_delete_cursor(uint32_t cursor) // subfunction 6 - delete cursor |
{ |
int ret; |
asm_inline( |
"int $0x40" |
:"=a"(ret) |
:"a"(37), "b"(6), "c"(cursor) |
:"memory" |
); |
: "memory"); |
return ret; |
} |
static inline |
uint32_t _ksys_get_mouse_wheels(void) // subfunction 7 - get scroll data |
KOSAPI uint32_t _ksys_get_mouse_wheels(void) // subfunction 7 - get scroll data |
{ |
uint32_t val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(37),"b"(7) |
); |
: "a"(37), "b"(7)); |
return val; |
} |
891,91 → 822,77 |
KSYS_EVM_CURSOR_FILTER = 0x40000000, |
}; |
static inline |
uint32_t _ksys_set_event_mask(uint32_t mask){ |
KOSAPI uint32_t _ksys_set_event_mask(uint32_t mask) |
{ |
unsigned val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(40), "b"(mask) |
); |
: "a"(40), "b"(mask)); |
return val; |
} |
/*====================== Function 38 - draw line. ======================*/ |
static inline |
void _ksys_draw_line(int xs, int ys, int xe, int ye, ksys_color_t color) |
KOSAPI void _ksys_draw_line(int xs, int ys, int xe, int ye, ksys_color_t color) |
{ |
asm_inline( |
"int $0x40" |
::"a"(38), "d"(color), |
"int $0x40" ::"a"(38), "d"(color), |
"b"((xs << 16) | xe), |
"c"((ys << 16) | ye) |
); |
"c"((ys << 16) | ye)); |
} |
/*============= Function 47 - draw a number in the window. =============*/ |
static inline |
void _ksys_draw_number(int number, int x, int y, int len, ksys_color_t color){ |
KOSAPI void _ksys_draw_number(int number, int x, int y, int len, ksys_color_t color) |
{ |
unsigned fmt; |
fmt = len << 16 | 0x80000000; // no leading zeros + width |
asm_inline( |
"int $0x40" |
::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color) |
); |
"int $0x40" ::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color)); |
} |
static inline |
void _ksys_draw_number_bg(unsigned number, int x, int y, int len, ksys_color_t color, ksys_color_t bg){ |
KOSAPI void _ksys_draw_number_bg(unsigned number, int x, int y, int len, ksys_color_t color, ksys_color_t bg) |
{ |
unsigned fmt; |
fmt = len << 16 | 0x80000000; // no leading zeros + width |
asm_inline( |
"int $0x40" |
::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color), "D"(bg) |
); |
"int $0x40" ::"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color), "D"(bg)); |
} |
/*====== Function 48, subfunction 3 - get standard window colors. ======*/ |
static inline |
void _ksys_get_system_colors(ksys_colors_table_t *color_table) |
KOSAPI void _ksys_get_system_colors(ksys_colors_table_t* color_table) |
{ |
asm_inline( |
"int $0x40" |
::"a"(48),"b"(3),"c"(color_table),"d"(40) |
); |
"int $0x40" ::"a"(48), "b"(3), "c"(color_table), "d"(40)); |
} |
/*============ Function 48, subfunction 4 - get skin height. ===========*/ |
static inline |
uint32_t _ksys_get_skin_height(){ |
KOSAPI uint32_t _ksys_get_skin_height() |
{ |
unsigned height; |
asm_inline( |
"int $0x40" |
:"=a"(height) |
:"a"(48),"b"(4) |
); |
: "a"(48), "b"(4)); |
return height; |
} |
/*==================== Function 51 - create thread. ====================*/ |
static inline |
int _ksys_create_thread(void* thread_entry, void* stack_top){ |
KOSAPI int _ksys_create_thread(void* thread_entry, void* stack_top) |
{ |
int val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(51), "b"(1), "c"(thread_entry), "d"(stack_top) |
:"memory" |
); |
: "memory"); |
return val; |
} |
/*==================== Function 54, subfunction 0 ======================*/ |
/*============== Get the number of slots in the clipboard. =============*/ |
991,14 → 908,13 |
KSYS_CLIP_RAW = 2 |
}; |
static inline |
int _ksys_clip_num(){ |
KOSAPI int _ksys_clip_num(void) |
{ |
unsigned val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(54), "b"(0) |
); |
: "a"(54), "b"(0)); |
return val; |
} |
1005,14 → 921,13 |
/*==================== Function 54, subfunction 1 ======================*/ |
/*================= Read the data from the clipboard. ==================-*/ |
static inline |
char* _ksys_clip_get(int n) { // returned buffer must be freed by _ksys_free() |
KOSAPI char* _ksys_clip_get(int n) // returned buffer must be freed by _ksys_free() |
{ |
char* val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(54), "b"(1), "c"(n) |
); |
: "a"(54), "b"(1), "c"(n)); |
return val; |
} |
1019,15 → 934,14 |
/*==================== Function 54, subfunction 2 ======================*/ |
/*================= Write the data to the clipboard. ===================*/ |
static inline |
int _ksys_clip_set(int n, char *buffer){ |
KOSAPI int _ksys_clip_set(int n, char* buffer) |
{ |
unsigned val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(54), "b"(2), "c"(n), "d"(buffer) |
:"memory" |
); |
: "memory"); |
return val; |
} |
1034,14 → 948,13 |
/*===================== Function 54, subfunction 3 =====================*/ |
/*================ Delete the last slot in the clipboard ===============*/ |
static inline |
int _ksys_clip_pop(){ |
KOSAPI int _ksys_clip_pop() |
{ |
unsigned val; |
asm_inline ( |
"int $0x40" |
:"=a"(val) |
:"a"(54), "b"(3) |
); |
: "a"(54), "b"(3)); |
return val; |
} |
1048,26 → 961,25 |
/*===================== Function 54, subfunction 4 =====================*/ |
/*===================== Alarm reset the lock buffer ====================*/ |
static inline |
int _ksys_clip_unlock(){ |
KOSAPI int _ksys_clip_unlock() |
{ |
unsigned val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(54), "b"(4) |
); |
: "a"(54), "b"(4)); |
return val; |
} |
/*============== Function 63 - work with the debug board. ==============*/ |
static inline |
void _ksys_debug_putc(char c){ |
KOSAPI void _ksys_debug_putc(char c) |
{ |
asm_inline("int $0x40"::"a"(63), "b"(1), "c"(c)); |
} |
static inline |
void _ksys_debug_puts(const char* s){ |
KOSAPI void _ksys_debug_puts(const char* s) |
{ |
unsigned i=0; |
while (*(s+i)){ |
asm_inline ("int $0x40"::"a"(63), "b"(1), "c"(*(s+i))); |
1082,97 → 994,86 |
KSYS_KEY_INPUT_MODE_SCANC = 1, |
} ksys_key_input_mode_t; |
static inline |
void _ksys_set_key_input_mode(ksys_key_input_mode_t mode){ |
KOSAPI void _ksys_set_key_input_mode(ksys_key_input_mode_t mode) |
{ |
asm_inline( |
"int $0x40" |
::"a"(66),"b"(1),"c"(mode) |
); |
"int $0x40" ::"a"(66), "b"(1), "c"(mode)); |
} |
/*========= Function 67 - change position/sizes of the window. =========*/ |
static inline |
void _ksys_change_window(int new_x, int new_y, int new_w, int new_h){ |
KOSAPI void _ksys_change_window(int new_x, int new_y, int new_w, int new_h) |
{ |
asm_inline( |
"int $0x40" |
::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w),"S"(new_h) |
); |
"int $0x40" ::"a"(67), "b"(new_x), "c"(new_y), "d"(new_w), "S"(new_h)); |
} |
/*======== Function 68, subfunction 12 - allocate memory block. ========*/ |
static inline |
void* _ksys_alloc(size_t size){ |
KOSAPI void* _ksys_alloc(size_t size) |
{ |
void *val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(12),"c"(size) |
); |
: "a"(68), "b"(12), "c"(size)); |
return val; |
} |
/*========== Function 68, subfunction 13 - free memory block. ==========*/ |
static inline |
int _ksys_free(void *mem){ |
KOSAPI int _ksys_free(void* mem) |
{ |
int val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(13),"c"(mem) |
); |
: "a"(68), "b"(13), "c"(mem)); |
return val; |
} |
/*============= Function 68, subfunction 16 - load driver. =============*/ |
static inline |
ksys_drv_hand_t _ksys_load_driver(char *driver_name) |
KOSAPI ksys_drv_hand_t _ksys_load_driver(char* driver_name) |
{ |
ksys_drv_hand_t driver_h; |
asm_inline( |
"int $0x40" |
:"=a"(driver_h) |
:"a"(68), "b"(16), "c"(driver_name) |
); |
: "a"(68), "b"(16), "c"(driver_name)); |
return driver_h; |
} |
/*============ Function 68, subfunction 17 - driver control. ===========*/ |
static inline |
unsigned _ksys_driver_control(ksys_ioctl_t *ioctl) |
KOSAPI int _ksys_driver_control(ksys_ioctl_t* ioctl) |
{ |
unsigned status; |
int status; |
asm_inline( |
"int $0x40" |
:"=a"(status) |
:"a"(68), "b"(17), "c"(ioctl) |
:"memory" |
); |
: "memory"); |
return status; |
} |
/*== Function 68, subfunction 18 - subfunction 19 - load DLL (MS COFF) ==*/ |
static inline |
ksys_dll_t* _ksys_dlopen(const char* path){ |
KOSAPI ksys_dll_t* _ksys_dlopen(const char* path) |
{ |
ksys_dll_t *table; |
asm_inline( |
"int $0x40" |
:"=a"(table) |
:"a"(68),"b"(19), "c"(path) |
:"memory" |
); |
: "memory"); |
return table; |
} |
/* It is not a system call, it serves as an auxiliary tool*/ |
static inline |
void* _ksys_dlsym(ksys_dll_t *table, const char* fun_name){ |
KOSAPI void* _ksys_dlsym(ksys_dll_t* table, const char* fun_name) |
{ |
unsigned i=0; |
while (1){ |
if (!(table+i)->func_name){ |
1189,29 → 1090,26 |
/* Function 68, subfunction 20 - reallocate memory block.*/ |
static inline |
void* _ksys_realloc(void *mem, size_t size){ |
KOSAPI void* _ksys_realloc(void* mem, size_t size) |
{ |
void *val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(20),"c"(size),"d"(mem) |
:"memory" |
); |
: "memory"); |
return val; |
} |
/* Function 68, subfunction 21 - load driver by full name. */ |
static inline |
ksys_drv_hand_t _ksys_load_driver_opt(char *driver_path, char *cmd_line) |
KOSAPI ksys_drv_hand_t _ksys_load_driver_opt(char* driver_path, char* cmd_line) |
{ |
ksys_drv_hand_t driver_h; |
asm_inline( |
"int $0x40" |
:"=a"(driver_h) |
:"a"(68), "b"(21), "c"(driver_path), "d"(cmd_line) |
); |
: "a"(68), "b"(21), "c"(driver_path), "d"(cmd_line)); |
return driver_h; |
} |
1225,46 → 1123,41 |
KSYS_SHM_WRITE = 0x01, |
}; |
static inline |
int _ksys_shm_open(char *name, int mode, int size, char **new_shm) |
KOSAPI int _ksys_shm_open(char* name, int mode, int size, char** new_shm) |
{ |
int error; |
asm_inline( |
"int $0x40" |
:"=a"(*new_shm), "=d"(error) |
:"a"(68), "b"(22), "c"(name), "d"(size), "S"(mode) |
); |
: "a"(68), "b"(22), "c"(name), "d"(size), "S"(mode)); |
return error; |
} |
/*======= Function 68, subfunction 23 - close named memory area. =======*/ |
static inline |
void _ksys_shm_close(char *shm_name) |
KOSAPI void _ksys_shm_close(char* shm_name) |
{ |
asm_inline( |
"int $0x40": |
:"a"(68), "b"(23), "c"(shm_name) |
); |
"int $0x40" |
: |
: "a"(68), "b"(23), "c"(shm_name)); |
} |
/*====== Function 68, subfunction 26 - release memory pages ============*/ |
static inline |
int* _ksys_unmap(void *base, size_t offset, size_t size){ |
KOSAPI int* _ksys_unmap(void* base, size_t offset, size_t size) |
{ |
int *val; |
asm_inline( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size) |
); |
: "a"(68), "b"(26), "c"(base), "d"(offset), "S"(size)); |
return val; |
} |
/*========== Function 68, subfunction 27 - load file ===================*/ |
static inline |
ksys_ufile_t _ksys_load_file(const char *path) |
KOSAPI ksys_ufile_t _ksys_load_file(const char* path) |
{ |
ksys_ufile_t uf; |
asm_inline( |
1271,15 → 1164,13 |
"int $0x40" |
:"=a"(uf.data), "=d"(uf.size) |
:"a"(68), "b"(27),"c"(path) |
:"memory" |
); |
: "memory"); |
return uf; |
} |
/*==== Function 68, subfunction 28 - load file, specifying the encoding ===*/ |
static inline |
ksys_ufile_t _ksys_load_file_enc(const char *path, unsigned file_encoding) |
KOSAPI ksys_ufile_t _ksys_load_file_enc(const char* path, unsigned file_encoding) |
{ |
ksys_ufile_t uf; |
asm_inline( |
1286,30 → 1177,26 |
"int $0x40" |
:"=a"(uf.data), "=d"(uf.size) |
:"a"(68), "b"(28),"c"(path), "d"(file_encoding) |
:"memory" |
); |
: "memory"); |
return uf; |
} |
/*==== Function 70 - work with file system with long names support. ====*/ |
static inline |
int _ksys_work_files(const ksys70_t *k) |
KOSAPI ksys70_status_t _ksys70(const ksys70_t* k) |
{ |
int status; |
ksys70_status_t status; |
asm_inline( |
"int $0x40" |
:"=a"(status) |
: "=a"(status.status), "=b"(status.rw_bytes) |
:"a"(70), "b"(k) |
:"memory" |
); |
: "memory"); |
return status; |
} |
/*====== Function 70, subfunction 0 - read file with long names support. ======*/ |
static inline |
int _ksys_file_read_file(const char *name, unsigned long long offset, unsigned size, void *buf, unsigned *bytes_read) |
KOSAPI ksys70_status_t _ksys_file_read(const char* name, uint64_t offset, uint32_t size, void* buf) |
{ |
ksys70_t k; |
k.p00 = 0; |
1318,21 → 1205,14 |
k.buf16 = buf; |
k.p20 = 0; |
k.p21 = name; |
int status; |
asm_inline( |
"int $0x40" |
:"=a"(status), "=b"(*bytes_read) |
:"a"(70), "b"(&k) |
:"memory" |
); |
return status; |
return _ksys70(&k); |
} |
/*===================== Function 70, subfunction 2 =====================*/ |
/*============ Create/rewrite file with long names support. ============*/ |
static inline |
int _ksys_file_create(const char* name){ |
KOSAPI int _ksys_file_create(const char* name) |
{ |
ksys70_t k; |
k.p00 = 2; |
k.p04dw = 0; |
1339,14 → 1219,13 |
k.p08dw = 0; |
k.p12 = 0; |
k.p21 = name; |
return _ksys_work_files(&k); |
return _ksys70(&k).status; |
} |
/*===================== Function 70, subfunction 3 =====================*/ |
/*=========== Write to existing file with long names support. ==========*/ |
static inline |
int _ksys_file_write_file(const char *name, unsigned long long offset, unsigned size, const void *buf, unsigned *bytes_written) |
KOSAPI ksys70_status_t _ksys_file_write(const char* name, uint64_t offset, uint32_t size, const void* buf) |
{ |
ksys70_t k; |
k.p00 = 3; |
1355,20 → 1234,12 |
k.cbuf16 = buf; |
k.p20 = 0; |
k.p21 = name; |
int status; |
asm_inline( |
"int $0x40" |
:"=a"(status), "=b"(*bytes_written) |
:"a"(70), "b"(&k) |
:"memory" |
); |
return status; |
return _ksys70(&k); |
} |
/*========== Function 70, subfunction 5 - get information on file/folder. =====*/ |
static inline |
int _ksys_file_get_info(const char *name, ksys_bdfe_t *bdfe) |
KOSAPI int _ksys_file_info(const char* name, ksys_bdfe_t* bdfe) |
{ |
ksys70_t k; |
k.p00 = 5; |
1378,18 → 1249,19 |
k.bdfe = bdfe; |
k.p20 = 0; |
k.p21 = name; |
return _ksys_work_files(&k); |
return _ksys70(&k).status; |
} |
#define _ksys_dir_info _ksys_file_info |
/*=========== Function 70, subfunction 7 - start application. ===========*/ |
static inline |
int _ksys_exec(char *app_name, char *args) |
KOSAPI int _ksys_exec(const char* app_name, char* args) |
{ |
ksys70_t file_opt; |
file_opt.p00 = 7; |
file_opt.p04dw = 0; |
file_opt.p08dw = (unsigned)args; |
file_opt.p08dw = (uint32_t)args; |
file_opt.p12 = 0; |
file_opt.p16 = 0; |
1396,36 → 1268,33 |
file_opt.p20 = 0; |
file_opt.p21 = app_name; |
return _ksys_work_files(&file_opt); |
return _ksys70(&file_opt).status; |
} |
/*========== Function 70, subfunction 8 - delete file/folder. ==========*/ |
static inline |
int _ksys_file_delete(const char *name) |
KOSAPI int _ksys_file_delete(const char* name) |
{ |
ksys70_t k; |
k.p00 = 8; |
k.p20 = 0; |
k.p21 = name; |
return _ksys_work_files(&k); |
return _ksys70(&k).status; |
} |
/*============= Function 70, subfunction 9 - create folder. ============*/ |
static inline |
int _ksys_mkdir(const char *path) |
KOSAPI int _ksys_mkdir(const char* path) |
{ |
ksys70_t dir_opt; |
dir_opt.p00 = 9; |
dir_opt.p21 = path; |
return _ksys_work_files(&dir_opt); |
return _ksys70(&dir_opt).status; |
} |
/*============= Function 70, subfunction 10 - rename/move. =============*/ |
static inline |
int _ksys_file_rename(const char *name, const char *new_name) |
KOSAPI int _ksys_file_rename(const char* name, const char* new_name) |
{ |
ksys70_t k; |
k.p00 = 10; |
1432,13 → 1301,14 |
k.new_name = new_name; |
k.p20 = 0; |
k.p21 = name; |
return _ksys_work_files(&k); |
return _ksys70(&k).status; |
} |
#define _ksys_dir_rename _ksys_file_rename |
/*============= Function 77 - implements the POSIX subsystem. =============*/ |
static inline |
int _ksys_posix_read(int pipefd, void* buff, int n) |
KOSAPI int _ksys_posix_read(int pipefd, void* buff, int n) |
{ |
int count; |
asm_inline( |
1445,13 → 1315,11 |
"int $0x40" |
:"=a"(count) |
:"a"(77), "b"(10),"c"(pipefd), "d"(buff), "S"(n) |
:"memory" |
); |
: "memory"); |
return count; |
} |
static inline |
int _ksys_posix_write(int pipefd, void* buff, int n) |
KOSAPI int _ksys_posix_write(int pipefd, void* buff, int n) |
{ |
int count; |
asm_inline( |
1458,13 → 1326,11 |
"int $0x40" |
:"=a"(count) |
:"a"(77), "b"(11),"c"(pipefd), "d"(buff), "S"(n) |
:"memory" |
); |
: "memory"); |
return count; |
} |
static inline |
int _ksys_posix_pipe2(int pipefd[2], int flags) |
KOSAPI int _ksys_posix_pipe2(int pipefd[2], int flags) |
{ |
int err; |
asm_inline( |
1471,8 → 1337,7 |
"int $0x40" |
:"=a"(err) |
:"a"(77), "b"(13),"c"(pipefd), "d"(flags) |
:"memory" |
); |
: "memory"); |
return err; |
} |
1479,5 → 1344,20 |
/* ######### Old names of functions and structures. Do not use again! ##########*/ |
#define _ksys_get_event _ksys_wait_event |
#define _ksys_file_get_info _ksys_file_info |
static inline int _ksys_file_read_file(const char* name, unsigned long long offset, unsigned size, void* buff, unsigned* bytes_read) |
{ |
ksys70_status_t res = _ksys_file_read(name, offset, size, buff); |
*bytes_read = res.rw_bytes; |
return res.status; |
} |
static inline int _ksys_file_write_file(const char* name, unsigned long long offset, unsigned size, const void* buff, unsigned* bytes_write) |
{ |
ksys70_status_t res = _ksys_file_write(name, offset, size, buff); |
*bytes_write = res.rw_bytes; |
return res.status; |
} |
#endif // _KSYS_H_ |
/programs/develop/ktcc/trunk/libc.obj/include/sys/socket.h |
---|
3,9 → 3,9 |
#ifndef _SOCKET_H_ |
#define _SOCKET_H_ |
#include <errno.h> |
#include <stddef.h> |
#include <sys/ksys.h> |
#include <errno.h> |
// Socket Types |
#define SOCK_STREAM 1 |
/programs/develop/ktcc/trunk/libc.obj/samples/assert_test.c |
---|
3,7 → 3,8 |
int a=431; |
int b=532; |
int main(){ |
int main() |
{ |
assert(a!=b); |
assert(a==b); |
} |
/programs/develop/ktcc/trunk/libc.obj/samples/basic_gui.c |
---|
1,7 → 1,7 |
#include <stdarg.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <stdarg.h> |
#include <sys/ksys.h> |
ksys_colors_table_t sys_color_table; |
10,8 → 10,7 |
ksys_thread_t proc_info; |
char text_line[255]; |
enum BUTTONS |
{ |
enum BUTTONS { |
BTN_QUIT = 1, |
BTN_POP = 10, |
BTN_UNLOCK = 11 |
30,8 → 29,10 |
// define&draw window |
_ksys_create_window(10, 40, 600, 400, "My window", sys_color_table.work_area, 0x13); |
_ksys_thread_info(&proc_info, -1); |
F |
win_width = proc_info.winx_size; |
win_width |
= proc_info.winx_size; |
win_hight = proc_info.winy_size; |
_ksys_define_button(10, 30, 70, 20, BTN_POP, sys_color_table.work_button); |
51,7 → 52,8 |
_ksys_draw_text(text_line, 5, pos_y, 0, 0x90000000 | sys_color_table.work_text); |
pos_y += FONT_H; |
if(pos_y + 29 > win_hight) break; // 12 font + 12 statusbar + 5 border |
if (pos_y + 29 > win_hight) |
break; // 12 font + 12 statusbar + 5 border |
} |
// end redraw |
_ksys_end_draw(); |
69,8 → 71,7 |
do{ |
gui_event = _ksys_get_event(); |
switch(gui_event) |
{ |
switch (gui_event) { |
case KSYS_EVENT_NONE: |
break; |
case KSYS_EVENT_REDRAW: |
80,8 → 81,7 |
break; |
case KSYS_EVENT_BUTTON: |
pressed_button = _ksys_get_button(); |
switch (pressed_button) |
{ |
switch (pressed_button) { |
case BTN_POP: |
strcpy(statusbar, "POP pressed...."); |
draw_window(); |
102,7 → 102,8 |
if (mouse_button & (1<<24)) // double click |
{ |
int n = (mouse_pos.y - 60) / FONT_H; |
if (n < 0 || n >= LINES) break; |
if (n < 0 || n >= LINES) |
break; |
debug_printf("click on str(%d), clip slot(%d)\n", n, LINES - n - 1); |
sprintf(statusbar, "click on str(%d), clip slot(%d)\n", n, LINES - n - 1); |
draw_window(); |
/programs/develop/ktcc/trunk/libc.obj/samples/clayer/boxlib.c |
---|
1,11 → 1,11 |
// BOXLIB EXAMPLE (scrollbar, progressbar, editbox and checkbox) |
// Writed by maxcodehack and superturbocat2001 |
#include <sys/ksys.h> |
#include <clayer/boxlib.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <clayer/boxlib.h> |
#include <stdio.h> |
#include <sys/ksys.h> |
#define WIN_W 640 |
#define WIN_H 563 |
29,7 → 29,8 |
edit_box ed={WIN_W-140,10,60,0xFFFFFF,0x6a9480,0,0x6a9480, BLACK | TEXT_SIZE, ED_BUFF_LEN, ed_buff,NULL,ed_focus}; |
check_box output_off={X_W(10, 15), Y_H(120,15), 10, WHITE, BLUE, BLACK | TEXT_SIZE, "Disable duplicate output",0}; |
void draw_window(){ |
void draw_window() |
{ |
_ksys_start_draw(); |
_ksys_create_window(215,100,WIN_W,WIN_H,title, 0x858585, 0x34); |
edit_box_draw(&ed); |
49,7 → 50,8 |
while(1){ |
switch(_ksys_get_event()){ |
case KSYS_EVENT_BUTTON: |
if (_ksys_get_button() == 1) return 0; |
if (_ksys_get_button() == 1) |
return 0; |
break; |
case KSYS_EVENT_KEY: |
/programs/develop/ktcc/trunk/libc.obj/samples/clayer/dialog.c |
---|
1,6 → 1,6 |
#include <sys/ksys.h> |
#include <clayer/dialog.h> |
#include <stdio.h> |
#include <sys/ksys.h> |
int main() |
{ |
/programs/develop/ktcc/trunk/libc.obj/samples/clayer/libimg.c |
---|
1,9 → 1,9 |
/* Written by turbocat2001 (Logaev Maxim) */ |
#include <clayer/libimg.h> |
#include <stddef.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stddef.h> |
#include <clayer/libimg.h> |
#include <sys/ksys.h> |
#define NEW_IMG_H 128 |
16,7 → 16,8 |
ksys_colors_table_t sys_color_table; // Create system colors table |
void* load_img(char* fname, uint32_t* read_sz){ // Image file upload function |
void* load_img(char* fname, uint32_t* read_sz) |
{ // Image file upload function |
FILE *f = fopen(fname, "rb"); |
if (!f) { |
printf("Can't open file: %s\n", fname); |
42,7 → 43,8 |
return fdata; |
} |
void draw_gui(){ |
void draw_gui() |
{ |
_ksys_start_draw(); |
_ksys_create_window(10, 40, (IMG_W+NEW_IMG_W)+50, IMG_H+50, "Libimg", sys_color_table.work_area, 0x34); |
img_draw(image_blend, 10, 10, IMG_W*2, IMG_H , 0, 0); // Draw blended image to window |
49,7 → 51,8 |
_ksys_end_draw(); |
} |
int main(){ |
int main() |
{ |
_ksys_get_system_colors(&sys_color_table); // Get system colors theme |
_ksys_set_event_mask(0xC0000027); |
/programs/develop/ktcc/trunk/libc.obj/samples/clayer/rasterworks.c |
---|
1,8 → 1,7 |
#include <clayer/rasterworks.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <sys/ksys.h> |
#include <clayer/rasterworks.h> |
// Sizes |
int x_size = 768, y_size = 256; |
43,7 → 42,8 |
break; |
case KSYS_EVENT_BUTTON: |
if(_ksys_get_button() == 1) exit(0); |
if (_ksys_get_button() == 1) |
exit(0); |
break; |
}; |
} |
/programs/develop/ktcc/trunk/libc.obj/samples/consoleio.c |
---|
5,8 → 5,9 |
int main() |
{ |
if(con_init()) return 1; // init fail |
(*con_set_title)("Console colors"); |
if (con_init()) |
return 1; // init fail |
(*con_set_tsitle)("Console colors"); |
// con_write_asciiz("\033[0;31;42m test \n"); // red on green bk |
/programs/develop/ktcc/trunk/libc.obj/samples/defgen.c |
---|
1,7 → 1,7 |
#include "stddef.h" |
#include <libgen.h> |
#include <stddef.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <libgen.h> |
#include <string.h> |
#include <sys/ksys.h> |
12,11 → 12,13 |
OUT = 2 |
}; |
void show_help(void){ |
void show_help(void) |
{ |
puts("Usage: defgen [lib.obj] [lib.def]"); |
} |
int main(int argc, char** argv){ |
int main(int argc, char** argv) |
{ |
if(argc!=ARGC_VALID){ |
show_help(); |
/programs/develop/ktcc/trunk/libc.obj/samples/dir_example.c |
---|
1,8 → 1,8 |
#include <sys/dirent.h> |
#include <sys/dir.h> |
#include <conio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <conio.h> |
#include <sys/dir.h> |
#include <sys/dirent.h> |
const char *folder_type = "Folder"; |
const char *file_type = "File"; |
13,8 → 13,7 |
printf("Current directory: %s\n", path); |
if(mkdir("test")){ |
puts("Test folder created!"); |
} |
else{ |
} else { |
puts("Error creating folder!"); |
} |
/programs/develop/ktcc/trunk/libc.obj/samples/file_io.c |
---|
1,7 → 1,7 |
#include <errno.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <errno.h> |
#define READ_MAX 255 |
/programs/develop/ktcc/trunk/libc.obj/samples/http_tcp_demo.c |
---|
1,14 → 1,16 |
#include <clayer/network.h> |
#include <string.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
int main() { |
int main() |
{ |
char *host = "kolibrios.org"; |
int port = 80; |
printf("Connecting to %s on port %d\n", host, port); |
struct addrinfo *addr_info; |
char port_str[16]; sprintf(port_str, "%d", port); |
char port_str[16]; |
sprintf(port_str, "%d", port); |
struct addrinfo hints; |
memset(&hints, 0, sizeof(hints)); |
hints.ai_family = AF_UNSPEC; // IPv4 or IPv6 doesnt matter |
/programs/develop/ktcc/trunk/libc.obj/samples/libc_test.c |
---|
1,15 → 1,17 |
#include <sys/ksys.h> |
#include <assert.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <sys/ksys.h> |
#include <time.h> |
int comp(void *a, void *b) { |
int comp(void* a, void* b) |
{ |
return *(int*)a - *(int*)b; |
} |
int main(){ |
int main() |
{ |
puts("Start testing."); |
assert(NULL == ((void*)0)); |
assert(RAND_MAX == 65535); |
/programs/develop/ktcc/trunk/libc.obj/samples/math_test.c |
---|
1,11 → 1,10 |
#include <math.h> |
#include <stdio.h> |
#include <math.h> |
int main() |
{ |
int i; |
for (i = 0; i < 20; i++) |
{ |
for (i = 0; i < 20; i++) { |
printf("------------------------------------------------------\n"); |
// printf ( "remainder of 5.3 / 2 is %f\n", remainder (5.3,2) ); |
// printf ( "remainder of 18.5 / 4.2 is %f\n", remainder (18.5,4.2) ); |
38,6 → 37,5 |
param = 50; |
result = frexp (param , &n); |
printf ("%f = %f * 2^%d\n", param, result, n); |
} |
} |
/programs/develop/ktcc/trunk/libc.obj/samples/pipe.c |
---|
3,11 → 3,11 |
* Created by turbocat (Maxim Logaev) 2022. |
*/ |
#include <sys/ksys.h> |
#include <assert.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <assert.h> |
#include <string.h> |
#include <sys/ksys.h> |
#define TH_STACK_SIZE 1024 |
#define MESSAGE_SIZE 12 |
16,7 → 16,8 |
int pipefd[2]; |
char *send_message = "HELLO PIPE!"; |
void tmain() { |
void tmain() |
{ |
char recv_message[MESSAGE_SIZE]; |
_ksys_posix_read(pipefd[0], recv_message, MESSAGE_SIZE); |
printf("RECV: %s\n", recv_message); |
25,7 → 26,8 |
exit(0); |
} |
void create_thread(void){ |
void create_thread(void) |
{ |
unsigned tid; // New thread ID |
void *th_stack = malloc(TH_STACK_SIZE); // Allocate memory for thread stack |
if (!th_stack) { |
40,7 → 42,8 |
printf("New thread created (TID=%u)\n", tid); |
} |
void main() { |
void main() |
{ |
if (_ksys_posix_pipe2(pipefd, 0)) { |
puts("Pipe creation error!"); |
return; |
/programs/develop/ktcc/trunk/libc.obj/samples/sdltest.c |
---|
17,30 → 17,27 |
*pixmem32 = colour; |
} |
void DrawScreen(SDL_Surface* screen, int h) |
{ |
int x, y, ytimesw; |
if(SDL_MUSTLOCK(screen)) |
{ |
if(SDL_LockSurface(screen) < 0) return; |
if (SDL_MUSTLOCK(screen)) { |
if (SDL_LockSurface(screen) < 0) |
return; |
} |
for(y = 0; y < screen->h; y++ ) |
{ |
for (y = 0; y < screen->h; y++) { |
ytimesw = y*screen->pitch/BPP; |
for( x = 0; x < screen->w; x++ ) |
{ |
for (x = 0; x < screen->w; x++) { |
setpixel(screen, x, ytimesw, (x*x)/256+3*y+h, (y*y)/256+x+h, h); |
} |
} |
if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); |
if (SDL_MUSTLOCK(screen)) |
SDL_UnlockSurface(screen); |
SDL_Flip(screen); |
} |
int main(int argc, char* argv[]) |
{ |
SDL_Surface *screen; |
49,21 → 46,18 |
int keypress = 0; |
int h=0; |
if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1; |
if (SDL_Init(SDL_INIT_VIDEO) < 0) |
return 1; |
if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_FULLSCREEN|SDL_HWSURFACE))) |
{ |
if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_FULLSCREEN | SDL_HWSURFACE))) { |
SDL_Quit(); |
return 1; |
} |
while(!keypress) |
{ |
while (!keypress) { |
DrawScreen(screen,h++); |
while(SDL_PollEvent(&event)) |
{ |
switch (event.type) |
{ |
while (SDL_PollEvent(&event)) { |
switch (event.type) { |
case SDL_QUIT: |
keypress = 1; |
break; |
/programs/develop/ktcc/trunk/libc.obj/samples/shell_test.c |
---|
2,7 → 2,8 |
char string[256]; |
int main(){ |
int main() |
{ |
shell_cls(); |
shell_printf("SHELL PID=%d\n\r", shell_get_pid()); |
/programs/develop/ktcc/trunk/libc.obj/samples/stdio_test.c |
---|
1,11 → 1,12 |
#include <limits.h> |
#include <stdio.h> |
#include <sys/ksys.h> |
#include <stdio.h> |
#include <limits.h> |
char* test_string1 = "Hello world!"; |
int a, b; |
int main(int argc, char** argv){ |
int main(int argc, char** argv) |
{ |
sscanf("43 53","%d %d",&a, &b); |
printf("(43 53) = (%d %d)\n", a, b); |
printf("Hello world! = %s\n", test_string1); |
/programs/develop/ktcc/trunk/libc.obj/samples/string_test.c |
---|
1,10 → 1,11 |
#include <ctype.h> |
#include <errno.h> |
#include <sys/ksys.h> |
#include <stdio.h> |
#include <string.h> |
#include <ctype.h> |
#include <sys/ksys.h> |
int main(int argc, char** argv){ |
int main(int argc, char** argv) |
{ |
char hello1[]="Hello, KolibriOS!"; |
char hello2[20]; |
memcpy(hello1, hello2, strlen(hello1)); |
/programs/develop/ktcc/trunk/libc.obj/samples/thread_work.c |
---|
5,9 → 5,9 |
* Created by turbocat (Maxim Logaev) 2021. |
*/ |
#include <sys/ksys.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <sys/ksys.h> |
#define TH_STACK_SIZE 1024 |
20,7 → 20,8 |
extern int main(); |
void redraw_window(void){ |
void redraw_window(void) |
{ |
ksys_pos_t mouse_pos = _ksys_get_mouse_pos(KSYS_MOUSE_SCREEN_POS); |
_ksys_start_draw(); |
_ksys_create_window(mouse_pos.x, mouse_pos.y, 140, 60, "Threads", sys_colors.work_area, 0x14); |
29,7 → 30,8 |
_ksys_end_draw(); |
} |
void create_thread(void){ |
void create_thread(void) |
{ |
unsigned tid; // New thread ID |
void *th_stack = malloc(TH_STACK_SIZE); // Allocate memory for thread stack |
if(!th_stack){ |
44,7 → 46,8 |
debug_printf("New thread created (TID=%u)\n", tid); |
} |
int main(){ |
int main() |
{ |
_ksys_get_system_colors(&sys_colors); |
int gui_event; |
redraw_window(); |
/programs/develop/ktcc/trunk/libc.obj/samples/tmpdisk_work.c |
---|
1,7 → 1,7 |
#include "stddef.h" |
#include <sys/ksys.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <sys/ksys.h> |
#define DEV_ADD_DISK 1 |
22,10 → 22,11 |
"DiskSize is too small, might be too little free RAM", |
"Memory allocation failed", |
"Unknown error O_o", |
0}; |
0 |
}; |
int main(){ |
int main() |
{ |
ksys_drv_hand_t tmpdisk_drv = _ksys_load_driver("tmpdisk"); |
if(!tmpdisk_drv){ |
puts("tmpdisk.sys driver not load!"); |
/programs/develop/ktcc/trunk/libc.obj/samples/whois.c |
---|
4,14 → 4,14 |
https://www.binarytides.com/whois-client-code-in-c-with-linux-sockets/ |
*/ |
#include "sys/ksys.h" |
#include <clayer/network.h> |
#include <conio.h> |
#include <errno.h> |
#include "sys/ksys.h" |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <stdlib.h> |
#include <sys/socket.h> |
#include <clayer/network.h> |
#include <conio.h> |
FILE *out=stdout; |
38,7 → 38,6 |
char *str_replace(char *search , char *replace , char *subject ); |
char* str_copy(char*); |
int main(int argc , char *argv[]) |
{ |
char *domain , *data = NULL; |
231,7 → 230,8 |
int hostname_to_ip(char *hostname , char *ip) |
{ |
struct addrinfo *addr_info; |
char port_str[16]; sprintf(port_str, "%d", 80); |
char port_str[16]; |
sprintf(port_str, "%d", 80); |
struct addrinfo hints; |
memset(&hints, 0, sizeof(hints)); |
hints.ai_family = AF_UNSPEC; // IPv4 or IPv6 doesnt matter |