diff options
Diffstat (limited to 'mysys')
-rwxr-xr-x | mysys/CMakeLists.txt | 47 | ||||
-rw-r--r-- | mysys/my_create.c | 9 | ||||
-rw-r--r-- | mysys/my_getsystime.c | 5 | ||||
-rw-r--r-- | mysys/my_winthread.c | 19 | ||||
-rw-r--r-- | mysys/mysys_priv.h | 5 |
5 files changed, 61 insertions, 24 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_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); |