diff options
| author | ruki <[email protected]> | 2016-11-30 09:53:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-11-30 09:53:19 +0800 |
| commit | f715df4627649f3bd03bf2e762d9ad7e13a98dff (patch) | |
| tree | 843f20f76b2aa02e3676105f6e01141d952786e9 | |
| parent | ac4aeb1c415cd13ffea9560bec83a50f41f038b5 (diff) | |
update tbox for linux x64
337 files changed, 7146 insertions, 1123 deletions
diff --git a/core/pkg/tbox.pkg/inc/linux/tbox.config.h b/core/pkg/tbox.pkg/inc/linux/tbox.config.h new file mode 100755 index 000000000..4bdfb3984 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/linux/tbox.config.h @@ -0,0 +1,122 @@ +#ifndef TB_CONFIG_H +#define TB_CONFIG_H + +// version +#define TB_CONFIG_VERSION "1.6.1" +#define TB_CONFIG_VERSION_MAJOR 1 +#define TB_CONFIG_VERSION_MINOR 6 +#define TB_CONFIG_VERSION_ALTER 1 +#define TB_CONFIG_VERSION_BUILD 201611300950 + +// defines +#define TB_CONFIG_OS_LINUX 1 +#define _GNU_SOURCE 1 +#define _REENTRANT 1 +#define TB_CONFIG_SMALL 1 +#define TB_CONFIG_TYPE_HAVE_FLOAT 1 +#define TB_CONFIG_LIBC_HAVE_MEMCPY 1 +#define TB_CONFIG_LIBC_HAVE_MEMSET 1 +#define TB_CONFIG_LIBC_HAVE_MEMMOVE 1 +#define TB_CONFIG_LIBC_HAVE_MEMCMP 1 +#define TB_CONFIG_LIBC_HAVE_STRCAT 1 +#define TB_CONFIG_LIBC_HAVE_STRNCAT 1 +#define TB_CONFIG_LIBC_HAVE_STRCPY 1 +#define TB_CONFIG_LIBC_HAVE_STRNCPY 1 +#define TB_CONFIG_LIBC_HAVE_STRLEN 1 +#define TB_CONFIG_LIBC_HAVE_STRNLEN 1 +#define TB_CONFIG_LIBC_HAVE_STRSTR 1 +#define TB_CONFIG_LIBC_HAVE_STRCMP 1 +#define TB_CONFIG_LIBC_HAVE_STRCASECMP 1 +#define TB_CONFIG_LIBC_HAVE_STRNCMP 1 +#define TB_CONFIG_LIBC_HAVE_STRNCASECMP 1 +#define TB_CONFIG_LIBC_HAVE_WCSCAT 1 +#define TB_CONFIG_LIBC_HAVE_WCSNCAT 1 +#define TB_CONFIG_LIBC_HAVE_WCSCPY 1 +#define TB_CONFIG_LIBC_HAVE_WCSNCPY 1 +#define TB_CONFIG_LIBC_HAVE_WCSLEN 1 +#define TB_CONFIG_LIBC_HAVE_WCSNLEN 1 +#define TB_CONFIG_LIBC_HAVE_WCSSTR 1 +#define TB_CONFIG_LIBC_HAVE_WCSCMP 1 +#define TB_CONFIG_LIBC_HAVE_WCSCASECMP 1 +#define TB_CONFIG_LIBC_HAVE_WCSNCMP 1 +#define TB_CONFIG_LIBC_HAVE_WCSNCASECMP 1 +#define TB_CONFIG_LIBC_HAVE_WCSTOMBS 1 +#define TB_CONFIG_LIBC_HAVE_MBSTOWCS 1 +#define TB_CONFIG_LIBC_HAVE_GMTIME 1 +#define TB_CONFIG_LIBC_HAVE_MKTIME 1 +#define TB_CONFIG_LIBC_HAVE_LOCALTIME 1 +#define TB_CONFIG_LIBC_HAVE_GETTIMEOFDAY 1 +#define TB_CONFIG_LIBC_HAVE_SIGNAL 1 +#define TB_CONFIG_LIBC_HAVE_SETJMP 1 +#define TB_CONFIG_LIBC_HAVE_SIGSETJMP 1 +#define TB_CONFIG_LIBC_HAVE_KILL 1 +#define TB_CONFIG_LIBC_HAVE_BACKTRACE 1 +#define TB_CONFIG_LIBC_HAVE_SETLOCALE 1 +#define TB_CONFIG_LIBC_HAVE_FPUTS 1 +#define TB_CONFIG_LIBC_HAVE_SRANDOM 1 +#define TB_CONFIG_LIBC_HAVE_RANDOM 1 +#define TB_CONFIG_LIBM_HAVE_LOG2 1 +#define TB_CONFIG_LIBM_HAVE_LOG2F 1 +#define TB_CONFIG_LIBM_HAVE_SQRT 1 +#define TB_CONFIG_LIBM_HAVE_SQRTF 1 +#define TB_CONFIG_LIBM_HAVE_ACOS 1 +#define TB_CONFIG_LIBM_HAVE_ACOSF 1 +#define TB_CONFIG_LIBM_HAVE_ASIN 1 +#define TB_CONFIG_LIBM_HAVE_ASINF 1 +#define TB_CONFIG_LIBM_HAVE_POW 1 +#define TB_CONFIG_LIBM_HAVE_POWF 1 +#define TB_CONFIG_LIBM_HAVE_FMOD 1 +#define TB_CONFIG_LIBM_HAVE_FMODF 1 +#define TB_CONFIG_LIBM_HAVE_TAN 1 +#define TB_CONFIG_LIBM_HAVE_TANF 1 +#define TB_CONFIG_LIBM_HAVE_ATAN 1 +#define TB_CONFIG_LIBM_HAVE_ATANF 1 +#define TB_CONFIG_LIBM_HAVE_ATAN2 1 +#define TB_CONFIG_LIBM_HAVE_ATAN2F 1 +#define TB_CONFIG_LIBM_HAVE_COS 1 +#define TB_CONFIG_LIBM_HAVE_COSF 1 +#define TB_CONFIG_LIBM_HAVE_SIN 1 +#define TB_CONFIG_LIBM_HAVE_SINF 1 +#define TB_CONFIG_LIBM_HAVE_EXP 1 +#define TB_CONFIG_LIBM_HAVE_EXPF 1 +#define TB_CONFIG_POSIX_HAVE_POLL 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_MUTEX_INIT 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_CREATE 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_SETSPECIFIC 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_GETSPECIFIC 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_KEY_CREATE 1 +#define TB_CONFIG_POSIX_HAVE_PTHREAD_KEY_DELETE 1 +#define TB_CONFIG_POSIX_HAVE_SOCKET 1 +#define TB_CONFIG_POSIX_HAVE_OPENDIR 1 +#define TB_CONFIG_POSIX_HAVE_DLOPEN 1 +#define TB_CONFIG_POSIX_HAVE_OPEN 1 +#define TB_CONFIG_POSIX_HAVE_GETHOSTNAME 1 +#define TB_CONFIG_POSIX_HAVE_GETIFADDRS 1 +#define TB_CONFIG_POSIX_HAVE_SEM_INIT 1 +#define TB_CONFIG_POSIX_HAVE_GETPAGESIZE 1 +#define TB_CONFIG_POSIX_HAVE_SYSCONF 1 +#define TB_CONFIG_POSIX_HAVE_SCHED_YIELD 1 +#define TB_CONFIG_POSIX_HAVE_REGCOMP 1 +#define TB_CONFIG_POSIX_HAVE_REGEXEC 1 +#define TB_CONFIG_POSIX_HAVE_READV 1 +#define TB_CONFIG_POSIX_HAVE_WRITEV 1 +#define TB_CONFIG_POSIX_HAVE_PREADV 1 +#define TB_CONFIG_POSIX_HAVE_PWRITEV 1 +#define TB_CONFIG_POSIX_HAVE_FDATASYNC 1 +#define TB_CONFIG_POSIX_HAVE_SENDFILE 1 +#define TB_CONFIG_POSIX_HAVE_EPOLL_CREATE 1 +#define TB_CONFIG_POSIX_HAVE_EPOLL_WAIT 1 +#define TB_CONFIG_POSIX_HAVE_POSIX_SPAWNP 1 +#define TB_CONFIG_POSIX_HAVE_EXECVP 1 +#define TB_CONFIG_POSIX_HAVE_FORK 1 +#define TB_CONFIG_POSIX_HAVE_VFORK 1 +#define TB_CONFIG_POSIX_HAVE_WAITPID 1 +#define TB_CONFIG_POSIX_HAVE_GETDTABLESIZE 1 +#define TB_CONFIG_POSIX_HAVE_GETRLIMIT 1 +#define TB_CONFIG_POSIX_HAVE_GETADDRINFO 1 +#define TB_CONFIG_POSIX_HAVE_GETNAMEINFO 1 +#define TB_CONFIG_POSIX_HAVE_GETHOSTBYNAME 1 +#define TB_CONFIG_POSIX_HAVE_GETHOSTBYADDR 1 +#define TB_CONFIG_SYSTEMV_HAVE_SEMGET 1 + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/algorithm.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/algorithm.h index e8c3981ac..a522bb749 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/algorithm.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/algorithm.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file algorithm.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/binary_find.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/binary_find.h index 6a6f0b5f5..2fe312adc 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/binary_find.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/binary_find.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file binary_find.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/binary_find_if.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/binary_find_if.h index 43d9f581c..b4ff71caa 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/binary_find_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/binary_find_if.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file binary_find_if.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/bubble_sort.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/bubble_sort.h index 9d98c046e..0a2543e44 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/bubble_sort.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/bubble_sort.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file bubble_sort.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/count.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/count.h index 58053cbef..660fadacf 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/count.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/count.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file count.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/count_if.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/count_if.h index 4800417b5..05587df88 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/count_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/count_if.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file count_if.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/distance.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/distance.h index 268049483..6a221ada7 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/distance.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/distance.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file distance.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/find.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/find.h index be3ed6f3c..6f8eedbcb 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/find.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/find.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file find.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/find_if.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/find_if.h index d5239aa5c..60c5cf622 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/find_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/find_if.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file find_if.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/for.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/for.h index 814607a3e..435df0c2e 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/for.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/for.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file for.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/for_if.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/for_if.h index cd2270a25..2d558bfaa 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/for_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/for_if.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file for_if.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/heap_sort.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/heap_sort.h index 092ba2387..7e0beffc8 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/heap_sort.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/heap_sort.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file heap_sort.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/insert_sort.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/insert_sort.h index 595be6a66..c59d4b929 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/insert_sort.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/insert_sort.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file insert_sort.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/predicate.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/predicate.h index 3b9e13eb2..7985eb683 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/predicate.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/predicate.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file predicate.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/prefix.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/prefix.h index c991dc554..2ded06148 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/quick_sort.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/quick_sort.h index 51aca3eae..b9845b62c 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/quick_sort.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/quick_sort.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file quick_sort.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/remove.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/remove.h index 55d688378..ba9acb78d 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/remove.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/remove.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file remove.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_first.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_first.h index a5524d6c4..7ebe4009f 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_first.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_first.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file remove_first.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_first_if.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_first_if.h index 12a547e41..1a4bffe08 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_first_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_first_if.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file remove_first_if.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_if.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_if.h index 382a94ffd..af065d9c3 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_if.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file remove_if.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/rfind.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/rfind.h index 5c9bf5368..bae4700fc 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/rfind.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/rfind.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file rfind.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/rfind_if.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/rfind_if.h index 6608f39fa..2501967cd 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/rfind_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/rfind_if.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file rfind_if.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/rfor.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/rfor.h index bbe553812..0a38de78c 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/rfor.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/rfor.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file rfor.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/rfor_if.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/rfor_if.h index 41da291b1..249ce3649 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/rfor_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/rfor_if.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file rfor_if.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/rwalk.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/rwalk.h index f85b0f1a3..dedbe4b8c 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/rwalk.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/rwalk.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file rwalk.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/sort.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/sort.h index 8d76f7c03..2cc4a2d96 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/sort.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/sort.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file sort.h diff --git a/core/pkg/tbox.pkg/inc/tbox/algorithm/walk.h b/core/pkg/tbox.pkg/inc/tbox/algorithm/walk.h index b5fe70f03..6a634aab7 100755 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/walk.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/walk.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file walk.h diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/asio.h b/core/pkg/tbox.pkg/inc/tbox/asio/asio.h index 8d96712c2..b974a8c4b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/asio/asio.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/asio.h @@ -14,11 +14,10 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file asio.h - * @defgroup asio * */ #ifndef TB_ASIO_H @@ -28,15 +27,8 @@ * includes */ #include "prefix.h" -#include "aioo.h" -#include "aioe.h" -#include "aiop.h" -#include "aico.h" -#include "aice.h" -#include "aicp.h" -#include "http.h" -#include "dns.h" -#include "ssl.h" - +#ifdef TB_CONFIG_API_HAVE_DEPRECATED +# include "deprecated/deprecated.h" +#endif #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aice.h b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aice.h new file mode 100755 index 000000000..46db4b058 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aice.h @@ -0,0 +1,482 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file aice.h + * @ingroup asio + */ +#ifndef TB_ASIO_AICE_H +#define TB_ASIO_AICE_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "aico.h" +#include "../../network/ipaddr.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the aice code enum +typedef enum __tb_aice_code_e +{ + TB_AICE_CODE_NONE = 0 + +, TB_AICE_CODE_ACPT = 1 //!< for sock, accept it +, TB_AICE_CODE_CONN = 2 //!< for sock, connect to the host address +, TB_AICE_CODE_RECV = 3 //!< for sock, recv data for tcp +, TB_AICE_CODE_SEND = 4 //!< for sock, send data for tcp +, TB_AICE_CODE_URECV = 5 //!< for sock, recv data for udp +, TB_AICE_CODE_USEND = 6 //!< for sock, send data for udp +, TB_AICE_CODE_RECVV = 7 //!< for sock, recv iovec data for tcp +, TB_AICE_CODE_SENDV = 8 //!< for sock, send iovec data for tcp +, TB_AICE_CODE_URECVV = 9 //!< for sock, recv iovec data for udp +, TB_AICE_CODE_USENDV = 10 //!< for sock, send iovec data for udp +, TB_AICE_CODE_SENDF = 11 //!< for sock, maybe return TB_STATE_NOT_SUPPORTED + +, TB_AICE_CODE_READ = 12 //!< for file, read data +, TB_AICE_CODE_WRIT = 13 //!< for file, writ data +, TB_AICE_CODE_READV = 14 //!< for file, read iovec data +, TB_AICE_CODE_WRITV = 15 //!< for file, writ iovec data +, TB_AICE_CODE_FSYNC = 16 //!< for file, flush data to file + +, TB_AICE_CODE_RUNTASK = 17 //!< for task or sock or file, run task with the given delay +, TB_AICE_CODE_CLOS = 18 //!< for task or sock or file + +, TB_AICE_CODE_MAXN = 19 + +}tb_aice_code_e; + +/// the acpt aice type +typedef struct __tb_aice_acpt_t +{ + /// the client aico + tb_aico_ref_t aico; + + /// the client addr + tb_ipaddr_t addr; + + /// the private data for using the left space of the union + tb_cpointer_t priv[1]; + +}tb_aice_acpt_t; + +/// the conn aice type +typedef struct __tb_aice_conn_t +{ + /// the addr + tb_ipaddr_t addr; + +}tb_aice_conn_t; + +#ifdef TB_CONFIG_OS_WINDOWS +/// the recv aice type, base: tb_iovec_t +typedef struct __tb_aice_recv_t +{ + /// the data size for (tb_iovec_t*)->size + tb_iovec_size_t size; + + /// the recv data for (tb_iovec_t*)->data + tb_byte_t* data; + + /// the data real + tb_size_t real; + +}tb_aice_recv_t; + +/// the send aice type, base: tb_iovec_t +typedef struct __tb_aice_send_t +{ + /// the data size for (tb_iovec_t*)->size + tb_iovec_size_t size; + + /// the send data for (tb_iovec_t*)->data + tb_byte_t const* data; + + /// the data real + tb_size_t real; + +}tb_aice_send_t; + +/// the urecv aice type, base: tb_iovec_t +typedef struct __tb_aice_urecv_t +{ + /// the data size for (tb_iovec_t*)->size + tb_iovec_size_t size; + + /// the recv data for (tb_iovec_t*)->data + tb_byte_t* data; + + /// the data real + tb_size_t real; + + /// the addr + tb_ipaddr_t addr; + +}tb_aice_urecv_t; + +/// the usend aice type, base: tb_iovec_t +typedef struct __tb_aice_usend_t +{ + /// the data size for (tb_iovec_t*)->size + tb_iovec_size_t size; + + /// the send data for (tb_iovec_t*)->data + tb_byte_t const* data; + + /// the data real + tb_size_t real; + + /// the peer addr + tb_ipaddr_t addr; + +}tb_aice_usend_t; + +/// the read aice type, base: tb_iovec_t +typedef struct __tb_aice_read_t +{ + /// the data size for (tb_iovec_t*)->size + tb_iovec_size_t size; + + /// the read data for (tb_iovec_t*)->data + tb_byte_t* data; + + /// the data real + tb_size_t real; + + /// the file seek + tb_hize_t seek; + +}tb_aice_read_t; + +/// the writ aice type, base: tb_iovec_t +typedef struct __tb_aice_writ_t +{ + /// the data size for (tb_iovec_t*)->size + tb_iovec_size_t size; + + /// the writ data for (tb_iovec_t*)->data + tb_byte_t const* data; + + /// the data real + tb_size_t real; + + /// the file seek + tb_hize_t seek; + +}tb_aice_writ_t; +#else +/// the recv aice type, base: tb_iovec_t +typedef struct __tb_aice_recv_t +{ + /// the recv data for (tb_iovec_t*)->data + tb_byte_t* data; + + /// the data size for (tb_iovec_t*)->size + tb_iovec_size_t size; + + /// the data real + tb_size_t real; + +}tb_aice_recv_t; + +/// the send aice type, base: tb_iovec_t +typedef struct __tb_aice_send_t +{ + /// the send data for (tb_iovec_t*)->data + tb_byte_t const* data; + + /// the data size for (tb_iovec_t*)->size + tb_iovec_size_t size; + + /// the data real + tb_size_t real; + +}tb_aice_send_t; + +/// the urecv aice type, base: tb_iovec_t +typedef struct __tb_aice_urecv_t +{ + /// the recv data for (tb_iovec_t*)->data + tb_byte_t* data; + + /// the data size for (tb_iovec_t*)->size + tb_iovec_size_t size; + + /// the data real + tb_size_t real; + + /// the addr + tb_ipaddr_t addr; + +}tb_aice_urecv_t; + +/// the usend aice type, base: tb_iovec_t +typedef struct __tb_aice_usend_t +{ + /// the send data for (tb_iovec_t*)->data + tb_byte_t const* data; + + /// the data size for (tb_iovec_t*)->size + tb_iovec_size_t size; + + /// the data real + tb_size_t real; + + /// the addr + tb_ipaddr_t addr; + +}tb_aice_usend_t; + +/// the read aice type, base: tb_iovec_t +typedef struct __tb_aice_read_t +{ + /// the read data for (tb_iovec_t*)->data + tb_byte_t* data; + + /// the data size for (tb_iovec_t*)->size + tb_iovec_size_t size; + + /// the data real + tb_size_t real; + + /// the file seek + tb_hize_t seek; + +}tb_aice_read_t; + +/// the writ aice type, base: tb_iovec_t +typedef struct __tb_aice_writ_t +{ + /// the writ data for (tb_iovec_t*)->data + tb_byte_t const* data; + + /// the data size for (tb_iovec_t*)->size + tb_iovec_size_t size; + + /// the data real + tb_size_t real; + + /// the file seek + tb_hize_t seek; + +}tb_aice_writ_t; +#endif + +/// the recvv aice type +typedef struct __tb_aice_recvv_t +{ + /// the recv list + tb_iovec_t const* list; + + /// the list size + tb_size_t size; + + /// the data real + tb_size_t real; + +}tb_aice_recvv_t; + +/// the sendv aice type +typedef struct __tb_aice_sendv_t +{ + /// the send list + tb_iovec_t const* list; + + /// the list size + tb_size_t size; + + /// the data real + tb_size_t real; + +}tb_aice_sendv_t; + +/// the urecvv aice type +typedef struct __tb_aice_urecvv_t +{ + /// the recv list + tb_iovec_t const* list; + + /// the list size + tb_size_t size; + + /// the data real + tb_size_t real; + + /// the peer addr + tb_ipaddr_t addr; + +}tb_aice_urecvv_t; + +/// the usendv aice type +typedef struct __tb_aice_usendv_t +{ + /// the send list + tb_iovec_t const* list; + + /// the list size + tb_size_t size; + + /// the data real + tb_size_t real; + + /// the addr + tb_ipaddr_t addr; + +}tb_aice_usendv_t; + +/// the sendf aice type +typedef struct __tb_aice_sendf_t +{ + /// the file + tb_file_ref_t file; + + /// the private data for using the left space of the union + tb_handle_t priv[1]; + + /// the real + tb_size_t real; + + /// the size + tb_hize_t size; + + /// the seek + tb_hize_t seek; + +}tb_aice_sendf_t; + +/// the readv aice type +typedef struct __tb_aice_readv_t +{ + /// the read list + tb_iovec_t const* list; + + /// the list size + tb_size_t size; + + /// the data real + tb_size_t real; + + /// the file seek + tb_hize_t seek; + +}tb_aice_readv_t; + +/// the writv aice type +typedef struct __tb_aice_writv_t +{ + /// the writ list + tb_iovec_t const* list; + + /// the list size + tb_size_t size; + + /// the data real + tb_size_t real; + + /// the file seek + tb_hize_t seek; + +}tb_aice_writv_t; + +/// the runtask aice type +typedef struct __tb_aice_runtask_t +{ + /// the when + tb_hize_t when; + + /// the delay + tb_size_t delay; + +}tb_aice_runtask_t; + +/// the aice type +typedef struct __tb_aice_t +{ + /// the aice code + tb_uint8_t code; + + /*! the state + * + * TB_STATE_OK + * TB_STATE_FAILED + * TB_STATE_KILLED + * TB_STATE_CLOSED + * TB_STATE_PENDING + * TB_STATE_TIMEOUT + * TB_STATE_NOT_SUPPORTED + */ + tb_size_t state; + + /// the aico func + tb_aico_func_t func; + + /// the aico private data + tb_cpointer_t priv; + + /// the aico + tb_aico_ref_t aico; + + /*! the events + * + * tb_iovec_t must be aligned by cpu-bytes for windows WSABUF + */ +#ifdef TB_CONFIG_OS_WINDOWS + __tb_cpu_aligned__ union +#else + union +#endif + { + // for sock + tb_aice_acpt_t acpt; + tb_aice_conn_t conn; + tb_aice_recv_t recv; + tb_aice_send_t send; + tb_aice_urecv_t urecv; + tb_aice_usend_t usend; + tb_aice_recvv_t recvv; + tb_aice_sendv_t sendv; + tb_aice_urecvv_t urecvv; + tb_aice_usendv_t usendv; + tb_aice_sendf_t sendf; + + // for file + tb_aice_read_t read; + tb_aice_writ_t writ; + tb_aice_readv_t readv; + tb_aice_writv_t writv; + + // for task + tb_aice_runtask_t runtask; + + } u; + +}tb_aice_t, *tb_aice_ref_t; + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aico.h b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aico.h new file mode 100755 index 000000000..c48dea735 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aico.h @@ -0,0 +1,731 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file aico.h + * @ingroup asio + * + */ +#ifndef TB_ASIO_AICO_H +#define TB_ASIO_AICO_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "../../network/ipaddr.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ +#define tb_aico_clos(aico, func, priv) tb_aico_clos_(aico, func, priv __tb_debug_vals__) +#define tb_aico_acpt(aico, func, priv) tb_aico_acpt_(aico, func, priv __tb_debug_vals__) +#define tb_aico_conn(aico, addr, func, priv) tb_aico_conn_(aico, addr, func, priv __tb_debug_vals__) +#define tb_aico_recv(aico, data, size, func, priv) tb_aico_recv_(aico, data, size, func, priv __tb_debug_vals__) +#define tb_aico_send(aico, data, size, func, priv) tb_aico_send_(aico, data, size, func, priv __tb_debug_vals__) +#define tb_aico_urecv(aico, data, size, func, priv) tb_aico_urecv_(aico, data, size, func, priv __tb_debug_vals__) +#define tb_aico_usend(aico, addr, data, size, func, priv) tb_aico_usend_(aico, addr, data, size, func, priv __tb_debug_vals__) +#define tb_aico_recvv(aico, list, size, func, priv) tb_aico_recvv_(aico, list, size, func, priv __tb_debug_vals__) +#define tb_aico_sendv(aico, list, size, func, priv) tb_aico_sendv_(aico, list, size, func, priv __tb_debug_vals__) +#define tb_aico_urecvv(aico, addr, list, size, func, priv) tb_aico_urecvv_(aico, addr, list, size, func, priv __tb_debug_vals__) +#define tb_aico_usendv(aico, addr, list, size, func, priv) tb_aico_usendv_(aico, addr, list, size, func, priv __tb_debug_vals__) +#define tb_aico_sendf(aico, file, seek, size, func, priv) tb_aico_sendf_(aico, file, seek, size, func, priv __tb_debug_vals__) +#define tb_aico_read(aico, seek, data, size, func, priv) tb_aico_read_(aico, seek, data, size, func, priv __tb_debug_vals__) +#define tb_aico_writ(aico, seek, data, size, func, priv) tb_aico_writ_(aico, seek, data, size, func, priv __tb_debug_vals__) +#define tb_aico_readv(aico, seek, list, size, func, priv) tb_aico_readv_(aico, seek, list, size, func, priv __tb_debug_vals__) +#define tb_aico_writv(aico, seek, list, size, func, priv) tb_aico_writv_(aico, seek, list, size, func, priv __tb_debug_vals__) +#define tb_aico_fsync(aico, func, priv) tb_aico_fsync_(aico, func, priv __tb_debug_vals__) + +#define tb_aico_clos_after(aico, delay, func, priv) tb_aico_clos_after_(aico, delay, func, priv __tb_debug_vals__) +#define tb_aico_acpt_after(aico, delay, func, priv) tb_aico_acpt_after_(aico, delay, func, priv __tb_debug_vals__) +#define tb_aico_conn_after(aico, delay, addr, func, priv) tb_aico_conn_after_(aico, delay, addr, func, priv __tb_debug_vals__) +#define tb_aico_recv_after(aico, delay, data, size, func, priv) tb_aico_recv_after_(aico, delay, data, size, func, priv __tb_debug_vals__) +#define tb_aico_send_after(aico, delay, data, size, func, priv) tb_aico_send_after_(aico, delay, data, size, func, priv __tb_debug_vals__) +#define tb_aico_urecv_after(aico, delay, data, size, func, priv) tb_aico_urecv_after_(aico, delay, data, size, func, priv __tb_debug_vals__) +#define tb_aico_usend_after(aico, delay, addr, data, size, func, priv) tb_aico_usend_after_(aico, delay, addr, data, size, func, priv __tb_debug_vals__) +#define tb_aico_recvv_after(aico, delay, list, size, func, priv) tb_aico_recvv_after_(aico, delay, list, size, func, priv __tb_debug_vals__) +#define tb_aico_sendv_after(aico, delay, list, size, func, priv) tb_aico_sendv_after_(aico, delay, list, size, func, priv __tb_debug_vals__) +#define tb_aico_urecvv_after(aico, delay, addr, list, size, func, priv) tb_aico_urecvv_after_(aico, delay, addr, list, size, func, priv __tb_debug_vals__) +#define tb_aico_usendv_after(aico, delay, addr, list, size, func, priv) tb_aico_usendv_after_(aico, delay, addr, list, size, func, priv __tb_debug_vals__) +#define tb_aico_sendf_after(aico, delay, file, seek, size, func, priv) tb_aico_sendf_after_(aico, delay, file, seek, size, func, priv __tb_debug_vals__) +#define tb_aico_read_after(aico, delay, seek, data, size, func, priv) tb_aico_read_after_(aico, delay, seek, data, size, func, priv __tb_debug_vals__) +#define tb_aico_writ_after(aico, delay, seek, data, size, func, priv) tb_aico_writ_after_(aico, delay, seek, data, size, func, priv __tb_debug_vals__) +#define tb_aico_readv_after(aico, delay, seek, list, size, func, priv) tb_aico_readv_after_(aico, delay, seek, list, size, func, priv __tb_debug_vals__) +#define tb_aico_writv_after(aico, delay, seek, list, size, func, priv) tb_aico_writv_after_(aico, delay, seek, list, size, func, priv __tb_debug_vals__) +#define tb_aico_fsync_after(aico, delay, func, priv) tb_aico_fsync_after_(aico, delay, func, priv __tb_debug_vals__) + +#define tb_aico_task_run(aico, delay, func, priv) tb_aico_task_run_(aico, delay, func, priv __tb_debug_vals__) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +struct __tb_aice_t; +/// the aico func type +typedef tb_bool_t (*tb_aico_func_t)(struct __tb_aice_t* aice); + +/// the aico type enum +typedef enum __tb_aico_type_e +{ + TB_AICO_TYPE_NONE = 0 //!< null +, TB_AICO_TYPE_SOCK = 1 //!< sock +, TB_AICO_TYPE_FILE = 2 //!< file +, TB_AICO_TYPE_TASK = 3 //!< task +, TB_AICO_TYPE_MAXN = 4 + +}tb_aico_type_e; + +/// the aico timeout enum, only for sock +typedef enum __tb_aico_timeout_e +{ + TB_AICO_TIMEOUT_CONN = 0 +, TB_AICO_TIMEOUT_RECV = 1 +, TB_AICO_TIMEOUT_SEND = 2 +, TB_AICO_TIMEOUT_MAXN = 3 + +}tb_aico_timeout_e; + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init the aico + * + * @param aicp the aicp + * + * @return the aico + */ +__tb_deprecated__ +tb_aico_ref_t tb_aico_init(tb_aicp_ref_t aicp); + +/*! open the sock aico + * + * @param aicp the aicp + * @param sock the socket + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_open_sock(tb_aico_ref_t aico, tb_socket_ref_t sock); + +/*! open the sock aico from the socket type + * + * @param aicp the aicp + * @param type the socket type + * @param family the address family, default: ipv4 + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_open_sock_from_type(tb_aico_ref_t aico, tb_size_t type, tb_size_t family); + +/*! open the file aico + * + * @param aicp the aicp + * @param file the file + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_open_file(tb_aico_ref_t aico, tb_file_ref_t file); + +/*! open the file aico from path + * + * @param aicp the aicp + * @param path the file path + * @param mode the file mode + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_open_file_from_path(tb_aico_ref_t aico, tb_char_t const* path, tb_size_t mode); + +/*! open the task aico + * + * @param aicp the aicp + * @param ltimer is the lower precision timer? + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_open_task(tb_aico_ref_t aico, tb_bool_t ltimer); + +/*! kill the aico + * + * @param aico the aico + */ +__tb_deprecated__ +tb_void_t tb_aico_kill(tb_aico_ref_t aico); + +/*! exit the aico + * + * @param aico the aico + */ +__tb_deprecated__ +tb_void_t tb_aico_exit(tb_aico_ref_t aico); + +/*! the aico aicp + * + * @param aico the aico + * + * @return the aico aicp + */ +__tb_deprecated__ +tb_aicp_ref_t tb_aico_aicp(tb_aico_ref_t aico); + +/*! the aico type + * + * @param aico the aico + * + * @return the aico type + */ +__tb_deprecated__ +tb_size_t tb_aico_type(tb_aico_ref_t aico); + +/*! get the socket if the aico is socket type + * + * @param aico the aico + * + * @return the socket + */ +__tb_deprecated__ +tb_socket_ref_t tb_aico_sock(tb_aico_ref_t aico); + +/*! get the file if the aico is file type + * + * @param aico the aico + * + * @return the file + */ +__tb_deprecated__ +tb_file_ref_t tb_aico_file(tb_aico_ref_t aico); + +/*! try to close it + * + * @param aico the aico + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_clos_try(tb_aico_ref_t aico); + +/*! the aico timeout + * + * @param aico the aico + * @param type the timeout type + * + * @return the timeout + */ +__tb_deprecated__ +tb_long_t tb_aico_timeout(tb_aico_ref_t aico, tb_size_t type); + +/*! set the aico timeout + * + * @param aico the aico + * @param type the timeout type + * @param timeout the timeout + */ +__tb_deprecated__ +tb_void_t tb_aico_timeout_set(tb_aico_ref_t aico, tb_size_t type, tb_long_t timeout); + +/*! post the clos + * + * @param aicp the aicp + * @param func the func + * @param priv the func private data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_clos_(tb_aico_ref_t aico, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the acpt + * + * @param aico the aico + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_acpt_(tb_aico_ref_t aico, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the conn + * + * @param aico the aico + * @param addr the address + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_conn_(tb_aico_ref_t aico, tb_ipaddr_ref_t addr, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the recv for sock + * + * @param aico the aico + * @param data the data + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_recv_(tb_aico_ref_t aico, tb_byte_t* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the send for sock + * + * @param aico the aico + * @param data the data + * @param size the size, send the left file data if size == 0 + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_send_(tb_aico_ref_t aico, tb_byte_t const* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the urecv for sock + * + * @param aico the aico + * @param data the data + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_urecv_(tb_aico_ref_t aico, tb_byte_t* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the usend for sock + * + * @param aico the aico + * @param addr the addr + * @param data the data + * @param size the size, send the left file data if size == 0 + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_usend_(tb_aico_ref_t aico, tb_ipaddr_ref_t addr, tb_byte_t const* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the recvv for sock + * + * @param aico the aico + * @param list the list + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_recvv_(tb_aico_ref_t aico, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the sendv for sock + * + * @param aico the aico + * @param list the list + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_sendv_(tb_aico_ref_t aico, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the urecvv for sock + * + * @param aico the aico + * @param addr the addr + * @param list the list + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_urecvv_(tb_aico_ref_t aico, tb_ipaddr_ref_t addr, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the usendv for sock + * + * @param aico the aico + * @param addr the addr + * @param list the list + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_usendv_(tb_aico_ref_t aico, tb_ipaddr_ref_t addr, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the sendfile for sock + * + * @param aico the aico + * @param file the file handle + * @param seek the seek + * @param size the size, send the left data if size == 0 + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_sendf_(tb_aico_ref_t aico, tb_file_ref_t file, tb_hize_t seek, tb_hize_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the read for file + * + * @param aico the aico + * @param seek the seek + * @param data the data + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_read_(tb_aico_ref_t aico, tb_hize_t seek, tb_byte_t* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the writ for file + * + * @param aico the aico + * @param seek the seek + * @param data the data + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_writ_(tb_aico_ref_t aico, tb_hize_t seek, tb_byte_t const* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the readv for file + * + * @param aico the aico + * @param seek the seek + * @param list the list + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_readv_(tb_aico_ref_t aico, tb_hize_t seek, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the writv for file + * + * @param aico the aico + * @param seek the seek + * @param list the list + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_writv_(tb_aico_ref_t aico, tb_hize_t seek, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the fsync for file + * + * @param aico the aico + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_fsync_(tb_aico_ref_t aico, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the clos after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_clos_after_(tb_aico_ref_t aico, tb_size_t delay, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the acpt after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_acpt_after_(tb_aico_ref_t aico, tb_size_t delay, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the conn after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param addr the address + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_conn_after_(tb_aico_ref_t aico, tb_size_t delay, tb_ipaddr_ref_t addr, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the recv for sock after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param data the data + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_recv_after_(tb_aico_ref_t aico, tb_size_t delay, tb_byte_t* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the send for sock after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param data the data + * @param size the size, send the left file data if size == 0 + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_send_after_(tb_aico_ref_t aico, tb_size_t delay, tb_byte_t const* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the urecv for sock after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param data the data + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_urecv_after_(tb_aico_ref_t aico, tb_size_t delay, tb_byte_t* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the usend for sock after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param addr the addr + * @param data the data + * @param size the size, send the left file data if size == 0 + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_usend_after_(tb_aico_ref_t aico, tb_size_t delay, tb_ipaddr_ref_t addr, tb_byte_t const* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the recvv for sock after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param list the list + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_recvv_after_(tb_aico_ref_t aico, tb_size_t delay, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the sendv for sock after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param list the list + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_sendv_after_(tb_aico_ref_t aico, tb_size_t delay, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the urecvv for sock after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param addr the addr + * @param list the list + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_urecvv_after_(tb_aico_ref_t aico, tb_size_t delay, tb_ipaddr_ref_t addr, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the usendv for sock after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param addr the addr + * @param list the list + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_usendv_after_(tb_aico_ref_t aico, tb_size_t delay, tb_ipaddr_ref_t addr, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the sendfile for sock after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param file the file handle + * @param seek the seek + * @param size the size, send the left data if size == 0 + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_sendf_after_(tb_aico_ref_t aico, tb_size_t delay, tb_file_ref_t file, tb_hize_t seek, tb_hize_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the read for file after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param seek the seek + * @param data the data + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_read_after_(tb_aico_ref_t aico, tb_size_t delay, tb_hize_t seek, tb_byte_t* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the writ for file after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param seek the seek + * @param data the data + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_writ_after_(tb_aico_ref_t aico, tb_size_t delay, tb_hize_t seek, tb_byte_t const* data, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the readv for file after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param seek the seek + * @param list the list + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_readv_after_(tb_aico_ref_t aico, tb_size_t delay, tb_hize_t seek, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the writv for file after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param seek the seek + * @param list the list + * @param size the size + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_writv_after_(tb_aico_ref_t aico, tb_size_t delay, tb_hize_t seek, tb_iovec_t const* list, tb_size_t size, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! post the fsync for file after the delay time + * + * @param aico the aico + * @param delay the delay time, ms + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_fsync_after_(tb_aico_ref_t aico, tb_size_t delay, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! run aico task after timeout and will be auto-remove it after be expired + * + * only once, need continue to call it again if want to repeat task + * + * @param aico the aico + * @param delay the delay time, ms + * @param func the callback func + * @param priv the callback data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aico_task_run_(tb_aico_ref_t aico, tb_size_t delay, tb_aico_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aicp.h b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aicp.h new file mode 100755 index 000000000..d589732a4 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aicp.h @@ -0,0 +1,178 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file aicp.h + * @ingroup asio + * + */ +#ifndef TB_ASIO_AICP_H +#define TB_ASIO_AICP_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "aice.h" +#include "../../platform/timer.h" +#include "../../container/container.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ + +/// post +#define tb_aicp_post(aicp, aice) tb_aicp_post_(aicp, aice __tb_debug_vals__) +#define tb_aicp_post_after(aicp, delay, aice) tb_aicp_post_after_(aicp, delay, aice __tb_debug_vals__) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! the aicp instance + * + * @return the aicp + */ +__tb_deprecated__ +tb_aicp_ref_t tb_aicp(tb_noarg_t); + +/*! init the aicp + * + * @param maxn the aico maxn, using the default maxn if be zero + * + * @return the aicp + */ +__tb_deprecated__ +tb_aicp_ref_t tb_aicp_init(tb_size_t maxn); + +/*! exit the aicp + * + * @param aicp the aicp + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_exit(tb_aicp_ref_t aicp); + +/*! the aico maxn + * + * @param aicp the aicp + * + * @return the aico maxn + */ +__tb_deprecated__ +tb_size_t tb_aicp_maxn(tb_aicp_ref_t aicp); + +/*! post the aice + * + * @param aicp the aicp + * @param aice the aice + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_post_(tb_aicp_ref_t aicp, tb_aice_ref_t aice __tb_debug_decl__); + +/*! post the aice + * + * @param aicp the aicp + * @param delay the delay time, ms + * @param aice the aice + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_post_after_(tb_aicp_ref_t aicp, tb_size_t delay, tb_aice_ref_t aice __tb_debug_decl__); + +/*! loop aicp for the external thread + * + * @code + * tb_pointer_t tb_aicp_worker_thread(tb_pointer_t) + * { + * tb_aicp_loop(aicp); + * } + * @endcode + * + * @param aicp the aicp + */ +__tb_deprecated__ +tb_void_t tb_aicp_loop(tb_aicp_ref_t aicp); + +/*! loop aicp util ... for the external thread + * + * @code + * tb_bool_t tb_aicp_stop_func(tb_pointer_t) + * { + * if (...) return tb_true; + * return tb_false; + * } + * tb_pointer_t tb_aicp_worker_thread(tb_pointer_t) + * { + * tb_aicp_loop_util(aicp, stop_func, tb_null); + * } + * @endcode + * + * @param aicp the aicp + */ +__tb_deprecated__ +tb_void_t tb_aicp_loop_util(tb_aicp_ref_t aicp, tb_bool_t (*stop)(tb_cpointer_t priv), tb_cpointer_t priv); + +/*! kill loop + * + * @param aicp the aicp + */ +__tb_deprecated__ +tb_void_t tb_aicp_kill(tb_aicp_ref_t aicp); + +/*! kill all and cannot continue to post it, but not kill loop + * + * @param aicp the aicp + */ +__tb_deprecated__ +tb_void_t tb_aicp_kill_all(tb_aicp_ref_t aicp); + +/*! wait all exiting + * + * @param aicp the aicp + * @param timeout the timeout + * + * @return ok: > 0, timeout: 0, failed: -1 + */ +__tb_deprecated__ +tb_long_t tb_aicp_wait_all(tb_aicp_ref_t aicp, tb_long_t timeout); + +/*! the spak time + * + * @param aicp the aicp + * + * @return the time + */ +__tb_deprecated__ +tb_hong_t tb_aicp_time(tb_aicp_ref_t aicp); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aioe.h b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aioe.h new file mode 100755 index 000000000..f7fa7bbaa --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aioe.h @@ -0,0 +1,74 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file aioe.h + * @ingroup asio + * + */ +#ifndef TB_ASIO_AIOE_H +#define TB_ASIO_AIOE_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the aioe code enum, only for sock +typedef enum __tb_aioe_code_e +{ + TB_AIOE_CODE_NONE = 0x0000 +, TB_AIOE_CODE_CONN = 0x0001 +, TB_AIOE_CODE_ACPT = 0x0002 +, TB_AIOE_CODE_RECV = 0x0004 +, TB_AIOE_CODE_SEND = 0x0008 +, TB_AIOE_CODE_EALL = TB_AIOE_CODE_RECV | TB_AIOE_CODE_SEND | TB_AIOE_CODE_ACPT | TB_AIOE_CODE_CONN +, TB_AIOE_CODE_CLEAR = 0x0010 //!< edge trigger. after the event is retrieved by the user, its state is reset +, TB_AIOE_CODE_ONESHOT = 0x0020 //!< causes the event to return only the first occurrence of the filter being triggered + +}tb_aioe_code_e; + +/// the aioe type +typedef struct __tb_aioe_t +{ + /// the code + tb_size_t code; + + /// the priv + tb_cpointer_t priv; + + /// the aioo + tb_aioo_ref_t aioo; + +}tb_aioe_t, *tb_aioe_ref_t; + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aioo.h b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aioo.h new file mode 100755 index 000000000..9b3c1fbe5 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aioo.h @@ -0,0 +1,70 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file aioo.h + * @ingroup asio + * + */ +#ifndef TB_ASIO_AIOO_H +#define TB_ASIO_AIOO_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! the aioo handle + * + * @param aioo the aioo + * + * @return the socket + */ +__tb_deprecated__ +tb_socket_ref_t tb_aioo_sock(tb_aioo_ref_t aioo); + +/*! wait the aioo + * + * blocking wait the single event aioo, so need not aiop + * return the event type if ok, otherwise return 0 for timeout + * + * @param sock the sock + * @param code the aioe code + * @param timeout the timeout, infinity: -1 + * + * @return > 0: the aioe code, 0: timeout, -1: failed + */ +__tb_deprecated__ +tb_long_t tb_aioo_wait(tb_socket_ref_t sock, tb_size_t code, tb_long_t timeout); + + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aiop.h b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aiop.h new file mode 100755 index 000000000..b298458e0 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/aiop.h @@ -0,0 +1,154 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file aiop.h + * @ingroup asio + * + */ +#ifndef TB_ASIO_AIOP_H +#define TB_ASIO_AIOP_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "aioo.h" +#include "aioe.h" +#include "../../platform/prefix.h" +#include "../../container/container.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init the aiop + * + * @param maxn the maximum number of concurrent objects + * + * @return the aiop + */ +__tb_deprecated__ +tb_aiop_ref_t tb_aiop_init(tb_size_t maxn); + +/*! exit the aiop + * + * @param aiop the aiop + */ +__tb_deprecated__ +tb_void_t tb_aiop_exit(tb_aiop_ref_t aiop); + +/*! cler the aiop + * + * @param aiop the aiop + */ +__tb_deprecated__ +tb_void_t tb_aiop_cler(tb_aiop_ref_t aiop); + +/*! kill the aiop + * + * @param aiop the aiop + */ +__tb_deprecated__ +tb_void_t tb_aiop_kill(tb_aiop_ref_t aiop); + +/*! spak the aiop, break the wait + * + * @param aiop the aiop + */ +__tb_deprecated__ +tb_void_t tb_aiop_spak(tb_aiop_ref_t aiop); + +/*! the aioe code is supported for the aiop? + * + * @param aiop the aiop + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aiop_have(tb_aiop_ref_t aiop, tb_size_t code); + +/*! addo the aioo + * + * @param aiop the aiop + * @param sock the socket + * @param code the code + * @param priv the private data + * + * @return the aioo + */ +__tb_deprecated__ +tb_aioo_ref_t tb_aiop_addo(tb_aiop_ref_t aiop, tb_socket_ref_t sock, tb_size_t code, tb_cpointer_t priv); + +/*! delo the aioo + * + * @param aiop the aiop + * @param aioo the aioo + * + */ +__tb_deprecated__ +tb_void_t tb_aiop_delo(tb_aiop_ref_t aiop, tb_aioo_ref_t aioo); + +/*! post the aioe + * + * @param aiop the aiop + * @param aioe the aioe + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aiop_post(tb_aiop_ref_t aiop, tb_aioe_ref_t aioe); + +/*! set the aioe + * + * @param aiop the aiop + * @param aioo the aioo + * @param code the code + * @param priv the private data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aiop_sete(tb_aiop_ref_t aiop, tb_aioo_ref_t aioo, tb_size_t code, tb_cpointer_t priv); + +/*! wait the asio objects in the pool + * + * blocking wait the multiple event objects + * return the event number if ok, otherwise return 0 for timeout + * + * @param aiop the aiop + * @param list the aioe list + * @param maxn the aioe maxn + * @param timeout the timeout, infinity: -1 + * + * @return > 0: the aioe list size, 0: timeout, -1: failed + */ +__tb_deprecated__ +tb_long_t tb_aiop_wait(tb_aiop_ref_t aiop, tb_aioe_ref_t list, tb_size_t maxn, tb_long_t timeout); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/asio.h b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/asio.h new file mode 100755 index 000000000..82cc343f2 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/asio.h @@ -0,0 +1,42 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file asio.h + * @defgroup asio + * + */ +#ifndef TB_ASIO_DEPRECATED_H +#define TB_ASIO_DEPRECATED_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "aioo.h" +#include "aioe.h" +#include "aiop.h" +#include "aico.h" +#include "aice.h" +#include "aicp.h" +#include "http.h" +#include "dns.h" +#include "ssl.h" + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/deprecated.h b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/deprecated.h new file mode 100755 index 000000000..a0dfc6112 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/deprecated.h @@ -0,0 +1,33 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file deprecated.h + * @defgroup asio + * + */ +#ifndef TB_ASIO_DEPRECATED_H +#define TB_ASIO_DEPRECATED_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "asio.h" + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/dns.h b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/dns.h new file mode 100755 index 000000000..3a1efda9d --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/dns.h @@ -0,0 +1,102 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file dns.h + * @ingroup asio + * + */ +#ifndef TB_ASIO_DNS_H +#define TB_ASIO_DNS_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "aicp.h" +#include "../../network/ipaddr.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the aicp dns ref type +typedef __tb_typeref__(aicp_dns); + +/// the aicp dns done func type +typedef tb_void_t (*tb_aicp_dns_done_func_t)(tb_aicp_dns_ref_t dns, tb_char_t const* host, tb_ipaddr_ref_t addr, tb_cpointer_t priv); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init the dns + * + * @param aicp the aicp + * + * @return the dns + */ +__tb_deprecated__ +tb_aicp_dns_ref_t tb_aicp_dns_init(tb_aicp_ref_t aicp); + +/*! kill the dns + * + * @param dns the dns + */ +__tb_deprecated__ +tb_void_t tb_aicp_dns_kill(tb_aicp_dns_ref_t dns); + +/*! exit the dns + * + * @param dns the dns + */ +__tb_deprecated__ +tb_void_t tb_aicp_dns_exit(tb_aicp_dns_ref_t dns); + +/*! done the dns + * + * @param dns the dns + * @param host the host + * @param timeout the timeout, ms + * @param func the done func + * @param priv the func private data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_dns_done(tb_aicp_dns_ref_t dns, tb_char_t const* host, tb_long_t timeout, tb_aicp_dns_done_func_t func, tb_cpointer_t priv); + +/*! the dns aicp + * + * @param handle the dns handle + * + * @return the aicp + */ +__tb_deprecated__ +tb_aicp_ref_t tb_aicp_dns_aicp(tb_aicp_dns_ref_t dns); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/http.h b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/http.h new file mode 100755 index 000000000..8871b3add --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/http.h @@ -0,0 +1,257 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file http.h + * @ingroup asio + * + */ +#ifndef TB_ASIO_HTTP_H +#define TB_ASIO_HTTP_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "aicp.h" +#include "../../network/http.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the aicp http ref type +typedef __tb_typeref__(aicp_http); + +/*! the aicp http open func type + * + * @param http the http handle + * @param state the state + * @param status the http status + * @param priv the func private data + * + * @return tb_true: ok, tb_false: error, but not break aicp + */ +typedef tb_bool_t (*tb_aicp_http_open_func_t)(tb_aicp_http_ref_t http, tb_size_t state, tb_http_status_t const* status, tb_cpointer_t priv); + +/*! the aicp http open func type + * + * @param http the http handle + * @param state the state + * @param priv the func private data + * + * @return tb_true: ok, tb_false: error, but not break aicp + */ +typedef tb_void_t (*tb_aicp_http_clos_func_t)(tb_aicp_http_ref_t http, tb_size_t state, tb_cpointer_t priv); + +/*! the aicp http read func type + * + * @param http the http handle + * @param state the state + * @param data the readed data + * @param real the real size, maybe zero + * @param size the need size + * @param priv the func private data + * + * @return tb_true: ok and continue it if need, tb_false: break it, but not break aicp + */ +typedef tb_bool_t (*tb_aicp_http_read_func_t)(tb_aicp_http_ref_t http, tb_size_t state, tb_byte_t const* data, tb_size_t real, tb_size_t size, tb_cpointer_t priv); + +/*! the aicp http seek func type + * + * @param http the http handle + * @param state the state + * @param offset the real offset + * @param priv the func private data + * + * @return tb_true: ok, tb_false: error, but not break aicp + */ +typedef tb_bool_t (*tb_aicp_http_seek_func_t)(tb_aicp_http_ref_t http, tb_size_t state, tb_hize_t offset, tb_cpointer_t priv); + +/*! the aicp http task func type + * + * @param http the http handle + * @param state the state + * @param priv the func private data + * + * @return tb_true: ok, tb_false: error, but not break aicp + */ +typedef tb_bool_t (*tb_aicp_http_task_func_t)(tb_aicp_http_ref_t http, tb_size_t state, tb_cpointer_t priv); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init the http + * + * @param aicp the aicp + * + * @return the http + */ +__tb_deprecated__ +tb_aicp_http_ref_t tb_aicp_http_init(tb_aicp_ref_t aicp); + +/*! kill the http + * + * @param http the http + */ +__tb_deprecated__ +tb_void_t tb_aicp_http_kill(tb_aicp_http_ref_t http); + +/*! exit the http + * + * @param http the http + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_http_exit(tb_aicp_http_ref_t http); + +/*! open the http + * + * @param http the http + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_http_open(tb_aicp_http_ref_t http, tb_aicp_http_open_func_t func, tb_cpointer_t priv); + +/*! close the http + * + * @param http the http + * @param func the func + * @param priv the private data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_http_clos(tb_aicp_http_ref_t http, tb_aicp_http_clos_func_t func, tb_cpointer_t priv); + +/*! try closing the http + * + * @param http the http + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_http_clos_try(tb_aicp_http_ref_t http); + +/*! read the http + * + * @param http the http + * @param size the read size, using the default size if be zero + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_http_read(tb_aicp_http_ref_t http, tb_size_t size, tb_aicp_http_read_func_t func, tb_cpointer_t priv); + +/*! read the http after the delay time + * + * @param http the http + * @param delay the delay time, ms + * @param size the read size, using the default size if be zero + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_http_read_after(tb_aicp_http_ref_t http, tb_size_t delay, tb_size_t size, tb_aicp_http_read_func_t func, tb_cpointer_t priv); + +/*! seek the http + * + * @param http the http + * @param offset the offset + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_http_seek(tb_aicp_http_ref_t http, tb_hize_t offset, tb_aicp_http_seek_func_t func, tb_cpointer_t priv); + +/*! task the http + * + * @param http the http + * @param delay the delay time, ms + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_http_task(tb_aicp_http_ref_t http, tb_size_t delay, tb_aicp_http_task_func_t func, tb_cpointer_t priv); + +/*! open and read the http, open it first if not opened + * + * @param http the http + * @param size the read size, using the default size if be zero + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_http_open_read(tb_aicp_http_ref_t http, tb_size_t size, tb_aicp_http_read_func_t func, tb_cpointer_t priv); + +/*! open and seek the http, open it first if not opened + * + * @param http the http + * @param offset the offset + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_http_open_seek(tb_aicp_http_ref_t http, tb_hize_t offset, tb_aicp_http_seek_func_t func, tb_cpointer_t priv); + +/*! the http aicp + * + * @param http the http + * + * @return the aicp + */ +__tb_deprecated__ +tb_aicp_ref_t tb_aicp_http_aicp(tb_aicp_http_ref_t http); + +/*! ctrl the http option + * + * @param http the http + * @param option the http option + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_http_ctrl(tb_aicp_http_ref_t http, tb_size_t option, ...); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/prefix.h b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/prefix.h new file mode 100755 index 000000000..65637b603 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/prefix.h @@ -0,0 +1,137 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * + */ +#ifndef TB_ASIO_DEPRECATED_PREFIX_H +#define TB_ASIO_DEPRECATED_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" +#include "../../platform/prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the aioo ref type +typedef __tb_typeref__(aioo); + +/// the aico ref type +typedef __tb_typeref__(aico); + +/*! the aico pool ref type + * + * <pre> + * |------------------------------------------------| + * | astream | + * |------------------------------------------------| + * | addr | http | file | sock | .. | + * '------------------------------------------------' + * | + * init: [aicp] + * | + * |------------------------------------------------| + * addo: | aico0 aico1 aico2 aico3 ... | <= sock, file, and task aico + * '------------------------------------------------' + * | + * [aicp] + * | + * post: |------------------------------------------------| <= only post one aice for the same aico util the aice is finished + * aice: | aice0 aice1 aice2 aice3 ... | <--------------------------------------------------------------------------------- + * '------------------------------------------------' | + * | | + * [aicp] | + * | <= input aices | + * | | + * '-------------------------------------------------------------- | + * | | | + * |--------------------------------------------------------------------------------------------------| | + * | unix proactor | | windows proactor | | + * |-----------------------------------------------------------------------|--------------------------| | + * | | | | | | + * | continue to spak aice | | |----- | | + * | -------------------------------> | | | | | | + * | | \/ [lock] | \/ | | | + * aiop: |------|-------|-------|-------|---- ... --|-----| |-----| | done post | | + * aico: | aico0 aico1 aico2 aico3 ... | | | | | | | | | + * wait: |------|-------|-------|-------|---- ... --|-----| |aice4| | |----------------| | | + * | | | | | | | | | | | | + * | aice0 aice2 | |aice5| | | | | | + * | | | | | | | | | | | | + * | aice1 ... | |aice6| | | iocp | | | + * | | | | | | | | | | | + * | aice3 | |aice7| | | | | | + * | | | | | | | | | | | + * | ... | | ... | | | | | | + * | | | | | | | | wait0 wait1 .. | | | + * | | | | | ---------------- | | + * | wait poll | |queue| | | | | | + * '------------------------------------------------' '-----'-----------'--------------------------' | + * /\ | [lock] | | | + * | | | | | + * | no data? wait aice --------------------------->----------------- | + * |<-----------------------------| worker0 | worker1 | ... | <= done loop for workers | + * -------------------<------------------------- | + * | | | | + * |---------------------------------------------| | + * | aice0 | aice2 | ... | | + * | aice1 | aice3 | ... | <= output aices | + * | ... | aice4 | ... | | + * | ... | ... | ... | | + * '---------------------------------------------' | + * | | | | + * |---------------------------------------------| | + * | caller0 | caller2 | ... | | + * | caller1 | ... | ... | <= done callers | + * | ... | caller3 | ... | | + * | ... | ... | ... | | + * '---------------------------------------------' | + * | | | + * ... ... | + * post aice end ---- | + * | | | + * '---------------------|------------------------------------------------>' + * | + * kill: ... | + * | | + * exit: ... <---------' + * + * </pre> + * + */ +typedef __tb_typeref__(aicp); + +/*! the asio poll pool type + * + * @note only for sock and using level triggered mode + * + * <pre> + * objs: |-----|------|------|--- ... ...---|-------| + * wait: | | + * evet: read writ ... + * </pre> + * + */ +typedef __tb_typeref__(aiop); + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/ssl.h b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/ssl.h new file mode 100755 index 000000000..601aed8ca --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/asio/deprecated/ssl.h @@ -0,0 +1,285 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="ssl://www.gnu.org/licenses/"> ssl://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file ssl.h + * @ingroup asio + * + */ +#ifndef TB_ASIO_SSL_H +#define TB_ASIO_SSL_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "aicp.h" +#include "../../network/ssl.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the aicp ssl ref type +typedef __tb_typeref__(aicp_ssl); + +/*! the aicp ssl open func type + * + * @param ssl the ssl + * @param state the state + * @param priv the func private data + * + * @return tb_true: ok, tb_false: error, but not break aicp + */ +typedef tb_bool_t (*tb_aicp_ssl_open_func_t)(tb_aicp_ssl_ref_t ssl, tb_size_t state, tb_cpointer_t priv); + +/*! the aicp ssl clos func type + * + * @param ssl the ssl + * @param state the state + * @param priv the func private data + */ +typedef tb_void_t (*tb_aicp_ssl_clos_func_t)(tb_aicp_ssl_ref_t ssl, tb_size_t state, tb_cpointer_t priv); + +/*! the aicp ssl read func type + * + * @param ssl the ssl + * @param state the state + * @param data the readed data + * @param real the real size, maybe zero + * @param size the need size + * @param priv the func private data + * + * @return tb_true: ok and continue it if need, tb_false: break it, but not break aicp + */ +typedef tb_bool_t (*tb_aicp_ssl_read_func_t)(tb_aicp_ssl_ref_t ssl, tb_size_t state, tb_byte_t* data, tb_size_t real, tb_size_t size, tb_cpointer_t priv); + +/*! the aicp ssl writ func type + * + * @param ssl the ssl + * @param state the state + * @param data the writed data + * @param real the real size, maybe zero + * @param size the need size + * @param priv the func private data + * + * @return tb_true: ok and continue it if need, tb_false: break it, but not break aicp + */ +typedef tb_bool_t (*tb_aicp_ssl_writ_func_t)(tb_aicp_ssl_ref_t ssl, tb_size_t state, tb_byte_t const* data, tb_size_t real, tb_size_t size, tb_cpointer_t priv); + +/*! the aicp ssl task func type + * + * @param ssl the ssl + * @param state the state + * @param delay the delay + * @param priv the func private data + * + * @return tb_true: ok, tb_false: error, but not break aicp + */ +typedef tb_bool_t (*tb_aicp_ssl_task_func_t)(tb_aicp_ssl_ref_t ssl, tb_size_t state, tb_size_t delay, tb_cpointer_t priv); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init the ssl + * + * @param aicp the aicp + * @param bserver is server endpoint? + * + * @return the ssl + */ +__tb_deprecated__ +tb_aicp_ssl_ref_t tb_aicp_ssl_init(tb_aicp_ref_t aicp, tb_bool_t bserver); + +/*! kill the ssl + * + * @param ssl the ssl + */ +__tb_deprecated__ +tb_void_t tb_aicp_ssl_kill(tb_aicp_ssl_ref_t ssl); + +/*! exit the ssl + * + * @param ssl the ssl + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_ssl_exit(tb_aicp_ssl_ref_t ssl); + +/*! set the ssl aico + * + * @param ssl the ssl + * @param aico the aico + */ +__tb_deprecated__ +tb_void_t tb_aicp_ssl_set_aico(tb_aicp_ssl_ref_t ssl, tb_aico_ref_t aico); + +/*! set the ssl timeout + * + * @param ssl the ssl + * @param timeout the ssl timeout, using the default timeout if be zero + */ +__tb_deprecated__ +tb_void_t tb_aicp_ssl_set_timeout(tb_aicp_ssl_ref_t ssl, tb_long_t timeout); + +/*! open the ssl + * + * @param ssl the ssl + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_ssl_open(tb_aicp_ssl_ref_t ssl, tb_aicp_ssl_open_func_t func, tb_cpointer_t priv); + +/*! close the ssl + * + * @param handle the ssl + * @param func the func + * @param priv the func private data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_ssl_clos(tb_aicp_ssl_ref_t ssl, tb_aicp_ssl_clos_func_t func, tb_cpointer_t priv); + +/*! try closing the ssl + * + * @param ssl the ssl + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_ssl_clos_try(tb_aicp_ssl_ref_t ssl); + +/*! read the ssl + * + * @param ssl the ssl + * @param data the read data + * @param size the read size + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_ssl_read(tb_aicp_ssl_ref_t ssl, tb_byte_t* data, tb_size_t size, tb_aicp_ssl_read_func_t func, tb_cpointer_t priv); + +/*! writ the ssl + * + * @param ssl the ssl + * @param data the data + * @param size the size + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_ssl_writ(tb_aicp_ssl_ref_t ssl, tb_byte_t const* data, tb_size_t size, tb_aicp_ssl_writ_func_t func, tb_cpointer_t priv); + +/*! read the ssl after the delay time + * + * @param ssl the ssl + * @param delay the delay time, ms + * @param data the read data + * @param size the read size + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_ssl_read_after(tb_aicp_ssl_ref_t ssl, tb_size_t delay, tb_byte_t* data, tb_size_t size, tb_aicp_ssl_read_func_t func, tb_cpointer_t priv); + +/*! writ the ssl after the delay time + * + * @param ssl the ssl + * @param delay the delay time, ms + * @param data the data + * @param size the size + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_ssl_writ_after(tb_aicp_ssl_ref_t ssl, tb_size_t delay, tb_byte_t const* data, tb_size_t size, tb_aicp_ssl_writ_func_t func, tb_cpointer_t priv); + +/*! task the ssl + * + * @param ssl the ssl + * @param delay the delay time, ms + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_ssl_task(tb_aicp_ssl_ref_t ssl, tb_size_t delay, tb_aicp_ssl_task_func_t func, tb_cpointer_t priv); + +/*! open and read the ssl, open it first if not opened + * + * @param ssl the ssl + * @param data the read data + * @param size the read size + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_ssl_open_read(tb_aicp_ssl_ref_t ssl, tb_byte_t* data, tb_size_t size, tb_aicp_ssl_read_func_t func, tb_cpointer_t priv); + +/*! open and writ the ssl, open it first if not opened + * + * @param ssl the ssl + * @param data the data + * @param size the size + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +__tb_deprecated__ +tb_bool_t tb_aicp_ssl_open_writ(tb_aicp_ssl_ref_t ssl, tb_byte_t const* data, tb_size_t size, tb_aicp_ssl_writ_func_t func, tb_cpointer_t priv); + +/*! the ssl aicp + * + * @param ssl the ssl + * + * @return the aicp + */ +__tb_deprecated__ +tb_aicp_ref_t tb_aicp_ssl_aicp(tb_aicp_ssl_ref_t ssl); + + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif + diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/prefix.h b/core/pkg/tbox.pkg/inc/tbox/asio/prefix.h index fe7990e96..dd4a8287d 100755 --- a/core/pkg/tbox.pkg/inc/tbox/asio/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h @@ -27,111 +27,5 @@ * includes */ #include "../prefix.h" -#include "../platform/prefix.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * types - */ - -/// the aioo ref type -typedef struct{}* tb_aioo_ref_t; - -/// the aico ref type -typedef struct{}* tb_aico_ref_t; - -/*! the aico pool ref type - * - * <pre> - * |------------------------------------------------| - * | astream | - * |------------------------------------------------| - * | addr | http | file | sock | .. | - * '------------------------------------------------' - * | - * init: [aicp] - * | - * |------------------------------------------------| - * addo: | aico0 aico1 aico2 aico3 ... | <= sock, file, and task aico - * '------------------------------------------------' - * | - * [aicp] - * | - * post: |------------------------------------------------| <= only post one aice for the same aico util the aice is finished - * aice: | aice0 aice1 aice2 aice3 ... | <--------------------------------------------------------------------------------- - * '------------------------------------------------' | - * | | - * [aicp] | - * | <= input aices | - * | | - * '-------------------------------------------------------------- | - * | | | - * |--------------------------------------------------------------------------------------------------| | - * | unix proactor | | windows proactor | | - * |-----------------------------------------------------------------------|--------------------------| | - * | | | | | | - * | continue to spak aice | | |----- | | - * | -------------------------------> | | | | | | - * | | \/ [lock] | \/ | | | - * aiop: |------|-------|-------|-------|---- ... --|-----| |-----| | done post | | - * aico: | aico0 aico1 aico2 aico3 ... | | | | | | | | | - * wait: |------|-------|-------|-------|---- ... --|-----| |aice4| | |----------------| | | - * | | | | | | | | | | | | - * | aice0 aice2 | |aice5| | | | | | - * | | | | | | | | | | | | - * | aice1 ... | |aice6| | | iocp | | | - * | | | | | | | | | | | - * | aice3 | |aice7| | | | | | - * | | | | | | | | | | | - * | ... | | ... | | | | | | - * | | | | | | | | wait0 wait1 .. | | | - * | | | | | ---------------- | | - * | wait poll | |queue| | | | | | - * '------------------------------------------------' '-----'-----------'--------------------------' | - * /\ | [lock] | | | - * | | | | | - * | no data? wait aice --------------------------->----------------- | - * |<-----------------------------| worker0 | worker1 | ... | <= done loop for workers | - * -------------------<------------------------- | - * | | | | - * |---------------------------------------------| | - * | aice0 | aice2 | ... | | - * | aice1 | aice3 | ... | <= output aices | - * | ... | aice4 | ... | | - * | ... | ... | ... | | - * '---------------------------------------------' | - * | | | | - * |---------------------------------------------| | - * | caller0 | caller2 | ... | | - * | caller1 | ... | ... | <= done callers | - * | ... | caller3 | ... | | - * | ... | ... | ... | | - * '---------------------------------------------' | - * | | | - * ... ... | - * post aice end ---- | - * | | | - * '---------------------|------------------------------------------------>' - * | - * kill: ... | - * | | - * exit: ... <---------' - * - * </pre> - * - */ -typedef struct{}* tb_aicp_ref_t; - -/*! the asio poll pool type - * - * @note only for sock and using level triggered mode - * - * <pre> - * objs: |-----|------|------|--- ... ...---|-------| - * wait: | | - * evet: read writ ... - * </pre> - * - */ -typedef struct{}* tb_aiop_ref_t; #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/charset/charset.h b/core/pkg/tbox.pkg/inc/tbox/charset/charset.h index e33d12436..ad1fc2fc0 100755 --- a/core/pkg/tbox.pkg/inc/tbox/charset/charset.h +++ b/core/pkg/tbox.pkg/inc/tbox/charset/charset.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file charset.h diff --git a/core/pkg/tbox.pkg/inc/tbox/charset/prefix.h b/core/pkg/tbox.pkg/inc/tbox/charset/prefix.h index 4f36158ce..98aed780c 100755 --- a/core/pkg/tbox.pkg/inc/tbox/charset/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/charset/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/config.h b/core/pkg/tbox.pkg/inc/tbox/config.h index 27ccfd550..1e3b9ec03 100755 --- a/core/pkg/tbox.pkg/inc/tbox/config.h +++ b/core/pkg/tbox.pkg/inc/tbox/config.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file config.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/bloom_filter.h b/core/pkg/tbox.pkg/inc/tbox/container/bloom_filter.h index 883e0bab9..76ef1e724 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/bloom_filter.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/bloom_filter.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file bloom_filter.h @@ -111,7 +111,7 @@ __tb_extern_c_enter__ * c = p^(1/k) * s = m / n = 2k / (2c + c * c) */ -typedef struct{}* tb_bloom_filter_ref_t; +typedef __tb_typeref__(bloom_filter); /// the probability of false positives typedef enum __tb_bloom_filter_probability_e diff --git a/core/pkg/tbox.pkg/inc/tbox/container/circle_queue.h b/core/pkg/tbox.pkg/inc/tbox/container/circle_queue.h index 82157147c..f6cdea39c 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/circle_queue.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/circle_queue.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file queue.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/container.h b/core/pkg/tbox.pkg/inc/tbox/container/container.h index 237ceb9c1..0414fc653 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/container.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/container.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file container.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/element.h b/core/pkg/tbox.pkg/inc/tbox/container/element.h index 1ded4b0ff..49f133f54 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/element.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/element.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file element.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/element/hash.h b/core/pkg/tbox.pkg/inc/tbox/container/element/hash.h index 54a4e411a..135d1dd80 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/element/hash.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/element/hash.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file hash.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/element/prefix.h b/core/pkg/tbox.pkg/inc/tbox/container/element/prefix.h index 51bf8c8a4..035851bb0 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/element/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/element/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/hash_map.h b/core/pkg/tbox.pkg/inc/tbox/container/hash_map.h index 8ac423017..7020881b2 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/hash_map.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/hash_map.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file hash_map.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/hash_set.h b/core/pkg/tbox.pkg/inc/tbox/container/hash_set.h index db0e930e8..612bc29dc 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/hash_set.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/hash_set.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file hash_set.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/heap.h b/core/pkg/tbox.pkg/inc/tbox/container/heap.h index 612618bca..1a8bd7343 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/heap.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/heap.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file heap.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/iterator.h b/core/pkg/tbox.pkg/inc/tbox/container/iterator.h index c0d26e620..fd7cd32eb 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/iterator.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/iterator.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file iterator.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/iterator/prefix.h b/core/pkg/tbox.pkg/inc/tbox/container/iterator/prefix.h index d84483189..56b561874 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/iterator/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/iterator/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/list.h b/core/pkg/tbox.pkg/inc/tbox/container/list.h index f27c4935a..0bad078c6 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/list.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/list.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file list.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/list_entry.h b/core/pkg/tbox.pkg/inc/tbox/container/list_entry.h index 4a006a16d..7d5311677 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/list_entry.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/list_entry.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file list_entry.h @@ -34,8 +34,26 @@ * macros */ -/// the list entry -#define tb_list_entry(head, entry) ((((tb_byte_t*)(entry)) - (head)->eoff)) +/// get the list entry +#define tb_list_entry(head, entry) ((((tb_byte_t*)(entry)) - (head)->eoff)) + +/*! get the list entry with zero offset + * + * @code + * + // the xxxx entry type + typedef struct __tb_xxxx_entry_t + { + // the list entry (be placed in header with zero offset) + tb_list_entry_t entry; + + // .. + + }tb_xxxx_entry_t; + * + * @endcode + */ +#define tb_list_entry0(entry) (entry) /*! init the list entry * @@ -180,12 +198,11 @@ static __tb_inline__ tb_size_t tb_list_entry_size(tb_list_entry_hea /*! the list next entry * - * @param list the list * @param entry the entry * * @return the next entry */ -static __tb_inline__ tb_list_entry_ref_t tb_list_entry_next(tb_list_entry_head_ref_t list, tb_list_entry_ref_t entry) +static __tb_inline__ tb_list_entry_ref_t tb_list_entry_next(tb_list_entry_ref_t entry) { // check tb_assert(entry); @@ -196,12 +213,11 @@ static __tb_inline__ tb_list_entry_ref_t tb_list_entry_next(tb_list_entry_hea /*! the list prev entry * - * @param list the list * @param entry the entry * * @return the prev entry */ -static __tb_inline__ tb_list_entry_ref_t tb_list_entry_prev(tb_list_entry_head_ref_t list, tb_list_entry_ref_t entry) +static __tb_inline__ tb_list_entry_ref_t tb_list_entry_prev(tb_list_entry_ref_t entry) { // check tb_assert(entry); diff --git a/core/pkg/tbox.pkg/inc/tbox/container/prefix.h b/core/pkg/tbox.pkg/inc/tbox/container/prefix.h index 3dde431fe..08d9f9a08 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/priority_queue.h b/core/pkg/tbox.pkg/inc/tbox/container/priority_queue.h index 2e87a64ae..a37c15d63 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/priority_queue.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/priority_queue.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file priority_queue.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/queue.h b/core/pkg/tbox.pkg/inc/tbox/container/queue.h index 8aa5a98aa..d52ca1538 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/queue.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/queue.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file queue.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/single_list.h b/core/pkg/tbox.pkg/inc/tbox/container/single_list.h index 861c749c0..81f6a46df 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/single_list.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/single_list.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file single_list.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/single_list_entry.h b/core/pkg/tbox.pkg/inc/tbox/container/single_list_entry.h index c45be57b1..641898ac3 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/single_list_entry.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/single_list_entry.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file single_list_entry.h @@ -37,6 +37,24 @@ /// the list entry #define tb_single_list_entry(head, entry) ((((tb_byte_t*)(entry)) - (head)->eoff)) +/*! get the list entry with zero offset + * + * @code + * + // the xxxx entry type + typedef struct __tb_xxxx_entry_t + { + // the list entry (be placed in header with zero offset) + tb_single_list_entry_t entry; + + // .. + + }tb_xxxx_entry_t; + * + * @endcode + */ +#define tb_single_list_entry0(entry) (entry) + /*! init the list entry * * @code @@ -175,12 +193,11 @@ static __tb_inline__ tb_size_t tb_single_list_entry_size(tb_sin /*! the list next entry * - * @param list the list * @param entry the entry * * @return the next entry */ -static __tb_inline__ tb_single_list_entry_ref_t tb_single_list_entry_next(tb_single_list_entry_head_ref_t list, tb_single_list_entry_ref_t entry) +static __tb_inline__ tb_single_list_entry_ref_t tb_single_list_entry_next(tb_single_list_entry_ref_t entry) { // check tb_assert(entry); diff --git a/core/pkg/tbox.pkg/inc/tbox/container/stack.h b/core/pkg/tbox.pkg/inc/tbox/container/stack.h index d357eca0a..d538ad061 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/stack.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/stack.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file stack.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/vector.h b/core/pkg/tbox.pkg/inc/tbox/container/vector.h index 6306fd7f9..060ffab9a 100755 --- a/core/pkg/tbox.pkg/inc/tbox/container/vector.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/vector.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file vector.h diff --git a/core/pkg/tbox.pkg/inc/tbox/coroutine/channel.h b/core/pkg/tbox.pkg/inc/tbox/coroutine/channel.h new file mode 100755 index 000000000..3aa5d5102 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/coroutine/channel.h @@ -0,0 +1,118 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file channel.h + * @ingroup coroutine + * + */ +#ifndef TB_COROUTINE_CHANNEL_H +#define TB_COROUTINE_CHANNEL_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "../container/container.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the coroutine channel ref type +typedef __tb_typeref__(co_channel); + +/*! the free function type + * + * @param data the channel data + * @param priv the user private data + */ +typedef tb_void_t (*tb_co_channel_free_func_t)(tb_pointer_t data, tb_cpointer_t priv); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init channel + * + * @param size the buffer size, 0: no buffer + * @param free the free function + * @param priv the user private data + * + * @return the channel + */ +tb_co_channel_ref_t tb_co_channel_init(tb_size_t size, tb_co_channel_free_func_t free, tb_cpointer_t priv); + +/*! exit channel + * + * @param channel the channel + */ +tb_void_t tb_co_channel_exit(tb_co_channel_ref_t channel); + +/*! send data into channel + * + * the current coroutine will be suspend if this channel is full + * + * @param channel the channel + * @param data the channel data + */ +tb_void_t tb_co_channel_send(tb_co_channel_ref_t channel, tb_cpointer_t data); + +/*! recv data from channel + * + * the current coroutine will be suspend if no data + * + * @param channel the channel + * + * @return the channel data + */ +tb_pointer_t tb_co_channel_recv(tb_co_channel_ref_t channel); + +/*! try sending data into channel only with buffer + * + * the current coroutine will be suspend if this channel is full + * + * @param channel the channel + * @param data the channel data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_co_channel_send_try(tb_co_channel_ref_t channel, tb_cpointer_t data); + +/*! try recving data from channel only with buffer + * + * the current coroutine will be suspend if no data + * + * @param channel the channel + * @param pdata the channel data pointer + * + * @return tb_true or tb_false + */ +tb_bool_t tb_co_channel_recv_try(tb_co_channel_ref_t channel, tb_pointer_t* pdata); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/coroutine/coroutine.h b/core/pkg/tbox.pkg/inc/tbox/coroutine/coroutine.h new file mode 100755 index 000000000..390640f71 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/coroutine/coroutine.h @@ -0,0 +1,117 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file coroutine.h + * @defgroup coroutine + * + */ +#ifndef TB_COROUTINE_H +#define TB_COROUTINE_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "lock.h" +#include "channel.h" +#include "semaphore.h" +#include "scheduler.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the coroutine ref type +typedef __tb_typeref__(coroutine); + +/// the coroutine function type +typedef tb_void_t (*tb_coroutine_func_t)(tb_cpointer_t priv); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! start coroutine + * + * @param scheduler the scheduler, uses the current scheduler if be null + * @param func the coroutine function + * @param priv the passed user private data as the argument of function + * @param stacksize the stack size + * + * @return tb_true or tb_false + */ +tb_bool_t tb_coroutine_start(tb_co_scheduler_ref_t scheduler, tb_coroutine_func_t func, tb_cpointer_t priv, tb_size_t stacksize); + +/*! yield the current coroutine + * + * @return tb_true(yield ok) or tb_false(yield failed, no more coroutines) + */ +tb_bool_t tb_coroutine_yield(tb_noarg_t); + +/*! resume the given coroutine (suspended) + * + * @param coroutine the suspended coroutine + * @param priv the user private data as the return value of suspend() or sleep() + * + * @return the user private data from suspend(priv) + */ +tb_pointer_t tb_coroutine_resume(tb_coroutine_ref_t coroutine, tb_cpointer_t priv); + +/*! suspend the current coroutine + * + * @param priv the user private data as the return value of resume() + * + * @return the user private data from resume(priv) + */ +tb_pointer_t tb_coroutine_suspend(tb_cpointer_t priv); + +/*! sleep some times (ms) + * + * @param interval the interval (ms), infinity: -1 + * + * @return the user private data from resume(priv) + */ +tb_pointer_t tb_coroutine_sleep(tb_long_t interval); + +/*! wait io events + * + * @param sock the socket + * @param events the waited events, will remove this socket from io scheduler if be TB_SOCKET_EVENT_NONE + * @param timeout the timeout, infinity: -1 + * + * @return > 0: the events, 0: timeout, -1: failed + */ +tb_long_t tb_coroutine_wait(tb_socket_ref_t sock, tb_size_t events, tb_long_t timeout); + +/*! get the current coroutine + * + * @return the current coroutine + */ +tb_coroutine_ref_t tb_coroutine_self(tb_noarg_t); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/coroutine/lock.h b/core/pkg/tbox.pkg/inc/tbox/coroutine/lock.h new file mode 100755 index 000000000..e5644184a --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/coroutine/lock.h @@ -0,0 +1,85 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file lock.h + * @ingroup coroutine + * + */ +#ifndef TB_COROUTINE_LOCK_H +#define TB_COROUTINE_LOCK_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the coroutine lock ref type +typedef __tb_typeref__(co_lock); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init lock + * + * @return the lock + */ +tb_co_lock_ref_t tb_co_lock_init(tb_noarg_t); + +/*! exit lock + * + * @param lock the lock + */ +tb_void_t tb_co_lock_exit(tb_co_lock_ref_t lock); + +/*! enter lock + * + * @param lock the lock + */ +tb_void_t tb_co_lock_enter(tb_co_lock_ref_t lock); + +/*! try to enter lock + * + * @param lock the lock + * + * @return tb_true or tb_false + */ +tb_bool_t tb_co_lock_enter_try(tb_co_lock_ref_t lock); + +/*! leave lock + * + * @param lock the lock + */ +tb_void_t tb_co_lock_leave(tb_co_lock_ref_t lock); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/coroutine/prefix.h b/core/pkg/tbox.pkg/inc/tbox/coroutine/prefix.h new file mode 100755 index 000000000..1ebb846ff --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/coroutine/prefix.h @@ -0,0 +1,32 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * + */ +#ifndef TB_COROUTINE_PREFIX_H +#define TB_COROUTINE_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/coroutine/scheduler.h b/core/pkg/tbox.pkg/inc/tbox/coroutine/scheduler.h new file mode 100755 index 000000000..73a6cfea3 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/coroutine/scheduler.h @@ -0,0 +1,85 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file scheduler.h + * @ingroup coroutine + * + */ +#ifndef TB_COROUTINE_SCHEDULER_H +#define TB_COROUTINE_SCHEDULER_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the coroutine scheduler ref type +typedef __tb_typeref__(co_scheduler); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init scheduler + * + * @return the scheduler + */ +tb_co_scheduler_ref_t tb_co_scheduler_init(tb_noarg_t); + +/*! exit scheduler + * + * @param scheduler the scheduler + */ +tb_void_t tb_co_scheduler_exit(tb_co_scheduler_ref_t scheduler); + +/* kill the scheduler + * + * @param scheduler the scheduler + */ +tb_void_t tb_co_scheduler_kill(tb_co_scheduler_ref_t scheduler); + +/*! run the scheduler loop + * + * @param scheduler the scheduler + * @param exclusive enable exclusive mode, we need ensure only one loop() be called at the same time, + * but it will be faster using thr global scheduler instead of TLS storage + */ +tb_void_t tb_co_scheduler_loop(tb_co_scheduler_ref_t schedule, tb_bool_t exclusive); + +/*! get the scheduler of the current coroutine + * + * @return the scheduler + */ +tb_co_scheduler_ref_t tb_co_scheduler_self(tb_noarg_t); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/coroutine/semaphore.h b/core/pkg/tbox.pkg/inc/tbox/coroutine/semaphore.h new file mode 100755 index 000000000..d38060bfc --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/coroutine/semaphore.h @@ -0,0 +1,93 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file semaphore.h + * @ingroup coroutine + * + */ +#ifndef TB_COROUTINE_SEMAPHORE_H +#define TB_COROUTINE_SEMAPHORE_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the coroutine semaphore ref type +typedef __tb_typeref__(co_semaphore); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init semaphore + * + * @param value the initial semaphore value + * + * @return the semaphore + */ +tb_co_semaphore_ref_t tb_co_semaphore_init(tb_size_t value); + +/*! exit semaphore + * + * @return the semaphore + */ +tb_void_t tb_co_semaphore_exit(tb_co_semaphore_ref_t semaphore); + +/*! post semaphore + * + * @param semaphore the semaphore + * @param post the post semaphore value + * + * @return tb_true or tb_false + */ +tb_void_t tb_co_semaphore_post(tb_co_semaphore_ref_t semaphore, tb_size_t post); + +/*! the semaphore value + * + * @param semaphore the semaphore + * + * @return the semaphore value + */ +tb_size_t tb_co_semaphore_value(tb_co_semaphore_ref_t semaphore); + +/*! wait semaphore + * + * @param semaphore the semaphore + * @param timeout the timeout + * + * @return ok: 1, timeout: 0, fail: -1 + */ +tb_long_t tb_co_semaphore_wait(tb_co_semaphore_ref_t semaphore, tb_long_t timeout); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/database/database.h b/core/pkg/tbox.pkg/inc/tbox/database/database.h index 26122a4ec..8b0c6170b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/database/database.h +++ b/core/pkg/tbox.pkg/inc/tbox/database/database.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file database.h diff --git a/core/pkg/tbox.pkg/inc/tbox/database/prefix.h b/core/pkg/tbox.pkg/inc/tbox/database/prefix.h index e0e7f10d5..a2f9d3101 100755 --- a/core/pkg/tbox.pkg/inc/tbox/database/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/database/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/database/sql.h b/core/pkg/tbox.pkg/inc/tbox/database/sql.h index bdbe4b876..65935b084 100755 --- a/core/pkg/tbox.pkg/inc/tbox/database/sql.h +++ b/core/pkg/tbox.pkg/inc/tbox/database/sql.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file sql.h @@ -48,10 +48,10 @@ typedef enum __tb_database_sql_type_e }tb_database_sql_type_e; /// the database sql ref type -typedef struct{}* tb_database_sql_ref_t; +typedef __tb_typeref__(database_sql); /// the database sql statement ref type -typedef struct{}* tb_database_sql_statement_ref_t; +typedef __tb_typeref__(database_sql_statement); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces diff --git a/core/pkg/tbox.pkg/inc/tbox/database/value.h b/core/pkg/tbox.pkg/inc/tbox/database/value.h index a28d286ee..a81d54f18 100755 --- a/core/pkg/tbox.pkg/inc/tbox/database/value.h +++ b/core/pkg/tbox.pkg/inc/tbox/database/value.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file value.h diff --git a/core/pkg/tbox.pkg/inc/tbox/hash/adler32.h b/core/pkg/tbox.pkg/inc/tbox/hash/adler32.h index b02c8a0f2..94ba8e229 100755 --- a/core/pkg/tbox.pkg/inc/tbox/hash/adler32.h +++ b/core/pkg/tbox.pkg/inc/tbox/hash/adler32.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file adler32.h diff --git a/core/pkg/tbox.pkg/inc/tbox/hash/crc16.h b/core/pkg/tbox.pkg/inc/tbox/hash/crc16.h index 6cce6b28f..636ec65de 100755 --- a/core/pkg/tbox.pkg/inc/tbox/hash/crc16.h +++ b/core/pkg/tbox.pkg/inc/tbox/hash/crc16.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file crc16.h diff --git a/core/pkg/tbox.pkg/inc/tbox/hash/crc32.h b/core/pkg/tbox.pkg/inc/tbox/hash/crc32.h index 276abaae0..99dd1212f 100755 --- a/core/pkg/tbox.pkg/inc/tbox/hash/crc32.h +++ b/core/pkg/tbox.pkg/inc/tbox/hash/crc32.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file crc32.h diff --git a/core/pkg/tbox.pkg/inc/tbox/hash/crc8.h b/core/pkg/tbox.pkg/inc/tbox/hash/crc8.h index 633f67665..35ec93b24 100755 --- a/core/pkg/tbox.pkg/inc/tbox/hash/crc8.h +++ b/core/pkg/tbox.pkg/inc/tbox/hash/crc8.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file crc8.h diff --git a/core/pkg/tbox.pkg/inc/tbox/hash/hash.h b/core/pkg/tbox.pkg/inc/tbox/hash/hash.h index d647253e9..08a6b0bdd 100755 --- a/core/pkg/tbox.pkg/inc/tbox/hash/hash.h +++ b/core/pkg/tbox.pkg/inc/tbox/hash/hash.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file hash.h @@ -44,8 +44,5 @@ #include "murmur.h" #include "adler32.h" #include "blizzard.h" -#ifdef TB_CONFIG_API_HAVE_DEPRECATED -# include "deprecated/deprecated.h" -#endif #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/hash/md5.h b/core/pkg/tbox.pkg/inc/tbox/hash/md5.h index 93f559635..19b015c61 100755 --- a/core/pkg/tbox.pkg/inc/tbox/hash/md5.h +++ b/core/pkg/tbox.pkg/inc/tbox/hash/md5.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file md5.h diff --git a/core/pkg/tbox.pkg/inc/tbox/hash/prefix.h b/core/pkg/tbox.pkg/inc/tbox/hash/prefix.h index d2d05d07c..80560c2f1 100755 --- a/core/pkg/tbox.pkg/inc/tbox/hash/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/hash/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/hash/sha.h b/core/pkg/tbox.pkg/inc/tbox/hash/sha.h index 1ffa458da..5da9674c6 100755 --- a/core/pkg/tbox.pkg/inc/tbox/hash/sha.h +++ b/core/pkg/tbox.pkg/inc/tbox/hash/sha.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file sha.h diff --git a/core/pkg/tbox.pkg/inc/tbox/hash/uuid.h b/core/pkg/tbox.pkg/inc/tbox/hash/uuid.h index ffd24a601..69b8174c1 100755 --- a/core/pkg/tbox.pkg/inc/tbox/hash/uuid.h +++ b/core/pkg/tbox.pkg/inc/tbox/hash/uuid.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file uuid.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/libc.h b/core/pkg/tbox.pkg/inc/tbox/libc/libc.h index 0ae380055..e9ef97beb 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/libc.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/libc.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file libc.h @@ -33,28 +33,4 @@ #include "stdlib/stdlib.h" #include "string/string.h" -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! init libc - * - * @return tb_true or tb_false - */ -tb_bool_t tb_libc_init(tb_noarg_t); - -/*! exit libc - */ -tb_void_t tb_libc_exit(tb_noarg_t); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/misc/ctype.h b/core/pkg/tbox.pkg/inc/tbox/libc/misc/ctype.h index 878fce45c..86ba9b7b3 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/ctype.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/ctype.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file ctype.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/misc/limits.h b/core/pkg/tbox.pkg/inc/tbox/libc/misc/limits.h index 45828a1a7..ca4f79d3a 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/limits.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/limits.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file limits.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/misc/misc.h b/core/pkg/tbox.pkg/inc/tbox/libc/misc/misc.h index 84a6aebbf..2d68c7e1a 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/misc.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/misc.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file misc.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/misc/prefix.h b/core/pkg/tbox.pkg/inc/tbox/libc/misc/prefix.h index 3cd542525..b95cdc7fc 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/misc/setjmp.h b/core/pkg/tbox.pkg/inc/tbox/libc/misc/setjmp.h index b8583dcfd..bd065e7a8 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/setjmp.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/setjmp.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file setjmp.h @@ -38,13 +38,8 @@ // setjmp #ifdef TB_CONFIG_LIBC_HAVE_SETJMP -# if defined(TB_COMPILER_IS_GCC) -# define tb_setjmp(buf) __builtin_setjmp(buf) -# define tb_longjmp(buf, val) __builtin_longjmp(buf, val) -# else -# define tb_setjmp(buf) setjmp(buf) -# define tb_longjmp(buf, val) longjmp(buf, val) -# endif +# define tb_setjmp(buf) setjmp(buf) +# define tb_longjmp(buf, val) longjmp(buf, val) #else # undef tb_setjmp # undef tb_longjmp diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/misc/signal.h b/core/pkg/tbox.pkg/inc/tbox/libc/misc/signal.h index a2db2500f..27e0f5a67 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/signal.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/signal.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file signal.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/misc/stdarg.h b/core/pkg/tbox.pkg/inc/tbox/libc/misc/stdarg.h index 16aff2378..726bdf400 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/stdarg.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/stdarg.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file stdarg.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/prefix.h b/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/prefix.h index af57dee8b..315b48282 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/time.h b/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/time.h index d96c76432..a0015c1f3 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/time.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/time.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file time.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/type.h b/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/type.h index 25679768a..853a54ec4 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/type.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/type.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file type.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/prefix.h b/core/pkg/tbox.pkg/inc/tbox/libc/prefix.h index d01c40204..660dcc309 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/stdio/prefix.h b/core/pkg/tbox.pkg/inc/tbox/libc/stdio/prefix.h index 0b3b5db9e..15e37ffd4 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/stdio/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/stdio/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/stdio/printf_object.h b/core/pkg/tbox.pkg/inc/tbox/libc/stdio/printf_object.h index 966ddc4a9..93cc5f123 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/stdio/printf_object.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/stdio/printf_object.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file printf_object.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/stdio/stdio.h b/core/pkg/tbox.pkg/inc/tbox/libc/stdio/stdio.h index 99935bce8..cdc7d9aae 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/stdio/stdio.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/stdio/stdio.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file stdio.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/stdlib/prefix.h b/core/pkg/tbox.pkg/inc/tbox/libc/stdlib/prefix.h index 16225fb06..5e3c74ca0 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/stdlib/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/stdlib/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/stdlib/stdlib.h b/core/pkg/tbox.pkg/inc/tbox/libc/stdlib/stdlib.h index bef6c0651..e076e76e9 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/stdlib/stdlib.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/stdlib/stdlib.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file stdlib.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/string/prefix.h b/core/pkg/tbox.pkg/inc/tbox/libc/string/prefix.h index 4a7bd507e..cf80ae80c 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/string/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/string/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/string/string.h b/core/pkg/tbox.pkg/inc/tbox/libc/string/string.h index ead619b44..bb2e9f33a 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libc/string/string.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/string/string.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file string.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/ceil.h b/core/pkg/tbox.pkg/inc/tbox/libm/ceil.h index eb3eaf343..07d727b22 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libm/ceil.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/ceil.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file ceil.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/fabs.h b/core/pkg/tbox.pkg/inc/tbox/libm/fabs.h index 2465c49e2..0cd62f2d3 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libm/fabs.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/fabs.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file fabs.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/floor.h b/core/pkg/tbox.pkg/inc/tbox/libm/floor.h index 8c31041c1..3a6cd2b9f 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libm/floor.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/floor.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file floor.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/inf.h b/core/pkg/tbox.pkg/inc/tbox/libm/inf.h index 289ead7e3..50b746013 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libm/inf.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/inf.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file inf.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/libm.h b/core/pkg/tbox.pkg/inc/tbox/libm/libm.h index ddcb0df07..afd208b72 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libm/libm.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/libm.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file libm.h @@ -29,28 +29,4 @@ */ #include "math.h" -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! init libm - * - * @return tb_true or tb_false - */ -tb_bool_t tb_libm_init(tb_noarg_t); - -/*! exit libm - */ -tb_void_t tb_libm_exit(tb_noarg_t); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/maf.h b/core/pkg/tbox.pkg/inc/tbox/libm/maf.h index 3101d4a4a..9f9a465e3 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libm/maf.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/maf.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file maf.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/math.h b/core/pkg/tbox.pkg/inc/tbox/libm/math.h index 5f6b91737..de0bfbf5a 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libm/math.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/math.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file math.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/mif.h b/core/pkg/tbox.pkg/inc/tbox/libm/mif.h index 0518db0d3..e20edb6f8 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libm/mif.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/mif.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file mif.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/nan.h b/core/pkg/tbox.pkg/inc/tbox/libm/nan.h index 0aca2f237..b58b71de0 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libm/nan.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/nan.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file nan.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/pi.h b/core/pkg/tbox.pkg/inc/tbox/libm/pi.h index 29bbc59c7..657e3050a 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libm/pi.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/pi.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file pi.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/prefix.h b/core/pkg/tbox.pkg/inc/tbox/libm/prefix.h index 0e0e72d14..953e781d6 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libm/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/round.h b/core/pkg/tbox.pkg/inc/tbox/libm/round.h index 17e9148fc..5148eae51 100755 --- a/core/pkg/tbox.pkg/inc/tbox/libm/round.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/round.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file round.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed.h index 590578a73..714885fed 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/fixed.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file fixed.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h index 138934543..1e42826b5 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file fixed16.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h index c820018b3..3539d35a1 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file fixed30.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h index ed384c32c..6275fbaea 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file fixed6.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed16_arm.h b/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed16_arm.h index 2a84fca64..eed9c74dc 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed16_arm.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed16_arm.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file fixed16_arm.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed30_arm.h b/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed30_arm.h index 68ea25f26..9447be953 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed30_arm.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed30_arm.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file fixed30_arm.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/impl/impl.h b/core/pkg/tbox.pkg/inc/tbox/math/impl/impl.h new file mode 100755 index 000000000..b8a26a681 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/math/impl/impl.h @@ -0,0 +1,33 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file impl.h + * + */ +#ifndef TB_MATH_IMPL_H +#define TB_MATH_IMPL_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "math.h" + + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/math/impl/math.h b/core/pkg/tbox.pkg/inc/tbox/math/impl/math.h new file mode 100755 index 000000000..041841ae1 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/math/impl/math.h @@ -0,0 +1,55 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file math.h + * + */ +#ifndef TB_MATH_IMPL_MATH_H +#define TB_MATH_IMPL_MATH_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/* init math envirnoment + * + * @return tb_true or tb_false + */ +tb_bool_t tb_math_init_env(tb_noarg_t); + +// exit math envirnoment +tb_void_t tb_math_exit_env(tb_noarg_t); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif + diff --git a/core/pkg/tbox.pkg/inc/tbox/math/impl/prefix.h b/core/pkg/tbox.pkg/inc/tbox/math/impl/prefix.h index 55e9f3aff..6f1d9e87a 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/impl/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/impl/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/int32.h b/core/pkg/tbox.pkg/inc/tbox/math/int32.h index b51d425a3..55983a543 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/int32.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/int32.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file int32.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/math.h b/core/pkg/tbox.pkg/inc/tbox/math/math.h index 9eefda77f..734bde48e 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/math.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/math.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file math.h @@ -35,28 +35,5 @@ #include "fixed.h" #include "random/random.h" -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! init math - * - * @return tb_true or tb_false - */ -tb_bool_t tb_math_init(tb_noarg_t); - -/// exit math -tb_void_t tb_math_exit(tb_noarg_t); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/math/prefix.h b/core/pkg/tbox.pkg/inc/tbox/math/prefix.h index e42d4e57a..6930e024b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/random/linear.h b/core/pkg/tbox.pkg/inc/tbox/math/random/linear.h index f4ab1bd9d..9be1d6879 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/random/linear.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/random/linear.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file linear.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/random/prefix.h b/core/pkg/tbox.pkg/inc/tbox/math/random/prefix.h index 6eca3764e..159bcde10 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/random/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/random/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/random/random.h b/core/pkg/tbox.pkg/inc/tbox/math/random/random.h index e4a43efad..a78d382b3 100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/random/random.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/random/random.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file random.h @@ -44,8 +44,10 @@ __tb_extern_c_enter__ tb_void_t tb_random_seed(tb_size_t seed); /*! reset value using the initial seed + * + * @param pseudo reset to the pseudo random? */ -tb_void_t tb_random_reset(tb_noarg_t); +tb_void_t tb_random_reset(tb_bool_t pseudo); /*! generate the random value * diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/allocator.h b/core/pkg/tbox.pkg/inc/tbox/memory/allocator.h index d78d66b90..8bbe1e042 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/allocator.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/allocator.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file allocator.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/buffer.h b/core/pkg/tbox.pkg/inc/tbox/memory/buffer.h index 98c6f568e..7c0ea0a7f 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/buffer.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/buffer.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file buffer.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/default_allocator.h b/core/pkg/tbox.pkg/inc/tbox/memory/default_allocator.h index 4762a5e7d..05b898699 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/default_allocator.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/default_allocator.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file default_allocator.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/fixed_pool.h b/core/pkg/tbox.pkg/inc/tbox/memory/fixed_pool.h index 433948dd8..214d811d4 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/fixed_pool.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/fixed_pool.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file fixed_pool.h @@ -122,7 +122,7 @@ __tb_extern_c_enter__ * * </pre> */ -typedef struct{}* tb_fixed_pool_ref_t; +typedef __tb_typeref__(fixed_pool); /// the item init func type typedef tb_bool_t (*tb_fixed_pool_item_init_func_t)(tb_pointer_t data, tb_cpointer_t priv); diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/large_allocator.h b/core/pkg/tbox.pkg/inc/tbox/memory/large_allocator.h index f78e70eee..31755a6e2 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/large_allocator.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/large_allocator.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file large_allocator.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/memory.h b/core/pkg/tbox.pkg/inc/tbox/memory/memory.h index b80d00ba2..d16fb7c53 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/memory.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/memory.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file memory.h @@ -41,11 +41,6 @@ #include "default_allocator.h" /* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// * description */ @@ -103,25 +98,5 @@ __tb_extern_c_enter__ * </pre> */ -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! init memory - * - * @param allocator the allocator - * - * @return tb_true or tb_false - */ -tb_bool_t tb_memory_init(tb_allocator_ref_t allocator); - -/// exit memory -tb_void_t tb_memory_exit(tb_noarg_t); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/native_allocator.h b/core/pkg/tbox.pkg/inc/tbox/memory/native_allocator.h index 3df6a16dd..88f96a718 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/native_allocator.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/native_allocator.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file native_allocator.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/prefix.h b/core/pkg/tbox.pkg/inc/tbox/memory/prefix.h index 120511a2a..0476ad1bf 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/queue_buffer.h b/core/pkg/tbox.pkg/inc/tbox/memory/queue_buffer.h index cb4c18d4f..c7356d5dd 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/queue_buffer.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/queue_buffer.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file queue_buffer.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/small_allocator.h b/core/pkg/tbox.pkg/inc/tbox/memory/small_allocator.h index 78100ad28..1bcff6c6e 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/small_allocator.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/small_allocator.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file small_allocator.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/static_allocator.h b/core/pkg/tbox.pkg/inc/tbox/memory/static_allocator.h index 19334dfb9..fe8260b72 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/static_allocator.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/static_allocator.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file static_allocator.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/static_buffer.h b/core/pkg/tbox.pkg/inc/tbox/memory/static_buffer.h index daaa065fd..b289ffc6b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/static_buffer.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/static_buffer.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file static_buffer.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/string_pool.h b/core/pkg/tbox.pkg/inc/tbox/memory/string_pool.h index a1c068a92..598cfb7ee 100755 --- a/core/pkg/tbox.pkg/inc/tbox/memory/string_pool.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/string_pool.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file string_pool.h @@ -39,7 +39,7 @@ __tb_extern_c_enter__ */ /// the string pool ref type -typedef struct{}* tb_string_pool_ref_t; +typedef __tb_typeref__(string_pool); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces diff --git a/core/pkg/tbox.pkg/inc/tbox/network/cookies.h b/core/pkg/tbox.pkg/inc/tbox/network/cookies.h index 5d6438fe9..2a0cd44fc 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/cookies.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/cookies.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file cookies.h @@ -206,7 +206,7 @@ __tb_extern_c_enter__ */ /// the cookies ref type -typedef struct{}* tb_cookies_ref_t; +typedef __tb_typeref__(cookies); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces diff --git a/core/pkg/tbox.pkg/inc/tbox/network/dns/cache.h b/core/pkg/tbox.pkg/inc/tbox/network/dns/cache.h index b4bcdd662..560b9103c 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/dns/cache.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/dns/cache.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file cache.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/dns/dns.h b/core/pkg/tbox.pkg/inc/tbox/network/dns/dns.h index d4553323f..9a7bad817 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/dns/dns.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/dns/dns.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file dns.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/dns/looker.h b/core/pkg/tbox.pkg/inc/tbox/network/dns/looker.h index b400e8108..dd969511f 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/dns/looker.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/dns/looker.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file looker.h @@ -34,7 +34,7 @@ */ /// the dns looker type -typedef struct{}* tb_dns_looker_ref_t; +typedef __tb_typeref__(dns_looker); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces diff --git a/core/pkg/tbox.pkg/inc/tbox/network/dns/prefix.h b/core/pkg/tbox.pkg/inc/tbox/network/dns/prefix.h index ba0e8ccbe..25ab533ef 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/dns/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/dns/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/dns/server.h b/core/pkg/tbox.pkg/inc/tbox/network/dns/server.h index 7a574a28c..f13e5b635 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/dns/server.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/dns/server.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file server.h @@ -30,6 +30,11 @@ #include "prefix.h" /* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// * interfaces */ @@ -62,4 +67,9 @@ tb_size_t tb_dns_server_get(tb_ipaddr_t addr[2]); */ tb_void_t tb_dns_server_add(tb_char_t const* addr); +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/network/http.h b/core/pkg/tbox.pkg/inc/tbox/network/http.h index 6ff4cb986..c82d46c95 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/http.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/http.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file http.h @@ -188,7 +188,7 @@ typedef struct __tb_http_range_t }tb_http_range_t; /// the http ref type -typedef struct{}* tb_http_ref_t; +typedef __tb_typeref__(http); /*! the http head func type * @@ -336,12 +336,12 @@ tb_void_t tb_http_kill(tb_http_ref_t http); * return the event type if ok, otherwise return 0 for timeout * * @param http the http - * @param aioe the aioe + * @param events the events * @param timeout the timeout value, return immediately if 0, infinity if -1 * * @return the event type, return 0 if timeout, return -1 if error */ -tb_long_t tb_http_wait(tb_http_ref_t http, tb_size_t aioe, tb_long_t timeout); +tb_long_t tb_http_wait(tb_http_ref_t http, tb_size_t events, tb_long_t timeout); /*! open the http * diff --git a/core/pkg/tbox.pkg/inc/tbox/network/hwaddr.h b/core/pkg/tbox.pkg/inc/tbox/network/hwaddr.h index f3168cf24..06bb09bed 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/hwaddr.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/hwaddr.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file hwaddr.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/ipaddr.h b/core/pkg/tbox.pkg/inc/tbox/network/ipaddr.h index d24f7400d..7dbb51377 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/ipaddr.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/ipaddr.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file ipaddr.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/ipv4.h b/core/pkg/tbox.pkg/inc/tbox/network/ipv4.h index 5d6639c9d..d5f1259d9 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/ipv4.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/ipv4.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file ipv4.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/ipv6.h b/core/pkg/tbox.pkg/inc/tbox/network/ipv6.h index b9b4b99d5..b38f95bfd 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/ipv6.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/ipv6.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file ipv6.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/network.h b/core/pkg/tbox.pkg/inc/tbox/network/network.h index da1a1972c..079ee01d0 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/network.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/network.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file network.h @@ -38,27 +38,4 @@ #include "cookies.h" #include "dns/dns.h" -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! init network - * - * @return tb_true or tb_false - */ -tb_bool_t tb_network_init(tb_noarg_t); - -/// exit network -tb_void_t tb_network_exit(tb_noarg_t); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/network/prefix.h b/core/pkg/tbox.pkg/inc/tbox/network/prefix.h index f84388c05..cabb62bf0 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/ssl.h b/core/pkg/tbox.pkg/inc/tbox/network/ssl.h index 160bec37d..1cd72fd48 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/ssl.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/ssl.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file ssl.h @@ -73,7 +73,7 @@ typedef tb_long_t (*tb_ssl_func_writ_t)(tb_cpointer_t priv, tb_byte_t const* d /*! the ssl wait func type * * @param priv the priv data for context - * @param code the aioe code + * @param code the events code * @param timeout the timeout * * @return the real code, no event: 0, failed or closed: -1 @@ -81,7 +81,7 @@ typedef tb_long_t (*tb_ssl_func_writ_t)(tb_cpointer_t priv, tb_byte_t const* d typedef tb_long_t (*tb_ssl_func_wait_t)(tb_cpointer_t priv, tb_size_t code, tb_long_t timeout); /// the ssl ref type -typedef struct{}* tb_ssl_ref_t; +typedef __tb_typeref__(ssl); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces @@ -91,26 +91,26 @@ typedef struct{}* tb_ssl_ref_t; * * @param bserver is server endpoint? * - * @return the ssl handle + * @return the ssl */ tb_ssl_ref_t tb_ssl_init(tb_bool_t bserver); /*! exit ssl * - * @param ssl the ssl handle + * @param ssl the ssl */ tb_void_t tb_ssl_exit(tb_ssl_ref_t ssl); /*! set ssl bio sock * - * @param ssl the ssl handle + * @param ssl the ssl * @param sock the sock handle, non-blocking */ tb_void_t tb_ssl_set_bio_sock(tb_ssl_ref_t ssl, tb_socket_ref_t sock); /*! set ssl bio read and writ func * - * @param ssl the ssl handle + * @param ssl the ssl * @param read the read func * @param writ the writ func * #param wait the wait func only for tb_ssl_open and tb_ssl_wait @@ -120,7 +120,7 @@ tb_void_t tb_ssl_set_bio_func(tb_ssl_ref_t ssl, tb_ssl_func_read_t rea /*! set ssl timeout for opening * - * @param ssl the ssl handle + * @param ssl the ssl * @param timeout the timeout */ tb_void_t tb_ssl_set_timeout(tb_ssl_ref_t ssl, tb_long_t timeout); @@ -129,7 +129,7 @@ tb_void_t tb_ssl_set_timeout(tb_ssl_ref_t ssl, tb_long_t timeout); * * @note need wait func * - * @param ssl the ssl handle + * @param ssl the ssl * * @return tb_true or tb_false */ @@ -144,13 +144,13 @@ tb_bool_t tb_ssl_open(tb_ssl_ref_t ssl); while (!(ok = tb_ssl_open_try(handle))) { // wait it - ok = tb_ssl_wait(handle, TB_AIOE_CODE_RECV | TB_AIOE_CODE_SEND, timeout); + ok = tb_ssl_wait(handle, TB_SOCKET_EVENT_RECV | TB_SOCKET_EVENT_SEND, timeout); tb_check_break(ok > 0); } * @endcode * - * @param ssl the ssl handle + * @param ssl the ssl * * @return ok: 1, continue: 0, failed: -1 */ @@ -158,7 +158,7 @@ tb_long_t tb_ssl_open_try(tb_ssl_ref_t ssl); /*! clos ssl * - * @param ssl the ssl handle + * @param ssl the ssl * * @return tb_true or tb_false */ @@ -173,13 +173,13 @@ tb_bool_t tb_ssl_clos(tb_ssl_ref_t ssl); while (!(ok = tb_ssl_clos_try(handle))) { // wait it - ok = tb_ssl_wait(handle, TB_AIOE_CODE_RECV | TB_AIOE_CODE_SEND, timeout); + ok = tb_ssl_wait(handle, TB_SOCKET_EVENT_RECV | TB_SOCKET_EVENT_SEND, timeout); tb_check_break(ok > 0); } * @endcode * - * @param ssl the ssl handle + * @param ssl the ssl * * @return ok: 1, continue: 0, failed: -1 */ @@ -187,7 +187,7 @@ tb_long_t tb_ssl_clos_try(tb_ssl_ref_t ssl); /*! read ssl data * - * @param ssl the ssl handle + * @param ssl the ssl * @param data the data * @param size the size * @@ -197,7 +197,7 @@ tb_long_t tb_ssl_read(tb_ssl_ref_t ssl, tb_byte_t* data, tb_size_t siz /*! writ ssl data * - * @param ssl the ssl handle + * @param ssl the ssl * @param data the data * @param size the size * @@ -207,17 +207,17 @@ tb_long_t tb_ssl_writ(tb_ssl_ref_t ssl, tb_byte_t const* data, tb_size /*! wait ssl data * - * @param ssl the ssl handle - * @param code the aioe code + * @param ssl the ssl + * @param events the events * @param timeout the timeout * - * @return the real code, no event: 0, failed or closed: -1 + * @return the real events, no event: 0, failed or closed: -1 */ -tb_long_t tb_ssl_wait(tb_ssl_ref_t ssl, tb_size_t code, tb_long_t timeout); +tb_long_t tb_ssl_wait(tb_ssl_ref_t ssl, tb_size_t events, tb_long_t timeout); /*! the ssl state see the stream ssl state * - * @param ssl the ssl handle + * @param ssl the ssl * * @return the ssl state */ diff --git a/core/pkg/tbox.pkg/inc/tbox/network/url.h b/core/pkg/tbox.pkg/inc/tbox/network/url.h index b82094ec8..686d12b37 100755 --- a/core/pkg/tbox.pkg/inc/tbox/network/url.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/url.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file url.h @@ -97,6 +97,15 @@ typedef struct __tb_url_t */ tb_bool_t tb_url_init(tb_url_ref_t url); +/*! init url from c-string + * + * @param url the url + * @param cstr the url c-string + * + * @return tb_true or tb_false + */ +tb_bool_t tb_url_init_from_cstr(tb_url_ref_t url, tb_char_t const* cstr); + /*! exit url * * @param url the url diff --git a/core/pkg/tbox.pkg/inc/tbox/object/array.h b/core/pkg/tbox.pkg/inc/tbox/object/array.h index 7e860acbd..19655302f 100755 --- a/core/pkg/tbox.pkg/inc/tbox/object/array.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/array.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file array.h @@ -45,7 +45,7 @@ __tb_extern_c_enter__ * * @return the array object */ -tb_object_ref_t tb_object_array_init(tb_size_t grow, tb_bool_t incr); +tb_object_ref_t tb_oc_array_init(tb_size_t grow, tb_bool_t incr); /*! the array size * @@ -53,7 +53,7 @@ tb_object_ref_t tb_object_array_init(tb_size_t grow, tb_bool_t incr); * * @return the array size */ -tb_size_t tb_object_array_size(tb_object_ref_t array); +tb_size_t tb_oc_array_size(tb_object_ref_t array); /*! the array item at index * @@ -62,14 +62,14 @@ tb_size_t tb_object_array_size(tb_object_ref_t array); * * @return the array item */ -tb_object_ref_t tb_object_array_item(tb_object_ref_t array, tb_size_t index); +tb_object_ref_t tb_oc_array_item(tb_object_ref_t array, tb_size_t index); /*! set the array incr * * @param array the array object * @param incr is increase refn? */ -tb_void_t tb_object_array_incr(tb_object_ref_t array, tb_bool_t incr); +tb_void_t tb_oc_array_incr(tb_object_ref_t array, tb_bool_t incr); /*! the array iterator * @@ -78,7 +78,7 @@ tb_void_t tb_object_array_incr(tb_object_ref_t array, tb_bool_t incr); * @return the array iterator * * @code - * tb_for_all (tb_object_ref_t, item, tb_object_array_itor(array)) + * tb_for_all (tb_object_ref_t, item, tb_oc_array_itor(array)) * { * if (item) * { @@ -87,21 +87,21 @@ tb_void_t tb_object_array_incr(tb_object_ref_t array, tb_bool_t incr); * } * @endcode */ -tb_iterator_ref_t tb_object_array_itor(tb_object_ref_t array); +tb_iterator_ref_t tb_oc_array_itor(tb_object_ref_t array); /*! remove the item from index * * @param array the array object * @param index the array index */ -tb_void_t tb_object_array_remove(tb_object_ref_t array, tb_size_t index); +tb_void_t tb_oc_array_remove(tb_object_ref_t array, tb_size_t index); /*! append item to array * * @param array the array object * @param index the array index */ -tb_void_t tb_object_array_append(tb_object_ref_t array, tb_object_ref_t item); +tb_void_t tb_oc_array_append(tb_object_ref_t array, tb_object_ref_t item); /*! insert item to array * @@ -109,7 +109,7 @@ tb_void_t tb_object_array_append(tb_object_ref_t array, tb_object_ref_ * @param index the array index * @param item the array item */ -tb_void_t tb_object_array_insert(tb_object_ref_t array, tb_size_t index, tb_object_ref_t item); +tb_void_t tb_oc_array_insert(tb_object_ref_t array, tb_size_t index, tb_object_ref_t item); /*! replace item to array * @@ -117,7 +117,7 @@ tb_void_t tb_object_array_insert(tb_object_ref_t array, tb_size_t inde * @param index the array index * @param item the array item */ -tb_void_t tb_object_array_replace(tb_object_ref_t array, tb_size_t index, tb_object_ref_t item); +tb_void_t tb_oc_array_replace(tb_object_ref_t array, tb_size_t index, tb_object_ref_t item); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/object/boolean.h b/core/pkg/tbox.pkg/inc/tbox/object/boolean.h index 5ad12edb6..96a60138b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/object/boolean.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/boolean.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file boolean.h @@ -44,19 +44,19 @@ __tb_extern_c_enter__ * * @return the boolean object */ -tb_object_ref_t tb_object_boolean_init(tb_bool_t value); +tb_object_ref_t tb_oc_boolean_init(tb_bool_t value); /*! the boolean value: true * * @return the boolean object */ -tb_object_ref_t tb_object_boolean_true(tb_noarg_t); +tb_object_ref_t tb_oc_boolean_true(tb_noarg_t); /*! the boolean value: false * * @return the boolean object */ -tb_object_ref_t tb_object_boolean_false(tb_noarg_t); +tb_object_ref_t tb_oc_boolean_false(tb_noarg_t); /*! the boolean value * @@ -64,7 +64,7 @@ tb_object_ref_t tb_object_boolean_false(tb_noarg_t); * * @return tb_true or tb_false */ -tb_bool_t tb_object_boolean_bool(tb_object_ref_t boolean); +tb_bool_t tb_oc_boolean_bool(tb_object_ref_t boolean); /* ////////////////////////////////////////////////////////////////////////////////////// diff --git a/core/pkg/tbox.pkg/inc/tbox/object/data.h b/core/pkg/tbox.pkg/inc/tbox/object/data.h index 6449e8307..79b499183 100755 --- a/core/pkg/tbox.pkg/inc/tbox/object/data.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/data.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file data.h @@ -45,7 +45,7 @@ __tb_extern_c_enter__ * * @return the data object */ -tb_object_ref_t tb_object_data_init_from_url(tb_char_t const* url); +tb_object_ref_t tb_oc_data_init_from_url(tb_char_t const* url); /*! init data from data * @@ -54,7 +54,7 @@ tb_object_ref_t tb_object_data_init_from_url(tb_char_t const* url); * * @return the data object */ -tb_object_ref_t tb_object_data_init_from_data(tb_pointer_t data, tb_size_t size); +tb_object_ref_t tb_oc_data_init_from_data(tb_pointer_t data, tb_size_t size); /*! init data from buffer * @@ -62,7 +62,7 @@ tb_object_ref_t tb_object_data_init_from_data(tb_pointer_t data, tb_size_t s * * @return the data object */ -tb_object_ref_t tb_object_data_init_from_buffer(tb_buffer_ref_t buffer); +tb_object_ref_t tb_oc_data_init_from_buffer(tb_buffer_ref_t buffer); /*! get the data * @@ -70,7 +70,7 @@ tb_object_ref_t tb_object_data_init_from_buffer(tb_buffer_ref_t buffer); * * @return the data address */ -tb_pointer_t tb_object_data_getp(tb_object_ref_t data); +tb_pointer_t tb_oc_data_getp(tb_object_ref_t data); /*! set the data * @@ -80,7 +80,7 @@ tb_pointer_t tb_object_data_getp(tb_object_ref_t data); * * @return tb_true or tb_false */ -tb_bool_t tb_object_data_setp(tb_object_ref_t data, tb_pointer_t addr, tb_size_t size); +tb_bool_t tb_oc_data_setp(tb_object_ref_t data, tb_pointer_t addr, tb_size_t size); /*! the data size * @@ -88,7 +88,7 @@ tb_bool_t tb_object_data_setp(tb_object_ref_t data, tb_pointer_t addr, * * @return the data size */ -tb_size_t tb_object_data_size(tb_object_ref_t data); +tb_size_t tb_oc_data_size(tb_object_ref_t data); /*! the data buffer * @@ -96,7 +96,7 @@ tb_size_t tb_object_data_size(tb_object_ref_t data); * * @return the data buffer */ -tb_buffer_ref_t tb_object_data_buffer(tb_object_ref_t data); +tb_buffer_ref_t tb_oc_data_buffer(tb_object_ref_t data); /*! writ data to url * @@ -104,7 +104,7 @@ tb_buffer_ref_t tb_object_data_buffer(tb_object_ref_t data); * * @return tb_true or tb_false */ -tb_bool_t tb_object_data_writ_to_url(tb_object_ref_t data, tb_char_t const* url); +tb_bool_t tb_oc_data_writ_to_url(tb_object_ref_t data, tb_char_t const* url); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/object/date.h b/core/pkg/tbox.pkg/inc/tbox/object/date.h index 289951c85..1eaae74b5 100755 --- a/core/pkg/tbox.pkg/inc/tbox/object/date.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/date.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file date.h @@ -38,23 +38,11 @@ __tb_extern_c_enter__ * interfaces */ -/*! init date reader - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_date_init_reader(tb_noarg_t); - -/*! init date writer - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_date_init_writer(tb_noarg_t); - /*! init date from now * * @return the date object */ -tb_object_ref_t tb_object_date_init_from_now(tb_noarg_t); +tb_object_ref_t tb_oc_date_init_from_now(tb_noarg_t); /*! init date from time * @@ -62,7 +50,7 @@ tb_object_ref_t tb_object_date_init_from_now(tb_noarg_t); * * @return the date object */ -tb_object_ref_t tb_object_date_init_from_time(tb_time_t time); +tb_object_ref_t tb_oc_date_init_from_time(tb_time_t time); /*! the date time * @@ -70,7 +58,7 @@ tb_object_ref_t tb_object_date_init_from_time(tb_time_t time); * * @return the date time */ -tb_time_t tb_object_date_time(tb_object_ref_t date); +tb_time_t tb_oc_date_time(tb_object_ref_t date); /*! set the date time * @@ -79,7 +67,7 @@ tb_time_t tb_object_date_time(tb_object_ref_t date); * * @return tb_true or tb_false */ -tb_bool_t tb_object_date_time_set(tb_object_ref_t date, tb_time_t time); +tb_bool_t tb_oc_date_time_set(tb_object_ref_t date, tb_time_t time); /*! set the date time for now * @@ -87,7 +75,7 @@ tb_bool_t tb_object_date_time_set(tb_object_ref_t date, tb_time_t time * * @return tb_true or tb_false */ -tb_bool_t tb_object_date_time_set_now(tb_object_ref_t date); +tb_bool_t tb_oc_date_time_set_now(tb_object_ref_t date); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/object/deprecated/array.h b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/array.h new file mode 100755 index 000000000..df7b149c7 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/array.h @@ -0,0 +1,47 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file array.h + * @ingroup object + * + */ +#ifndef TB_OBJECT_DEPRECATED_ARRAY_H +#define TB_OBJECT_DEPRECATED_ARRAY_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +#define tb_object_array_init tb_oc_array_init +#define tb_object_array_size tb_oc_array_size +#define tb_object_array_item tb_oc_array_item +#define tb_object_array_incr tb_oc_array_incr +#define tb_object_array_itor tb_oc_array_itor +#define tb_object_array_remove tb_oc_array_remove +#define tb_object_array_append tb_oc_array_append +#define tb_object_array_insert tb_oc_array_insert +#define tb_object_array_replace tb_oc_array_replace + +#endif + diff --git a/core/pkg/tbox.pkg/inc/tbox/object/deprecated/boolean.h b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/boolean.h new file mode 100755 index 000000000..da0476d15 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/boolean.h @@ -0,0 +1,43 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file boolean.h + * @ingroup object + * + */ +#ifndef TB_OBJECT_DEPRECATED_BOOLEAN_H +#define TB_OBJECT_DEPRECATED_BOOLEAN_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +#define tb_object_boolean_init tb_oc_boolean_init +#define tb_object_boolean_true tb_oc_boolean_true +#define tb_object_boolean_false tb_oc_boolean_false +#define tb_object_boolean_bool tb_oc_boolean_bool + + +#endif + diff --git a/core/pkg/tbox.pkg/inc/tbox/object/deprecated/data.h b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/data.h new file mode 100755 index 000000000..e48c5ffdc --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/data.h @@ -0,0 +1,45 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file data.h + * @ingroup object + * + */ +#ifndef TB_OBJECT_DEPRECATED_DATA_H +#define TB_OBJECT_DEPRECATED_DATA_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ +#define tb_object_data_init_from_url tb_oc_data_init_from_url +#define tb_object_data_init_from_data tb_oc_data_init_from_data +#define tb_object_data_init_from_buffer tb_oc_data_init_from_buffer +#define tb_object_data_getp tb_oc_data_getp +#define tb_object_data_setp tb_oc_data_setp +#define tb_object_data_size tb_oc_data_size +#define tb_object_data_buffer tb_oc_data_buffer +#define tb_object_data_writ_to_url tb_oc_data_writ_to_url + +#endif + diff --git a/core/pkg/tbox.pkg/inc/tbox/object/deprecated/date.h b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/date.h new file mode 100755 index 000000000..6394a613f --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/date.h @@ -0,0 +1,45 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file date.h + * @ingroup object + * + */ +#ifndef TB_OBJECT_DEPRECATED_DATE_H +#define TB_OBJECT_DEPRECATED_DATE_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +#define tb_object_date_init_from_now tb_oc_date_init_from_now +#define tb_object_date_init_from_time tb_oc_date_init_from_time +#define tb_object_date_time tb_oc_date_time +#define tb_object_date_time_set tb_oc_date_time_set +#define tb_object_date_time_set_now tb_oc_date_time_set_now + + + +#endif + diff --git a/core/pkg/tbox.pkg/inc/tbox/object/deprecated/deprecated.h b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/deprecated.h new file mode 100755 index 000000000..a0a9c1437 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/deprecated.h @@ -0,0 +1,39 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file deprecated.h + * + */ +#ifndef TB_OBJECT_DEPRECATED_H +#define TB_OBJECT_DEPRECATED_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "null.h" +#include "data.h" +#include "date.h" +#include "array.h" +#include "string.h" +#include "number.h" +#include "boolean.h" +#include "dictionary.h" + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/object/deprecated/dictionary.h b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/dictionary.h new file mode 100755 index 000000000..99e602206 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/dictionary.h @@ -0,0 +1,66 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file dictionary.h + * @ingroup object + * + */ +#ifndef TB_OBJECT_DEPRECATED_DICTIONARY_H +#define TB_OBJECT_DEPRECATED_DICTIONARY_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ +#define TB_OBJECT_DICTIONARY_SIZE_MICRO (64) +#define TB_OBJECT_DICTIONARY_SIZE_SMALL (256) +#define TB_OBJECT_DICTIONARY_SIZE_LARGE (65536) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the dictionary item type +typedef struct __tb_object_dictionary_item_t +{ + /// the key + tb_char_t const* key; + + /// the value + tb_object_ref_t val; + +}tb_object_dictionary_item_t; + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ +#define tb_object_dictionary_init tb_oc_dictionary_init +#define tb_object_dictionary_size tb_oc_dictionary_size +#define tb_object_dictionary_incr tb_oc_dictionary_incr +#define tb_object_dictionary_itor tb_oc_dictionary_itor +#define tb_object_dictionary_value tb_oc_dictionary_value +#define tb_object_dictionary_insert tb_oc_dictionary_insert +#define tb_object_dictionary_remove tb_oc_dictionary_remove + +#endif + diff --git a/core/pkg/tbox.pkg/inc/tbox/object/deprecated/null.h b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/null.h new file mode 100755 index 000000000..fca1fc5c2 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/null.h @@ -0,0 +1,40 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file null.h + * @ingroup object + * + */ +#ifndef TB_OBJECT_DEPRECATED_NULL_H +#define TB_OBJECT_DEPRECATED_NULL_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +#define tb_object_null_init tb_oc_null_init + + +#endif + diff --git a/core/pkg/tbox.pkg/inc/tbox/object/deprecated/number.h b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/number.h new file mode 100755 index 000000000..ec07b4cb7 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/number.h @@ -0,0 +1,98 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file number.h + * @ingroup object + * + */ +#ifndef TB_OBJECT_DEPRECATED_NUMBER_H +#define TB_OBJECT_DEPRECATED_NUMBER_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the number type enum +typedef enum __tb_object_number_type_e +{ + TB_NUMBER_TYPE_NONE = 0 +, TB_NUMBER_TYPE_UINT8 = 1 +, TB_NUMBER_TYPE_SINT8 = 2 +, TB_NUMBER_TYPE_UINT16 = 3 +, TB_NUMBER_TYPE_SINT16 = 4 +, TB_NUMBER_TYPE_UINT32 = 5 +, TB_NUMBER_TYPE_SINT32 = 6 +, TB_NUMBER_TYPE_UINT64 = 7 +, TB_NUMBER_TYPE_SINT64 = 8 +, TB_NUMBER_TYPE_FLOAT = 9 +, TB_NUMBER_TYPE_DOUBLE = 10 + +}tb_object_number_type_e; + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +#define tb_object_number_init_from_uint8 tb_oc_number_init_from_uint8 +#define tb_object_number_init_from_sint8 tb_oc_number_init_from_sint8 +#define tb_object_number_init_from_uint16 tb_oc_number_init_from_uint16 +#define tb_object_number_init_from_sint16 tb_oc_number_init_from_sint16 +#define tb_object_number_init_from_uint32 tb_oc_number_init_from_uint32 +#define tb_object_number_init_from_sint32 tb_oc_number_init_from_sint32 +#define tb_object_number_init_from_uint64 tb_oc_number_init_from_uint64 +#define tb_object_number_init_from_sint64 tb_oc_number_init_from_sint64 +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT +# define tb_object_number_init_from_float tb_oc_number_init_from_float +# define tb_object_number_init_from_double tb_oc_number_init_from_double +#endif + +#define tb_object_number_type tb_oc_number_type +#define tb_object_number_uint8 tb_oc_number_uint8 +#define tb_object_number_sint8 tb_oc_number_sint8 +#define tb_object_number_uint16 tb_oc_number_uint16 +#define tb_object_number_sint16 tb_oc_number_sint16 +#define tb_object_number_uint32 tb_oc_number_uint32 +#define tb_object_number_sint32 tb_oc_number_sint32 +#define tb_object_number_uint64 tb_oc_number_uint64 +#define tb_object_number_sint64 tb_oc_number_sint64 +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT +# define tb_object_number_float tb_oc_number_float +# define tb_object_number_double tb_oc_number_double +#endif + +#define tb_object_number_uint8_set tb_oc_number_uint8_set +#define tb_object_number_sint8_set tb_oc_number_sint8_set +#define tb_object_number_uint16_set tb_oc_number_uint16_set +#define tb_object_number_sint16_set tb_oc_number_sint16_set +#define tb_object_number_uint32_set tb_oc_number_uint32_set +#define tb_object_number_sint32_set tb_oc_number_sint32_set +#define tb_object_number_uint64_set tb_oc_number_uint64_set +#define tb_object_number_sint64_set tb_oc_number_sint64_set +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT +# define tb_object_number_floa_set tb_oc_number_float_set +# define tb_object_number_double_set tb_oc_number_double_set +#endif + +#endif + diff --git a/core/pkg/tbox.pkg/inc/tbox/object/deprecated/prefix.h b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/prefix.h new file mode 100755 index 000000000..04245e17c --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/prefix.h @@ -0,0 +1,33 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * + */ +#ifndef TB_OBJECT_DEPRECATED_PREFIX_H +#define TB_OBJECT_DEPRECATED_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" + + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/object/deprecated/string.h b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/string.h new file mode 100755 index 000000000..3a65038ba --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/object/deprecated/string.h @@ -0,0 +1,43 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file string.h + * @ingroup object + * + */ +#ifndef TB_OBJECT_DEPRECATED_STRING_H +#define TB_OBJECT_DEPRECATED_STRING_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +#define tb_object_string_init_from_cstr tb_oc_string_init_from_cstr +#define tb_object_string_init_from_str tb_oc_string_init_from_str +#define tb_object_string_cstr tb_oc_string_cstr +#define tb_object_string_cstr_set tb_oc_string_cstr_set +#define tb_object_string_size tb_oc_string_size + +#endif + diff --git a/core/pkg/tbox.pkg/inc/tbox/object/dictionary.h b/core/pkg/tbox.pkg/inc/tbox/object/dictionary.h index a4f9b5dc7..e97e9d9b1 100755 --- a/core/pkg/tbox.pkg/inc/tbox/object/dictionary.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/dictionary.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file dictionary.h @@ -37,24 +37,24 @@ __tb_extern_c_enter__ /* ////////////////////////////////////////////////////////////////////////////////////// * macros */ -#define TB_OBJECT_DICTIONARY_SIZE_MICRO (64) -#define TB_OBJECT_DICTIONARY_SIZE_SMALL (256) -#define TB_OBJECT_DICTIONARY_SIZE_LARGE (65536) +#define TB_OC_DICTIONARY_SIZE_MICRO (64) +#define TB_OC_DICTIONARY_SIZE_SMALL (256) +#define TB_OC_DICTIONARY_SIZE_LARGE (65536) /* ////////////////////////////////////////////////////////////////////////////////////// * types */ /// the dictionary item type -typedef struct __tb_object_dictionary_item_t +typedef struct __tb_oc_dictionary_item_t { /// the key - tb_char_t const* key; + tb_char_t const* key; /// the value - tb_object_ref_t val; + tb_object_ref_t val; -}tb_object_dictionary_item_t; +}tb_oc_dictionary_item_t; /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces @@ -65,20 +65,20 @@ typedef struct __tb_object_dictionary_item_t * @code // init dictionary // {"key1": "hello", "key2" :"world", "key3": 12345, "key4": true} - tb_object_ref_t dict = tb_object_dictionary_init(0, tb_false); + tb_object_ref_t dict = tb_oc_dictionary_init(0, tb_false); if (dict) { // key1 => hello - tb_object_dictionary_insert(dict, "key1", tb_object_string_init_from_cstr("hello")); + tb_oc_dictionary_insert(dict, "key1", tb_oc_string_init_from_cstr("hello")); // key2 => world - tb_object_dictionary_insert(dict, "key2", tb_object_string_init_from_cstr("world")); + tb_oc_dictionary_insert(dict, "key2", tb_oc_string_init_from_cstr("world")); // key3 => 12345 - tb_object_dictionary_insert(dict, "key3", tb_object_number_init_from_sint32(12345)); + tb_oc_dictionary_insert(dict, "key3", tb_oc_number_init_from_sint32(12345)); // key4 => true - tb_object_dictionary_insert(dict, "key4", tb_object_boolean_true()); + tb_oc_dictionary_insert(dict, "key4", tb_oc_boolean_true()); // exit dictionary tb_object_exit(dict); @@ -90,7 +90,7 @@ typedef struct __tb_object_dictionary_item_t * * @return the dictionary object */ -tb_object_ref_t tb_object_dictionary_init(tb_size_t size, tb_bool_t incr); +tb_object_ref_t tb_oc_dictionary_init(tb_size_t size, tb_bool_t incr); /*! the dictionary size * @@ -98,14 +98,14 @@ tb_object_ref_t tb_object_dictionary_init(tb_size_t size, tb_bool_t incr * * @return the dictionary size */ -tb_size_t tb_object_dictionary_size(tb_object_ref_t dictionary); +tb_size_t tb_oc_dictionary_size(tb_object_ref_t dictionary); /*! set the dictionary incr * * @param dictionary the dictionary object * @param incr is increase refn? */ -tb_void_t tb_object_dictionary_incr(tb_object_ref_t dictionary, tb_bool_t incr); +tb_void_t tb_oc_dictionary_incr(tb_object_ref_t dictionary, tb_bool_t incr); /*! the dictionary iterator * @@ -114,7 +114,7 @@ tb_void_t tb_object_dictionary_incr(tb_object_ref_t dictionary, tb * @return the dictionary iterator * * @code - tb_for_all (tb_object_dictionary_item_t*, item, tb_object_dictionary_itor(dictionary)) + tb_for_all (tb_oc_dictionary_item_t*, item, tb_oc_dictionary_itor(dictionary)) { if (item) { @@ -126,7 +126,7 @@ tb_void_t tb_object_dictionary_incr(tb_object_ref_t dictionary, tb } * @endcode */ -tb_iterator_ref_t tb_object_dictionary_itor(tb_object_ref_t dictionary); +tb_iterator_ref_t tb_oc_dictionary_itor(tb_object_ref_t dictionary); /*! get the dictionary value * @@ -135,7 +135,7 @@ tb_iterator_ref_t tb_object_dictionary_itor(tb_object_ref_t dictionary); * * @return the dictionary value */ -tb_object_ref_t tb_object_dictionary_value(tb_object_ref_t dictionary, tb_char_t const* key); +tb_object_ref_t tb_oc_dictionary_value(tb_object_ref_t dictionary, tb_char_t const* key); /*! insert dictionary item * @@ -143,14 +143,14 @@ tb_object_ref_t tb_object_dictionary_value(tb_object_ref_t dictionary, t * @param key the key * @param val the value */ -tb_void_t tb_object_dictionary_insert(tb_object_ref_t dictionary, tb_char_t const* key, tb_object_ref_t val); +tb_void_t tb_oc_dictionary_insert(tb_object_ref_t dictionary, tb_char_t const* key, tb_object_ref_t val); /*! remove dictionary item * * @param dictionary the dictionary object * @param key the key */ -tb_void_t tb_object_dictionary_remove(tb_object_ref_t dictionary, tb_char_t const* key); +tb_void_t tb_oc_dictionary_remove(tb_object_ref_t dictionary, tb_char_t const* key); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/object/null.h b/core/pkg/tbox.pkg/inc/tbox/object/null.h index f1e20b427..44f187ca5 100755 --- a/core/pkg/tbox.pkg/inc/tbox/object/null.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/null.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file null.h @@ -42,7 +42,7 @@ __tb_extern_c_enter__ * * @return the null object */ -tb_object_ref_t tb_object_null_init(tb_noarg_t); +tb_object_ref_t tb_oc_null_init(tb_noarg_t); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/object/number.h b/core/pkg/tbox.pkg/inc/tbox/object/number.h index 830afc660..6914bc27c 100755 --- a/core/pkg/tbox.pkg/inc/tbox/object/number.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/number.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file number.h @@ -39,21 +39,21 @@ __tb_extern_c_enter__ */ /// the number type enum -typedef enum __tb_object_number_type_e +typedef enum __tb_oc_number_type_e { - TB_NUMBER_TYPE_NONE = 0 -, TB_NUMBER_TYPE_UINT8 = 1 -, TB_NUMBER_TYPE_SINT8 = 2 -, TB_NUMBER_TYPE_UINT16 = 3 -, TB_NUMBER_TYPE_SINT16 = 4 -, TB_NUMBER_TYPE_UINT32 = 5 -, TB_NUMBER_TYPE_SINT32 = 6 -, TB_NUMBER_TYPE_UINT64 = 7 -, TB_NUMBER_TYPE_SINT64 = 8 -, TB_NUMBER_TYPE_FLOAT = 9 -, TB_NUMBER_TYPE_DOUBLE = 10 + TB_OC_NUMBER_TYPE_NONE = 0 +, TB_OC_NUMBER_TYPE_UINT8 = 1 +, TB_OC_NUMBER_TYPE_SINT8 = 2 +, TB_OC_NUMBER_TYPE_UINT16 = 3 +, TB_OC_NUMBER_TYPE_SINT16 = 4 +, TB_OC_NUMBER_TYPE_UINT32 = 5 +, TB_OC_NUMBER_TYPE_SINT32 = 6 +, TB_OC_NUMBER_TYPE_UINT64 = 7 +, TB_OC_NUMBER_TYPE_SINT64 = 8 +, TB_OC_NUMBER_TYPE_FLOAT = 9 +, TB_OC_NUMBER_TYPE_DOUBLE = 10 -}tb_object_number_type_e; +}tb_oc_number_type_e; /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces @@ -65,7 +65,7 @@ typedef enum __tb_object_number_type_e * * @return the number object */ -tb_object_ref_t tb_object_number_init_from_uint8(tb_uint8_t value); +tb_object_ref_t tb_oc_number_init_from_uint8(tb_uint8_t value); /*! init number from sint8 * @@ -73,7 +73,7 @@ tb_object_ref_t tb_object_number_init_from_uint8(tb_uint8_t value); * * @return the number object */ -tb_object_ref_t tb_object_number_init_from_sint8(tb_sint8_t value); +tb_object_ref_t tb_oc_number_init_from_sint8(tb_sint8_t value); /*! init number from uint16 * @@ -81,7 +81,7 @@ tb_object_ref_t tb_object_number_init_from_sint8(tb_sint8_t value); * * @return the number object */ -tb_object_ref_t tb_object_number_init_from_uint16(tb_uint16_t value); +tb_object_ref_t tb_oc_number_init_from_uint16(tb_uint16_t value); /*! init number from sint16 * @@ -89,7 +89,7 @@ tb_object_ref_t tb_object_number_init_from_uint16(tb_uint16_t value); * * @return the number object */ -tb_object_ref_t tb_object_number_init_from_sint16(tb_sint16_t value); +tb_object_ref_t tb_oc_number_init_from_sint16(tb_sint16_t value); /*! init number from uint32 * @@ -97,7 +97,7 @@ tb_object_ref_t tb_object_number_init_from_sint16(tb_sint16_t value); * * @return the number object */ -tb_object_ref_t tb_object_number_init_from_uint32(tb_uint32_t value); +tb_object_ref_t tb_oc_number_init_from_uint32(tb_uint32_t value); /*! init number from sint32 * @@ -105,7 +105,7 @@ tb_object_ref_t tb_object_number_init_from_uint32(tb_uint32_t value); * * @return the number object */ -tb_object_ref_t tb_object_number_init_from_sint32(tb_sint32_t value); +tb_object_ref_t tb_oc_number_init_from_sint32(tb_sint32_t value); /*! init number from uint64 * @@ -113,7 +113,7 @@ tb_object_ref_t tb_object_number_init_from_sint32(tb_sint32_t value); * * @return the number object */ -tb_object_ref_t tb_object_number_init_from_uint64(tb_uint64_t value); +tb_object_ref_t tb_oc_number_init_from_uint64(tb_uint64_t value); /*! init number from sint64 * @@ -121,7 +121,7 @@ tb_object_ref_t tb_object_number_init_from_uint64(tb_uint64_t value); * * @return the number object */ -tb_object_ref_t tb_object_number_init_from_sint64(tb_sint64_t value); +tb_object_ref_t tb_oc_number_init_from_sint64(tb_sint64_t value); #ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! init number from float @@ -130,7 +130,7 @@ tb_object_ref_t tb_object_number_init_from_sint64(tb_sint64_t value); * * @return the number object */ -tb_object_ref_t tb_object_number_init_from_float(tb_float_t value); +tb_object_ref_t tb_oc_number_init_from_float(tb_float_t value); /*! init number from double * @@ -138,7 +138,7 @@ tb_object_ref_t tb_object_number_init_from_float(tb_float_t value); * * @return the number object */ -tb_object_ref_t tb_object_number_init_from_double(tb_double_t value); +tb_object_ref_t tb_oc_number_init_from_double(tb_double_t value); #endif /*! the number type @@ -147,7 +147,7 @@ tb_object_ref_t tb_object_number_init_from_double(tb_double_t value); * * @return the number type */ -tb_size_t tb_object_number_type(tb_object_ref_t number); +tb_size_t tb_oc_number_type(tb_object_ref_t number); /*! the uint8 value of the number * @@ -155,7 +155,7 @@ tb_size_t tb_object_number_type(tb_object_ref_t number); * * @return the number value */ -tb_uint8_t tb_object_number_uint8(tb_object_ref_t number); +tb_uint8_t tb_oc_number_uint8(tb_object_ref_t number); /*! the sint8 value of the number * @@ -163,7 +163,7 @@ tb_uint8_t tb_object_number_uint8(tb_object_ref_t number); * * @return the number value */ -tb_sint8_t tb_object_number_sint8(tb_object_ref_t number); +tb_sint8_t tb_oc_number_sint8(tb_object_ref_t number); /*! the uint16 value of the number * @@ -171,7 +171,7 @@ tb_sint8_t tb_object_number_sint8(tb_object_ref_t number); * * @return the number value */ -tb_uint16_t tb_object_number_uint16(tb_object_ref_t number); +tb_uint16_t tb_oc_number_uint16(tb_object_ref_t number); /*! the sint16 value of the number * @@ -179,7 +179,7 @@ tb_uint16_t tb_object_number_uint16(tb_object_ref_t number); * * @return the number value */ -tb_sint16_t tb_object_number_sint16(tb_object_ref_t number); +tb_sint16_t tb_oc_number_sint16(tb_object_ref_t number); /*! the uint32 value of the number * @@ -187,7 +187,7 @@ tb_sint16_t tb_object_number_sint16(tb_object_ref_t number); * * @return the number value */ -tb_uint32_t tb_object_number_uint32(tb_object_ref_t number); +tb_uint32_t tb_oc_number_uint32(tb_object_ref_t number); /*! the sint32 value of the number * @@ -195,7 +195,7 @@ tb_uint32_t tb_object_number_uint32(tb_object_ref_t number); * * @return the number value */ -tb_sint32_t tb_object_number_sint32(tb_object_ref_t number); +tb_sint32_t tb_oc_number_sint32(tb_object_ref_t number); /*! the uint64 value of the number * @@ -203,7 +203,7 @@ tb_sint32_t tb_object_number_sint32(tb_object_ref_t number); * * @return the number value */ -tb_uint64_t tb_object_number_uint64(tb_object_ref_t number); +tb_uint64_t tb_oc_number_uint64(tb_object_ref_t number); /*! the sint64 value of the number * @@ -211,7 +211,7 @@ tb_uint64_t tb_object_number_uint64(tb_object_ref_t number); * * @return the number value */ -tb_sint64_t tb_object_number_sint64(tb_object_ref_t number); +tb_sint64_t tb_oc_number_sint64(tb_object_ref_t number); #ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! the float value of the number @@ -220,7 +220,7 @@ tb_sint64_t tb_object_number_sint64(tb_object_ref_t number); * * @return the number value */ -tb_float_t tb_object_number_float(tb_object_ref_t number); +tb_float_t tb_oc_number_float(tb_object_ref_t number); /*! the double value of the number * @@ -228,7 +228,7 @@ tb_float_t tb_object_number_float(tb_object_ref_t number); * * @return the number value */ -tb_double_t tb_object_number_double(tb_object_ref_t number); +tb_double_t tb_oc_number_double(tb_object_ref_t number); #endif /*! set the uint8 value @@ -238,7 +238,7 @@ tb_double_t tb_object_number_double(tb_object_ref_t number); * * @return tb_true or tb_false */ -tb_bool_t tb_object_number_uint8_set(tb_object_ref_t number, tb_uint8_t value); +tb_bool_t tb_oc_number_uint8_set(tb_object_ref_t number, tb_uint8_t value); /*! set the sint8 value * @@ -247,7 +247,7 @@ tb_bool_t tb_object_number_uint8_set(tb_object_ref_t number, tb_uint8_ * * @return tb_true or tb_false */ -tb_bool_t tb_object_number_sint8_set(tb_object_ref_t number, tb_sint8_t value); +tb_bool_t tb_oc_number_sint8_set(tb_object_ref_t number, tb_sint8_t value); /*! set the uint16 value * @@ -256,7 +256,7 @@ tb_bool_t tb_object_number_sint8_set(tb_object_ref_t number, tb_sint8_ * * @return tb_true or tb_false */ -tb_bool_t tb_object_number_uint16_set(tb_object_ref_t number, tb_uint16_t value); +tb_bool_t tb_oc_number_uint16_set(tb_object_ref_t number, tb_uint16_t value); /*! set the sint16 value * @@ -265,7 +265,7 @@ tb_bool_t tb_object_number_uint16_set(tb_object_ref_t number, tb_uint1 * * @return tb_true or tb_false */ -tb_bool_t tb_object_number_sint16_set(tb_object_ref_t number, tb_sint16_t value); +tb_bool_t tb_oc_number_sint16_set(tb_object_ref_t number, tb_sint16_t value); /*! set the uint32 value * @@ -274,7 +274,7 @@ tb_bool_t tb_object_number_sint16_set(tb_object_ref_t number, tb_sint1 * * @return tb_true or tb_false */ -tb_bool_t tb_object_number_uint32_set(tb_object_ref_t number, tb_uint32_t value); +tb_bool_t tb_oc_number_uint32_set(tb_object_ref_t number, tb_uint32_t value); /*! set the sint32 value * @@ -283,7 +283,7 @@ tb_bool_t tb_object_number_uint32_set(tb_object_ref_t number, tb_uint3 * * @return tb_true or tb_false */ -tb_bool_t tb_object_number_sint32_set(tb_object_ref_t number, tb_sint32_t value); +tb_bool_t tb_oc_number_sint32_set(tb_object_ref_t number, tb_sint32_t value); /*! set the uint64 value * @@ -292,7 +292,7 @@ tb_bool_t tb_object_number_sint32_set(tb_object_ref_t number, tb_sint3 * * @return tb_true or tb_false */ -tb_bool_t tb_object_number_uint64_set(tb_object_ref_t number, tb_uint64_t value); +tb_bool_t tb_oc_number_uint64_set(tb_object_ref_t number, tb_uint64_t value); /*! set the sint64 value * @@ -301,7 +301,7 @@ tb_bool_t tb_object_number_uint64_set(tb_object_ref_t number, tb_uint6 * * @return tb_true or tb_false */ -tb_bool_t tb_object_number_sint64_set(tb_object_ref_t number, tb_sint64_t value); +tb_bool_t tb_oc_number_sint64_set(tb_object_ref_t number, tb_sint64_t value); #ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! set the float value @@ -311,7 +311,7 @@ tb_bool_t tb_object_number_sint64_set(tb_object_ref_t number, tb_sint6 * * @return tb_true or tb_false */ -tb_bool_t tb_object_number_float_set(tb_object_ref_t number, tb_float_t value); +tb_bool_t tb_oc_number_float_set(tb_object_ref_t number, tb_float_t value); /*! set the double value * @@ -320,7 +320,7 @@ tb_bool_t tb_object_number_float_set(tb_object_ref_t number, tb_float_ * * @return tb_true or tb_false */ -tb_bool_t tb_object_number_double_set(tb_object_ref_t number, tb_double_t value); +tb_bool_t tb_oc_number_double_set(tb_object_ref_t number, tb_double_t value); #endif /* ////////////////////////////////////////////////////////////////////////////////////// diff --git a/core/pkg/tbox.pkg/inc/tbox/object/object.h b/core/pkg/tbox.pkg/inc/tbox/object/object.h index f3853df22..0a01edcf3 100755 --- a/core/pkg/tbox.pkg/inc/tbox/object/object.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/object.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file object.h @@ -36,6 +36,9 @@ #include "number.h" #include "boolean.h" #include "dictionary.h" +#ifdef TB_CONFIG_API_HAVE_DEPRECATED +# include "deprecated/deprecated.h" +#endif /* ////////////////////////////////////////////////////////////////////////////////////// * extern @@ -46,15 +49,6 @@ __tb_extern_c_enter__ * interfaces */ -/*! init object context - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_context_init(tb_noarg_t); - -/// exit object context -tb_void_t tb_object_context_exit(tb_noarg_t); - /*! init object * * @param object the object @@ -221,7 +215,7 @@ tb_object_ref_t tb_object_data(tb_object_ref_t object, tb_size_t format); * tb_object_ref_t object = tb_object_seek(root, ".array[5].string", tb_false); * if (object) * { - * tb_trace_d("%s", tb_object_string_cstr(object)); + * tb_trace_d("%s", tb_oc_string_cstr(object)); * } * <endcode> * diff --git a/core/pkg/tbox.pkg/inc/tbox/object/prefix.h b/core/pkg/tbox.pkg/inc/tbox/object/prefix.h index 0179b06ce..8c71d7411 100755 --- a/core/pkg/tbox.pkg/inc/tbox/object/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h @@ -29,8 +29,6 @@ */ #include "../prefix.h" #include "../xml/xml.h" -#include "../stream/stream.h" -#include "../container/container.h" /* ////////////////////////////////////////////////////////////////////////////////////// * types @@ -79,54 +77,26 @@ typedef enum __tb_object_format_e typedef struct __tb_object_t { /// the object flag - tb_uint8_t flag; + tb_uint8_t flag; /// the object type - tb_uint16_t type; + tb_uint16_t type; /// the object reference count - tb_size_t refn; + tb_size_t refn; /// the object private data - tb_cpointer_t priv; + tb_cpointer_t priv; /// the copy func - struct __tb_object_t* (*copy)(struct __tb_object_t* object); + struct __tb_object_t* (*copy)(struct __tb_object_t* object); /// the clear func - tb_void_t (*clear)(struct __tb_object_t* object); + tb_void_t (*clear)(struct __tb_object_t* object); /// the exit func - tb_void_t (*exit)(struct __tb_object_t* object); + tb_void_t (*exit)(struct __tb_object_t* object); -}tb_object_t; - -/// the object ref type -typedef tb_object_t* tb_object_ref_t; - -/// the object reader type -typedef struct __tb_object_reader_t -{ - /// the hooker - tb_hash_map_ref_t hooker; - - /// probe format - tb_size_t (*probe)(tb_stream_ref_t stream); - - /// read it - tb_object_ref_t (*read)(tb_stream_ref_t stream); - -}tb_object_reader_t; - -/// the object writer type -typedef struct __tb_object_writer_t -{ - /// the hooker - tb_hash_map_ref_t hooker; - - /// writ it - tb_long_t (*writ)(tb_stream_ref_t stream, tb_object_ref_t object, tb_bool_t deflate); - -}tb_object_writer_t; +}tb_object_t, *tb_object_ref_t; #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/object/string.h b/core/pkg/tbox.pkg/inc/tbox/object/string.h index a3721b777..402b974e0 100755 --- a/core/pkg/tbox.pkg/inc/tbox/object/string.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/string.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file string.h @@ -44,7 +44,7 @@ __tb_extern_c_enter__ * * @return the string object */ -tb_object_ref_t tb_object_string_init_from_cstr(tb_char_t const* cstr); +tb_object_ref_t tb_oc_string_init_from_cstr(tb_char_t const* cstr); /*! init string from string * @@ -52,7 +52,7 @@ tb_object_ref_t tb_object_string_init_from_cstr(tb_char_t const* cstr); * * @return the string object */ -tb_object_ref_t tb_object_string_init_from_str(tb_string_ref_t str); +tb_object_ref_t tb_oc_string_init_from_str(tb_string_ref_t str); /*! the c-string * @@ -60,7 +60,7 @@ tb_object_ref_t tb_object_string_init_from_str(tb_string_ref_t str); * * @return the c-string */ -tb_char_t const* tb_object_string_cstr(tb_object_ref_t string); +tb_char_t const* tb_oc_string_cstr(tb_object_ref_t string); /*! set the c-string * @@ -69,7 +69,7 @@ tb_char_t const* tb_object_string_cstr(tb_object_ref_t string); * * @return the string size */ -tb_size_t tb_object_string_cstr_set(tb_object_ref_t string, tb_char_t const* cstr); +tb_size_t tb_oc_string_cstr_set(tb_object_ref_t string, tb_char_t const* cstr); /*! the string size * @@ -77,7 +77,7 @@ tb_size_t tb_object_string_cstr_set(tb_object_ref_t string, tb_char_t * * @return the string size */ -tb_size_t tb_object_string_size(tb_object_ref_t string); +tb_size_t tb_oc_string_size(tb_object_ref_t string); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/addrinfo.h b/core/pkg/tbox.pkg/inc/tbox/platform/addrinfo.h new file mode 100755 index 000000000..a22ce3eec --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/addrinfo.h @@ -0,0 +1,92 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file addrinfo.h + * @ingroup platform + * + */ +#ifndef TB_PLATFORM_ADDRINFO_H +#define TB_PLATFORM_ADDRINFO_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "../network/ipaddr.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! get the first dns address from the host name + * + * @code + + // get the default address (ipv4) + tb_ipaddr_t addr = {0}; + if (tb_addrinfo_addr("www.tboox.org", &addr)) + tb_trace_i("%{ipaddr}", &addr); + + // get the ipv6 address by the hint info + tb_ipaddr_t addr = {0}; + tb_ipaddr_family_set(&addr, TB_IPADDR_FAMILY_IPV6); + if (tb_addrinfo_addr("www.tboox.org", &addr)) + tb_trace_i("%{ipaddr}", &addr); + + * @endcode + * + * @param name the host name (cannot be null) + * @param addr the ip address (we can fill some hint info first) + * + * @return tb_true or tb_false + */ +tb_bool_t tb_addrinfo_addr(tb_char_t const* name, tb_ipaddr_ref_t addr); + +/*! get the host name from the given address + * + * @code + + // get the host name by address + tb_ipaddr_t addr; + tb_char_t host[256]; + tb_ipaddr_ip_cstr_set(&addr, "127.0.0.1"); + tb_trace_i("%s", tb_addrinfo_name(&addr, host, sizeof(host))); + + * @endcode + * + * @param addr the ip address (cannot be null) + * @param name the host name buffer + * @param maxn the host name buffer maxn + * + * @return the host name or tb_null + */ +tb_char_t const* tb_addrinfo_name(tb_ipaddr_ref_t addr, tb_char_t* name, tb_size_t maxn); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/android/android.h b/core/pkg/tbox.pkg/inc/tbox/platform/android/android.h index 3868f34e5..3e8186916 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/android/android.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/android/android.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file android.h @@ -38,10 +38,10 @@ * * @return tb_true or tb_false */ -tb_bool_t tb_android_init(JavaVM* jvm); +tb_bool_t tb_android_init_env(JavaVM* jvm); /// exit the android platform -tb_void_t tb_android_exit(tb_noarg_t); +tb_void_t tb_android_exit_env(tb_noarg_t); /*! the java machine pointer * diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/android/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/android/prefix.h index 65be2ee39..c207f9240 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/android/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/android/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/frame.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/frame.h index 4e0b57417..787a3ab06 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/frame.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/frame.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file frame.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/prefix.h index 6e4b9b805..c337fe0f3 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm64/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm64/prefix.h new file mode 100755 index 000000000..d5a183622 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm64/prefix.h @@ -0,0 +1,32 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * + */ +#ifndef TB_PLATFORM_ARCH_ARM64_PREFIX_H +#define TB_PLATFORM_ARCH_ARM64_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/atomic.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/atomic.h index ea9bc45d8..fb885b5c2 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/atomic.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file atomic.h @@ -32,8 +32,6 @@ # include "x86/atomic.h" #elif defined(TB_ARCH_x64) # include "x64/atomic.h" -#elif defined(TB_ARCH_ARM) -# include "arm/atomic.h" #endif #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/barrier.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/barrier.h index 5c4542140..15b1d788c 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/barrier.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file barrier.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/frame.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/frame.h index 9d029823a..4ef845c5e 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/frame.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/frame.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file frame.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/mips/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/mips/prefix.h new file mode 100755 index 000000000..d6235df2d --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/mips/prefix.h @@ -0,0 +1,32 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * + */ +#ifndef TB_PLATFORM_ARCH_MIPS_PREFIX_H +#define TB_PLATFORM_ARCH_MIPS_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/prefix.h index ead1d4e22..0b1548656 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/atomic.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/atomic.h index 8ff26d126..3162fed2b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/atomic.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file atomic.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/barrier.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/barrier.h index 08fdb7c11..39d874acf 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/barrier.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file barrier.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/frame.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/frame.h index 512b06e00..cf1a76e0e 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/frame.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/frame.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file frame.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/prefix.h index c2d356bde..68f8ab37e 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/atomic.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/atomic.h index b708e5d03..1a3ff2bf7 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/atomic.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file atomic.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/barrier.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/barrier.h index e88531d88..f944aeb20 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/barrier.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file barrier.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/frame.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/frame.h index bdbbcd715..664b5a0dc 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/frame.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/frame.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file frame.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/prefix.h index ca366b4b1..ac071bb29 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/atomic.h b/core/pkg/tbox.pkg/inc/tbox/platform/atomic.h index 0075668f9..5b0dd858a 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/atomic.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file atomic.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/atomic64.h b/core/pkg/tbox.pkg/inc/tbox/platform/atomic64.h index c7e88121d..d01756ef9 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/atomic64.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/atomic64.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file atomic64.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/backtrace.h b/core/pkg/tbox.pkg/inc/tbox/platform/backtrace.h index 733a75dbd..36ae60a56 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/backtrace.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/backtrace.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file backtrace.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/barrier.h b/core/pkg/tbox.pkg/inc/tbox/platform/barrier.h index 5054febfe..9b0b287f7 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/barrier.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file barrier.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/cache_time.h b/core/pkg/tbox.pkg/inc/tbox/platform/cache_time.h index 1979c7817..6c7cdb893 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/cache_time.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/cache_time.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file cache_time.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/atomic.h b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/atomic.h index 66eba4d6d..11dc7c6f4 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/atomic.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file atomic.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/atomic64.h b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/atomic64.h index e4bc06098..2a5c16db2 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/atomic64.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/atomic64.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file atomic64.h @@ -69,7 +69,7 @@ static __tb_inline__ tb_hong_t tb_atomic64_fetch_and_add_sync(tb_atomic64_t* a, } static __tb_inline__ tb_hong_t tb_atomic64_fetch_and_sub_sync(tb_atomic64_t* a, tb_hong_t v) { - return __sync_fetch_and_sub(a, v); + return __sync_fetch_and_sub_8(a, v); } #if !(defined(TB_CONFIG_OS_IOS) && (TB_ARCH_ARM_VERSION < 7)) static __tb_inline__ tb_hong_t tb_atomic64_fetch_and_xor_sync(tb_atomic64_t* a, tb_hong_t v) diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/barrier.h b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/barrier.h index 06ac42942..e4107977b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/barrier.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file barrier.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/prefix.h index 2900ee549..d9bad9fe5 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/prefix.h index c41e8c01d..3a72ddec5 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/context.h b/core/pkg/tbox.pkg/inc/tbox/platform/context.h new file mode 100755 index 000000000..76f3a4efc --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/context.h @@ -0,0 +1,89 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file context.h + * @ingroup platform + * + */ +#ifndef TB_PLATFORM_CONTEXT_H +#define TB_PLATFORM_CONTEXT_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the context ref type +typedef __tb_typeref__(context); + +// the context-from type +typedef struct __tb_context_from_t +{ + // the from-context + tb_context_ref_t context; + + // the passed user private data + tb_cpointer_t priv; + +}tb_context_from_t; + +/*! the context entry function type + * + * @param from the from-context + */ +typedef tb_void_t (*tb_context_func_t)(tb_context_from_t from); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! make context from the given the stack space and the callback function + * + * @param stackdata the stack data + * @param stacksize the stack size + * @param func the entry function + * + * @return the context pointer + */ +tb_context_ref_t tb_context_make(tb_byte_t* stackdata, tb_size_t stacksize, tb_context_func_t func); + +/*! jump to the given context + * + * @param context the to-context + * @param priv the passed user private data + * + * @return the from-context + */ +tb_context_from_t tb_context_jump(tb_context_ref_t context, tb_cpointer_t priv); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/deprecated/deprecated.h b/core/pkg/tbox.pkg/inc/tbox/platform/deprecated/deprecated.h new file mode 100755 index 000000000..f798248d1 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/deprecated/deprecated.h @@ -0,0 +1,31 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file deprecated.h + * + */ +#ifndef TB_PLATFORM_DEPRECATED_H +#define TB_PLATFORM_DEPRECATED_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/deprecated/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/deprecated/prefix.h new file mode 100755 index 000000000..17264328e --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/deprecated/prefix.h @@ -0,0 +1,32 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * + */ +#ifndef TB_PLATFORM_DEPRECATED_PREFIX_H +#define TB_PLATFORM_DEPRECATED_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/directory.h b/core/pkg/tbox.pkg/inc/tbox/platform/directory.h index 23df0b329..21af67e6d 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/directory.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/directory.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file directory.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/dynamic.h b/core/pkg/tbox.pkg/inc/tbox/platform/dynamic.h index 420772d19..446c49af8 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/dynamic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/dynamic.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file mutex.h @@ -39,7 +39,7 @@ __tb_extern_c_enter__ */ /// the dynamic ref type -typedef struct{}* tb_dynamic_ref_t; +typedef __tb_typeref__(dynamic); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/environment.h b/core/pkg/tbox.pkg/inc/tbox/platform/environment.h index 7140ee3ac..58459263b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/environment.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/environment.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file environment.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/event.h b/core/pkg/tbox.pkg/inc/tbox/platform/event.h index 48b05e008..cdf351f80 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/event.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/event.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file event.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/exception.h b/core/pkg/tbox.pkg/inc/tbox/platform/exception.h index 080fb7e21..a1ee4d0fb 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/exception.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/exception.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file exception.h @@ -31,12 +31,17 @@ # include "../libc/misc/signal.h" # if defined(TB_CONFIG_OS_WINDOWS) # include "windows/exception.h" -# elif defined(tb_signal) +# elif defined(tb_signal) # include "libc/exception.h" # endif #endif /* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// * macros */ @@ -72,6 +77,11 @@ # define tb_assert_and_check_leave(x) tb_check_leave(x) #endif +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/file.h b/core/pkg/tbox.pkg/inc/tbox/platform/file.h index 0590e47a2..6da831b36 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/file.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/file.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file file.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/hostname.h b/core/pkg/tbox.pkg/inc/tbox/platform/hostname.h index f6eb57090..584e4dc30 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/hostname.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/hostname.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file hostname.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/ifaddrs.h b/core/pkg/tbox.pkg/inc/tbox/platform/ifaddrs.h index ceb76ee61..aa72eea52 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/ifaddrs.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/ifaddrs.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file ifaddrs.h @@ -74,7 +74,7 @@ typedef struct __tb_ifaddrs_interface_t }tb_ifaddrs_interface_t, *tb_ifaddrs_interface_ref_t; /// the ifaddrs type -typedef struct{}* tb_ifaddrs_ref_t; +typedef __tb_typeref__(ifaddrs); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/libc/exception.h b/core/pkg/tbox.pkg/inc/tbox/platform/libc/exception.h index a93eb82c6..ecf03accd 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/libc/exception.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/libc/exception.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file exception.h @@ -28,8 +28,7 @@ * includes */ #include "prefix.h" -#include "../thread_store.h" -#include "../../libc/misc/signal.h" +#include "../thread_local.h" #include "../../libc/misc/setjmp.h" #include "../../container/container.h" #ifdef TB_CONFIG_LIBC_HAVE_KILL @@ -37,58 +36,38 @@ #endif /* ////////////////////////////////////////////////////////////////////////////////////// - * types + * globals */ - -#if defined(tb_signal) && defined(tb_sigsetjmp) && defined(tb_siglongjmp) - -// the exception data type -typedef struct __tb_exception_list_t -{ - // the thread store base - tb_thread_store_data_t base; - - // the stack - tb_stack_ref_t stack; - -}tb_exception_list_t; - -#endif +extern tb_thread_local_t g_exception_local; /* ////////////////////////////////////////////////////////////////////////////////////// * macros */ -#if defined(tb_signal) && defined(tb_sigsetjmp) && defined(tb_siglongjmp) +#if defined(tb_sigsetjmp) && defined(tb_siglongjmp) // try # define __tb_try \ do \ { \ - /* init exception first */ \ - tb_exception_init_impl(); \ - \ - /* init exception data */ \ - tb_exception_list_t* __l = tb_null; \ - if (!(__l = (tb_exception_list_t*)tb_thread_store_getp())) \ + /* init exception stack */ \ + tb_stack_ref_t __stack = tb_null; \ + if (!(__stack = (tb_stack_ref_t)tb_thread_local_get(&g_exception_local))) \ { \ - __l = tb_malloc0(sizeof(tb_exception_list_t)); \ - if (__l) \ - { \ - __l->base.type = TB_THREAD_STORE_DATA_TYPE_EXCEPTION; \ - __l->base.free = tb_exception_list_free; \ - __l->stack = tb_stack_init(16, tb_element_mem(sizeof(tb_sigjmpbuf_t), tb_null, tb_null)); \ - tb_thread_store_setp((tb_thread_store_data_t const*)__l); \ - } \ + tb_stack_ref_t __stack_new = tb_stack_init(16, tb_element_mem(sizeof(tb_sigjmpbuf_t), tb_null, tb_null)); \ + if (__stack_new && tb_thread_local_set(&g_exception_local, __stack_new)) \ + __stack = __stack_new; \ + else if (__stack_new) \ + tb_stack_exit(__stack_new); \ } \ \ /* push jmpbuf */ \ tb_sigjmpbuf_t* __top = tb_null; \ - if (__l && __l->stack) \ + if (__stack) \ { \ tb_sigjmpbuf_t __buf; \ - tb_stack_put(__l->stack, &__buf); \ - __top = (tb_sigjmpbuf_t*)tb_stack_top(__l->stack); \ + tb_stack_put(__stack, &__buf); \ + __top = (tb_sigjmpbuf_t*)tb_stack_top(__stack); \ } \ \ /* init jmpbuf and save sigmask */ \ @@ -104,14 +83,14 @@ typedef struct __tb_exception_list_t /* check */ \ tb_assert(x >= 0); \ /* pop the jmpbuf */ \ - if (__l && __l->stack) tb_stack_pop(__l->stack); \ + if (__stack) tb_stack_pop(__stack); \ /* do not this catch? */ \ if (__j && !(x)) \ { \ /* goto the top exception stack */ \ - if (__l && __l->stack && tb_stack_size(__l->stack)) \ + if (__stack && tb_stack_size(__stack)) \ { \ - tb_sigjmpbuf_t* jmpbuf = (tb_sigjmpbuf_t*)tb_stack_top(__l->stack); \ + tb_sigjmpbuf_t* jmpbuf = (tb_sigjmpbuf_t*)tb_stack_top(__stack); \ if (jmpbuf) tb_siglongjmp(*jmpbuf, 1); \ } \ else \ @@ -123,77 +102,73 @@ typedef struct __tb_exception_list_t /* exception been catched? */ \ if (__j) - // end -# define __tb_end \ - } while (0); +#else - // leave -# define __tb_leave break + // try +# define __tb_try \ + do \ + { \ + /* init exception stack */ \ + tb_stack_ref_t __stack = tb_null; \ + if (!(__stack = (tb_stack_ref_t)tb_thread_local_get(&g_exception_local))) \ + { \ + tb_stack_ref_t __stack_new = tb_stack_init(16, tb_element_mem(sizeof(tb_jmpbuf_t), tb_null, tb_null)); \ + if (__stack_new && tb_thread_local_set(&g_exception_local, __stack_new)) \ + __stack = __stack_new; \ + else if (__stack_new) \ + tb_stack_exit(__stack_new); \ + } \ + \ + /* push jmpbuf */ \ + tb_jmpbuf_t* __top = tb_null; \ + if (__stack) \ + { \ + tb_jmpbuf_t __buf; \ + tb_stack_put(__stack, &__buf); \ + __top = (tb_jmpbuf_t*)tb_stack_top(__stack); \ + } \ + \ + /* init jmpbuf */ \ + __tb_volatile__ tb_int_t __j = __top? tb_setjmp(*__top) : 0; \ + /* done try */ \ + if (!__j) \ + { - // init -# define tb_exception_init tb_exception_init_impl + // except +# define __tb_except(x) \ + } \ + \ + /* check */ \ + tb_assert(x >= 0); \ + /* pop the jmpbuf */ \ + if (__stack) tb_stack_pop(__stack); \ + /* do not this catch? */ \ + if (__j && !(x)) \ + { \ + /* goto the top exception stack */ \ + if (__stack && tb_stack_size(__stack)) \ + { \ + tb_jmpbuf_t* jmpbuf = (tb_jmpbuf_t*)tb_stack_top(__stack); \ + if (jmpbuf) tb_longjmp(*jmpbuf, 1); \ + } \ + else \ + { \ + /* no exception handler */ \ + tb_assert_and_check_break(0); \ + } \ + } \ + /* exception been catched? */ \ + if (__j) #endif -/* ////////////////////////////////////////////////////////////////////////////////////// - * handler - */ - -#if defined(tb_signal) && defined(tb_sigsetjmp) && defined(tb_siglongjmp) -static __tb_inline__ tb_void_t tb_exception_func_impl(tb_int_t sig) -{ - tb_exception_list_t* list = (tb_exception_list_t*)tb_thread_store_getp(); - if (list && list->stack && tb_stack_size(list->stack)) - { - tb_sigjmpbuf_t* jmpbuf = (tb_sigjmpbuf_t*)tb_stack_top(list->stack); - if (jmpbuf) tb_siglongjmp(*jmpbuf, 1); - } - else - { - // trace - tb_trace_e("exception: no handler for signal: %d", sig); - - // ignore signal - tb_signal(TB_SIGILL, TB_SIG_DFL); - tb_signal(TB_SIGFPE, TB_SIG_DFL); - tb_signal(TB_SIGBUS, TB_SIG_DFL); - tb_signal(TB_SIGSEGV, TB_SIG_DFL); - tb_signal(TB_SIGABRT, TB_SIG_DFL); + // end +#define __tb_end \ + } while (0); -#ifdef TB_CONFIG_LIBC_HAVE_KILL - // kill it - kill(getpid(), sig); -#endif - } -} -static __tb_inline__ tb_void_t tb_exception_init_impl() -{ - static tb_atomic_t s_init = 0; - if (!tb_atomic_fetch_and_set(&s_init, 1)) - { -// tb_signal(TB_SIGINT, tb_exception_func_impl); - tb_signal(TB_SIGILL, tb_exception_func_impl); - tb_signal(TB_SIGFPE, tb_exception_func_impl); - tb_signal(TB_SIGBUS, tb_exception_func_impl); - tb_signal(TB_SIGSEGV, tb_exception_func_impl); - tb_signal(TB_SIGABRT, tb_exception_func_impl); -// tb_signal(TB_SIGTRAP, tb_exception_func_impl); - } -} -static __tb_inline__ tb_void_t tb_exception_list_free(tb_thread_store_data_t* data) -{ - tb_exception_list_t* list = (tb_exception_list_t*)data; - if (list) - { - // exit stack - if (list->stack) tb_stack_exit(list->stack); - list->stack = tb_null; + // leave +#define __tb_leave break - // exit exception - tb_free(list); - } -} -#endif #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/libc/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/libc/prefix.h index 0b9dab421..458d846ce 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/libc/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/libc/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/linux/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/linux/prefix.h index e131be8ad..a2bb4cf33 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/linux/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/linux/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/ltimer.h b/core/pkg/tbox.pkg/inc/tbox/platform/ltimer.h index 93b5e8c3d..cf65b737e 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/ltimer.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/ltimer.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file ltimer.h @@ -53,10 +53,10 @@ typedef enum __tb_ltimer_tick_e typedef tb_timer_task_func_t tb_ltimer_task_func_t; /// the ltimer ref type -typedef struct{}* tb_ltimer_ref_t; +typedef __tb_typeref__(ltimer); /// the ltimer task ref type -typedef struct{}* tb_ltimer_task_ref_t; +typedef __tb_typeref__(ltimer_task); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces @@ -66,13 +66,13 @@ typedef struct{}* tb_ltimer_task_ref_t; * * lower tick and limit range, but faster * - * @param maxn the timer maxn + * @param grow the timer grow * @param tick the timer tick * @param ctime using ctime? * * @return the timer */ -tb_ltimer_ref_t tb_ltimer_init(tb_size_t maxn, tb_size_t tick, tb_bool_t ctime); +tb_ltimer_ref_t tb_ltimer_init(tb_size_t grow, tb_size_t tick, tb_bool_t ctime); /*! exit timer * diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/mach/barrier.h b/core/pkg/tbox.pkg/inc/tbox/platform/mach/barrier.h index 3a54f5ef5..a358b50d2 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/mach/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/mach/barrier.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file barrier.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/mach/ios/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/mach/ios/prefix.h index d8bdbc6d3..d1a696ace 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/mach/ios/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/mach/ios/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/mach/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/mach/prefix.h index e306ad0da..a052b6816 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/mach/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/mach/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/memory.h b/core/pkg/tbox.pkg/inc/tbox/platform/memory.h index 0cb294d35..48b1c4af9 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/memory.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/memory.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file memory.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/mutex.h b/core/pkg/tbox.pkg/inc/tbox/platform/mutex.h index 2600463f7..f90942ded 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/mutex.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/mutex.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file mutex.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/page.h b/core/pkg/tbox.pkg/inc/tbox/platform/page.h index c3c9ca9c0..b678dacd6 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/page.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/page.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file page.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/path.h b/core/pkg/tbox.pkg/inc/tbox/platform/path.h index c08eb4f6c..919f5e577 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/path.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/path.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @path path.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/platform.h b/core/pkg/tbox.pkg/inc/tbox/platform/platform.h index 7233c2272..b594ee084 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/platform.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/platform.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file platform.h @@ -28,7 +28,6 @@ * includes */ #include "prefix.h" -#include "dns.h" #include "page.h" #include "path.h" #include "file.h" @@ -42,10 +41,13 @@ #include "thread.h" #include "atomic.h" #include "memory.h" +#include "poller.h" +#include "context.h" #include "ifaddrs.h" #include "barrier.h" #include "dynamic.h" #include "process.h" +#include "addrinfo.h" #include "spinlock.h" #include "atomic64.h" #include "hostname.h" @@ -57,33 +59,9 @@ #include "cache_time.h" #include "environment.h" #include "thread_pool.h" -#include "thread_store.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! init the platform - * - * @param priv the platform private data - * pass JavaVM* jvm for android - * pass tb_null for other platform - * - * @return tb_true or tb_false - */ -tb_bool_t tb_platform_init(tb_handle_t priv); - -/// exit the platform -tb_void_t tb_platform_exit(tb_noarg_t); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ +#include "thread_local.h" +#ifdef TB_CONFIG_API_HAVE_DEPRECATED +# include "deprecated/deprecated.h" +#endif #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/poller.h b/core/pkg/tbox.pkg/inc/tbox/platform/poller.h new file mode 100755 index 000000000..76e1bd083 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/poller.h @@ -0,0 +1,168 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file poller.h + * @ingroup platform + * + */ +#ifndef TB_PLATFORM_POLLER_H +#define TB_PLATFORM_POLLER_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "socket.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the poller event enum, only for sock +typedef enum __tb_poller_event_e +{ + TB_POLLER_EVENT_NONE = TB_SOCKET_EVENT_NONE +, TB_POLLER_EVENT_CONN = TB_SOCKET_EVENT_CONN +, TB_POLLER_EVENT_ACPT = TB_SOCKET_EVENT_ACPT +, TB_POLLER_EVENT_RECV = TB_SOCKET_EVENT_RECV +, TB_POLLER_EVENT_SEND = TB_SOCKET_EVENT_SEND + +, TB_POLLER_EVENT_CLEAR = 0x0010 //!< edge trigger. after the event is retrieved by the user, its state is reset +, TB_POLLER_EVENT_ONESHOT = 0x0020 //!< causes the event to return only the first occurrence of the filter being triggered + +, TB_POLLER_EVENT_EALL = TB_SOCKET_EVENT_EALL + +}tb_poller_event_e; + +/// the poller ref type +typedef __tb_typeref__(poller); + +/*! the poller event func type + * + * @param poller the poller + * @param sock the socket + * @param events the poller events + * @param priv the user private data for this socket + */ +typedef tb_void_t (*tb_poller_event_func_t)(tb_poller_ref_t poller, tb_socket_ref_t sock, tb_size_t events, tb_cpointer_t priv); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init poller + * + * @param priv the user private data + * + * @param poller the poller + */ +tb_poller_ref_t tb_poller_init(tb_cpointer_t priv); + +/*! exit poller + * + * @param poller the poller + */ +tb_void_t tb_poller_exit(tb_poller_ref_t poller); + +/*! clear all sockets + * + * @param poller the poller + */ +tb_void_t tb_poller_clear(tb_poller_ref_t poller); + +/*! get the user private data + * + * @param poller the poller + * + * @return the user private data + */ +tb_cpointer_t tb_poller_priv(tb_poller_ref_t poller); + +/*! kill all waited events, tb_poller_wait() will return -1 + * + * @param poller the poller + */ +tb_void_t tb_poller_kill(tb_poller_ref_t poller); + +/*! spak the poller, break the tb_poller_wait() and return all events + * + * @param poller the poller + */ +tb_void_t tb_poller_spak(tb_poller_ref_t poller); + +/*! the events(clear, oneshot, ..) is supported for the poller? + * + * @param poller the poller + * @param events the poller events + * + * @return tb_true or tb_false + */ +tb_bool_t tb_poller_support(tb_poller_ref_t poller, tb_size_t events); + +/*! insert socket to poller + * + * @param poller the poller + * @param sock the socket + * @param events the poller events + * @param priv the private data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_poller_insert(tb_poller_ref_t poller, tb_socket_ref_t sock, tb_size_t events, tb_cpointer_t priv); + +/*! remove socket from poller + * + * @param poller the poller + * @param aioo the aioo + * + * @return tb_true or tb_false + */ +tb_bool_t tb_poller_remove(tb_poller_ref_t poller, tb_socket_ref_t sock); + +/*! modify events for the given socket + * + * @param poller the poller + * @param sock the socket + * @param events the poller events + * @param priv the private data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_poller_modify(tb_poller_ref_t poller, tb_socket_ref_t sock, tb_size_t events, tb_cpointer_t priv); + +/*! wait all sockets + * + * @param poller the poller + * @param func the events function + * @param timeout the timeout, infinity: -1 + * + * @return > 0: the events number, 0: timeout, -1: failed + */ +tb_long_t tb_poller_wait(tb_poller_ref_t poller, tb_poller_event_func_t func, tb_long_t timeout); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/posix/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/posix/prefix.h index cf88c8e85..acd9a7bd5 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/posix/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/posix/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/posix/sockaddr.h b/core/pkg/tbox.pkg/inc/tbox/platform/posix/sockaddr.h index 3d3529c01..fdaf47cdf 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/posix/sockaddr.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/posix/sockaddr.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file sockaddr.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/prefix.h index c5791eab9..b3877bfb5 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/print.h b/core/pkg/tbox.pkg/inc/tbox/platform/print.h index a7b00e490..abfd08248 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/print.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/print.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file print.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/process.h b/core/pkg/tbox.pkg/inc/tbox/platform/process.h index 438245774..edcfa74e2 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/process.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/process.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file process.h @@ -100,7 +100,7 @@ typedef struct __tb_process_attr_t }tb_process_attr_t, *tb_process_attr_ref_t; /// the process ref type -typedef struct{}* tb_process_ref_t; +typedef __tb_typeref__(process); /// the process wait info type typedef struct __tb_process_waitinfo_t diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/processor.h b/core/pkg/tbox.pkg/inc/tbox/platform/processor.h index 16ca7360c..6ad4cf7e6 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/processor.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/processor.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file processor.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/sched.h b/core/pkg/tbox.pkg/inc/tbox/platform/sched.h index 09ca92f27..6c85f4b92 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/sched.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/sched.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file sched.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/semaphore.h b/core/pkg/tbox.pkg/inc/tbox/platform/semaphore.h index 1eb800ce8..24bbc5879 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/semaphore.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/semaphore.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file semaphore.h @@ -40,21 +40,21 @@ __tb_extern_c_enter__ /*! init semaphore * - * @param init the init semaphore value + * @param value the initial semaphore value * - * @return the semaphore handle + * @return the semaphore */ -tb_semaphore_ref_t tb_semaphore_init(tb_size_t init); +tb_semaphore_ref_t tb_semaphore_init(tb_size_t value); /*! exit semaphore * - * @param handle the semaphore handle + * @return the semaphore */ tb_void_t tb_semaphore_exit(tb_semaphore_ref_t semaphore); /*! post semaphore * - * @param handle the semaphore handle + * @param semaphore the semaphore * @param post the post semaphore value * * @return tb_true or tb_false @@ -63,7 +63,7 @@ tb_bool_t tb_semaphore_post(tb_semaphore_ref_t semaphore, tb_size_t po /*! the semaphore value * - * @param handle the semaphore handle + * @param semaphore the semaphore * * @return >= 0: the semaphore value, -1: failed */ @@ -71,7 +71,7 @@ tb_long_t tb_semaphore_value(tb_semaphore_ref_t semaphore); /*! wait semaphore * - * @param handle the semaphore handle + * @param semaphore the semaphore * @param timeout the timeout * * @return ok: 1, timeout: 0, fail: -1 diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/socket.h b/core/pkg/tbox.pkg/inc/tbox/platform/socket.h index 2022aa4a1..bd03b0a5f 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/socket.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/socket.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file socket.h @@ -71,6 +71,18 @@ typedef enum __tb_socket_ctrl_e }tb_socket_ctrl_e; +/// the socket event enum, only for sock +typedef enum __tb_socket_event_e +{ + TB_SOCKET_EVENT_NONE = 0x0000 +, TB_SOCKET_EVENT_RECV = 0x0001 +, TB_SOCKET_EVENT_SEND = 0x0002 +, TB_SOCKET_EVENT_CONN = TB_SOCKET_EVENT_SEND +, TB_SOCKET_EVENT_ACPT = TB_SOCKET_EVENT_RECV +, TB_SOCKET_EVENT_EALL = TB_SOCKET_EVENT_RECV | TB_SOCKET_EVENT_SEND + +}tb_socket_event_e; + /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces */ @@ -260,6 +272,16 @@ tb_long_t tb_socket_urecvv(tb_socket_ref_t sock, tb_ipaddr_ref_t addr, */ tb_long_t tb_socket_usendv(tb_socket_ref_t sock, tb_ipaddr_ref_t addr, tb_iovec_t const* list, tb_size_t size); +/*! wait socket events + * + * @param sock the sock + * @param events the socket events + * @param timeout the timeout, infinity: -1 + * + * @return > 0: the events code, 0: timeout, -1: failed + */ +tb_long_t tb_socket_wait(tb_socket_ref_t sock, tb_size_t events, tb_long_t timeout); + /* ////////////////////////////////////////////////////////////////////////////////////// * extern */ diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/spinlock.h b/core/pkg/tbox.pkg/inc/tbox/platform/spinlock.h index cd4f91376..e5403e7c1 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/spinlock.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/spinlock.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file spinlock.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/systemv/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/systemv/prefix.h index 64c917a0f..ace84ed73 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/systemv/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/systemv/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/thread.h b/core/pkg/tbox.pkg/inc/tbox/platform/thread.h index e1de62e96..8c87198c8 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/thread.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/thread.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file thread.h @@ -35,11 +35,59 @@ __tb_extern_c_enter__ /* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/*! the thread func type + * + * @param priv the passed private data + * + * @return the return value + */ +typedef tb_int_t (*tb_thread_func_t)(tb_cpointer_t priv); + +/* ////////////////////////////////////////////////////////////////////////////////////// * interfaces */ /*! init thread * + * @code + static tb_int_t tb_demo_thread_func(tb_cpointer_t priv) + { + // self + tb_size_t self = tb_thread_self(); + + // trace + tb_trace_i("thread[%lx: %s]: init", priv, self); + + // exit thread and return failed value: -1 + // tb_thread_return(-1); + + // trace + tb_trace_i("thread[%lx: %s]: exit", priv, self); + + // ok + return 0; + } + + // init thread + tb_thread_ref_t thread = tb_thread_init(tb_null, tb_demo_thread_func, "hello", 0); + if (thread) + { + // wait thread + tb_int_t retval = 0; + if (tb_thread_wait(thread, -1, &retval) > 0) + { + // trace + tb_trace_i("wait: ok, retval: %d", retval); + } + + // exit thread + tb_thread_exit(thread); + } + * @endcode + * * @param name the thread name, maybe null * @param func the thread func * @param priv the thread func private data @@ -47,7 +95,7 @@ __tb_extern_c_enter__ * * @return the thread handle */ -tb_thread_ref_t tb_thread_init(tb_char_t const* name, tb_pointer_t (*func)(tb_cpointer_t), tb_cpointer_t priv, tb_size_t stack); +tb_thread_ref_t tb_thread_init(tb_char_t const* name, tb_thread_func_t func, tb_cpointer_t priv, tb_size_t stack); /*! exit thread * @@ -59,10 +107,11 @@ tb_void_t tb_thread_exit(tb_thread_ref_t thread); * * @param thread the thread * @param timeout the timeout + * @param retval the return value pointer of the thread (optional) * * @return ok: 1, timeout: 0, error: -1 */ -tb_long_t tb_thread_wait(tb_thread_ref_t thread, tb_long_t timeout); +tb_long_t tb_thread_wait(tb_thread_ref_t thread, tb_long_t timeout, tb_int_t* retval); /*! suspend thread * @@ -88,9 +137,41 @@ tb_size_t tb_thread_self(tb_noarg_t); /*! return the thread value * - * @param value the value pointer + * @param value the return value of the thread + */ +tb_void_t tb_thread_return(tb_int_t value); + +/*! run the given function only once + * + * @code + + // the once function + static tb_bool_t tb_thread_once_func(tb_cpointer_t priv) + { + // trace + tb_trace_i("%s", priv); + + // ok + return tb_true; + } + + // run the once function + static tb_atomic_t once = 0; + if (tb_thread_once(&once, tb_thread_once_func, "hello")) + { + // ok + // ... + } + + * @endcode + * + * @param lock the global or static atomic lock pointer (need be initialized as zero) + * @param func the function + * @param priv the user private data + * + * @return tb_true or tb_false */ -tb_void_t tb_thread_return(tb_pointer_t value); +tb_bool_t tb_thread_once(tb_atomic_t* lock, tb_bool_t (*func)(tb_cpointer_t), tb_cpointer_t priv); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/thread_local.h b/core/pkg/tbox.pkg/inc/tbox/platform/thread_local.h new file mode 100755 index 000000000..dc3d8b61d --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/thread_local.h @@ -0,0 +1,168 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file thread_local.h + * @ingroup platform + * + */ +#ifndef TB_PLATFORM_THREAD_LOCAL_H +#define TB_PLATFORM_THREAD_LOCAL_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "../container/single_list_entry.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ + +/// the thread local initial value +#define TB_THREAD_LOCAL_INIT {{0}, 0} + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/*! the thread local free function type + * + * @param priv the thread local private data + */ +typedef tb_void_t (*tb_thread_local_free_t)(tb_cpointer_t priv); + +/// the thread local type +typedef struct __tb_thread_local_t +{ + // the list entry + tb_single_list_entry_t entry; + + // have been initialized? + tb_bool_t inited; + + // the atomice lock of once function + tb_atomic_t once; + + // the free function + tb_thread_local_free_t free; + + /* the private data space for implementation + * + * - sizeof(pthread_key_t) * 2 for pthread key + * - sizeof(DWORD) * 2 for windows key + */ + tb_byte_t priv[16]; + +}tb_thread_local_t, *tb_thread_local_ref_t; + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init a thread local + * + * @note support to be called repeatly, thread safely and only init it once + * + * @code + + // the thread local free function + static tb_void_t tb_thread_local_free_func(tb_cpointer_t priv) + { + if (priv) tb_free(priv); + } + + // the thread function + static tb_cpointer_t th_thread_func(tb_cpointer_t priv) + { + // init the thread local, only once + static tb_thread_local_t s_local = TB_THREAD_LOCAL_INIT; + if (!tb_thread_local_init(&s_local, tb_thread_local_free_func)) return tb_null; + + // get the thread local data + tb_char_t const* data = tb_null; + if (!(data = tb_thread_local_get(&s_local))) + { + tb_char_t const* cstr = tb_strdup("hello"); + if (tb_thread_local_set(&s_local, cstr)) + data = cstr; + else tb_free(cstr); + } + + // trace + tb_trace_i("data: %s", data); + + ... + } + + * @endcode + * + * @param local the global or static thread local (need be initialized as TB_THREAD_LOCAL_INIT) + * @param func the thread local free function + * + * @return tb_true or tb_false + */ +tb_bool_t tb_thread_local_init(tb_thread_local_ref_t local, tb_thread_local_free_t func); + +/*! exit the thread local (optional) + * + * @note this local will be exited automaticlly after tb_exit() was called + * and we call also manually call this function to exit the thread local in earlier time + * + * @param local the thread local reference + */ +tb_void_t tb_thread_local_exit(tb_thread_local_ref_t local); + +/*! has thead local data on the current thread? + * + * @param local the thread local reference + * + * @return the thread local private data + */ +tb_bool_t tb_thread_local_has(tb_thread_local_ref_t local); + +/*! get thead local data from the current thread + * + * @param local the thread local reference + * + * @return the thread local private data + */ +tb_pointer_t tb_thread_local_get(tb_thread_local_ref_t local); + +/*! set thead local data to the current thread + * + * @note this data will be freed automaticlly after it's thread was returned + * + * @param local the thread local reference + * @param priv the thread local private data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_thread_local_set(tb_thread_local_ref_t local, tb_cpointer_t priv); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/thread_pool.h b/core/pkg/tbox.pkg/inc/tbox/platform/thread_pool.h index 2f8df50dc..97243e677 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/thread_pool.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/thread_pool.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file thread_pool.h @@ -50,13 +50,13 @@ __tb_extern_c_enter__ */ /// the thread pool ref type -typedef struct{}* tb_thread_pool_ref_t; +typedef __tb_typeref__(thread_pool); /// the thread pool task ref type -typedef struct{}* tb_thread_pool_task_ref_t; +typedef __tb_typeref__(thread_pool_task); /// the thread pool worker ref type -typedef struct{}* tb_thread_pool_worker_ref_t; +typedef __tb_typeref__(thread_pool_worker); /// the thread pool priv exit func type typedef tb_void_t (*tb_thread_pool_priv_exit_func_t)(tb_thread_pool_worker_ref_t worker, tb_cpointer_t priv); diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/time.h b/core/pkg/tbox.pkg/inc/tbox/platform/time.h index bc9009c70..b7ff9924b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/time.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/time.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file time.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/timer.h b/core/pkg/tbox.pkg/inc/tbox/platform/timer.h index ef9968195..f59ac5cec 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/timer.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/timer.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file timer.h @@ -46,10 +46,10 @@ __tb_extern_c_enter__ typedef tb_void_t (*tb_timer_task_func_t)(tb_bool_t killed, tb_cpointer_t priv); /// the timer ref type -typedef struct{}* tb_timer_ref_t; +typedef __tb_typeref__(timer); /// the timer task ref type -typedef struct{}* tb_timer_task_ref_t; +typedef __tb_typeref__(timer_task); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces @@ -63,12 +63,12 @@ tb_timer_ref_t tb_timer(tb_noarg_t); /*! init timer * - * @param maxn the timer maxn + * @param grow the timer grow * @param ctime using ctime? * * @return the timer */ -tb_timer_ref_t tb_timer_init(tb_size_t maxn, tb_bool_t ctime); +tb_timer_ref_t tb_timer_init(tb_size_t grow, tb_bool_t ctime); /*! exit timer * diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/unix/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/unix/prefix.h index c5735c89c..dcd32d249 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/unix/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/unix/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/unix/syscall.h b/core/pkg/tbox.pkg/inc/tbox/platform/unix/syscall.h index ffa028f34..aa59af874 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/unix/syscall.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/unix/syscall.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file syscall.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/atomic.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/atomic.h index 2df848185..9a705b1a8 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/atomic.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file atomic.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/atomic64.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/atomic64.h index 3cf651b98..5f71c3d1e 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/atomic64.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/atomic64.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file atomic64.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/barrier.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/barrier.h index 61e27d51c..e5d22655a 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/barrier.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file barrier.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/exception.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/exception.h index 132d38d17..1d3d76419 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/exception.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/exception.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file exception.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/dbghelp.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/dbghelp.h index 582082055..9add016e6 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/dbghelp.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/dbghelp.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file dbghelp.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/interface.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/interface.h index 3467ec421..a598a1980 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/interface.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/interface.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file interface.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/iphlpapi.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/iphlpapi.h index 677690f66..674b1b5d6 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/iphlpapi.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/iphlpapi.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file iphlpapi.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/kernel32.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/kernel32.h index a8d32d976..2621476d1 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/kernel32.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/kernel32.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file kernel32.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/mswsock.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/mswsock.h index b791d5c07..ab6289a15 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/mswsock.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/mswsock.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file mswsock.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/ole32.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/ole32.h index 19cee203d..302b03bb0 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/ole32.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/ole32.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file ole32.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/prefix.h index c65ec26ab..992b77b6a 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/shell32.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/shell32.h index 54f3d38ca..cae00014d 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/shell32.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/shell32.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file shell32.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/user32.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/user32.h index a1875436c..7b04b9a09 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/user32.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/user32.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file user32.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/ws2_32.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/ws2_32.h index d53b99cfb..8ac1d5e92 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/ws2_32.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/ws2_32.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file ws2_32.h @@ -115,6 +115,18 @@ typedef tb_int_t (WSAAPI* tb_ws2_32_gethostname_t)(tb_char_t* name, tb_int_t nam // the __WSAFDIsSet func type typedef tb_int_t (WSAAPI* tb_ws2_32___WSAFDIsSet_t)(SOCKET fd, fd_set* set); +// the getaddrinfo func type +typedef tb_int_t (WSAAPI* tb_ws2_32_getaddrinfo_t)(PCSTR pNodeName, PCSTR pServiceName, ADDRINFOA *pHints, PADDRINFOA *ppResult); + +// the getnameinfo func type +typedef tb_int_t (WSAAPI* tb_ws2_32_getnameinfo_t)(const struct sockaddr FAR *sa, socklen_t salen, tb_char_t FAR *host, DWORD hostlen, tb_char_t FAR *serv, DWORD servlen, tb_int_t flags); + +// the gethostbyname func type +typedef struct hostent* (WSAAPI* tb_ws2_32_gethostbyname_t)(tb_char_t const* name); + +// the gethostbyaddr func type +typedef struct hostent* (WSAAPI* tb_ws2_32_gethostbyaddr_t)(tb_char_t const* addr, tb_int_t len, tb_int_t type); + // the ws2_32 interfaces type typedef struct __tb_ws2_32_t { @@ -192,7 +204,19 @@ typedef struct __tb_ws2_32_t // gethostname tb_ws2_32_gethostname_t gethostname; + + // getaddrinfo + tb_ws2_32_getaddrinfo_t getaddrinfo; + + // getnameinfo + tb_ws2_32_getnameinfo_t getnameinfo; + // gethostbyname + tb_ws2_32_gethostbyname_t gethostbyname; + + // gethostbyaddr + tb_ws2_32_gethostbyaddr_t gethostbyaddr; + // __WSAFDIsSet tb_ws2_32___WSAFDIsSet_t __WSAFDIsSet; diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/ntstatus.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/ntstatus.h index c57efe865..4726620d7 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/ntstatus.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/ntstatus.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file ntstatus.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/prefix.h index 9d9f38502..eb42cac39 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h @@ -35,6 +35,7 @@ #include <mswsock.h> #include <windows.h> #include <iphlpapi.h> +#include <ws2tcpip.h> /* ////////////////////////////////////////////////////////////////////////////////////// * inlines diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/socket_pool.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/socket_pool.h index ff8fde64a..973692ab0 100755 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/socket_pool.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/socket_pool.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file socket_pool.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix.h b/core/pkg/tbox.pkg/inc/tbox/prefix.h index c72e3af69..00fc52019 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/abort.h b/core/pkg/tbox.pkg/inc/tbox/prefix/abort.h index 4ae8b1d58..6f75dbfad 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/abort.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/abort.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file abort.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/arch.h b/core/pkg/tbox.pkg/inc/tbox/prefix/arch.h index 6bebf5f90..dcf937080 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/arch.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/arch.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file arch.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/arm/prefix.S b/core/pkg/tbox.pkg/inc/tbox/prefix/arm/prefix.S new file mode 100755 index 000000000..bd438a83b --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/arm/prefix.S @@ -0,0 +1,120 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file prefix.S + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ +#ifdef TB_ARCH_ELF +# define ELF +# define EXTERN_ASM +#else +# define ELF @ +# define EXTERN_ASM _ +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * arch + */ + +#if defined(TB_ARCH_ARM_v8) + .arch armv8-a +#elif defined(TB_ARCH_ARM_v7A) + .arch armv7-a +#elif defined(TB_ARCH_ARM_v7) + .arch armv7 +#elif defined(TB_ARCH_ARM_v6) + .arch armv6 +#elif defined(TB_ARCH_ARM_v5te) + .arch armv5te +#elif defined(TB_ARCH_ARM_v5) + .arch armv5 +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * fpu + */ + +#if defined(TB_ARCH_ARM_NEON) && !defined(TB_ARCH_ARM64) + .fpu neon +#elif defined(TB_ARCH_VFP) + .fpu vfp +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * syntax + */ +#if defined(TB_ARCH_ARM) && !defined(TB_ARCH_ARM64) + .syntax unified +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * eabi + */ +#if defined(TB_ARCH_ELF) && defined(TB_ARCH_ARM) && !defined(TB_ARCH_ARM64) + .eabi_attribute 25, 1 +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ + +/*! function + * + * @code + function func_xxxx, export=1 + ... + endfunc + @endcode + */ +.macro function name, export=0 + .macro endfunc +ELF .size \name, . - \name + .purgem endfunc + .endm + + .text + .align TB_CPU_BITBYTE + .if \export + .global EXTERN_ASM\name +ELF .type EXTERN_ASM\name, %function +ELF .hidden EXTERN_ASM\name +EXTERN_ASM\name: + .else +ELF .type \name, %function +ELF .hidden \name +\name: + .endif +.endm + +/*! label + * + * @code + label name + ... + @endcode + */ +.macro label name + .align TB_CPU_BITBYTE +\name: +.endm + diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/arm64/prefix.S b/core/pkg/tbox.pkg/inc/tbox/prefix/arm64/prefix.S new file mode 100755 index 000000000..80ec7ba65 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/arm64/prefix.S @@ -0,0 +1,120 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file prefix.S + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ +#ifdef TB_ARCH_ELF +# define ELF +# define EXTERN_ASM +#else +# define ELF # +# define EXTERN_ASM _ +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * arch + */ + +#if defined(TB_ARCH_ARM_v8) + .arch armv8-a +#elif defined(TB_ARCH_ARM_v7A) + .arch armv7-a +#elif defined(TB_ARCH_ARM_v7) + .arch armv7 +#elif defined(TB_ARCH_ARM_v6) + .arch armv6 +#elif defined(TB_ARCH_ARM_v5te) + .arch armv5te +#elif defined(TB_ARCH_ARM_v5) + .arch armv5 +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * fpu + */ + +#if defined(TB_ARCH_ARM_NEON) && !defined(TB_ARCH_ARM64) + .fpu neon +#elif defined(TB_ARCH_VFP) + .fpu vfp +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * syntax + */ +#if defined(TB_ARCH_ARM) && !defined(TB_ARCH_ARM64) + .syntax unified +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * eabi + */ +#if defined(TB_ARCH_ELF) && defined(TB_ARCH_ARM) && !defined(TB_ARCH_ARM64) + .eabi_attribute 25, 1 +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ + +/*! function + * + * @code + function func_xxxx, export=1 + ... + endfunc + @endcode + */ +.macro function name, export=0 + .macro endfunc +ELF .size \name, . - \name + .purgem endfunc + .endm + + .text + .align TB_CPU_BITBYTE + .if \export + .global EXTERN_ASM\name +ELF .type EXTERN_ASM\name, %function +ELF .hidden EXTERN_ASM\name +EXTERN_ASM\name: + .else +ELF .type \name, %function +ELF .hidden \name +\name: + .endif +.endm + +/*! label + * + * @code + label name + ... + @endcode + */ +.macro label name + .align TB_CPU_BITBYTE +\name: +.endm + diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/assembler.h b/core/pkg/tbox.pkg/inc/tbox/prefix/assembler.h index 8f55841a3..5b1ad5eac 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/assembler.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/assembler.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file assembler.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/assert.h b/core/pkg/tbox.pkg/inc/tbox/prefix/assert.h index ab5771310..dff63eddb 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/assert.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/assert.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file assert.h @@ -237,7 +237,7 @@ __tb_extern_c_enter__ #endif /// assert: noimpl -#define tb_assert_noimpl() tb_assertf(0, "noimpl") +#define tb_assert_noimpl() tb_assertf(0, "noimpl") /*! the static assert * @@ -247,7 +247,13 @@ __tb_extern_c_enter__ * * @endcode */ -#define tb_assert_static(x) do { typedef int __tb_static_assert__[(x)? 1 : -1]; __tb_volatile__ __tb_static_assert__ __a; tb_used(__a); } while(0) +#if __tb_has_feature__(c_static_assert) +# define tb_assert_static(x) _Static_assert(x, "") +#elif defined(TB_COMPILER_IS_GCC) && TB_COMPILER_VERSION_BE(4, 6) +# define tb_assert_static(x) _Static_assert(x, "") +#else +# define tb_assert_static(x) do { typedef int __tb_static_assert__[(x)? 1 : -1]; __tb_volatile__ __tb_static_assert__ __a; tb_used_ptr((tb_cpointer_t)(tb_size_t)__a); } while(0) +#endif /* ////////////////////////////////////////////////////////////////////////////////////// * declaration @@ -261,6 +267,12 @@ __tb_extern_c_enter__ */ tb_void_t tb_backtrace_dump(tb_char_t const* prefix, tb_pointer_t* frames, tb_size_t nframe); +/*! this variable have been used + * + * @param variable the variable + */ +tb_void_t tb_used_ptr(tb_cpointer_t variable); + /* ////////////////////////////////////////////////////////////////////////////////////// * inlines */ diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/cache.h b/core/pkg/tbox.pkg/inc/tbox/prefix/cache.h new file mode 100755 index 000000000..17e6a2156 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/cache.h @@ -0,0 +1,79 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file cache.h + * + */ +#ifndef TB_PREFIX_CACHE_H +#define TB_PREFIX_CACHE_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "config.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ + +// the cpu L1 cache shift, default: (1 << 5) == 32 bytes +#ifndef TB_L1_CACHE_SHIFT +# define TB_L1_CACHE_SHIFT (5) +#endif + +// the cpu L1 cache bytes, default: 32 bytes +#ifndef TB_L1_CACHE_BYTES +# define TB_L1_CACHE_BYTES (1 << TB_L1_CACHE_SHIFT) +#endif + +// the smp cache bytes +#ifndef TB_SMP_CACHE_BYTES +# define TB_SMP_CACHE_BYTES TB_L1_CACHE_BYTES +#endif + +// the cacheline aligned keyword +#ifndef __tb_cacheline_aligned__ +# if defined(TB_COMPILER_IS_GCC) +# define __tb_cacheline_aligned__ __attribute__((__aligned__(TB_SMP_CACHE_BYTES))) +# elif defined(TB_COMPILER_IS_MSVC) +# if TB_SMP_CACHE_BYTES == 4 +# define __tb_cacheline_aligned__ __declspec(align(4)) +# elif TB_SMP_CACHE_BYTES == 8 +# define __tb_cacheline_aligned__ __declspec(align(8)) +# elif TB_SMP_CACHE_BYTES == 16 +# define __tb_cacheline_aligned__ __declspec(align(16)) +# elif TB_SMP_CACHE_BYTES == 32 +# define __tb_cacheline_aligned__ __declspec(align(32)) +# elif TB_SMP_CACHE_BYTES == 64 +# define __tb_cacheline_aligned__ __declspec(align(64)) +# elif TB_SMP_CACHE_BYTES == 128 +# define __tb_cacheline_aligned__ __declspec(align(128)) +# elif TB_SMP_CACHE_BYTES == 256 +# define __tb_cacheline_aligned__ __declspec(align(256)) +# else +# error unknown cacheline bytes +# endif +# else +# define __tb_cacheline_aligned__ +# endif +#endif + +#endif + + diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/check.h b/core/pkg/tbox.pkg/inc/tbox/prefix/check.h index b64aacd55..6eb07571c 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/check.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/check.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file check.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/compiler.h b/core/pkg/tbox.pkg/inc/tbox/prefix/compiler.h index 4d50eacc2..cbda980cf 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/compiler.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/compiler.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file compiler.h @@ -32,6 +32,19 @@ * macros */ +// some help macros for making version string +#ifndef __tb_mstring__ +# define __tb_mstring__(x) #x +#endif + +#ifndef __tb_mstring_ex__ +# define __tb_mstring_ex__(x) __tb_mstring__(x) +#endif + +#ifndef __tb_mstrcat4__ +# define __tb_mstrcat4__(a, b, c, d) a b c d +#endif + // intel c++ #if defined(__INTEL_COMPILER) # define TB_COMPILER_IS_INTEL @@ -127,46 +140,8 @@ # else # define TB_COMPILER_VERSION_STRING "gnu c/c++ > 3.4 && < 4.0" # endif -# elif __GNUC__ == 4 -# if __GNUC_MINOR__ == 1 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 4.1" -# elif __GNUC_MINOR__ == 2 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 4.2" -# elif __GNUC_MINOR__ == 3 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 4.3" -# elif __GNUC_MINOR__ == 4 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 4.4" -# elif __GNUC_MINOR__ == 5 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 4.5" -# elif __GNUC_MINOR__ == 6 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 4.6" -# elif __GNUC_MINOR__ == 7 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 4.7" -# elif __GNUC_MINOR__ == 8 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 4.8" -# elif __GNUC_MINOR__ == 9 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 4.9" -# endif -# elif __GNUC__ == 5 -# if __GNUC_MINOR__ == 1 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 5.1" -# elif __GNUC_MINOR__ == 2 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 5.2" -# elif __GNUC_MINOR__ == 3 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 5.3" -# elif __GNUC_MINOR__ == 4 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 5.4" -# elif __GNUC_MINOR__ == 5 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 5.5" -# elif __GNUC_MINOR__ == 6 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 5.6" -# elif __GNUC_MINOR__ == 7 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 5.7" -# elif __GNUC_MINOR__ == 8 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 5.8" -# elif __GNUC_MINOR__ == 9 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 5.9" -# endif +# elif __GNUC__ >= 4 && defined(__GNUC_MINOR__) +# define TB_COMPILER_VERSION_STRING __tb_mstrcat4__("gnu c/c++ ", __tb_mstring_ex__(__GNUC__), ".", __tb_mstring_ex__(__GNUC_MINOR__)) # else # error Unknown gnu c/c++ Compiler Version # endif @@ -183,10 +158,24 @@ # undef TB_COMPILER_VERSION_STRING # define TB_COMPILER_VERSION_STRING __clang_version__ # endif - // ignore warning: empty struct has size 0 in C, size 1 in C++ + // suppress warning: empty struct has size 0 in C, size 1 in C++ # ifdef __cplusplus # pragma clang diagnostic ignored "-Wextern-c-compat" # endif + /* suppress warning (must be placed in the front) + * + * in old version clang: + * + * unknown warning group '-Wnullability-completeness', ignored [-Werror,-Wunknown-pragmas] + */ +# pragma clang diagnostic ignored "-Wunknown-pragmas" + + /* suppress warning + * + * signal.h + * pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) + */ +# pragma clang diagnostic ignored "-Wnullability-completeness" # endif // watcom c/c++ diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/config.h b/core/pkg/tbox.pkg/inc/tbox/prefix/config.h index d8b62dcb3..1e6df81ce 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/config.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/config.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file config.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/cpu.h b/core/pkg/tbox.pkg/inc/tbox/prefix/cpu.h index fab6bb866..171dc5a2f 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/cpu.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/cpu.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file cpu.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/endian.h b/core/pkg/tbox.pkg/inc/tbox/prefix/endian.h index 04ce3c8db..37d645d1b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/endian.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/endian.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file endian.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/keyword.h b/core/pkg/tbox.pkg/inc/tbox/prefix/keyword.h index dc262326e..2513947a6 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/keyword.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/keyword.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file keyword.h @@ -113,7 +113,7 @@ #endif // like -#if defined(TB_COMPILER_IS_GCC) && __GNUC__ > 2 +#if defined(TB_COMPILER_IS_GCC) && TB_COMPILER_VERSION_BT(2, 0) # define __tb_likely__(x) __builtin_expect((x), 1) # define __tb_unlikely__(x) __builtin_expect((x), 0) #else @@ -179,7 +179,7 @@ # define __tb_export__ #endif -#if defined(TB_COMPILER_IS_GCC) && __GNUC__ >= 3 +#if defined(TB_COMPILER_IS_GCC) && TB_COMPILER_VERSION_BE(3, 0) # define __tb_deprecated__ __attribute__((deprecated)) #elif defined(TB_COMPILER_IS_MSVC) && defined(_MSC_VER) && _MSC_VER >= 1300 # define __tb_deprecated__ __declspec(deprecated) @@ -215,6 +215,43 @@ # define __tb_no_sanitize_address__ #endif +// thread local +#if __tb_has_feature__(c_thread_local) +# define __tb_thread_local__ _Thread_local +#elif defined(TB_COMPILER_IS_GCC) +# if TB_COMPILER_VERSION_BE(4, 9) +# define __tb_thread_local__ _Thread_local +# else +# define __tb_thread_local__ __thread +# endif +#elif defined(TB_COMPILER_IS_MSVC) || defined(TB_COMPILER_IS_BORLAND) +# define __tb_thread_local__ __declspec(thread) +#endif + +/*! the type reference keyword for defining tb_xxxx_ref_t + * + * typedef __tb_typeref__(xxxx); + * + * + * suppress gcc 4.9 on c++ codes warning: '__tb_yyyy_t' has a field '__tb_yyyy_t::xxxx' whose type uses the anonymous namespace + * + * @code + * + typedef struct{}* tb_xxxx_ref_t; + + typedef struct __tb_yyyy_t + { + tb_xxxx_ref_t xxxx; + + }__tb_yyyy_t; + + * + * + * @endcode + * + */ +#define __tb_typeref__(object) struct __tb_##object##_dummy_t{tb_int_t dummy;}* tb_##object##_ref_t + // macros #define __tb_mstring__(x) #x #define __tb_mstring_ex__(x) __tb_mstring__(x) diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/limits.h b/core/pkg/tbox.pkg/inc/tbox/prefix/limits.h index 7bc322f8c..1ddd91c0a 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/limits.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/limits.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file limits.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/malloc.h b/core/pkg/tbox.pkg/inc/tbox/prefix/malloc.h index 37651ad51..3c30524d8 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/malloc.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/malloc.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file malloc.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/mips/prefix.S b/core/pkg/tbox.pkg/inc/tbox/prefix/mips/prefix.S new file mode 100755 index 000000000..07e16c76c --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/mips/prefix.S @@ -0,0 +1,59 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file prefix.S + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ + +/*! function + * + * @code + function func_xxxx, export=1 + ... + endfunc + @endcode + */ +.macro function name, export=0 + .macro endfunc + .end \name + .size \name, . - \name + .purgem endfunc + .endm + + .text + .align TB_CPU_BITBYTE + .if \export + .global \name + .type \name, @function + .hidden \name + .ent \name +\name: + .else + .type \name, @function + .hidden \name + .ent \name +\name: + .endif +.endm + + diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/packed.h b/core/pkg/tbox.pkg/inc/tbox/prefix/packed.h index 815c294bb..7b0d2a9a3 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/packed.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/packed.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file packed_e.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/prefix.h b/core/pkg/tbox.pkg/inc/tbox/prefix/prefix.h index db4bf42f3..ebc5dd1c8 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h @@ -43,7 +43,7 @@ #include "malloc.h" #include "utils.h" #include "state.h" -#include "asm.h" +#include "cache.h" #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/state.h b/core/pkg/tbox.pkg/inc/tbox/prefix/state.h index d8e5dc454..96cd1dc6b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/state.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/state.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file state.h @@ -62,24 +62,28 @@ typedef enum __tb_state_e { TB_STATE_OK = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 0) , TB_STATE_END = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 1) -, TB_STATE_FAILED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 2) -, TB_STATE_KILLED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 3) -, TB_STATE_PAUSED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 4) -, TB_STATE_CLOSED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 5) -, TB_STATE_OPENED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 6) -, TB_STATE_OPENING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 7) -, TB_STATE_PENDING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 8) -, TB_STATE_WAITING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 9) -, TB_STATE_WORKING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 10) -, TB_STATE_KILLING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 11) -, TB_STATE_PAUSING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 12) -, TB_STATE_EXITING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 13) -, TB_STATE_TIMEOUT = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 14) -, TB_STATE_FINISHED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 15) -, TB_STATE_WAIT_FAILED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 16) -, TB_STATE_POST_FAILED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 17) -, TB_STATE_NOT_SUPPORTED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 18) -, TB_STATE_UNKNOWN_ERROR = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 19) +, TB_STATE_DEAD = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 2) +, TB_STATE_READY = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 3) +, TB_STATE_FAILED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 4) +, TB_STATE_KILLED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 5) +, TB_STATE_PAUSED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 6) +, TB_STATE_CLOSED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 7) +, TB_STATE_OPENED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 8) +, TB_STATE_OPENING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 9) +, TB_STATE_SUSPEND = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 10) +, TB_STATE_RUNNING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 11) +, TB_STATE_PENDING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 12) +, TB_STATE_WAITING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 13) +, TB_STATE_WORKING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 14) +, TB_STATE_KILLING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 15) +, TB_STATE_PAUSING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 16) +, TB_STATE_EXITING = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 17) +, TB_STATE_TIMEOUT = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 18) +, TB_STATE_FINISHED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 19) +, TB_STATE_WAIT_FAILED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 20) +, TB_STATE_POST_FAILED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 21) +, TB_STATE_NOT_SUPPORTED = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 22) +, TB_STATE_UNKNOWN_ERROR = TB_STATE_DEFINE(TB_STATE_TYPE_NONE, 23) , TB_STATE_FILE_NOT_EXISTS = TB_STATE_DEFINE(TB_STATE_TYPE_FILE, 1) , TB_STATE_FILE_OPEN_FAILED = TB_STATE_DEFINE(TB_STATE_TYPE_FILE, 2) diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/trace.h b/core/pkg/tbox.pkg/inc/tbox/prefix/trace.h index 68c508ba5..786277b0f 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/trace.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/trace.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file trace.h @@ -219,8 +219,8 @@ __tb_extern_c_enter__ # define tb_trace1_i #endif -// trace info only? -#ifdef TB_CONFIG_TRACE_INFO_ONLY +// trace more info? +#if !defined(__tb_debug__) && !defined(TB_CONFIG_INFO_TRACE_MORE) # undef TB_TRACE_DEBUG # undef TB_TRACE_MODULE_DEBUG # undef tb_trace_d diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/type.h b/core/pkg/tbox.pkg/inc/tbox/prefix/type.h index 400ac88bc..e4a108c29 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/type.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/type.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file type.h @@ -100,7 +100,7 @@ typedef __WCHAR_TYPE__ tb_wchar_t; #elif defined(__WCHAR_WIDTH__) && (__WCHAR_WIDTH__ == 2) typedef tb_int16_t tb_wchar_t; #elif defined(__WCHAR_WIDTH__) && (__WCHAR_WIDTH__ == 4) -typedef tb_int16_t tb_wchar_t; +typedef tb_int32_t tb_wchar_t; #else typedef tb_int32_t tb_wchar_t; #endif @@ -161,31 +161,31 @@ typedef tb_atomic_t tb_spinlock_t; typedef tb_spinlock_t* tb_spinlock_ref_t; /// the pool ref type -typedef struct{}* tb_pool_ref_t; +typedef __tb_typeref__(pool); /// the file ref type -typedef struct{}* tb_file_ref_t; +typedef __tb_typeref__(file); /// the socket ref type -typedef struct{}* tb_socket_ref_t; +typedef __tb_typeref__(socket); /// the event ref type -typedef struct{}* tb_event_ref_t; +typedef __tb_typeref__(event); /// the mutex ref type -typedef struct{}* tb_mutex_ref_t; +typedef __tb_typeref__(mutex); /// the thread ref type -typedef struct{}* tb_thread_ref_t; +typedef __tb_typeref__(thread); /// the semaphore ref type -typedef struct{}* tb_semaphore_ref_t; +typedef __tb_typeref__(semaphore); /// the stream ref type -typedef struct{}* tb_stream_ref_t; +typedef __tb_typeref__(stream); /// the async stream ref type -typedef struct{}* tb_async_stream_ref_t; +typedef __tb_typeref__(async_stream); /// the time type typedef tb_hong_t tb_time_t; diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/utils.h b/core/pkg/tbox.pkg/inc/tbox/prefix/utils.h index 4bd0e7a46..5d776258c 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/utils.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/utils.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file utils.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/version.h b/core/pkg/tbox.pkg/inc/tbox/prefix/version.h index 9d066993f..0abcd9799 100755 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/version.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/version.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file version.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/x64/prefix.S b/core/pkg/tbox.pkg/inc/tbox/prefix/x64/prefix.S new file mode 100755 index 000000000..c3f80f31d --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/x64/prefix.S @@ -0,0 +1,27 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file prefix.S + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../x86/prefix.S" diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/x86/prefix.S b/core/pkg/tbox.pkg/inc/tbox/prefix/x86/prefix.S new file mode 100755 index 000000000..0866baa24 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/x86/prefix.S @@ -0,0 +1,54 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file prefix.S + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ + +/*! function + * + * @code + function(func_xxxx) + ... + endfunc + @endcode + */ +#ifdef TB_ARCH_ELF +# define function(name) \ + .text ;\ + .align TB_CPU_BITBYTE ; \ + .global name ;\ + .type name, %function; \ + .hidden name; \ +name: +#else +# define function(name) \ + .text ;\ + .align TB_CPU_BITBYTE ; \ + .global _##name ;\ +_##name: +#endif + +// end function +#define endfunc + diff --git a/core/pkg/tbox.pkg/inc/tbox/regex/prefix.h b/core/pkg/tbox.pkg/inc/tbox/regex/prefix.h index 4ca191d5a..d5639e2f4 100755 --- a/core/pkg/tbox.pkg/inc/tbox/regex/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/regex/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/regex/regex.h b/core/pkg/tbox.pkg/inc/tbox/regex/regex.h index a25ee00be..942a7eef3 100755 --- a/core/pkg/tbox.pkg/inc/tbox/regex/regex.h +++ b/core/pkg/tbox.pkg/inc/tbox/regex/regex.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file regex.h @@ -38,7 +38,7 @@ __tb_extern_c_enter__ */ /// the regex ref type -typedef struct{}* tb_regex_ref_t; +typedef __tb_typeref__(regex); /// the regex match type typedef struct _tb_regex_match_t diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/async_stream.h b/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/async_stream.h new file mode 100755 index 000000000..0badeb247 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/async_stream.h @@ -0,0 +1,724 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file async_stream.h + * @ingroup stream + * + */ +#ifndef TB_STREAM_ASYNC_STREAM_H +#define TB_STREAM_ASYNC_STREAM_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "../../asio/deprecated/asio.h" +#include "../../libc/libc.h" +#include "../../network/url.h" +#include "../../memory/memory.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ + +/// open +#define tb_async_stream_open(stream, func, priv) tb_async_stream_open_(stream, func, priv __tb_debug_vals__) + +/// clos +#define tb_async_stream_clos(stream, func, priv) tb_async_stream_clos_(stream, func, priv __tb_debug_vals__) + +/// read +#define tb_async_stream_read(stream, size, func, priv) tb_async_stream_read_(stream, size, func, priv __tb_debug_vals__) + +/// writ +#define tb_async_stream_writ(stream, data, size, func, priv) tb_async_stream_writ_(stream, data, size, func, priv __tb_debug_vals__) + +/// seek +#define tb_async_stream_seek(stream, offset, func, priv) tb_async_stream_seek_(stream, offset, func, priv __tb_debug_vals__) + +/// sync +#define tb_async_stream_sync(stream, bclosing, func, priv) tb_async_stream_sync_(stream, bclosing, func, priv __tb_debug_vals__) + +/// task +#define tb_async_stream_task(stream, delay, func, priv) tb_async_stream_task_(stream, delay, func, priv __tb_debug_vals__) + +/// open and read +#define tb_async_stream_open_read(stream, size, func, priv) tb_async_stream_open_read_(stream, size, func, priv __tb_debug_vals__) + +/// open and writ +#define tb_async_stream_open_writ(stream, data, size, func, priv) tb_async_stream_open_writ_(stream, data, size, func, priv __tb_debug_vals__) + +/// open and seek +#define tb_async_stream_open_seek(stream, offset, func, priv) tb_async_stream_open_seek_(stream, offset, func, priv __tb_debug_vals__) + +/// read after delay +#define tb_async_stream_read_after(stream, delay, size, func, priv) tb_async_stream_read_after_(stream, delay, size, func, priv __tb_debug_vals__) + +/// writ after delay +#define tb_async_stream_writ_after(stream, delay, data, size, func, priv) tb_async_stream_writ_after_(stream, delay, data, size, func, priv __tb_debug_vals__) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/*! the stream open func type + * + * @param stream the stream + * @param state the state + * @param priv the func private data + * + * @return tb_true: ok, tb_false: error, but not break aicp + */ +typedef tb_bool_t (*tb_async_stream_open_func_t)(tb_async_stream_ref_t stream, tb_size_t state, tb_cpointer_t priv); + +/*! the stream clos func type + * + * @param stream the stream + * @param state the state + * @param priv the func private data + */ +typedef tb_void_t (*tb_async_stream_clos_func_t)(tb_async_stream_ref_t stream, tb_size_t state, tb_cpointer_t priv); + +/*! the stream read func type + * + * @param stream the stream + * @param state the state + * @param data the readed data + * @param real the real size, maybe zero + * @param size the need size + * @param priv the func private data + * + * @return tb_true: ok and continue it if need, tb_false: break it, but not break aicp + */ +typedef tb_bool_t (*tb_async_stream_read_func_t)(tb_async_stream_ref_t stream, tb_size_t state, tb_byte_t const* data, tb_size_t real, tb_size_t size, tb_cpointer_t priv); + +/*! the stream writ func type + * + * @param stream the stream + * @param state the state + * @param data the writed data + * @param real the real size, maybe zero + * @param size the need size + * @param priv the func private data + * + * @return tb_true: ok and continue it if need, tb_false: break it, but not break aicp + */ +typedef tb_bool_t (*tb_async_stream_writ_func_t)(tb_async_stream_ref_t stream, tb_size_t state, tb_byte_t const* data, tb_size_t real, tb_size_t size, tb_cpointer_t priv); + +/*! the stream seek func type + * + * @param stream the stream + * @param state the state + * @param offset the real offset + * @param priv the func private data + * + * @return tb_true: ok, tb_false: error, but not break aicp + */ +typedef tb_bool_t (*tb_async_stream_seek_func_t)(tb_async_stream_ref_t stream, tb_size_t state, tb_hize_t offset, tb_cpointer_t priv); + +/*! the stream sync func type + * + * @param stream the stream + * @param state the state + * @param bclosing is closing? + * @param priv the func private data + * + * @return tb_true: ok, tb_false: error, but not break aicp + */ +typedef tb_bool_t (*tb_async_stream_sync_func_t)(tb_async_stream_ref_t stream, tb_size_t state, tb_bool_t bclosing, tb_cpointer_t priv); + +/*! the stream task func type + * + * @param stream the stream + * @param state the state + * @param priv the func private data + * + * @return tb_true: ok, tb_false: error, but not break aicp + */ +typedef tb_bool_t (*tb_async_stream_task_func_t)(tb_async_stream_ref_t stream, tb_size_t state, tb_cpointer_t priv); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init async stream + * + * @param aicp the aicp + * @param type the stream type + * @param type_size the stream type size + * @param rcache the read cache size + * @param wcache the writ cache size + * @param open the stream impl func: open + * @param clos the stream impl func: clos + * @param exit the stream impl func: exit, optional + * @param ctrl the stream impl func: ctrl + * @param wait the stream impl func: wait + * @param read the stream impl func: read + * @param writ the stream impl func: writ + * @param seek the stream impl func: seek, optional + * @param sync the stream impl func: sync, optional + * @param kill the stream impl func: kill, optional + * + * @return the stream + * + * @code + // the custom xxxx async stream type + typedef struct __tb_async_stream_xxxx_impl_t + { + // the xxxx data + tb_handle_t xxxx; + + }tb_async_stream_xxxx_impl_t; + + static tb_bool_t tb_async_stream_xxxx_impl_open(tb_async_stream_ref_t stream, tb_async_stream_open_func_t func, tb_cpointer_t priv) + { + // check + tb_async_stream_xxxx_impl_t* impl = (tb_async_stream_xxxx_impl_t*)stream; + tb_assert_and_check_return_val(impl, tb_false); + + // ok + return tb_true; + } + static tb_bool_t tb_async_stream_xxxx_impl_clos(tb_async_stream_ref_t stream, tb_async_stream_clos_func_t, tb_cpointer_t priv) + { + // check + tb_async_stream_xxxx_impl_t* impl = (tb_async_stream_xxxx_impl_t*)stream; + tb_assert_and_check_return_val(impl, tb_false); + + // ok + return tb_true; + } + + // define other xxxx async stream func + // ... + + // init async stream + tb_async_stream_ref_t stream = tb_async_stream_init( tb_aicp() + , TB_STREAM_TYPE_XXXX + , sizeof(tb_async_stream_xxxx_impl_t) + , 0 + , 0 + , tb_async_stream_xxxx_impl_open_try + , tb_async_stream_xxxx_impl_clos_try + , tb_async_stream_xxxx_impl_open + , tb_async_stream_xxxx_impl_clos + , tb_async_stream_xxxx_impl_exit + , tb_async_stream_xxxx_impl_kill + , tb_async_stream_xxxx_impl_ctrl + , tb_async_stream_xxxx_impl_read + , tb_async_stream_xxxx_impl_writ + , tb_async_stream_xxxx_impl_seek + , tb_async_stream_xxxx_impl_sync + , tb_async_stream_xxxx_impl_task + ); + + // using async stream + // ... + + * @endcode + */ +tb_async_stream_ref_t tb_async_stream_init( tb_aicp_ref_t aicp + , tb_size_t type + , tb_size_t type_size + , tb_size_t rcache + , tb_size_t wcache + , tb_bool_t (*open_try)(tb_async_stream_ref_t stream) + , tb_bool_t (*clos_try)(tb_async_stream_ref_t stream) + , tb_bool_t (*open)(tb_async_stream_ref_t stream, tb_async_stream_open_func_t func, tb_cpointer_t priv) + , tb_bool_t (*clos)(tb_async_stream_ref_t stream, tb_async_stream_clos_func_t func, tb_cpointer_t priv) + , tb_bool_t (*exit)(tb_async_stream_ref_t stream) + , tb_void_t (*kill)(tb_async_stream_ref_t stream) + , tb_bool_t (*ctrl)(tb_async_stream_ref_t stream, tb_size_t ctrl, tb_va_list_t args) + , tb_bool_t (*read)(tb_async_stream_ref_t stream, tb_size_t delay, tb_byte_t* data, tb_size_t size, tb_async_stream_read_func_t func, tb_cpointer_t priv) + , tb_bool_t (*writ)(tb_async_stream_ref_t stream, tb_size_t delay, tb_byte_t const* data, tb_size_t size, tb_async_stream_writ_func_t func, tb_cpointer_t priv) + , tb_bool_t (*seek)(tb_async_stream_ref_t stream, tb_hize_t offset, tb_async_stream_seek_func_t func, tb_cpointer_t priv) + , tb_bool_t (*sync)(tb_async_stream_ref_t stream, tb_bool_t bclosing, tb_async_stream_sync_func_t func, tb_cpointer_t priv) + , tb_bool_t (*task)(tb_async_stream_ref_t stream, tb_size_t delay, tb_async_stream_task_func_t func, tb_cpointer_t priv)); + +/*! init data stream + * + * @param aicp the aicp, using the default aicp if be null + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_data(tb_aicp_ref_t aicp); + +/*! init file stream + * + * @param aicp the aicp, using the default aicp if be null + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_file(tb_aicp_ref_t aicp); + +/*! init sock stream + * + * @param aicp the aicp, using the default aicp if be null + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_sock(tb_aicp_ref_t aicp); + +/*! init http stream + * + * @param aicp the aicp, using the default aicp if be null + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_http(tb_aicp_ref_t aicp); + +/*! init filter stream + * + * @param aicp the aicp, using the default aicp if be null + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_filter(tb_aicp_ref_t aicp); + +/*! exit stream + * + * @param stream the stream + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_exit(tb_async_stream_ref_t stream); + +/*! init stream from url + * + * @param aicp the aicp, using the default aicp if be null + * @param url the url + * <pre> + * data://base64 + * file://path or unix path: e.g. /root/xxxx/file + * sock://host:port?tcp= + * sock://host:port?udp= + * socks://host:port + * http://host:port/path?arg0=&arg1=... + * https://host:port/path?arg0=&arg1=... + * </pre> + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_from_url(tb_aicp_ref_t aicp, tb_char_t const* url); + +/*! init stream from data + * + * @param aicp the aicp, using the default aicp if be null + * @param data the data + * @param size the size + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_from_data(tb_aicp_ref_t aicp, tb_byte_t const* data, tb_size_t size); + +/*! init stream from file + * + * @param aicp the aicp, using the default aicp if be null + * @param path the file path + * @param mode the file mode, using the default ro mode if zero + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_from_file(tb_aicp_ref_t aicp, tb_char_t const* path, tb_size_t mode); + +/*! init stream from sock + * + * @param aicp the aicp, using the default aicp if be null + * @param host the host + * @param port the port + * @param type the socket type, tcp or udp + * @param bssl enable ssl? + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_from_sock(tb_aicp_ref_t aicp, tb_char_t const* host, tb_uint16_t port, tb_size_t type, tb_bool_t bssl); + +/*! init stream from http or https + * + * @param aicp the aicp, using the default aicp if be null + * @param host the host + * @param port the port + * @param path the path + * @param bssl enable ssl? + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_from_http(tb_aicp_ref_t aicp, tb_char_t const* host, tb_uint16_t port, tb_char_t const* path, tb_bool_t bssl); + +/*! init filter stream from null + * + * @param stream the stream + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_filter_from_null(tb_async_stream_ref_t stream); + +/*! init filter stream from zip + * + * @param stream the stream + * @param algo the zip algorithm + * @param action the zip action + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_filter_from_zip(tb_async_stream_ref_t stream, tb_size_t algo, tb_size_t action); + +/*! init filter stream from cache + * + * @param stream the stream + * @param size the initial cache size, using the default size if be zero + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_filter_from_cache(tb_async_stream_ref_t stream, tb_size_t size); + +/*! init filter stream from charset + * + * @param stream the stream + * @param fr the from charset + * @param to the to charset + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_filter_from_charset(tb_async_stream_ref_t stream, tb_size_t fr, tb_size_t to); + +/*! init filter stream from chunked + * + * @param stream the stream + * @param dechunked decode the chunked data? + * + * @return the stream + */ +tb_async_stream_ref_t tb_async_stream_init_filter_from_chunked(tb_async_stream_ref_t stream, tb_bool_t dechunked); + +/*! the stream url + * + * @param stream the stream + * + * @return the stream url + */ +tb_url_ref_t tb_async_stream_url(tb_async_stream_ref_t stream); + +/*! the stream type + * + * @param stream the stream + * + * @return the stream type + */ +tb_size_t tb_async_stream_type(tb_async_stream_ref_t stream); + +/*! the stream size and not seeking it + * + * @param stream the stream + * + * @return the stream size, no size: -1, empty or error: 0 + */ +tb_hong_t tb_async_stream_size(tb_async_stream_ref_t stream); + +/*! the stream left size and not seeking it + * + * @param stream the stream + * + * @return the stream left size, no size: infinity, empty or end: 0 + */ +tb_hize_t tb_async_stream_left(tb_async_stream_ref_t stream); + +/*! the stream is end? + * + * @param stream the stream + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_beof(tb_async_stream_ref_t stream); + +/*! the stream offset + * + * the offset is read + writ and using seek for modifying it if size != -1, .e.g: data, file, .. + * the offset is calculated from the last read/writ and not seeking it if size == -1, .e.g: sock, filter, .. + * + * @param stream the stream + * + * @return the stream offset + */ +tb_hize_t tb_async_stream_offset(tb_async_stream_ref_t stream); + +/*! is opened? + * + * @param stream the stream + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_is_opened(tb_async_stream_ref_t stream); + +/*! is closed? + * + * @param stream the stream + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_is_closed(tb_async_stream_ref_t stream); + +/*! is killed? + * + * @param stream the stream + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_is_killed(tb_async_stream_ref_t stream); + +/*! the stream timeout + * + * @param stream the stream + * + * @return the stream timeout + */ +tb_long_t tb_async_stream_timeout(tb_async_stream_ref_t stream); + +/*! ctrl stream + * + * @param stream the stream + * @param ctrl the ctrl code + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_ctrl(tb_async_stream_ref_t stream, tb_size_t ctrl, ...); + +/*! ctrl stream with arguments + * + * @param stream the stream + * @param ctrl the ctrl code + * @param args the ctrl args + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_ctrl_with_args(tb_async_stream_ref_t stream, tb_size_t ctrl, tb_va_list_t args); + +/*! kill stream + * + * @param stream the stream + */ +tb_void_t tb_async_stream_kill(tb_async_stream_ref_t stream); + +/*! try opening the stream for stream: file, filter, ... + * + * @param stream the stream + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_open_try(tb_async_stream_ref_t stream); + +/*! open the stream + * + * @param stream the stream + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_open_(tb_async_stream_ref_t stream, tb_async_stream_open_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! try closing the stream for stream: file, filter, or closed stream... + * + * @param stream the stream + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_clos_try(tb_async_stream_ref_t stream); + +/*! close the stream + * + * @param stream the stream + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_clos_(tb_async_stream_ref_t stream, tb_async_stream_clos_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! read the stream + * + * @param stream the stream + * @param size the read size, using the default size if be zero + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_read_(tb_async_stream_ref_t stream, tb_size_t size, tb_async_stream_read_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! writ the stream + * + * @param stream the stream + * @param data the data + * @param size the size + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_writ_(tb_async_stream_ref_t stream, tb_byte_t const* data, tb_size_t size, tb_async_stream_writ_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! seek the stream + * + * @param stream the stream + * @param offset the offset + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_seek_(tb_async_stream_ref_t stream, tb_hize_t offset, tb_async_stream_seek_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! sync the stream + * + * @param stream the stream + * @param bclosing sync the tail data for closing + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_sync_(tb_async_stream_ref_t stream, tb_bool_t bclosing, tb_async_stream_sync_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! task the stream + * + * @param stream the stream + * @param delay the delay time, ms + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_task_(tb_async_stream_ref_t stream, tb_size_t delay, tb_async_stream_task_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! open and read the stream, open it first if not opened + * + * @param stream the stream + * @param size the read size, using the default size if be zero + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_read_(tb_async_stream_ref_t stream, tb_size_t size, tb_async_stream_read_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! open and read the stream, open it first if not opened + * + * @param stream the stream + * @param size the size, using the default size be zero + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_open_read_(tb_async_stream_ref_t stream, tb_size_t size, tb_async_stream_read_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! open and writ the stream, open it first if not opened + * + * @param stream the stream + * @param data the data + * @param size the size + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_open_writ_(tb_async_stream_ref_t stream, tb_byte_t const* data, tb_size_t size, tb_async_stream_writ_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! open and seek the stream, open it first if not opened + * + * @param stream the stream + * @param offset the offset + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_open_seek_(tb_async_stream_ref_t stream, tb_hize_t offset, tb_async_stream_seek_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! read the stream after the delay time + * + * @param stream the stream + * @param delay the delay time, ms + * @param size the read size, using the default size if be zero + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_read_after_(tb_async_stream_ref_t stream, tb_size_t delay, tb_size_t size, tb_async_stream_read_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! writ the stream after the delay time + * + * @param stream the stream + * @param delay the delay time, ms + * @param data the data + * @param size the size + * @param func the func + * @param priv the func data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_stream_writ_after_(tb_async_stream_ref_t stream, tb_size_t delay, tb_byte_t const* data, tb_size_t size, tb_async_stream_writ_func_t func, tb_cpointer_t priv __tb_debug_decl__); + +/*! the stream aicp + * + * @param stream the stream + * + * @return the stream aicp + */ +tb_aicp_ref_t tb_async_stream_aicp(tb_async_stream_ref_t stream); + +#ifdef __tb_debug__ +/*! the stream func name from post for debug + * + * @param stream the stream + * + * @return the stream func name + */ +tb_char_t const* tb_async_stream_func(tb_async_stream_ref_t stream); + +/*! the stream file name from post for debug + * + * @param stream the stream + * + * @return the stream file name + */ +tb_char_t const* tb_async_stream_file(tb_async_stream_ref_t stream); + +/*! the stream line number from post for debug + * + * @param stream the stream + * + * @return the stream line number + */ +tb_size_t tb_async_stream_line(tb_async_stream_ref_t stream); +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/async_transfer.h b/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/async_transfer.h new file mode 100755 index 000000000..15f9475bf --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/async_transfer.h @@ -0,0 +1,321 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file async_transfer.h + * @ingroup stream + * + */ +#ifndef TB_STREAM_ASYNC_TRANSFER_H +#define TB_STREAM_ASYNC_TRANSFER_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "async_stream.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/*! the async transfer open func type + * + * @param state the stream state + * @param offset the istream offset + * @param size the istream size, no size: -1 + * @param priv the func private data + * + * @return tb_true: ok, tb_false: break it + */ +typedef tb_bool_t (*tb_async_transfer_open_func_t)(tb_size_t state, tb_hize_t offset, tb_hong_t size, tb_cpointer_t priv); + +/*! the async transfer clos func type + * + * @param state the stream state + * @param priv the func private data + */ +typedef tb_void_t (*tb_async_transfer_clos_func_t)(tb_size_t state, tb_cpointer_t priv); + +/*! the async transfer ctrl func type + * + * @param istream the istream + * @param ostream the ostream + * @param priv the func private data + * + * @return tb_true: ok, tb_false: break it + */ +typedef tb_bool_t (*tb_async_transfer_ctrl_func_t)(tb_async_stream_ref_t istream, tb_async_stream_ref_t ostream, tb_cpointer_t priv); + +/*! the async transfer done func type + * + * @param state the stream state + * @param offset the istream offset + * @param size the istream size, no size: -1 + * @param save the saved size + * @param rate the current rate, bytes/s + * @param priv the func private data + * + * @return tb_true: ok and continue it if need, tb_false: break it + */ +typedef tb_bool_t (*tb_async_transfer_done_func_t)(tb_size_t state, tb_hize_t offset, tb_hong_t size, tb_hize_t save, tb_size_t rate, tb_cpointer_t priv); + +/// the async transfer ref type +typedef __tb_typeref__(async_transfer); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init async transfer + * + * @param aicp the aicp, using the default aicp if be null + * @param autoclosing auto closing it after finishing transfer + * + * @return the async transfer + */ +tb_async_transfer_ref_t tb_async_transfer_init(tb_aicp_ref_t aicp, tb_bool_t autoclosing); + +/*! init istream + * + * @param transfer the async transfer + * @param stream the stream + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_init_istream(tb_async_transfer_ref_t transfer, tb_async_stream_ref_t stream); + +/*! init istream from url + * + * @param transfer the async transfer + * @param url the url + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_init_istream_from_url(tb_async_transfer_ref_t transfer, tb_char_t const* url); + +/*! init istream from data + * + * @param transfer the async transfer + * @param data the data + * @param size the size + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_init_istream_from_data(tb_async_transfer_ref_t transfer, tb_byte_t const* data, tb_size_t size); + +/*! init ostream + * + * @param transfer the async transfer + * @param stream the stream + * + * @return the async transfer + */ +tb_bool_t tb_async_transfer_init_ostream(tb_async_transfer_ref_t transfer, tb_async_stream_ref_t stream); + +/*! init ostream from url + * + * @param transfer the async transfer + * @param url the url + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_init_ostream_from_url(tb_async_transfer_ref_t transfer, tb_char_t const* url); + +/*! init ostream from data + * + * @param transfer the async transfer + * @param data the data + * @param size the size + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_init_ostream_from_data(tb_async_transfer_ref_t transfer, tb_byte_t* data, tb_size_t size); + +/*! ctrl istream + * + * @note must call it before opening + * + * @param transfer the async transfer + * @param ctrl the ctrl code, using the stream ctrl code + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_ctrl_istream(tb_async_transfer_ref_t transfer, tb_size_t ctrl, ...); + +/*! ctrl ostream + * + * @note must call it before opening + * + * @param transfer the async transfer + * @param ctrl the ctrl code, using the stream ctrl code + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_ctrl_ostream(tb_async_transfer_ref_t transfer, tb_size_t ctrl, ...); + +/*! ctrl transfer + * + * @param transfer the async transfer + * @param offset the start offset + * @param func the ctrl func + * @param priv the func private data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_ctrl(tb_async_transfer_ref_t transfer, tb_async_transfer_ctrl_func_t func, tb_cpointer_t priv); + +/*! open transfer + * + * @param transfer the async transfer + * @param offset the start offset + * @param func the open func + * @param priv the func private data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_open(tb_async_transfer_ref_t transfer, tb_hize_t offset, tb_async_transfer_open_func_t func, tb_cpointer_t priv); + +/*! clos transfer + * + * @param transfer the async transfer + * @param func the clos func + * @param priv the func private data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_clos(tb_async_transfer_ref_t transfer, tb_async_transfer_clos_func_t func, tb_cpointer_t priv); + +/*! try closing transfer + * + * @param transfer the async transfer + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_clos_try(tb_async_transfer_ref_t transfer); + +/*! done transfer and will close it automaticly + * + * @param transfer the async transfer + * @param func the save func + * @param priv the func private data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_done(tb_async_transfer_ref_t transfer, tb_async_transfer_done_func_t func, tb_cpointer_t priv); + +/*! open and done transfer and will close it automaticly + * + * @code + * + static tb_bool_t tb_demo_transfer_done_func(tb_size_t state, tb_hize_t offset, tb_hong_t size, tb_hize_t save, tb_size_t rate, tb_cpointer_t priv) + { + // percent + tb_size_t percent = 0; + if (size > 0) percent = (offset * 100) / size; + else if (state == TB_STATE_OK) percent = 100; + + // trace + tb_trace_i("done: %llu bytes, rate: %lu bytes/s, percent: %lu%%, state: %s", save, rate, percent, tb_state_cstr(state)); + + // ok + return tb_true; + } + + // init transfer + tb_async_transfer_ref_t transfer = tb_async_transfer_init(tb_null); + if (transfer) + { + // init stream + tb_async_transfer_init_istream_from_url(transfer, url); + tb_async_transfer_init_ostream_from_data(transfer, data, size); + + // ctrl stream +// tb_async_transfer_ctrl_istream(transfer, TB_STREAM_CTRL_SET_TIMEOUT, 10000); + + // limit rate +// tb_async_transfer_limitrate(transfer, 256000); + + // open and done transfer + tb_async_transfer_open_done(transfer, 0, tb_demo_transfer_done_func, tb_null); + + // exit transfer + tb_async_transfer_exit(transfer); + } + * + * @endcode + * + * @param transfer the async transfer + * @param offset the start offset + * @param func the save func + * @param priv the func private data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_open_done(tb_async_transfer_ref_t transfer, tb_hize_t offset, tb_async_transfer_done_func_t func, tb_cpointer_t priv); + +/*! kill transfer + * + * @param transfer the async transfer + */ +tb_void_t tb_async_transfer_kill(tb_async_transfer_ref_t transfer); + +/*! exit transfer + * + * @note will wait transfer closed and cannot be called in the callback func + * + * @param transfer the async transfer + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_exit(tb_async_transfer_ref_t transfer); + +/*! pause transfer + * + * the save func state will return TB_STATE_PAUSED + * + * @param transfer the async transfer + */ +tb_void_t tb_async_transfer_pause(tb_async_transfer_ref_t transfer); + +/*! resume transfer + * + * @param transfer the async transfer + * + * @return tb_true or tb_false + */ +tb_bool_t tb_async_transfer_resume(tb_async_transfer_ref_t transfer); + +/*! limit transfer rate + * + * @param transfer the async transfer + * @param rate the trasfer rate and no limit if 0, bytes/s + */ +tb_void_t tb_async_transfer_limitrate(tb_async_transfer_ref_t transfer, tb_size_t rate); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/deprecated.h b/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/deprecated.h new file mode 100755 index 000000000..34ce8907c --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/deprecated.h @@ -0,0 +1,34 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file deprecated.h + * @ingroup stream + * + */ +#ifndef TB_STREAM_DEPRECATED_H +#define TB_STREAM_DEPRECATED_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "async_stream.h" +#include "transfer_pool.h" + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/prefix.h b/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/prefix.h new file mode 100755 index 000000000..ae5b9c40f --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/prefix.h @@ -0,0 +1,31 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * + */ +#ifndef TB_STREAM_DEPRECATED_PREFIX_H +#define TB_STREAM_DEPRECATED_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/transfer_pool.h b/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/transfer_pool.h new file mode 100755 index 000000000..d6e2d2e2c --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/stream/deprecated/transfer_pool.h @@ -0,0 +1,127 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file transfer_pool.h + * @ingroup stream + * + */ +#ifndef TB_STREAM_TRANSFER_POOL_H +#define TB_STREAM_TRANSFER_POOL_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include "../transfer.h" +#include "async_stream.h" +#include "async_transfer.h" +#include "../../asio/deprecated/asio.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +/// the transfer pool ref type +typedef __tb_typeref__(transfer_pool); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! the transfer pool instance + * + * @return the transfer pool instance + */ +tb_transfer_pool_ref_t tb_transfer_pool(tb_noarg_t); + +/*! init transfer pool + * + * @param aicp the aicp, using the default aicp if be null + * + * @return the transfer pool + */ +tb_transfer_pool_ref_t tb_transfer_pool_init(tb_aicp_ref_t aicp); + +/*! exit transfer pool + * + * @param pool the transfer pool + * + * @return tb_true or tb_false + */ +tb_bool_t tb_transfer_pool_exit(tb_transfer_pool_ref_t pool); + +/*! kill transfer pool + * + * @param pool the transfer pool + */ +tb_void_t tb_transfer_pool_kill(tb_transfer_pool_ref_t pool); + +/*! kill all working tasks + * + * @param pool the transfer pool handle + */ +tb_void_t tb_transfer_pool_kill_all(tb_transfer_pool_ref_t pool); + +/*! wait all working tasks + * + * @param pool the transfer pool handle + * @param timeout the timeout + * + * @return ok: 1, timeout: 0, error: -1 + */ +tb_long_t tb_transfer_pool_wait_all(tb_transfer_pool_ref_t pool, tb_long_t timeout); + +/*! the transfer pool size + * + * @param pool the transfer pool + */ +tb_size_t tb_transfer_pool_size(tb_transfer_pool_ref_t pool); + +/*! the transfer pool maxn + * + * @param pool the transfer pool + */ +tb_size_t tb_transfer_pool_maxn(tb_transfer_pool_ref_t pool); + +/*! done transfer from iurl to ourl + * + * @param pool the transfer pool + * @param iurl the input url + * @param ourl the output url + * @param offset the offset + * @param rate the limited rate, not limit if be zero + * @param done the done func + * @param ctrl the ctrl func + * @param priv the func private data + * + * @return tb_true or tb_false + */ +tb_bool_t tb_transfer_pool_done(tb_transfer_pool_ref_t pool, tb_char_t const* iurl, tb_char_t const* ourl, tb_hize_t offset, tb_size_t rate, tb_async_transfer_done_func_t done, tb_async_transfer_ctrl_func_t ctrl, tb_cpointer_t priv); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/filter.h b/core/pkg/tbox.pkg/inc/tbox/stream/filter.h index f6c1535e2..a159a1fcb 100755 --- a/core/pkg/tbox.pkg/inc/tbox/stream/filter.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/filter.h @@ -14,15 +14,15 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file filter.h * @defgroup stream * */ -#ifndef TB_STREAM_FILTER_H -#define TB_STREAM_FILTER_H +#ifndef TB_FILTER_H +#define TB_FILTER_H /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,8 +33,8 @@ * macros */ -/// the stream filter ctrl -#define TB_STREAM_FILTER_CTRL(type, ctrl) (((type) << 16) | (ctrl)) +/// the filter ctrl +#define TB_FILTER_CTRL(type, ctrl) (((type) << 16) | (ctrl)) /* ////////////////////////////////////////////////////////////////////////////////////// * extern @@ -46,35 +46,35 @@ __tb_extern_c_enter__ */ /// the filter type enum -typedef enum __tb_stream_filter_type_e +typedef enum __tb_filter_type_e { - TB_STREAM_FILTER_TYPE_NONE = 0 -, TB_STREAM_FILTER_TYPE_ZIP = 1 -, TB_STREAM_FILTER_TYPE_CACHE = 2 -, TB_STREAM_FILTER_TYPE_CHARSET = 3 -, TB_STREAM_FILTER_TYPE_CHUNKED = 4 + TB_FILTER_TYPE_NONE = 0 +, TB_FILTER_TYPE_ZIP = 1 +, TB_FILTER_TYPE_CACHE = 2 +, TB_FILTER_TYPE_CHARSET = 3 +, TB_FILTER_TYPE_CHUNKED = 4 -}tb_stream_filter_type_e; +}tb_filter_type_e; /// the filter ctrl enum -typedef enum __tb_stream_filter_ctrl_e +typedef enum __tb_filter_ctrl_e { - TB_STREAM_FILTER_CTRL_NONE = 0 + TB_FILTER_CTRL_NONE = 0 -, TB_STREAM_FILTER_CTRL_ZIP_GET_ALGO = TB_STREAM_FILTER_CTRL(TB_STREAM_FILTER_TYPE_ZIP, 1) -, TB_STREAM_FILTER_CTRL_ZIP_GET_ACTION = TB_STREAM_FILTER_CTRL(TB_STREAM_FILTER_TYPE_ZIP, 2) -, TB_STREAM_FILTER_CTRL_ZIP_SET_ALGO = TB_STREAM_FILTER_CTRL(TB_STREAM_FILTER_TYPE_ZIP, 3) -, TB_STREAM_FILTER_CTRL_ZIP_SET_ACTION = TB_STREAM_FILTER_CTRL(TB_STREAM_FILTER_TYPE_ZIP, 4) +, TB_FILTER_CTRL_ZIP_GET_ALGO = TB_FILTER_CTRL(TB_FILTER_TYPE_ZIP, 1) +, TB_FILTER_CTRL_ZIP_GET_ACTION = TB_FILTER_CTRL(TB_FILTER_TYPE_ZIP, 2) +, TB_FILTER_CTRL_ZIP_SET_ALGO = TB_FILTER_CTRL(TB_FILTER_TYPE_ZIP, 3) +, TB_FILTER_CTRL_ZIP_SET_ACTION = TB_FILTER_CTRL(TB_FILTER_TYPE_ZIP, 4) -, TB_STREAM_FILTER_CTRL_CHARSET_GET_FTYPE = TB_STREAM_FILTER_CTRL(TB_STREAM_FILTER_TYPE_CHARSET, 1) -, TB_STREAM_FILTER_CTRL_CHARSET_GET_TTYPE = TB_STREAM_FILTER_CTRL(TB_STREAM_FILTER_TYPE_CHARSET, 2) -, TB_STREAM_FILTER_CTRL_CHARSET_SET_FTYPE = TB_STREAM_FILTER_CTRL(TB_STREAM_FILTER_TYPE_CHARSET, 3) -, TB_STREAM_FILTER_CTRL_CHARSET_SET_TTYPE = TB_STREAM_FILTER_CTRL(TB_STREAM_FILTER_TYPE_CHARSET, 4) +, TB_FILTER_CTRL_CHARSET_GET_FTYPE = TB_FILTER_CTRL(TB_FILTER_TYPE_CHARSET, 1) +, TB_FILTER_CTRL_CHARSET_GET_TTYPE = TB_FILTER_CTRL(TB_FILTER_TYPE_CHARSET, 2) +, TB_FILTER_CTRL_CHARSET_SET_FTYPE = TB_FILTER_CTRL(TB_FILTER_TYPE_CHARSET, 3) +, TB_FILTER_CTRL_CHARSET_SET_TTYPE = TB_FILTER_CTRL(TB_FILTER_TYPE_CHARSET, 4) -}tb_stream_filter_ctrl_e; +}tb_filter_ctrl_e; -/// the stream filter ref type -typedef struct{}* tb_stream_filter_ref_t; +/// the filter ref type +typedef __tb_typeref__(filter); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces @@ -87,7 +87,7 @@ typedef struct{}* tb_stream_filter_ref_t; * * @return the filter */ -tb_stream_filter_ref_t tb_stream_filter_init_from_zip(tb_size_t algo, tb_size_t action); +tb_filter_ref_t tb_filter_init_from_zip(tb_size_t algo, tb_size_t action); /*! init filter from charset * @@ -96,7 +96,7 @@ tb_stream_filter_ref_t tb_stream_filter_init_from_zip(tb_size_t algo, tb_size_t * * @return the filter */ -tb_stream_filter_ref_t tb_stream_filter_init_from_charset(tb_size_t fr, tb_size_t to); +tb_filter_ref_t tb_filter_init_from_charset(tb_size_t fr, tb_size_t to); /*! init filter from chunked * @@ -104,7 +104,7 @@ tb_stream_filter_ref_t tb_stream_filter_init_from_charset(tb_size_t fr, tb_size * * @return the filter */ -tb_stream_filter_ref_t tb_stream_filter_init_from_chunked(tb_bool_t dechunked); +tb_filter_ref_t tb_filter_init_from_chunked(tb_bool_t dechunked); /*! init filter from cache * @@ -112,13 +112,13 @@ tb_stream_filter_ref_t tb_stream_filter_init_from_chunked(tb_bool_t dechunked); * * @return the filter */ -tb_stream_filter_ref_t tb_stream_filter_init_from_cache(tb_size_t size); +tb_filter_ref_t tb_filter_init_from_cache(tb_size_t size); /*! exit filter * * @param filter the filter */ -tb_void_t tb_stream_filter_exit(tb_stream_filter_ref_t filter); +tb_void_t tb_filter_exit(tb_filter_ref_t filter); /*! open filter * @@ -126,13 +126,13 @@ tb_void_t tb_stream_filter_exit(tb_stream_filter_ref_t filter); * * @return tb_true or tb_false */ -tb_bool_t tb_stream_filter_open(tb_stream_filter_ref_t filter); +tb_bool_t tb_filter_open(tb_filter_ref_t filter); /*! clos filter * * @param filter the filter */ -tb_void_t tb_stream_filter_clos(tb_stream_filter_ref_t filter); +tb_void_t tb_filter_clos(tb_filter_ref_t filter); /*! ctrl filter * @@ -141,7 +141,7 @@ tb_void_t tb_stream_filter_clos(tb_stream_filter_ref_t filter); * * @return tb_true or tb_false */ -tb_bool_t tb_stream_filter_ctrl(tb_stream_filter_ref_t filter, tb_size_t ctrl, ...); +tb_bool_t tb_filter_ctrl(tb_filter_ref_t filter, tb_size_t ctrl, ...); /*! is eof for the filter input data, but the output maybe exists the left data and need flush it * @@ -149,14 +149,14 @@ tb_bool_t tb_stream_filter_ctrl(tb_stream_filter_ref_t filter, tb_ * * @return tb_true or tb_false */ -tb_bool_t tb_stream_filter_beof(tb_stream_filter_ref_t filter); +tb_bool_t tb_filter_beof(tb_filter_ref_t filter); /*! limit the input size for filter * * @param filter the filter * @param limit the input limit size */ -tb_void_t tb_stream_filter_limit(tb_stream_filter_ref_t filter, tb_hong_t limit); +tb_void_t tb_filter_limit(tb_filter_ref_t filter, tb_hong_t limit); /*! push data to the filter input data * @@ -164,7 +164,7 @@ tb_void_t tb_stream_filter_limit(tb_stream_filter_ref_t filter, tb * * @return tb_true or tb_false */ -tb_bool_t tb_stream_filter_push(tb_stream_filter_ref_t filter, tb_byte_t const* data, tb_size_t size); +tb_bool_t tb_filter_push(tb_filter_ref_t filter, tb_byte_t const* data, tb_size_t size); /*! spak filter * @@ -177,7 +177,7 @@ tb_bool_t tb_stream_filter_push(tb_stream_filter_ref_t filter, tb_ * * @return > 0: the output size, 0: continue, -1: end */ -tb_long_t tb_stream_filter_spak(tb_stream_filter_ref_t filter, tb_byte_t const* data, tb_size_t size, tb_byte_t const** pdata, tb_size_t need, tb_long_t sync); +tb_long_t tb_filter_spak(tb_filter_ref_t filter, tb_byte_t const* data, tb_size_t size, tb_byte_t const** pdata, tb_size_t need, tb_long_t sync); /* ////////////////////////////////////////////////////////////////////////////////////// diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/prefix.h b/core/pkg/tbox.pkg/inc/tbox/stream/prefix.h index f2e4b50d7..1dacae133 100755 --- a/core/pkg/tbox.pkg/inc/tbox/stream/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h @@ -29,8 +29,8 @@ #include "../prefix.h" #include "../libc/libc.h" #include "../network/url.h" -#include "../asio/asio.h" #include "../memory/memory.h" +#include "../platform/socket.h" /* ////////////////////////////////////////////////////////////////////////////////////// * macros @@ -51,8 +51,8 @@ typedef enum __tb_stream_mode_e { TB_STREAM_MODE_NONE = 0 -, TB_STREAM_MODE_AIOO = 1 ///!< for bstream -, TB_STREAM_MODE_AICO = 2 ///!< for astream +, TB_STREAM_MODE_AIOO = 1 ///!< for stream +, TB_STREAM_MODE_AICO = 2 ///!< for async_stream }tb_stream_mode_e; @@ -72,10 +72,10 @@ typedef enum __tb_stream_type_e /// the stream wait enum typedef enum __tb_stream_wait_e { - TB_STREAM_WAIT_NONE = TB_AIOE_CODE_NONE -, TB_STREAM_WAIT_READ = TB_AIOE_CODE_RECV -, TB_STREAM_WAIT_WRIT = TB_AIOE_CODE_SEND -, TB_STREAM_WAIT_EALL = TB_AIOE_CODE_EALL + TB_STREAM_WAIT_NONE = TB_SOCKET_EVENT_NONE +, TB_STREAM_WAIT_READ = TB_SOCKET_EVENT_RECV +, TB_STREAM_WAIT_WRIT = TB_SOCKET_EVENT_SEND +, TB_STREAM_WAIT_EALL = TB_SOCKET_EVENT_EALL }tb_stream_wait_e; diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/static_stream.h b/core/pkg/tbox.pkg/inc/tbox/stream/static_stream.h index 3cead8dc0..68c304025 100755 --- a/core/pkg/tbox.pkg/inc/tbox/stream/static_stream.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/static_stream.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file static_stream.h diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/stream.h b/core/pkg/tbox.pkg/inc/tbox/stream/stream.h index 10a906c73..3c80b5f10 100755 --- a/core/pkg/tbox.pkg/inc/tbox/stream/stream.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/stream.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file stream.h @@ -28,58 +28,34 @@ * includes */ #include "prefix.h" -#include "async_stream.h" -#include "static_stream.h" -#include "transfer.h" -#include "transfer_pool.h" #include "filter.h" +#include "transfer.h" +#include "static_stream.h" +#ifdef TB_CONFIG_API_HAVE_DEPRECATED +# include "deprecated/deprecated.h" +#endif /*!architecture * * * <pre> - * wait - loop - * | - * | - data - * [aioo] | - * ----- stream -------- stream ----------------------- file - * | | | - * | | - sock - * | | | - * | | - http - * | | - charset - * | | | - * | - filter - |- chunked - * transfer --------- | | - * | |- cache - * | | - * | - zip - * | - * ----- stream + * + * - data + * | + * stream --------------------- - file + * | | + * | - sock + * | | + * | - http + * | - charset + * | | + * - filter - |- chunked + * | + * |- cache + * | + * - zip + * * - * - loop - * [asio] | - * aicp -| loop - * | | - * | - ... - data - * [aico] | - * -------------------- async_stream -------- async_stream ------------ file - * | | | - * | | - sock - * ---------------- | | - * | | - http - * ----- transfer | - charset - * | | | | - * | ---------------- - filter - |- chunked - * | | | | - * transfer_pool ----- transfer | | |- cache - * | | | | - * | | | - zip - * | | | - * ----- ... | | - * | static_stream - [data, size] - * | - * -------------------- async_stream * url: * data://base64 * file://path or unix path: e.g. /root/xxxx/file diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/transfer.h b/core/pkg/tbox.pkg/inc/tbox/stream/transfer.h index f82a23308..01c8eb3b6 100755 --- a/core/pkg/tbox.pkg/inc/tbox/stream/transfer.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/transfer.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file transfer.h @@ -28,8 +28,6 @@ * includes */ #include "prefix.h" -#include "async_stream.h" -#include "async_transfer.h" /* ////////////////////////////////////////////////////////////////////////////////////// * extern @@ -40,7 +38,7 @@ __tb_extern_c_enter__ * types */ -/*! the basic transfer done func type +/*! the transfer func type * * @param state the stream state * @param offset the istream offset @@ -51,13 +49,13 @@ __tb_extern_c_enter__ * * @return tb_true: ok and continue it if need, tb_false: break it */ -typedef tb_bool_t (*tb_transfer_done_func_t)(tb_size_t state, tb_hize_t offset, tb_hong_t size, tb_hize_t save, tb_size_t rate, tb_cpointer_t priv); +typedef tb_bool_t (*tb_transfer_func_t)(tb_size_t state, tb_hize_t offset, tb_hong_t size, tb_hize_t save, tb_size_t rate, tb_cpointer_t priv); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces */ -/*! done transfer from stream to stream +/*! transfer stream to stream * * @param istream the istream * @param ostream the ostream @@ -67,9 +65,9 @@ typedef tb_bool_t (*tb_transfer_done_func_t)(tb_size_t state, tb_hize_t offset * * @return the saved size, failed: -1 */ -tb_hong_t tb_transfer_done(tb_stream_ref_t istream, tb_stream_ref_t ostream, tb_size_t lrate, tb_transfer_done_func_t func, tb_cpointer_t priv); +tb_hong_t tb_transfer(tb_stream_ref_t istream, tb_stream_ref_t ostream, tb_size_t lrate, tb_transfer_func_t func, tb_cpointer_t priv); -/*! done transfer from stream to url +/*! transfer stream to url * * @param istream the istream * @param ourl the output url @@ -79,9 +77,9 @@ tb_hong_t tb_transfer_done(tb_stream_ref_t istream, tb_stream_ref_t os * * @return the saved size, failed: -1 */ -tb_hong_t tb_transfer_done_to_url(tb_stream_ref_t istream, tb_char_t const* ourl, tb_size_t lrate, tb_transfer_done_func_t func, tb_cpointer_t priv); +tb_hong_t tb_transfer_to_url(tb_stream_ref_t istream, tb_char_t const* ourl, tb_size_t lrate, tb_transfer_func_t func, tb_cpointer_t priv); -/*! done transfer from stream to data +/*! transfer stream to data * * @param istream the istream * @param odata the output data @@ -92,9 +90,9 @@ tb_hong_t tb_transfer_done_to_url(tb_stream_ref_t istream, tb_char_t c * * @return the saved size, failed: -1 */ -tb_hong_t tb_transfer_done_to_data(tb_stream_ref_t istream, tb_byte_t* odata, tb_size_t osize, tb_size_t lrate, tb_transfer_done_func_t func, tb_cpointer_t priv); +tb_hong_t tb_transfer_to_data(tb_stream_ref_t istream, tb_byte_t* odata, tb_size_t osize, tb_size_t lrate, tb_transfer_func_t func, tb_cpointer_t priv); -/*! done transfer from url to url +/*! transfer url to url * * @param iurl the input url * @param ourl the output url @@ -104,9 +102,9 @@ tb_hong_t tb_transfer_done_to_data(tb_stream_ref_t istream, tb_byte_t* * * @return the saved size, failed: -1 */ -tb_hong_t tb_transfer_done_url(tb_char_t const* iurl, tb_char_t const* ourl, tb_size_t lrate, tb_transfer_done_func_t func, tb_cpointer_t priv); +tb_hong_t tb_transfer_url(tb_char_t const* iurl, tb_char_t const* ourl, tb_size_t lrate, tb_transfer_func_t func, tb_cpointer_t priv); -/*! done transfer from url to stream +/*! transfer url to stream * * @param iurl the input url * @param ostream the ostream @@ -116,9 +114,9 @@ tb_hong_t tb_transfer_done_url(tb_char_t const* iurl, tb_char_t const* * * @return the saved size, failed: -1 */ -tb_hong_t tb_transfer_done_url_to_stream(tb_char_t const* iurl, tb_stream_ref_t ostream, tb_size_t lrate, tb_transfer_done_func_t func, tb_cpointer_t priv); +tb_hong_t tb_transfer_url_to_stream(tb_char_t const* iurl, tb_stream_ref_t ostream, tb_size_t lrate, tb_transfer_func_t func, tb_cpointer_t priv); -/*! done transfer from url to data +/*! transfer url to data * * @param iurl the input url * @param odata the output data @@ -129,9 +127,9 @@ tb_hong_t tb_transfer_done_url_to_stream(tb_char_t const* iurl, tb_str * * @return the saved size, failed: -1 */ -tb_hong_t tb_transfer_done_url_to_data(tb_char_t const* iurl, tb_byte_t* odata, tb_size_t osize, tb_size_t lrate, tb_transfer_done_func_t func, tb_cpointer_t priv); +tb_hong_t tb_transfer_url_to_data(tb_char_t const* iurl, tb_byte_t* odata, tb_size_t osize, tb_size_t lrate, tb_transfer_func_t func, tb_cpointer_t priv); -/*! done transfer from data to url +/*! transfer data to url * * @param idata the input data * @param isize the input size @@ -142,9 +140,9 @@ tb_hong_t tb_transfer_done_url_to_data(tb_char_t const* iurl, tb_byte_ * * @return the saved size, failed: -1 */ -tb_hong_t tb_transfer_done_data_to_url(tb_byte_t const* idata, tb_size_t isize, tb_char_t const* ourl, tb_size_t lrate, tb_transfer_done_func_t func, tb_cpointer_t priv); +tb_hong_t tb_transfer_data_to_url(tb_byte_t const* idata, tb_size_t isize, tb_char_t const* ourl, tb_size_t lrate, tb_transfer_func_t func, tb_cpointer_t priv); -/*! done transfer from data to stream +/*! transfer data to stream * * @param idata the input data * @param isize the input size @@ -155,7 +153,7 @@ tb_hong_t tb_transfer_done_data_to_url(tb_byte_t const* idata, tb_size * * @return the saved size, failed: -1 */ -tb_hong_t tb_transfer_done_data_to_stream(tb_byte_t const* idata, tb_size_t isize, tb_stream_ref_t ostream, tb_size_t lrate, tb_transfer_done_func_t func, tb_cpointer_t priv); +tb_hong_t tb_transfer_data_to_stream(tb_byte_t const* idata, tb_size_t isize, tb_stream_ref_t ostream, tb_size_t lrate, tb_transfer_func_t func, tb_cpointer_t priv); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/string/prefix.h b/core/pkg/tbox.pkg/inc/tbox/string/prefix.h index baa78f413..198300564 100755 --- a/core/pkg/tbox.pkg/inc/tbox/string/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/string/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/string/static_string.h b/core/pkg/tbox.pkg/inc/tbox/string/static_string.h index 8f97aeacb..bd53dff5b 100755 --- a/core/pkg/tbox.pkg/inc/tbox/string/static_string.h +++ b/core/pkg/tbox.pkg/inc/tbox/string/static_string.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file static_string.h diff --git a/core/pkg/tbox.pkg/inc/tbox/string/string.h b/core/pkg/tbox.pkg/inc/tbox/string/string.h index f59bb04ae..b3087d116 100755 --- a/core/pkg/tbox.pkg/inc/tbox/string/string.h +++ b/core/pkg/tbox.pkg/inc/tbox/string/string.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file string.h diff --git a/core/pkg/tbox.pkg/inc/tbox/tbox.h b/core/pkg/tbox.pkg/inc/tbox/tbox.h index 76a64b0ff..b786487e8 100755 --- a/core/pkg/tbox.pkg/inc/tbox/tbox.h +++ b/core/pkg/tbox.pkg/inc/tbox/tbox.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file tbox.h @@ -46,6 +46,7 @@ #include "database/database.h" #include "algorithm/algorithm.h" #include "container/container.h" +#include "coroutine/coroutine.h" /* ////////////////////////////////////////////////////////////////////////////////////// * extern @@ -121,21 +122,12 @@ __tb_extern_c_enter__ if (stream) { // save stream data to file - tb_transfer_done_to_url(stream, "/home/file/index.html", 0, tb_null, tb_null); + tb_transfer_to_url(stream, "/home/file/index.html", 0, tb_null, tb_null); // exit stream tb_stream_exit(stream); } - // block: save http to file - tb_transfer_done_url("http://www.xxxx.com/index.html", "/home/file/index.html", 0, tb_null, tb_null); - - // async: save http to file - tb_transfer_pool_done(tb_transfer_pool(), "http://www.xxxx.com/index0.html", "/home/file/index0.html", 0, 0, tb_null, tb_null); - tb_transfer_pool_done(tb_transfer_pool(), "http://www.xxxx.com/index1.html", "/home/file/index2.html", 0, 0, tb_null, tb_null); - tb_transfer_pool_done(tb_transfer_pool(), "http://www.xxxx.com/index2.html", "/home/file/index3.html", 0, 0, tb_null, tb_null); - tb_transfer_pool_done(tb_transfer_pool(), "http://www.xxxx.com/index3.html", "/home/file/index4.html", 0, 0, tb_null, tb_null); - // ... // exit tbox diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/base32.h b/core/pkg/tbox.pkg/inc/tbox/utils/base32.h index 912139a89..9801ac5b5 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/base32.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/base32.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file base32.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/base64.h b/core/pkg/tbox.pkg/inc/tbox/utils/base64.h index 957dd0910..e4e4216e9 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/base64.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/base64.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file base.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/bits.h b/core/pkg/tbox.pkg/inc/tbox/utils/bits.h index cdc05ad66..d5f97adff 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/bits.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/bits.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file bits.h @@ -50,6 +50,12 @@ __tb_extern_c_enter__ * macros */ +/* TODO + * + * check TB_UNALIGNED_ACCESS_ENABLE for compiler + */ +//#define TB_UNALIGNED_ACCESS_ENABLE + // 1-bits #define tb_bits_get_u1(p) (((*(p)) >> 7) & 1) #define tb_bits_set_u1(p, x) do { *(p) &= 0x7f; *(p) |= (((x) & 0x1) << 7); } while (0) @@ -180,7 +186,7 @@ __tb_extern_c_enter__ # endif #endif -#ifdef TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE +#ifdef TB_UNALIGNED_ACCESS_ENABLE # ifdef TB_WORDS_BIGENDIAN // 16-bits @@ -320,7 +326,7 @@ __tb_extern_c_enter__ # define tb_bits_set_u64_be(p, x) tb_bits_set_u64_be_impl((tb_byte_t*)(p), x) # define tb_bits_set_s64_be(p, x) tb_bits_set_s64_be_impl((tb_byte_t*)(p), x) -#endif /* TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE */ +#endif /* TB_UNALIGNED_ACCESS_ENABLE */ #ifdef TB_WORDS_BIGENDIAN # define tb_bits_get_u16_ne(p) tb_bits_get_u16_be(p) @@ -805,7 +811,7 @@ static __tb_inline__ tb_size_t tb_bits_cb1_u64_inline(tb_uint64_t x) */ static __tb_inline__ tb_float_t tb_bits_get_float_le_inline(tb_byte_t const* p) { -#if defined(TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE) \ +#if defined(TB_UNALIGNED_ACCESS_ENABLE) \ && !defined(TB_WORDS_BIGENDIAN) return *((tb_float_t*)p); #else @@ -816,7 +822,7 @@ static __tb_inline__ tb_float_t tb_bits_get_float_le_inline(tb_byte_t const* p) } static __tb_inline__ tb_float_t tb_bits_get_float_be_inline(tb_byte_t const* p) { -#if defined(TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE) \ +#if defined(TB_UNALIGNED_ACCESS_ENABLE) \ && defined(TB_WORDS_BIGENDIAN) return *((tb_float_t*)p); #else @@ -827,7 +833,7 @@ static __tb_inline__ tb_float_t tb_bits_get_float_be_inline(tb_byte_t const* p) } static __tb_inline__ tb_void_t tb_bits_set_float_le_inline(tb_byte_t* p, tb_float_t x) { -#if defined(TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE) \ +#if defined(TB_UNALIGNED_ACCESS_ENABLE) \ && !defined(TB_WORDS_BIGENDIAN) *((tb_float_t*)p) = x; #else @@ -838,7 +844,7 @@ static __tb_inline__ tb_void_t tb_bits_set_float_le_inline(tb_byte_t* p, tb_floa } static __tb_inline__ tb_void_t tb_bits_set_float_be_inline(tb_byte_t* p, tb_float_t x) { -#if defined(TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE) \ +#if defined(TB_UNALIGNED_ACCESS_ENABLE) \ && defined(TB_WORDS_BIGENDIAN) *((tb_float_t*)p) = x; #else @@ -852,7 +858,7 @@ static __tb_inline__ tb_void_t tb_bits_set_float_be_inline(tb_byte_t* p, tb_floa */ static __tb_inline__ tb_double_t tb_bits_get_double_bbe_inline(tb_byte_t const* p) { -#if defined(TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE) \ +#if defined(TB_UNALIGNED_ACCESS_ENABLE) \ && defined(TB_FLOAT_BIGENDIAN) \ && defined(TB_WORDS_BIGENDIAN) return *((tb_double_t*)p); @@ -872,7 +878,7 @@ static __tb_inline__ tb_double_t tb_bits_get_double_bbe_inline(tb_byte_t const* } static __tb_inline__ tb_double_t tb_bits_get_double_ble_inline(tb_byte_t const* p) { -#if defined(TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE) \ +#if defined(TB_UNALIGNED_ACCESS_ENABLE) \ && defined(TB_FLOAT_BIGENDIAN) \ && !defined(TB_WORDS_BIGENDIAN) return *((tb_double_t*)p); @@ -893,7 +899,7 @@ static __tb_inline__ tb_double_t tb_bits_get_double_ble_inline(tb_byte_t const* } static __tb_inline__ tb_double_t tb_bits_get_double_lbe_inline(tb_byte_t const* p) { -#if defined(TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE) \ +#if defined(TB_UNALIGNED_ACCESS_ENABLE) \ && !defined(TB_FLOAT_BIGENDIAN) \ && defined(TB_WORDS_BIGENDIAN) return *((tb_double_t*)p); @@ -913,7 +919,7 @@ static __tb_inline__ tb_double_t tb_bits_get_double_lbe_inline(tb_byte_t const* } static __tb_inline__ tb_double_t tb_bits_get_double_lle_inline(tb_byte_t const* p) { -#if defined(TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE) \ +#if defined(TB_UNALIGNED_ACCESS_ENABLE) \ && !defined(TB_FLOAT_BIGENDIAN) \ && !defined(TB_WORDS_BIGENDIAN) return *((tb_double_t*)p); @@ -934,7 +940,7 @@ static __tb_inline__ tb_double_t tb_bits_get_double_lle_inline(tb_byte_t const* // 7 6 5 4 3 2 1 0 static __tb_inline__ tb_void_t tb_bits_set_double_bbe_inline(tb_byte_t* p, tb_double_t x) { -#if defined(TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE) \ +#if defined(TB_UNALIGNED_ACCESS_ENABLE) \ && defined(TB_FLOAT_BIGENDIAN) \ && defined(TB_WORDS_BIGENDIAN) *((tb_double_t*)p) = x; @@ -956,7 +962,7 @@ static __tb_inline__ tb_void_t tb_bits_set_double_bbe_inline(tb_byte_t* p, tb_do // 4 5 6 7 0 1 2 3 static __tb_inline__ tb_void_t tb_bits_set_double_ble_inline(tb_byte_t* p, tb_double_t x) { -#if defined(TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE) \ +#if defined(TB_UNALIGNED_ACCESS_ENABLE) \ && defined(TB_FLOAT_BIGENDIAN) \ && !defined(TB_WORDS_BIGENDIAN) *((tb_double_t*)p) = x; @@ -978,7 +984,7 @@ static __tb_inline__ tb_void_t tb_bits_set_double_ble_inline(tb_byte_t* p, tb_do // 3 2 1 0 7 6 5 4 static __tb_inline__ tb_void_t tb_bits_set_double_lbe_inline(tb_byte_t* p, tb_double_t x) { -#if defined(TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE) \ +#if defined(TB_UNALIGNED_ACCESS_ENABLE) \ && !defined(TB_FLOAT_BIGENDIAN) \ && defined(TB_WORDS_BIGENDIAN) *((tb_double_t*)p) = x; @@ -1000,7 +1006,7 @@ static __tb_inline__ tb_void_t tb_bits_set_double_lbe_inline(tb_byte_t* p, tb_do // 0 1 2 3 4 5 6 7 static __tb_inline__ tb_void_t tb_bits_set_double_lle_inline(tb_byte_t* p, tb_double_t x) { -#if defined(TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE) \ +#if defined(TB_UNALIGNED_ACCESS_ENABLE) \ && !defined(TB_FLOAT_BIGENDIAN) \ && !defined(TB_WORDS_BIGENDIAN) *((tb_double_t*)p) = x; diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/dump.h b/core/pkg/tbox.pkg/inc/tbox/utils/dump.h index 07f254673..b0b61ce0a 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/dump.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/dump.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file dump.h @@ -45,18 +45,6 @@ __tb_extern_c_enter__ */ tb_void_t tb_dump_data(tb_byte_t const* data, tb_size_t size); -/*! dump data from url - * - * @param url the url - */ -tb_void_t tb_dump_data_from_url(tb_char_t const* url); - -/*! dump data from stream - * - * @param stream the stream - */ -tb_void_t tb_dump_data_from_stream(tb_stream_ref_t stream); - /* ////////////////////////////////////////////////////////////////////////////////////// * extern */ diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_arm.h b/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_arm.h index 988e2a311..5fbfe01dd 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_arm.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_arm.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file bits_arm.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_gcc.h b/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_gcc.h index 70df7ae14..df853e693 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_gcc.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_gcc.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file bits_gcc.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_sh4.h b/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_sh4.h index d73418104..9faaa400e 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_sh4.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_sh4.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file bits_sh4.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_x86.h b/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_x86.h index 2eef8b0fd..76fc8010f 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_x86.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_x86.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file bits_x86.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/impl/impl.h b/core/pkg/tbox.pkg/inc/tbox/utils/impl/impl.h new file mode 100755 index 000000000..ca3af8d38 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/utils/impl/impl.h @@ -0,0 +1,32 @@ +/*!The Treasure Box Library + * + * TBox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * TBox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TBox; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2017, ruki All rights reserved. + * + * @author ruki + * @file impl.h + * + */ +#ifndef TB_UTILS_IMPL_H +#define TB_UTILS_IMPL_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "singleton.h" + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/impl/prefix.h b/core/pkg/tbox.pkg/inc/tbox/utils/impl/prefix.h index 0f32a6b68..6fc6fefb2 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/impl/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/impl/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/lock_profiler.h b/core/pkg/tbox.pkg/inc/tbox/utils/lock_profiler.h index 657d5ee31..6026120f7 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/lock_profiler.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/lock_profiler.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file lock_profiler.h @@ -40,7 +40,7 @@ __tb_extern_c_enter__ // enable lock profiler #undef TB_LOCK_PROFILER_ENABLE -#ifdef __tb_debug__ +#if defined(__tb_debug__) && !defined(TB_CONFIG_MICRO_ENABLE) # define TB_LOCK_PROFILER_ENABLE #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/option.h b/core/pkg/tbox.pkg/inc/tbox/utils/option.h index f1c67cc5e..94b63c59c 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/option.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/option.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file option.h @@ -81,7 +81,7 @@ typedef struct __tb_option_item_t }tb_option_item_t; /// the option ref type -typedef struct{}* tb_option_ref_t; +typedef __tb_typeref__(option); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/prefix.h b/core/pkg/tbox.pkg/inc/tbox/utils/prefix.h index c9bbc618f..06423fd41 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/singleton.h b/core/pkg/tbox.pkg/inc/tbox/utils/singleton.h index 883da67f5..2ea322642 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/singleton.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/singleton.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file singleton.h @@ -47,6 +47,13 @@ typedef enum __tb_singleton_type_e /// the static allocator , TB_SINGLETON_TYPE_STATIC_ALLOCATOR = 1 +#ifdef TB_CONFIG_MICRO_ENABLE + + /// the user defined type +, TB_SINGLETON_TYPE_USER = 2 + +#else + /// the lock profiler type , TB_SINGLETON_TYPE_LOCK_PROFILER = 2 @@ -59,7 +66,7 @@ typedef enum __tb_singleton_type_e /// the ltimer type , TB_SINGLETON_TYPE_LTIMER = 5 - /// the aicp type + /// the aicp type, TODO deprecated , TB_SINGLETON_TYPE_AICP = 6 /// the openssl library type @@ -83,11 +90,15 @@ typedef enum __tb_singleton_type_e /// the user defined type , TB_SINGLETON_TYPE_USER = 13 +#endif + /// the max count of the singleton type -#ifdef __tb_small__ -, TB_SINGLETON_TYPE_MAXN = 32 +#if defined(TB_CONFIG_MICRO_ENABLE) +, TB_SINGLETON_TYPE_MAXN = TB_SINGLETON_TYPE_USER + 2 +#elif defined(__tb_small__) +, TB_SINGLETON_TYPE_MAXN = TB_SINGLETON_TYPE_USER + 8 #else -, TB_SINGLETON_TYPE_MAXN = 128 +, TB_SINGLETON_TYPE_MAXN = TB_SINGLETON_TYPE_USER + 64 #endif }tb_singleton_type_e; diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/trace.h b/core/pkg/tbox.pkg/inc/tbox/utils/trace.h index ffdd0efd3..133d8c8c2 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/trace.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/trace.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file trace.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/url.h b/core/pkg/tbox.pkg/inc/tbox/utils/url.h index e8b671152..038dec828 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/url.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/url.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file url.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/used.h b/core/pkg/tbox.pkg/inc/tbox/utils/used.h index 624ce2acd..c5be23f27 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/used.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/used.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file used.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/utils.h b/core/pkg/tbox.pkg/inc/tbox/utils/utils.h index 88afb3b5c..3a72be29e 100755 --- a/core/pkg/tbox.pkg/inc/tbox/utils/utils.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/utils.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file utils.h diff --git a/core/pkg/tbox.pkg/inc/tbox/xml/node.h b/core/pkg/tbox.pkg/inc/tbox/xml/node.h index 23da09d11..d787a5020 100755 --- a/core/pkg/tbox.pkg/inc/tbox/xml/node.h +++ b/core/pkg/tbox.pkg/inc/tbox/xml/node.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file node.h diff --git a/core/pkg/tbox.pkg/inc/tbox/xml/prefix.h b/core/pkg/tbox.pkg/inc/tbox/xml/prefix.h index eddf8bca1..bae29dfc4 100755 --- a/core/pkg/tbox.pkg/inc/tbox/xml/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/xml/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/xml/reader.h b/core/pkg/tbox.pkg/inc/tbox/xml/reader.h index 1f6dd84f2..7ca599237 100755 --- a/core/pkg/tbox.pkg/inc/tbox/xml/reader.h +++ b/core/pkg/tbox.pkg/inc/tbox/xml/reader.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file reader.h @@ -55,7 +55,7 @@ typedef enum __tb_xml_reader_event_t }tb_xml_reader_event_t; /// the xml reader ref type -typedef struct{}* tb_xml_reader_ref_t; +typedef __tb_typeref__(xml_reader); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces diff --git a/core/pkg/tbox.pkg/inc/tbox/xml/writer.h b/core/pkg/tbox.pkg/inc/tbox/xml/writer.h index 8541ba03e..11c8129b8 100755 --- a/core/pkg/tbox.pkg/inc/tbox/xml/writer.h +++ b/core/pkg/tbox.pkg/inc/tbox/xml/writer.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file writer.h @@ -40,7 +40,7 @@ __tb_extern_c_enter__ */ /// the xml writer ref type -typedef struct{}* tb_xml_writer_ref_t; +typedef __tb_typeref__(xml_writer); /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces diff --git a/core/pkg/tbox.pkg/inc/tbox/xml/xml.h b/core/pkg/tbox.pkg/inc/tbox/xml/xml.h index 4c0214775..db247bae8 100755 --- a/core/pkg/tbox.pkg/inc/tbox/xml/xml.h +++ b/core/pkg/tbox.pkg/inc/tbox/xml/xml.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file xml.h diff --git a/core/pkg/tbox.pkg/inc/tbox/zip/gzip.h b/core/pkg/tbox.pkg/inc/tbox/zip/gzip.h index e614e1a5f..8afea8111 100755 --- a/core/pkg/tbox.pkg/inc/tbox/zip/gzip.h +++ b/core/pkg/tbox.pkg/inc/tbox/zip/gzip.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file gzip.h diff --git a/core/pkg/tbox.pkg/inc/tbox/zip/prefix.h b/core/pkg/tbox.pkg/inc/tbox/zip/prefix.h index 76f5d0884..36eb931c3 100755 --- a/core/pkg/tbox.pkg/inc/tbox/zip/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/zip/prefix.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/zip/zip.h b/core/pkg/tbox.pkg/inc/tbox/zip/zip.h index 04d8a145a..5c9b95018 100755 --- a/core/pkg/tbox.pkg/inc/tbox/zip/zip.h +++ b/core/pkg/tbox.pkg/inc/tbox/zip/zip.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file zip.h diff --git a/core/pkg/tbox.pkg/inc/tbox/zip/zlib.h b/core/pkg/tbox.pkg/inc/tbox/zip/zlib.h index f6b2ae730..1a0ad54e6 100755 --- a/core/pkg/tbox.pkg/inc/tbox/zip/zlib.h +++ b/core/pkg/tbox.pkg/inc/tbox/zip/zlib.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file zlib.h diff --git a/core/pkg/tbox.pkg/inc/tbox/zip/zlibraw.h b/core/pkg/tbox.pkg/inc/tbox/zip/zlibraw.h index 805f7c50b..324950047 100755 --- a/core/pkg/tbox.pkg/inc/tbox/zip/zlibraw.h +++ b/core/pkg/tbox.pkg/inc/tbox/zip/zlibraw.h @@ -14,7 +14,7 @@ * along with TBox; * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> * - * Copyright (C) 2009 - 2015, ruki All rights reserved. + * Copyright (C) 2009 - 2017, ruki All rights reserved. * * @author ruki * @file zlibraw.h diff --git a/core/pkg/tbox.pkg/xmake.lua b/core/pkg/tbox.pkg/xmake.lua index b71bbe659..b946b73b2 100644 --- a/core/pkg/tbox.pkg/xmake.lua +++ b/core/pkg/tbox.pkg/xmake.lua @@ -1,4 +1,5 @@ --- add tbox package + +-- the tbox package option("tbox") -- show menu @@ -20,11 +21,10 @@ option("tbox") add_links("tbox") -- add link directories - add_linkdirs("lib/$(plat)/$(arch)") + add_linkdirs("lib/$(mode)/$(plat)/$(arch)") -- add c includes for checking add_cincludes("tbox/tbox.h") -- add include directories - add_includedirs("inc/$(plat)/$(arch)", "inc") - + add_includedirs("inc/$(plat)", "inc") |
