summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <jcole@tetra.spaceapes.com>2001-01-27 03:27:40 -0600
committerunknown <jcole@tetra.spaceapes.com>2001-01-27 03:27:40 -0600
commit63950c58419efa309a05e42972c4381e57650d67 (patch)
treef6bda9d9ef97783aa278a34c9482e07a13bc2995 /mysys
parent70e783fa2e22e03f3ffd59038ceb26fcef577f68 (diff)
parent882f16d0369b4cd0742ac37650a71fc6f3b00a57 (diff)
downloadmariadb-git-63950c58419efa309a05e42972c4381e57650d67.tar.gz
manual merge
sql/mysqld.cc: Auto merged client/mysqltest.c: Auto merged Docs/manual.texi: merged
Diffstat (limited to 'mysys')
-rw-r--r--mysys/Makefile.am2
-rw-r--r--mysys/my_bitmap.c60
-rw-r--r--mysys/my_init.c10
-rw-r--r--mysys/mysys_priv.h1
4 files changed, 71 insertions, 2 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/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_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/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)