Permalink
Browse files

Initial commit (1726 compatible, with "any" workaround)

  • Loading branch information...
rajkosto committed Sep 12, 2012
0 parents commit 20a0d23272a688750c58a4ba39100d873e5faee4
Showing with 26,176 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +1 −0 Dependencies10/.gitignore
  3. +38 −0 Dependencies10/MySQL/include/mysql/atomic/gcc_builtins.h
  4. +115 −0 Dependencies10/MySQL/include/mysql/atomic/generic-msvc.h
  5. +48 −0 Dependencies10/MySQL/include/mysql/atomic/nolock.h
  6. +57 −0 Dependencies10/MySQL/include/mysql/atomic/rwlock.h
  7. +69 −0 Dependencies10/MySQL/include/mysql/atomic/x86-gcc.h
  8. +49 −0 Dependencies10/MySQL/include/mysql/base64.h
  9. +392 −0 Dependencies10/MySQL/include/mysql/config-win.h
  10. +107 −0 Dependencies10/MySQL/include/mysql/decimal.h
  11. +103 −0 Dependencies10/MySQL/include/mysql/errmsg.h
  12. +84 −0 Dependencies10/MySQL/include/mysql/hash.h
  13. +153 −0 Dependencies10/MySQL/include/mysql/keycache.h
  14. +260 −0 Dependencies10/MySQL/include/mysql/lf.h
  15. +654 −0 Dependencies10/MySQL/include/mysql/m_ctype.h
  16. +393 −0 Dependencies10/MySQL/include/mysql/m_string.h
  17. +65 −0 Dependencies10/MySQL/include/mysql/my_aes.h
  18. +58 −0 Dependencies10/MySQL/include/mysql/my_alarm.h
  19. +51 −0 Dependencies10/MySQL/include/mysql/my_alloc.h
  20. +254 −0 Dependencies10/MySQL/include/mysql/my_atomic.h
  21. +63 −0 Dependencies10/MySQL/include/mysql/my_attribute.h
  22. +626 −0 Dependencies10/MySQL/include/mysql/my_base.h
  23. +109 −0 Dependencies10/MySQL/include/mysql/my_bit.h
  24. +182 −0 Dependencies10/MySQL/include/mysql/my_bitmap.h
  25. +57 −0 Dependencies10/MySQL/include/mysql/my_charsets.h
  26. +295 −0 Dependencies10/MySQL/include/mysql/my_config.h
  27. +295 −0 Dependencies10/MySQL/include/mysql/my_config.h.in
  28. +140 −0 Dependencies10/MySQL/include/mysql/my_dbug.h
  29. +109 −0 Dependencies10/MySQL/include/mysql/my_dir.h
  30. +86 −0 Dependencies10/MySQL/include/mysql/my_getopt.h
  31. +1,616 −0 Dependencies10/MySQL/include/mysql/my_global.h
  32. +27 −0 Dependencies10/MySQL/include/mysql/my_libwrap.h
  33. +45 −0 Dependencies10/MySQL/include/mysql/my_list.h
  34. +54 −0 Dependencies10/MySQL/include/mysql/my_md5.h
  35. +114 −0 Dependencies10/MySQL/include/mysql/my_net.h
  36. +50 −0 Dependencies10/MySQL/include/mysql/my_no_pthread.h
  37. +52 −0 Dependencies10/MySQL/include/mysql/my_nosys.h
  38. +734 −0 Dependencies10/MySQL/include/mysql/my_pthread.h
  39. +66 −0 Dependencies10/MySQL/include/mysql/my_stacktrace.h
  40. +1,082 −0 Dependencies10/MySQL/include/mysql/my_sys.h
  41. +172 −0 Dependencies10/MySQL/include/mysql/my_time.h
  42. +96 −0 Dependencies10/MySQL/include/mysql/my_tree.h
  43. +141 −0 Dependencies10/MySQL/include/mysql/my_trie.h
  44. +1,479 −0 Dependencies10/MySQL/include/mysql/my_uctype.h
  45. +38 −0 Dependencies10/MySQL/include/mysql/my_vle.h
  46. +89 −0 Dependencies10/MySQL/include/mysql/my_xml.h
  47. +238 −0 Dependencies10/MySQL/include/mysql/myisampack.h
  48. +755 −0 Dependencies10/MySQL/include/mysql/mysql.h
  49. +617 −0 Dependencies10/MySQL/include/mysql/mysql.h.pp
  50. +543 −0 Dependencies10/MySQL/include/mysql/mysql_com.h
  51. +55 −0 Dependencies10/MySQL/include/mysql/mysql_time.h
  52. +26 −0 Dependencies10/MySQL/include/mysql/mysql_version.h
  53. +26 −0 Dependencies10/MySQL/include/mysql/mysql_version.h.in
  54. +730 −0 Dependencies10/MySQL/include/mysql/mysqld_error.h
  55. +41 −0 Dependencies10/MySQL/include/mysql/mysys/rijndael.h
  56. +90 −0 Dependencies10/MySQL/include/mysql/mysys_err.h
  57. +72 −0 Dependencies10/MySQL/include/mysql/queues.h
  58. +24 −0 Dependencies10/MySQL/include/mysql/service_versions.h
  59. +66 −0 Dependencies10/MySQL/include/mysql/sha1.h
  60. +72 −0 Dependencies10/MySQL/include/mysql/sha2.h
  61. +50 −0 Dependencies10/MySQL/include/mysql/sql_common.h
  62. +28 −0 Dependencies10/MySQL/include/mysql/sslopt-case.h
  63. +45 −0 Dependencies10/MySQL/include/mysql/sslopt-longopts.h
  64. +31 −0 Dependencies10/MySQL/include/mysql/sslopt-vars.h
  65. +254 −0 Dependencies10/MySQL/include/mysql/t_ctype.h
  66. +110 −0 Dependencies10/MySQL/include/mysql/thr_alarm.h
  67. +181 −0 Dependencies10/MySQL/include/mysql/thr_lock.h
  68. +39 −0 Dependencies10/MySQL/include/mysql/typelib.h
  69. +222 −0 Dependencies10/MySQL/include/mysql/violite.h
  70. +130 −0 Dependencies10/MySQL/include/mysql/waiting_threads.h
  71. +27 −0 Dependencies10/MySQL/include/mysql/wqueue.h
  72. BIN Dependencies10/MySQL/lib/x86/debug/libmysql.dll
  73. BIN Dependencies10/MySQL/lib/x86/debug/libmysql.exp
  74. BIN Dependencies10/MySQL/lib/x86/debug/libmysql.ilk
  75. BIN Dependencies10/MySQL/lib/x86/debug/libmysql.lib
  76. BIN Dependencies10/MySQL/lib/x86/debug/libmysql.pdb
  77. BIN Dependencies10/MySQL/lib/x86/debug/mysqlclient.lib
  78. BIN Dependencies10/MySQL/lib/x86/debug/mysqlclient.pdb
  79. BIN Dependencies10/MySQL/lib/x86/release/libmysql.dll
  80. BIN Dependencies10/MySQL/lib/x86/release/libmysql.exp
  81. BIN Dependencies10/MySQL/lib/x86/release/libmysql.ilk
  82. BIN Dependencies10/MySQL/lib/x86/release/libmysql.lib
  83. BIN Dependencies10/MySQL/lib/x86/release/libmysql.pdb
  84. BIN Dependencies10/MySQL/lib/x86/release/mysqlclient.lib
  85. BIN Dependencies10/MySQL/lib/x86/release/mysqlclient.pdb
  86. +1 −0 Dependencies10/poco/.gitignore
  87. +2 −0 Dependencies10/poco/INSTRUCTIONS.TXT
  88. +1 −0 Dependencies10/tbb/.gitignore
  89. +5 −0 Dependencies10/tbb/INSTRUCTIONS.TXT
  90. +2 −0 Hive/.gitignore
  91. +5 −0 Hive/Binaries/.gitignore
  92. +340 −0 Hive/Binaries/COPYING
  93. +68 −0 Hive/Binaries/HiveExt.ini
  94. +41 −0 Hive/Binaries/Restarter.ini
  95. +11 −0 Hive/Binaries/makedlllinks.bat
  96. BIN Hive/SQF/pbo/1725/dayz_server.pbo
  97. BIN Hive/SQF/pbo/1726/dayz_server.pbo
  98. +1 −0 Hive/SQF/pbo/README.TXT
  99. +6 −0 Hive/SQF/src/README.TXT
  100. +1 −0 Hive/SQF/src/dayz_server/$PBOPREFIX$
  101. +23 −0 Hive/SQF/src/dayz_server/compile/server_gutObject.sqf
  102. 0 Hive/SQF/src/dayz_server/compile/server_onPlayerConnect.sqf
  103. +37 −0 Hive/SQF/src/dayz_server/compile/server_onPlayerDisconnect.sqf
  104. +45 −0 Hive/SQF/src/dayz_server/compile/server_playerDied.sqf
  105. +120 −0 Hive/SQF/src/dayz_server/compile/server_playerLogin.sqf
  106. +247 −0 Hive/SQF/src/dayz_server/compile/server_playerSetup.sqf
  107. +4 −0 Hive/SQF/src/dayz_server/compile/server_playerStat.sqf
  108. +194 −0 Hive/SQF/src/dayz_server/compile/server_playerSync.sqf
  109. +29 −0 Hive/SQF/src/dayz_server/compile/server_publishObject.sqf
  110. +14 −0 Hive/SQF/src/dayz_server/compile/server_routinePlayerCheck.sqf
  111. +24 −0 Hive/SQF/src/dayz_server/compile/server_townDeZombify.sqf
  112. +68 −0 Hive/SQF/src/dayz_server/compile/server_townZombify.sqf
  113. +118 −0 Hive/SQF/src/dayz_server/compile/server_updateObject.sqf
  114. 0 Hive/SQF/src/dayz_server/compile/server_updatePlayer.sqf
  115. +46 −0 Hive/SQF/src/dayz_server/compile/zombie_findOwner.sqf
  116. +176 −0 Hive/SQF/src/dayz_server/init/server_functions.sqf
  117. +13 −0 Hive/SQF/src/dayz_server/system/s_fps.sqf
  118. +393 −0 Hive/SQF/src/dayz_server/system/server_cleanup.fsm
  119. +201 −0 Hive/SQF/src/dayz_server/system/server_monitor.sqf
  120. +180 −0 Hive/SQF/src/dayz_server/system/server_monitor.sqf.bak
  121. +55 −0 Hive/SQL/char_tables.sql
  122. +47 −0 Hive/SQL/obj_sample_data.sql
  123. +22 −0 Hive/SQL/obj_tables.sql
  124. +1 −0 Hive/Source/.gitignore
  125. +11 −0 Hive/Source/ConsoleApp.Debug.props
  126. +12 −0 Hive/Source/ConsoleApp.Generic.props
  127. +11 −0 Hive/Source/ConsoleApp.Release.props
  128. +36 −0 Hive/Source/Database/Callback.h
  129. +106 −0 Hive/Source/Database/Database.h
  130. +132 −0 Hive/Source/Database/Database.vcxproj
  131. +72 −0 Hive/Source/Database/Database.vcxproj.filters
  132. +3 −0 Hive/Source/Database/Database.vcxproj.user
  133. +81 −0 Hive/Source/Database/Field.h
  134. +574 −0 Hive/Source/Database/Implementation/ConcreteDatabase.cpp
  135. +192 −0 Hive/Source/Database/Implementation/ConcreteDatabase.h
  136. +823 −0 Hive/Source/Database/Implementation/DatabaseMysql.cpp
  137. +137 −0 Hive/Source/Database/Implementation/DatabaseMysql.h
  138. +34 −0 Hive/Source/Database/Implementation/MySQLDelayThread.cpp
  139. +33 −0 Hive/Source/Database/Implementation/MySQLDelayThread.h
  140. +103 −0 Hive/Source/Database/Implementation/QueryResultMysql.cpp
  141. +47 −0 Hive/Source/Database/Implementation/QueryResultMysql.h
  142. +107 −0 Hive/Source/Database/Implementation/SqlConnection.cpp
  143. +92 −0 Hive/Source/Database/Implementation/SqlConnection.h
  144. +71 −0 Hive/Source/Database/Implementation/SqlDelayThread.cpp
  145. +53 −0 Hive/Source/Database/Implementation/SqlDelayThread.h
  146. +106 −0 Hive/Source/Database/Implementation/SqlOperations.cpp
  147. +102 −0 Hive/Source/Database/Implementation/SqlOperations.h
  148. +106 −0 Hive/Source/Database/Implementation/SqlPreparedStatement.cpp
  149. +82 −0 Hive/Source/Database/Implementation/SqlPreparedStatement.h
  150. +47 −0 Hive/Source/Database/Implementation/SqlStatementImpl.cpp
  151. +81 −0 Hive/Source/Database/Implementation/SqlStatementImpl.h
  152. +28 −0 Hive/Source/Database/Manifest.cpp
  153. +79 −0 Hive/Source/Database/QueryResult.h
  154. +354 −0 Hive/Source/Database/SqlStatement.h
  155. +12 −0 Hive/Source/DynamicLib.Common.props
  156. +18 −0 Hive/Source/DynamicLib.Debug.props
  157. +18 −0 Hive/Source/DynamicLib.Release.props
  158. +24 −0 Hive/Source/Executable.Common.props
  159. +11 −0 Hive/Source/Executable.Debug.props
  160. +11 −0 Hive/Source/Executable.Release.props
  161. +24 −0 Hive/Source/Generic.Common.props
  162. +16 −0 Hive/Source/Generic.Debug.props
  163. +17 −0 Hive/Source/Generic.Release.props
  164. +52 −0 Hive/Source/Hive.sln
  165. +80 −0 Hive/Source/HiveExt/DirectHiveApp.cpp
  166. +33 −0 Hive/Source/HiveExt/DirectHiveApp.h
  167. +132 −0 Hive/Source/HiveExt/HiveExt.vcxproj
  168. +10 −0 Hive/Source/HiveExt/HiveExt.vcxproj.filters
  169. +17 −0 Hive/Source/HiveExt/HiveExt.vcxproj.user
  170. +57 −0 Hive/Source/HiveExt/Main.cpp
  171. +1 −0 Hive/Source/HiveLib/.gitignore
  172. +84 −0 Hive/Source/HiveLib/DataSource/CharDataSource.cpp
  173. +35 −0 Hive/Source/HiveLib/DataSource/CharDataSource.h
  174. +31 −0 Hive/Source/HiveLib/DataSource/DataSource.h
  175. +35 −0 Hive/Source/HiveLib/DataSource/ObjDataSource.h
  176. +398 −0 Hive/Source/HiveLib/DataSource/SqlCharDataSource.cpp
  177. +39 −0 Hive/Source/HiveLib/DataSource/SqlCharDataSource.h
  178. +33 −0 Hive/Source/HiveLib/DataSource/SqlDataSource.h
  179. +249 −0 Hive/Source/HiveLib/DataSource/SqlObjDataSource.cpp
  180. +42 −0 Hive/Source/HiveLib/DataSource/SqlObjDataSource.h
  181. +182 −0 Hive/Source/HiveLib/ExtStartup.cpp
  182. +38 −0 Hive/Source/HiveLib/ExtStartup.h
  183. +429 −0 Hive/Source/HiveLib/HiveExtApp.cpp
  184. +79 −0 Hive/Source/HiveLib/HiveExtApp.h
  185. +123 −0 Hive/Source/HiveLib/HiveLib.vcxproj
  186. +47 −0 Hive/Source/HiveLib/HiveLib.vcxproj.filters
  187. +3 −0 Hive/Source/HiveLib/HiveLib.vcxproj.user
  188. +345 −0 Hive/Source/HiveLib/Sqf.cpp
  189. +49 −0 Hive/Source/HiveLib/Sqf.h
  190. +4 −0 Hive/Source/HiveLib/Version.cpp.template
  191. +22 −0 Hive/Source/HiveLib/Version.h
  192. +6 −0 Hive/Source/HiveLib/version_gen.sh
  193. +16 −0 Hive/Source/Poco.props
  194. +614 −0 Hive/Source/Restarter/Main.cpp
  195. +99 −0 Hive/Source/Restarter/Restarter.vcxproj
  196. +6 −0 Hive/Source/Restarter/Restarter.vcxproj.filters
  197. +13 −0 Hive/Source/Restarter/Restarter.vcxproj.user
  198. +64 −0 Hive/Source/Shared/Common/Exception.h
  199. +45 −0 Hive/Source/Shared/Common/Pimpl.h
  200. +54 −0 Hive/Source/Shared/Common/PimplImpl.h
  201. +28 −0 Hive/Source/Shared/Common/Singleton.h
  202. +23 −0 Hive/Source/Shared/Common/SingletonImpl.h
  203. +57 −0 Hive/Source/Shared/Common/Timer.cpp
  204. +56 −0 Hive/Source/Shared/Common/Timer.h
  205. +68 −0 Hive/Source/Shared/Common/Types.h
  206. +121 −0 Hive/Source/Shared/Library/Database/DatabaseLoader.cpp
  207. +38 −0 Hive/Source/Shared/Library/Database/DatabaseLoader.h
  208. +48 −0 Hive/Source/Shared/Library/SharedLibraryLoader.h
  209. +74 −0 Hive/Source/Shared/Policy/Allocator.cpp
  210. +122 −0 Hive/Source/Shared/Server/AppServer.cpp
  211. +37 −0 Hive/Source/Shared/Server/AppServer.h
  212. +114 −0 Hive/Source/Shared/Shared.vcxproj
  213. +66 −0 Hive/Source/Shared/Shared.vcxproj.filters
  214. +3 −0 Hive/Source/Shared/Shared.vcxproj.user
  215. +13 −0 Hive/Source/StaticLib.Common.props
  216. +11 −0 Hive/Source/StaticLib.Debug.props
  217. +11 −0 Hive/Source/StaticLib.Release.props
  218. +15 −0 Hive/Source/TBB.props
  219. +55 −0 README
