Commit eeeaa19b authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.1-new

into serg.mylan:/usr/home/serg/Abk/mysql-5.1

parents 6e20d34b 740077bd
...@@ -1772,3 +1772,4 @@ zlib/*.ds? ...@@ -1772,3 +1772,4 @@ zlib/*.ds?
zlib/*.vcproj zlib/*.vcproj
libmysqld/event_scheduler.cc libmysqld/event_scheduler.cc
mysys/test_atomic mysys/test_atomic
*-t
...@@ -155,84 +155,6 @@ fi ...@@ -155,84 +155,6 @@ fi
]) ])
#---START: Used in for client configure
AC_DEFUN([MYSQL_CHECK_ULONG],
[AC_MSG_CHECKING(for type ulong)
AC_CACHE_VAL(ac_cv_ulong,
[AC_TRY_RUN([#include <stdio.h>
#include <sys/types.h>
main()
{
ulong foo;
foo++;
exit(0);
}], ac_cv_ulong=yes, ac_cv_ulong=no, ac_cv_ulong=no)])
AC_MSG_RESULT($ac_cv_ulong)
if test "$ac_cv_ulong" = "yes"
then
AC_DEFINE([HAVE_ULONG], [1], [system headers define ulong])
fi
])
AC_DEFUN([MYSQL_CHECK_UCHAR],
[AC_MSG_CHECKING(for type uchar)
AC_CACHE_VAL(ac_cv_uchar,
[AC_TRY_RUN([#include <stdio.h>
#include <sys/types.h>
main()
{
uchar foo;
foo++;
exit(0);
}], ac_cv_uchar=yes, ac_cv_uchar=no, ac_cv_uchar=no)])
AC_MSG_RESULT($ac_cv_uchar)
if test "$ac_cv_uchar" = "yes"
then
AC_DEFINE([HAVE_UCHAR], [1], [system headers define uchar])
fi
])
AC_DEFUN([MYSQL_CHECK_UINT],
[AC_MSG_CHECKING(for type uint)
AC_CACHE_VAL(ac_cv_uint,
[AC_TRY_RUN([#include <stdio.h>
#include <sys/types.h>
main()
{
uint foo;
foo++;
exit(0);
}], ac_cv_uint=yes, ac_cv_uint=no, ac_cv_uint=no)])
AC_MSG_RESULT($ac_cv_uint)
if test "$ac_cv_uint" = "yes"
then
AC_DEFINE([HAVE_UINT], [1], [system headers define uint])
fi
])
AC_DEFUN([MYSQL_CHECK_IN_ADDR_T],
[AC_MSG_CHECKING(for type in_addr_t)
AC_CACHE_VAL(ac_cv_in_addr_t,
[AC_TRY_RUN([#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main(int argc, char **argv)
{
in_addr_t foo;
exit(0);
}], ac_cv_in_addr_t=yes, ac_cv_in_addr_t=no, ac_cv_in_addr_t=no)])
AC_MSG_RESULT($ac_cv_in_addr_t)
if test "$ac_cv_in_addr_t" = "yes"
then
AC_DEFINE([HAVE_IN_ADDR_T], [1], [system headers define in_addr_t])
fi
])
AC_DEFUN([MYSQL_PTHREAD_YIELD], AC_DEFUN([MYSQL_PTHREAD_YIELD],
[AC_CACHE_CHECK([if pthread_yield takes zero arguments], ac_cv_pthread_yield_zero_arg, [AC_CACHE_CHECK([if pthread_yield takes zero arguments], ac_cv_pthread_yield_zero_arg,
[AC_TRY_LINK([#define _GNU_SOURCE [AC_TRY_LINK([#define _GNU_SOURCE
...@@ -272,25 +194,6 @@ fi ...@@ -272,25 +194,6 @@ fi
#---END: #---END:
AC_DEFUN([MYSQL_CHECK_FP_EXCEPT],
[AC_MSG_CHECKING(for type fp_except)
AC_CACHE_VAL(ac_cv_fp_except,
[AC_TRY_RUN([#include <stdio.h>
#include <sys/types.h>
#include <ieeefp.h>
main()
{
fp_except foo;
foo++;
exit(0);
}], ac_cv_fp_except=yes, ac_cv_fp_except=no, ac_cv_fp_except=no)])
AC_MSG_RESULT($ac_cv_fp_except)
if test "$ac_cv_fp_except" = "yes"
then
AC_DEFINE([HAVE_FP_EXCEPT], [1], [fp_except from ieeefp.h])
fi
])
# From fileutils-3.14/aclocal.m4 # From fileutils-3.14/aclocal.m4
# @defmac AC_PROG_CC_STDC # @defmac AC_PROG_CC_STDC
......
...@@ -829,38 +829,20 @@ fi ...@@ -829,38 +829,20 @@ fi
# Later in this script LIBS will be augmented with a threads library. # Later in this script LIBS will be augmented with a threads library.
NON_THREADED_LIBS="$LIBS" NON_THREADED_LIBS="$LIBS"
AC_MSG_CHECKING([for int8]) AC_CHECK_TYPES([int8, uint8, int16, uint16, int32, uint32, int64, uint64,
case $SYSTEM_TYPE in uchar, uint, ulong],[],[], [
*netware)
AC_MSG_RESULT([no])
;;
*)
AC_TRY_RUN([
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif ])
AC_CHECK_TYPES([in_addr_t], [], [], [
int main() #include <sys/types.h>
{ #include <sys/socket.h>
int8 i; #include <netinet/in.h>
return 0; #include <arpa/inet.h>
} ])
], AC_CHECK_TYPES([fp_except], [], [], [
[AC_DEFINE([HAVE_INT_8_16_32], [1], #include <sys/types.h>
[whether int8, int16 and int32 types exist]) #include <ieeefp.h>
AC_MSG_RESULT([yes])], ])
[AC_MSG_RESULT([no])]
)
;;
esac
# #
# Some system specific hacks # Some system specific hacks
...@@ -1734,16 +1716,6 @@ MYSQL_FUNC_ALLOCA ...@@ -1734,16 +1716,6 @@ MYSQL_FUNC_ALLOCA
MYSQL_TIMESPEC_TS MYSQL_TIMESPEC_TS
# Do we have the tzname variable # Do we have the tzname variable
MYSQL_TZNAME MYSQL_TZNAME
# Do the system files define ulong
MYSQL_CHECK_ULONG
# Do the system files define uchar
MYSQL_CHECK_UCHAR
# Do the system files define uint
MYSQL_CHECK_UINT
# Check for fp_except in ieeefp.h
MYSQL_CHECK_FP_EXCEPT
# Check for IN_ADDR_T
MYSQL_CHECK_IN_ADDR_T
# Do the c++ compiler have a bool type # Do the c++ compiler have a bool type
MYSQL_CXX_BOOL MYSQL_CXX_BOOL
# Check some common bugs with gcc 2.8.# on sparc # Check some common bugs with gcc 2.8.# on sparc
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
cmpxchg8b, if necessary cmpxchg8b, if necessary
*/ */
/* fix -ansi errors while maintaining readability */
#define asm __asm__
#define make_atomic_add_body8 \ #define make_atomic_add_body8 \
asm volatile (LOCK "xadd %0, %1;" : "+r" (v) , "+m" (a->val)) asm volatile (LOCK "xadd %0, %1;" : "+r" (v) , "+m" (a->val))
#define make_atomic_swap_body8 \ #define make_atomic_swap_body8 \
......
...@@ -864,26 +864,36 @@ typedef void *gptr; /* Generic pointer */ ...@@ -864,26 +864,36 @@ typedef void *gptr; /* Generic pointer */
#else #else
typedef char *gptr; /* Generic pointer */ typedef char *gptr; /* Generic pointer */
#endif #endif
#ifndef HAVE_INT_8_16_32
typedef signed char int8; /* Signed integer >= 8 bits */
typedef short int16; /* Signed integer >= 16 bits */
#endif
#ifndef HAVE_UCHAR #ifndef HAVE_UCHAR
typedef unsigned char uchar; /* Short for unsigned char */ typedef unsigned char uchar; /* Short for unsigned char */
#endif #endif
typedef unsigned char uint8; /* Short for unsigned integer >= 8 bits */
typedef unsigned short uint16; /* Short for unsigned integer >= 16 bits */
#ifndef HAVE_INT8
typedef signed char int8; /* Signed integer >= 8 bits */
#endif
#ifndef HAVE_UINT8
typedef unsigned char uint8; /* Unsigned integer >= 8 bits */
#endif
#ifndef HAVE_INT16
typedef short int16;
#endif
#ifndef HAVE_UINT16
typedef unsigned short uint16;
#endif
#if SIZEOF_INT == 4 #if SIZEOF_INT == 4
#ifndef HAVE_INT_8_16_32 #ifndef HAVE_INT32
typedef int int32; typedef int int32;
#endif #endif
typedef unsigned int uint32; /* Short for unsigned integer >= 32 bits */ #ifndef HAVE_UINT32
typedef unsigned int uint32;
#endif
#elif SIZEOF_LONG == 4 #elif SIZEOF_LONG == 4
#ifndef HAVE_INT_8_16_32 #ifndef HAVE_INT32
typedef long int32; typedef long int32;
#endif #endif
typedef unsigned long uint32; /* Short for unsigned integer >= 32 bits */ #ifndef HAVE_UINT32
typedef unsigned long uint32;
#endif
#else #else
#error "Neither int or long is of 4 bytes width" #error "Neither int or long is of 4 bytes width"
#endif #endif
...@@ -900,8 +910,12 @@ typedef unsigned long ulonglong; /* ulong or unsigned long long */ ...@@ -900,8 +910,12 @@ typedef unsigned long ulonglong; /* ulong or unsigned long long */
typedef long longlong; typedef long longlong;
#endif #endif
#endif #endif
#ifndef HAVE_INT64
typedef longlong int64; typedef longlong int64;
#endif
#ifndef HAVE_UINT64
typedef ulonglong uint64; typedef ulonglong uint64;
#endif
#if defined(NO_CLIENT_LONG_LONG) #if defined(NO_CLIENT_LONG_LONG)
typedef unsigned long my_ulonglong; typedef unsigned long my_ulonglong;
......
...@@ -821,8 +821,9 @@ extern ulong crc32(ulong crc, const uchar *buf, uint len); ...@@ -821,8 +821,9 @@ extern ulong crc32(ulong crc, const uchar *buf, uint len);
extern uint my_set_max_open_files(uint files); extern uint my_set_max_open_files(uint files);
void my_free_open_file_info(void); void my_free_open_file_info(void);
ulonglong my_getsystime(void); extern ulonglong my_getsystime(void);
my_bool my_gethwaddr(uchar *to); extern my_bool my_gethwaddr(uchar *to);
extern int my_getncpus();
#ifdef HAVE_SYS_MMAN_H #ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h> #include <sys/mman.h>
......
...@@ -63,7 +63,6 @@ libmysys_a_LIBADD = @THREAD_LOBJECTS@ ...@@ -63,7 +63,6 @@ libmysys_a_LIBADD = @THREAD_LOBJECTS@
# testhash_DEPENDENCIES= $(LIBRARIES) # testhash_DEPENDENCIES= $(LIBRARIES)
# test_charset_DEPENDENCIES= $(LIBRARIES) # test_charset_DEPENDENCIES= $(LIBRARIES)
# charset2html_DEPENDENCIES= $(LIBRARIES) # charset2html_DEPENDENCIES= $(LIBRARIES)
noinst_PROGRAMS= test_atomic$(EXEEXT)
DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \ DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
-DDATADIR="\"$(MYSQLDATAdir)\"" \ -DDATADIR="\"$(MYSQLDATAdir)\"" \
-DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \ -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
......
SUBDIRS = mytap . mysys examples SUBDIRS = mytap . mysys examples
noinst_SCRIPTS = unit noinst_SCRIPTS = unit
#EXTRA_DIST = unit.pl
EXTRA_DIST = unit.pl unittests = mytap mysys
DISTCLEANFILES = unit test: unit
./unit run $(unittests)
unittests = mysys examples
.PHONY: all mytap mysys examples test
test: unit all
@./unit run $(unittests)
mytap:
cd mytap && $(MAKE)
mysys:
cd mysys && $(MAKE)
examples:
cd examples && $(MAKE)
unit: $(srcdir)/unit.pl unit: $(srcdir)/unit.pl
cp $(srcdir)/unit.pl $@ cp $(srcdir)/unit.pl $@
chmod +x $@ chmod 700 $@
...@@ -7,14 +7,14 @@ will be added over time. ...@@ -7,14 +7,14 @@ will be added over time.
mytap Source for the MyTAP library mytap Source for the MyTAP library
mysys Tests for mysys components mysys Tests for mysys components
bitmap.t.c Unit test for MY_BITMAP bitmap-t.c Unit test for MY_BITMAP
base64.t.c Unit test for base64 encoding functions base64-t.c Unit test for base64 encoding functions
examples Example unit tests examples Example unit tests
simple.t.c Example of a standard TAP unit test simple-t.c Example of a standard TAP unit test
skip.t.c Example where some test points are skipped skip-t.c Example where some test points are skipped
skip_all.t.c Example of a test where the entire test is skipped skip_all-t.c Example of a test where the entire test is skipped
todo.t.c Example where test contain test points that are TODO todo-t.c Example where test contain test points that are TODO
no_plan.t.c Example of a test with no plan (avoid this) no_plan-t.c Example of a test with no plan (avoid this)
Executing unit tests Executing unit tests
...@@ -28,9 +28,12 @@ To make and execute all unit tests in the directory: ...@@ -28,9 +28,12 @@ To make and execute all unit tests in the directory:
Adding unit tests Adding unit tests
----------------- -----------------
Add a file with a name of the format "foo.t.c" to the appropriate Add a file with a name of the format "foo-t.c" to the appropriate
directory and add the following to the Makefile.am in that directory directory and add the following to the Makefile.am in that directory
(where ... denotes stuff already there): (where ... denotes stuff already there):
noinst_PROGRAMS = ... foo.t noinst_PROGRAMS = ... foo-t
foo_t_c_SOURCES = foo.t.c
Note, it's important to have "-t" at the end of the filename, otherwise the
test won't be executed by 'make test' !
...@@ -5,14 +5,5 @@ AM_LDFLAGS = -L$(top_builddir)/unittest/mytap ...@@ -5,14 +5,5 @@ AM_LDFLAGS = -L$(top_builddir)/unittest/mytap
LDADD = -lmytap LDADD = -lmytap
noinst_PROGRAMS = simple.t skip.t todo.t skip_all.t no_plan.t noinst_PROGRAMS = simple-t skip-t todo-t skip_all-t no_plan-t
simple_t_SOURCES = simple.t.c
skip_t_SOURCES = skip.t.c
todo_t_SOURCES = todo.t.c
skip_all_t_SOURCES = skip_all.t.c
no_plan_t_SOURCES = no_plan.t.c
...@@ -7,9 +7,5 @@ AM_LDFLAGS += -L$(top_builddir)/strings -L$(top_builddir)/dbug ...@@ -7,9 +7,5 @@ AM_LDFLAGS += -L$(top_builddir)/strings -L$(top_builddir)/dbug
LDADD = -lmytap -lmysys -ldbug -lmystrings LDADD = -lmytap -lmysys -ldbug -lmystrings
noinst_PROGRAMS = bitmap.t base64.t noinst_PROGRAMS = bitmap-t base64-t my_atomic-t
bitmap_t_SOURCES = bitmap.t.c
base64_t_SOURCES = base64.t.c
/* Copyright (C) 2006 MySQL AB
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 <tap.h>
#include <my_global.h> #include <my_global.h>
#include <my_sys.h> #include <my_sys.h>
#include <my_atomic.h> #include <my_atomic.h>
...@@ -25,6 +43,7 @@ pthread_handler_t test_atomic_add_handler(void *arg) ...@@ -25,6 +43,7 @@ pthread_handler_t test_atomic_add_handler(void *arg)
N--; N--;
if (!N) pthread_cond_signal(&cond); if (!N) pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
return 0;
} }
/* /*
...@@ -54,6 +73,7 @@ pthread_handler_t test_atomic_swap_handler(void *arg) ...@@ -54,6 +73,7 @@ pthread_handler_t test_atomic_swap_handler(void *arg)
N--; N--;
if (!N) pthread_cond_signal(&cond); if (!N) pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
return 0;
} }
/* /*
...@@ -75,6 +95,7 @@ pthread_handler_t test_atomic_cas_handler(void *arg) ...@@ -75,6 +95,7 @@ pthread_handler_t test_atomic_cas_handler(void *arg)
N--; N--;
if (!N) pthread_cond_signal(&cond); if (!N) pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
return 0;
} }
void test_atomic(const char *test, pthread_handler handler, int n, int m) void test_atomic(const char *test, pthread_handler handler, int n, int m)
...@@ -86,7 +107,7 @@ void test_atomic(const char *test, pthread_handler handler, int n, int m) ...@@ -86,7 +107,7 @@ void test_atomic(const char *test, pthread_handler handler, int n, int m)
my_atomic_store32(&b32, 0, &rwl); my_atomic_store32(&b32, 0, &rwl);
my_atomic_store32(&c32, 0, &rwl); my_atomic_store32(&c32, 0, &rwl);
printf("Testing %s with %d threads, %d iterations... ", test, n, m); diag("Testing %s with %d threads, %d iterations... ", test, n, m);
for (N=n ; n ; n--) for (N=n ; n ; n--)
pthread_create(&t, &thr_attr, handler, &m); pthread_create(&t, &thr_attr, handler, &m);
...@@ -95,24 +116,19 @@ void test_atomic(const char *test, pthread_handler handler, int n, int m) ...@@ -95,24 +116,19 @@ void test_atomic(const char *test, pthread_handler handler, int n, int m)
pthread_cond_wait(&cond, &mutex); pthread_cond_wait(&cond, &mutex);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
now=my_getsystime()-now; now=my_getsystime()-now;
printf("got %lu in %g secs\n", my_atomic_load32(&a32, &rwl), ok(my_atomic_load32(&a32, &rwl) == 0,
((double)now)/1e7); "tested %s in %g secs", test, ((double)now)/1e7);
} }
int main() int main()
{ {
int err; int err;
#ifdef _IONBF diag("N CPUs: %d", my_getncpus());
setvbuf(stdout, 0, _IONBF, 0); err= my_atomic_initialize();
#endif
printf("N CPUs: %d\n", my_getncpus());
if ((err= my_atomic_initialize())) plan(4);
{ ok(err == 0, "my_atomic_initialize() returned %d", err);
printf("my_atomic_initialize() failed. Error=%d\n", err);
return 1;
}
pthread_attr_init(&thr_attr); pthread_attr_init(&thr_attr);
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
...@@ -128,6 +144,6 @@ int main() ...@@ -128,6 +144,6 @@ int main()
pthread_cond_destroy(&cond); pthread_cond_destroy(&cond);
pthread_attr_destroy(&thr_attr); pthread_attr_destroy(&thr_attr);
my_atomic_rwlock_destroy(&rwl); my_atomic_rwlock_destroy(&rwl);
return 0; return exit_status();
} }
...@@ -5,8 +5,5 @@ AM_LDFLAGS = -L$(top_builddir)/unittest/mytap ...@@ -5,8 +5,5 @@ AM_LDFLAGS = -L$(top_builddir)/unittest/mytap
LDADD = -lmytap LDADD = -lmytap
noinst_PROGRAMS = basic.t noinst_PROGRAMS = basic-t
basic_t_SOURCES = basic.t.c
all: $(noinst_PROGRAMS)
...@@ -59,7 +59,7 @@ sub _find_test_files (@) { ...@@ -59,7 +59,7 @@ sub _find_test_files (@) {
my @files; my @files;
find sub { find sub {
$File::Find::prune = 1 if /^SCCS$/; $File::Find::prune = 1 if /^SCCS$/;
push(@files, $File::Find::name) if -x _ && /\.t\z/; push(@files, $File::Find::name) if -x _ && /-t\z/;
}, @dirs; }, @dirs;
return @files; return @files;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment