Initial revision of NDB Cluster files

BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
This commit is contained in:
unknown 2004-04-14 10:53:21 +02:00
commit 6386c55cee
1835 changed files with 500032 additions and 0 deletions

View file

@ -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

View file

@ -0,0 +1,28 @@
/* 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_CONSTANT_HPP
#define NDB_CONSTANT_HPP
#include <ndb_types.h>
#ifdef NDB_VC98
#define STATIC_CONST(x) enum { x }
#else
#define STATIC_CONST(x) static const Uint32 x
#endif
#endif

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,82 @@
/* 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 <stddef.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

View file

@ -0,0 +1,114 @@
/* 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
#ifdef NDB_WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined NDB_OSE || defined NDB_SOFTOSE
#include <ose.h>
typedef SEMAPHORE NdbMutex;
#define NDB_MUTEX_INITIALIZER { 1, 0, 0 }
#elif defined NDB_WIN32
typedef CRITICAL_SECTION NdbMutex;
#else
#include <pthread.h>
typedef pthread_mutex_t NdbMutex;
#define NDB_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#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

View file

@ -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

View file

@ -0,0 +1,36 @@
/* 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 */
/*
* NdbStdio.h - stdio.h for ndb
*
*
*/
#if defined NDB_OSE || defined NDB_SOFTOSE
/* On OSE Delta the snprintf is declare in outfmt.h */
#include <outfmt.h>
#endif
#include <stdio.h>
#ifdef NDB_WIN32
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define strtok_r(s1, s2, l) strtok(s1, s2)
#endif

View file

@ -0,0 +1,137 @@
/* 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
#if defined NDB_OSE || defined NDB_SOFTOSE
/**
* Include files needed
*/
#include "inet.h"
#include <netdb.h>
#include <errno.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())
#endif
#if defined NDB_SOLARIS || defined NDB_HPUX || defined NDB_IBMAIX || defined NDB_TRU64X
/**
* Include files needed
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netdb.h>
#include <errno.h>
#include <fcntl.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
#if defined NDB_LINUX || defined NDB_MACOSX
/**
* Include files needed
*/
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netdb.h>
#include <errno.h>
#include <fcntl.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
#ifdef NDB_WIN32
/**
* Include files needed
*/
#include <winsock2.h>
#include <ws2tcpip.h>
#include <errno.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)
#endif
#ifndef NDB_MACOSX
#define NDB_SOCKLEN_T socklen_t
#else
#define NDB_SOCKLEN_T int
#endif
#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

View file

@ -0,0 +1,103 @@
/* 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 <sys/types.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(int status);
/**
* Set thread concurrency level
*
* *
*/
int NdbThread_SetConcurrencyLevel(int level);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -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

View file

@ -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_UNISTD_H
#define NDB_UNISTD_H
#ifdef NDB_WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#include <limits.h>
#define DIR_SEPARATOR "\\"
#define PATH_MAX 256
#pragma warning(disable: 4503 4786)
#else
#include <unistd.h>
#include <limits.h>
#define DIR_SEPARATOR "/"
#endif
#endif

View file

@ -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 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_WIN32
#include <time.h>
struct tms
{
time_t tms_utime; // user time
time_t tms_stime; // system time
time_t tms_cutime; // user time of children
time_t tms_cstime; // system time of children
};
struct timespec
{
long tv_sec; // Seconds
long tv_nsec; // Nanoseconds
};
#define strcasecmp(a,b) _strcmpi(a,b)
// Exports a WIN32 getopt function
extern int optind;
extern char *optarg;
int getopt(int, char **, char *opts);
#endif // NDB_WIN32
#ifdef NDB_ALPHA
#ifdef NDB_GCC
extern int gnuShouldNotUseRPCC();
#define RPCC() gnuShouldNotUseRPCC();
#else
#ifdef NDB_WIN32
#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
u_int64 __asm(char *, ...);
double __dasm(char *, ...);
float __fasm(char *, ...);
void _AcquireSpinLock(long *);
void _ReleaseSpinLock(long *);
int __ADD_ATOMIC_LONG2(void *, int);
#ifdef __cplusplus
};
#endif //__cplusplus
#pragma intrinsic (__asm, __dasm, __fasm)
#pragma intrinsic(_ReleaseSpinLock, _AcquireSpinLock)
#pragma intrinsic(__ADD_ATOMIC_LONG2)
#endif // NDB_WIN32
#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

View file

@ -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