summaryrefslogtreecommitdiff
path: root/innobase/ut
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/ut
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/ut')
-rw-r--r--innobase/ut/Makefile.am24
-rw-r--r--innobase/ut/makefilewin21
-rw-r--r--innobase/ut/ts/makefile12
-rw-r--r--innobase/ut/ts/tsut.c347
-rw-r--r--innobase/ut/ut0byte.c32
-rw-r--r--innobase/ut/ut0dbg.c27
-rw-r--r--innobase/ut/ut0mem.c69
-rw-r--r--innobase/ut/ut0rnd.c79
-rw-r--r--innobase/ut/ut0ut.c164
9 files changed, 775 insertions, 0 deletions
diff --git a/innobase/ut/Makefile.am b/innobase/ut/Makefile.am
new file mode 100644
index 00000000000..de3cf41b767
--- /dev/null
+++ b/innobase/ut/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 = libut.a
+
+libut_a_SOURCES = ut0byte.c ut0dbg.c ut0mem.c ut0rnd.c ut0ut.c
+
+EXTRA_PROGRAMS =
diff --git a/innobase/ut/makefilewin b/innobase/ut/makefilewin
new file mode 100644
index 00000000000..2fda190773b
--- /dev/null
+++ b/innobase/ut/makefilewin
@@ -0,0 +1,21 @@
+include ..\include\makefile.i
+
+ut.lib: ut0ut.obj ut0mem.obj ut0byte.obj ut0dbg.obj ut0rnd.obj
+ lib -out:..\libs\ut.lib ut0ut.obj ut0mem.obj ut0byte.obj ut0dbg.obj ut0rnd.obj
+
+ut0ut.obj: ut0ut.c
+ $(CCOM) $(CFL) -c ut0ut.c
+
+ut0mem.obj: ut0mem.c
+ $(CCOM) $(CFL) -c ut0mem.c
+
+ut0byte.obj: ut0byte.c
+ $(CCOM) $(CFL) -c ut0byte.c
+
+ut0dbg.obj: ut0dbg.c
+ $(CCOM) $(CFL) -c ut0dbg.c
+
+ut0rnd.obj: ut0rnd.c
+ $(CCOM) $(CFL) -c ut0rnd.c
+
+
diff --git a/innobase/ut/ts/makefile b/innobase/ut/ts/makefile
new file mode 100644
index 00000000000..5ef15ade794
--- /dev/null
+++ b/innobase/ut/ts/makefile
@@ -0,0 +1,12 @@
+
+include ..\..\makefile.i
+
+tsut: ..\ut.lib tsut.c
+ $(CCOM) $(CFL) -I.. -I..\.. ..\ut.lib ..\..\os.lib tsut.c $(LFL)
+
+
+
+
+
+
+
diff --git a/innobase/ut/ts/tsut.c b/innobase/ut/ts/tsut.c
new file mode 100644
index 00000000000..81c9ff79f96
--- /dev/null
+++ b/innobase/ut/ts/tsut.c
@@ -0,0 +1,347 @@
+/************************************************************************
+The test module for the utilities
+
+(c) 1995 Innobase Oy
+
+Created 10/28/1995 Heikki Tuuri
+*************************************************************************/
+
+#include "../ut0lst.h"
+#include "../ut0mem.h"
+#include "../ut0byte.h"
+#include "../ut0sort.h"
+#include "../ut0rnd.h"
+
+typedef struct node_struct node_t;
+struct node_struct {
+ ulint index;
+ ulint zyx;
+ UT_LIST_NODE_T(node_t) list1;
+ ulint yzx;
+ UT_LIST_NODE_T(node_t) list2;
+};
+
+/* Arrays to be sorted */
+ulint uarr[100000];
+ulint aux_uarr[100000];
+dulint duarr[100000];
+dulint aux_duarr[100000];
+
+/*********************************************************************
+Tests for two-way lists. */
+
+void
+test1(void)
+/*=======*/
+{
+ ulint i;
+ UT_LIST_BASE_NODE_T(node_t) base1;
+ UT_LIST_BASE_NODE_T(node_t) base2;
+ node_t* node;
+ node_t* node2;
+
+ printf("-------------------------------------------\n");
+ printf("TEST 1. Test of two-way lists \n");
+
+ UT_LIST_INIT(base1);
+ UT_LIST_INIT(base2);
+
+ for (i = 0; i < 1000; i++) {
+ node = ut_malloc(sizeof(node_t));
+
+ node->index = 999 - i;
+
+ UT_LIST_ADD_FIRST(list1, base1, node);
+ UT_LIST_ADD_LAST(list2, base2, node);
+ }
+
+ UT_LIST_VALIDATE(list1, node_t, base1);
+ UT_LIST_VALIDATE(list2, node_t, base2);
+
+ node = UT_LIST_GET_FIRST(base1);
+
+ for (i = 0; i < 1000; i++) {
+
+ ut_a(node);
+ ut_a(node->index == i);
+
+ node = UT_LIST_GET_NEXT(list1, node);
+ }
+
+ ut_a(node == NULL);
+
+ node = UT_LIST_GET_FIRST(base2);
+
+ for (i = 0; i < 1000; i++) {
+
+ ut_a(node);
+ ut_a(node->index == 999 - i);
+
+ node = UT_LIST_GET_NEXT(list2, node);
+ }
+
+ ut_a(node == NULL);
+
+ UT_LIST_VALIDATE(list1, node_t, base1);
+ UT_LIST_VALIDATE(list2, node_t, base2);
+
+ node = UT_LIST_GET_FIRST(base1);
+
+ for (i = 0; i < 500; i++) {
+
+ ut_a(node);
+ ut_a(node->index == i);
+
+ node = UT_LIST_GET_NEXT(list1, node);
+ }
+
+ for (i = 0; i < 100; i++) {
+ node2 = ut_malloc(sizeof(node_t));
+
+ node2->index = 99 - i;
+
+ UT_LIST_INSERT_AFTER(list1, base1, node, node2);
+ UT_LIST_VALIDATE(list1, node_t, base1);
+ }
+
+ node2 = ut_malloc(sizeof(node_t));
+ node2->index = 1000;
+ UT_LIST_INSERT_AFTER(list1, base1, UT_LIST_GET_LAST(base1), node2);
+
+ node2 = node;
+
+ for (i = 0; i < 100; i++) {
+ node2 = UT_LIST_GET_NEXT(list1, node2);
+
+ ut_a(node2);
+ ut_a(node2->index == i);
+ }
+
+ UT_LIST_VALIDATE(list1, node_t, base1);
+
+ for (i = 0; i < 600; i++) {
+
+ node2 = UT_LIST_GET_NEXT(list1, node);
+
+ UT_LIST_REMOVE(list1, base1, node2);
+ UT_LIST_VALIDATE(list1, node_t, base1);
+ }
+
+ node2 = UT_LIST_GET_NEXT(list1, node);
+
+ UT_LIST_VALIDATE(list1, node_t, base1);
+ UT_LIST_VALIDATE(list2, node_t, base2);
+
+ ut_a(UT_LIST_GET_LEN(base1) == 501);
+
+ ut_a(UT_LIST_GET_LAST(base1) == node);
+
+ for (i = 0; i < 500; i++) {
+
+ node = UT_LIST_GET_PREV(list1, node);
+ }
+
+ ut_a(UT_LIST_GET_FIRST(base1) == node);
+
+ for (i = 0; i < 501; i++) {
+
+ node2 = UT_LIST_GET_FIRST(base1);
+
+ UT_LIST_REMOVE(list1, base1, node2);
+ }
+
+ UT_LIST_VALIDATE(list1, node_t, base1);
+ UT_LIST_VALIDATE(list2, node_t, base2);
+
+ ut_a(UT_LIST_GET_LEN(base1) == 0);
+ ut_a(UT_LIST_GET_LEN(base2) == 1000);
+}
+
+/*********************************************************************
+Tests for dulints. */
+
+void
+test2(void)
+/*=======*/
+{
+ dulint a, b;
+
+ printf("-------------------------------------------\n");
+ printf("TEST 2. Test of dulints \n");
+
+ a = ut_dulint_create(0xFFFFFFFF, 0xFFFFFFFF);
+
+ b = a;
+
+ ut_a(ut_dulint_cmp(a, b) == 0);
+
+ ut_a(ut_dulint_get_low(b) == 0xFFFFFFFF);
+ ut_a(ut_dulint_get_high(b) == 0xFFFFFFFF);
+
+ a = ut_dulint_create(0xFFFFFFFE, 0xFFFFFFFF);
+ ut_a(ut_dulint_cmp(a, b) == -1);
+ ut_a(ut_dulint_cmp(b, a) == 1);
+
+ a = ut_dulint_create(0xFFFFFFFF, 0xFFFFFFFE);
+ ut_a(ut_dulint_cmp(a, b) == -1);
+ ut_a(ut_dulint_cmp(b, a) == 1);
+
+ a = ut_dulint_create(5, 0xFFFFFFFF);
+
+ a = ut_dulint_add(a, 5);
+
+ ut_a(ut_dulint_get_low(a) == 4);
+ ut_a(ut_dulint_get_high(a) == 6);
+
+ a = ut_dulint_create(5, 0x80000000);
+
+ a = ut_dulint_add(a, 0x80000000);
+
+ ut_a(ut_dulint_get_low(a) == 0);
+ ut_a(ut_dulint_get_high(a) == 6);
+
+ a = ut_dulint_create(5, 10);
+
+ a = ut_dulint_add(a, 20);
+
+ ut_a(ut_dulint_get_low(a) == 30);
+ ut_a(ut_dulint_get_high(a) == 5);
+}
+
+/***************************************************************
+Comparison function for ulints. */
+UNIV_INLINE
+int
+cmp_ulint(ulint a, ulint b)
+/*=======================*/
+{
+ if (a < b) {
+ return(-1);
+ } else if (b < a) {
+ return(1);
+ } else {
+ return(0);
+ }
+}
+
+/****************************************************************
+Sort function for ulint arrays. */
+void
+sort_ulint(ulint* arr, ulint* aux_arr, ulint low, ulint high)
+/*=========================================================*/
+{
+ ut_ad(high <= 100000);
+
+ UT_SORT_FUNCTION_BODY(sort_ulint, arr, aux_arr, low, high,
+ cmp_ulint);
+}
+
+/****************************************************************
+Sort function for dulint arrays. */
+void
+sort_dulint(dulint* arr, dulint* aux_arr, ulint low, ulint high)
+/*=========================================================*/
+{
+ ut_ad(high <= 100000);
+
+ UT_SORT_FUNCTION_BODY(sort_dulint, arr, aux_arr, low, high,
+ ut_dulint_cmp);
+}
+
+/*********************************************************************
+Tests for sorting. */
+
+void
+test3(void)
+/*=======*/
+{
+ ulint i, j;
+ ulint tm, oldtm;
+
+ printf("-------------------------------------------\n");
+ printf("TEST 3. Test of sorting \n");
+
+ for (i = 0; i < 100000; i++) {
+ uarr[i] = ut_rnd_gen_ulint();
+ }
+
+ oldtm = ut_clock();
+
+ for (j = 0; j < 1; j++) {
+ i = 100000;
+
+ sort_ulint(uarr, aux_uarr, 0, i);
+ }
+
+ tm = ut_clock();
+
+ printf("Wall clock time for sort of %lu ulints %lu millisecs\n",
+ j * i, tm - oldtm);
+
+ for (i = 1; i < 100000; i++) {
+ ut_a(uarr[i - 1] < uarr[i]);
+ }
+
+ for (i = 0; i < 100000; i++) {
+ uarr[i] = 99999 - i;
+ }
+
+ sort_ulint(uarr, aux_uarr, 0, 100000);
+
+ for (i = 1; i < 100000; i++) {
+ ut_a(uarr[i] == i);
+ }
+
+ sort_ulint(uarr, aux_uarr, 0, 100000);
+
+ for (i = 1; i < 100000; i++) {
+ ut_a(uarr[i] == i);
+ }
+
+ sort_ulint(uarr, aux_uarr, 5, 6);
+
+ for (i = 1; i < 100000; i++) {
+ ut_a(uarr[i] == i);
+ }
+
+ for (i = 0; i < 100000; i++) {
+ uarr[i] = 5;
+ }
+
+ sort_ulint(uarr, aux_uarr, 0, 100000);
+
+ for (i = 1; i < 100000; i++) {
+ ut_a(uarr[i] == 5);
+ }
+
+ for (i = 0; i < 100000; i++) {
+ duarr[i] = ut_dulint_create(ut_rnd_gen_ulint() & 0xFFFFFFFF,
+ ut_rnd_gen_ulint() & 0xFFFFFFFF);
+ }
+
+ oldtm = ut_clock();
+
+ i = 100000;
+
+ sort_dulint(duarr, aux_duarr, 0, i);
+
+ tm = ut_clock();
+
+ printf("Wall clock time for sort of %lu dulints %lu millisecs\n",
+ j * i, tm - oldtm);
+
+ for (i = 1; i < 100000; i++) {
+ ut_a(ut_dulint_cmp(duarr[i - 1], duarr[i]) < 0);
+ }
+
+}
+
+void
+main(void)
+{
+ test1();
+ test2();
+ test3();
+
+ printf("TEST SUCCESSFULLY COMPLETED!\n");
+}
diff --git a/innobase/ut/ut0byte.c b/innobase/ut/ut0byte.c
new file mode 100644
index 00000000000..fa0d904a6a7
--- /dev/null
+++ b/innobase/ut/ut0byte.c
@@ -0,0 +1,32 @@
+/*******************************************************************
+Byte utilities
+
+(c) 1994, 1995 Innobase Oy
+
+Created 5/11/1994 Heikki Tuuri
+********************************************************************/
+
+#include "ut0byte.h"
+
+#ifdef UNIV_NONINL
+#include "ut0byte.ic"
+#endif
+
+#include "ut0sort.h"
+
+/* Zero value for a dulint */
+dulint ut_dulint_zero = {0, 0};
+
+/* Maximum value for a dulint */
+dulint ut_dulint_max = {0xFFFFFFFF, 0xFFFFFFFF};
+
+/****************************************************************
+Sort function for dulint arrays. */
+void
+ut_dulint_sort(dulint* arr, dulint* aux_arr, ulint low, ulint high)
+/*===============================================================*/
+{
+ UT_SORT_FUNCTION_BODY(ut_dulint_sort, arr, aux_arr, low, high,
+ ut_dulint_cmp);
+}
+
diff --git a/innobase/ut/ut0dbg.c b/innobase/ut/ut0dbg.c
new file mode 100644
index 00000000000..970dd501fad
--- /dev/null
+++ b/innobase/ut/ut0dbg.c
@@ -0,0 +1,27 @@
+/*********************************************************************
+Debug utilities for Innobase.
+
+(c) 1994, 1995 Innobase Oy
+
+Created 1/30/1994 Heikki Tuuri
+**********************************************************************/
+
+#include "univ.i"
+
+/* This is used to eliminate compiler warnings */
+ulint ut_dbg_zero = 0;
+
+/* If this is set to TRUE all threads will stop into the next assertion
+and assert */
+ibool ut_dbg_stop_threads = FALSE;
+
+/* Null pointer used to generate memory trap */
+
+ulint* ut_dbg_null_ptr = NULL;
+
+/* Dummy function to prevent gcc from ignoring this file */
+void
+ut_dummy(void)
+{
+ printf("Hello world\n");
+}
diff --git a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c
new file mode 100644
index 00000000000..492f57670a9
--- /dev/null
+++ b/innobase/ut/ut0mem.c
@@ -0,0 +1,69 @@
+/************************************************************************
+Memory primitives
+
+(c) 1994, 1995 Innobase Oy
+
+Created 5/11/1994 Heikki Tuuri
+*************************************************************************/
+
+#include "ut0mem.h"
+
+#ifdef UNIV_NONINL
+#include "ut0mem.ic"
+#endif
+
+#include "mem0mem.h"
+
+void*
+ut_malloc(ulint n)
+{
+ void* ret;
+ /*
+ ret = VirtualAlloc(NULL, n, MEM_COMMIT, PAGE_READWRITE);
+ */
+
+ ret = malloc(n);
+
+ if (ret == NULL) {
+ fprintf(stderr,
+ "Innobase: Fatal error: cannot allocate memory!\n");
+ fprintf(stderr,
+ "Innobase: Cannot continue operation!\n");
+ fprintf(stderr,
+ "Innobase: Check if you can increase the swap file of your\n");
+ fprintf(stderr,
+ "Innobase: operating system.\n");
+
+ exit(1);
+ }
+
+ return(ret);
+}
+
+/**************************************************************************
+Catenates two strings into newly allocated memory. The memory must be freed
+using mem_free. */
+
+char*
+ut_str_catenate(
+/*============*/
+ /* out, own: catenated null-terminated string */
+ char* str1, /* in: null-terminated string */
+ char* str2) /* in: null-terminated string */
+{
+ ulint len1;
+ ulint len2;
+ char* str;
+
+ len1 = ut_strlen(str1);
+ len2 = ut_strlen(str2);
+
+ str = mem_alloc(len1 + len2 + 1);
+
+ ut_memcpy(str, str1, len1);
+ ut_memcpy(str + len1, str2, len2);
+
+ str[len1 + len2] = '\0';
+
+ return(str);
+}
diff --git a/innobase/ut/ut0rnd.c b/innobase/ut/ut0rnd.c
new file mode 100644
index 00000000000..3335861384f
--- /dev/null
+++ b/innobase/ut/ut0rnd.c
@@ -0,0 +1,79 @@
+/*******************************************************************
+Random numbers and hashing
+
+(c) 1994, 1995 Innobase Oy
+
+Created 5/11/1994 Heikki Tuuri
+********************************************************************/
+
+#include "ut0rnd.h"
+
+#ifdef UNIV_NONINL
+#include "ut0rnd.ic"
+#endif
+
+/* These random numbers are used in ut_find_prime */
+#define UT_RANDOM_1 1.0412321
+#define UT_RANDOM_2 1.1131347
+#define UT_RANDOM_3 1.0132677
+
+
+ulint ut_rnd_ulint_counter = 65654363;
+
+/***************************************************************
+Looks for a prime number slightly greater than the given argument.
+The prime is chosen so that it is not near any power of 2. */
+
+ulint
+ut_find_prime(
+/*==========*/
+ /* out: prime */
+ ulint n) /* in: positive number > 100 */
+{
+ ulint pow2;
+ ulint i;
+
+ n += 100;
+
+ pow2 = 1;
+ while (pow2 * 2 < n) {
+ pow2 = 2 * pow2;
+ }
+
+ if ((double)n < 1.05 * (double)pow2) {
+ n = (ulint) ((double)n * UT_RANDOM_1);
+ }
+
+ pow2 = 2 * pow2;
+
+ if ((double)n > 0.95 * (double)pow2) {
+ n = (ulint) ((double)n * UT_RANDOM_2);
+ }
+
+ if (n > pow2 - 20) {
+ n += 30;
+ }
+
+ /* Now we have n far enough from powers of 2. To make
+ n more random (especially, if it was not near
+ a power of 2), we then multiply it by a random number. */
+
+ n = (ulint) ((double)n * UT_RANDOM_3);
+
+ for (;; n++) {
+ i = 2;
+ while (i * i <= n) {
+ if (n % i == 0) {
+ goto next_n;
+ }
+ i++;
+ }
+
+ /* Found a prime */
+ break;
+ next_n: ;
+ }
+
+ return(n);
+}
+
diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c
new file mode 100644
index 00000000000..8af1f7487f4
--- /dev/null
+++ b/innobase/ut/ut0ut.c
@@ -0,0 +1,164 @@
+/*******************************************************************
+Various utilities for Innobase.
+
+(c) 1994, 1995 Innobase Oy
+
+Created 5/11/1994 Heikki Tuuri
+********************************************************************/
+
+#include "ut0ut.h"
+
+#ifdef UNIV_NONINL
+#include "ut0ut.ic"
+#endif
+
+#include "ut0sort.h"
+
+ibool ut_always_false = FALSE;
+
+/************************************************************
+The following function returns a clock time in milliseconds. */
+
+ulint
+ut_clock(void)
+{
+ return((clock() * 1000) / CLOCKS_PER_SEC);
+}
+
+/**************************************************************
+Returns system time. We do not specify the format of the time returned:
+the only way to manipulate it is to use the function ut_difftime. */
+
+ib_time_t
+ut_time(void)
+/*=========*/
+{
+ return(time(NULL));
+}
+
+/**************************************************************
+Returns the difference of two times in seconds. */
+
+double
+ut_difftime(
+/*========*/
+ /* out: time2 - time1 expressed in seconds */
+ ib_time_t time2, /* in: time */
+ ib_time_t time1) /* in: time */
+{
+ return(difftime(time2, time1));
+}
+
+/*****************************************************************
+Runs an idle loop on CPU. The argument gives the desired delay
+in microseconds on 100 MHz Pentium + Visual C++. */
+
+ulint
+ut_delay(
+/*=====*/
+ /* out: dummy value */
+ ulint delay) /* in: delay in microseconds on 100 MHz Pentium */
+{
+ ulint i, j;
+
+ j = 0;
+
+ for (i = 0; i < delay * 50; i++) {
+ j += i;
+ }
+
+ if (ut_always_false) {
+ printf("%lu", j);
+ }
+
+ return(j);
+}
+
+/*****************************************************************
+Prints the contents of a memory buffer in hex and ascii. */
+
+void
+ut_print_buf(
+/*=========*/
+ byte* buf, /* in: memory buffer */
+ ulint len) /* in: length of the buffer */
+{
+ byte* data;
+ ulint i;
+
+ printf(" len %lu; hex ", len);
+
+ data = buf;
+
+ for (i = 0; i < len; i++) {
+ printf("%02x", (ulint)*data);
+ data++;
+ }
+
+ printf("; asc ");
+
+ data = buf;
+
+ for (i = 0; i < len; i++) {
+ if (isprint((char)(*data))) {
+ printf("%c", (char)*data);
+ }
+ data++;
+ }
+
+ printf(";");
+}
+
+/*****************************************************************
+Prints the contents of a memory buffer in hex and ascii. */
+
+ulint
+ut_sprintf_buf(
+/*===========*/
+ /* out: printed length in bytes */
+ char* str, /* in: buffer to print to */
+ byte* buf, /* in: memory buffer */
+ ulint len) /* in: length of the buffer */
+{
+ byte* data;
+ ulint n;
+ ulint i;
+
+ n = 0;
+
+ n += sprintf(str + n, " len %lu; hex ", len);
+
+ data = buf;
+
+ for (i = 0; i < len; i++) {
+ n += sprintf(str + n, "%02x", (ulint)*data);
+ data++;
+ }
+
+ n += sprintf(str + n, "; asc ");
+
+ data = buf;
+
+ for (i = 0; i < len; i++) {
+ if (isprint((char)(*data))) {
+ n += sprintf(str + n, "%c", (char)*data);
+ }
+
+ data++;
+ }
+
+ n += sprintf(str + n, ";");
+
+ return(n);
+}
+
+/****************************************************************
+Sort function for ulint arrays. */
+
+void
+ut_ulint_sort(ulint* arr, ulint* aux_arr, ulint low, ulint high)
+/*============================================================*/
+{
+ UT_SORT_FUNCTION_BODY(ut_ulint_sort, arr, aux_arr, low, high,
+ ut_ulint_cmp);
+}