summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CMakeLists.txt61
-rw-r--r--include/Makefile.am3
-rw-r--r--include/keycache.h2
-rw-r--r--include/my_global.h111
-rw-r--r--include/my_pthread.h18
-rw-r--r--include/my_sys.h3
-rw-r--r--include/mysql/plugin.h29
-rw-r--r--include/thr_alarm.h2
8 files changed, 200 insertions, 29 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
new file mode 100644
index 00000000000..c16f8ea1ff8
--- /dev/null
+++ b/include/CMakeLists.txt
@@ -0,0 +1,61 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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; version 2 of the License.
+#
+# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+SET(HEADERS_GEN_CONFIGURE
+${CMAKE_CURRENT_BINARY_DIR}/mysql_version.h
+${CMAKE_CURRENT_BINARY_DIR}/my_config.h
+${CMAKE_CURRENT_BINARY_DIR}/mysqld_ername.h
+${CMAKE_CURRENT_BINARY_DIR}/mysqld_error.h
+${CMAKE_CURRENT_BINARY_DIR}/sql_state.h
+)
+SET(HEADERS_ABI
+ mysql.h
+ mysql_com.h
+ mysql_time.h
+ my_list.h
+ my_alloc.h
+ typelib.h
+)
+
+SET(HEADERS
+ ${HEADERS_ABI}
+ my_dbug.h
+ m_string.h
+ my_sys.h
+ my_xml.h
+ mysql_embed.h
+ my_pthread.h
+ my_no_pthread.h
+ decimal.h
+ errmsg.h
+ my_global.h
+ my_net.h
+ my_getopt.h
+ sslopt-longopts.h
+ my_dir.h
+ sslopt-vars.h
+ sslopt-case.h
+ sql_common.h
+ keycache.h
+ m_ctype.h
+ my_attribute.h
+ ${HEADERS_GEN_CONFIGURE}
+)
+
+INSTALL(FILES ${HEADERS} DESTINATION include)
+INSTALL(DIRECTORY mysql/ DESTINATION include
+ FILES_MATCHING PATTERN "*.h")
+
+
diff --git a/include/Makefile.am b/include/Makefile.am
index 0a7a35bd6fa..f9a069bc4b5 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -43,7 +43,8 @@ noinst_HEADERS = config-win.h config-netware.h my_bit.h \
atomic/solaris.h \
atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h
-EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp probes_mysql.d.base
+EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp probes_mysql.d.base \
+ CMakeLists.txt
# Remove built files and the symlinked directories
CLEANFILES = $(BUILT_SOURCES) readline openssl probes_mysql.d probes_mysql_nodtrace.h
diff --git a/include/keycache.h b/include/keycache.h
index a6005bae878..1ffb1dbb71f 100644
--- a/include/keycache.h
+++ b/include/keycache.h
@@ -67,7 +67,7 @@ typedef struct st_key_cache
HASH_LINK *free_hash_list; /* list of free hash links */
BLOCK_LINK *free_block_list; /* list of free blocks */
BLOCK_LINK *block_root; /* memory for block links */
- uchar HUGE_PTR *block_mem; /* memory for block buffers */
+ uchar *block_mem; /* memory for block buffers */
BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */
BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */
pthread_mutex_t cache_lock; /* to lock access to the cache structure */
diff --git a/include/my_global.h b/include/my_global.h
index f6d1592fc6f..c95861204d7 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -68,8 +68,8 @@
#define C_MODE_END
#endif
-#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
-#include <config-win.h>
+#if defined(_WIN32)
+#include <my_config.h>
#elif defined(__NETWARE__)
#include <my_config.h>
#include <config-netware.h>
@@ -107,6 +107,49 @@
#define NETWARE_SET_SCREEN_MODE(A)
#endif
+#if defined (_WIN32)
+/*
+ off_t is 32 bit long. We do not use C runtime functions
+ with off_t but native Win32 file IO APIs, that work with
+ 64 bit offsets.
+*/
+#undef SIZEOF_OFF_T
+#define SIZEOF_OFF_T 8
+
+/*
+ Prevent inclusion of Windows GDI headers - they define symbol
+ ERROR that conflicts with mysql headers.
+*/
+#ifndef NOGDI
+#define NOGDI
+#endif
+
+/* Include common headers.*/
+#include <winsock2.h>
+#include <ws2tcpip.h> /* SOCKET */
+#include <io.h> /* access(), chmod() */
+#include <process.h> /* getpid() */
+
+#define sleep(a) Sleep((a)*1000)
+
+/* Define missing access() modes. */
+#define F_OK 0
+#define W_OK 2
+
+/* Define missing file locking constants. */
+#define F_RDLCK 1
+#define F_WRLCK 2
+#define F_UNLCK 3
+#define F_TO_EOF 0x3FFFFFFF
+
+/* Shared memory and named pipe connections are supported. */
+#define HAVE_SMEM 1
+#define HAVE_NAMED_PIPE 1
+#define shared_memory_buffer_length 16000
+#define default_shared_memory_base_name "MYSQL"
+#endif /* _WIN32*/
+
+
/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
#if defined(_AIX) && defined(_LARGE_FILE_API)
#undef _LARGE_FILE_API
@@ -486,8 +529,11 @@ C_MODE_END
/* Go around some bugs in different OS and compilers */
#if defined (HPUX11) && defined(_LARGEFILE_SOURCE)
+#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
+#endif
+
#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
#include <sys/stream.h> /* HPUX 10.20 defines ulong here. UGLY !!! */
#define HAVE_ULONG
@@ -656,7 +702,9 @@ C_MODE_END
/* Some types that is different between systems */
typedef int File; /* File descriptor */
-#ifndef Socket_defined
+#ifdef _WIN32
+typedef SOCKET my_socket;
+#else
typedef int my_socket; /* File descriptor for sockets */
#define INVALID_SOCKET -1
#endif
@@ -744,7 +792,13 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define FN_CURLIB '.' /* ./ is used as abbrev for current dir */
#define FN_PARENTDIR ".." /* Parent directory; Must be a string */
-#ifndef FN_LIBCHAR
+#ifdef _WIN32
+#define FN_LIBCHAR '\\'
+#define FN_ROOTDIR "\\"
+#define FN_DEVCHAR ':'
+#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
+#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
+#else
#define FN_LIBCHAR '/'
#define FN_ROOTDIR "/"
#endif
@@ -828,6 +882,31 @@ typedef SOCKET_SIZE_TYPE size_socket;
#undef remove /* Crashes MySQL on SCO 5.0.0 */
#ifndef __WIN__
#define closesocket(A) close(A)
+#endif
+
+#if (_MSC_VER)
+#if !defined(_WIN64)
+inline double my_ulonglong2double(unsigned long long value)
+{
+ long long nr=(long long) value;
+ if (nr >= 0)
+ return (double) nr;
+ return (18446744073709551616.0 + (double) nr);
+}
+#define ulonglong2double my_ulonglong2double
+#define my_off_t2double my_ulonglong2double
+#endif /* _WIN64 */
+inline unsigned long long my_double2ulonglong(double d)
+{
+ double t= d - (double) 0x8000000000000000ULL;
+
+ if (t >= 0)
+ return ((unsigned long long) t) + 0x8000000000000000ULL;
+ return (unsigned long long) d;
+}
+#define double2ulonglong my_double2ulonglong
+#endif
+
#ifndef ulonglong2double
#define ulonglong2double(A) ((double) (ulonglong) (A))
#define my_off_t2double(A) ((double) (my_off_t) (A))
@@ -835,7 +914,6 @@ typedef SOCKET_SIZE_TYPE size_socket;
#ifndef double2ulonglong
#define double2ulonglong(A) ((ulonglong) (double) (A))
#endif
-#endif
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
@@ -1092,15 +1170,18 @@ typedef long long intptr;
#define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T
#endif /* USE_RAID */
+#if defined(_WIN32)
+typedef unsigned long long my_off_t;
+typedef unsigned long long os_off_t;
+#else
+typedef off_t os_off_t;
#if SIZEOF_OFF_T > 4
typedef ulonglong my_off_t;
#else
typedef unsigned long my_off_t;
#endif
+#endif /*_WIN32*/
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
-#if !defined(__WIN__)
-typedef off_t os_off_t;
-#endif
#if defined(__WIN__)
#define socket_errno WSAGetLastError()
@@ -1127,9 +1208,6 @@ typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */
typedef short int15; /* Most effective integer 0 <= x <= 32767 */
typedef int myf; /* Type of MyFlags in my_funcs */
typedef char my_bool; /* Small bool */
-#if !defined(bool) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
-typedef char bool; /* Ordinary boolean values 0 1 */
-#endif
/* Macros for converting *constants* to the right type */
#define INT8(v) (int8) (v)
#define INT16(v) (int16) (v)
@@ -1522,12 +1600,15 @@ do { doubleget_union _tmp; \
#define NO_EMBEDDED_ACCESS_CHECKS
#endif
-#ifdef HAVE_DLOPEN
-#if defined(__WIN__)
-#define dlsym(lib, name) GetProcAddress((HMODULE)lib, name)
+#if defined(_WIN32)
+#define dlsym(lib, name) (void*)GetProcAddress((HMODULE)lib, name)
#define dlopen(libname, unused) LoadLibraryEx(libname, NULL, 0)
#define dlclose(lib) FreeLibrary((HMODULE)lib)
-#elif defined(HAVE_DLFCN_H)
+#define HAVE_DLOPEN
+#endif
+
+#ifdef HAVE_DLOPEN
+#if defined(HAVE_DLFCN_H)
#include <dlfcn.h>
#endif
#endif
diff --git a/include/my_pthread.h b/include/my_pthread.h
index b6d9feae067..9f46d1f76c1 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -117,9 +117,11 @@ struct tm *gmtime_r(const time_t *timep,struct tm *tmp);
void pthread_exit(void *a);
int pthread_join(pthread_t thread, void **value_ptr);
+int pthread_cancel(pthread_t thread);
-
+#ifndef ETIMEDOUT
#define ETIMEDOUT 145 /* Win32 doesn't have this */
+#endif
#define HAVE_LOCALTIME_R 1
#define _REENTRANT 1
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
@@ -154,6 +156,7 @@ int pthread_join(pthread_t thread, void **value_ptr);
#define pthread_condattr_destroy(A)
#define my_pthread_getprio(thread_id) pthread_dummy(0)
+#define my_sigset(A,B) signal(A,B)
#else /* Normal threads */
@@ -699,25 +702,32 @@ extern uint thd_lib_detected;
Warning:
When compiling without threads, this file is not included.
See the *other* declarations of thread_safe_xxx in include/my_global.h
-
- Second warning:
- See include/config-win.h, for yet another implementation.
*/
#ifdef THREAD
#ifndef thread_safe_increment
+#ifdef _WIN32
+#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
+#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V))
+#else
#define thread_safe_increment(V,L) \
(pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L)))
#define thread_safe_decrement(V,L) \
(pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L)))
#endif
+#endif
#ifndef thread_safe_add
+#ifdef _WIN32
+#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
+#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
+#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)))
#endif
#endif
+#endif
/*
statistics_xxx functions are for non critical statistic,
diff --git a/include/my_sys.h b/include/my_sys.h
index 9121f0f249e..ea466653372 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -34,6 +34,9 @@ extern int NEAR my_errno; /* Last error in mysys */
#include <m_ctype.h> /* for CHARSET_INFO */
#include <stdarg.h>
#include <typelib.h>
+#ifdef _WIN32
+#include <malloc.h> /*for alloca*/
+#endif
#define MYSYS_PROGRAM_USES_CURSES() { error_handler_hook = my_message_curses; mysys_uses_curses=1; }
#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index f158dc20999..289d1f06fbc 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -18,10 +18,25 @@
/*
On Windows, exports from DLL need to be declared
-*/
-#if (defined(_WIN32) && defined(MYSQL_DYNAMIC_PLUGIN))
-#define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
-#else
+ Also, plugin needs to be declared as extern "C" because MSVC
+ unlike other compilers, uses C++ mangling for variables not only
+ for functions.
+*/
+#if defined(_MSC_VER)
+#if defined(MYSQL_DYNAMIC_PLUGIN)
+ #ifdef __cplusplus
+ #define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
+ #else
+ #define MYSQL_PLUGIN_EXPORT __declspec(dllexport)
+ #endif
+#else /* MYSQL_DYNAMIC_PLUGIN */
+ #ifdef __cplusplus
+ #define MYSQL_PLUGIN_EXPORT extern "C"
+ #else
+ #define MYSQL_PLUGIN_EXPORT
+ #endif
+#endif /*MYSQL_DYNAMIC_PLUGIN */
+#else /*_MSC_VER */
#define MYSQL_PLUGIN_EXPORT
#endif
@@ -87,9 +102,9 @@ typedef struct st_mysql_xid MYSQL_XID;
#ifndef MYSQL_DYNAMIC_PLUGIN
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \
-int VERSION= MYSQL_PLUGIN_INTERFACE_VERSION; \
-int PSIZE= sizeof(struct st_mysql_plugin); \
-struct st_mysql_plugin DECLS[]= {
+MYSQL_PLUGIN_EXPORT int VERSION= MYSQL_PLUGIN_INTERFACE_VERSION; \
+MYSQL_PLUGIN_EXPORT int PSIZE= sizeof(struct st_mysql_plugin); \
+MYSQL_PLUGIN_EXPORT struct st_mysql_plugin DECLS[]= {
#else
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \
MYSQL_PLUGIN_EXPORT int _mysql_plugin_interface_version_= MYSQL_PLUGIN_INTERFACE_VERSION; \
diff --git a/include/thr_alarm.h b/include/thr_alarm.h
index fb906039269..8d7f5bcdee0 100644
--- a/include/thr_alarm.h
+++ b/include/thr_alarm.h
@@ -64,7 +64,7 @@ typedef my_bool ALARM;
#if defined(__WIN__)
typedef struct st_thr_alarm_entry
{
- rf_SetTimer crono;
+ UINT_PTR crono;
} thr_alarm_entry;
#else /* System with posix threads */