Commit b87a116a authored by unknown's avatar unknown

lots of HAVE_ and some ndb_global fixes for ndb subtree


ndb/include/portlib/NdbTCP.h:
  introduced ndb_net.h
ndb/include/portlib/NdbThread.h:
  ndb_global
ndb/src/common/portlib/unix/NdbCondition.c:
  Used HAVE_CLOCK_GETTIME
ndb/src/common/portlib/unix/NdbMem.c:
  used HAVE_MLOCKALL
ndb/src/common/portlib/unix/NdbSleep.c:
  ndb_global
ndb/src/common/portlib/unix/NdbThread.c:
  .
ndb/src/common/portlib/unix/NdbTick.c:
  HAVE_CLOCK_GETTIME
ndb/src/kernel/vm/Emulator.cpp:
  ndb_global
parent 5c6f5b94
#ifndef NDBNET_H
#define NDBNET_H
#include <my_net.h>
#endif
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#define NDB_TCP_H #define NDB_TCP_H
#include <ndb_global.h> #include <ndb_global.h>
#include <ndb_net.h>
#if defined NDB_OSE || defined NDB_SOFTOSE #if defined NDB_OSE || defined NDB_SOFTOSE
/** /**
...@@ -45,10 +46,6 @@ typedef int socklen_t; ...@@ -45,10 +46,6 @@ typedef int socklen_t;
/** /**
* Include files needed * Include files needed
*/ */
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#define NDB_NONBLOCK O_NONBLOCK #define NDB_NONBLOCK O_NONBLOCK
...@@ -75,12 +72,7 @@ typedef int socklen_t; ...@@ -75,12 +72,7 @@ typedef int socklen_t;
#endif #endif
#ifndef NDB_MACOSX #define NDB_SOCKLEN_T SOCKET_SIZE_TYPE
#define NDB_SOCKLEN_T socklen_t
#else
#define NDB_SOCKLEN_T int
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
#ifndef NDB_THREAD_H #ifndef NDB_THREAD_H
#define NDB_THREAD_H #define NDB_THREAD_H
#include <sys/types.h> #include <ndb_global.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
...@@ -61,7 +61,6 @@ NdbCondition_Wait(struct NdbCondition* p_cond, ...@@ -61,7 +61,6 @@ NdbCondition_Wait(struct NdbCondition* p_cond,
return result; return result;
} }
#if defined NDB_SOLARIS || defined NDB_HPUX
#include <time.h> #include <time.h>
int int
NdbCondition_WaitTimeout(struct NdbCondition* p_cond, NdbCondition_WaitTimeout(struct NdbCondition* p_cond,
...@@ -74,7 +73,16 @@ NdbCondition_WaitTimeout(struct NdbCondition* p_cond, ...@@ -74,7 +73,16 @@ NdbCondition_WaitTimeout(struct NdbCondition* p_cond,
if (p_cond == NULL || p_mutex == NULL) if (p_cond == NULL || p_mutex == NULL)
return 1; return 1;
#ifdef HAVE_CLOCK_GETTIME
clock_gettime(CLOCK_REALTIME, &abstime); clock_gettime(CLOCK_REALTIME, &abstime);
#else
{
struct timeval tick_time;
gettimeofday(&tick_time, 0);
abstime.tv_sec = tick_time.tv_sec;
abstime.tv_nsec = tick_time.tv_usec * 1000;
}
#endif
if(msecs >= 1000){ if(msecs >= 1000){
secs = msecs / 1000; secs = msecs / 1000;
...@@ -92,45 +100,6 @@ NdbCondition_WaitTimeout(struct NdbCondition* p_cond, ...@@ -92,45 +100,6 @@ NdbCondition_WaitTimeout(struct NdbCondition* p_cond,
return result; return result;
} }
#endif
#if defined NDB_LINUX || defined NDB_MACOSX
#include <unistd.h>
#include <sys/time.h>
int
NdbCondition_WaitTimeout(struct NdbCondition* p_cond,
NdbMutex* p_mutex,
int msecs){
int result;
struct timespec abstime;
struct timeval tick_time;
int secs = 0;
if (p_cond == NULL || p_mutex == NULL)
return 1;
gettimeofday(&tick_time, 0);
if(msecs >= 1000){
secs = msecs / 1000;
msecs = msecs % 1000;
}
abstime.tv_sec = tick_time.tv_sec + secs;
abstime.tv_nsec = tick_time.tv_usec * 1000 + msecs * 1000000;
if (abstime.tv_nsec >= 1000000000) {
abstime.tv_sec += 1;
abstime.tv_nsec -= 1000000000;
}
result = pthread_cond_timedwait(&p_cond->cond, p_mutex, &abstime);
return result;
}
#endif
int int
NdbCondition_Signal(struct NdbCondition* p_cond){ NdbCondition_Signal(struct NdbCondition* p_cond){
......
...@@ -54,16 +54,16 @@ void NdbMem_Free(void* ptr) ...@@ -54,16 +54,16 @@ void NdbMem_Free(void* ptr)
int NdbMem_MemLockAll(){ int NdbMem_MemLockAll(){
#if defined NDB_MACOSX #ifdef HAVE_MLOCKALL
return 0; return -1;
#else #else
return mlockall(MCL_CURRENT); return mlockall(MCL_CURRENT);
#endif #endif
} }
int NdbMem_MemUnlockAll(){ int NdbMem_MemUnlockAll(){
#if defined NDB_MACOSX #ifdef HAVE_MLOCKALL
return 0; return -1;
#else #else
return munlockall(); return munlockall();
#endif #endif
......
...@@ -15,19 +15,9 @@ ...@@ -15,19 +15,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
#include "NdbSleep.h" #include "NdbSleep.h"
#ifdef NDB_SOLARIS
#include <sys/types.h>
#include <unistd.h>
#endif
#if defined NDB_LINUX || defined NDB_HPUX || defined NDB_MACOSX
#include <time.h>
#include <unistd.h>
#endif
int int
NdbSleep_MilliSleep(int milliseconds){ NdbSleep_MilliSleep(int milliseconds){
int result = 0; int result = 0;
......
...@@ -16,9 +16,8 @@ ...@@ -16,9 +16,8 @@
#include <ndb_global.h> #include <ndb_global.h>
#include <NdbThread.h>
#include "NdbThread.h" #include <my_pthread.h>
#include <pthread.h>
#define MAX_THREAD_NAME 16 #define MAX_THREAD_NAME 16
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
#include "NdbTick.h" #include "NdbTick.h"
#include <time.h>
#define NANOSEC_PER_SEC 1000000000 #define NANOSEC_PER_SEC 1000000000
#define MICROSEC_PER_SEC 1000000 #define MICROSEC_PER_SEC 1000000
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#define MILLISEC_PER_NANOSEC 1000000 #define MILLISEC_PER_NANOSEC 1000000
#if defined NDB_SOLARIS || NDB_HPUX #ifdef HAVE_CLOCK_GETTIME
NDB_TICKS NdbTick_CurrentMillisecond(void) NDB_TICKS NdbTick_CurrentMillisecond(void)
{ {
struct timespec tick_time; struct timespec tick_time;
...@@ -44,11 +44,7 @@ NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros){ ...@@ -44,11 +44,7 @@ NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros){
* micros = t.tv_nsec / 1000; * micros = t.tv_nsec / 1000;
return res; return res;
} }
#endif #else
#if defined NDB_LINUX || NDB_MACOSX
#include <unistd.h>
#include <sys/time.h>
NDB_TICKS NdbTick_CurrentMillisecond(void) NDB_TICKS NdbTick_CurrentMillisecond(void)
{ {
struct timeval tick_time; struct timeval tick_time;
......
...@@ -39,12 +39,6 @@ extern "C" { ...@@ -39,12 +39,6 @@ extern "C" {
extern void (* ndb_new_handler)(); extern void (* ndb_new_handler)();
} }
#if defined (NDB_LINUX) || defined (NDB_SOLARIS)
#include <sys/types.h>
#include <sys/wait.h>
#endif
/** /**
* Declare the global variables * Declare the global variables
*/ */
......
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