mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
0fa5279543
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BitKeeper/deleted/.del-database.c~af098622e818ce0d: Auto merged BitKeeper/deleted/.del-have_openssl_2.inc~8c9f1a45676b698f: Auto merged BitKeeper/deleted/.del-have_openssl_2.require~53bbdfc136fb514: Auto merged BitKeeper/deleted/.del-mini_client.cc~8677895ec8169183: Auto merged BitKeeper/deleted/.del-openssl_2.test~f2dfa927f19d14f8: Auto merged Build-tools/Bootstrap: Auto merged Build-tools/Do-compile: Auto merged SSL/cacert.pem: Auto merged acconfig.h: Auto merged acinclude.m4: Auto merged configure.in: Auto merged SSL/client-cert.pem: Auto merged SSL/client-key.pem: Auto merged SSL/server-cert.pem: Auto merged SSL/server-key.pem: Auto merged VC++Files/client/mysql.dsp: Auto merged VC++Files/client/mysqladmin.dsp: Auto merged VC++Files/client/mysqlclient.dsp: Auto merged VC++Files/client/mysqldump.dsp: Auto merged VC++Files/client/mysqlimport.dsp: Auto merged VC++Files/client/mysqlshow.dsp: Auto merged VC++Files/comp_err/comp_err.dsp: Auto merged VC++Files/innobase/innobase.dsp: Auto merged VC++Files/isamchk/isamchk.dsp: Auto merged VC++Files/libmysql/libmysql.dsp: Auto merged VC++Files/libmysqltest/myTest.dsp: Auto merged VC++Files/my_print_defaults/my_print_defaults.dsp: Auto merged VC++Files/myisamlog/myisamlog.dsp: Auto merged VC++Files/mysql.dsw: Auto merged VC++Files/mysqlbinlog/mysqlbinlog.dsp: Auto merged VC++Files/mysqlcheck/mysqlcheck.dsp: Auto merged VC++Files/mysqlmanager/MySqlManager.dsp: Auto merged VC++Files/mysqlserver/mysqlserver.dsp: Auto merged VC++Files/mysqlshutdown/mysqlshutdown.dsp: Auto merged VC++Files/mysys/mysys.dsp: Auto merged VC++Files/pack_isam/pack_isam.dsp: Auto merged VC++Files/perror/perror.dsp: Auto merged VC++Files/replace/replace.dsp: Auto merged VC++Files/test1/test1.dsp: Auto merged VC++Files/thr_test/thr_test.dsp: Auto merged VC++Files/vio/vio.dsp: Auto merged VC++Files/zlib/zlib.dsp: Auto merged client/mysqlbinlog.cc: Auto merged client/mysqldump.c: Auto merged client/mysqlimport.c: Auto merged extra/my_print_defaults.c: Auto merged extra/resolveip.c: Auto merged include/m_string.h: Auto merged include/my_sys.h: Auto merged include/mysql_com.h: Auto merged innobase/dict/dict0dict.c: Auto merged innobase/os/os0file.c: Auto merged isam/_search.c: Auto merged libmysql/Makefile.am: Auto merged libmysql/errmsg.c: Auto merged libmysql/libmysql.c: Auto merged myisam/mi_check.c: Auto merged myisam/mi_create.c: Auto merged myisam/mi_open.c: Auto merged myisam/mi_search.c: Auto merged myisam/mi_write.c: Auto merged myisam/myisamchk.c: Auto merged myisam/myisamlog.c: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/group_by.result: Auto merged mysql-test/r/isam.result: Auto merged mysql-test/r/loaddata.result: Auto merged mysql-test/r/lowercase_table.result: Auto merged mysql-test/r/multi_update.result: Auto merged mysql-test/r/openssl_1.result: Auto merged mysql-test/r/packet.result: Auto merged mysql-test/r/query_cache.result: Auto merged mysql-test/r/range.result: Auto merged mysql-test/r/select_safe.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/t/grant.test: Auto merged mysql-test/t/group_by.test: Auto merged mysql-test/t/lock_tables_lost_commit-master.opt: Auto merged mysql-test/t/lowercase_table.test: Auto merged mysql-test/t/multi_update.test: Auto merged mysql-test/t/openssl_1.test: Auto merged mysql-test/t/range.test: Auto merged mysql-test/t/rpl_loaddata.test: Auto merged mysql-test/t/rpl_log.test: Auto merged mysql-test/t/select_safe.test: Auto merged mysql-test/t/show_check.test: Auto merged mysql-test/t/symlink.test: Auto merged mysys/default.c: Auto merged mysys/my_getopt.c: Auto merged mysys/my_pthread.c: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/make_win_src_distribution.sh: Auto merged scripts/mysql_install_db.sh: Auto merged scripts/mysqld_safe.sh: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/item_uniq.h: Auto merged sql/log_event.h: Auto merged sql/net_serv.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_update.cc: Auto merged vio/Makefile.am: Auto merged vio/vio.c: Auto merged mysql-test/t/myisam.test: merge with 4.0.15 Extra tests mysys/mf_keycache.c: Keep local file
343 lines
10 KiB
C
343 lines
10 KiB
C
/* Copyright (C) 2000 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 */
|
|
|
|
/* Defines for Win32 to make it compatible for MySQL */
|
|
|
|
#ifdef __WIN2000__
|
|
/* We have to do this define before including windows.h to get the AWE API
|
|
functions */
|
|
#define _WIN32_WINNT 0x0500
|
|
#endif
|
|
|
|
#include <sys/locking.h>
|
|
#include <windows.h>
|
|
#include <math.h> /* Because of rint() */
|
|
#include <fcntl.h>
|
|
#include <io.h>
|
|
#include <malloc.h>
|
|
|
|
#define HAVE_SMEM 1
|
|
|
|
#if defined(__NT__)
|
|
#define SYSTEM_TYPE "NT"
|
|
#elif defined(__WIN2000__)
|
|
#define SYSTEM_TYPE "WIN2000"
|
|
#else
|
|
#define SYSTEM_TYPE "Win95/Win98"
|
|
#endif
|
|
|
|
#if defined(_WIN64) || defined(WIN64)
|
|
#define MACHINE_TYPE "ia64" /* Define to machine type name */
|
|
#else
|
|
#define MACHINE_TYPE "i32" /* Define to machine type name */
|
|
#ifndef _WIN32
|
|
#define _WIN32 /* Compatible with old source */
|
|
#endif
|
|
#ifndef __WIN32__
|
|
#define __WIN32__
|
|
#endif
|
|
#endif /* _WIN64 */
|
|
#ifndef __WIN__
|
|
#define __WIN__ /* To make it easier in VC++ */
|
|
#endif
|
|
|
|
/* File and lock constants */
|
|
#define O_SHARE 0x1000 /* Open file in sharing mode */
|
|
#ifdef __BORLANDC__
|
|
#define F_RDLCK LK_NBLCK /* read lock */
|
|
#define F_WRLCK LK_NBRLCK /* write lock */
|
|
#define F_UNLCK LK_UNLCK /* remove lock(s) */
|
|
#else
|
|
#define F_RDLCK _LK_NBLCK /* read lock */
|
|
#define F_WRLCK _LK_NBRLCK /* write lock */
|
|
#define F_UNLCK _LK_UNLCK /* remove lock(s) */
|
|
#endif
|
|
|
|
#define F_EXCLUSIVE 1 /* We have only exclusive locking */
|
|
#define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */
|
|
#define F_OK 0 /* parameter to access() */
|
|
|
|
#define S_IROTH S_IREAD /* for my_lib */
|
|
|
|
#ifdef __BORLANDC__
|
|
#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
|
|
#define O_TEMPORARY 0
|
|
#define O_SHORT_LIVED 0
|
|
#define SH_DENYNO _SH_DENYNO
|
|
#else
|
|
#define O_BINARY _O_BINARY /* compability with MSDOS */
|
|
#define FILE_BINARY _O_BINARY /* my_fopen in binary mode */
|
|
#define O_TEMPORARY _O_TEMPORARY
|
|
#define O_SHORT_LIVED _O_SHORT_LIVED
|
|
#define SH_DENYNO _SH_DENYNO
|
|
#endif
|
|
#define NO_OPEN_3 /* For my_create() */
|
|
|
|
#define SIGQUIT SIGTERM /* No SIGQUIT */
|
|
|
|
#undef _REENTRANT /* Crashes something for win32 */
|
|
#undef SAFE_MUTEX /* Can't be used on windows */
|
|
|
|
#define LONGLONG_MIN ((__int64) 0x8000000000000000)
|
|
#define LONGLONG_MAX ((__int64) 0x7FFFFFFFFFFFFFFF)
|
|
#define LL(A) ((__int64) A)
|
|
|
|
/* Type information */
|
|
|
|
typedef unsigned short ushort;
|
|
typedef unsigned int uint;
|
|
typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
|
|
typedef __int64 longlong;
|
|
typedef int sigset_t;
|
|
#define longlong_defined
|
|
/* off_t should not be __int64 because of conflicts in header files;
|
|
Use my_off_t or os_off_t instead */
|
|
typedef long off_t;
|
|
typedef __int64 os_off_t;
|
|
#ifdef _WIN64
|
|
typedef UINT_PTR rf_SetTimer;
|
|
#else
|
|
typedef unsigned int size_t;
|
|
typedef uint rf_SetTimer;
|
|
#endif
|
|
|
|
#define Socket_defined
|
|
#define my_socket SOCKET
|
|
#define bool BOOL
|
|
#define SIGPIPE SIGINT
|
|
#define RETQSORTTYPE void
|
|
#define QSORT_TYPE_IS_VOID
|
|
#define RETSIGTYPE void
|
|
#define SOCKET_SIZE_TYPE int
|
|
#define my_socket_defined
|
|
#define bool_defined
|
|
#define byte_defined
|
|
#define HUGE_PTR
|
|
#define STDCALL __stdcall /* Used by libmysql.dll */
|
|
#define isnan(X) _isnan(X)
|
|
#define finite(X) _finite(X)
|
|
|
|
#ifndef UNDEF_THREAD_HACK
|
|
#define THREAD
|
|
#endif
|
|
#define VOID_SIGHANDLER
|
|
#define SIZEOF_CHAR 1
|
|
#define SIZEOF_LONG 4
|
|
#define SIZEOF_LONG_LONG 8
|
|
#define SIZEOF_OFF_T 8
|
|
#ifdef _WIN64
|
|
#define SIZEOF_CHARP 8
|
|
#else
|
|
#define SIZEOF_CHARP 4
|
|
#endif
|
|
#define HAVE_BROKEN_NETINET_INCLUDES
|
|
#ifdef __NT__
|
|
#define HAVE_NAMED_PIPE /* We can only create pipes on NT */
|
|
#endif
|
|
|
|
/* We need to close files to break connections on shutdown */
|
|
#ifndef SIGNAL_WITH_VIO_CLOSE
|
|
#define SIGNAL_WITH_VIO_CLOSE
|
|
#endif
|
|
|
|
/* Use all character sets in MySQL */
|
|
#define USE_MB 1
|
|
#define USE_MB_IDENT 1
|
|
#define USE_STRCOLL 1
|
|
|
|
/* If LOAD DATA LOCAL INFILE should be enabled by default */
|
|
#define ENABLED_LOCAL_INFILE 1
|
|
|
|
/* Convert some simple functions to Posix */
|
|
|
|
#define sigset(A,B) signal((A),(B))
|
|
#define finite(A) _finite(A)
|
|
#define sleep(A) Sleep((A)*1000)
|
|
|
|
#ifndef __BORLANDC__
|
|
#define access(A,B) _access(A,B)
|
|
#endif
|
|
|
|
#if !defined(__cplusplus)
|
|
#define inline __inline
|
|
#endif /* __cplusplus */
|
|
|
|
inline double rint(double nr)
|
|
{
|
|
double f = floor(nr);
|
|
double c = ceil(nr);
|
|
return (((c-nr) >= (nr-f)) ? f :c);
|
|
}
|
|
|
|
#ifdef _WIN64
|
|
#define ulonglong2double(A) ((double) (A))
|
|
#define my_off_t2double(A) ((double) (A))
|
|
|
|
#else
|
|
inline double ulonglong2double(ulonglong value)
|
|
{
|
|
longlong nr=(longlong) value;
|
|
if (nr >= 0)
|
|
return (double) nr;
|
|
return (18446744073709551616.0 + (double) nr);
|
|
}
|
|
#define my_off_t2double(A) ulonglong2double(A)
|
|
#endif /* _WIN64 */
|
|
|
|
#if SIZEOF_OFF_T > 4
|
|
#define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
|
|
#define tell(A) _telli64(A)
|
|
#endif
|
|
|
|
#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; }
|
|
|
|
#define STACK_DIRECTION -1
|
|
|
|
/* Optimized store functions for Intel x86 */
|
|
|
|
#ifndef _WIN64
|
|
#define sint2korr(A) (*((int16 *) (A)))
|
|
#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \
|
|
(((uint32) 255L << 24) | \
|
|
(((uint32) (uchar) (A)[2]) << 16) |\
|
|
(((uint32) (uchar) (A)[1]) << 8) | \
|
|
((uint32) (uchar) (A)[0])) : \
|
|
(((uint32) (uchar) (A)[2]) << 16) |\
|
|
(((uint32) (uchar) (A)[1]) << 8) | \
|
|
((uint32) (uchar) (A)[0])))
|
|
#define sint4korr(A) (*((long *) (A)))
|
|
#define uint2korr(A) (*((uint16 *) (A)))
|
|
#define uint3korr(A) (long) (*((unsigned long *) (A)) & 0xFFFFFF)
|
|
#define uint4korr(A) (*((unsigned long *) (A)))
|
|
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
|
|
(((uint32) ((uchar) (A)[1])) << 8) +\
|
|
(((uint32) ((uchar) (A)[2])) << 16) +\
|
|
(((uint32) ((uchar) (A)[3])) << 24)) +\
|
|
(((ulonglong) ((uchar) (A)[4])) << 32))
|
|
#define uint8korr(A) (*((ulonglong *) (A)))
|
|
#define sint8korr(A) (*((longlong *) (A)))
|
|
#define int2store(T,A) *((uint16*) (T))= (uint16) (A)
|
|
#define int3store(T,A) { *(T)= (uchar) ((A));\
|
|
*(T+1)=(uchar) (((uint) (A) >> 8));\
|
|
*(T+2)=(uchar) (((A) >> 16)); }
|
|
#define int4store(T,A) *((long *) (T))= (long) (A)
|
|
#define int5store(T,A) { *(T)= (uchar)((A));\
|
|
*((T)+1)=(uchar) (((A) >> 8));\
|
|
*((T)+2)=(uchar) (((A) >> 16));\
|
|
*((T)+3)=(uchar) (((A) >> 24)); \
|
|
*((T)+4)=(uchar) (((A) >> 32)); }
|
|
#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A)
|
|
|
|
#define doubleget(V,M) { *((long *) &V) = *((long*) M); \
|
|
*(((long *) &V)+1) = *(((long*) M)+1); }
|
|
#define doublestore(T,V) { *((long *) T) = *((long*) &V); \
|
|
*(((long *) T)+1) = *(((long*) &V)+1); }
|
|
#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
|
|
#define float8get(V,M) doubleget((V),(M))
|
|
#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
|
|
#define float8store(V,M) doublestore((V),(M))
|
|
#endif /* _WIN64 */
|
|
|
|
#define HAVE_PERROR
|
|
#define HAVE_VFPRINT
|
|
#define HAVE_RENAME /* Have rename() as function */
|
|
#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */
|
|
#define HAVE_LONG_JMP /* Have long jump function */
|
|
#define HAVE_LOCKING /* have locking() call */
|
|
#define HAVE_ERRNO_AS_DEFINE /* errno is a define */
|
|
#define HAVE_STDLIB /* everything is include in this file */
|
|
#define HAVE_MEMCPY
|
|
#define HAVE_MEMMOVE
|
|
#define HAVE_GETCWD
|
|
#define HAVE_TELL
|
|
#define HAVE_TZNAME
|
|
#define HAVE_PUTENV
|
|
#define HAVE_SELECT
|
|
#define HAVE_SETLOCALE
|
|
#define HAVE_SOCKET /* Giangi */
|
|
#define HAVE_FLOAT_H
|
|
#define HAVE_LIMITS_H
|
|
#define HAVE_STDDEF_H
|
|
#define HAVE_RINT /* defined in this file */
|
|
#define NO_FCNTL_NONBLOCK /* No FCNTL */
|
|
#define HAVE_ALLOCA
|
|
#define HAVE_STRPBRK
|
|
#define HAVE_STRSTR
|
|
#define HAVE_COMPRESS
|
|
#define HAVE_CREATESEMAPHORE
|
|
#define HAVE_ISNAN
|
|
#define HAVE_FINITE
|
|
#define HAVE_ISAM /* We want to have support for ISAM in 4.0 */
|
|
#define HAVE_QUERY_CACHE
|
|
#define SPRINTF_RETURNS_INT
|
|
#define HAVE_SETFILEPOINTER
|
|
#define HAVE_VIO
|
|
|
|
#ifdef NOT_USED
|
|
#define HAVE_SNPRINTF /* Gave link error */
|
|
#define _snprintf snprintf
|
|
#endif
|
|
|
|
#ifdef _MSC_VER
|
|
#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
|
|
#define HAVE_ANSI_INCLUDE
|
|
#define HAVE_SYS_UTIME_H
|
|
#define HAVE_STRTOUL
|
|
#endif
|
|
#define my_reinterpret_cast(A) reinterpret_cast <A>
|
|
#define my_const_cast(A) const_cast<A>
|
|
|
|
|
|
/* MYSQL OPTIONS */
|
|
|
|
#ifdef _CUSTOMCONFIG_
|
|
#include <custom_conf.h>
|
|
#else
|
|
#define DEFAULT_MYSQL_HOME "c:\\mysql"
|
|
#define PACKAGE "mysql"
|
|
#define DEFAULT_BASEDIR "C:\\"
|
|
#define SHAREDIR "share"
|
|
#define DEFAULT_CHARSET_HOME "C:/mysql/"
|
|
#endif
|
|
|
|
/* File name handling */
|
|
|
|
#define FN_LIBCHAR '\\'
|
|
#define FN_ROOTDIR "\\"
|
|
#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
|
|
#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
|
|
#define MY_NFILE 1024
|
|
|
|
#define DO_NOT_REMOVE_THREAD_WRAPPERS
|
|
#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
|
|
/* The following is only used for statistics, so it should be good enough */
|
|
#ifdef __NT__ /* This should also work on Win98 but .. */
|
|
#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
|
|
#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
|
|
#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
|
|
#else
|
|
#define thread_safe_add(V,C,L) \
|
|
pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
|
|
#define thread_safe_sub(V,C,L) \
|
|
pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
|
|
#define statistic_add(V,C,L) (V)+=(C)
|
|
#endif
|
|
#define statistic_increment(V,L) thread_safe_increment((V),(L))
|
|
|
|
#define shared_memory_buffer_length 16000
|
|
#define default_shared_memory_base_name "MYSQL"
|
|
#define MYSQL_DEFAULT_CHARSET_NAME "latin1"
|
|
#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
|