os Class Reference

#include <os.h>


Static Public Member Functions

static caddr_t mmap (caddr_t addr, size_t len, int prot, int flags, int fildes, off_t off)
static int munmap (caddr_t addr, size_t len)
static int openFile (const char *name, FileOpenMode flags, size_t size)
static int closeFile (int fd)
static off_t lseek (int fildes, off_t offset, int whence)
static size_t write (int fildes, char *buf, size_t size)
static int msync (caddr_t addr, size_t len, int flags)
static int fsync (int fildes)
static size_t alignLong (size_t size)
static size_t align (size_t size)
static char * encrypt (const char *key, const char *salt)
static void * memset (void *src, int c, size_t size)
static void * memcpy (void *src, const void *dest, size_t size)
static int memcmp (const void *s1, const void *s2, size_t size)
static int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
static int usleep (int microsecs)
static int sleep (int secs)
static shared_memory_id shm_create (shared_memory_key key, size_t size, int flag)
static shared_memory_id shm_open (shared_memory_key key, size_t size, int flag)
static void * shm_attach (shared_memory_id id, const void *ptr, int flag)
static int shm_detach (void *)
static int shmctl (int shmid, int cmd)
static double floor (double val)
static sighandler_t signal (int signum, sighandler_t handler)
static int gettimeofday (struct timeval *tp)
static struct tm * localtime (long *secs)
static pid_t getpid ()
static pthread_t getthrid ()
static char * getenv (const char *envVarName)
static int setenv (const char *envVarName, const char *value)
static int kill (pid_t pid, int sig)
static bool atobool (char *value)
static pid_t createProcess (const char *cmdName, const char *arg0,...)
static pid_t fork ()
static size_t send (int fd, const void *buf, size_t len, int flags)
static size_t recv (int fd, void *buf, size_t len, int flags)


Detailed Description

Definition at line 112 of file os.h.


Member Function Documentation

size_t os::align ( size_t  size  )  [static]

Definition at line 152 of file os.cxx.

Referenced by Chunk::allocate(), DatabaseManagerImpl::createTable(), FieldList::getFieldOffset(), TableDef::getTupleSize(), FieldList::getTupleSize(), TableImpl::insertTuple(), TableImpl::isFldNull(), DatabaseManagerImpl::openTable(), and TableImpl::updateTuple().

00153 {
00154     //Calls alignLong
00155     return ((size - 1) | (sizeof(long) - 1)) + 1;
00156 }

Here is the caller graph for this function:

size_t os::alignLong ( size_t  size  )  [static]

Definition at line 147 of file os.cxx.

Referenced by DatabaseManagerImpl::createDatabase(), Database::getSystemDatabaseChunk(), Database::getSystemDatabaseTrans(), and Database::getThreadInfo().

00148 {
00149     return ((size - 1) | (sizeof(long) - 1)) + 1;
00150 }

Here is the caller graph for this function:

bool os::atobool ( char *  value  )  [static]

Definition at line 194 of file os.cxx.

00195 {
00196     if (strlen(value) ==3 && strncasecmp(value,"YES",3)==0) return true;
00197     else if (strlen(value) ==2 && strncasecmp(value,"NO", 2)==0) return false;
00198     else if (strlen(value) ==4 && strncasecmp(value,"true",4)==0) return true;
00199     else if (strlen(value) ==5 && strncasecmp(value,"false",5)==0) return false;
00200     return false;
00201 }

int os::closeFile ( int  fd  )  [static]

Definition at line 99 of file os.cxx.

Referenced by Logger::stopLogger().

00100 {
00101     return ::close(fd);
00102 }

Here is the caller graph for this function:

pid_t os::createProcess ( const char *  cmdName,
const char *  arg0,
  ... 
) [static]

Definition at line 202 of file os.cxx.

Referenced by main(), and startCacheServer().

00203 {
00204     pid_t pid;
00205     pid = ::vfork();
00206     if (pid == (pid_t) -1 )
00207     {
00208         printf("Process creation failed\n");
00209         return -1;
00210     }
00211     if (pid >0)
00212     {
00213         //return for parent
00214         return pid;
00215     }
00216     va_list ap;
00217     va_start(ap,arg0);
00218 
00219     const char *argv[5];
00220 
00221     argv[0]=cmdName;
00222     argv[1]=arg0;
00223 
00224     argv[2]=NULL;
00225     int i = 2;
00226     while(argv[i++]=va_arg(ap,char *));
00227     switch(i){
00228         case 2:
00229             pid=::execl(argv[0],argv[1]);break;
00230         case 3:
00231             pid=::execl(argv[0],argv[1],argv[2]);break;
00232         case 4:
00233             pid=::execl(argv[0],argv[1],argv[2],argv[3]);break;
00234         case 5:
00235             pid=::execl(argv[0],argv[1],argv[2],argv[3],argv[4]);break;
00236         default:
00237             printf("only three options allowed\n");
00238             pid=-1;break;
00239     }
00240     if (pid < 0)
00241         printf("Exec failed\n");
00242     return pid;
00243 
00244 }

Here is the caller graph for this function:

