summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <tim@work.mysql.com>2001-01-29 20:14:29 +0100
committerunknown <tim@work.mysql.com>2001-01-29 20:14:29 +0100
commitbf1f8fd3eb4b98dadd265f8ed10d92220dabe1bb (patch)
treec871edb91cbcc25e8dc02efd481e5c826480a715 /mysys
parentef2e14428542668c46d72fe8a4795df74ec4fedf (diff)
parent74e9d984e7404e559a0fc8c5636b113edfb3cd97 (diff)
downloadmariadb-git-bf1f8fd3eb4b98dadd265f8ed10d92220dabe1bb.tar.gz
Merge work.mysql.com:/home/bk/mysql
into work.mysql.com:/d1/users/tim/my/work BitKeeper/etc/logging_ok: auto-union
Diffstat (limited to 'mysys')
-rw-r--r--mysys/Makefile.am2
-rw-r--r--mysys/hash.c4
-rw-r--r--mysys/mf_tempfile.c2
-rw-r--r--mysys/my_bitmap.c60
-rw-r--r--mysys/my_getwd.c4
-rw-r--r--mysys/my_init.c10
-rw-r--r--mysys/my_vsnprintf.c7
-rw-r--r--mysys/mysys_priv.h1
-rw-r--r--mysys/thr_lock.c8
9 files changed, 92 insertions, 6 deletions
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index 7615b85fa29..6674132bdca 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -44,7 +44,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
my_quick.c my_lockmem.c my_static.c \
getopt.c getopt1.c getvar.c my_mkdir.c \
default.c my_compress.c checksum.c raid.cc my_net.c \
- my_vsnprintf.c charset.c
+ my_vsnprintf.c charset.c my_bitmap.c
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c
libmysys_a_LIBADD = @THREAD_LOBJECTS@
diff --git a/mysys/hash.c b/mysys/hash.c
index b366554272a..66fa91811b5 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -83,7 +83,7 @@ void hash_free(HASH *hash)
/* some helper functions */
-static inline byte*
+inline byte*
hash_key(HASH *hash,const byte *record,uint *length,my_bool first)
{
if (hash->get_key)
@@ -180,7 +180,7 @@ uint calc_hashnr_caseup(const byte *key, uint len)
#endif
-static inline uint rec_hashnr(HASH *hash,const byte *record)
+inline uint rec_hashnr(HASH *hash,const byte *record)
{
uint length;
byte *key=hash_key(hash,record,&length,0);
diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c
index 6204c4d0407..b2c0e89b9e4 100644
--- a/mysys/mf_tempfile.c
+++ b/mysys/mf_tempfile.c
@@ -40,7 +40,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
myf MyFlags __attribute__((unused)))
{
File file= -1;
- DBUG_ENTER("open_temp_file");
+ DBUG_ENTER("create_temp_file");
#if defined(_MSC_VER)
{
char temp[FN_REFLEN],*end,*res,**old_env,*temp_env[1];
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
new file mode 100644
index 00000000000..1434f472f98
--- /dev/null
+++ b/mysys/my_bitmap.c
@@ -0,0 +1,60 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/*
+ Handling of uchar arrays as large bitmaps.
+*/
+
+#include "mysys_priv.h"
+#include <my_bitmap.h>
+
+pthread_mutex_t LOCK_bitmap;
+
+void bitmap_set_bit(uchar *bitmap, uint bitmap_size, uint bitmap_bit) {
+ if((bitmap_bit != MY_BIT_NONE) && (bitmap_bit < bitmap_size*8)) {
+ pthread_mutex_lock(&LOCK_bitmap);
+ bitmap[bitmap_bit / 8] |= (1 << bitmap_bit % 8);
+ pthread_mutex_unlock(&LOCK_bitmap);
+ };
+};
+
+uint bitmap_set_next(uchar *bitmap, uint bitmap_size) {
+ uint bit_found = MY_BIT_NONE;
+ int i, b;
+
+ pthread_mutex_lock(&LOCK_bitmap);
+ for(i=0; (i<bitmap_size) && (bit_found==MY_BIT_NONE); i++) {
+ if(bitmap[i] == 0xff) continue;
+ for(b=0; (b<8) && (bit_found==MY_BIT_NONE); b++)
+ if((bitmap[i] & 1<<b) == 0) {
+ bit_found = (i*8)+b;
+ bitmap[i] |= 1<<b;
+ };
+ };
+ pthread_mutex_unlock(&LOCK_bitmap);
+
+ return bit_found;
+};
+
+void bitmap_clear_bit(uchar *bitmap, uint bitmap_size, uint bitmap_bit) {
+ if((bitmap_bit != MY_BIT_NONE) && (bitmap_bit < bitmap_size*8)) {
+ pthread_mutex_lock(&LOCK_bitmap);
+ bitmap[bitmap_bit / 8] &= ~(1 << bitmap_bit % 8);
+ pthread_mutex_unlock(&LOCK_bitmap);
+ };
+};
+
diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c
index 3d674276731..b49737b2a61 100644
--- a/mysys/my_getwd.c
+++ b/mysys/my_getwd.c
@@ -29,6 +29,10 @@
#include <direct.h>
#endif
+#ifdef __EMX__
+// chdir2 support also drive change
+#define chdir _chdir2
+#endif
/* Gets current working directory in buff. Directory is allways ended
with FN_LIBCHAR */
diff --git a/mysys/my_init.c b/mysys/my_init.c
index a9c8b49a257..384fab5d53c 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -48,6 +48,7 @@ static my_bool win32_init_tcp_ip();
static my_bool my_init_done=0;
+
static ulong atoi_octal(const char *str)
{
long int tmp;
@@ -76,6 +77,7 @@ void my_init(void)
#ifndef __WIN__
sigfillset(&my_signals); /* signals blocked by mf_brkhant */
#endif
+ pthread_mutex_init(&LOCK_bitmap, NULL);
#endif
{
DBUG_ENTER("my_init");
@@ -127,7 +129,12 @@ void my_end(int infoflag)
#ifdef HAVE_GETRUSAGE
struct rusage rus;
if (!getrusage(RUSAGE_SELF, &rus))
- fprintf(info_file,"\nUser time %.2f, System time %.2f\nMaximum resident set size %ld, Integral resident set size %ld\nNon physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\nBlocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\nVouluntary context switches %ld, Invouluntary context switches %ld\n",
+ fprintf(info_file,"\n\
+User time %.2f, System time %.2f\n\
+Maximum resident set size %ld, Integral resident set size %ld\n\
+Non-physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\n\
+Blocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\n\
+Voluntary context switches %ld, Involuntary context switches %ld\n",
(rus.ru_utime.tv_sec * SCALE_SEC +
rus.ru_utime.tv_usec / SCALE_USEC) / 100.0,
(rus.ru_stime.tv_sec * SCALE_SEC +
@@ -159,6 +166,7 @@ void my_end(int infoflag)
pthread_mutex_destroy(&THR_LOCK_keycache);
pthread_mutex_destroy(&THR_LOCK_malloc);
pthread_mutex_destroy(&THR_LOCK_open);
+ pthread_mutex_destroy(&LOCK_bitmap);
DBUG_POP(); /* Must be done before my_thread_end */
my_thread_end();
my_thread_global_end();
diff --git a/mysys/my_vsnprintf.c b/mysys/my_vsnprintf.c
index 030846ea63b..669b8be61b1 100644
--- a/mysys/my_vsnprintf.c
+++ b/mysys/my_vsnprintf.c
@@ -21,6 +21,13 @@
#include <stdarg.h>
#include <m_ctype.h>
+int my_snprintf(char* to, size_t n, const char* fmt, ...)
+{
+ va_list args;
+ va_start(args,fmt);
+ return my_vsnprintf(to, n, fmt, args);
+}
+
int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
{
char *start=to, *end=to+n-1;
diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h
index 86c32202e99..20fda270658 100644
--- a/mysys/mysys_priv.h
+++ b/mysys/mysys_priv.h
@@ -25,6 +25,7 @@
#ifdef THREAD
extern pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache,
THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_net,THR_LOCK_charset;
+extern pthread_mutex_t LOCK_bitmap;
#else /* THREAD */
#define pthread_mutex_lock(A)
#define pthread_mutex_unlock(A)
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index 5c48ad435a4..348c7bae74f 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -83,7 +83,7 @@ multiple read locks.
#include <errno.h>
my_bool thr_lock_inited=0;
-
+ulong locks_immediate = 0L, locks_waited = 0L;
/* The following constants are only for debug output */
#define MAX_THREADS 100
@@ -387,6 +387,7 @@ static my_bool wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
else
{
result=0;
+ statistic_increment(locks_waited, &THR_LOCK_lock);
if (data->lock->get_status)
(*data->lock->get_status)(data->status_param);
check_locks(data->lock,"got wait_for_lock",0);
@@ -447,6 +448,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
check_locks(lock,"read lock with old write lock",0);
if (lock->get_status)
(*lock->get_status)(data->status_param);
+ ++locks_immediate;
goto end;
}
if (lock->write.data->type == TL_WRITE_ONLY)
@@ -470,6 +472,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
if ((int) lock_type == (int) TL_READ_NO_INSERT)
lock->read_no_write_count++;
check_locks(lock,"read lock with no write locks",0);
+ ++locks_immediate;
goto end;
}
/* Can't get lock yet; Wait for it */
@@ -501,6 +504,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
data->cond=get_cond();
if (lock->get_status)
(*lock->get_status)(data->status_param);
+ ++locks_immediate;
goto end;
}
}
@@ -535,6 +539,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
check_locks(lock,"second write lock",0);
if (data->lock->get_status)
(*data->lock->get_status)(data->status_param);
+ ++locks_immediate;
goto end;
}
DBUG_PRINT("lock",("write locked by thread: %ld",
@@ -560,6 +565,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
if (data->lock->get_status)
(*data->lock->get_status)(data->status_param);
check_locks(lock,"only write lock",0);
+ ++locks_immediate;
goto end;
}
}