diff options
| author | ruki <[email protected]> | 2015-07-02 14:54:00 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-07-02 14:54:00 +0800 |
| commit | f69c00a7ddcb835fe52169fa9b7e097680fba5c1 (patch) | |
| tree | fdbe29e9037607dd09335a117c730cc3f07a04d1 | |
| parent | c6cc4e543cbfc3e23761ebb4cc0f825055928ed2 (diff) | |
update tbox and fix copy file bug
318 files changed, 1907 insertions, 2086 deletions
diff --git a/core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h b/core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h index 72c9c14e9..4d34a7622 100644..100755 --- a/core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h +++ b/core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h @@ -1,97 +1,82 @@ #ifndef TB_CONFIG_H #define TB_CONFIG_H -// packages - #define TB_CONFIG_PACKAGE_HAVE_BASE +// version +#define TB_CONFIG_VERSION "1.5.0" +#define TB_CONFIG_VERSION_MAJOR 1 +#define TB_CONFIG_VERSION_MINOR 5 +#define TB_CONFIG_VERSION_ALTER 0 +#define TB_CONFIG_VERSION_BUILD 201507021420 -// major version -#define TB_CONFIG_VERSION_MAJOR 1 - -// minor version -#define TB_CONFIG_VERSION_MINOR 4 - -// alter version -#define TB_CONFIG_VERSION_ALTER 8 - -// build version -#define TB_CONFIG_VERSION_BUILD 201505251325 - -// small -#define TB_CONFIG_SMALL (0) - -// os -#define TB_CONFIG_OS_MAC -#define TB_CONFIG_OS_LIKE_UNIX - -// api -#define TB_CONFIG_API_HAVE_POSIX -#define TB_CONFIG_API_HAVE_SYSTEMV - -// type -#define TB_CONFIG_TYPE_FLOAT - -// memory -//#define TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE - -// trace -//#define TB_CONFIG_TRACE_INFO_ONLY - -// exception -#define TB_CONFIG_EXCEPTION_ENABLE - -// libc +// defines +#define TB_CONFIG_OS_MACOSX +#define TB_CONFIG_TYPE_HAVE_FLOAT +#define TB_CONFIG_MODULE_HAVE_XML +#define TB_CONFIG_MODULE_HAVE_ZIP +#define TB_CONFIG_MODULE_HAVE_ASIO +#define TB_CONFIG_MODULE_HAVE_OBJECT +#define TB_CONFIG_MODULE_HAVE_CHARSET +#define TB_CONFIG_MODULE_HAVE_DATABASE #define TB_CONFIG_LIBC_HAVE_MEMCPY #define TB_CONFIG_LIBC_HAVE_MEMSET -#define TB_CONFIG_LIBC_HAVE_MEMMOV +#define TB_CONFIG_LIBC_HAVE_MEMMOVE #define TB_CONFIG_LIBC_HAVE_MEMCMP #define TB_CONFIG_LIBC_HAVE_STRCAT #define TB_CONFIG_LIBC_HAVE_STRNCAT #define TB_CONFIG_LIBC_HAVE_STRCPY #define TB_CONFIG_LIBC_HAVE_STRNCPY -//#define TB_CONFIG_LIBC_HAVE_STRLCPY -#define TB_CONFIG_LIBC_HAVE_STRLEN +#define TB_CONFIG_LIBC_HAVE_STRLCPY +#define TB_CONFIG_LIBC_HAVE_STRLEN #define TB_CONFIG_LIBC_HAVE_STRNLEN #define TB_CONFIG_LIBC_HAVE_STRSTR -#define TB_CONFIG_LIBC_HAVE_STRISTR +#define TB_CONFIG_LIBC_HAVE_STRCASESTR #define TB_CONFIG_LIBC_HAVE_STRCMP -#define TB_CONFIG_LIBC_HAVE_STRICMP +#define TB_CONFIG_LIBC_HAVE_STRCASECMP #define TB_CONFIG_LIBC_HAVE_STRNCMP -#define TB_CONFIG_LIBC_HAVE_STRNICMP +#define TB_CONFIG_LIBC_HAVE_STRNCASECMP #define TB_CONFIG_LIBC_HAVE_WCSCAT #define TB_CONFIG_LIBC_HAVE_WCSNCAT #define TB_CONFIG_LIBC_HAVE_WCSCPY #define TB_CONFIG_LIBC_HAVE_WCSNCPY -//#define TB_CONFIG_LIBC_HAVE_WCSLCPY -#define TB_CONFIG_LIBC_HAVE_WCSLEN +#define TB_CONFIG_LIBC_HAVE_WCSLCPY +#define TB_CONFIG_LIBC_HAVE_WCSLEN #define TB_CONFIG_LIBC_HAVE_WCSNLEN #define TB_CONFIG_LIBC_HAVE_WCSSTR -//#define TB_CONFIG_LIBC_HAVE_WCSISTR #define TB_CONFIG_LIBC_HAVE_WCSCMP -#define TB_CONFIG_LIBC_HAVE_WCSICMP +#define TB_CONFIG_LIBC_HAVE_WCSCASECMP #define TB_CONFIG_LIBC_HAVE_WCSNCMP -#define TB_CONFIG_LIBC_HAVE_WCSNICMP +#define TB_CONFIG_LIBC_HAVE_WCSNCASECMP #define TB_CONFIG_LIBC_HAVE_WCSTOMBS #define TB_CONFIG_LIBC_HAVE_MBSTOWCS #define TB_CONFIG_LIBC_HAVE_GMTIME #define TB_CONFIG_LIBC_HAVE_MKTIME #define TB_CONFIG_LIBC_HAVE_LOCALTIME +#define TB_CONFIG_LIBC_HAVE_GETTIMEOFDAY #define TB_CONFIG_LIBC_HAVE_SIGNAL #define TB_CONFIG_LIBC_HAVE_SETJMP #define TB_CONFIG_LIBC_HAVE_SIGSETJMP #define TB_CONFIG_LIBC_HAVE_BACKTRACE - -// libm -//#define TB_CONFIG_LIBM_HAVE_SINCOS -//#define TB_CONFIG_LIBM_HAVE_SINCOSF +#define TB_CONFIG_LIBC_HAVE_SYSTEM #define TB_CONFIG_LIBM_HAVE_LOG2 #define TB_CONFIG_LIBM_HAVE_LOG2F +#define TB_CONFIG_POSIX_HAVE_POLL +#define TB_CONFIG_POSIX_HAVE_PTHREAD_MUTEX_INIT +#define TB_CONFIG_POSIX_HAVE_PTHREAD_CREATE +#define TB_CONFIG_POSIX_HAVE_SOCKET +#define TB_CONFIG_POSIX_HAVE_OPENDIR +#define TB_CONFIG_POSIX_HAVE_DLOPEN +#define TB_CONFIG_POSIX_HAVE_OPEN +#define TB_CONFIG_POSIX_HAVE_GETHOSTNAME +#define TB_CONFIG_POSIX_HAVE_GETIFADDRS +#define TB_CONFIG_POSIX_HAVE_SEM_INIT +#define TB_CONFIG_POSIX_HAVE_GETPAGESIZE +#define TB_CONFIG_POSIX_HAVE_SYSCONF +#define TB_CONFIG_POSIX_HAVE_SCHED_YIELD +#define TB_CONFIG_SYSTEMV_HAVE_SEMGET -// module -#define TB_CONFIG_MODULE_HAVE_XML -#define TB_CONFIG_MODULE_HAVE_ZIP -#define TB_CONFIG_MODULE_HAVE_ASIO -#define TB_CONFIG_MODULE_HAVE_OBJECT -#define TB_CONFIG_MODULE_HAVE_CHARSET -#define TB_CONFIG_MODULE_HAVE_DATABASE +// undefines +#undef TB_CONFIG_TRACE_INFO_ONLY +#undef TB_CONFIG_EXCEPTION_ENABLE +#undef TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE #endif diff --git a/core/pkg/tbox.pkg/inc/msvc/x86/tbox.config.h b/core/pkg/tbox.pkg/inc/msvc/x86/tbox.config.h index f48896de0..6ec51f4ca 100644 --- a/core/pkg/tbox.pkg/inc/msvc/x86/tbox.config.h +++ b/core/pkg/tbox.pkg/inc/msvc/x86/tbox.config.h @@ -1,95 +1,56 @@ -#ifndef TB_CONFIG_H -#define TB_CONFIG_H - -// packages - #define TB_CONFIG_PACKAGE_HAVE_BASE - - -// major version -#define TB_CONFIG_VERSION_MAJOR 1 - -// minor version -#define TB_CONFIG_VERSION_MINOR 4 - -// alter version -#define TB_CONFIG_VERSION_ALTER 8 - -// build version -#define TB_CONFIG_VERSION_BUILD 201506021443 - -// small -#define TB_CONFIG_SMALL (0) - -// os -#define TB_CONFIG_OS_WINDOWS -//#define TB_CONFIG_OS_LIKE_UNIX - -// api -//#define TB_CONFIG_API_HAVE_POSIX -//#define TB_CONFIG_API_HAVE_SYSTEMV - -// type -#define TB_CONFIG_TYPE_FLOAT - -// memory -//#define TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE - -// trace -//#define TB_CONFIG_TRACE_INFO_ONLY - -// exception -#define TB_CONFIG_EXCEPTION_ENABLE - -// libc -#define TB_CONFIG_LIBC_HAVE_MEMCPY -#define TB_CONFIG_LIBC_HAVE_MEMSET -#define TB_CONFIG_LIBC_HAVE_MEMMOV -#define TB_CONFIG_LIBC_HAVE_MEMCMP -#define TB_CONFIG_LIBC_HAVE_STRCAT -#define TB_CONFIG_LIBC_HAVE_STRNCAT -#define TB_CONFIG_LIBC_HAVE_STRCPY -#define TB_CONFIG_LIBC_HAVE_STRNCPY -//#define TB_CONFIG_LIBC_HAVE_STRLCPY -#define TB_CONFIG_LIBC_HAVE_STRLEN -#define TB_CONFIG_LIBC_HAVE_STRNLEN -#define TB_CONFIG_LIBC_HAVE_STRSTR -//#define TB_CONFIG_LIBC_HAVE_STRISTR -#define TB_CONFIG_LIBC_HAVE_STRCMP -#define TB_CONFIG_LIBC_HAVE_STRICMP -#define TB_CONFIG_LIBC_HAVE_STRNCMP -#define TB_CONFIG_LIBC_HAVE_STRNICMP -#define TB_CONFIG_LIBC_HAVE_WCSCAT -#define TB_CONFIG_LIBC_HAVE_WCSNCAT -#define TB_CONFIG_LIBC_HAVE_WCSCPY -#define TB_CONFIG_LIBC_HAVE_WCSNCPY -//#define TB_CONFIG_LIBC_HAVE_WCSLCPY -#define TB_CONFIG_LIBC_HAVE_WCSLEN -#define TB_CONFIG_LIBC_HAVE_WCSNLEN -#define TB_CONFIG_LIBC_HAVE_WCSSTR -//#define TB_CONFIG_LIBC_HAVE_WCSISTR -#define TB_CONFIG_LIBC_HAVE_WCSCMP -#define TB_CONFIG_LIBC_HAVE_WCSICMP -#define TB_CONFIG_LIBC_HAVE_WCSNCMP -#define TB_CONFIG_LIBC_HAVE_WCSNICMP -#define TB_CONFIG_LIBC_HAVE_WCSTOMBS -#define TB_CONFIG_LIBC_HAVE_MBSTOWCS -#define TB_CONFIG_LIBC_HAVE_GMTIME -#define TB_CONFIG_LIBC_HAVE_MKTIME -#define TB_CONFIG_LIBC_HAVE_LOCALTIME -//#define TB_CONFIG_LIBC_HAVE_SETJMP - -// libm -#define TB_CONFIG_LIBM_HAVE_SINCOS -//#define TB_CONFIG_LIBM_HAVE_SINCOSF -//#define TB_CONFIG_LIBM_HAVE_LOG2 -//#define TB_CONFIG_LIBM_HAVE_LOG2F - -// module -#define TB_CONFIG_MODULE_HAVE_XML -#define TB_CONFIG_MODULE_HAVE_ZIP -#define TB_CONFIG_MODULE_HAVE_ASIO -#define TB_CONFIG_MODULE_HAVE_OBJECT -#define TB_CONFIG_MODULE_HAVE_CHARSET -#define TB_CONFIG_MODULE_HAVE_DATABASE - -#endif +#ifndef TB_CONFIG_H
+#define TB_CONFIG_H
+
+// version
+#define TB_CONFIG_VERSION "1.5.0"
+#define TB_CONFIG_VERSION_MAJOR 1
+#define TB_CONFIG_VERSION_MINOR 5
+#define TB_CONFIG_VERSION_ALTER 0
+#define TB_CONFIG_VERSION_BUILD 201507021431
+
+// defines
+#define TB_CONFIG_OS_WINDOWS
+#define TB_CONFIG_TYPE_HAVE_FLOAT
+#define TB_CONFIG_MODULE_HAVE_XML
+#define TB_CONFIG_MODULE_HAVE_ZIP
+#define TB_CONFIG_MODULE_HAVE_ASIO
+#define TB_CONFIG_MODULE_HAVE_OBJECT
+#define TB_CONFIG_MODULE_HAVE_CHARSET
+#define TB_CONFIG_MODULE_HAVE_DATABASE
+#define TB_CONFIG_LIBC_HAVE_MEMCPY
+#define TB_CONFIG_LIBC_HAVE_MEMSET
+#define TB_CONFIG_LIBC_HAVE_MEMMOVE
+#define TB_CONFIG_LIBC_HAVE_MEMCMP
+#define TB_CONFIG_LIBC_HAVE_STRCAT
+#define TB_CONFIG_LIBC_HAVE_STRNCAT
+#define TB_CONFIG_LIBC_HAVE_STRCPY
+#define TB_CONFIG_LIBC_HAVE_STRNCPY
+#define TB_CONFIG_LIBC_HAVE_STRLEN
+#define TB_CONFIG_LIBC_HAVE_STRNLEN
+#define TB_CONFIG_LIBC_HAVE_STRSTR
+#define TB_CONFIG_LIBC_HAVE_STRCMP
+#define TB_CONFIG_LIBC_HAVE_STRNCMP
+#define TB_CONFIG_LIBC_HAVE_WCSCAT
+#define TB_CONFIG_LIBC_HAVE_WCSNCAT
+#define TB_CONFIG_LIBC_HAVE_WCSCPY
+#define TB_CONFIG_LIBC_HAVE_WCSNCPY
+#define TB_CONFIG_LIBC_HAVE_WCSLEN
+#define TB_CONFIG_LIBC_HAVE_WCSNLEN
+#define TB_CONFIG_LIBC_HAVE_WCSSTR
+#define TB_CONFIG_LIBC_HAVE_WCSCMP
+#define TB_CONFIG_LIBC_HAVE_WCSNCMP
+#define TB_CONFIG_LIBC_HAVE_WCSTOMBS
+#define TB_CONFIG_LIBC_HAVE_MBSTOWCS
+#define TB_CONFIG_LIBC_HAVE_GMTIME
+#define TB_CONFIG_LIBC_HAVE_MKTIME
+#define TB_CONFIG_LIBC_HAVE_LOCALTIME
+#define TB_CONFIG_LIBC_HAVE_SIGNAL
+#define TB_CONFIG_LIBC_HAVE_SETJMP
+#define TB_CONFIG_LIBC_HAVE_SYSTEM
+
+// undefines
+#undef TB_CONFIG_TRACE_INFO_ONLY
+#undef TB_CONFIG_EXCEPTION_ENABLE
+#undef TB_CONFIG_MEMORY_UNALIGNED_ACCESS_ENABLE
+
+#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..e8c3981ac 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/algorithm.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..6a6f0b5f5 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/binary_find.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..43d9f581c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/binary_find_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..9d98c046e 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/bubble_sort.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..58053cbef 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/count.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..4800417b5 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/count_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..268049483 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/distance.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..be3ed6f3c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/find.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..d5239aa5c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/find_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..814607a3e 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/for.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..cd2270a25 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/for_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..092ba2387 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/heap_sort.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..595be6a66 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/insert_sort.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..3b9e13eb2 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/predicate.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..c991dc554 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..51aca3eae 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/quick_sort.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..55d688378 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/remove.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..a5524d6c4 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_first.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..12a547e41 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_first_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..382a94ffd 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/remove_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..5c9bf5368 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/rfind.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..6608f39fa 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/rfind_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..bbe553812 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/rfor.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..41da291b1 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/rfor_if.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..f85b0f1a3 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/rwalk.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..8d76f7c03 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/sort.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/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..b5fe70f03 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/algorithm/walk.h +++ b/core/pkg/tbox.pkg/inc/tbox/algorithm/walk.h diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/aice.h b/core/pkg/tbox.pkg/inc/tbox/asio/aice.h index 5093b6b2f..5093b6b2f 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/asio/aice.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/aice.h diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/aico.h b/core/pkg/tbox.pkg/inc/tbox/asio/aico.h index 9b808c738..9b808c738 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/asio/aico.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/aico.h diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/aicp.h b/core/pkg/tbox.pkg/inc/tbox/asio/aicp.h index f8c0fbf62..f8c0fbf62 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/asio/aicp.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/aicp.h diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/aioe.h b/core/pkg/tbox.pkg/inc/tbox/asio/aioe.h index e9c692a48..e9c692a48 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/asio/aioe.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/aioe.h diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/aioo.h b/core/pkg/tbox.pkg/inc/tbox/asio/aioo.h index 372cbd86d..372cbd86d 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/asio/aioo.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/aioo.h diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/aiop.h b/core/pkg/tbox.pkg/inc/tbox/asio/aiop.h index 4b5cc15e3..4b5cc15e3 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/asio/aiop.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/aiop.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..8d96712c2 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/asio/asio.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/asio.h diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/dns.h b/core/pkg/tbox.pkg/inc/tbox/asio/dns.h index 5039b4cec..5039b4cec 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/asio/dns.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/dns.h diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/http.h b/core/pkg/tbox.pkg/inc/tbox/asio/http.h index 1fddab323..1fddab323 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/asio/http.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/http.h diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/prefix.h b/core/pkg/tbox.pkg/inc/tbox/asio/prefix.h index fe7990e96..fe7990e96 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/asio/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/asio/ssl.h b/core/pkg/tbox.pkg/inc/tbox/asio/ssl.h index a2d192e52..a2d192e52 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/asio/ssl.h +++ b/core/pkg/tbox.pkg/inc/tbox/asio/ssl.h diff --git a/core/pkg/tbox.pkg/inc/tbox/charset/charset.h b/core/pkg/tbox.pkg/inc/tbox/charset/charset.h index e33d12436..e33d12436 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/charset/charset.h +++ b/core/pkg/tbox.pkg/inc/tbox/charset/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..4f36158ce 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/charset/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/charset/prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/config.h b/core/pkg/tbox.pkg/inc/tbox/config.h index 27ccfd550..27ccfd550 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/config.h +++ b/core/pkg/tbox.pkg/inc/tbox/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 346e115d5..346e115d5 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/bloom_filter.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/bloom_filter.h 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..82157147c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/circle_queue.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/circle_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..237ceb9c1 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/container.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/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..1ded4b0ff 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/element.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/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 new file mode 100644 index 000000000..54a4e411a --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/container/element/hash.h @@ -0,0 +1,96 @@ +/*!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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file hash.h + * + */ +#ifndef TB_CONTAINER_ELEMENT_HASH_H +#define TB_CONTAINER_ELEMENT_HASH_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/* compute the uint8 hash + * + * @param value the value + * @param mask the mask + * @param index the hash func index + * + * @return the hash value + */ +tb_size_t tb_element_hash_uint8(tb_uint8_t value, tb_size_t mask, tb_size_t index); + +/* compute the uint16 hash + * + * @param value the value + * @param mask the mask + * @param index the hash func index + * + * @return the hash value + */ +tb_size_t tb_element_hash_uint16(tb_uint16_t value, tb_size_t mask, tb_size_t index); + +/* compute the uint32 hash + * + * @param value the value + * @param mask the mask + * @param index the hash func index + * + * @return the hash value + */ +tb_size_t tb_element_hash_uint32(tb_uint32_t value, tb_size_t mask, tb_size_t index); + +/* compute the uint64 hash + * + * @param value the value + * @param mask the mask + * @param index the hash func index + * + * @return the hash value + */ +tb_size_t tb_element_hash_uint64(tb_uint64_t value, tb_size_t mask, tb_size_t index); + +/* compute the data hash + * + * @param data the data + * @param size the size + * @param mask the mask + * @param index the hash func index + * + * @return the hash value + */ +tb_size_t tb_element_hash_data(tb_byte_t const* data, tb_size_t size, tb_size_t mask, tb_size_t index); + +/* compute the cstring hash + * + * @param cstr the cstring + * @param mask the mask + * @param index the hash func index + * + * @return the hash value + */ +tb_size_t tb_element_hash_cstr(tb_char_t const* cstr, tb_size_t mask, tb_size_t index); + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/container/element/prefix.h b/core/pkg/tbox.pkg/inc/tbox/container/element/prefix.h new file mode 100644 index 000000000..51bf8c8a4 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/container/element/prefix.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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * + */ +#ifndef TB_CONTAINER_ELEMENT_PREFIX_H +#define TB_CONTAINER_ELEMENT_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" +#include "../element.h" +#include "../../libc/libc.h" +#include "../../utils/utils.h" +#include "../../memory/memory.h" +#include "../../object/object.h" +#include "../../stream/stream.h" +#include "../../platform/platform.h" + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/container/hash.h b/core/pkg/tbox.pkg/inc/tbox/container/hash.h deleted file mode 100755 index 39cb36724..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/container/hash.h +++ /dev/null @@ -1,184 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file hash.h - * @ingroup container - * - */ -#ifndef TB_CONTAINER_HASH_H -#define TB_CONTAINER_HASH_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "prefix.h" -#include "item.h" -#include "iterator.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * macros - */ - -// the hash bulk size -#define TB_HASH_BULK_SIZE_MICRO (64) -#define TB_HASH_BULK_SIZE_SMALL (256) -#define TB_HASH_BULK_SIZE_LARGE (65536) - -/* ////////////////////////////////////////////////////////////////////////////////////// - * types - */ - -/// the hash item type -typedef struct __tb_hash_item_t -{ - /// the item name - tb_pointer_t name; - - /// the item data - tb_pointer_t data; - -}tb_hash_item_t, *tb_hash_item_ref_t; - -/*! the hash ref type - * - * <pre> - * 0 1 3 ... ... n n + 1 - * hash_list: |--------|--------|--------|--------|--------|--------|--------|--------| - * | - * ----- - * item_list: | | key:0 - * ----- - * | | key:1 - * ----- <= insert by binary search algorithm - * | | key:2 - * ----- - * | | key:3 - * ----- - * | | key:4 - * ----- - * | | - * ----- - * | | - * ----- - * | | - * ----- - * - * </pre> - * - * @note the itor of the same item is mutable - */ -typedef tb_iterator_ref_t tb_hash_ref_t; - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! init hash - * - * @param bulk_size the hash bulk size, using the default size if be zero - * @param name_func the hash name func - * @param data_func the hash data func - * - * @return the hash - */ -tb_hash_ref_t tb_hash_init(tb_size_t bulk_size, tb_item_func_t name_func, tb_item_func_t data_func); - -/*! exit hash - * - * @param hash the hash - */ -tb_void_t tb_hash_exit(tb_hash_ref_t hash); - -/*! clear hash - * - * @param hash the hash - */ -tb_void_t tb_hash_clear(tb_hash_ref_t hash); - -/*! get hash item itor - * - * @param hash the hash - * @param name the hash item name - * - * @return the hash itor, @note: itor => item maybe changed if insert or remove item - */ -tb_size_t tb_hash_itor(tb_hash_ref_t hash, tb_cpointer_t name); - -/*! get hash item data - * - * @param hash the hash - * @param name the hash item name - * - * @return the hash item data - */ -tb_pointer_t tb_hash_get(tb_hash_ref_t hash, tb_cpointer_t name); - -/*! del hash item - * - * @param hash the hash - * @param name the hash item name - */ -tb_void_t tb_hash_del(tb_hash_ref_t hash, tb_cpointer_t name); - -/*! set hash item - * - * @param hash the hash - * @param name the hash item name - * @param data the hash item data - * - * @return the hash itor, @note: itor => item maybe changed if insert or remove item - */ -tb_size_t tb_hash_set(tb_hash_ref_t hash, tb_cpointer_t name, tb_cpointer_t data); - -/*! the hash size - * - * @param hash the hash - * - * @return the hash size - */ -tb_size_t tb_hash_size(tb_hash_ref_t hash); - -/*! the hash maxn - * - * @param hash the hash - * - * @return the hash maxn - */ -tb_size_t tb_hash_maxn(tb_hash_ref_t hash); - -#ifdef __tb_debug__ -/*! dump hash - * - * @param hash the hash - */ -tb_void_t tb_hash_dump(tb_hash_ref_t hash); -#endif - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - -#endif - 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 976369f6f..976369f6f 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/hash_map.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/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..db0e930e8 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/hash_set.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/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..612618bca 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/heap.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/heap.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/item.h b/core/pkg/tbox.pkg/inc/tbox/container/item.h deleted file mode 100755 index 35b48a8ea..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/container/item.h +++ /dev/null @@ -1,350 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file item.h - * @ingroup container - * - */ -#ifndef TB_CONTAINER_ITEM_H -#define TB_CONTAINER_ITEM_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "prefix.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * types - */ - -struct __tb_item_func_t; - -/*! the item data hash func type - * - * @param func the item func - * @param data the item data - * @param mask the hash mask - * @param index the hash index - * - * @return the hash value - */ -typedef tb_size_t (*tb_item_func_hash_t)(struct __tb_item_func_t* func, tb_cpointer_t data, tb_size_t mask, tb_size_t index); - -/*! the item data compare func type - * - * @param func the item func - * @param ldata the left-hand data - * @param rdata the right-hand data - * - * @return equal: 0, 1: >, -1: < - */ -typedef tb_long_t (*tb_item_func_comp_t)(struct __tb_item_func_t* func, tb_cpointer_t ldata, tb_cpointer_t rdata); - -/*! the item data func type - * - * @param func the item func - * @param buff the item data address - * - * @return the item data - */ -typedef tb_pointer_t (*tb_item_func_data_t)(struct __tb_item_func_t* func, tb_cpointer_t buff); - -/*! the item data string func type - * - * @param func the item func - * @param data the item data - * @param cstr the string buffer - * @param maxn the string buffer maximum size - * - * @return the string pointer - */ -typedef tb_char_t const* (*tb_item_func_cstr_t)(struct __tb_item_func_t* func, tb_cpointer_t data, tb_char_t* cstr, tb_size_t maxn); - -/*! the item data load func type - * - * load data to the item from the stream - * - * @param func the item func - * @param buff the item buffer - * @param stream the stream - * - * @return tb_true or tb_false - */ -typedef tb_bool_t (*tb_item_func_load_t)(struct __tb_item_func_t* func, tb_pointer_t buff, tb_stream_ref_t stream); - -/*! the item data save func type - * - * save data to the stream - * - * @param func the item func - * @param data the item data - * @param stream the stream - * - * @return tb_true or tb_false - */ -typedef tb_bool_t (*tb_item_func_save_t)(struct __tb_item_func_t* func, tb_cpointer_t data, tb_stream_ref_t stream); - -/*! the item free func type - * - * @param func the item func - * @param buff the item buffer - */ -typedef tb_void_t (*tb_item_func_free_t)(struct __tb_item_func_t* func, tb_pointer_t buff); - -/*! the item duplicate func type - * - * allocate a new item and copy the item data - * - * @param func the item func - * @param buff the item buffer - * @param data the item data - */ -typedef tb_void_t (*tb_item_func_dupl_t)(struct __tb_item_func_t* func, tb_pointer_t buff, tb_cpointer_t data); - -/*! the item replace func type - * - * free the previous item data and duplicate the new data - * - * @param func the item func - * @param buff the item buffer - * @param data the item data - */ -typedef tb_void_t (*tb_item_func_repl_t)(struct __tb_item_func_t* func, tb_pointer_t buff, tb_cpointer_t data); - -/*! the item copy func type - * - * only copy the item data and not allocate new item - * - * @param func the item func - * @param buff the item data address - * @param data the item data - */ -typedef tb_void_t (*tb_item_func_copy_t)(struct __tb_item_func_t* func, tb_pointer_t buff, tb_cpointer_t data); - -/*! the items free func type - * - * free some items - * - * @param func the item func - * @param buff the item buffer - * @param size the item count - */ -typedef tb_void_t (*tb_item_func_nfree_t)(struct __tb_item_func_t* func, tb_pointer_t buff, tb_size_t size); - -/*! the items duplicate func type - * - * duplicate some items - * - * @param func the item func - * @param buff the item buffer - * @param data the item data - * @param size the item count - */ -typedef tb_void_t (*tb_item_func_ndupl_t)(struct __tb_item_func_t* func, tb_pointer_t buff, tb_cpointer_t data, tb_size_t size); - -/*! the items replace func type - * - * replace some items - * - * @param func the item func - * @param buff the item buffer - * @param data the item data - * @param size the item count - */ -typedef tb_void_t (*tb_item_func_nrepl_t)(struct __tb_item_func_t* func, tb_pointer_t buff, tb_cpointer_t data, tb_size_t size); - -/*! the items copy func type - * - * copy some items - * - * @param func the item func - * @param buff the item buffer - * @param data the item data - * @param size the item count - */ -typedef tb_void_t (*tb_item_func_ncopy_t)(struct __tb_item_func_t* func, tb_pointer_t buff, tb_cpointer_t data, tb_size_t size); - -/// the item type -typedef enum __tb_item_type_t -{ - TB_ITEM_TYPE_NULL = 0 //!< null -, TB_ITEM_TYPE_LONG = 1 //!< integer for tb_long_t -, TB_ITEM_TYPE_SIZE = 2 //!< integer for tb_size_t -, TB_ITEM_TYPE_UINT8 = 3 //!< integer for tb_uint8_t -, TB_ITEM_TYPE_UINT16 = 4 //!< integer for tb_uint16_t -, TB_ITEM_TYPE_UINT32 = 5 //!< integer for tb_uint32_t -, TB_ITEM_TYPE_STR = 6 //!< string -, TB_ITEM_TYPE_PTR = 7 //!< pointer -, TB_ITEM_TYPE_MEM = 8 //!< memory -, TB_ITEM_TYPE_OBJ = 9 //!< object -, TB_ITEM_TYPE_TRUE = 10 //!< true -, TB_ITEM_TYPE_USER = 11 //!< the user defined type - -}tb_item_type_t; - -/// the item func type -typedef struct __tb_item_func_t -{ - /// the item type - tb_uint16_t type; - - /// the item flag - tb_uint16_t flag; - - /// the item size - tb_uint16_t size; - - /// the priv data - tb_cpointer_t priv; - - /// the hash func - tb_item_func_hash_t hash; - - /// the compare func - tb_item_func_comp_t comp; - - /// the data func - tb_item_func_data_t data; - - /// the string func - tb_item_func_cstr_t cstr; - - /// the free item func - tb_item_func_free_t free; - - /// the duplicate func - tb_item_func_dupl_t dupl; - - /// the replace func - tb_item_func_repl_t repl; - - /// the copy func - tb_item_func_copy_t copy; - - /// the free items func - tb_item_func_nfree_t nfree; - - /// the duplicate items func - tb_item_func_ndupl_t ndupl; - - /// the replace items func - tb_item_func_nrepl_t nrepl; - - /// the copy items func - tb_item_func_ncopy_t ncopy; - -}tb_item_func_t; - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! the null item function, no space - * - * @return the item func - */ -tb_item_func_t tb_item_func_null(tb_noarg_t); - -/*! the true item function, no space - * - * .e.g for hash data - * - * @return the item func - */ -tb_item_func_t tb_item_func_true(tb_noarg_t); - -/*! the integer item function for tb_long_t - * - * @return the item func - */ -tb_item_func_t tb_item_func_long(tb_noarg_t); - -/*! the integer item function for tb_size_t - * - * @return the item func - */ -tb_item_func_t tb_item_func_size(tb_noarg_t); - -/*! the integer item function for tb_uint8_t - * - * @return the item func - */ -tb_item_func_t tb_item_func_uint8(tb_noarg_t); - -/*! the integer item function for tb_uint16_t - * - * @return the item func - */ -tb_item_func_t tb_item_func_uint16(tb_noarg_t); - -/*! the integer item function for tb_uint32_t - * - * @return the item func - */ -tb_item_func_t tb_item_func_uint32(tb_noarg_t); - -/*! the string item function - * - * @param bcase is case? - * - * @return the item func - */ -tb_item_func_t tb_item_func_str(tb_bool_t bcase); - -/*! the pointer item function - * - * @note if the free func have been hooked, the nfree need hook too. - * - * @param free the item free func - * @param priv the private data of the item free func - * - * @return the item func - */ -tb_item_func_t tb_item_func_ptr(tb_item_func_free_t free, tb_cpointer_t priv); - -/*! the object item function - * - * @return the item func - */ -tb_item_func_t tb_item_func_obj(tb_noarg_t); - -/*! the internal fixed memory item function - * - * storing it in the internal item of the container directly for saving memory - * - * @param size the item size - * @param free the item free func - * @param priv the private data of the item free func - * - * @return the item func - */ -tb_item_func_t tb_item_func_mem(tb_size_t size, tb_item_func_free_t free, tb_cpointer_t priv); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - -#endif - diff --git a/core/pkg/tbox.pkg/inc/tbox/container/iterator.h b/core/pkg/tbox.pkg/inc/tbox/container/iterator.h index c0d26e620..c0d26e620 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/iterator.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/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 new file mode 100644 index 000000000..d84483189 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/container/iterator/prefix.h @@ -0,0 +1,38 @@ +/*!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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * + */ +#ifndef TB_CONTAINER_ITERATOR_PREFIX_H +#define TB_CONTAINER_ITERATOR_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" +#include "../iterator.h" +#include "../../libc/libc.h" +#include "../../utils/utils.h" +#include "../../memory/memory.h" +#include "../../object/object.h" +#include "../../platform/platform.h" + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/container/list.h b/core/pkg/tbox.pkg/inc/tbox/container/list.h index f27c4935a..f27c4935a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/list.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/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 810736b64..810736b64 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/list_entry.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/list_entry.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/prefix.h b/core/pkg/tbox.pkg/inc/tbox/container/prefix.h index 3dde431fe..3dde431fe 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/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..2e87a64ae 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/priority_queue.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/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..8aa5a98aa 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/queue.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/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..861c749c0 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/single_list.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/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 a5e0923a3..a5e0923a3 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/single_list_entry.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/single_list_entry.h diff --git a/core/pkg/tbox.pkg/inc/tbox/container/stack.h b/core/pkg/tbox.pkg/inc/tbox/container/stack.h index d357eca0a..d357eca0a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/stack.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/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 53b3e111d..53b3e111d 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/container/vector.h +++ b/core/pkg/tbox.pkg/inc/tbox/container/vector.h diff --git a/core/pkg/tbox.pkg/inc/tbox/database/database.h b/core/pkg/tbox.pkg/inc/tbox/database/database.h index 26122a4ec..26122a4ec 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/database/database.h +++ b/core/pkg/tbox.pkg/inc/tbox/database/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..e0e7f10d5 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/database/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/database/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 26f66c99a..26f66c99a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/database/sql.h +++ b/core/pkg/tbox.pkg/inc/tbox/database/sql.h diff --git a/core/pkg/tbox.pkg/inc/tbox/database/value.h b/core/pkg/tbox.pkg/inc/tbox/database/value.h index af82222af..a28d286ee 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/database/value.h +++ b/core/pkg/tbox.pkg/inc/tbox/database/value.h @@ -51,7 +51,7 @@ typedef enum __tb_database_sql_value_type_e , TB_DATABASE_SQL_VALUE_TYPE_UINT16 = 6 , TB_DATABASE_SQL_VALUE_TYPE_UINT32 = 7 , TB_DATABASE_SQL_VALUE_TYPE_UINT64 = 8 -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT , TB_DATABASE_SQL_VALUE_TYPE_FLOAT = 13 , TB_DATABASE_SQL_VALUE_TYPE_DOUBLE = 14 #endif @@ -87,7 +87,7 @@ typedef struct __tb_database_sql_value_t tb_uint64_t u64; // float -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT tb_float_t f; tb_double_t d; #endif @@ -191,7 +191,7 @@ tb_uint32_t tb_database_sql_value_uint32(tb_database_sql_value_t const* */ tb_uint64_t tb_database_sql_value_uint64(tb_database_sql_value_t const* value); -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! the float value * * @param value the value @@ -272,7 +272,7 @@ tb_void_t tb_database_sql_value_set_uint32(tb_database_sql_value_t* va */ tb_void_t tb_database_sql_value_set_uint64(tb_database_sql_value_t* value, tb_uint64_t number); -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! set the float value * * @param value the value @@ -358,7 +358,7 @@ static __tb_inline_force__ tb_bool_t tb_database_sql_value_is_integer(tb_databas } /// the value is float? -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT static __tb_inline_force__ tb_bool_t tb_database_sql_value_is_float(tb_database_sql_value_t const* value) { return ( value diff --git a/core/pkg/tbox.pkg/inc/tbox/libc/libc.h b/core/pkg/tbox.pkg/inc/tbox/libc/libc.h index 0ae380055..0ae380055 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/libc.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/libc.h 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..878fce45c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/ctype.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/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..45828a1a7 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/limits.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/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..84a6aebbf 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/misc.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/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..3cd542525 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/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..b8583dcfd 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/setjmp.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/setjmp.h 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 ca15dc661..ca15dc661 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/signal.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/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..16aff2378 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/stdarg.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/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..af57dee8b 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/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..d96c76432 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/time.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/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..25679768a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/type.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/misc/time/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..d01c40204 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/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..0b3b5db9e 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/stdio/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/stdio/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..966ddc4a9 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/stdio/printf_object.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/stdio/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..99935bce8 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/stdio/stdio.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/stdio/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..16225fb06 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/stdlib/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/stdlib/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 27b55a9d7..e22467e29 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/stdlib/stdlib.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/stdlib/stdlib.h @@ -63,7 +63,7 @@ __tb_extern_c_enter__ #define tb_sbtoi64(s, b) ((tb_int64_t)tb_sbtou64(s, b)) // for float -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_s2tof(s) ((tb_float_t)tb_s2tod(s)) # define tb_s8tof(s) ((tb_float_t)tb_s8tod(s)) # define tb_s10tof(s) ((tb_float_t)tb_s10tod(s)) @@ -77,7 +77,7 @@ __tb_extern_c_enter__ #define tb_atoll(s) tb_s10toi64(s) #define tb_strtol(s, e, b) tb_sbtoi32(s, b) #define tb_strtoll(s, e, b) tb_sbtoi64(s, b) -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_atof(s) tb_s10tod(s) # define tb_strtof(s, e) tb_s10tof(s) # define tb_strtod(s, e) tb_s10tod(s) @@ -177,7 +177,7 @@ tb_uint64_t tb_stou64(tb_char_t const* s); */ tb_uint64_t tb_sbtou64(tb_char_t const* s, tb_int_t base); -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! convert the binary string to double * 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..4a7bd507e 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/string/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/string/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 eb4e4cf5b..eb4e4cf5b 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libc/string/string.h +++ b/core/pkg/tbox.pkg/inc/tbox/libc/string/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..eb3eaf343 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libm/ceil.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/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..2465c49e2 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libm/fabs.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/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..8c31041c1 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libm/floor.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/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..289ead7e3 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libm/inf.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/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..ddcb0df07 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libm/libm.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/libm.h diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/maf.h b/core/pkg/tbox.pkg/inc/tbox/libm/maf.h index 3101d4a4a..3101d4a4a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libm/maf.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/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 5ed5f8832..ec85c209a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libm/math.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/math.h @@ -28,7 +28,7 @@ * includes */ #include "prefix.h" -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT # include "nan.h" # include "inf.h" # include "maf.h" @@ -49,7 +49,7 @@ __tb_extern_c_enter__ * interfaces */ -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT // is infinite? tb_long_t tb_isinf(tb_double_t x); diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/mif.h b/core/pkg/tbox.pkg/inc/tbox/libm/mif.h index 0518db0d3..0518db0d3 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libm/mif.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/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..0aca2f237 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libm/nan.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/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..29bbc59c7 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libm/pi.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/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 a876ed2d8..0e0e72d14 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libm/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/prefix.h @@ -33,7 +33,7 @@ * types */ -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT // the ieee float type typedef union __tb_ieee_float_t diff --git a/core/pkg/tbox.pkg/inc/tbox/libm/round.h b/core/pkg/tbox.pkg/inc/tbox/libm/round.h index 17e9148fc..17e9148fc 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/libm/round.h +++ b/core/pkg/tbox.pkg/inc/tbox/libm/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 97bf82338..590578a73 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/math/fixed.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed.h @@ -46,7 +46,7 @@ #define TB_FIXED_NEAR0 TB_FIXED16_NEAR0 // conversion -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_fixed_to_float(x) tb_fixed16_to_float(x) # define tb_float_to_fixed(x) tb_float_to_fixed16(x) #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h index 4ac998f04..abe99aadc 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h @@ -55,7 +55,7 @@ __tb_extern_c_enter__ #define TB_FIXED16_NEAR0 (1 << 4) // conversion -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT # ifndef tb_fixed16_to_float # define tb_fixed16_to_float(x) ((tb_float_t)((x) * 1.5258789e-5)) # endif @@ -175,7 +175,7 @@ __tb_extern_c_enter__ // sin #ifndef tb_fixed16_sin -# ifdef TB_CONFIG_TYPE_FLOAT +# ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_fixed16_sin(x) tb_fixed16_sin_float(x) # else # define tb_fixed16_sin(x) tb_fixed16_sin_int32(x) @@ -184,7 +184,7 @@ __tb_extern_c_enter__ // cos #ifndef tb_fixed16_cos -# ifdef TB_CONFIG_TYPE_FLOAT +# ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_fixed16_cos(x) tb_fixed16_cos_float(x) # else # define tb_fixed16_cos(x) tb_fixed16_cos_int32(x) @@ -193,7 +193,7 @@ __tb_extern_c_enter__ // sincos #ifndef tb_fixed16_sincos -# ifdef TB_CONFIG_TYPE_FLOAT +# ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_fixed16_sincos(x, s, c) tb_fixed16_sincos_float(x, s, c) # else # define tb_fixed16_sincos(x, s, c) tb_fixed16_sincos_int32(x, s, c) @@ -202,7 +202,7 @@ __tb_extern_c_enter__ // tan #ifndef tb_fixed16_tan -# ifdef TB_CONFIG_TYPE_FLOAT +# ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_fixed16_tan(x) tb_fixed16_tan_float(x) # else # define tb_fixed16_tan(x) tb_fixed16_tan_int32(x) @@ -211,7 +211,7 @@ __tb_extern_c_enter__ // asin #ifndef tb_fixed16_asin -# ifdef TB_CONFIG_TYPE_FLOAT +# ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_fixed16_asin(x) tb_fixed16_asin_float(x) # else # define tb_fixed16_asin(x) tb_fixed16_asin_int32(x) @@ -220,7 +220,7 @@ __tb_extern_c_enter__ // acos #ifndef tb_fixed16_acos -# ifdef TB_CONFIG_TYPE_FLOAT +# ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_fixed16_acos(x) tb_fixed16_acos_float(x) # else # define tb_fixed16_acos(x) tb_fixed16_acos_int32(x) @@ -229,7 +229,7 @@ __tb_extern_c_enter__ // atan #ifndef tb_fixed16_atan -# ifdef TB_CONFIG_TYPE_FLOAT +# ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_fixed16_atan(x) tb_fixed16_atan_float(x) # else # define tb_fixed16_atan(x) tb_fixed16_atan_int32(x) @@ -238,7 +238,7 @@ __tb_extern_c_enter__ // atan2 #ifndef tb_fixed16_atan2 -# ifdef TB_CONFIG_TYPE_FLOAT +# ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_fixed16_atan2(y, x) tb_fixed16_atan2_float(y, x) # else # define tb_fixed16_atan2(y, x) tb_fixed16_atan2_int32(y, x) @@ -247,7 +247,7 @@ __tb_extern_c_enter__ // exp #ifndef tb_fixed16_exp -# ifdef TB_CONFIG_TYPE_FLOAT +# ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_fixed16_exp(x) tb_fixed16_exp_float(x) # else # define tb_fixed16_exp(x) tb_fixed16_exp_int32(x) @@ -255,7 +255,7 @@ __tb_extern_c_enter__ #endif #ifndef tb_fixed16_expi -# ifdef TB_CONFIG_TYPE_FLOAT +# ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_fixed16_expi(x) tb_fixed16_expi_float(x) # else # define tb_fixed16_expi(x) tb_assert(0) @@ -263,7 +263,7 @@ __tb_extern_c_enter__ #endif #ifndef tb_fixed16_exp1 -# ifdef TB_CONFIG_TYPE_FLOAT +# ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_fixed16_exp1(x) tb_fixed16_exp1_float(x) # else # define tb_fixed16_exp1(x) tb_assert(0) @@ -424,7 +424,7 @@ static __tb_inline__ tb_fixed16_t tb_fixed16_imulsub_check(tb_fixed16_t x, tb_lo // ok return (tb_fixed16_t)v; } -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT static __tb_inline__ tb_fixed16_t tb_fixed16_sin_float(tb_fixed16_t x) { return tb_float_to_fixed16(tb_sinf(tb_fixed16_to_float(x))); diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h index b7232b715..41965701a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h @@ -53,7 +53,7 @@ __tb_extern_c_enter__ #define TB_FIXED30_SQRT2 (0x5a827999) // conversion -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT # ifndef tb_fixed30_to_float # define tb_fixed30_to_float(x) (((x) * 0.00000000093132257f)) # endif @@ -83,7 +83,7 @@ __tb_extern_c_enter__ #ifndef tb_fixed30_mul # if 1 # define tb_fixed30_mul(x, y) tb_fixed30_mul_int64(x, y) -# elif defined(TB_CONFIG_TYPE_FLOAT) +# elif defined(TB_CONFIG_TYPE_HAVE_FLOAT) # define tb_fixed30_mul(x, y) tb_fixed30_mul_float(x, y) # else # define tb_fixed30_mul(x, y) tb_fixed30_mul_int32(x, y) @@ -94,7 +94,7 @@ __tb_extern_c_enter__ #ifndef tb_fixed30_div # if 1 # define tb_fixed30_div(x, y) tb_fixed30_div_int64(x, y) -# elif defined(TB_CONFIG_TYPE_FLOAT) +# elif defined(TB_CONFIG_TYPE_HAVE_FLOAT) # define tb_fixed30_div(x, y) tb_fixed30_div_float(x, y) # else # define tb_fixed30_div(x, y) tb_int32_div(x, y, 30) @@ -105,7 +105,7 @@ __tb_extern_c_enter__ #ifndef tb_fixed30_sqre # if 1 # define tb_fixed30_sqre(x) tb_fixed30_sqre_int64(x) -# elif defined(TB_CONFIG_TYPE_FLOAT) +# elif defined(TB_CONFIG_TYPE_HAVE_FLOAT) # define tb_fixed30_sqre(x) tb_fixed30_sqre_float(x) # else # define tb_fixed30_sqre(x) tb_fixed30_sqre_int32(x) @@ -122,7 +122,7 @@ __tb_extern_c_enter__ */ #ifdef __tb_debug__ -# ifdef TB_CONFIG_TYPE_FLOAT +# ifdef TB_CONFIG_TYPE_HAVE_FLOAT static __tb_inline__ tb_fixed30_t tb_float_to_fixed30_check(tb_float_t x) { // check overflow, [-2., 2.] @@ -152,7 +152,7 @@ static __tb_inline__ tb_fixed30_t tb_fixed30_sqre_int64(tb_fixed30_t x) return (tb_fixed30_t)((tb_hong_t)x * x >> 30); } -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT static __tb_inline__ tb_fixed30_t tb_fixed30_mul_float(tb_fixed30_t x, tb_fixed30_t y) { tb_float_t f = tb_fixed30_to_float(x) * tb_fixed30_to_float(y); diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h index d3a01669c..0703e2b0d 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h @@ -51,7 +51,7 @@ __tb_extern_c_enter__ #define TB_FIXED6_NEAR0 (0) // conversion -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT # ifndef tb_fixed6_to_float # define tb_fixed6_to_float(x) (((x) * 0.015625)) # endif 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 deleted file mode 100755 index 2a84fca64..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed16_arm.h +++ /dev/null @@ -1,66 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file fixed16_arm.h - * - */ -#ifndef TB_MATH_IMPL_FIXED16_ARM_H -#define TB_MATH_IMPL_FIXED16_ARM_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "../prefix.h" - - -/* ////////////////////////////////////////////////////////////////////////////////////// - * macros - */ - -#ifdef TB_ASSEMBLER_IS_GAS - -#if 0 -# define tb_fixed16_mul(x, y) tb_fixed16_mul_asm(x, y) -#endif - -#endif /* TB_ASSEMBLER_IS_GAS */ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -#if defined(TB_ASSEMBLER_IS_GAS) && !defined(TB_ARCH_ARM64) -static __tb_inline__ tb_fixed16_t tb_fixed16_mul_asm(tb_fixed16_t x, tb_fixed16_t y) -{ - __tb_register__ tb_fixed16_t t; - __tb_asm__ __tb_volatile__ - ( - "smull %0, %2, %1, %3 \n" // r64 = (l, h) = x * y - "mov %0, %0, lsr #16 \n" // to fixed16: r64 >>= 16 - "orr %0, %0, %2, lsl #16 \n" // x = l = (h << (32 - 16)) | (l >> 16); - - : "=r"(x), "=&r"(y), "=r"(t) - : "r"(x), "1"(y) - ); - return x; -} -#endif - -#endif - diff --git a/core/pkg/tbox.pkg/inc/tbox/math/int32.h b/core/pkg/tbox.pkg/inc/tbox/math/int32.h index b51d425a3..b51d425a3 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/math/int32.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/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 9eef102c4..9eef102c4 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/math/math.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/math.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/prefix.h b/core/pkg/tbox.pkg/inc/tbox/math/prefix.h index e42d4e57a..e42d4e57a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/math/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/random.h b/core/pkg/tbox.pkg/inc/tbox/math/random.h index 86b99ae36..f21a364ee 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/math/random.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/random.h @@ -83,7 +83,7 @@ tb_void_t tb_random_clear(tb_random_ref_t random); */ tb_long_t tb_random_range(tb_random_ref_t random, tb_long_t beg, tb_long_t end); -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! generate the float random with range: [beg, end) * * @param random the random, using the default random if be null diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/buffer.h b/core/pkg/tbox.pkg/inc/tbox/memory/buffer.h index 98c6f568e..98c6f568e 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/memory/buffer.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/buffer.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 998a0a02f..998a0a02f 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/memory/fixed_pool.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/fixed_pool.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/large_pool.h b/core/pkg/tbox.pkg/inc/tbox/memory/large_pool.h index e95137b6c..e95137b6c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/memory/large_pool.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/large_pool.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/memory.h b/core/pkg/tbox.pkg/inc/tbox/memory/memory.h index 4db46adb5..4db46adb5 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/memory/memory.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/memory.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/pool.h b/core/pkg/tbox.pkg/inc/tbox/memory/pool.h index 2a0c6de16..2a0c6de16 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/memory/pool.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/pool.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..120511a2a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/memory/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/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..cb4c18d4f 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/memory/queue_buffer.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/queue_buffer.h diff --git a/core/pkg/tbox.pkg/inc/tbox/memory/small_pool.h b/core/pkg/tbox.pkg/inc/tbox/memory/small_pool.h index 7736adf39..7736adf39 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/memory/small_pool.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/small_pool.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..daaa065fd 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/memory/static_buffer.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/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..a1c068a92 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/memory/string_pool.h +++ b/core/pkg/tbox.pkg/inc/tbox/memory/string_pool.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/cookies.h b/core/pkg/tbox.pkg/inc/tbox/network/cookies.h index 5d6438fe9..5d6438fe9 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/cookies.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/cookies.h 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..b4bcdd662 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/dns/cache.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/dns/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..d4553323f 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/dns/dns.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/dns/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..b400e8108 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/dns/looker.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/dns/looker.h 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..ba0e8ccbe 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/dns/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/dns/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..7a574a28c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/dns/server.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/dns/server.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/http.h b/core/pkg/tbox.pkg/inc/tbox/network/http.h index 6ff4cb986..6ff4cb986 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/http.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/http.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/hwaddr.h b/core/pkg/tbox.pkg/inc/tbox/network/hwaddr.h index f3168cf24..f3168cf24 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/hwaddr.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/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..d24f7400d 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/ipaddr.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/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..5d6639c9d 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/ipv4.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/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..b9b4b99d5 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/ipv6.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/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 31e6b74c0..31e6b74c0 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/network.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/network.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/prefix.h b/core/pkg/tbox.pkg/inc/tbox/network/prefix.h index f84388c05..f84388c05 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/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..160bec37d 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/ssl.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/ssl.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/url.h b/core/pkg/tbox.pkg/inc/tbox/network/url.h index b82094ec8..b82094ec8 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/url.h +++ b/core/pkg/tbox.pkg/inc/tbox/network/url.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/array.h b/core/pkg/tbox.pkg/inc/tbox/object/array.h index 7e860acbd..7e860acbd 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/array.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/array.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/boolean.h b/core/pkg/tbox.pkg/inc/tbox/object/boolean.h index 5ad12edb6..5ad12edb6 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/boolean.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/boolean.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/data.h b/core/pkg/tbox.pkg/inc/tbox/object/data.h index 893f1568b..893f1568b 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/data.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/data.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/date.h b/core/pkg/tbox.pkg/inc/tbox/object/date.h index 289951c85..289951c85 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/date.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/date.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/dictionary.h b/core/pkg/tbox.pkg/inc/tbox/object/dictionary.h index fac229aa9..fac229aa9 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/dictionary.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/dictionary.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/null.h b/core/pkg/tbox.pkg/inc/tbox/object/null.h index f1e20b427..f1e20b427 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/null.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/null.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/number.h b/core/pkg/tbox.pkg/inc/tbox/object/number.h index 0b994a15c..830afc660 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/number.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/number.h @@ -123,7 +123,7 @@ tb_object_ref_t tb_object_number_init_from_uint64(tb_uint64_t value); */ tb_object_ref_t tb_object_number_init_from_sint64(tb_sint64_t value); -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! init number from float * * @param value the value @@ -213,7 +213,7 @@ tb_uint64_t tb_object_number_uint64(tb_object_ref_t number); */ tb_sint64_t tb_object_number_sint64(tb_object_ref_t number); -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! the float value of the number * * @param object the object pointer @@ -303,7 +303,7 @@ tb_bool_t tb_object_number_uint64_set(tb_object_ref_t number, tb_uint6 */ tb_bool_t tb_object_number_sint64_set(tb_object_ref_t number, tb_sint64_t value); -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! set the float value * * @param object the object pointer diff --git a/core/pkg/tbox.pkg/inc/tbox/object/object.h b/core/pkg/tbox.pkg/inc/tbox/object/object.h index 59320f46a..59320f46a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/object.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/object.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/prefix.h b/core/pkg/tbox.pkg/inc/tbox/object/prefix.h index 8aa6e4df0..8aa6e4df0 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/reader/bin.h b/core/pkg/tbox.pkg/inc/tbox/object/reader/bin.h deleted file mode 100755 index 49940aa49..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/object/reader/bin.h +++ /dev/null @@ -1,88 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file bin.h - * @ingroup object - * - */ -#ifndef TB_OBJECT_READER_BIN_H -#define TB_OBJECT_READER_BIN_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "prefix.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * types - */ - -/// the bin reader type -typedef struct __tb_object_bin_reader_t -{ - /// the stream - tb_stream_ref_t stream; - - /// the object list - tb_vector_ref_t list; - -}tb_object_bin_reader_t; - -/// the bin reader func type -typedef tb_object_ref_t (*tb_object_bin_reader_func_t)(tb_object_bin_reader_t* reader, tb_size_t type, tb_uint64_t size); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! the bin object reader - * - * @return the bin object reader - */ -tb_object_reader_t* tb_object_bin_reader(tb_noarg_t); - -/*! hook the bin reader - * - * @param type the object type - * @param func the reader func - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_bin_reader_hook(tb_size_t type, tb_object_bin_reader_func_t func); - -/*! the bin reader func - * - * @param type the object type - * - * @return the object reader func - */ -tb_object_bin_reader_func_t tb_object_bin_reader_func(tb_size_t type); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - -#endif - diff --git a/core/pkg/tbox.pkg/inc/tbox/object/reader/bplist.h b/core/pkg/tbox.pkg/inc/tbox/object/reader/bplist.h deleted file mode 100755 index 9bf1c6c66..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/object/reader/bplist.h +++ /dev/null @@ -1,85 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file bplist.h - * @ingroup object - * - */ -#ifndef TB_OBJECT_READER_BPLIST_H -#define TB_OBJECT_READER_BPLIST_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "prefix.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * types - */ - -/// the bplist reader type -typedef struct __tb_object_bplist_reader_t -{ - /// the stream - tb_stream_ref_t stream; - -}tb_object_bplist_reader_t; - -/// the bplist reader func type -typedef tb_object_ref_t (*tb_object_bplist_reader_func_t)(tb_object_bplist_reader_t* reader, tb_size_t type, tb_size_t size, tb_size_t item_size); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! the bplist object reader - * - * @return the bplist object reader - */ -tb_object_reader_t* tb_object_bplist_reader(tb_noarg_t); - -/*! hook the bplist reader - * - * @param type the object type - * @param func the reader func - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_bplist_reader_hook(tb_size_t type, tb_object_bplist_reader_func_t func); - -/*! the bplist reader func - * - * @param type the object type - * - * @return the object reader func - */ -tb_object_bplist_reader_func_t tb_object_bplist_reader_func(tb_size_t type); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - -#endif - diff --git a/core/pkg/tbox.pkg/inc/tbox/object/reader/json.h b/core/pkg/tbox.pkg/inc/tbox/object/reader/json.h deleted file mode 100755 index fbf4a3288..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/object/reader/json.h +++ /dev/null @@ -1,85 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file json.h - * @ingroup object - * - */ -#ifndef TB_OBJECT_READER_JSON_H -#define TB_OBJECT_READER_JSON_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "prefix.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * types - */ - -/// the json reader type -typedef struct __tb_object_json_reader_t -{ - /// the stream - tb_stream_ref_t stream; - -}tb_object_json_reader_t; - -/// the json reader func type -typedef tb_object_ref_t (*tb_object_json_reader_func_t)(tb_object_json_reader_t* reader, tb_char_t type); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! the json object reader - * - * @return the json object reader - */ -tb_object_reader_t* tb_object_json_reader(tb_noarg_t); - -/*! hook the json reader - * - * @param type the object type name - * @param func the reader func - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_json_reader_hook(tb_char_t type, tb_object_json_reader_func_t func); - -/*! the json reader func - * - * @param type the object type name - * - * @return the object reader func - */ -tb_object_json_reader_func_t tb_object_json_reader_func(tb_char_t type); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - -#endif - diff --git a/core/pkg/tbox.pkg/inc/tbox/object/reader/prefix.h b/core/pkg/tbox.pkg/inc/tbox/object/reader/prefix.h deleted file mode 100755 index 564d818d8..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/object/reader/prefix.h +++ /dev/null @@ -1,84 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file prefix.h - * @ingroup object - * - */ -#ifndef TB_OBJECT_READER_PREFIX_H -#define TB_OBJECT_READER_PREFIX_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "../prefix.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * macros - */ - -// bytes -#define tb_object_reader_need_bytes(x) \ - (((tb_uint64_t)(x)) < (1ull << 8) ? 1 : \ - (((tb_uint64_t)(x)) < (1ull << 16) ? 2 : \ - (((tb_uint64_t)(x)) < (1ull << 24) ? 3 : \ - (((tb_uint64_t)(x)) < (1ull << 32) ? 4 : 8)))) - -/* ////////////////////////////////////////////////////////////////////////////////////// - * inlines - */ -static __tb_inline__ tb_void_t tb_object_reader_bin_type_size(tb_stream_ref_t stream, tb_size_t* ptype, tb_uint64_t* psize) -{ - // check - tb_assert_and_check_return(stream); - - // the flag - tb_uint8_t flag = tb_stream_bread_u8(stream); - - // the type & size - tb_size_t type = flag >> 4; - tb_uint64_t size = flag & 0x0f; - if (type == 0xf) type = tb_stream_bread_u8(stream); - switch (size) - { - case 0xc: - size = tb_stream_bread_u8(stream); - break; - case 0xd: - size = tb_stream_bread_u16_be(stream); - break; - case 0xe: - size = tb_stream_bread_u32_be(stream); - break; - case 0xf: - size = tb_stream_bread_u64_be(stream); - break; - default: - break; - } - - // trace -// tb_trace("type: %lu, size: %llu", type, size); - - // save - if (ptype) *ptype = type; - if (psize) *psize = size; -} - -#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/object/reader/xplist.h b/core/pkg/tbox.pkg/inc/tbox/object/reader/xplist.h deleted file mode 100755 index 41cb4058b..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/object/reader/xplist.h +++ /dev/null @@ -1,85 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file xplist.h - * @ingroup object - * - */ -#ifndef TB_OBJECT_READER_XPLIST_H -#define TB_OBJECT_READER_XPLIST_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "prefix.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * types - */ - -/// the xplist reader type -typedef struct __tb_object_xplist_reader_t -{ - /// the xplist reader - tb_xml_reader_ref_t reader; - -}tb_object_xplist_reader_t; - -/// the xplist reader func type -typedef tb_object_ref_t (*tb_object_xplist_reader_func_t)(tb_object_xplist_reader_t* reader, tb_size_t event); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! the xplist object reader - * - * @return the xplist object reader - */ -tb_object_reader_t* tb_object_xplist_reader(tb_noarg_t); - -/*! hook the xplist reader - * - * @param type the object type name - * @param func the reader func - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_xplist_reader_hook(tb_char_t const* type, tb_object_xplist_reader_func_t func); - -/*! the xplist reader func - * - * @param type the object type name - * - * @return the object reader func - */ -tb_object_xplist_reader_func_t tb_object_xplist_reader_func(tb_char_t const* type); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - -#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..a3721b777 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/string.h +++ b/core/pkg/tbox.pkg/inc/tbox/object/string.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/writer/bin.h b/core/pkg/tbox.pkg/inc/tbox/object/writer/bin.h deleted file mode 100755 index 097eae520..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/object/writer/bin.h +++ /dev/null @@ -1,100 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file bin.h - * @ingroup object - * - */ -#ifndef TB_OBJECT_WRITER_BIN_H -#define TB_OBJECT_WRITER_BIN_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "prefix.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * types - */ - -/// the object bin writer type -typedef struct __tb_object_bin_writer_t -{ - /// the stream - tb_stream_ref_t stream; - - /// the object hash - tb_hash_ref_t ohash; - - /// the string hash - tb_hash_ref_t shash; - - /// the object index - tb_size_t index; - - /// the encoder data - tb_byte_t* data; - - /// the encoder maxn - tb_size_t maxn; - -}tb_object_bin_writer_t; - -/// the bin writer func type -typedef tb_bool_t (*tb_object_bin_writer_func_t)(tb_object_bin_writer_t* writer, tb_object_ref_t object); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! the bin object writer - * - * @return the bin object writer - */ -tb_object_writer_t* tb_object_bin_writer(tb_noarg_t); - -/*! hook the bin writer - * - * @param type the object type - * @param func the writer func - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_bin_writer_hook(tb_size_t type, tb_object_bin_writer_func_t func); - -/*! the bin writer func - * - * @param type the object type - * - * @return the object writer func - */ -tb_object_bin_writer_func_t tb_object_bin_writer_func(tb_size_t type); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - -#endif - diff --git a/core/pkg/tbox.pkg/inc/tbox/object/writer/json.h b/core/pkg/tbox.pkg/inc/tbox/object/writer/json.h deleted file mode 100755 index ac5eb60c0..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/object/writer/json.h +++ /dev/null @@ -1,88 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file json.h - * @ingroup object - * - */ -#ifndef TB_OBJECT_WRITER_JSON_H -#define TB_OBJECT_WRITER_JSON_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "prefix.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * types - */ - -/// the object json writer type -typedef struct __tb_object_json_writer_t -{ - /// the stream - tb_stream_ref_t stream; - - /// is deflate? - tb_bool_t deflate; - -}tb_object_json_writer_t; - -/// the json writer func type -typedef tb_bool_t (*tb_object_json_writer_func_t)(tb_object_json_writer_t* writer, tb_object_ref_t object, tb_size_t level); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! the json object writer - * - * @return the json object writer - */ -tb_object_writer_t* tb_object_json_writer(tb_noarg_t); - -/*! hook the json writer - * - * @param type the object type - * @param func the writer func - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_json_writer_hook(tb_size_t type, tb_object_json_writer_func_t func); - -/*! the json writer func - * - * @param type the object type - * - * @return the object writer func - */ -tb_object_json_writer_func_t tb_object_json_writer_func(tb_size_t type); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - -#endif - diff --git a/core/pkg/tbox.pkg/inc/tbox/object/writer/prefix.h b/core/pkg/tbox.pkg/inc/tbox/object/writer/prefix.h deleted file mode 100755 index 1fdd5362f..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/object/writer/prefix.h +++ /dev/null @@ -1,124 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file prefix.h - * @ingroup object - * - */ -#ifndef TB_OBJECT_WRITER_PREFIX_H -#define TB_OBJECT_WRITER_PREFIX_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "../prefix.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * macros - */ - -// bytes -#define tb_object_writer_need_bytes(x) \ - (((tb_uint64_t)(x)) < (1ull << 8) ? 1 : \ - (((tb_uint64_t)(x)) < (1ull << 16) ? 2 : \ - (((tb_uint64_t)(x)) < (1ull << 24) ? 3 : \ - (((tb_uint64_t)(x)) < (1ull << 32) ? 4 : 8)))) - -/* ////////////////////////////////////////////////////////////////////////////////////// - * inlines - */ - -static __tb_inline__ tb_bool_t tb_object_writer_tab(tb_stream_ref_t stream, tb_bool_t deflate, tb_size_t tab) -{ - // writ tab - if (!deflate) - { - while (tab--) if (tb_stream_printf(stream, "\t") < 0) return tb_false; - } - - // ok - return tb_true; -} -static __tb_inline__ tb_bool_t tb_object_writer_newline(tb_stream_ref_t stream, tb_bool_t deflate) -{ - // writ newline - if (!deflate && tb_stream_printf(stream, __tb_newline__) < 0) return tb_false; - - // ok - return tb_true; -} -static __tb_inline__ tb_bool_t tb_object_writer_bin_type_size(tb_stream_ref_t stream, tb_size_t type, tb_uint64_t size) -{ - // check - tb_assert_and_check_return_val(stream && type <= 0xff, tb_false); - - // byte for size < 64bits - tb_size_t sizeb = tb_object_writer_need_bytes(size); - tb_assert_and_check_return_val(sizeb <= 8, tb_false); - - // flag for size - tb_size_t sizef = 0; - switch (sizeb) - { - case 1: sizef = 0xc; break; - case 2: sizef = 0xd; break; - case 4: sizef = 0xe; break; - case 8: sizef = 0xf; break; - default: break; - } - tb_assert_and_check_return_val(sizef, tb_false); - - // writ flag - tb_uint8_t flag = ((type < 0xf? (tb_uint8_t)type : 0xf) << 4) | (size < 0xc? (tb_uint8_t)size : (tb_uint8_t)sizef); - if (!tb_stream_bwrit_u8(stream, flag)) return tb_false; - - // trace -// tb_trace("writ: type: %lu, size: %llu", type, size); - - // writ type - if (type >= 0xf) if (!tb_stream_bwrit_u8(stream, (tb_uint8_t)type)) return tb_false; - - // writ size - if (size >= 0xc) - { - switch (sizeb) - { - case 1: - if (!tb_stream_bwrit_u8(stream, (tb_uint8_t)size)) return tb_false; - break; - case 2: - if (!tb_stream_bwrit_u16_be(stream, (tb_uint16_t)size)) return tb_false; - break; - case 4: - if (!tb_stream_bwrit_u32_be(stream, (tb_uint32_t)size)) return tb_false; - break; - case 8: - if (!tb_stream_bwrit_u64_be(stream, (tb_uint64_t)size)) return tb_false; - break; - default: - tb_assert_and_check_return_val(0, tb_false); - break; - } - } - - // ok - return tb_true; -} - -#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/object/writer/writer.h b/core/pkg/tbox.pkg/inc/tbox/object/writer/writer.h deleted file mode 100755 index 98014c41c..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/object/writer/writer.h +++ /dev/null @@ -1,84 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file writer.h - * @ingroup object - * - */ -#ifndef TB_OBJECT_WRITER_H -#define TB_OBJECT_WRITER_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "xml.h" -#include "bin.h" -#include "json.h" -#include "xplist.h" -#include "bplist.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! set object writer - * - * @param format the writer format - * @param writer the writer - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_writer_set(tb_size_t format, tb_object_writer_t* writer); - -/*! del object writer - * - * @param format the writer format - */ -tb_void_t tb_object_writer_del(tb_size_t format); - -/*! get object writer - * - * @param format the writer format - * - * @return the object writer - */ -tb_object_writer_t* tb_object_writer_get(tb_size_t format); - -/*! done writer - * - * @param object the object - * @param stream the stream - * @param format the object format - * - * @return the writed size, failed: -1 - */ -tb_long_t tb_object_writer_done(tb_object_ref_t object, tb_stream_ref_t stream, tb_size_t format); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - - -#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/object/writer/xml.h b/core/pkg/tbox.pkg/inc/tbox/object/writer/xml.h deleted file mode 100755 index ff601f765..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/object/writer/xml.h +++ /dev/null @@ -1,88 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file xml.h - * @ingroup object - * - */ -#ifndef TB_OBJECT_WRITER_XML_H -#define TB_OBJECT_WRITER_XML_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "prefix.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * types - */ - -/// the object xml writer type -typedef struct __tb_object_xml_writer_t -{ - /// the stream - tb_stream_ref_t stream; - - /// is deflate? - tb_bool_t deflate; - -}tb_object_xml_writer_t; - -/// the xml writer func type -typedef tb_bool_t (*tb_object_xml_writer_func_t)(tb_object_xml_writer_t* writer, tb_object_ref_t object, tb_size_t level); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! the xml object writer - * - * @return the xml object writer - */ -tb_object_writer_t* tb_object_xml_writer(tb_noarg_t); - -/*! hook the xml writer - * - * @param type the object type - * @param func the writer func - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_xml_writer_hook(tb_size_t type, tb_object_xml_writer_func_t func); - -/*! the xml writer func - * - * @param type the object type - * - * @return the object writer func - */ -tb_object_xml_writer_func_t tb_object_xml_writer_func(tb_size_t type); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - -#endif - diff --git a/core/pkg/tbox.pkg/inc/tbox/object/writer/xplist.h b/core/pkg/tbox.pkg/inc/tbox/object/writer/xplist.h deleted file mode 100755 index b6a2ad436..000000000 --- a/core/pkg/tbox.pkg/inc/tbox/object/writer/xplist.h +++ /dev/null @@ -1,88 +0,0 @@ -/*!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 - 2015, ruki All rights reserved. - * - * @author ruki - * @file xplist.h - * @ingroup object - * - */ -#ifndef TB_OBJECT_WRITER_XPLIST_H -#define TB_OBJECT_WRITER_XPLIST_H - -/* ////////////////////////////////////////////////////////////////////////////////////// - * includes - */ -#include "prefix.h" - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_enter__ - -/* ////////////////////////////////////////////////////////////////////////////////////// - * types - */ - -/// the object xplist writer type -typedef struct __tb_object_xplist_writer_t -{ - /// the stream - tb_stream_ref_t stream; - - /// is deflate? - tb_bool_t deflate; - -}tb_object_xplist_writer_t; - -/// the xplist writer func type -typedef tb_bool_t (*tb_object_xplist_writer_func_t)(tb_object_xplist_writer_t* writer, tb_object_ref_t object, tb_size_t level); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ - -/*! the xplist object writer - * - * @return the xplist object writer - */ -tb_object_writer_t* tb_object_xplist_writer(tb_noarg_t); - -/*! hook the xplist writer - * - * @param type the object type - * @param func the writer func - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_xplist_writer_hook(tb_size_t type, tb_object_xplist_writer_func_t func); - -/*! the xplist writer func - * - * @param type the object type - * - * @return the object writer func - */ -tb_object_xplist_writer_func_t tb_object_xplist_writer_func(tb_size_t type); - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ - -#endif - diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/atomic.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/atomic.h index 131cd2ed3..131cd2ed3 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/atomic.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed30_arm.h b/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/frame.h index 68ea25f26..4e0b57417 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed30_arm.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/frame.h @@ -17,49 +17,50 @@ * Copyright (C) 2009 - 2015, ruki All rights reserved. * * @author ruki - * @file fixed30_arm.h + * @file frame.h * */ -#ifndef TB_MATH_IMPL_FIXED30_ARM_H -#define TB_MATH_IMPL_FIXED30_ARM_H +#ifndef TB_PLATFORM_ARCH_ARM_FRAME_H +#define TB_PLATFORM_ARCH_ARM_FRAME_H /* ////////////////////////////////////////////////////////////////////////////////////// * includes */ -#include "../prefix.h" +#include "prefix.h" /* ////////////////////////////////////////////////////////////////////////////////////// * macros */ -#ifdef TB_ASSEMBLER_IS_GAS - -#if 0 -# define tb_fixed30_mul(x, y) tb_fixed30_mul_asm(x, y) +// the current stack frame address +#if !defined(TB_CURRENT_STACK_FRAME) \ + && defined(TB_COMPILER_IS_GCC) \ + && TB_COMPILER_VERSION_BE(4, 1) +# define TB_CURRENT_STACK_FRAME (__builtin_frame_address(0) - 12) #endif -#endif /* TB_ASSEMBLER_IS_GAS */ +// the advance stack frame address +#ifndef TB_ADVANCE_STACK_FRAME +# define TB_ADVANCE_STACK_FRAME(next) ((tb_frame_layout_t*)(next) - 1) +#endif /* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces + * types */ -#if defined(TB_ASSEMBLER_IS_GAS) -static __tb_inline__ tb_fixed30_t tb_fixed30_mul_asm(tb_fixed30_t x, tb_fixed30_t y) + +// the frame layout type +typedef struct __tb_frame_layout_t { - __tb_register__ tb_fixed30_t t; - __tb_asm__ __tb_volatile__ - ( - "smull %0, %2, %1, %3 \n" // r64 = (l, h) = x * y - "mov %0, %0, lsr #30 \n" // to fixed30: r64 >>= 30 - "orr %0, %0, %2, lsl #2 \n" // x = l = (h << (32 - 30)) | (l >> 30); + // the next + struct __tb_frame_layout_t* next; - : "=r"(x), "=&r"(y), "=r"(t) - : "r"(x), "1"(y) - ); - return x; -} -#endif + // the sp + tb_pointer_t sp; + // the frame return address + tb_pointer_t return_address; + +}tb_frame_layout_t; -#endif +#endif 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..6e4b9b805 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/arm/prefix.h 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..ea9bc45d8 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/atomic.h 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..5c4542140 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/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..9d029823a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/frame.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/frame.h 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..ead1d4e22 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/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..8ff26d126 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/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..08fdb7c11 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/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..512b06e00 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/frame.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/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..c2d356bde 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x64/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..b708e5d03 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/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..e88531d88 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/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..bdbbcd715 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/frame.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/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..ca366b4b1 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/arch/x86/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..0075668f9 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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..c7e88121d 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/atomic64.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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..733a75dbd 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/backtrace.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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 13712e87d..5054febfe 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/barrier.h @@ -28,7 +28,7 @@ * includes */ #include "prefix.h" -#if defined(TB_CONFIG_OS_MAC) || defined(TB_CONFIG_OS_IOS) +#if defined(TB_CONFIG_OS_MACOSX) || defined(TB_CONFIG_OS_IOS) # include "mach/barrier.h" #elif defined(TB_COMPILER_IS_GCC) \ && TB_COMPILER_VERSION_BE(4, 1) 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..1979c7817 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/cache_time.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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..66eba4d6d 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/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..e4bc06098 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/atomic64.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/atomic64.h 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..06ac42942 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/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..2900ee549 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/gcc/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..c41e8c01d 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/compiler/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/compiler/prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/directory.h b/core/pkg/tbox.pkg/inc/tbox/platform/directory.h index 23df0b329..23df0b329 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/directory.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/directory.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/dns.h b/core/pkg/tbox.pkg/inc/tbox/platform/dns.h index 8fa360c63..8fa360c63 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/dns.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/dns.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..420772d19 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/dynamic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/dynamic.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/environment.h b/core/pkg/tbox.pkg/inc/tbox/platform/environment.h index 238e368af..238e368af 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/environment.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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..48b05e008 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/event.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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..080fb7e21 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/exception.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/exception.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/file.h b/core/pkg/tbox.pkg/inc/tbox/platform/file.h index 0590e47a2..0590e47a2 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/file.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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..f6eb57090 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/hostname.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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 b24acf3b8..b24acf3b8 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/ifaddrs.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/ifaddrs.h 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 a8ffbc1b7..a8ffbc1b7 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/libc/exception.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/libc/exception.h 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..0b9dab421 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/libc/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/libc/prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/linux/android/android.h b/core/pkg/tbox.pkg/inc/tbox/platform/linux/android/android.h new file mode 100644 index 000000000..1d00defb3 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/linux/android/android.h @@ -0,0 +1,52 @@ +/*!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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file android.h + * @ingroup platform + */ +#ifndef TB_PLATFORM_LINUX_ANDROID_H +#define TB_PLATFORM_LINUX_ANDROID_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! init the android platform + * + * @param jenv the jni environment pointer + * + * @return tb_true or tb_false + */ +tb_bool_t tb_android_init(JNIEnv* jenv); + +/// exit the android platform +tb_void_t tb_android_exit(tb_noarg_t); + +/*! the jni environment pointer + * + * @return the environment pointer + */ +JNIEnv* tb_android_jenv(tb_noarg_t); + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/linux/android/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/linux/android/prefix.h new file mode 100644 index 000000000..1208719a8 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/linux/android/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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * @ingroup platform + */ +#ifndef TB_PLATFORM_LINUX_ANDROID_PREFIX_H +#define TB_PLATFORM_LINUX_ANDROID_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" +#include <jni.h> + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/linux/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/linux/prefix.h new file mode 100644 index 000000000..e131be8ad --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/linux/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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * @ingroup platform + */ +#ifndef TB_PLATFORM_LINUX_PREFIX_H +#define TB_PLATFORM_LINUX_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" +#include "../../libc/libc.h" +#include "../../utils/utils.h" + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/ltimer.h b/core/pkg/tbox.pkg/inc/tbox/platform/ltimer.h index 523cd2c0a..523cd2c0a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/ltimer.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/ltimer.h 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..3a54f5ef5 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/mach/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/mach/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 new file mode 100644 index 000000000..d8bdbc6d3 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/mach/ios/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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * @ingroup platform + */ +#ifndef TB_PLATFORM_MACH_IOS_PREFIX_H +#define TB_PLATFORM_MACH_IOS_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/mach/mac/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/mach/mac/prefix.h new file mode 100644 index 000000000..f4e014c91 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/mach/mac/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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * @ingroup platform + */ +#ifndef TB_PLATFORM_MACH_MAC_PREFIX_H +#define TB_PLATFORM_MACH_MAC_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" + +#endif 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..e306ad0da 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/mach/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/mach/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 be46941a8..be46941a8 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/memory.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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..2600463f7 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/mutex.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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 ecdb61458..ecdb61458 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/page.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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..c08eb4f6c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/path.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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 3b759e2f7..3b759e2f7 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/platform.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/platform.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/posix/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/posix/prefix.h new file mode 100644 index 000000000..cf88c8e85 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/posix/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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * @ingroup platform + */ +#ifndef TB_PLATFORM_POSIX_PREFIX_H +#define TB_PLATFORM_POSIX_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../platform.h" +#include "../../libc/libc.h" +#include "../../utils/utils.h" + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/posix/sockaddr.h b/core/pkg/tbox.pkg/inc/tbox/platform/posix/sockaddr.h new file mode 100644 index 000000000..1b18bfaf8 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/posix/sockaddr.h @@ -0,0 +1,204 @@ +/*!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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file sockaddr.h + */ +#ifndef TB_PLATFORM_POSIX_SOCKADDR_H +#define TB_PLATFORM_POSIX_SOCKADDR_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#ifdef TB_CONFIG_OS_WINDOWS +# include "ws2tcpip.h" +#else +# include <netinet/in.h> +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/* save the socket address to the ip address + * + * @param ipaddr the ip address + * @param saddr the socket address + * + * @return the socket address size + */ +static __tb_inline__ tb_size_t tb_sockaddr_save(tb_ipaddr_ref_t ipaddr, struct sockaddr_storage const* saddr) +{ + // check + tb_assert_and_check_return_val(ipaddr && saddr, 0); + + // clear address + tb_ipaddr_clear(ipaddr); + + // done + tb_size_t size = 0; + switch (saddr->ss_family) + { + case AF_INET: + { + // the ipv4 ipaddr + struct sockaddr_in* addr4 = (struct sockaddr_in*)saddr; + + // save family + tb_ipaddr_family_set(ipaddr, TB_IPADDR_FAMILY_IPV4); + + // make ipv4 + tb_ipv4_t ipv4; + ipv4.u32 = (tb_uint32_t)addr4->sin_addr.s_addr; + + // save ipv4 + tb_ipaddr_ipv4_set(ipaddr, &ipv4); + + // save port + tb_ipaddr_port_set(ipaddr, tb_bits_be_to_ne_u16(addr4->sin_port)); + + // save size + size = sizeof(struct sockaddr_in); + } + break; + case AF_INET6: + { + // the ipv6 ipaddr + struct sockaddr_in6* addr6 = (struct sockaddr_in6*)saddr; + + // check + tb_assert_static(sizeof(ipaddr->u.ipv6.addr.u8) == sizeof(addr6->sin6_addr.s6_addr)); + tb_assert_static(tb_arrayn(ipaddr->u.ipv6.addr.u8) == tb_arrayn(addr6->sin6_addr.s6_addr)); + + // save family + tb_ipaddr_family_set(ipaddr, TB_IPADDR_FAMILY_IPV6); + + // save port + tb_ipaddr_port_set(ipaddr, tb_bits_be_to_ne_u16(addr6->sin6_port)); + + // make ipv6 + tb_ipv6_t ipv6; + tb_memcpy(ipv6.addr.u8, addr6->sin6_addr.s6_addr, sizeof(ipv6.addr.u8)); + + // save scope id + ipv6.scope_id = 0; + if (IN6_IS_ADDR_LINKLOCAL(&addr6->sin6_addr) || IN6_IS_ADDR_MC_LINKLOCAL(&addr6->sin6_addr)) + ipv6.scope_id = addr6->sin6_scope_id; + + // save ipv6 + tb_ipaddr_ipv6_set(ipaddr, &ipv6); + + // save size + size = sizeof(struct sockaddr_in6); + } + break; + default: + tb_assert_abort(0); + break; + } + + // ok? + return size; +} + +/* load the ip address to socket address + * + * @param saddr the socket address + * @param ipaddr the ip address + * + * @return the socket address size + */ +static __tb_inline__ tb_size_t tb_sockaddr_load(struct sockaddr_storage* saddr, tb_ipaddr_ref_t ipaddr) +{ + // check + tb_assert_and_check_return_val(saddr && ipaddr, 0); + + // clear address + tb_memset(saddr, 0, sizeof(struct sockaddr_storage)); + + // done + tb_size_t size = 0; + switch (tb_ipaddr_family(ipaddr)) + { + case TB_IPADDR_FAMILY_IPV4: + { + // the ipv4 ipaddr + struct sockaddr_in* addr4 = (struct sockaddr_in*)saddr; + + // save family + addr4->sin_family = AF_INET; + + // save ipv4 + addr4->sin_addr.s_addr = tb_ipaddr_ip_is_any(ipaddr)? INADDR_ANY : ipaddr->u.ipv4.u32; + + // save port + addr4->sin_port = tb_bits_ne_to_be_u16(tb_ipaddr_port(ipaddr)); + + // save size + size = sizeof(struct sockaddr_in); + } + break; + case TB_IPADDR_FAMILY_IPV6: + { + // the ipv6 ipaddr + struct sockaddr_in6* addr6 = (struct sockaddr_in6*)saddr; + + // check + tb_assert_static(sizeof(ipaddr->u.ipv6.addr.u8) == sizeof(addr6->sin6_addr.s6_addr)); + tb_assert_static(tb_arrayn(ipaddr->u.ipv6.addr.u8) == tb_arrayn(addr6->sin6_addr.s6_addr)); + + // save family + addr6->sin6_family = AF_INET6; + + // save ipv6 + if (tb_ipaddr_ip_is_any(ipaddr)) addr6->sin6_addr = in6addr_any; + else tb_memcpy(addr6->sin6_addr.s6_addr, ipaddr->u.ipv6.addr.u8, sizeof(addr6->sin6_addr.s6_addr)); + + // save port + addr6->sin6_port = tb_bits_ne_to_be_u16(tb_ipaddr_port(ipaddr)); + + // save scope id + if (tb_ipv6_is_linklocal(&ipaddr->u.ipv6) || tb_ipv6_is_mc_linklocal(&ipaddr->u.ipv6)) + addr6->sin6_scope_id = ipaddr->u.ipv6.scope_id; + + // save size + size = sizeof(struct sockaddr_in6); + } + break; + default: + tb_assert_abort(0); + break; + } + + // ok? + return size; +} + + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/prefix.h index 0795b9f37..0795b9f37 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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..a7b00e490 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/print.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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 1bc0d09c7..1bc0d09c7 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/process.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/process.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/processor.h b/core/pkg/tbox.pkg/inc/tbox/platform/processor.h index 16ca7360c..16ca7360c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/processor.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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..09ca92f27 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/sched.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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..1eb800ce8 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/semaphore.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/semaphore.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/socket.h b/core/pkg/tbox.pkg/inc/tbox/platform/socket.h index 2f05ca48e..2f05ca48e 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/socket.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/socket.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/spinlock.h b/core/pkg/tbox.pkg/inc/tbox/platform/spinlock.h index 583943c26..583943c26 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/spinlock.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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 new file mode 100644 index 000000000..64c917a0f --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/systemv/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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * @ingroup platform + */ +#ifndef TB_PLATFORM_SYSTEMV_PREFIX_H +#define TB_PLATFORM_SYSTEMV_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../platform.h" +#include "../../libc/libc.h" +#include "../../utils/utils.h" + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/thread.h b/core/pkg/tbox.pkg/inc/tbox/platform/thread.h index e1de62e96..e1de62e96 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/thread.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/thread.h 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..2f8df50dc 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/thread_pool.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/thread_pool.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/thread_store.h b/core/pkg/tbox.pkg/inc/tbox/platform/thread_store.h index 150799caa..150799caa 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/thread_store.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/thread_store.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/time.h b/core/pkg/tbox.pkg/inc/tbox/platform/time.h index bc9009c70..bc9009c70 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/time.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/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 9e18ecd57..9e18ecd57 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/timer.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/timer.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/unix/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/unix/prefix.h new file mode 100644 index 000000000..c5735c89c --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/unix/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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * @ingroup platform + */ +#ifndef TB_PLATFORM_UNIX_PREFIX_H +#define TB_PLATFORM_UNIX_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" +#include "../../libc/libc.h" +#include "../../utils/utils.h" + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/unix/syscall.h b/core/pkg/tbox.pkg/inc/tbox/platform/unix/syscall.h new file mode 100644 index 000000000..ffa028f34 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/unix/syscall.h @@ -0,0 +1,185 @@ +/*!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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file syscall.h + * @ingroup platform + */ +#ifndef TB_PLATFORM_UNIX_SYSCALL_H +#define TB_PLATFORM_UNIX_SYSCALL_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#include <sys/syscall.h> + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ +#ifdef TB_ASSEMBLER_IS_GAS + +// x64 +# if defined(TB_ARCH_x64) +# define tb_syscall1(code, name, type1, arg1) \ + static __tb_inline__ tb_long_t name(type1 arg1) \ + { \ + tb_long_t __ret; \ + __asm__ __volatile__("syscall" : "=a" (__ret) : \ + "0" (code), "D" (arg1)); \ + return __ret; \ + } + +# define tb_syscall2(code, name, type1, arg1, type2, arg2) \ + static __tb_inline__ tb_long_t name(type1 arg1, type2 arg2) \ + { \ + tb_long_t __ret; \ + __asm__ __volatile__("syscall" : "=a" (__ret) : \ + "0" (code), "D" (arg1), "S" (arg2)); \ + return __ret; \ + } + +# define tb_syscall3(code, name, type1, arg1, type2, arg2, type3, arg3) \ + static __tb_inline__ tb_long_t name(type1 arg1, type2 arg2, type3 arg3) \ + { \ + tb_long_t __ret; \ + __asm__ __volatile__("syscall" : "=a" (__ret) : \ + "0" (code), "D" (arg1), "S" (arg2), \ + "d" (arg3) \ + ); \ + return __ret; \ + } + +# define tb_syscall4(code, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ + static __tb_inline__ tb_long_t name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ + { \ + tb_long_t __ret; \ + __asm__ __volatile__("movq %5,%%r10 ; syscall" : "=a" (__ret) : \ + "0" (code), "D" (arg1), "S" (arg2), \ + "d" (arg3), "g" (arg4) \ + ); \ + return __ret; \ + } + +# define tb_syscall5(code, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) \ + static __tb_inline__ tb_long_t name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ + { \ + tb_long_t __ret; \ + __asm__ __volatile__("movq %5,%%r10 ; movq %6,%%r8 ; syscall" : "=a" (__ret) : \ + "0" (code), "D" (arg1), "S" (arg2), \ + "d" (arg3), "g" (arg4), "g" (arg5) \ + ); \ + return __ret; \ + } + +// x86 +# elif defined(TB_ARCH_x86) +# define tb_syscall1(code, name, type1, arg1) \ + static __tb_inline__ tb_long_t name(type1 arg1) \ + { \ + tb_long_t __ret; \ + __asm__ __volatile__("int $0x80" : "=a" (__ret) : \ + "0" (code), "b" (arg1)); \ + return __ret; \ + } + +# define tb_syscall2(code, name, type1, arg1, type2, arg2) \ + static __tb_inline__ tb_long_t name(type1 arg1, type2 arg2) \ + { \ + tb_long_t __ret; \ + __asm__ __volatile__("int $0x80" : "=a" (__ret) : \ + "0" (code), "b" (arg1), "c" (arg2)); \ + return __ret; \ + } + +# define tb_syscall3(code, name, type1, arg1, type2, arg2, type3, arg3) \ + static __tb_inline__ tb_long_t name(type1 arg1, type2 arg2, type3 arg3) \ + { \ + tb_long_t __ret; \ + __asm__ __volatile__("int $0x80" : "=a" (__ret) : \ + "0" (code), "b" (arg1), "c" (arg2), \ + "d" (arg3) \ + ); \ + return __ret; \ + } + +# define tb_syscall4(code, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ + static __tb_inline__ tb_long_t name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ + { \ + tb_long_t __ret; \ + __asm__ __volatile__("int $0x80" : "=a" (__ret) : \ + "0" (code), "b" (arg1), "c" (arg2), \ + "d" (arg3), "S" (arg4) \ + ); \ + return __ret; \ + } + +# define tb_syscall5(code, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) \ + static __tb_inline__ tb_long_t name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ + { \ + tb_long_t __ret; \ + __asm__ __volatile__("int $0x80" : "=a" (__ret) : \ + "0" (code), "b" (arg1), "c" (arg2), \ + "d" (arg3), "S" (arg4), "D" (arg5) \ + ); \ + return __ret; \ + } + +# endif +#endif + +#ifndef tb_syscall1 +# define tb_syscall1(code, name, type1, arg1) \ + static __tb_inline__ tb_long_t name(type1 arg1) \ + { \ + return syscall(code, arg1); \ + } +#endif + +#ifndef tb_syscall2 +# define tb_syscall2(code, name, type1, arg1, type2, arg2) \ + static __tb_inline__ tb_long_t name(type1 arg1, type2 arg2) \ + { \ + return syscall(code, arg1, arg2); \ + } +#endif + +#ifndef tb_syscall3 +# define tb_syscall3(code, name, type1, arg1, type2, arg2, type3, arg3) \ + static __tb_inline__ tb_long_t name(type1 arg1, type2 arg2, type3 arg3) \ + { \ + return syscall(code, arg1, arg2, arg3); \ + } +#endif + +#ifndef tb_syscall4 +# define tb_syscall4(code, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \ + static __tb_inline__ tb_long_t name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ + { \ + return syscall(code, arg1, arg2, arg3, arg4); \ + } +#endif + +#ifndef tb_syscall5 +# define tb_syscall5(code, name, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) \ + static __tb_inline__ tb_long_t name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ + { \ + return syscall(code, arg1, arg2, arg3, arg4, arg5); \ + } +#endif +#endif 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 6d11e832a..6d11e832a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/atomic.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/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..3cf651b98 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/atomic64.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/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..61e27d51c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/barrier.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/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..132d38d17 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/exception.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/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..582082055 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/dbghelp.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/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 24e843258..24e843258 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/interface.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/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..677690f66 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/iphlpapi.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/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 aafd97c91..aafd97c91 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/kernel32.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/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..b791d5c07 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/mswsock.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/mswsock.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..c65ec26ab 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/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..54f3d38ca 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/shell32.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/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..a1875436c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/user32.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/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..d53b99cfb 100755..100644 --- 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 diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/ntstatus.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/ntstatus.h new file mode 100644 index 000000000..c57efe865 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/ntstatus.h @@ -0,0 +1,408 @@ +/*!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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file ntstatus.h + * + */ +#ifndef TB_PLATFORM_WINDOWS_NTSTATUS_H +#define TB_PLATFORM_WINDOWS_NTSTATUS_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +//#include <ntdef.h> + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ + +#ifndef FACILITY_NTWIN32 +# define FACILITY_NTWIN32 (0x7) +#endif + +#ifndef STATUS_SUCCESS +# define STATUS_SUCCESS (0x00000000) +#endif + +#ifndef STATUS_PENDING +# define STATUS_PENDING (0x00000103) +#endif + +#ifndef STATUS_END_OF_FILE +# define STATUS_END_OF_FILE (0xC0000011) +#endif + +#ifndef STATUS_INVALID_HANDLE +# define STATUS_INVALID_HANDLE (0xC0000008) +#endif + +#ifndef STATUS_OBJECT_TYPE_MISMATCH +# define STATUS_OBJECT_TYPE_MISMATCH (0xC0000024) +#endif + +#ifndef STATUS_INSUFFICIENT_RESOURCES +# define STATUS_INSUFFICIENT_RESOURCES (0xC000009A) +#endif + +#ifndef STATUS_PAGEFILE_QUOTA +# define STATUS_PAGEFILE_QUOTA (0xC0000007) +#endif + +#ifndef STATUS_COMMITMENT_LIMIT +# define STATUS_COMMITMENT_LIMIT (0xC000012D) +#endif + +#ifndef STATUS_WORKING_SET_QUOTA +# define STATUS_WORKING_SET_QUOTA (0xC00000A1) +#endif + +#ifndef STATUS_NO_MEMORY +# define STATUS_NO_MEMORY (0xC0000017) +#endif + +#ifndef STATUS_CONFLICTING_ADDRESSES +# define STATUS_CONFLICTING_ADDRESSES (0xC0000018) +#endif + +#ifndef STATUS_QUOTA_EXCEEDED +# define STATUS_QUOTA_EXCEEDED (0xC0000044) +#endif + +#ifndef STATUS_TOO_MANY_PAGING_FILES +# define STATUS_TOO_MANY_PAGING_FILES (0xC0000097) +#endif + +#ifndef STATUS_REMOTE_RESOURCES +# define STATUS_REMOTE_RESOURCES (0xC000013D) +#endif + +#ifndef STATUS_TOO_MANY_ADDRESSES +# define STATUS_TOO_MANY_ADDRESSES (0xC0000209) +#endif + +#ifndef STATUS_SHARING_VIOLATION +# define STATUS_SHARING_VIOLATION (0xC0000043) +#endif + +#ifndef STATUS_HOPLIMIT_EXCEEDED +# define STATUS_HOPLIMIT_EXCEEDED (0xC000A012) +#endif + +#ifndef STATUS_ADDRESS_ALREADY_EXISTS +# define STATUS_ADDRESS_ALREADY_EXISTS (0xC000020A) +#endif + +#ifndef STATUS_LINK_TIMEOUT +# define STATUS_LINK_TIMEOUT (0xC000013F) +#endif + +#ifndef STATUS_IO_TIMEOUT +# define STATUS_IO_TIMEOUT (0xC00000B5) +#endif + +#ifndef STATUS_TIMEOUT +# define STATUS_TIMEOUT (0x00000102) +#endif + +#ifndef STATUS_GRACEFUL_DISCONNECT +# define STATUS_GRACEFUL_DISCONNECT (0xC0000237) +#endif + +#ifndef STATUS_REMOTE_DISCONNECT +# define STATUS_REMOTE_DISCONNECT (0xC000013C) +#endif + +#ifndef STATUS_CONNECTION_RESET +# define STATUS_CONNECTION_RESET (0xC000020D) +#endif + +#ifndef STATUS_LINK_FAILED +# define STATUS_LINK_FAILED (0xC000013E) +#endif + +#ifndef STATUS_CONNECTION_DISCONNECTED +# define STATUS_CONNECTION_DISCONNECTED (0xC000020C) +#endif + +#ifndef STATUS_PORT_UNREACHABLE +# define STATUS_PORT_UNREACHABLE (0xC000023F) +#endif + +#ifndef STATUS_HOPLIMIT_EXCEEDED +# define STATUS_HOPLIMIT_EXCEEDED (0xC000A012) +#endif + +#ifndef STATUS_LOCAL_DISCONNECT +# define STATUS_LOCAL_DISCONNECT (0xC000013B) +#endif + +#ifndef STATUS_FLTRSACTION_ABORTED +//# define STATUS_FLTRSACTION_ABORTED (0x00000000) +#endif + +#ifndef STATUS_CONNECTION_ABORTED +# define STATUS_CONNECTION_ABORTED (0xC0000241) +#endif + +#ifndef STATUS_BAD_NETWORK_PATH +# define STATUS_BAD_NETWORK_PATH (0xC00000BE) +#endif + +#ifndef STATUS_NETWORK_UNREACHABLE +# define STATUS_NETWORK_UNREACHABLE (0xC000023C) +#endif + +#ifndef STATUS_PROTOCOL_UNREACHABLE +# define STATUS_PROTOCOL_UNREACHABLE (0xC000023E) +#endif + +#ifndef STATUS_HOST_UNREACHABLE +# define STATUS_HOST_UNREACHABLE (0xC000023D) +#endif + +#ifndef STATUS_CANCELLED +# define STATUS_CANCELLED (0xC0000120) +#endif + +#ifndef STATUS_REQUEST_ABORTED +# define STATUS_REQUEST_ABORTED (0xC0000240) +#endif + +#ifndef STATUS_BUFFER_OVERFLOW +# define STATUS_BUFFER_OVERFLOW (0x80000005) +#endif + +#ifndef STATUS_INVALID_BUFFER_SIZE +# define STATUS_INVALID_BUFFER_SIZE (0xC0000206) +#endif + +#ifndef STATUS_BUFFER_TOO_SMALL +# define STATUS_BUFFER_TOO_SMALL (0xC0000023) +#endif + +#ifndef STATUS_ACCESS_VIOLATION +# define STATUS_ACCESS_VIOLATION (0xC0000005) +#endif + +#ifndef STATUS_DEVICE_NOT_READY +# define STATUS_DEVICE_NOT_READY (0xC00000A3) +#endif + +#ifndef STATUS_REQUEST_NOT_ACCEPTED +# define STATUS_REQUEST_NOT_ACCEPTED (0xC00000D0) +#endif + +#ifndef STATUS_INVALID_NETWORK_RESPONSE +# define STATUS_INVALID_NETWORK_RESPONSE (0xC00000C3) +#endif + +#ifndef STATUS_NETWORK_BUSY +# define STATUS_NETWORK_BUSY (0xC00000BF) +#endif + +#ifndef STATUS_NO_SUCH_DEVICE +# define STATUS_NO_SUCH_DEVICE (0xC000000E) +#endif + +#ifndef STATUS_NO_SUCH_FILE +# define STATUS_NO_SUCH_FILE (0xC000000F) +#endif + +#ifndef STATUS_OBJECT_PATH_NOT_FOUND +# define STATUS_OBJECT_PATH_NOT_FOUND (0xC000003A) +#endif + +#ifndef STATUS_OBJECT_NAME_NOT_FOUND +# define STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034) +#endif + +#ifndef STATUS_UNEXPECTED_NETWORK_ERROR +# define STATUS_UNEXPECTED_NETWORK_ERROR (0xC00000C4) +#endif + +#ifndef STATUS_INVALID_CONNECTION +# define STATUS_INVALID_CONNECTION (0xC0000140) +#endif + +#ifndef STATUS_REMOTE_NOT_LISTENING +# define STATUS_REMOTE_NOT_LISTENING (0xC00000BC) +#endif + +#ifndef STATUS_CONNECTION_REFUSED +# define STATUS_CONNECTION_REFUSED (0xC0000236) +#endif + +#ifndef STATUS_PIPE_DISCONNECTED +# define STATUS_PIPE_DISCONNECTED (0xC00000B0) +#endif + +#ifndef STATUS_INVALID_ADDRESS +# define STATUS_INVALID_ADDRESS (0xC0000141) +#endif + +#ifndef STATUS_INVALID_ADDRESS_COMPONENT +# define STATUS_INVALID_ADDRESS_COMPONENT (0xC0000207) +#endif + +#ifndef STATUS_NOT_SUPPORTED +# define STATUS_NOT_SUPPORTED (0xC00000BB) +#endif + +#ifndef STATUS_NOT_IMPLEMENTED +# define STATUS_NOT_IMPLEMENTED (0xC0000002) +#endif + +#ifndef STATUS_ACCESS_DENIED +# define STATUS_ACCESS_DENIED (0xC0000022) +#endif + +#ifndef STATUS_INVALID_DEVICE_STATE +# define STATUS_INVALID_DEVICE_STATE (0xC0000184) +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * inlines + */ + +static __tb_inline__ tb_size_t tb_ntstatus_to_winerror(tb_size_t status) +{ + switch (status) + { + case STATUS_SUCCESS: + return ERROR_SUCCESS; + + case STATUS_PENDING: + return ERROR_IO_PENDING; + + case STATUS_END_OF_FILE: + return ERROR_HANDLE_EOF; + + case STATUS_INVALID_HANDLE: + case STATUS_OBJECT_TYPE_MISMATCH: + return WSAENOTSOCK; + + case STATUS_INSUFFICIENT_RESOURCES: + case STATUS_PAGEFILE_QUOTA: + case STATUS_COMMITMENT_LIMIT: + case STATUS_WORKING_SET_QUOTA: + case STATUS_NO_MEMORY: + case STATUS_CONFLICTING_ADDRESSES: + case STATUS_QUOTA_EXCEEDED: + case STATUS_TOO_MANY_PAGING_FILES: + case STATUS_REMOTE_RESOURCES: + case STATUS_TOO_MANY_ADDRESSES: + return WSAENOBUFS; + + case STATUS_SHARING_VIOLATION: + case STATUS_ADDRESS_ALREADY_EXISTS: + return WSAEADDRINUSE; + + case STATUS_LINK_TIMEOUT: + case STATUS_IO_TIMEOUT: + case STATUS_TIMEOUT: + return WSAETIMEDOUT; + + case STATUS_GRACEFUL_DISCONNECT: + return WSAEDISCON; + + case STATUS_REMOTE_DISCONNECT: + case STATUS_CONNECTION_RESET: + case STATUS_LINK_FAILED: + case STATUS_CONNECTION_DISCONNECTED: + case STATUS_PORT_UNREACHABLE: + case STATUS_HOPLIMIT_EXCEEDED: + case STATUS_INVALID_DEVICE_STATE: + return WSAECONNRESET; + + case STATUS_LOCAL_DISCONNECT: +// case STATUS_FLTRSACTION_ABORTED: + case STATUS_CONNECTION_ABORTED: + return WSAECONNABORTED; + + case STATUS_BAD_NETWORK_PATH: + case STATUS_NETWORK_UNREACHABLE: + case STATUS_PROTOCOL_UNREACHABLE: + return WSAENETUNREACH; + + case STATUS_HOST_UNREACHABLE: + return WSAEHOSTUNREACH; + + case STATUS_CANCELLED: + case STATUS_REQUEST_ABORTED: + return WSAEINTR; + + case STATUS_BUFFER_OVERFLOW: + case STATUS_INVALID_BUFFER_SIZE: + return WSAEMSGSIZE; + + case STATUS_BUFFER_TOO_SMALL: + case STATUS_ACCESS_VIOLATION: + return WSAEFAULT; + + case STATUS_DEVICE_NOT_READY: + case STATUS_REQUEST_NOT_ACCEPTED: + return WSAEWOULDBLOCK; + + case STATUS_INVALID_NETWORK_RESPONSE: + case STATUS_NETWORK_BUSY: + case STATUS_NO_SUCH_DEVICE: + case STATUS_NO_SUCH_FILE: + case STATUS_OBJECT_PATH_NOT_FOUND: + case STATUS_OBJECT_NAME_NOT_FOUND: + case STATUS_UNEXPECTED_NETWORK_ERROR: + return WSAENETDOWN; + + case STATUS_INVALID_CONNECTION: + return WSAENOTCONN; + + case STATUS_REMOTE_NOT_LISTENING: + case STATUS_CONNECTION_REFUSED: + return WSAECONNREFUSED; + + case STATUS_PIPE_DISCONNECTED: + return WSAESHUTDOWN; + + case STATUS_INVALID_ADDRESS: + case STATUS_INVALID_ADDRESS_COMPONENT: + return WSAEADDRNOTAVAIL; + + case STATUS_NOT_SUPPORTED: + case STATUS_NOT_IMPLEMENTED: + return WSAEOPNOTSUPP; + + case STATUS_ACCESS_DENIED: + return WSAEACCES; + + default: + if ( (status & (FACILITY_NTWIN32 << 16)) == (FACILITY_NTWIN32 << 16) + && (status & (ERROR_SEVERITY_ERROR | ERROR_SEVERITY_WARNING))) + { + return (tb_size_t) (status & 0xffff); + } + else + { + tb_trace_e("ntstatus: unknown: %lx", status); + return WSAEINVAL; + } + } +} + + +#endif 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 d14a6fea8..d14a6fea8 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/hostmac.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/socket_pool.h index 3fa82d063..ff8fde64a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/platform/hostmac.h +++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/socket_pool.h @@ -17,17 +17,18 @@ * Copyright (C) 2009 - 2015, ruki All rights reserved. * * @author ruki - * @file hostmac.h + * @file socket_pool.h * @ingroup platform * */ -#ifndef TB_PLATFORM_HOSTMAC_H -#define TB_PLATFORM_HOSTMAC_H +#ifndef TB_PLATFORM_WINDOWS_SOCKET_POOL_H +#define TB_PLATFORM_WINDOWS_SOCKET_POOL_H /* ////////////////////////////////////////////////////////////////////////////////////// * includes */ #include "prefix.h" +#include "../socket.h" /* ////////////////////////////////////////////////////////////////////////////////////// * extern @@ -38,19 +39,34 @@ __tb_extern_c_enter__ * interfaces */ -/*! get the host mac address for the given network interface name +/*! init socket pool * - * @param interface_name the network interface name, using the first ethernet address if be null - * @param mac_address the raw mac address + * @return tb_true or tb_false + */ +tb_bool_t tb_socket_pool_init(tb_noarg_t); + +/*! exit socket pool + * + */ +tb_void_t tb_socket_pool_exit(tb_noarg_t); + +/*! put socket to the socket pool * - * @return tb_true or tb_false + * @param sock the tcp socket + * + * @return tb_true or tb_false */ -tb_bool_t tb_hostmac(tb_char_t const* interface_name, tb_byte_t mac_address[6]); +tb_bool_t tb_socket_pool_put(tb_socket_ref_t sock); + +/*! get socket from the socket pool + * + * @return the tcp socket + */ +tb_socket_ref_t tb_socket_pool_get(tb_noarg_t); /* ////////////////////////////////////////////////////////////////////////////////////// * extern */ __tb_extern_c_leave__ - #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix.h b/core/pkg/tbox.pkg/inc/tbox/prefix.h index c72e3af69..c72e3af69 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/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 a882013f9..a882013f9 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/abort.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/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 8364dceb6..8364dceb6 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/arch.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/arch.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/asm.h b/core/pkg/tbox.pkg/inc/tbox/prefix/asm.h index 7480e805d..7480e805d 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/asm.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/asm.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/asm/arm/prefix.S b/core/pkg/tbox.pkg/inc/tbox/prefix/asm/arm/prefix.S index d815dcbb7..e8c3981ac 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/asm/arm/prefix.S +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/asm/arm/prefix.S @@ -17,131 +17,41 @@ * Copyright (C) 2009 - 2015, ruki All rights reserved. * * @author ruki - * @file prefix.S + * @file algorithm.h + * @defgroup algorithm * */ +#ifndef TB_ALGORITHM_H +#define TB_ALGORITHM_H /* ////////////////////////////////////////////////////////////////////////////////////// * includes */ #include "prefix.h" +#include "predicate.h" +#include "distance.h" +#include "for.h" +#include "for_if.h" +#include "rfor.h" +#include "rfor_if.h" +#include "sort.h" +#include "heap_sort.h" +#include "quick_sort.h" +#include "insert_sort.h" +#include "bubble_sort.h" +#include "find.h" +#include "find_if.h" +#include "rfind.h" +#include "rfind_if.h" +#include "binary_find.h" +#include "binary_find_if.h" +#include "walk.h" +#include "rwalk.h" +#include "count.h" +#include "count_if.h" +#include "remove.h" +#include "remove_if.h" +#include "remove_first.h" +#include "remove_first_if.h" -/* ////////////////////////////////////////////////////////////////////////////////////// - * macros - */ - -#ifdef TB_ARCH_ARM_THUMB -# define A @ -# define T -#else -# define A -# define T @ -#endif - -#ifdef TB_ARCH_ELF -# define ELF -# define EXTERN_ASM -#else -# define ELF @ -# define EXTERN_ASM _ -#endif - -/* ////////////////////////////////////////////////////////////////////////////////////// - * arch - */ - -#if 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 - */ -#ifndef TB_ARCH_ARM64 - .syntax unified -#endif - -/* ////////////////////////////////////////////////////////////////////////////////////// - * thumb - */ - -// will crash -//T .thumb - -/* ////////////////////////////////////////////////////////////////////////////////////// - * eabi - */ -#ifndef TB_ARCH_ARM64 -ELF .eabi_attribute 25, 1 -#endif - -/* ////////////////////////////////////////////////////////////////////////////////////// - * macros - */ - -/*! function - * - * @code - function func_xxxx, export=1 - ... - bx lr - endfunc - @endcode - */ -.macro function name, export=0 - .macro endfunc -ELF .size \name, . - \name - .endfunc - .purgem endfunc - .endm - - .text -#ifdef TB_ARCH_ARM64 - .align 8 -#else - .align 4 -#endif - .if \export - .global EXTERN_ASM\name -EXTERN_ASM\name: - .endif -ELF .type \name, %function - .func \name -\name: -.endm - -/*! label - * - * @code - label name - xxx - xxx - bl name - @endcode - */ -.macro label name -#ifdef TB_ARCH_ARM64 - .align 8 -#else - .align 4 #endif -\name: -.endm diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/asm/arm/prefix.h b/core/pkg/tbox.pkg/inc/tbox/prefix/asm/arm/prefix.h index 58d8a6e9f..58d8a6e9f 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/asm/arm/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/asm/arm/prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/asm/asm.h b/core/pkg/tbox.pkg/inc/tbox/prefix/asm/asm.h index f3c6bbfa4..f3c6bbfa4 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/asm/asm.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/asm/asm.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/asm/cache.h b/core/pkg/tbox.pkg/inc/tbox/prefix/asm/cache.h index 9ffa51d6d..9ffa51d6d 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/asm/cache.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/asm/cache.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/asm/prefix.S b/core/pkg/tbox.pkg/inc/tbox/prefix/asm/prefix.S index 574675b8a..6a6f0b5f5 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/asm/prefix.S +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/asm/prefix.S @@ -16,16 +16,50 @@ * * Copyright (C) 2009 - 2015, ruki All rights reserved. * - * @author ruki - * @file prefix.S + * @author ruki + * @file binary_find.h + * @ingroup algorithm * */ +#ifndef TB_ALGORITHM_BINARY_FIND_H +#define TB_ALGORITHM_BINARY_FIND_H /* ////////////////////////////////////////////////////////////////////////////////////// * includes */ -#include "asm.h" -#if defined(TB_ARCH_ARM) -# include "arm/prefix.S" -#endif +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/*! binary find item + * + * @param iterator the iterator + * @param head the iterator head + * @param tail the iterator tail + * @param item the finded item + * + * @return the iterator itor, return tb_iterator_tail(iterator) if not found + */ +tb_size_t tb_binary_find(tb_iterator_ref_t iterator, tb_size_t head, tb_size_t tail, tb_cpointer_t item); +/*!binary find item for all + * + * @param iterator the iterator + * @param item the finded item + * + * @return the iterator itor, return tb_iterator_tail(iterator) if not found + */ +tb_size_t tb_binary_find_all(tb_iterator_ref_t iterator, tb_cpointer_t item); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/asm/prefix.h b/core/pkg/tbox.pkg/inc/tbox/prefix/asm/prefix.h index d211e155e..d211e155e 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/asm/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/asm/prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/assembler.h b/core/pkg/tbox.pkg/inc/tbox/prefix/assembler.h index 8f55841a3..8f55841a3 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/assembler.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/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 cf42f6770..cf42f6770 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/assert.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/assert.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/check.h b/core/pkg/tbox.pkg/inc/tbox/prefix/check.h index b64aacd55..b64aacd55 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/check.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/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 ed7c9df6e..aab9863e5 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/compiler.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/compiler.h @@ -303,6 +303,7 @@ # pragma warning(disable:4018) # pragma warning(disable:4197) # pragma warning(disable:4141) +# pragma warning(disable:4996) #else # define TB_COMPILER_STRING "unknown compiler" diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/config.h b/core/pkg/tbox.pkg/inc/tbox/prefix/config.h index d8b62dcb3..d8b62dcb3 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/config.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/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 1ce3717de..1ce3717de 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/cpu.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/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..04ce3c8db 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/endian.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/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 4264229f8..683ec43ff 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/keyword.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/keyword.h @@ -128,7 +128,7 @@ // small #undef __tb_small__ -#if TB_CONFIG_SMALL +#ifdef TB_CONFIG_SMALL # define __tb_small__ #endif diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/limits.h b/core/pkg/tbox.pkg/inc/tbox/prefix/limits.h index 7bc322f8c..7bc322f8c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/limits.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/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 b20c0fd71..b20c0fd71 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/malloc.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/malloc.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/packed.h b/core/pkg/tbox.pkg/inc/tbox/prefix/packed.h index 815c294bb..815c294bb 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/packed.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/packed.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..db4bf42f3 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/state.h b/core/pkg/tbox.pkg/inc/tbox/prefix/state.h index 658f43dac..658f43dac 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/state.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/state.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/trace.h b/core/pkg/tbox.pkg/inc/tbox/prefix/trace.h index 15fcbf4a4..15fcbf4a4 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/trace.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/trace.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/type.h b/core/pkg/tbox.pkg/inc/tbox/prefix/type.h index 0c742b914..d8b08ee95 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/type.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/type.h @@ -48,7 +48,7 @@ // check config #if !defined(TB_CONFIG_TYPE_SCALAR_IS_FIXED) \ - && !defined(TB_CONFIG_TYPE_FLOAT) + && !defined(TB_CONFIG_TYPE_HAVE_FLOAT) # define TB_CONFIG_TYPE_SCALAR_IS_FIXED #endif @@ -87,7 +87,9 @@ typedef tb_pointer_t tb_handle_t; #endif // wchar -#ifdef TB_CONFIG_OS_WINDOWS +#ifdef TB_CONFIG_TYPE_HAVE_WCHAR + typedef wchar_t tb_wchar_t; +#elif defined(TB_CONFIG_OS_WINDOWS) # if defined(_WCHAR_T_DEFINED) || defined(_NATIVE_WCHAR_T_DEFINED) typedef wchar_t tb_wchar_t; # else @@ -126,7 +128,7 @@ typedef unsigned long tb_ulong_t; typedef tb_ulong_t tb_size_t; // double -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT typedef float tb_float_t; typedef double tb_double_t; #endif @@ -308,7 +310,7 @@ typedef union __tb_value_t /// async stream tb_async_stream_ref_t astream; -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /// float tb_float_t f; diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/utils.h b/core/pkg/tbox.pkg/inc/tbox/prefix/utils.h index 51c4e35b5..51c4e35b5 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/utils.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/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..9d066993f 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/version.h +++ b/core/pkg/tbox.pkg/inc/tbox/prefix/version.h diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/async_stream.h b/core/pkg/tbox.pkg/inc/tbox/stream/async_stream.h index 4f7517d66..4f7517d66 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/stream/async_stream.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/async_stream.h diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/async_transfer.h b/core/pkg/tbox.pkg/inc/tbox/stream/async_transfer.h index 525820a59..525820a59 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/stream/async_transfer.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/async_transfer.h diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/filter.h b/core/pkg/tbox.pkg/inc/tbox/stream/filter.h index f6c1535e2..f6c1535e2 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/stream/filter.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/filter.h diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/prefix.h b/core/pkg/tbox.pkg/inc/tbox/stream/prefix.h index c2891bcbb..c2891bcbb 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/stream/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/prefix.h 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 378690253..0a4952540 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/stream/static_stream.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/static_stream.h @@ -79,7 +79,7 @@ __tb_extern_c_enter__ #endif -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT # ifdef TB_FLOAT_BIGENDIAN # define tb_static_stream_read_double_nbe(stream) tb_static_stream_read_double_bbe(stream) # define tb_static_stream_read_double_nle(stream) tb_static_stream_read_double_ble(stream) @@ -679,7 +679,7 @@ tb_bool_t tb_static_stream_writ_u64_le(tb_static_stream_ref_t stream, */ tb_bool_t tb_static_stream_writ_s64_le(tb_static_stream_ref_t stream, tb_sint64_t val); -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! read float-le number * diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/stream.h b/core/pkg/tbox.pkg/inc/tbox/stream/stream.h index cd4a24ecf..1cf448447 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/stream/stream.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/stream.h @@ -145,7 +145,7 @@ __tb_extern_c_enter__ #endif -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT # ifdef TB_FLOAT_BIGENDIAN # define tb_stream_bread_double_nbe(stream) tb_stream_bread_double_bbe(stream) # define tb_stream_bread_double_nle(stream) tb_stream_bread_double_ble(stream) @@ -974,7 +974,7 @@ tb_bool_t tb_stream_bwrit_u64_be(tb_stream_ref_t stream, tb_uint64 */ tb_bool_t tb_stream_bwrit_s64_be(tb_stream_ref_t stream, tb_sint64_t val); -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! read float-le number * diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/transfer.h b/core/pkg/tbox.pkg/inc/tbox/stream/transfer.h index f82a23308..f82a23308 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/stream/transfer.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/transfer.h diff --git a/core/pkg/tbox.pkg/inc/tbox/stream/transfer_pool.h b/core/pkg/tbox.pkg/inc/tbox/stream/transfer_pool.h index a251b099c..a251b099c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/stream/transfer_pool.h +++ b/core/pkg/tbox.pkg/inc/tbox/stream/transfer_pool.h diff --git a/core/pkg/tbox.pkg/inc/tbox/string/prefix.h b/core/pkg/tbox.pkg/inc/tbox/string/prefix.h index baa78f413..baa78f413 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/string/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/string/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..8f97aeacb 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/string/static_string.h +++ b/core/pkg/tbox.pkg/inc/tbox/string/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..f59bb04ae 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/string/string.h +++ b/core/pkg/tbox.pkg/inc/tbox/string/string.h diff --git a/core/pkg/tbox.pkg/inc/tbox/tbox.h b/core/pkg/tbox.pkg/inc/tbox/tbox.h index 926b584b9..926b584b9 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/tbox.h +++ b/core/pkg/tbox.pkg/inc/tbox/tbox.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/base32.h b/core/pkg/tbox.pkg/inc/tbox/utils/base32.h index 912139a89..912139a89 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/base32.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/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..957dd0910 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/base64.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/base64.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/bits.h b/core/pkg/tbox.pkg/inc/tbox/utils/bits.h index 86810f1ad..5ba791c87 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/bits.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/bits.h @@ -122,7 +122,7 @@ __tb_extern_c_enter__ #define tb_bits_set_s64_ne_impl(p, x) tb_bits_set_u64_ne_impl(p, x) // float -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT # define tb_bits_get_float_le(p) tb_bits_get_float_le_inline(p) # define tb_bits_get_float_be(p) tb_bits_get_float_be_inline(p) @@ -747,7 +747,7 @@ static __tb_inline__ tb_size_t tb_bits_cb1_u64_inline(tb_uint64_t x) return (tb_size_t)x; } -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /* ////////////////////////////////////////////////////////////////////////////////////// * float */ @@ -968,7 +968,7 @@ static __tb_inline__ tb_void_t tb_bits_set_double_lle_inline(tb_byte_t* p, tb_do } -#endif /* TB_CONFIG_TYPE_FLOAT */ +#endif /* TB_CONFIG_TYPE_HAVE_FLOAT */ /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/crc.h b/core/pkg/tbox.pkg/inc/tbox/utils/crc.h index 7fab11e13..7fab11e13 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/crc.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/crc.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/dump.h b/core/pkg/tbox.pkg/inc/tbox/utils/dump.h index 07f254673..07f254673 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/dump.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/dump.h 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 de8c1615e..de8c1615e 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_arm.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/impl/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 97bd3fbe8..97bd3fbe8 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_gcc.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/impl/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 58c99e1e4..58c99e1e4 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_sh4.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/impl/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 587da75ce..587da75ce 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_x86.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/impl/bits_x86.h diff --git a/core/pkg/tbox.pkg/inc/tbox/network/addr.h b/core/pkg/tbox.pkg/inc/tbox/utils/impl/crc_arm.h index 11840ea4a..9908bfb5a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/network/addr.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/impl/crc_arm.h @@ -17,41 +17,29 @@ * Copyright (C) 2009 - 2015, ruki All rights reserved. * * @author ruki - * @file addr.h - * @ingroup network + * @file crc_arm.h * */ -#ifndef TB_NETWORK_ADDR_H -#define TB_NETWORK_ADDR_H +#ifndef TB_UTILS_IMPL_CRC_ARM_H +#define TB_UTILS_IMPL_CRC_ARM_H /* ////////////////////////////////////////////////////////////////////////////////////// * includes */ -#include "prefix.h" +#include "../prefix.h" /* ////////////////////////////////////////////////////////////////////////////////////// - * extern + * macros */ -__tb_extern_c_enter__ +#ifndef TB_ARCH_ARM64 +# define tb_crc32_encode(crc, ib, in, table) tb_crc32_encode_asm(crc, ib, in, table) +#endif /* ////////////////////////////////////////////////////////////////////////////////////// - * types + * interfaces */ +tb_uint32_t tb_crc32_encode_asm(tb_uint32_t crc, tb_byte_t const* ib, tb_size_t in, tb_uint32_t const* table); -/// the addr4 type -typedef struct __tb_addr4_t -{ - /// the ipv4 - tb_ipv4_t ipv4; - - /// the port - tb_uint16_t port; - -}tb_addr4_t, *tb_addr4_ref_t; - -/* ////////////////////////////////////////////////////////////////////////////////////// - * extern - */ -__tb_extern_c_leave__ #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 new file mode 100644 index 000000000..0f32a6b68 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/utils/impl/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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file prefix.h + * + */ +#ifndef TB_UTILS_IMPL_PREFIX_H +#define TB_UTILS_IMPL_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" + + + +#endif 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..657d5ee31 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/lock_profiler.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/lock_profiler.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/md5.h b/core/pkg/tbox.pkg/inc/tbox/utils/md5.h index 3503712cf..3503712cf 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/md5.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/md5.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/option.h b/core/pkg/tbox.pkg/inc/tbox/utils/option.h index 17742aac5..f1c67cc5e 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/option.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/option.h @@ -224,7 +224,7 @@ tb_uint64_t tb_option_item_uint64(tb_option_ref_t option, tb_char_t */ tb_sint64_t tb_option_item_sint64(tb_option_ref_t option, tb_char_t const* name); -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! the option item - float * diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/prefix.h b/core/pkg/tbox.pkg/inc/tbox/utils/prefix.h index c9bbc618f..c9bbc618f 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/sha.h b/core/pkg/tbox.pkg/inc/tbox/utils/sha.h index 845dd5c64..845dd5c64 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/sha.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/sha.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/singleton.h b/core/pkg/tbox.pkg/inc/tbox/utils/singleton.h index 72e41713a..72e41713a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/singleton.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/singleton.h diff --git a/core/pkg/tbox.pkg/inc/tbox/utils/trace.h b/core/pkg/tbox.pkg/inc/tbox/utils/trace.h index ffdd0efd3..ffdd0efd3 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/trace.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/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..e8b671152 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/url.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/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..624ce2acd 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/used.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/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 8cc4b6d9c..8cc4b6d9c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/utils/utils.h +++ b/core/pkg/tbox.pkg/inc/tbox/utils/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..23da09d11 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/xml/node.h +++ b/core/pkg/tbox.pkg/inc/tbox/xml/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..eddf8bca1 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/xml/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/xml/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 df67e03b3..df67e03b3 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/xml/reader.h +++ b/core/pkg/tbox.pkg/inc/tbox/xml/reader.h diff --git a/core/pkg/tbox.pkg/inc/tbox/xml/writer.h b/core/pkg/tbox.pkg/inc/tbox/xml/writer.h index 5d1607204..8541ba03e 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/xml/writer.h +++ b/core/pkg/tbox.pkg/inc/tbox/xml/writer.h @@ -170,7 +170,7 @@ tb_void_t tb_xml_writer_attributes_cstr(tb_xml_writer_ref_t writer */ tb_void_t tb_xml_writer_attributes_format(tb_xml_writer_ref_t writer, tb_char_t const* name, tb_char_t const* format, ...); -#ifdef TB_CONFIG_TYPE_FLOAT +#ifdef TB_CONFIG_TYPE_HAVE_FLOAT /*! writ the xml attribute for float value * * @param writer the xml writer diff --git a/core/pkg/tbox.pkg/inc/tbox/xml/xml.h b/core/pkg/tbox.pkg/inc/tbox/xml/xml.h index 4c0214775..4c0214775 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/xml/xml.h +++ b/core/pkg/tbox.pkg/inc/tbox/xml/xml.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/reader/reader.h b/core/pkg/tbox.pkg/inc/tbox/zip/gzip.h index cc0aaba63..e614e1a5f 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/reader/reader.h +++ b/core/pkg/tbox.pkg/inc/tbox/zip/gzip.h @@ -17,21 +17,20 @@ * Copyright (C) 2009 - 2015, ruki All rights reserved. * * @author ruki - * @file reader.h - * @ingroup object + * @file gzip.h + * @ingroup zip * */ -#ifndef TB_OBJECT_READER_H -#define TB_OBJECT_READER_H +#ifndef TB_ZIP_GZIP_H +#define TB_ZIP_GZIP_H /* ////////////////////////////////////////////////////////////////////////////////////// * includes */ -#include "xml.h" -#include "bin.h" -#include "json.h" -#include "xplist.h" -#include "bplist.h" +#include "prefix.h" +#ifdef TB_CONFIG_PACKAGE_HAVE_ZLIB +# include "zlib/zlib.h" +#endif /* ////////////////////////////////////////////////////////////////////////////////////// * extern @@ -39,39 +38,39 @@ __tb_extern_c_enter__ /* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces + * types */ -/*! set object reader - * - * @param format the reader format - * @param reader the reader - * - * @return tb_true or tb_false - */ -tb_bool_t tb_object_reader_set(tb_size_t format, tb_object_reader_t* reader); +// the gzip zip type +typedef struct __tb_zip_gzip_t +{ + // the zip base + tb_zip_t base; -/*! del object reader - * - * @param format the reader format + // the zstream +#ifdef TB_CONFIG_PACKAGE_HAVE_ZLIB + z_stream zstream; +#endif + +}tb_zip_gzip_t; + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces */ -tb_void_t tb_object_reader_del(tb_size_t format); -/*! get object reader +/* init gzip * - * @param format the reader format + * @param action the action * - * @return the object reader + * @return the zip */ -tb_object_reader_t* tb_object_reader_get(tb_size_t format); +tb_zip_ref_t tb_zip_gzip_init(tb_size_t action); -/*! done reader - * - * @param stream the stream +/* exit gzip * - * @return the object + * @param zip the zip */ -tb_object_ref_t tb_object_reader_done(tb_stream_ref_t stream); +tb_void_t tb_zip_gzip_exit(tb_zip_ref_t zip); /* ////////////////////////////////////////////////////////////////////////////////////// * extern @@ -79,3 +78,4 @@ tb_object_ref_t tb_object_reader_done(tb_stream_ref_t stream); __tb_extern_c_leave__ #endif + diff --git a/core/pkg/tbox.pkg/inc/tbox/zip/lzsw.h b/core/pkg/tbox.pkg/inc/tbox/zip/lzsw.h new file mode 100644 index 000000000..d1a28d738 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/zip/lzsw.h @@ -0,0 +1,167 @@ +/*!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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file lzsw.h + * @ingroup zip + * + */ +#ifndef TB_STREAM_ZSTREAM_LZSW_H +#define TB_STREAM_ZSTREAM_LZSW_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ + +// vlc +#define TB_LZSW_VLC_TYPE_FIXED (0) +#define TB_LZSW_VLC_TYPE_GAMMA (1) +#define TB_LZSW_VLC_TYPE_GOLOMB (0) + +// window +//#define TB_LZSW_WINDOW_SIZE_MAX (256) +//#define TB_LZSW_WINDOW_SIZE_MAX (4096) +#define TB_LZSW_WINDOW_SIZE_MAX (65536) +//#define TB_LZSW_WINDOW_SIZE_MAX (8) + +#define TB_LZSW_WINDOW_HASH_FIND (1) +#define TB_LZSW_WINDOW_HASH_MAX (768) // (256 + 256 + 256) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +#if TB_LZSW_WINDOW_HASH_FIND +// the node type +typedef struct __tb_lzsw_node_t +{ + // the signature + tb_byte_t sign[4]; + + // the circle offset + tb_size_t coff; + + // the global address + tb_byte_t const* addr; + + // the next & prev + tb_size_t prev; + tb_size_t next; + +}tb_lzsw_node_t; +#endif + +// the inflate window type +typedef struct __tb_lzsw_inflate_window_t +{ + // the window rage + tb_byte_t const* we; + tb_size_t wn; + + // the window bits + tb_size_t wb; + tb_size_t mb; + +}tb_lzsw_inflate_window_t; + + +// the deflate window type +typedef struct __tb_lzsw_deflate_window_t +{ + // the window rage + tb_byte_t const* we; + tb_size_t wn; + + // the window bits + tb_size_t wb; + tb_size_t mb; + +#if TB_LZSW_WINDOW_HASH_FIND + // the circle base + tb_size_t base; + + // the window hash + tb_pointer_t pool; + tb_size_t hash[TB_LZSW_WINDOW_HASH_MAX]; +#endif + +}tb_lzsw_deflate_window_t; + + +// the lzsw inflate zstream type +typedef struct __tb_lzsw_inflate_stream_filter_zip_t +{ + // the stream base + tb_inflate_stream_filter_zip_t base; + + // the reference to vlc + tb_stream_filter_zip_vlc_t* vlc; + + // the window + tb_lzsw_inflate_window_t window; + +}tb_lzsw_inflate_stream_filter_zip_t; + +// the lzsw deflate zstream type +typedef struct __tb_lzsw_deflate_stream_filter_zip_t +{ + // the stream base + tb_deflate_stream_filter_zip_t base; + + // the reference to vlc + tb_stream_filter_zip_vlc_t* vlc; + + // the window + tb_lzsw_deflate_window_t window; + +}tb_lzsw_deflate_stream_filter_zip_t; + + +// the lzsw zstream type +typedef union __tb_lzsw_stream_filter_zip_t +{ + tb_lzsw_inflate_stream_filter_zip_t infst; + tb_lzsw_deflate_stream_filter_zip_t defst; + +}tb_lzsw_stream_filter_zip_t; + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +tb_stream_filter_t* tb_stream_filter_zip_open_lzsw_inflate(tb_lzsw_inflate_stream_filter_zip_t* zst); +tb_stream_filter_t* tb_stream_filter_zip_open_lzsw_deflate(tb_lzsw_deflate_stream_filter_zip_t* zst); +tb_stream_filter_t* tb_stream_filter_zip_open_lzsw(tb_lzsw_stream_filter_zip_t* zst, tb_size_t action); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif + diff --git a/core/pkg/tbox.pkg/inc/tbox/zip/prefix.h b/core/pkg/tbox.pkg/inc/tbox/zip/prefix.h index b4d16270c..b4d16270c 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/zip/prefix.h +++ b/core/pkg/tbox.pkg/inc/tbox/zip/prefix.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/writer/bplist.h b/core/pkg/tbox.pkg/inc/tbox/zip/rlc.h index 7ff9e69cb..adaec0ce6 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/writer/bplist.h +++ b/core/pkg/tbox.pkg/inc/tbox/zip/rlc.h @@ -17,12 +17,12 @@ * Copyright (C) 2009 - 2015, ruki All rights reserved. * * @author ruki - * @file bplist.h - * @ingroup object + * @file rlc.h + * @ingroup zip * */ -#ifndef TB_OBJECT_WRITER_BPLIST_H -#define TB_OBJECT_WRITER_BPLIST_H +#ifndef TB_ZIP_RLC_H +#define TB_ZIP_RLC_H /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -35,46 +35,41 @@ __tb_extern_c_enter__ /* ////////////////////////////////////////////////////////////////////////////////////// + * macros + */ + +// vlc +#define TB_ZIP_RLC_VLC_TYPE_FIXED (0) +#define TB_ZIP_RLC_VLC_TYPE_GAMMA (1) +#define TB_ZIP_RLC_VLC_TYPE_GOLOMB (0) + +/* ////////////////////////////////////////////////////////////////////////////////////// * types */ -/// the object bplist writer type -typedef struct __tb_object_bplist_writer_t +// the rlc zip type +typedef struct __tb_zip_rlc_t { - /// the stream - tb_stream_ref_t stream; + // the zip base + tb_zip_t base; -}tb_object_bplist_writer_t; + // the reference to vlc + tb_zip_vlc_t* vlc; -/// the bplist writer func type -typedef tb_bool_t (*tb_object_bplist_writer_func_t)(tb_object_bplist_writer_t* writer, tb_object_ref_t object, tb_size_t item_size); + // the last byte + tb_byte_t last; -/* ////////////////////////////////////////////////////////////////////////////////////// - * interfaces - */ + // the repeat size + tb_size_t repeat; -/*! the bplist object writer - * - * @return the bplist object writer - */ -tb_object_writer_t* tb_object_bplist_writer(tb_noarg_t); +}tb_zip_rlc_t; -/*! hook the bplist writer - * - * @param type the object type - * @param func the writer func - * - * @return tb_true or tb_false +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces */ -tb_bool_t tb_object_bplist_writer_hook(tb_size_t type, tb_object_bplist_writer_func_t func); -/*! the bplist writer func - * - * @param type the object type - * - * @return the object writer func - */ -tb_object_bplist_writer_func_t tb_object_bplist_writer_func(tb_size_t type); +tb_zip_ref_t tb_zip_rlc_init(tb_size_t action); +tb_void_t tb_zip_rlc_exit(tb_zip_ref_t zip); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/zip/vlc.h b/core/pkg/tbox.pkg/inc/tbox/zip/vlc.h index b0e23f339..b0e23f339 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/zip/vlc.h +++ b/core/pkg/tbox.pkg/inc/tbox/zip/vlc.h diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/prefix.S b/core/pkg/tbox.pkg/inc/tbox/zip/vlc/prefix.h index c459b12a9..4fb7ae046 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/prefix/prefix.S +++ b/core/pkg/tbox.pkg/inc/tbox/zip/vlc/prefix.h @@ -16,13 +16,16 @@ * * Copyright (C) 2009 - 2015, ruki All rights reserved. * - * @author ruki - * @file prefix.S + * @author ruki + * @file prefix.h * */ +#ifndef TB_ZIP_VLC_PREFIX_H +#define TB_ZIP_VLC_PREFIX_H /* ////////////////////////////////////////////////////////////////////////////////////// * includes */ -#include "asm/prefix.S" +#include "../prefix.h" +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/zip/zip.h b/core/pkg/tbox.pkg/inc/tbox/zip/zip.h index 04d8a145a..04d8a145a 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/zip/zip.h +++ b/core/pkg/tbox.pkg/inc/tbox/zip/zip.h diff --git a/core/pkg/tbox.pkg/inc/tbox/object/reader/xml.h b/core/pkg/tbox.pkg/inc/tbox/zip/zlib.h index 3a6b568ca..f6b2ae730 100755..100644 --- a/core/pkg/tbox.pkg/inc/tbox/object/reader/xml.h +++ b/core/pkg/tbox.pkg/inc/tbox/zip/zlib.h @@ -17,17 +17,20 @@ * Copyright (C) 2009 - 2015, ruki All rights reserved. * * @author ruki - * @file xml.h - * @ingroup object + * @file zlib.h + * @ingroup zip * */ -#ifndef TB_OBJECT_READER_XML_H -#define TB_OBJECT_READER_XML_H +#ifndef TB_ZIP_ZLIB_H +#define TB_ZIP_ZLIB_H /* ////////////////////////////////////////////////////////////////////////////////////// * includes */ #include "prefix.h" +#ifdef TB_CONFIG_PACKAGE_HAVE_ZLIB +# include "zlib/zlib.h" +#endif /* ////////////////////////////////////////////////////////////////////////////////////// * extern @@ -38,43 +41,36 @@ __tb_extern_c_enter__ * types */ -/// the xml reader type -typedef struct __tb_object_xml_reader_t +// the zlib zip type +typedef struct __tb_zip_zlib_t { - /// the xml reader - tb_xml_reader_ref_t reader; + // the zip base + tb_zip_t base; -}tb_object_xml_reader_t; + // the zstream +#ifdef TB_CONFIG_PACKAGE_HAVE_ZLIB + z_stream zstream; +#endif -/// the xml reader func type -typedef tb_object_ref_t (*tb_object_xml_reader_func_t)(tb_object_xml_reader_t* reader, tb_size_t event); +}tb_zip_zlib_t; /* ////////////////////////////////////////////////////////////////////////////////////// * interfaces */ -/*! the xml object reader - * - * @return the xml object reader - */ -tb_object_reader_t* tb_object_xml_reader(tb_noarg_t); - -/*! hook the xml reader +/* init zlib * - * @param type the object type name - * @param func the reader func + * @param action the action * - * @return tb_true or tb_false + * @return the zip */ -tb_bool_t tb_object_xml_reader_hook(tb_char_t const* type, tb_object_xml_reader_func_t func); +tb_zip_ref_t tb_zip_zlib_init(tb_size_t action); -/*! the xml reader func - * - * @param type the object type name +/* exit zlib * - * @return the object reader func + * @param zip the zip */ -tb_object_xml_reader_func_t tb_object_xml_reader_func(tb_char_t const* type); +tb_void_t tb_zip_zlib_exit(tb_zip_ref_t zip); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/core/pkg/tbox.pkg/inc/tbox/zip/zlibraw.h b/core/pkg/tbox.pkg/inc/tbox/zip/zlibraw.h new file mode 100644 index 000000000..805f7c50b --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/zip/zlibraw.h @@ -0,0 +1,81 @@ +/*!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 - 2015, ruki All rights reserved. + * + * @author ruki + * @file zlibraw.h + * @ingroup zip + * + */ +#ifndef TB_ZIP_ZLIBRAW_H +#define TB_ZIP_ZLIBRAW_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" +#ifdef TB_CONFIG_PACKAGE_HAVE_ZLIB +# include "zlib/zlib.h" +#endif + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +// the zlibraw zip type +typedef struct __tb_zip_zlibraw_t +{ + // the zip base + tb_zip_t base; + + // the zstream +#ifdef TB_CONFIG_PACKAGE_HAVE_ZLIB + z_stream zstream; +#endif + +}tb_zip_zlibraw_t; + +/* ////////////////////////////////////////////////////////////////////////////////////// + * interfaces + */ + +/* init zlibraw + * + * @param action the action + * + * @return the zip + */ +tb_zip_ref_t tb_zip_zlibraw_init(tb_size_t action); + +/* exit zlibraw + * + * @param zip the zip + */ +tb_void_t tb_zip_zlibraw_exit(tb_zip_ref_t zip); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#endif + diff --git a/core/pkg/tbox.pkg/lib/msvc/x86/tboxd.pdb b/core/pkg/tbox.pkg/lib/msvc/x86/tboxd.pdb Binary files differdeleted file mode 100644 index cac9103b7..000000000 --- a/core/pkg/tbox.pkg/lib/msvc/x86/tboxd.pdb +++ /dev/null diff --git a/core/pkg/tbox.pkg/lib/msvc/x86/tboxr.pdb b/core/pkg/tbox.pkg/lib/msvc/x86/tboxr.pdb Binary files differdeleted file mode 100644 index cbff71939..000000000 --- a/core/pkg/tbox.pkg/lib/msvc/x86/tboxr.pdb +++ /dev/null diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index 0898f9807..7c53cbd20 100755 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -251,7 +251,7 @@ xm_machine_ref_t xm_machine_init() // init host #if defined(TB_CONFIG_OS_WINDOWS) lua_pushstring(impl->lua, "windows"); -#elif defined(TB_CONFIG_OS_MAC) +#elif defined(TB_CONFIG_OS_MACOSX) lua_pushstring(impl->lua, "macosx"); #elif defined(TB_CONFIG_OS_LINUX) lua_pushstring(impl->lua, "linux"); diff --git a/core/src/xmake/os/setenv.c b/core/src/xmake/os/setenv.c index 1dcf125ce..13fb991e2 100755 --- a/core/src/xmake/os/setenv.c +++ b/core/src/xmake/os/setenv.c @@ -81,7 +81,7 @@ tb_int_t xm_os_setenv(lua_State* lua) tb_size_t size = tb_min(p - b, sizeof(data) - 1); // copy it - tb_strlcpy(data, b, size); + tb_strncpy(data, b, size); data[size] = '\0'; // have been not inserted? diff --git a/core/src/xmake/path/translate.c b/core/src/xmake/path/translate.c index 7b53662ea..e1a573032 100755 --- a/core/src/xmake/path/translate.c +++ b/core/src/xmake/path/translate.c @@ -46,8 +46,7 @@ tb_int_t xm_path_translate(lua_State* lua) // copy path tb_char_t data[TB_PATH_MAXN]; - tb_strlcpy(data, path, sizeof(data) - 1); - data[sizeof(data) - 1] = '\0'; + tb_strlcpy(data, path, sizeof(data)); // done path:translate() lua_pushstring(lua, tb_path_translate(data, 0, sizeof(data) - 1)? data : tb_null); diff --git a/xmake/scripts/base/project.lua b/xmake/scripts/base/project.lua index 85f652f2f..c020e7190 100644 --- a/xmake/scripts/base/project.lua +++ b/xmake/scripts/base/project.lua @@ -481,7 +481,7 @@ function project._makeconf_for_target(target_name, target) i = i + 1 if i > 3 then break end end - file:write(string.format("#define %s_VERSION_BUILD %d\n", prefix, os.date("%Y%m%d%H%M", os.time()))) + file:write(string.format("#define %s_VERSION_BUILD %s\n", prefix, os.date("%Y%m%d%H%M", os.time()))) file:write("\n") end |