char * os::encrypt ( const char *  key,
const char *  salt 
) [static]

Definition at line 123 of file os.cxx.

Referenced by CatalogTableUSER::authenticate(), CatalogTableUSER::changePass(), and CatalogTableUSER::insert().

00124 {
00125     return ::crypt(key, salt);
00126 }

Here is the caller graph for this function:

double os::floor ( double  val  )  [static]

Definition at line 56 of file os.cxx.

Referenced by Chunk::allocate(), Chunk::compact(), DatabaseManagerImpl::createDatabase(), Database::createSystemDatabaseChunk(), Chunk::free(), Chunk::getIterator(), Chunk::getTotalDataNodes(), and Chunk::setSize().

00057 {
00058     return ::floor(val);
00059 }

Here is the caller graph for this function:

pid_t os::fork (  )  [static]

Definition at line 245 of file os.cxx.

Referenced by TCPServer::handleClient().

00246 {
00247     return ::fork();
00248 }

Here is the caller graph for this function:

int os::fsync ( int  fildes  )  [static]

Definition at line 118 of file os.cxx.

Referenced by Logger::log().

00119 {
00120     return ::fsync(fildes);
00121 }

Here is the caller graph for this function:

char * os::getenv ( const char *  envVarName  )  [static]

Definition at line 178 of file os.cxx.

Referenced by main(), SessionImpl::readConfigFile(), and startCacheServer().

00179 {
00180     char *retVal;
00181     retVal = ::getenv(envVarName);
00182     return retVal;
00183 }

Here is the caller graph for this function:

pid_t os::getpid (  )  [static]

Definition at line 73 of file os.cxx.

Referenced by cleanupDeadProcs(), Logger::createLogRecord(), ProcessManager::getThreadTransaction(), ProcessManager::getThreadTransAddr(), printDebug1(), printError1(), ProcessManager::registerThread(), and ProcessManager::setThreadTransaction().

00074 {
00075     return ::getpid();
00076 }

Here is the caller graph for this function:

pthread_t os::getthrid (  )  [static]

Definition at line 77 of file os.cxx.

Referenced by cleanupDeadProcs(), Logger::createLogRecord(), ProcessManager::getThreadTransaction(), ProcessManager::getThreadTransAddr(), printDebug1(), printError1(), ProcessManager::registerThread(), and ProcessManager::setThreadTransaction().

00078 {
00079     return ::pthread_self();
00080 }

Here is the caller graph for this function:

int os::gettimeofday ( struct timeval *  tp  )  [static]

Definition at line 61 of file os.cxx.

Referenced by Logger::createLogRecord().

00062 {
00063     int retval;
00064     retval=::gettimeofday(tp, NULL);
00065     return retval;
00066 }

Here is the caller graph for this function:

int os::kill ( pid_t  pid,
int  sig 
) [static]

Definition at line 190 of file os.cxx.

Referenced by checkDead(), and main().

00191 {
00192     return ::kill(pid, sig);
00193 }

Here is the caller graph for this function:

struct tm * os::localtime ( long *  secs  )  [static]

Definition at line 68 of file os.cxx.

Referenced by Logger::createLogRecord().

00069 {
00070     return ::localtime(secs);
00071 }

Here is the caller graph for this function:

off_t os::lseek ( int  fildes,
off_t  offset,
int  whence 
) [static]

Definition at line 104 of file os.cxx.

Referenced by openFile().

00105 {
00106     return ::lseek(fildes, offset, whence);
00107 }

Here is the caller graph for this function:

int os::memcmp ( const void *  s1,
const void *  s2,
size_t  size 
) [static]

Definition at line 138 of file os.cxx.

Referenced by AllDataType::compareBinaryVal().

00139 {
00140     return ::memcmp(s1, s2, size);
00141 }

Here is the caller graph for this function:

void * os::memcpy ( void *  src,
const void *  dest,
size_t  size 
) [static]

Definition at line 133 of file os.cxx.

Referenced by TableDef::addField(), Transaction::appendUndoLog(), Transaction::applyUndoLogs(), AllDataType::copyVal(), CatalogTableFIELD::getFieldInfo(), CatalogTableFIELD::insert(), and TableImpl::insertTuple().

00134 {
00135     return ::memcpy(src, dest, size);
00136 }

Here is the caller graph for this function:

void * os::memset ( void *  src,
int  c,
size_t  size 
) [static]

Definition at line 128 of file os.cxx.

Referenced by TableDef::addField().

00129 {
00130     return::memset(src, c, size);
00131 }

Here is the caller graph for this function:

caddr_t os::mmap ( caddr_t  addr,
size_t  len,
int  prot,
int  flags,
int  fildes,
off_t  off 
) [static]

Definition at line 20 of file os.cxx.

00021 {
00022     return ((caddr_t)::mmap(addr,len,prot,flags,fildes,off));
00023 }

int os::msync ( caddr_t  addr,
size_t  len,
int  flags 
) [static]

Definition at line 114 of file os.cxx.

00115 {
00116     return ::msync(addr, len, flags);
00117 }

int os::munmap ( caddr_t  addr,
size_t  len 
) [static]

Definition at line 25 of file os.cxx.

