summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <vvaintroub/Wlad@vaio.>2008-01-10 13:21:53 +0100
committerunknown <vvaintroub/Wlad@vaio.>2008-01-10 13:21:53 +0100
commitce8de7afdffd46507f000048a17722f81eec7688 (patch)
tree9bd52862a62e97454cd29e245d4e68d9a9175211 /mysys
parent9b9175ff752957d32a3c532fed0ed52123efa234 (diff)
downloadmariadb-git-ce8de7afdffd46507f000048a17722f81eec7688.tar.gz
Windows fixes
-new option WITH_MARIA_STORAGE_ENGINE for config.js -correct build errors -build test executables -downport changes for atomic functions from 5.2 -remove LOCK_uuid_generator from C++ files to avoid linker errors -new function my_uuid2str() BitKeeper/deleted/.del-x86-msvc.h: Delete: include/atomic/x86-msvc.h CMakeLists.txt: Windows fixes: -New option WITH_MARIA_STORAGE_ENGINE -Add unit tests include/Makefile.am: replace x86-msvc.h with generic-msvc.h include/config-win.h: my_chmod() support include/my_atomic.h: Downport my_atomic from 5.2 tree include/my_bit.h: Correct unresolved symbol errors on Windows include/my_pthread.h: pthread_mutex_unlock now returns 0 (was void previously) defined PTHREAD_STACK_MIN include/my_sys.h: New function my_uuid2str() define MY_UUID_STRING_LENGTH include/atomic/nolock.h: Downport my_atomic from 5.2 tree libmysqld/CMakeLists.txt: New option WITH_MARIA_STORAGE_ENGINE mysys/CMakeLists.txt: Add missing files mysys/lf_dynarray.c: Fix compiler errors on Windows mysys/my_getncpus.c: Windows port mysys/my_uuid.c: Windows fixes: there is no random() on Windows, use ANSI rand() New function my_uuid2str() mysys/my_winthread.c: Downport from 5.2 tree -Call my_thread_end() before pthread_exit() -Avoid crash if pthread_create is called with NULL attributes sql/CMakeLists.txt: Link mysqld with Maria storage engine sql/item_func.cc: Remove LOCK_uuid_generator from C++ to avoid linker errors. Use dedicated mutex for short uuids sql/item_strfunc.cc: Use my_uuid() and my_uuid2str() functions from mysys. sql/item_strfunc.h: Define MY_UUID_STRING_LENGTH in my_sys.h sql/mysql_priv.h: LOCK_uuid_generator must be declared as extern "C" sql/mysqld.cc: Init and destroy LOCK_uuid_short mutex storage/maria/CMakeLists.txt: -Use the same source files as in Makefile.am -Build test binaries storage/maria/ha_maria.cc: snprintf->my_snprintf storage/maria/lockman.c: Fix compiler error on Windows storage/maria/ma_check.c: Fix compiler error on Windows storage/maria/ma_loghandler.c: Fix compile errors my_open()/my_sync() do not work for directories on Windows storage/maria/ma_recovery.c: Fix compile error on Windows storage/maria/ma_test2.c: Rename variable to avoid naming conflict with Microsoft C runtime function storage/maria/ma_test3.c: Fix build errors on Windows storage/maria/tablockman.c: Fix build errors on Windows storage/maria/unittest/Makefile.am: Add CMakeLists.txt storage/maria/unittest/ma_pagecache_consist.c: Fix build errors on Windows remove loop from get_len() storage/maria/unittest/ma_pagecache_single.c: Fix build errors on Windows storage/maria/unittest/ma_test_loghandler-t.c: Windows fixes -Avoid division by 0 in expressions like x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows) storage/maria/unittest/ma_test_loghandler_multigroup-t.c: Windows fixes -Avoid division by 0 in expressions like x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows) -remove loop in get_len() storage/maria/unittest/ma_test_loghandler_multithread-t.c: Windows fixes -Avoid division by 0 in expressions like x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows) -remove loop in get_len() storage/maria/unittest/ma_test_loghandler_noflush-t.c: Fix build errors on Windows storage/maria/unittest/test_file.c: Correct the code to get file size on Windows. stat() information can be outdated and thus cannot be trusted. On Vista,stat() returns file size=0 until the file is closed at the first time. storage/myisam/CMakeLists.txt: Fix compiler errors on Windows Build test executables storage/myisam/mi_test2.c: Rename variable to avoid naming conflict with Microsoft C runtime function storage/myisam/mi_test3.c: Fix build errors on Windows strings/CMakeLists.txt: Add missing file unittest/unit.pl: Windows: downport unittest changes from 5.2 bk tree unittest/mysys/Makefile.am: Windows: downport unittest changes from 5.2 bk tree unittest/mysys/my_atomic-t.c: Windows: downport unittest changes from 5.2 bk tree unittest/mytap/Makefile.am: Windows: downport unittest changes from 5.2 bk tree unittest/mytap/tap.c: Windows: downport unittest changes from 5.2 bk tree win/configure.js: Add WITH_MARIA_STORAGE_ENGINE configure option unittest/mytap/CMakeLists.txt: Add missing file unittest/mysys/CMakeLists.txt: Add missing file storage/maria/unittest/CMakeLists.txt: Add missing file BitKeeper/etc/ignore: Added comments maria-win.patch to the ignore list include/atomic/generic-msvc.h: Implement atomic operations with MSVC intrinsics
Diffstat (limited to 'mysys')
-rwxr-xr-xmysys/CMakeLists.txt8
-rw-r--r--mysys/lf_dynarray.c8
-rw-r--r--mysys/my_getncpus.c24
-rw-r--r--mysys/my_uuid.c32
-rw-r--r--mysys/my_winthread.c22
5 files changed, 66 insertions, 28 deletions
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index 5b024056fda..dffce464d8b 100755
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -31,7 +31,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
mf_keycaches.c mf_loadpath.c mf_pack.c mf_path.c mf_qsort.c mf_qsort2.c
mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_strip.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_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chmod.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_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
@@ -41,7 +41,11 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_wincond.c
my_windac.c my_winthread.c my_write.c ptr_cmp.c queues.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)
+ 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_rnd.c
+ my_uuid.c wqueue.c
+)
IF(NOT SOURCE_SUBLIBS)
ADD_LIBRARY(mysys ${MYSYS_SOURCES})
diff --git a/mysys/lf_dynarray.c b/mysys/lf_dynarray.c
index 770b1f9342b..7c8f54f07cf 100644
--- a/mysys/lf_dynarray.c
+++ b/mysys/lf_dynarray.c
@@ -37,7 +37,7 @@
*/
#include <my_global.h>
-#include <strings.h>
+#include <m_string.h>
#include <my_sys.h>
#include <lf.h>
@@ -123,7 +123,7 @@ void *_lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
}
if (!(ptr= *ptr_ptr))
{
- void *alloc, *data;
+ uchar *alloc, *data;
alloc= my_malloc(LF_DYNARRAY_LEVEL_LENGTH * array->size_of_element +
max(array->size_of_element, sizeof(void *)),
MYF(MY_WME|MY_ZEROFILL));
@@ -142,7 +142,7 @@ void *_lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
else
my_free(alloc, MYF(0));
}
- return ptr + array->size_of_element * idx;
+ return ((uchar*)ptr) + array->size_of_element * idx;
}
/*
@@ -167,7 +167,7 @@ void *_lf_dynarray_value(LF_DYNARRAY *array, uint idx)
}
if (!(ptr= *ptr_ptr))
return(NULL);
- return ptr + array->size_of_element * idx;
+ return ((uchar*)ptr) + array->size_of_element * idx;
}
static int recursive_iterate(LF_DYNARRAY *array, void *ptr, int level,
diff --git a/mysys/my_getncpus.c b/mysys/my_getncpus.c
index 82e87dee2e4..4cb96ac0bca 100644
--- a/mysys/my_getncpus.c
+++ b/mysys/my_getncpus.c
@@ -16,24 +16,26 @@
/* get the number of (online) CPUs */
#include "mysys_priv.h"
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
static int ncpus=0;
-#ifdef _SC_NPROCESSORS_ONLN
int my_getncpus()
{
if (!ncpus)
+ {
+#ifdef _SC_NPROCESSORS_ONLN
ncpus= sysconf(_SC_NPROCESSORS_ONLN);
- return ncpus;
-}
-
+#elif defined(__WIN__)
+ SYSTEM_INFO sysinfo;
+ GetSystemInfo(&sysinfo);
+ ncpus= sysinfo.dwNumberOfProcessors;
#else
-/* unknown */
-int my_getncpus()
-{
- return 2;
-}
-
+/* unknown so play safe: assume SMP and forbid uniprocessor build */
+ ncpus= 2;
#endif
-
+ }
+ return ncpus;
+}
diff --git a/mysys/my_uuid.c b/mysys/my_uuid.c
index d97aaf604fa..1ebc394cafa 100644
--- a/mysys/my_uuid.c
+++ b/mysys/my_uuid.c
@@ -41,6 +41,7 @@
#include "mysys_priv.h"
#include <m_string.h>
+#include <myisampack.h> /* mi_int2store, mi_int4store */
static my_bool my_uuid_inited= 0;
static struct my_rnd_struct uuid_rand;
@@ -67,7 +68,7 @@ pthread_mutex_t LOCK_uuid_generator;
static void set_clock_seq()
{
uint16 clock_seq= ((uint)(my_rnd(&uuid_rand)*16383)) | UUID_VARIANT;
- int2store(uuid_suffix, clock_seq);
+ mi_int2store(uuid_suffix, clock_seq);
}
@@ -105,7 +106,7 @@ void my_uuid_init(ulong seed1, ulong seed2)
randominit() here.
*/
/* purecov: begin inspected */
- my_rnd_init(&uuid_rand, (ulong) (seed2+ now/2), now+random());
+ my_rnd_init(&uuid_rand, (ulong) (seed2+ now/2), now+rand());
for (i=0; i < sizeof(mac); i++)
mac[i]= (uchar)(my_rnd(&uuid_rand)*255);
/* purecov: end */
@@ -160,14 +161,35 @@ void my_uuid(uchar *to)
Note, that the standard does NOT specify byte ordering in
multi-byte fields. it's implementation defined (but must be
the same for all fields).
+ We use big-endian, so we can use memcmp() to compare UUIDs
+ and for straightforward UUID to string conversion.
*/
- int4store(to, time_low);
- int2store(to+4, time_mid);
- int2store(to+6, time_hi_and_version);
+ mi_int4store(to, time_low);
+ mi_int2store(to+4, time_mid);
+ mi_int2store(to+6, time_hi_and_version);
bmove(to+8, uuid_suffix, sizeof(uuid_suffix));
}
+/**
+ Convert uuid to string representation
+
+ @func my_uuid2str()
+ @param guid uuid
+ @param s Output buffer.Must be at least MY_UUID_STRING_LENGTH+1 large.
+*/
+void my_uuid2str(const uchar *guid, char *s)
+{
+ int i;
+ for (i=0; i < MY_UUID_SIZE; i++)
+ {
+ *s++= _dig_vec_lower[guid[i] >>4];
+ *s++= _dig_vec_lower[guid[i] & 15];
+ if(i == 4 || i == 6 || i == 8 || i == 10)
+ *s++= '-';
+ }
+}
+
void my_uuid_end()
{
if (my_uuid_inited)
diff --git a/mysys/my_winthread.c b/mysys/my_winthread.c
index e94369bec32..0af6a47ec4a 100644
--- a/mysys/my_winthread.c
+++ b/mysys/my_winthread.c
@@ -77,12 +77,15 @@ pthread_handler_t pthread_start(void *param)
{
pthread_handler func=((struct pthread_map *) param)->func;
void *func_param=((struct pthread_map *) param)->param;
+ void *result;
my_thread_init(); /* Will always succeed in windows */
pthread_mutex_lock(&THR_LOCK_thread); /* Wait for beginthread to return */
win_pthread_self=((struct pthread_map *) param)->pthreadself;
pthread_mutex_unlock(&THR_LOCK_thread);
free((char*) param); /* Free param from create */
- pthread_exit((void*) (*func)(func_param));
+ result= (void*) (*func)(func_param);
+ my_thread_end();
+ pthread_exit(result);
return 0; /* Safety */
}
@@ -92,21 +95,28 @@ int pthread_create(pthread_t *thread_id, pthread_attr_t *attr,
{
HANDLE hThread;
struct pthread_map *map;
+ DWORD StackSize= 0;
+ int priority= 0;
DBUG_ENTER("pthread_create");
if (!(map=malloc(sizeof(*map))))
DBUG_RETURN(-1);
map->func=func;
map->param=param;
+ if (attr != NULL)
+ {
+ StackSize= attr->dwStackSize;
+ priority= attr->priority;
+ }
+ if (StackSize == 0)
+ StackSize= PTHREAD_STACK_MIN;
pthread_mutex_lock(&THR_LOCK_thread);
#ifdef __BORLANDC__
hThread=(HANDLE)_beginthread((void(_USERENTRY *)(void *)) pthread_start,
- attr->dwStackSize ? attr->dwStackSize :
- 65535, (void*) map);
+ StackSize, (void*) map);
#else
hThread=(HANDLE)_beginthread((void( __cdecl *)(void *)) pthread_start,
- attr->dwStackSize ? attr->dwStackSize :
- 65535, (void*) map);
+ StackSize, (void*) map);
#endif
DBUG_PRINT("info", ("hThread=%lu",(long) hThread));
*thread_id=map->pthreadself=hThread;
@@ -119,7 +129,7 @@ int pthread_create(pthread_t *thread_id, pthread_attr_t *attr,
("Can't create thread to handle request (error %d)",error));
DBUG_RETURN(error ? error : -1);
}
- VOID(SetThreadPriority(hThread, attr->priority)) ;
+ VOID(SetThreadPriority(hThread, priority)) ;
DBUG_RETURN(0);
}