summaryrefslogtreecommitdiff
path: root/innobase/mach
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2001-02-17 14:19:19 +0200
committerunknown <monty@donna.mysql.com>2001-02-17 14:19:19 +0200
commit2662b59306ef0cd495fa6e2edf7129e58a11393a (patch)
treebfe39951a73e906579ab819bf5198ad8f3a64a36 /innobase/mach
parent66de55a56bdcf2f7a9c0c4f8e19b3e761475e202 (diff)
downloadmariadb-git-2662b59306ef0cd495fa6e2edf7129e58a11393a.tar.gz
Added Innobase to source distribution
Docs/manual.texi: Added Innobase documentation configure.in: Incremented version include/my_base.h: Added option for Innobase myisam/mi_check.c: cleanup mysql-test/t/bdb.test: cleanup mysql-test/t/innobase.test: Extended with new tests from bdb.test mysql-test/t/merge.test: Added test of SHOW create mysys/my_init.c: Fix for UNIXWARE 7 scripts/mysql_install_db.sh: Always write how to start mysqld scripts/safe_mysqld.sh: Fixed type sql/ha_innobase.cc: Update to new version sql/ha_innobase.h: Update to new version sql/handler.h: Added 'update_table_comment()' and 'append_create_info()' sql/sql_delete.cc: Fixes for Innobase sql/sql_select.cc: Fixes for Innobase sql/sql_show.cc: Append create information (for MERGE tables) sql/sql_update.cc: Fixes for Innobase
Diffstat (limited to 'innobase/mach')
-rw-r--r--innobase/mach/Makefile.am24
-rw-r--r--innobase/mach/mach0data.c119
-rw-r--r--innobase/mach/makefilewin9
-rw-r--r--innobase/mach/ts/makefile12
-rw-r--r--innobase/mach/ts/tsmach.c158
5 files changed, 322 insertions, 0 deletions
diff --git a/innobase/mach/Makefile.am b/innobase/mach/Makefile.am
new file mode 100644
index 00000000000..8195831e92e
--- /dev/null
+++ b/innobase/mach/Makefile.am
@@ -0,0 +1,24 @@
+# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+# & Innobase Oy
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+include ../include/Makefile.i
+
+libs_LIBRARIES = libmach.a
+
+libmach_a_SOURCES = mach0data.c
+
+EXTRA_PROGRAMS =
diff --git a/innobase/mach/mach0data.c b/innobase/mach/mach0data.c
new file mode 100644
index 00000000000..336ce106a75
--- /dev/null
+++ b/innobase/mach/mach0data.c
@@ -0,0 +1,119 @@
+/**********************************************************************
+Utilities for converting data from the database file
+to the machine format.
+
+(c) 1995 Innobase Oy
+
+Created 11/28/1995 Heikki Tuuri
+***********************************************************************/
+
+#include "mach0data.h"
+
+#ifdef UNIV_NONINL
+#include "mach0data.ic"
+#endif
+
+/*************************************************************
+Reads a ulint in a compressed form if the log record fully contains it. */
+
+byte*
+mach_parse_compressed(
+/*==================*/
+ /* out: pointer to end of the stored field, NULL if
+ not complete */
+ byte* ptr, /* in: pointer to buffer from where to read */
+ byte* end_ptr,/* in: pointer to end of the buffer */
+ ulint* val) /* out: read value (< 2^32) */
+{
+ ulint flag;
+
+ ut_ad(ptr && end_ptr && val);
+
+ if (ptr >= end_ptr) {
+
+ return(NULL);
+ }
+
+ flag = mach_read_from_1(ptr);
+
+ if (flag < 0x80) {
+ *val = flag;
+ return(ptr + 1);
+
+ } else if (flag < 0xC0) {
+ if (end_ptr < ptr + 2) {
+ return(NULL);
+ }
+
+ *val = mach_read_from_2(ptr) & 0x7FFF;
+
+ return(ptr + 2);
+
+ } else if (flag < 0xE0) {
+ if (end_ptr < ptr + 3) {
+ return(NULL);
+ }
+
+ *val = mach_read_from_3(ptr) & 0x3FFFFF;
+
+ return(ptr + 3);
+ } else if (flag < 0xF0) {
+ if (end_ptr < ptr + 4) {
+ return(NULL);
+ }
+
+ *val = mach_read_from_4(ptr) & 0x1FFFFFFF;
+
+ return(ptr + 4);
+ } else {
+ ut_ad(flag == 0xF0);
+
+ if (end_ptr < ptr + 5) {
+ return(NULL);
+ }
+
+ *val = mach_read_from_4(ptr + 1);
+ return(ptr + 5);
+ }
+}
+
+/*************************************************************
+Reads a dulint in a compressed form if the log record fully contains it. */
+
+byte*
+mach_dulint_parse_compressed(
+/*=========================*/
+ /* out: pointer to end of the stored field, NULL if
+ not complete */
+ byte* ptr, /* in: pointer to buffer from where to read */
+ byte* end_ptr,/* in: pointer to end of the buffer */
+ dulint* val) /* out: read value */
+{
+ ulint high;
+ ulint low;
+ ulint size;
+
+ ut_ad(ptr && end_ptr && val);
+
+ if (end_ptr < ptr + 5) {
+
+ return(NULL);
+ }
+
+ high = mach_read_compressed(ptr);
+
+ size = mach_get_compressed_size(high);
+
+ ptr += size;
+
+ if (end_ptr < ptr + 4) {
+
+ return(NULL);
+ }
+
+ low = mach_read_from_4(ptr);
+
+ *val = ut_dulint_create(high, low);
+
+ return(ptr + 4);
+}
diff --git a/innobase/mach/makefilewin b/innobase/mach/makefilewin
new file mode 100644
index 00000000000..5306b0fe14c
--- /dev/null
+++ b/innobase/mach/makefilewin
@@ -0,0 +1,9 @@
+include ..\include\makefile.i
+
+mach.lib: mach0data.obj
+ lib -out:..\libs\mach.lib mach0data.obj
+
+mach0data.obj: mach0data.c
+ $(CCOM) $(CFLN) -c mach0data.c
+
+
diff --git a/innobase/mach/ts/makefile b/innobase/mach/ts/makefile
new file mode 100644
index 00000000000..e9531e6ebe0
--- /dev/null
+++ b/innobase/mach/ts/makefile
@@ -0,0 +1,12 @@
+
+include ..\..\makefile.i
+
+tsmach: ..\mach.lib tsmach.c
+ $(CCOM) $(CFL) -I.. -I..\.. ..\mach.lib ..\..\ut.lib ..\..\os.lib tsmach.c $(LFL)
+
+
+
+
+
+
+
diff --git a/innobase/mach/ts/tsmach.c b/innobase/mach/ts/tsmach.c
new file mode 100644
index 00000000000..a4b67227d20
--- /dev/null
+++ b/innobase/mach/ts/tsmach.c
@@ -0,0 +1,158 @@
+/************************************************************************
+The test module for the machine-dependent utilities
+
+(c) 1995 Innobase Oy
+
+Created 11/28/1995 Heikki Tuuri
+*************************************************************************/
+
+#include "../mach0data.h"
+
+byte arr[4000000];
+
+
+/*********************************************************************
+Test for ulint write and read. */
+
+void
+test1(void)
+/*=======*/
+{
+ ulint a, i, j;
+ ulint tm, oldtm;
+
+ printf("-------------------------------------------\n");
+ printf("TEST 1. Speed test of ulint read and write \n");
+
+ a = 0;
+
+ oldtm = ut_clock();
+
+ for (j = 0; j < 100; j++) {
+ for (i = 0; i < 10000; i++) {
+
+ a += mach_read_from_4(arr + i * 4);
+ }
+ }
+
+ tm = ut_clock();
+
+ printf("Wall clock time for read of %lu ulints %lu millisecs\n",
+ j * i, tm - oldtm);
+
+ oldtm = ut_clock();
+
+ for (j = 0; j < 100; j++) {
+ for (i = 0; i < 10000; i++) {
+
+ a += mach_read(arr + i * 4);
+ }
+ }
+
+ tm = ut_clock();
+
+ printf("Wall clock time for read of %lu ulints %lu millisecs\n",
+ j * i, tm - oldtm);
+
+ oldtm = ut_clock();
+
+ for (j = 0; j < 100; j++) {
+ for (i = 0; i < 10000; i++) {
+
+ a += mach_read_from_4(arr + i * 4 + 1);
+ }
+ }
+
+ tm = ut_clock();
+
+ printf("Wall clock time for read of %lu ulints %lu millisecs\n",
+ j * i, tm - oldtm);
+ oldtm = ut_clock();
+
+ for (j = 0; j < 100; j++) {
+ for (i = 0; i < 10000; i++) {
+
+ a += mach_read(arr + i * 4 + 1);
+ }
+ }
+
+ tm = ut_clock();
+
+ printf("Wall clock time for read of %lu ulints %lu millisecs\n",
+ j * i, tm - oldtm);
+
+ oldtm = ut_clock();
+
+ for (i = 0; i < 1000000; i++) {
+
+ a += mach_read_from_4(arr + i * 4);
+ }
+
+ tm = ut_clock();
+
+ printf("Wall clock time for read of %lu ulints %lu millisecs\n",
+ i, tm - oldtm);
+ oldtm = ut_clock();
+
+ for (i = 0; i < 1000000; i++) {
+
+ a += mach_read(arr + i * 4);
+ }
+
+ tm = ut_clock();
+
+ printf("Wall clock time for read of %lu ulints %lu millisecs\n",
+ i, tm - oldtm);
+
+ oldtm = ut_clock();
+
+ for (j = 0; j < 100; j++) {
+ for (i = 0; i < 10000; i++) {
+
+ a += mach_read_from_2(arr + i * 2);
+ }
+ }
+
+ tm = ut_clock();
+
+ printf("Wall clock time for read of %lu 16-bit ints %lu millisecs\n",
+ j * i, tm - oldtm);
+}
+
+/*********************************************************************
+Test for ulint write and read. */
+
+void
+test2(void)
+/*=======*/
+{
+ ulint a[2];
+
+ printf("-------------------------------------------\n");
+ printf("TEST 2. Correctness test of ulint read and write \n");
+
+ mach_write_to_4((byte*)&a, 737237727);
+
+ ut_a(737237727 == mach_read_from_4((byte*)&a));
+
+ mach_write_to_2((byte*)&a, 7372);
+
+ ut_a(7372 == mach_read_from_2((byte*)&a));
+
+ mach_write_to_1((byte*)&a, 27);
+
+ ut_a(27 == mach_read_from_1((byte*)&a));
+
+ mach_write((byte*)&a, 737237727);
+
+ ut_a(737237727 == mach_read((byte*)&a));
+}
+
+void
+main(void)
+{
+ test1();
+ test2();
+
+ printf("TEST SUCCESSFULLY COMPLETED!\n");
+}