00026 {
00027     return ::munmap(addr, len);
00028 }

int os::openFile ( const char *  name,
FileOpenMode  flags,
size_t  size 
) [static]

Definition at line 85 of file os.cxx.

References lseek(), and write().

Referenced by Logger::startLogger().

00086 {
00087     int retval = -1;
00088     //mode_t mode = S_IRWXU | S_IRGRP | S_IWGRP ;
00089     mode_t mode = (mode_t)0755 ;
00090     retval=::open(name, flags, mode);
00091     if (0 == size)
00092         return retval;
00093     os::lseek(retval, size-1, SEEK_SET);
00094     char *buf = (char*)" ";
00095     os::write(retval, buf, 1);
00096     return retval;
00097 }

Here is the call graph for this function:

Here is the caller graph for this function:

size_t os::recv ( int  fd,
void *  buf,
size_t  len,
int  flags 
) [static]

Definition at line 253 of file os.cxx.

Referenced by TCPClient::connect(), TCPServer::handleClient(), and TCPClient::receive().

00254 {
00255     return ::recv(fd, buf, len, flags);
00256 }

Here is the caller graph for this function:

int os::select ( int  nfds,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  exceptfds,
struct timeval *  timeout 
) [static]

Definition at line 158 of file os.cxx.

Referenced by UDPClient::connect(), TCPClient::connect(), TableImpl::fetchNoBind(), LockManager::getExclusiveLock(), LockManager::getSharedLock(), UDPServer::handleClient(), TCPServer::handleClient(), main(), UDPClient::receive(), TCPClient::receive(), Mutex::tryLock(), and usleep().

00160 {
00161     return ::select(nfds, readfds, writefds, exceptfds, timeout);
00162 }

Here is the caller graph for this function:

size_t os::send ( int  fd,
const void *  buf,
size_t  len,
int  flags 
) [static]

Definition at line 249 of file os.cxx.

Referenced by TCPClient::disconnect(), TCPServer::handleClient(), and TCPClient::send().

00250 {
00251     return ::send(fd, buf, len, flags);
00252 }

Here is the caller graph for this function:

int os::setenv ( const char *  envVarName,
const char *  value 
) [static]

Definition at line 185 of file os.cxx.

00186 {
00187     return ::setenv(envVarName, value,1);
00188 }

void * os::shm_attach ( shared_memory_id  id,
const void *  ptr,
int  flag 
) [static]

Definition at line 46 of file os.cxx.

Referenced by DatabaseManagerImpl::createDatabase(), and DatabaseManagerImpl::openDatabase().

00047 {
00048     return ::shmat(id, ptr, flag);
00049 }

Here is the caller graph for this function:

shared_memory_id os::shm_create ( shared_memory_key  key,
size_t  size,
int  flag 
) [static]

Definition at line 31 of file os.cxx.

Referenced by DatabaseManagerImpl::createDatabase().

00032 {
00033     return ::shmget(key, size, IPC_CREAT | IPC_EXCL | flag);
00034     //return ::shmget(key, size, IPC_CREAT | flag);
00035 }

Here is the caller graph for this function:

int os::shm_detach ( void *   )  [static]

Definition at line 51 of file os.cxx.

Referenced by DatabaseManagerImpl::closeDatabase().

00052 {
00053     return ::shmdt((char*)addr);
00054 }

Here is the caller graph for this function:

shared_memory_id os::shm_open ( shared_memory_key  key,
size_t  size,
int  flag 
) [static]

Definition at line 37 of file os.cxx.

Referenced by DatabaseManagerImpl::deleteDatabase(), and DatabaseManagerImpl::openDatabase().

00038 {
00039     return ::shmget(key, size, flag);
00040 }

Here is the caller graph for this function:

int os::shmctl ( int  shmid,
int  cmd 
) [static]

Definition at line 41 of file os.cxx.

Referenced by DatabaseManagerImpl::deleteDatabase().

00042 {
00043     return ::shmctl(shmid, cmd, NULL);
00044 }

Here is the caller graph for this function:

sighandler_t os::signal ( int  signum,
sighandler_t  handler 
) [static]

Definition at line 142 of file os.cxx.

Referenced by main().

00143 {
00144     return ::signal(signum, handler);
00145 }

Here is the caller graph for this function:

int os::sleep ( int  secs  )  [static]

Definition at line 163 of file os.cxx.

00164 { 
00165     return ::sleep(secs);
00166 }

int os::usleep ( int  microsecs  )  [static]

Definition at line 167 of file os.cxx.

References select().

00168 { 
00169     struct timeval timeout;
00170     timeout.tv_sec = 0;
00171     timeout.tv_usec = msecs;
00172     os::select(0,0,0,0, &timeout);
00173     return 0;
00174 }

Here is the call graph for this function:

size_t os::write ( int  fildes,
char *  buf,
size_t  size 
) [static]

Definition at line 109 of file os.cxx.

Referenced by Logger::log(), openFile(), printDebug1(), and printError1().

00110 {
00111     return ::write(fildes, buf, size);
00112 }

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 22:49:21 2008 for csql by  doxygen 1.4.7