summaryrefslogtreecommitdiff
path: root/storage/ndb/include/portlib
diff options
context:
space:
mode:
Diffstat (limited to 'storage/ndb/include/portlib')
-rw-r--r--storage/ndb/include/portlib/NdbCondition.h94
-rw-r--r--storage/ndb/include/portlib/NdbConfig.h39
-rw-r--r--storage/ndb/include/portlib/NdbDaemon.h72
-rw-r--r--storage/ndb/include/portlib/NdbEnv.h34
-rw-r--r--storage/ndb/include/portlib/NdbHost.h43
-rw-r--r--storage/ndb/include/portlib/NdbMain.h66
-rw-r--r--storage/ndb/include/portlib/NdbMem.h81
-rw-r--r--storage/ndb/include/portlib/NdbMutex.h113
-rw-r--r--storage/ndb/include/portlib/NdbSleep.h38
-rw-r--r--storage/ndb/include/portlib/NdbTCP.h96
-rw-r--r--storage/ndb/include/portlib/NdbThread.h102
-rw-r--r--storage/ndb/include/portlib/NdbTick.h69
-rw-r--r--storage/ndb/include/portlib/PortDefs.h53
-rw-r--r--storage/ndb/include/portlib/prefetch.h69
14 files changed, 969 insertions, 0 deletions
diff --git a/storage/ndb/include/portlib/NdbCondition.h b/storage/ndb/include/portlib/NdbCondition.h
new file mode 100644
index 00000000000..3d959a0db41
--- /dev/null
+++ b/storage/ndb/include/portlib/NdbCondition.h
@@ -0,0 +1,94 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef NDB_CONDITION_H
+#define NDB_CONDITION_H
+
+#include "NdbMutex.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct NdbCondition;
+
+
+/**
+ * Create a condition
+ *
+ * returnvalue: pointer to the condition structure
+ */
+struct NdbCondition* NdbCondition_Create(void);
+
+/**
+ * Wait for a condition, allows a thread to wait for
+ * a condition and atomically releases the associated mutex.
+ *
+ * p_cond: pointer to the condition structure
+ * p_mutex: pointer to the mutex structure
+ * returnvalue: 0 = succeeded, 1 = failed
+ */
+int NdbCondition_Wait(struct NdbCondition* p_cond,
+ NdbMutex* p_mutex);
+
+/*
+ * Wait for a condition with timeout, allows a thread to
+ * wait for a condition and atomically releases the associated mutex.
+ *
+ * @param p_cond - pointer to the condition structure
+ * @param p_mutex - pointer to the mutex structure
+ * @param msec - Wait for msec milli seconds the most
+ * @return 0 = succeeded, 1 = failed
+ * @
+ */
+int
+NdbCondition_WaitTimeout(struct NdbCondition* p_cond,
+ NdbMutex* p_mutex,
+ int msec);
+
+
+/**
+ * Signal a condition
+ *
+ * p_cond: pointer to the condition structure
+ * returnvalue: 0 = succeeded, 1 = failed
+ */
+int NdbCondition_Signal(struct NdbCondition* p_cond);
+
+
+/**
+ * Broadcast a condition
+ *
+ * p_cond: pointer to the condition structure
+ * returnvalue: 0 = succeeded, 1 = failed
+ */
+int NdbCondition_Broadcast(struct NdbCondition* p_cond);
+
+/**
+ * Destroy a condition
+ *
+ * p_cond: pointer to the condition structure
+ * returnvalue: 0 = succeeded, 1 = failed
+ */
+int NdbCondition_Destroy(struct NdbCondition* p_cond);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/storage/ndb/include/portlib/NdbConfig.h b/storage/ndb/include/portlib/NdbConfig.h
new file mode 100644
index 00000000000..1bca825ab8d
--- /dev/null
+++ b/storage/ndb/include/portlib/NdbConfig.h
@@ -0,0 +1,39 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef NDB_CONFIG_H
+#define NDB_CONFIG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const char* NdbConfig_get_path(int *len);
+void NdbConfig_SetPath(const char *path);
+char* NdbConfig_NdbCfgName(int with_ndb_home);
+char* NdbConfig_ErrorFileName(int node_id);
+char* NdbConfig_ClusterLogFileName(int node_id);
+char* NdbConfig_SignalLogFileName(int node_id);
+char* NdbConfig_TraceFileName(int node_id, int file_no);
+char* NdbConfig_NextTraceFileName(int node_id);
+char* NdbConfig_PidFileName(int node_id);
+char* NdbConfig_StdoutFileName(int node_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/storage/ndb/include/portlib/NdbDaemon.h b/storage/ndb/include/portlib/NdbDaemon.h
new file mode 100644
index 00000000000..74ea3f06419
--- /dev/null
+++ b/storage/ndb/include/portlib/NdbDaemon.h
@@ -0,0 +1,72 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef NDB_DAEMON_H
+#define NDB_DAEMON_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Become a daemon.
+ * lockfile the "pid file" or other resource to lock exclusively
+ * logfile daemon output is directed here (input is set to /dev/null)
+ * if NULL, output redirection is not done
+ * flags none currently
+ * returns 0 on success, on error -1
+ */
+extern int
+NdbDaemon_Make(const char* lockfile, const char* logfile, unsigned flags);
+
+/*
+ * Test if the daemon is running (file is locked).
+ * lockfile the "pid file"
+ * flags none currently
+ * return 0 no, 1 yes, -1
+ */
+extern int
+NdbDaemon_Test(const char* lockfile, unsigned flags);
+
+/*
+ * Kill the daemon.
+ * lockfile the "pid file"
+ * flags none currently
+ * return 0 killed, 1 not running, -1 other error
+ */
+extern int
+NdbDaemon_Kill(const char* lockfile, unsigned flags);
+
+/*
+ * Pid from last call, either forked off or found in lock file.
+ */
+extern long NdbDaemon_DaemonPid;
+
+/*
+ * Error code from last failed call.
+ */
+extern int NdbDaemon_ErrorCode;
+
+/*
+ * Error text from last failed call.
+ */
+extern char NdbDaemon_ErrorText[];
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/storage/ndb/include/portlib/NdbEnv.h b/storage/ndb/include/portlib/NdbEnv.h
new file mode 100644
index 00000000000..1611bf3152e
--- /dev/null
+++ b/storage/ndb/include/portlib/NdbEnv.h
@@ -0,0 +1,34 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef NDB_ENV_H
+#define NDB_ENV_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ const char* NdbEnv_GetEnv(const char* name, char * buf, int buflen);
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
+
+
+
diff --git a/storage/ndb/include/portlib/NdbHost.h b/storage/ndb/include/portlib/NdbHost.h
new file mode 100644
index 00000000000..90e7b781137
--- /dev/null
+++ b/storage/ndb/include/portlib/NdbHost.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef NDB_HOST_H
+#define NDB_HOST_H
+
+#ifndef NDB_WIN32
+#include <sys/param.h>
+#include <netdb.h>
+#endif
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 255
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ int NdbHost_GetHostName(char*);
+ int NdbHost_GetProcessId();
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
+
+
+
diff --git a/storage/ndb/include/portlib/NdbMain.h b/storage/ndb/include/portlib/NdbMain.h
new file mode 100644
index 00000000000..7cc7a877750
--- /dev/null
+++ b/storage/ndb/include/portlib/NdbMain.h
@@ -0,0 +1,66 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef NDBMAIN_H
+#define NDBMAIN_H
+
+#if defined NDB_SOFTOSE || defined NDB_OSE
+#include <ose.h>
+#include <shell.h>
+
+/* Define an OSE_PROCESS that can be started from osemain.con */
+#define NDB_MAIN(name) \
+int main_ ## name(int argc, const char** argv); \
+OS_PROCESS(name){ \
+ main_ ## name(0, 0); \
+ stop(current_process()); \
+ exit(0); \
+} \
+int main_ ## name(int argc, const char** argv)
+
+/* Define an function that can be started from the command line */
+#define NDB_COMMAND(name, str_name, syntax, description, stacksize) \
+int main_ ## name(int argc, const char** argv); \
+ \
+static int run_ ## name(int argc, char *argv[]){ \
+ return main_ ## name (argc, argv); \
+} \
+ \
+OS_PROCESS(init_ ## name){ \
+ shell_add_cmd_attrs(str_name, syntax, description, \
+ run_ ## name, OS_PRI_PROC, 25, stacksize); \
+ stop(current_process()); \
+ return; \
+} \
+ \
+int main_ ## name(int argc, const char** argv)
+
+
+
+
+#else
+
+#define NDB_MAIN(name) \
+int main(int argc, const char** argv)
+
+#define NDB_COMMAND(name, str_name, syntax, description, stacksize) \
+int main(int argc, const char** argv)
+
+
+#endif
+
+
+#endif
diff --git a/storage/ndb/include/portlib/NdbMem.h b/storage/ndb/include/portlib/NdbMem.h
new file mode 100644
index 00000000000..0f2de80200e
--- /dev/null
+++ b/storage/ndb/include/portlib/NdbMem.h
@@ -0,0 +1,81 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef NDB_MEM_H
+#define NDB_MEM_H
+
+#include <ndb_global.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * NdbMem_Create
+ * Create and initalise internal data structures for Ndb
+ */
+void NdbMem_Create(void);
+
+
+/**
+ * NdbMem_Destroy
+ * Destroy all memory allocated by NdbMem
+ */
+void NdbMem_Destroy(void);
+
+/**
+ * NdbMem_Allocate
+ * Allocate size of memory
+ * @parameter size - size in bytes of memory to allocate
+ * @returns - pointer to memory if succesful otherwise NULL
+ */
+void* NdbMem_Allocate(size_t size);
+
+/**
+ * NdbMem_AllocateAlign
+ * Allocate size of memory
+ * @parameter size - size in bytes of memory to allocate
+ * @paramter alignment - byte boundary to align the data at
+ * @returns - pointer to memory if succesful otherwise NULL
+ */
+void* NdbMem_AllocateAlign(size_t size, size_t alignment);
+
+
+/**
+ * NdbMem_Free
+ * Free the memory that ptr points to
+ * @parameter ptr - pointer to the memory to free
+ */
+void NdbMem_Free(void* ptr);
+
+/**
+ * NdbMem_MemLockAll
+ * Locks virtual memory in main memory
+ */
+int NdbMem_MemLockAll(void);
+
+/**
+ * NdbMem_MemUnlockAll
+ * Unlocks virtual memory
+ */
+int NdbMem_MemUnlockAll(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/storage/ndb/include/portlib/NdbMutex.h b/storage/ndb/include/portlib/NdbMutex.h
new file mode 100644
index 00000000000..b0b985ecef5
--- /dev/null
+++ b/storage/ndb/include/portlib/NdbMutex.h
@@ -0,0 +1,113 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef NDB_MUTEX_H
+#define NDB_MUTEX_H
+
+#include <ndb_global.h>
+
+#ifdef NDB_WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined NDB_OSE || defined NDB_SOFTOSE
+#include <ose.h>
+typedef SEMAPHORE NdbMutex;
+#elif defined NDB_WIN32
+typedef CRITICAL_SECTION NdbMutex;
+#else
+#include <pthread.h>
+typedef pthread_mutex_t NdbMutex;
+#endif
+
+/**
+ * Create a mutex
+ *
+ * p_mutex: pointer to the mutex structure
+ * returnvalue: pointer to the mutex structure
+ */
+NdbMutex* NdbMutex_Create(void);
+
+/**
+ * Destroy a mutex
+ *
+ * * p_mutex: pointer to the mutex structure
+ * * returnvalue: 0 = succeeded, -1 = failed
+ */
+int NdbMutex_Destroy(NdbMutex* p_mutex);
+
+/**
+ * Lock a mutex
+ *
+ * * p_mutex: pointer to the mutex structure
+ * * returnvalue: 0 = succeeded, -1 = failed
+ */
+int NdbMutex_Lock(NdbMutex* p_mutex);
+
+/**
+ * Unlock a mutex
+ *
+ * * p_mutex: pointer to the mutex structure
+ * * returnvalue: 0 = succeeded, -1 = failed
+ */
+int NdbMutex_Unlock(NdbMutex* p_mutex);
+
+/**
+ * Try to lock a mutex
+ *
+ * * p_mutex: pointer to the mutex structure
+ * * returnvalue: 0 = succeeded, -1 = failed
+ */
+int NdbMutex_Trylock(NdbMutex* p_mutex);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
+class NdbLockable {
+ friend class Guard;
+public:
+ NdbLockable() { m_mutex = NdbMutex_Create(); }
+ ~NdbLockable() { NdbMutex_Destroy(m_mutex); }
+
+ void lock() { NdbMutex_Lock(m_mutex); }
+ void unlock(){ NdbMutex_Unlock(m_mutex);}
+ bool tryLock(){ return NdbMutex_Trylock(m_mutex) == 0;}
+
+ NdbMutex* getMutex() {return m_mutex;};
+
+protected:
+ NdbMutex * m_mutex;
+};
+
+class Guard {
+public:
+ Guard(NdbMutex *mtx) : m_mtx(mtx) { NdbMutex_Lock(m_mtx); };
+ Guard(NdbLockable & l) : m_mtx(l.m_mutex) { NdbMutex_Lock(m_mtx); };
+ ~Guard() { NdbMutex_Unlock(m_mtx); };
+private:
+ NdbMutex *m_mtx;
+};
+
+#endif
+
+#endif
diff --git a/storage/ndb/include/portlib/NdbSleep.h b/storage/ndb/include/portlib/NdbSleep.h
new file mode 100644
index 00000000000..3b26710154f
--- /dev/null
+++ b/storage/ndb/include/portlib/NdbSleep.h
@@ -0,0 +1,38 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef NDBSLEEP_H
+#define NDBSLEEP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Sleep for some time
+ *
+ * returnvalue: true = time is up, false = failed
+ */
+int NdbSleep_MicroSleep(int microseconds);
+int NdbSleep_MilliSleep(int milliseconds);
+int NdbSleep_SecSleep(int seconds);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/storage/ndb/include/portlib/NdbTCP.h b/storage/ndb/include/portlib/NdbTCP.h
new file mode 100644
index 00000000000..8138a2ef354
--- /dev/null
+++ b/storage/ndb/include/portlib/NdbTCP.h
@@ -0,0 +1,96 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef NDB_TCP_H
+#define NDB_TCP_H
+
+#include <ndb_global.h>
+#include <ndb_net.h>
+
+#if defined NDB_OSE || defined NDB_SOFTOSE
+/**
+ * Include files needed
+ */
+#include "inet.h"
+
+#include <netdb.h>
+
+#define NDB_NONBLOCK FNDELAY
+#define NDB_SOCKET_TYPE int
+#define NDB_INVALID_SOCKET -1
+#define NDB_CLOSE_SOCKET(x) close(x)
+
+/**
+ * socklen_t not defined in the header files of OSE
+ */
+typedef int socklen_t;
+
+#define InetErrno (* inet_errno())
+
+#elif defined NDB_WIN32
+
+/**
+ * Include files needed
+ */
+#include <winsock2.h>
+#include <ws2tcpip.h>
+
+#define InetErrno WSAGetLastError()
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define NDB_SOCKET_TYPE SOCKET
+#define NDB_INVALID_SOCKET INVALID_SOCKET
+#define NDB_CLOSE_SOCKET(x) closesocket(x)
+
+#else
+
+/**
+ * Include files needed
+ */
+#include <netdb.h>
+
+#define NDB_NONBLOCK O_NONBLOCK
+#define NDB_SOCKET_TYPE int
+#define NDB_INVALID_SOCKET -1
+#define NDB_CLOSE_SOCKET(x) ::close(x)
+
+#define InetErrno errno
+
+#endif
+
+#define NDB_SOCKLEN_T SOCKET_SIZE_TYPE
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Convert host name or ip address to in_addr
+ *
+ * Returns 0 on success
+ * -1 on failure
+ *
+ * Implemented as:
+ * gethostbyname
+ * if not success
+ * inet_addr
+ */
+int Ndb_getInAddr(struct in_addr * dst, const char *address);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/storage/ndb/include/portlib/NdbThread.h b/storage/ndb/include/portlib/NdbThread.h
new file mode 100644
index 00000000000..e86deee4354
--- /dev/null
+++ b/storage/ndb/include/portlib/NdbThread.h
@@ -0,0 +1,102 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef NDB_THREAD_H
+#define NDB_THREAD_H
+
+#include <ndb_global.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum NDB_THREAD_PRIO_ENUM {
+ NDB_THREAD_PRIO_HIGHEST,
+ NDB_THREAD_PRIO_HIGH,
+ NDB_THREAD_PRIO_MEAN,
+ NDB_THREAD_PRIO_LOW,
+ NDB_THREAD_PRIO_LOWEST
+} NDB_THREAD_PRIO;
+
+typedef void* (NDB_THREAD_FUNC)(void*);
+typedef void* NDB_THREAD_ARG;
+typedef size_t NDB_THREAD_STACKSIZE;
+
+struct NdbThread;
+
+/**
+ * Create a thread
+ *
+ * * p_thread_func: pointer of the function to run in the thread
+ * * p_thread_arg: pointer to argument to be passed to the thread
+ * * thread_stack_size: stack size for this thread
+ * * p_thread_name: pointer to name of this thread
+ * * returnvalue: pointer to the created thread
+ */
+struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
+ NDB_THREAD_ARG *p_thread_arg,
+ const NDB_THREAD_STACKSIZE thread_stack_size,
+ const char* p_thread_name,
+ NDB_THREAD_PRIO thread_prio);
+
+/**
+ * Destroy a thread
+ * Deallocates memory for thread
+ * And NULL the pointer
+ *
+ */
+void NdbThread_Destroy(struct NdbThread** p_thread);
+
+
+/**
+ * Waitfor a thread, suspend the execution of the calling thread
+ * until the wait_thread_id completes
+ *
+ * * p_wait_thread, pointer to the thread to wait for
+ * * status: exit code from thread waited for
+ * * returnvalue: true = succeded, false = failed
+ */
+int NdbThread_WaitFor(struct NdbThread* p_wait_thread, void** status);
+
+/**
+ * Exit thread, terminates the calling thread
+ *
+ * * status: exit code
+ */
+void NdbThread_Exit(void *status);
+
+/**
+ * Set thread concurrency level
+ *
+ * *
+ */
+int NdbThread_SetConcurrencyLevel(int level);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
+
+
+
+
+
+
+
diff --git a/storage/ndb/include/portlib/NdbTick.h b/storage/ndb/include/portlib/NdbTick.h
new file mode 100644
index 00000000000..9bd8eca22bd
--- /dev/null
+++ b/storage/ndb/include/portlib/NdbTick.h
@@ -0,0 +1,69 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef NDB_TICK_H
+#define NDB_TICK_H
+
+#include <ndb_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined NDB_OSE || defined NDB_SOFTOSE
+typedef unsigned long NDB_TICKS;
+#else
+typedef Uint64 NDB_TICKS;
+#endif
+
+/**
+ * Returns the current millisecond since 1970
+ */
+NDB_TICKS NdbTick_CurrentMillisecond(void);
+
+/**
+ * Get current micro second
+ * Second method is simply abstraction on top of the first
+ *
+ * Returns 0 - Success
+ */
+int NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros);
+
+ /*#define TIME_MEASUREMENT*/
+#ifdef TIME_MEASUREMENT
+
+struct MicroSecondTimer {
+ NDB_TICKS seconds;
+ NDB_TICKS micro_seconds;
+};
+
+/**
+ * Get time between start and stop time in microseconds
+ * Abstraction to get time in struct
+ *
+ * 0 means stop happened at or before start time
+ */
+NDB_TICKS NdbTick_getMicrosPassed(struct MicroSecondTimer start,
+ struct MicroSecondTimer stop);
+int NdbTick_getMicroTimer(struct MicroSecondTimer* time_now);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/storage/ndb/include/portlib/PortDefs.h b/storage/ndb/include/portlib/PortDefs.h
new file mode 100644
index 00000000000..a115c60cfe1
--- /dev/null
+++ b/storage/ndb/include/portlib/PortDefs.h
@@ -0,0 +1,53 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef PORT_DEFS_H
+#define PORT_DEFS_H
+/*
+ This file contains varoius declarations/definitions needed in the port of AXEVM to NT, as well as backporting
+ to Solaris...
+
+ $Id: PortDefs.h,v 1.5 2003/10/07 07:59:59 mikael Exp $
+*/
+
+#ifdef NDB_ALPHA
+#ifdef NDB_GCC /* only for NDB_ALPHA */
+extern int gnuShouldNotUseRPCC();
+#define RPCC() gnuShouldNotUseRPCC();
+#else
+#define RPCC() ((int)__asm(" rpcc v0;"))
+#define MB() __asm(" mb;");
+#define WMB() __asm(" wmb;");
+#ifdef USE_INITIALSP
+#define IS_IP() (__asm(" mov sp,v0;") < IPinitialSP)
+#else /* USE_INITIALSP */
+#define IS_IP() (((__asm(" rpcc v0;") >> 32) & 0x7) == IP_CPU)
+#endif
+#endif /* NDB_GCC */
+#else /* NDB_ALPHA */
+#if defined NDB_SPARC
+#define MB() asm ("membar 0x0;"); /* LoadLoad */
+#define WMB() asm ("membar 0x3;"); /* StoreStore */
+#else /* NDB_SPARC */
+#define MB()
+#define WMB()
+#endif /* NDB_SPARC */
+#define IS_IP() (1==1)
+extern int shouldNotUseRPCC();
+#define RPCC() shouldNotUseRPCC();
+#endif /* NDB_ALPHA */
+
+#endif
diff --git a/storage/ndb/include/portlib/prefetch.h b/storage/ndb/include/portlib/prefetch.h
new file mode 100644
index 00000000000..729c80bd93e
--- /dev/null
+++ b/storage/ndb/include/portlib/prefetch.h
@@ -0,0 +1,69 @@
+/* Copyright (C) 2003 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 */
+
+#ifndef PREFETCH_H
+#define PREFETCH_H
+
+#ifdef NDB_FORTE6
+#include <sun_prefetch.h>
+#endif
+
+#ifdef USE_PREFETCH
+#define PREFETCH(addr) prefetch(addr)
+#else
+#define PREFETCH(addr)
+#endif
+
+#ifdef USE_PREFETCH
+#define WRITEHINT(addr) writehint(addr)
+#else
+#define WRITEHINT(addr)
+#endif
+
+#include "PortDefs.h"
+
+#ifdef NDB_FORTE6
+#pragma optimize("", off)
+#endif
+inline void prefetch(void* p)
+{
+#ifdef NDB_ALPHA
+ __asm(" ldl r31,0(a0);", p);
+#endif /* NDB_ALPHA */
+#ifdef NDB_FORTE6
+ sparc_prefetch_read_once(p);
+#else
+ (void)p;
+#endif
+}
+
+inline void writehint(void* p)
+{
+#ifdef NDB_ALPHA
+ __asm(" wh64 (a0);", p);
+#endif /* NDB_ALPHA */
+#ifdef NDB_FORTE6
+ sparc_prefetch_write_once(p);
+#else
+ (void)p;
+#endif
+}
+#ifdef NDB_FORTE6
+#pragma optimize("", on)
+#endif
+
+#endif
+