diff options
Diffstat (limited to 'storage/ndb/src/common/portlib/old_dirs/ose')
13 files changed, 0 insertions, 1223 deletions
diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/Makefile b/storage/ndb/src/common/portlib/old_dirs/ose/Makefile deleted file mode 100644 index 4ef93b7824a..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -include .defs.mk - -TYPE := - -PIC_ARCHIVE := Y -ARCHIVE_TARGET := portlib - -SOURCES = NdbOut.cpp - -SOURCES.c = NdbCondition.c \ - NdbMutex.c \ - NdbSleep.c \ - NdbTick.c \ - NdbEnv.c \ - NdbThread.c \ - NdbHost.c \ - NdbTCP.c - -ifeq ($(NDB_OS), SOFTOSE) - SOURCES += NdbMem_SoftOse.cpp -else - SOURCES.c += NdbMem.c -endif - -include $(NDB_TOP)/Epilogue.mk - - - - - - diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/NdbCondition.c b/storage/ndb/src/common/portlib/old_dirs/ose/NdbCondition.c deleted file mode 100644 index 73a2dbc5d66..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/NdbCondition.c +++ /dev/null @@ -1,243 +0,0 @@ -/* 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 */ - - -#include "NdbCondition.h" -#include <pthread.h> -#include <sys/types.h> -#include <malloc.h> - -#include <NdbMutex.h> - -#include "NdbConditionOSE.h" -struct NdbCondition -{ - PROCESS condserv_pid; -}; - - -OS_PROCESS(ndbcond_serv){ - - union SIGNAL* sig; - union SIGNAL* sig2; - - static const SIGSELECT sel_signal[] = {2, NDBCOND_SIGNAL, NDBCOND_BROADCAST}; - static const SIGSELECT sel_cond[] = {2, NDBCOND_WAIT, NDBCOND_WAITTIMEOUT}; - - for(;;){ - /* Receive condition wait signal */ - sig = receive((SIGSELECT*)sel_cond); - if (sig != NIL){ - switch (sig->sigNo){ - - case NDBCOND_WAIT: - /* Wait for a SIGNAL or BROADCAST from anyone */ - sig2 = receive((SIGSELECT*)sel_signal); - if (sig2 != NIL){ - switch(sig2->sigNo){ - - case NDBCOND_SIGNAL: - ((struct NdbCondWait*)sig)->status = NDBCOND_SIGNALED; - /* Send signal back to the one waiting for this condition */ - send(&sig, sender(&sig)); - break; - case NDBCOND_BROADCAST: - /* Not handled yet */ - assert(1==0); - break; - default: - assert(1==0); - break; - } - free_buf(&sig2); - } - break; - - case NDBCOND_WAITTIMEOUT: - /* Wait for a SIGNAL or BROADCAST from anyone */ - sig2 = receive_w_tmo(((struct NdbCondWaitTimeout*)sig)->timeout, (SIGSELECT*)sel_signal); - if (sig2 != NIL){ - switch(sig2->sigNo){ - - case NDBCOND_SIGNAL: - ((struct NdbCondWaitTimeout*)sig)->status = NDBCOND_SIGNALED; - /* Send signal back to the one waiting for this condition */ - send(&sig, sender(&sig)); - break; - case NDBCOND_BROADCAST: - /* Not handled yet */ - assert(1==0); - break; - default: - assert(1==0); - break; - } - free_buf(&sig2); - }else{ - ((struct NdbCondWaitTimeout*)sig)->status = NDBCOND_TIMEOUT; - send(&sig, sender(&sig)); - } - break; - - default: - assert(1==0); - break; - - } - } - - } -} - - -struct NdbCondition* -NdbCondition_Create(void) -{ - struct NdbCondition* tmpCond; - - - tmpCond = (struct NdbCondition*)malloc(sizeof(struct NdbCondition)); - - if (tmpCond == NULL) - return NULL; - - /** - * Start this process with a quite high - * priority, we want it to be responsive - */ - tmpCond->condserv_pid = create_process(OS_PRI_PROC, /* Process type */ - "ndbcond_serv", /* Name */ - ndbcond_serv, /* Entry point */ - 2048, /* Stack size */ - 10, /* Priority */ - 0, /* Time slice */ - get_bid(current_process()), /* Block */ - NULL, /* Redir table */ - 0, - 0); - - start(tmpCond->condserv_pid); - - return tmpCond; -} - - -int -NdbCondition_Wait(struct NdbCondition* p_cond, - NdbMutex* p_mutex) -{ - static const SIGSELECT sel_cond[] = {1, NDBCOND_WAIT}; - union SIGNAL* sig; - int result; - if (p_cond == NULL || p_mutex == NULL) - return 0; - - sig = alloc(sizeof(struct NdbCondWait), NDBCOND_WAIT); - send(&sig, p_cond->condserv_pid); - - NdbMutex_Unlock(p_mutex); - - result = 1; - while(NIL == (sig = receive_from((OSTIME)-1, (SIGSELECT*)sel_cond, p_cond->condserv_pid))); - if (sig != NIL){ - if (sig->sigNo == NDBCOND_WAIT){ - /* Condition is signaled */ - result = 0; - }else{ - assert(1==0); - } - free_buf(&sig); - - } - NdbMutex_Lock(p_mutex); - - return result; -} - - -int -NdbCondition_WaitTimeout(struct NdbCondition* p_cond, - NdbMutex* p_mutex, - int msecs){ - static const SIGSELECT sel_cond[] = {1, NDBCOND_WAITTIMEOUT}; - union SIGNAL* sig; - int result; - if (p_cond == NULL || p_mutex == NULL) - return 0; - - sig = alloc(sizeof(struct NdbCondWaitTimeout), NDBCOND_WAITTIMEOUT); - ((struct NdbCondWaitTimeout*)sig)->timeout = msecs; - send(&sig, p_cond->condserv_pid); - - NdbMutex_Unlock(p_mutex); - - result = 1; - while(NIL == (sig = receive_from((OSTIME)-1, (SIGSELECT*)sel_cond, p_cond->condserv_pid))); - if (sig != NIL){ - if (sig->sigNo == NDBCOND_WAITTIMEOUT){ - /* Condition is signaled */ - result = 0; - }else{ - assert(1==0); - } - free_buf(&sig); - - } - - NdbMutex_Lock(p_mutex); - - return result; -} - - -int -NdbCondition_Signal(struct NdbCondition* p_cond){ - - union SIGNAL* sig; - if (p_cond == NULL) - return 1; - - sig = alloc(sizeof(struct NdbCondSignal), NDBCOND_SIGNAL); - send(&sig, p_cond->condserv_pid); - - return 0; -} - - -int NdbCondition_Broadcast(struct NdbCondition* p_cond) -{ - union SIGNAL* sig; - if (p_cond == NULL) - return 1; - - sig = alloc(sizeof(struct NdbCondBroadcast), NDBCOND_BROADCAST); - send(&sig, p_cond->condserv_pid); - - return 0; -} - - -int NdbCondition_Destroy(struct NdbCondition* p_cond) -{ - if (p_cond == NULL) - return 1; - - kill_proc(p_cond->condserv_pid); - free(p_cond); - - return 0; -} - diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/NdbConditionOSE.h b/storage/ndb/src/common/portlib/old_dirs/ose/NdbConditionOSE.h deleted file mode 100644 index bd0306261cc..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/NdbConditionOSE.h +++ /dev/null @@ -1,103 +0,0 @@ -/* 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_CONDITIONOSE_H -#define NDB_CONDITIONOSE_H - - -#ifdef __cplusplus -extern "C" { -#endif - - -#define NDBCOND_SIGBASE 4000 - -#define NDBCOND_WAIT (NDBCOND_SIGBASE + 1) /* !-SIGNO(struct NdbCondWait)-! */ -#define NDBCOND_WAITTIMEOUT (NDBCOND_SIGBASE + 2) /* !-SIGNO(struct NdbCondWaitTimeOut)-! */ -#define NDBCOND_SIGNAL (NDBCOND_SIGBASE + 3) /* !-SIGNO(struct NdbCondSignal)-! */ -#define NDBCOND_BROADCAST (NDBCOND_SIGBASE + 4) /* !-SIGNO(struct NdbCondBroadcast)-! */ - - -const char * -sigNo2String(SIGSELECT sigNo){ - switch(sigNo){ - case NDBCOND_WAIT: - return "NDBCOND_WAIT"; - break; - case NDBCOND_WAITTIMEOUT: - return "NDBCOND_WAITTIMEOUT"; - break; - case NDBCOND_SIGNAL: - return "NDBCOND_SIGNAL"; - break; - case NDBCOND_BROADCAST: - return "NDBCOND_BROADCAST"; - break; - } - return "UNKNOWN"; -} - -struct NdbCondWait -{ - SIGSELECT sigNo; - int status; -}; - -/** - * Signal received - */ -#define NDBCOND_SIGNALED 1 - -/** - * Timeout occured - */ -#define NDBCOND_TIMEOUT 2 - -struct NdbCondWaitTimeout -{ - SIGSELECT sigNo; - int timeout; - int status; - -}; - -struct NdbCondSignal -{ - SIGSELECT sigNo; -}; - -struct NdbCondBroadcast -{ - SIGSELECT sigNo; -}; - - -union SIGNAL -{ - SIGSELECT sigNo; - struct NdbCondWait condWait; - struct NdbCondWaitTimeout condWaitTimeout; - struct NdbCondSignal condSignal; - struct NdbCondBroadcast condBroadcast; -}; - - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/NdbEnv.c b/storage/ndb/src/common/portlib/old_dirs/ose/NdbEnv.c deleted file mode 100644 index e2ac4d879d2..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/NdbEnv.c +++ /dev/null @@ -1,55 +0,0 @@ -/* 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 */ - - -#include "NdbEnv.h" -#include <string.h> -#include <stdlib.h> - -const char* NdbEnv_GetEnv(const char* name, char * buf, int buflen) -{ - /** - * All environment variables are associated with a process - * it's important to read env from the correct process - * for now read from own process, own block and last the "ose_shell" process. - * - * TODO! What process should this be read from in the future? - * - */ - PROCESS proc_; - char* p = NULL; - /* Look in own process */ - p = get_env(current_process(), (char*)name); - if (p == NULL){ - /* Look in block process */ - p = get_env(get_bid(current_process()), (char*)name); - if (p == NULL){ - /* Look in ose_shell process */ - if (hunt("ose_shell", 0, &proc_, NULL)){ - p = get_env(proc_, (char*)name); - } - } - } - - if (p != NULL){ - strncpy(buf, p, buflen); - buf[buflen-1] = 0; - free_buf((union SIGNAL **)&p); - p = buf; - } - return p; -} - diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/NdbHost.c b/storage/ndb/src/common/portlib/old_dirs/ose/NdbHost.c deleted file mode 100644 index f5e1e511c16..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/NdbHost.c +++ /dev/null @@ -1,55 +0,0 @@ -/* 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 */ - - -#include "NdbHost.h" -#include <unistd.h> - - -#include <inet.sig> -#include <string.h> - -union SIGNAL -{ - SIGSELECT sigNo; - struct InetIfUp inetIfUp; -}; - -int NdbHost_GetHostName(char* buf) -{ -#if 0 - extern PROCESS ose_inet_; - union SIGNAL *signal; - static const SIGSELECT select_if_up_reply[] = { 1, INET_IF_UP_REPLY }; - - signal = alloc(sizeof(struct InetIfUp), INET_IF_UP_REQUEST); - strcpy(signal->inetIfUp.ifName, "*"); - send((union SIGNAL **)&signal, ose_inet_); - signal = receive((SIGSELECT *)select_if_up_reply); - strcpy(buf, signal->inetIfUp.ifName); - free_buf(&signal); - return 0; -#else - return -1; -#endif -} - - -int NdbHost_GetProcessId(void) -{ - return current_process(); -} - diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/NdbMem.c b/storage/ndb/src/common/portlib/old_dirs/ose/NdbMem.c deleted file mode 100644 index 0e38024bbb4..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/NdbMem.c +++ /dev/null @@ -1,181 +0,0 @@ -/* 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 */ - - -#include "NdbMem.h" - - -#if defined NDB_OSE -#include <ose.h> -#include <mms.sig> -#include <mms_err.h> -#include <string.h> -#include <stdio.h> -#include <NdbOut.hpp> - -// Page size for mp750 is 4096 bytes. -#define PAGE_SIZE 4096 - -/** - * NOTE: To use NdbMem from a OSE system ose_mms has to be defined - * as a "Required External Process"(see OSE Kernel User's Guide/R1.1(p. 148)), - * like this in osemain.con: - * EXT_PROC(ose_mms, ose_mms, 50000) - * This will create a global variable ose_mms_ that is used from here. - */ - -union SIGNAL -{ - SIGSELECT sigNo; - struct MmsAllocateRegionRequest mmsAllocateRegionRequest; - struct MmsAllocateRegionReply mmsAllocateRegionReply; - struct MmsFreeRegionRequest mmsFreeRegionRequest; - struct MmsFreeRegionReply mmsFreeRegionReply; -}; /* union SIGNAL */ - -extern PROCESS ose_mms_; - -void NdbMem_Create(void) -{ - /* Do nothing */ - return; -} - -void NdbMem_Destroy(void) -{ - /* Do nothing */ - return; -} - -void* NdbMem_Allocate(size_t size) -{ - static SIGSELECT allocate_sig[] = {1,MMS_ALLOCATE_REGION_REPLY}; - union SIGNAL *sig; - U32 allocatedAdress; - - assert(size > 0); - - // Only allowed to allocate multiples of the page size. - if(size % PAGE_SIZE != 0) { - size += PAGE_SIZE - size%PAGE_SIZE; - } - - /* Allocate a new region in the callers memory segment. */ - sig = alloc(sizeof(struct MmsAllocateRegionRequest), - MMS_ALLOCATE_REGION_REQUEST); - /* -1: The callers domain is used */ - sig->mmsAllocateRegionRequest.domain = (MemoryDomain)-1; - sig->mmsAllocateRegionRequest.useAddr = False; - sig->mmsAllocateRegionRequest.size = size; - sig->mmsAllocateRegionRequest.access = SuperRW_UserRW; - sig->mmsAllocateRegionRequest.resident = False; - sig->mmsAllocateRegionRequest.memory = CodeData; - sig->mmsAllocateRegionRequest.cache = CopyBack; - strcpy(sig->mmsAllocateRegionRequest.name, "NDB_DATA"); - send(&sig, ose_mms_); - sig = receive(allocate_sig); - - if (sig->mmsAllocateRegionReply.status != MMS_SUCCESS){ - /* Memory allocation failed, make sure this function returns NULL */ - allocatedAdress = NULL; - } - else{ - allocatedAdress = sig->mmsAllocateRegionReply.address; - } - free_buf(&sig); - return (void*)allocatedAdress; -} - -void* NdbMem_AllocateAlign(size_t size, size_t alignment) -{ - return NdbMem_Allocate(size); -} - - -void NdbMem_Free(void* ptr) -{ - static SIGSELECT free_sig[] = {1,MMS_FREE_REGION_REPLY}; - union SIGNAL *sig; - - /* Free a region in the callers domain. */ - sig = alloc(sizeof(struct MmsFreeRegionRequest), - MMS_FREE_REGION_REQUEST); - sig->mmsFreeRegionRequest.address = (U32)ptr; - send(&sig, ose_mms_); - sig = receive(free_sig); - - if (sig->mmsFreeRegionReply.status != MMS_SUCCESS){ - ndbout_c("The MMS Region could not be deallocated.\r\n"); - error(sig->mmsFreeRegionReply.status); - }; - free_buf(&sig); -} - -int NdbMem_MemLockAll(){ - return -1; -} - -int NdbMem_MemUnlockAll(){ - return -1; -} - -#else -#include <stdlib.h> - - -void NdbMem_Create() -{ - /* Do nothing */ - return; -} - -void NdbMem_Destroy() -{ - /* Do nothing */ - return; -} - -void* NdbMem_Allocate(size_t size) -{ - assert(size > 0); - return (void*)malloc(size); -} - -void* NdbMem_AllocateAlign(size_t size, size_t alignment) -{ - /* - return (void*)memalign(alignment, size); - TEMP fix - */ - return (void*)malloc(size); -} - - -void NdbMem_Free(void* ptr) -{ - free(ptr); -} - - -int NdbMem_MemLockAll(){ - return -1; -} - -int NdbMem_MemUnlockAll(){ - return -1; -} - -#endif diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/NdbMem_SoftOse.cpp b/storage/ndb/src/common/portlib/old_dirs/ose/NdbMem_SoftOse.cpp deleted file mode 100644 index cad22c0474b..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/NdbMem_SoftOse.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* 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 */ - -#include "NdbMem.h" - -extern "C" -void NdbMem_Create() -{ -} -extern "C" -void NdbMem_Destroy() -{ -} - -extern "C" -void* NdbMem_Allocate(size_t size) -{ - return new char[size]; -} - -extern "C" -void* NdbMem_AllocateAlign(size_t size, size_t alignment) -{ - return NdbMem_Allocate(size); -} - -extern "C" -void NdbMem_Free(void* ptr) -{ - delete [] (char *)(ptr); -} - -int NdbMem_MemLockAll(){ - return -1; -} - -int NdbMem_MemUnlockAll(){ - return -1; -} - diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/NdbMutex.c b/storage/ndb/src/common/portlib/old_dirs/ose/NdbMutex.c deleted file mode 100644 index 253c0e412ff..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/NdbMutex.c +++ /dev/null @@ -1,85 +0,0 @@ -/* 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 */ - - -#include "NdbMutex.h" - -#include <pthread.h> -#include <stdlib.h> - - -NdbMutex* NdbMutex_Create(void) -{ - NdbMutex* pNdbMutex; - - pNdbMutex = create_sem(1); - - return pNdbMutex; -} - - -int NdbMutex_Destroy(NdbMutex* p_mutex) -{ - - if (p_mutex == NULL) - return -1; - - kill_sem(p_mutex); - - return 0; - -} - - -int NdbMutex_Lock(NdbMutex* p_mutex) -{ - if (p_mutex == NULL) - return -1; - - wait_sem(p_mutex); - - return 0; -} - - -int NdbMutex_Unlock(NdbMutex* p_mutex) -{ - - if (p_mutex == NULL) - return -1; - - signal_sem(p_mutex); - - return 0; -} - - -int NdbMutex_Trylock(NdbMutex* p_mutex) -{ - int result = -1; - - if (p_mutex != NULL) { - OSSEMVAL semvalue = get_sem(p_mutex); - if (semvalue > 0) { - wait_sem(p_mutex); - result = 0; - } - } - - return result; - -} - diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/NdbOut.cpp b/storage/ndb/src/common/portlib/old_dirs/ose/NdbOut.cpp deleted file mode 100644 index eb81bc9d971..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/NdbOut.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* 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 */ - -#include <ndb_global.h> - -#include "NdbOut.hpp" - -#if defined NDB_SOFTOSE -#include <dbgprintf.h> -#define printfunc dbgprintf -#else -#define printfunc printf -#endif - -static char const* const endlineString = "\r\n"; - -static int CtrlC = 0; -NdbOut ndbout; - - -NdbOut& NdbOut::operator<<(int aVal) -{ - char* format; - char HexFormat[] = "0x%08x"; - char DecFormat[] = "%d"; - if (isHexFormat == 1) - format = HexFormat; - else - format = DecFormat; - - printfunc(format, aVal); - return *this; -} - -NdbOut& NdbOut::operator<<(char* pVal) -{ - printfunc("%s", pVal); - return *this; -} - -NdbOut& NdbOut::endline() -{ - isHexFormat = 0; // Reset hex to normal, if user forgot this - printfunc(endlineString); - return *this; -} - -NdbOut& NdbOut::flushline() -{ - isHexFormat = 0; // Reset hex to normal, if user forgot this - return *this; -} - -NdbOut& NdbOut::setHexFormat(int _format) -{ - isHexFormat = _format; - return *this; -} - -NdbOut::NdbOut() -{ - CtrlC = 0; - isHexFormat = 0; -} - -NdbOut::~NdbOut() -{ -} - - - -extern "C" -void -ndbout_c(const char * fmt, ...){ - va_list ap; - char buf[1000]; - - va_start(ap, fmt); - if (fmt != 0) - vsnprintf(buf, sizeof(buf)-1, fmt, ap); - ndbout << buf << endl; - va_end(ap); -} diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/NdbSleep.c b/storage/ndb/src/common/portlib/old_dirs/ose/NdbSleep.c deleted file mode 100644 index 70fd83117ef..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/NdbSleep.c +++ /dev/null @@ -1,36 +0,0 @@ -/* 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 */ - - -#include "NdbSleep.h" - -#include <ose.h> - - -int -NdbSleep_MilliSleep(int milliseconds){ - const OSTIME millisecond_delay = milliseconds; - delay(millisecond_delay); - return 0; -} - -int -NdbSleep_SecSleep(int seconds){ - const OSTIME millisecond_delay = seconds*1000; - delay(millisecond_delay); - return 0; -} - diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/NdbTCP.c b/storage/ndb/src/common/portlib/old_dirs/ose/NdbTCP.c deleted file mode 100644 index 9994697b3f8..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/NdbTCP.c +++ /dev/null @@ -1,38 +0,0 @@ -/* 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 */ - - -#include "NdbTCP.h" - - -int -Ndb_getInAddr(struct in_addr * dst, const char *address) { - struct hostent * host; - host = gethostbyname_r(address); - if(host != 0){ - dst->s_addr = ((struct in_addr *) *host->h_addr_list)->s_addr; - free_buf((union SIGNAL **)&host); - return 0; - } - /* Try it as aaa.bbb.ccc.ddd. */ - dst->s_addr = inet_addr(address); - if (dst->s_addr != INADDR_NONE) { - return 0; - } - return -1; -} - - diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/NdbThread.c b/storage/ndb/src/common/portlib/old_dirs/ose/NdbThread.c deleted file mode 100644 index e46903a5cce..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/NdbThread.c +++ /dev/null @@ -1,183 +0,0 @@ -/* 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 */ - - -#include "NdbThread.h" -#include <pthread.h> -#include <malloc.h> -#include <string.h> -#include <NdbOut.hpp> - -#define MAX_THREAD_NAME 16 - - -struct NdbThread -{ - PROCESS pid; - char thread_name[MAX_THREAD_NAME]; -}; - -#define NDBTHREAD_SIGBASE 4010 - -#define NDBTHREAD_START (NDBTHREAD_SIGBASE + 1) /* !-SIGNO(struct NdbThreadStart)-! */ - -struct NdbThreadStart -{ - SIGSELECT sigNo; - NDB_THREAD_FUNC* func; - NDB_THREAD_ARG arg; -}; - -struct NdbThreadStopped -{ - SIGSELECT sigNo; -}; - -union SIGNAL -{ - SIGSELECT sigNo; - struct NdbThreadStart threadStart; - struct NdbThreadStopped threadStopped; -}; - -OS_PROCESS(thread_starter){ - static const SIGSELECT sel_start[] = {1, NDBTHREAD_START}; - struct NdbThreadStart* sigstart; - union SIGNAL* sig; - - /* Receive function adress and params */ - sig = receive((SIGSELECT*)sel_start); - if (sig != NIL){ - if (sig->sigNo == NDBTHREAD_START){ - sigstart = ((struct NdbThreadStart*)sig); - /* Execute function with arg */ - (*sigstart->func)(sigstart->arg); - }else{ - assert(1==0); - } - free_buf(&sig); - } -} - -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) -{ - struct NdbThread* tmpThread; - union SIGNAL* sig; - int ose_prio; - - if (p_thread_func == NULL) - return 0; - - tmpThread = (struct NdbThread*)malloc(sizeof(struct NdbThread)); - if (tmpThread == NULL) - return NULL; - - strncpy((char*)&tmpThread->thread_name, p_thread_name, MAX_THREAD_NAME); - - switch(thread_prio){ - case NDB_THREAD_PRIO_HIGHEST: - ose_prio = 1; - break; - case NDB_THREAD_PRIO_HIGH: - ose_prio = 10; - break; - case NDB_THREAD_PRIO_MEAN: - ose_prio = 16; - break; - case NDB_THREAD_PRIO_LOW: - ose_prio = 23; - break; - case NDB_THREAD_PRIO_LOWEST: - ose_prio = 31; - break; - default: - return NULL; - break; - } - - /* Create process */ - tmpThread->pid = create_process(OS_PRI_PROC, /* Process type */ - (char*)p_thread_name, /* Name */ - thread_starter, /* Entry point */ - thread_stack_size, /* Stack size */ - ose_prio, /* Priority */ - 0, /* Time slice */ - get_bid(current_process()), /* Block */ - NULL, /* Redir table */ - 0, - 0); - - /* Send params to process */ - sig = alloc(sizeof(struct NdbThreadStart), NDBTHREAD_START); - ((struct NdbThreadStart*)sig)->func = p_thread_func; - ((struct NdbThreadStart*)sig)->arg = p_thread_arg; - send(&sig, tmpThread->pid); - - /* Enable NDB_HOME environment variable for the thread */ - { - /* Hardcoded NDB_HOME...*/ - char* ndb_home_env = get_env(current_process(), "NDB_HOME"); - if (ndb_home_env != NULL) - { - /* Set NDB_HOME */ - int rc = set_env(tmpThread->pid, "NDB_HOME", ndb_home_env); - if (rc != 0) - { - /* Not really a problem */ - } - } /* Enable NDB_HOME */ - } - - /* Start process */ - start(tmpThread->pid); - - return tmpThread; -} - - - -void NdbThread_Destroy(struct NdbThread** p_thread) -{ - free(* p_thread); * p_thread = 0; -} - - -int NdbThread_WaitFor(struct NdbThread* p_wait_thread, void** status) -{ - while(hunt(p_wait_thread->thread_name, 0, NULL, NULL) != 0) - delay(1000); - - * status = 0; - - return 0; -} - - -void NdbThread_Exit(int a) -{ - kill_proc(current_process()); -} - - -int NdbThread_SetConcurrencyLevel(int level) -{ - return 0; -} - diff --git a/storage/ndb/src/common/portlib/old_dirs/ose/NdbTick.c b/storage/ndb/src/common/portlib/old_dirs/ose/NdbTick.c deleted file mode 100644 index c3deae2bec3..00000000000 --- a/storage/ndb/src/common/portlib/old_dirs/ose/NdbTick.c +++ /dev/null @@ -1,64 +0,0 @@ -/* 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 */ - - -#include "NdbTick.h" -#include <time.h> - -#define NANOSEC_PER_SEC 1000000000 -#define MICROSEC_PER_SEC 1000000 -#define MILLISEC_PER_SEC 1000 -#define MICROSEC_PER_MILLISEC 1000 -#define MILLISEC_PER_NANOSEC 1000000 - -#ifdef NDB_OSE -NDB_TICKS NdbTick_CurrentMillisecond(void) -{ - return get_ticks()*4; -} -#include <rtc.h> -int -NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros){ - struct TimePair tvp; - rtc_get_time(&tvp); - * secs = tvp.seconds; - * micros = tvp.micros; - return 0; -} - -#endif - -#if defined NDB_SOFTOSE -NDB_TICKS NdbTick_CurrentMillisecond(void) -{ - /** - * Depends on the interval counter in solaris - * that means each "tick" in OSE is really 10 milliseconds - */ - return get_ticks()*10; -} - -#include <rtc.h> -int -NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros){ - struct TimePair tvp; - rtc_get_time(&tvp); - * secs = tvp.seconds; - * micros = tvp.micros; - return 0; -} -#endif - |