summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rwxr-xr-xmysys/CMakeLists.txt47
-rw-r--r--mysys/my_create.c9
-rw-r--r--mysys/my_getsystime.c5
-rw-r--r--mysys/my_handler.c6
-rw-r--r--mysys/my_rdtsc.c8
-rw-r--r--mysys/my_winthread.c19
-rw-r--r--mysys/mysys_priv.h5
-rw-r--r--mysys/typelib.c2
8 files changed, 71 insertions, 30 deletions
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index ae9406450ed..c035a2f0b49 100755
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -13,15 +13,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# Only the server link with this library, the client libraries and the client
-# executables all link with recompiles of source found in the "mysys" directory.
-# So we only need to create one version of this library, with the "static"
-# Thread Local Storage model.
-#
-# Exception is the embedded server that needs this library compiled with
-# dynamic TLS, i.e. define USE_TLS
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys)
+
+INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys)
SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_modify.c
errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c
@@ -30,20 +24,45 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_arr_appstr.c mf_tempdir.c
mf_tempfile.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_access.c
my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chsize.c
- my_clock.c my_compress.c my_conio.c my_copy.c my_crc32.c my_create.c my_delete.c
+ my_clock.c my_compress.c my_copy.c my_crc32.c my_create.c my_delete.c
my_div.c my_error.c my_file.c my_fopen.c my_fstream.c my_gethostbyname.c
my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c
my_lib.c my_lock.c my_lockmem.c my_malloc.c my_messnc.c
my_mkdir.c my_mmap.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c
my_quick.c my_read.c my_realloc.c my_redel.c my_rename.c my_seek.c my_sleep.c
- my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_wincond.c
- my_winerr.c my_winfile.c my_windac.c my_winthread.c my_write.c ptr_cmp.c queues.c stacktrace.c
+ my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c
+ my_write.c ptr_cmp.c queues.c stacktrace.c
rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c
lf_alloc-pin.c lf_dynarray.c lf_hash.c
my_atomic.c my_getncpus.c
my_rdtsc.c)
-IF(NOT SOURCE_SUBLIBS)
- ADD_LIBRARY(mysys ${MYSYS_SOURCES})
-ENDIF(NOT SOURCE_SUBLIBS)
+IF (WIN32)
+ SET (MYSYS_SOURCES ${MYSYS_SOURCES} my_winthread.c my_wincond.c my_winerr.c my_winfile.c my_windac.c my_conio.c)
+ENDIF()
+
+IF(CMAKE_COMPILER_IS_GNUCC AND NOT HAVE_CXX_NEW)
+ # gcc as C++ compiler does not have new/delete
+ SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_new.cc)
+ ADD_DEFINITIONS( -DUSE_MYSYS_NEW)
+ENDIF()
+
+IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_C_COMPILER_ID MATCHES "SunPro")
+ # Inline assembly template for rdtsc
+ SET_SOURCE_FILES_PROPERTIES(my_rdtsc.c
+ PROPERTIES COMPILE_FLAGS "${CMAKE_CURRENT_SOURCE_DIR}/my_timer_cycles.il")
+ENDIF()
+
+IF(HAVE_LARGE_PAGES)
+ SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_largepage.c)
+ENDIF()
+
+IF(UNIX)
+ # some workarounds
+ SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_port.c)
+ENDIF()
+ADD_CONVENIENCE_LIBRARY(mysys ${MYSYS_SOURCES})
+TARGET_LINK_LIBRARIES(mysys dbug strings ${ZLIB_LIBRARY}
+ ${LIBNSL} ${LIBM} ${LIBRT})
+DTRACE_INSTRUMENT(mysys)
diff --git a/mysys/my_create.c b/mysys/my_create.c
index d0436276d03..49529f9b7b5 100644
--- a/mysys/my_create.c
+++ b/mysys/my_create.c
@@ -39,14 +39,11 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
DBUG_ENTER("my_create");
DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %d",
FileName, CreateFlags, access_flags, MyFlags));
-
-#if !defined(NO_OPEN_3)
- fd= open((char *) FileName, access_flags | O_CREAT,
- CreateFlags ? CreateFlags : my_umask);
-#elif defined(_WIN32)
+#if defined(_WIN32)
fd= my_win_open(FileName, access_flags | O_CREAT);
#else
- fd= open(FileName, access_flags);
+ fd= open((char *) FileName, access_flags | O_CREAT,
+ CreateFlags ? CreateFlags : my_umask);
#endif
if ((MyFlags & MY_SYNC_DIR) && (fd >=0) &&
diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c
index 81bb3e15298..ea12f73fe3d 100644
--- a/mysys/my_getsystime.c
+++ b/mysys/my_getsystime.c
@@ -150,7 +150,10 @@ ulonglong my_micro_time()
Value in microseconds from some undefined point in time
*/
-#define DELTA_FOR_SECONDS LL(500000000) /* Half a second */
+#define DELTA_FOR_SECONDS 500000000LL /* Half a second */
+
+/* Difference between GetSystemTimeAsFileTime() and now() */
+#define OFFSET_TO_EPOCH 116444736000000000ULL
ulonglong my_micro_time_and_time(time_t *time_arg)
{
diff --git a/mysys/my_handler.c b/mysys/my_handler.c
index 3bc27b622cb..3f8af553db6 100644
--- a/mysys/my_handler.c
+++ b/mysys/my_handler.c
@@ -576,6 +576,10 @@ HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a)
will ignore calls to register already registered error numbers.
*/
+static const char **get_handler_error_messages()
+{
+ return handler_error_messages;
+}
void my_handler_error_register(void)
{
@@ -587,7 +591,7 @@ void my_handler_error_register(void)
*/
compile_time_assert(HA_ERR_FIRST + array_elements(handler_error_messages) ==
HA_ERR_LAST + 1);
- my_error_register(handler_error_messages, HA_ERR_FIRST,
+ my_error_register(get_handler_error_messages, HA_ERR_FIRST,
HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
}
diff --git a/mysys/my_rdtsc.c b/mysys/my_rdtsc.c
index c2b31ee339d..073663e3d96 100644
--- a/mysys/my_rdtsc.c
+++ b/mysys/my_rdtsc.c
@@ -100,7 +100,7 @@
#if defined(__SUNPRO_CC) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
extern "C" ulonglong my_timer_cycles_il_sparc64();
-#elif defined(__SUNPRO_CC) && defined(__sparcv8plus) && defined(_ILP32) && !defined(__SunOS_5_7)
+#elif defined(__SUNPRO_CC) && defined(_ILP32) && !defined(__SunOS_5_7)
extern "C" ulonglong my_timer_cycles_il_sparc32();
#elif defined(__SUNPRO_CC) && defined(__i386) && defined(_ILP32)
extern "C" ulonglong my_timer_cycles_il_i386();
@@ -108,7 +108,7 @@ extern "C" ulonglong my_timer_cycles_il_i386();
extern "C" ulonglong my_timer_cycles_il_x86_64();
#elif defined(__SUNPRO_C) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
ulonglong my_timer_cycles_il_sparc64();
-#elif defined(__SUNPRO_C) && defined(__sparcv8plus) && defined(_ILP32) && !defined(__SunOS_5_7)
+#elif defined(__SUNPRO_C) && defined(_ILP32) && !defined(__SunOS_5_7)
ulonglong my_timer_cycles_il_sparc32();
#elif defined(__SUNPRO_C) && defined(__i386) && defined(_ILP32)
ulonglong my_timer_cycles_il_i386();
@@ -197,7 +197,7 @@ ulonglong my_timer_cycles(void)
}
#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
return (my_timer_cycles_il_sparc64());
-#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__sparcv8plus) && defined(_ILP32) && !defined(__SunOS_5_7)
+#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(_ILP32) && !defined(__SunOS_5_7)
return (my_timer_cycles_il_sparc32());
#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__i386) && defined(_ILP32)
/* This is probably redundant for __SUNPRO_C. */
@@ -549,7 +549,7 @@ void my_timer_init(MY_TIMER_INFO *mti)
mti->cycles.routine= MY_TIMER_ROUTINE_ASM_PPC;
#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
mti->cycles.routine= MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC64;
-#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__sparcv8plus) && defined(_ILP32) && !defined(__SunOS_5_7)
+#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(_ILP32) && !defined(__SunOS_5_7)
mti->cycles.routine= MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC32;
#elif (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && defined(__i386) && defined(_ILP32)
mti->cycles.routine= MY_TIMER_ROUTINE_ASM_SUNPRO_I386;
diff --git a/mysys/my_winthread.c b/mysys/my_winthread.c
index 6b7a51e7755..aecb2f7cc78 100644
--- a/mysys/my_winthread.c
+++ b/mysys/my_winthread.c
@@ -129,6 +129,24 @@ error_return:
return -1;
}
+int pthread_cancel(pthread_t thread)
+{
+
+ HANDLE handle= 0;
+ BOOL ok= FALSE;
+
+ handle= OpenThread(THREAD_TERMINATE, FALSE, thread);
+ if (handle)
+ {
+ ok= TerminateThread(handle,0);
+ CloseHandle(handle);
+ }
+ if (ok)
+ return 0;
+
+ errno= EINVAL;
+ return -1;
+}
/*
One time initialization. For simplicity, we assume initializer thread
@@ -160,5 +178,4 @@ int my_pthread_once(my_pthread_once_t *once_control,
}
return 0;
}
-
#endif
diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h
index 1f84d8d3aab..1ae6a9e3a99 100644
--- a/mysys/mysys_priv.h
+++ b/mysys/mysys_priv.h
@@ -86,6 +86,7 @@ extern PSI_file_key key_file_charset, key_file_cnf;
void my_error_unregister_all(void);
#ifdef _WIN32
+#include <sys/stat.h>
/* my_winfile.c exports, should not be used outside mysys */
extern File my_win_open(const char *path, int oflag);
extern int my_win_close(File fd);
@@ -101,8 +102,8 @@ extern FILE* my_win_fopen(const char *filename, const char *type);
extern File my_win_fclose(FILE *file);
extern File my_win_fileno(FILE *file);
extern FILE* my_win_fdopen(File Filedes, const char *type);
-extern int my_win_stat(const char *path, struct _stat64 *buf);
-extern int my_win_fstat(File fd, struct _stat64 *buf);
+extern int my_win_stat(const char *path, struct _stati64 *buf);
+extern int my_win_fstat(File fd, struct _stati64 *buf);
extern int my_win_fsync(File fd);
extern File my_win_dup(File fd);
extern File my_win_sopen(const char *path, int oflag, int shflag, int perm);
diff --git a/mysys/typelib.c b/mysys/typelib.c
index 73dab610bed..c332c82d17a 100644
--- a/mysys/typelib.c
+++ b/mysys/typelib.c
@@ -326,7 +326,7 @@ my_ulonglong find_set_from_flags(const TYPELIB *lib, uint default_name,
my_ulonglong flags_to_set= 0, flags_to_clear= 0, res;
my_bool set_defaults= 0;
- *err_pos= 0; // No error yet
+ *err_pos= 0; /* No error yet */
if (str != end)
{
const char *start= str;