@@ -0,0 +1,3 @@
+*.suo
+*.sdf
+*.opensdf
@@ -0,0 +1 @@
+*.user
@@ -0,0 +1,38 @@
+/* Copyright (C) 2008 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#define MY_ATOMIC_MODE "atomic_builtins"
+
+#define make_atomic_add_body(S) \
+ v= __sync_fetch_and_add(a, v);
+#define make_atomic_swap_body(S) \
+ v= __sync_lock_test_and_set(a, v);
+#define make_atomic_cas_body(S) \
+ int ## S sav; \
+ sav= __sync_val_compare_and_swap(a, *cmp, set); \
+ if (!(ret= (sav == *cmp))) *cmp= sav;
+
+#ifdef MY_ATOMIC_MODE_DUMMY
+#define make_atomic_load_body(S) ret= *a
+#define make_atomic_store_body(S) *a= v
+#define MY_ATOMIC_MODE "gcc-builtins-up"
+
+#else
+#define MY_ATOMIC_MODE "gcc-builtins-smp"
+#define make_atomic_load_body(S) \
+ ret= __sync_fetch_and_or(a, 0);
+#define make_atomic_store_body(S) \
+ (void) __sync_lock_test_and_set(a, v);
+#endif
@@ -0,0 +1,115 @@
+/* Copyright (C) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef _atomic_h_cleanup_
+#define _atomic_h_cleanup_ "atomic/generic-msvc.h"
+
+/*
+ We don't implement anything specific for MY_ATOMIC_MODE_DUMMY, always use
+ intrinsics.
+ 8 and 16-bit atomics are not implemented, but it can be done if necessary.
+*/
+
+/*
+ x86 compilers (both VS2003 or VS2005) never use instrinsics, but generate
+ function calls to kernel32 instead, even in the optimized build.
+ We force intrinsics as described in MSDN documentation for
+ _InterlockedCompareExchange.
+*/
+#ifdef _M_IX86
+
+#if (_MSC_VER >= 1500)
+#include <intrin.h>
+#else
+C_MODE_START
+/*Visual Studio 2003 and earlier do not have prototypes for atomic intrinsics*/
+LONG _InterlockedExchange (LONG volatile *Target,LONG Value);
+LONG _InterlockedCompareExchange (LONG volatile *Target, LONG Value, LONG Comp);
+LONG _InterlockedExchangeAdd (LONG volatile *Addend, LONG Value);
+C_MODE_END
+
+#pragma intrinsic(_InterlockedExchangeAdd)
+#pragma intrinsic(_InterlockedCompareExchange)
+#pragma intrinsic(_InterlockedExchange)
+#endif
+
+#define InterlockedExchange _InterlockedExchange
+#define InterlockedExchangeAdd _InterlockedExchangeAdd
+#define InterlockedCompareExchange _InterlockedCompareExchange
+/*
+ No need to do something special for InterlockedCompareExchangePointer
+ as it is a #define to InterlockedCompareExchange. The same applies to
+ InterlockedExchangePointer.
+*/
+#endif /*_M_IX86*/
+
+#define MY_ATOMIC_MODE "msvc-intrinsics"
+#define IL_EXCHG_ADD32(X,Y) InterlockedExchangeAdd((volatile LONG *)(X),(Y))
+#define IL_COMP_EXCHG32(X,Y,Z) InterlockedCompareExchange((volatile LONG *)(X),(Y),(Z))
+#define IL_COMP_EXCHGptr InterlockedCompareExchangePointer
+#define IL_EXCHG32(X,Y) InterlockedExchange((volatile LONG *)(X),(Y))
+#define IL_EXCHGptr InterlockedExchangePointer
+#define make_atomic_add_body(S) \
+ v= IL_EXCHG_ADD ## S (a, v)
+#define make_atomic_cas_body(S) \
+ int ## S initial_cmp= *cmp; \
+ int ## S initial_a= IL_COMP_EXCHG ## S (a, set, initial_cmp); \
+ if (!(ret= (initial_a == initial_cmp))) *cmp= initial_a;
+#define make_atomic_swap_body(S) \
+ v= IL_EXCHG ## S (a, v)
+#define make_atomic_load_body(S) \
+ ret= 0; /* avoid compiler warning */ \
+ ret= IL_COMP_EXCHG ## S (a, ret, ret);
+
+/*
+ my_yield_processor (equivalent of x86 PAUSE instruction) should be used
+ to improve performance on hyperthreaded CPUs. Intel recommends to use it in
+ spin loops also on non-HT machines to reduce power consumption (see e.g
+ http://softwarecommunity.intel.com/articles/eng/2004.htm)
+
+ Running benchmarks for spinlocks implemented with InterlockedCompareExchange
+ and YieldProcessor shows that much better performance is achieved by calling
+ YieldProcessor in a loop - that is, yielding longer. On Intel boxes setting
+ loop count in the range 200-300 brought best results.
+ */
+#ifndef YIELD_LOOPS
+#define YIELD_LOOPS 200
+#endif
+
+static __inline int my_yield_processor()
+{
+ int i;
+ for(i=0; i<YIELD_LOOPS; i++)
+ {
+#if (_MSC_VER <= 1310)
+ /* On older compilers YieldProcessor is not available, use inline assembly*/
+ __asm { rep nop }
+#else
+ YieldProcessor();
+#endif
+ }
+ return 1;
+}
+
+#define LF_BACKOFF my_yield_processor()
+#else /* cleanup */
+
+#undef IL_EXCHG_ADD32
+#undef IL_COMP_EXCHG32
+#undef IL_COMP_EXCHGptr
+#undef IL_EXCHG32
+#undef IL_EXCHGptr
+
+#endif
@@ -0,0 +1,48 @@
+/* Copyright (C) 2006 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#if defined(__i386__) || defined(_MSC_VER) || defined(__x86_64__) \
+ || defined(HAVE_GCC_ATOMIC_BUILTINS)
+
+# ifdef MY_ATOMIC_MODE_DUMMY
+# define LOCK_prefix ""
+# else
+# define LOCK_prefix "lock"
+# endif
+
+# ifdef HAVE_GCC_ATOMIC_BUILTINS
+# include "gcc_builtins.h"
+# elif __GNUC__
+# include "x86-gcc.h"
+# elif defined(_MSC_VER)
+# include "generic-msvc.h"
+# endif
+#endif
+
+#ifdef make_atomic_cas_body
+/*
+ Type not used so minimal size (emptry struct has different size between C
+ and C++, zero-length array is gcc-specific).
+*/
+typedef char my_atomic_rwlock_t __attribute__ ((unused));
+#define my_atomic_rwlock_destroy(name)
+#define my_atomic_rwlock_init(name)
+#define my_atomic_rwlock_rdlock(name)
+#define my_atomic_rwlock_wrlock(name)
+#define my_atomic_rwlock_rdunlock(name)
+#define my_atomic_rwlock_wrunlock(name)
+
+#endif
+
@@ -0,0 +1,57 @@
+/* Copyright (C) 2006 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t;
+#define MY_ATOMIC_MODE_RWLOCKS 1
+
+#ifdef MY_ATOMIC_MODE_DUMMY
+/*
+ the following can never be enabled by ./configure, one need to put #define in
+ a source to trigger the following warning. The resulting code will be broken,
+ it only makes sense to do it to see now test_atomic detects broken
+ implementations (another way is to run a UP build on an SMP box).
+*/
+#warning MY_ATOMIC_MODE_DUMMY and MY_ATOMIC_MODE_RWLOCKS are incompatible
+#define my_atomic_rwlock_destroy(name)
+#define my_atomic_rwlock_init(name)
+#define my_atomic_rwlock_rdlock(name)
+#define my_atomic_rwlock_wrlock(name)
+#define my_atomic_rwlock_rdunlock(name)
+#define my_atomic_rwlock_wrunlock(name)
+#define MY_ATOMIC_MODE "dummy (non-atomic)"
+#else
+/*
+ we're using read-write lock macros but map them to mutex locks, and they're
+ faster. Still, having semantically rich API we can change the
+ underlying implementation, if necessary.
+*/
+#define my_atomic_rwlock_destroy(name) pthread_mutex_destroy(& (name)->rw)
+#define my_atomic_rwlock_init(name) pthread_mutex_init(& (name)->rw, 0)
+#define my_atomic_rwlock_rdlock(name) pthread_mutex_lock(& (name)->rw)
+#define my_atomic_rwlock_wrlock(name) pthread_mutex_lock(& (name)->rw)
+#define my_atomic_rwlock_rdunlock(name) pthread_mutex_unlock(& (name)->rw)
+#define my_atomic_rwlock_wrunlock(name) pthread_mutex_unlock(& (name)->rw)
+#define MY_ATOMIC_MODE "mutex"
+#ifndef MY_ATOMIC_MODE_RWLOCKS
+#define MY_ATOMIC_MODE_RWLOCKS 1
+#endif
+#endif
+
+#define make_atomic_add_body(S) int ## S sav; sav= *a; *a+= v; v=sav;
+#define make_atomic_fas_body(S) int ## S sav; sav= *a; *a= v; v=sav;
+#define make_atomic_cas_body(S) if ((ret= (*a == *cmp))) *a= set; else *cmp=*a;
+#define make_atomic_load_body(S) ret= *a;
+#define make_atomic_store_body(S) *a= v;
+
@@ -0,0 +1,69 @@
+/* Copyright (C) 2006 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/*
+ XXX 64-bit atomic operations can be implemented using
+ cmpxchg8b, if necessary. Though I've heard that not all 64-bit
+ architectures support double-word (128-bit) cas.
+*/
+
+#ifdef __x86_64__
+# ifdef MY_ATOMIC_NO_XADD
+# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix "-no-xadd"
+# else
+# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix
+# endif
+#else
+# ifdef MY_ATOMIC_NO_XADD
+# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix "-no-xadd"
+# else
+# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix
+# endif
+#endif
+
+/* fix -ansi errors while maintaining readability */
+#ifndef asm
+#define asm __asm__
+#endif
+
+#ifndef MY_ATOMIC_NO_XADD
+#define make_atomic_add_body(S) \
+ asm volatile (LOCK_prefix "; xadd %0, %1;" : "+r" (v) , "+m" (*a))
+#endif
+#define make_atomic_fas_body(S) \
+ asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (*a))
+#define make_atomic_cas_body(S) \
+ asm volatile (LOCK_prefix "; cmpxchg %3, %0; setz %2;" \
+ : "+m" (*a), "+a" (*cmp), "=q" (ret): "r" (set))
+
+#ifdef MY_ATOMIC_MODE_DUMMY
+#define make_atomic_load_body(S) ret=*a
+#define make_atomic_store_body(S) *a=v
+#else
+/*
+ Actually 32-bit reads/writes are always atomic on x86
+ But we add LOCK_prefix here anyway to force memory barriers
+*/
+#define make_atomic_load_body(S) \
+ ret=0; \
+ asm volatile (LOCK_prefix "; cmpxchg %2, %0" \
+ : "+m" (*a), "+a" (ret): "r" (ret))
+#define make_atomic_store_body(S) \
+ asm volatile ("; xchg %0, %1;" : "+m" (*a), "+r" (v))
+#endif
+
+/* TODO test on intel whether the below helps. on AMD it makes no difference */
+//#define LF_BACKOFF ({asm volatile ("rep; nop"); 1; })
+
@@ -0,0 +1,49 @@
+/* Copyright (C) 2003 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef __BASE64_H_INCLUDED__
+#define __BASE64_H_INCLUDED__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ Calculate how much memory needed for dst of base64_encode()
+*/
+int my_base64_needed_encoded_length(int length_of_data);
+
+/*
+ Calculate how much memory needed for dst of base64_decode()
+*/
+int my_base64_needed_decoded_length(int length_of_encoded_data);
+
+
+/*
+ Encode data as a base64 string
+*/
+int my_base64_encode(const void *src, size_t src_len, char *dst);
+
+/*
+ Decode a base64 string into data
+*/
+int my_base64_decode(const char *src, size_t src_len,
+ void *dst, const char **end_ptr);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !__BASE64_H_INCLUDED__ */
Oops, something went wrong.

0 comments on commit 20a0d23

Please sign in to comment.