summaryrefslogtreecommitdiffstats
path: root/fastos
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-08-18 03:02:49 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-08-18 03:02:49 +0200
commit7a4461355f7ee8e5ec71888516cbfd640dd7e110 (patch)
tree5f800152d48de71247177c4fca93fff24dc993ac /fastos
parent15e7bcd9e902407fbe14cf830968f06c9fb5fb89 (diff)
Include only what you need.
Diffstat (limited to 'fastos')
-rw-r--r--fastos/src/tests/filetest.cpp2
-rw-r--r--fastos/src/tests/sockettest.cpp2
-rw-r--r--fastos/src/tests/tests.h1
-rw-r--r--fastos/src/tests/typetest.cpp35
-rw-r--r--fastos/src/vespa/fastos/CMakeLists.txt1
-rw-r--r--fastos/src/vespa/fastos/app.cpp14
-rw-r--r--fastos/src/vespa/fastos/cond.h4
-rw-r--r--fastos/src/vespa/fastos/file.cpp20
-rw-r--r--fastos/src/vespa/fastos/file.h17
-rw-r--r--fastos/src/vespa/fastos/linux_file.cpp5
-rw-r--r--fastos/src/vespa/fastos/mutex.h13
-rw-r--r--fastos/src/vespa/fastos/process.h20
-rw-r--r--fastos/src/vespa/fastos/serversocket.cpp13
-rw-r--r--fastos/src/vespa/fastos/serversocket.h12
-rw-r--r--fastos/src/vespa/fastos/socket.cpp5
-rw-r--r--fastos/src/vespa/fastos/socketevent.cpp7
-rw-r--r--fastos/src/vespa/fastos/socketevent.h4
-rw-r--r--fastos/src/vespa/fastos/thread.cpp4
-rw-r--r--fastos/src/vespa/fastos/thread.h6
-rw-r--r--fastos/src/vespa/fastos/types.h28
-rw-r--r--fastos/src/vespa/fastos/unix_app.cpp40
-rw-r--r--fastos/src/vespa/fastos/unix_app.h34
-rw-r--r--fastos/src/vespa/fastos/unix_dynamiclibrary.cpp2
-rw-r--r--fastos/src/vespa/fastos/unix_file.cpp12
-rw-r--r--fastos/src/vespa/fastos/unix_file.h3
-rw-r--r--fastos/src/vespa/fastos/unix_ipc.cpp12
-rw-r--r--fastos/src/vespa/fastos/unix_mutex.cpp3
-rw-r--r--fastos/src/vespa/fastos/unix_mutex.h4
-rw-r--r--fastos/src/vespa/fastos/unix_process.cpp73
-rw-r--r--fastos/src/vespa/fastos/unix_process.h73
-rw-r--r--fastos/src/vespa/fastos/unix_socket.cpp6
-rw-r--r--fastos/src/vespa/fastos/unix_thread.cpp20
-rw-r--r--fastos/src/vespa/fastos/unix_thread.h18
33 files changed, 244 insertions, 269 deletions
diff --git a/fastos/src/tests/filetest.cpp b/fastos/src/tests/filetest.cpp
index 92fd5558590..ad411364c0c 100644
--- a/fastos/src/tests/filetest.cpp
+++ b/fastos/src/tests/filetest.cpp
@@ -3,6 +3,8 @@
#include "tests.h"
#include <vespa/fastos/file.h>
#include <memory>
+#include <cassert>
+#include <sys/mman.h>
namespace {
diff --git a/fastos/src/tests/sockettest.cpp b/fastos/src/tests/sockettest.cpp
index 3a62fdbf6eb..0b6e8c9360d 100644
--- a/fastos/src/tests/sockettest.cpp
+++ b/fastos/src/tests/sockettest.cpp
@@ -3,7 +3,7 @@
#include "tests.h"
#include <vespa/fastos/file.h>
#include <vespa/fastos/serversocket.h>
-
+#include <cassert>
#define MAZE_FILE_OFFSET 1078
diff --git a/fastos/src/tests/tests.h b/fastos/src/tests/tests.h
index 94062c04e54..62a873f8a54 100644
--- a/fastos/src/tests/tests.h
+++ b/fastos/src/tests/tests.h
@@ -3,6 +3,7 @@
#include <vespa/fastos/app.h>
#include <vespa/fastos/socket.h>
#include <vespa/fastos/thread.h>
+#include <cstring>
class BaseTest : public FastOS_Application
{
diff --git a/fastos/src/tests/typetest.cpp b/fastos/src/tests/typetest.cpp
index e0399b56ba5..87e3d76c461 100644
--- a/fastos/src/tests/typetest.cpp
+++ b/fastos/src/tests/typetest.cpp
@@ -9,40 +9,6 @@
class TypeTest : public BaseTest
{
private:
- void PrintfSpecifiersTest ()
- {
- char testBuf[200];
- const char *correct;
-
- TestHeader("64-bit printf-specifiers test");
-
- sprintf(testBuf, "%" PRId64, int64_t(-1000)*1000*1000*1000*1000);
- correct = "-1000000000000000";
- Progress(strcmp(testBuf, correct) == 0,
- "Generated=[%s], Correct=[%s]", testBuf, correct);
-
- sprintf(testBuf, "%" PRIu64, uint64_t(1000)*1000*1000*1000*1000);
- correct = "1000000000000000";
- Progress(strcmp(testBuf, correct) == 0,
- "Generated=[%s], Correct=[%s]", testBuf, correct);
-
- sprintf(testBuf, "%" PRIo64, uint64_t(1000)*1000*1000*1000*1000);
- correct = "34327724461500000";
- Progress(strcmp(testBuf, correct) == 0,
- "Generated=[%s], Correct=[%s]", testBuf, correct);
-
- sprintf(testBuf, "%" PRIx64, uint64_t(1000)*1000*1000*1000*1000);
- correct = "38d7ea4c68000";
- Progress(strcmp(testBuf, correct) == 0,
- "Generated=[%s], Correct=[%s]", testBuf, correct);
-
- sprintf(testBuf, "%" PRIX64, uint64_t(1000)*1000*1000*1000*1000);
- correct = "38D7EA4C68000";
- Progress(strcmp(testBuf, correct) == 0,
- "Generated=[%s], Correct=[%s]", testBuf, correct);
-
- PrintSeparator();
- }
void ObjectSizeTest ()
{
@@ -73,7 +39,6 @@ public:
{
printf("grep for the string '%s' to detect failures.\n\n", failString);
- PrintfSpecifiersTest();
ObjectSizeTest();
PrintSeparator();
diff --git a/fastos/src/vespa/fastos/CMakeLists.txt b/fastos/src/vespa/fastos/CMakeLists.txt
index 661dd1c6547..2a0ff2d370a 100644
--- a/fastos/src/vespa/fastos/CMakeLists.txt
+++ b/fastos/src/vespa/fastos/CMakeLists.txt
@@ -5,6 +5,7 @@ vespa_add_library(fastos_objects OBJECT
backtrace.c
file.cpp
linux_file.cpp
+ process.cpp
serversocket.cpp
socket.cpp
socketevent.cpp
diff --git a/fastos/src/vespa/fastos/app.cpp b/fastos/src/vespa/fastos/app.cpp
index a76cd64d197..079dab55754 100644
--- a/fastos/src/vespa/fastos/app.cpp
+++ b/fastos/src/vespa/fastos/app.cpp
@@ -6,12 +6,14 @@
* @author Div, Oivind H. Danielsen
*/
-#include <vespa/fastos/app.h>
-#include <vespa/fastos/socket.h>
-#include <vespa/fastos/file.h>
-
-#include <vespa/fastos/process.h>
-#include <vespa/fastos/thread.h>
+#include "app.h"
+#include "socket.h"
+#include "file.h"
+
+#include "process.h"
+#include "thread.h"
+#include <cstring>
+#include <fcntl.h>
FastOS_ApplicationInterface *FastOS_ProcessInterface::_app;
FastOS_ThreadPool *FastOS_ProcessInterface::GetThreadPool ()
diff --git a/fastos/src/vespa/fastos/cond.h b/fastos/src/vespa/fastos/cond.h
index 457abe666d4..c9405728223 100644
--- a/fastos/src/vespa/fastos/cond.h
+++ b/fastos/src/vespa/fastos/cond.h
@@ -9,9 +9,7 @@
#pragma once
-
-#include <vespa/fastos/types.h>
-#include <vespa/fastos/mutex.h>
+#include "mutex.h"
/**
diff --git a/fastos/src/vespa/fastos/file.cpp b/fastos/src/vespa/fastos/file.cpp
index cf17b672bd5..8f164c2a522 100644
--- a/fastos/src/vespa/fastos/file.cpp
+++ b/fastos/src/vespa/fastos/file.cpp
@@ -6,9 +6,10 @@
* @author Div, Oivind H. Danielsen
*/
-#include <vespa/fastos/file.h>
+#include "file.h"
#include <sstream>
-
+#include <cstring>
+#include <fcntl.h>
DirectIOException::DirectIOException(const char * fileName, const void * buffer, size_t length, int64_t offset) :
std::exception(),
@@ -495,3 +496,18 @@ bool FastOS_FileInterface::Rename (const char *newFileName)
void FastOS_FileInterface::dropFromCache() const
{
}
+
+FastOS_DirectoryScanInterface::FastOS_DirectoryScanInterface(const char *path)
+ : _searchPath(strdup(path))
+{
+}
+
+/**
+ * Destructor.
+ *
+ * Frees operating system resources related to the directory scan.
+ */
+FastOS_DirectoryScanInterface::~FastOS_DirectoryScanInterface()
+{
+ free(_searchPath);
+} \ No newline at end of file
diff --git a/fastos/src/vespa/fastos/file.h b/fastos/src/vespa/fastos/file.h
index 8a9de224259..00ba61b793f 100644
--- a/fastos/src/vespa/fastos/file.h
+++ b/fastos/src/vespa/fastos/file.h
@@ -115,13 +115,6 @@ public:
int getFAdviseOptions() const { return _fAdviseOptions; }
void setFAdviseOptions(int options) { _fAdviseOptions = options; }
- char *ToString () {
- const char dummy[]="FastOS_File::ToString() deprecated";
- char *str = new char [strlen(dummy) + 1];
- strcpy(str, dummy);
- return str;
- }
-
/**
* Initialize the file class. This is invoked by
* @ref FastOS_Application::Init().
@@ -752,20 +745,14 @@ public:
* @param path Path of the directory to be scanned. The path string
* is copied internally.
*/
- FastOS_DirectoryScanInterface(const char *path)
- : _searchPath(strdup(path))
- {
- }
+ FastOS_DirectoryScanInterface(const char *path);
/**
* Destructor.
*
* Frees operating system resources related to the directory scan.
*/
- virtual ~FastOS_DirectoryScanInterface()
- {
- free(_searchPath);
- }
+ virtual ~FastOS_DirectoryScanInterface();
/**
* Get search path.
diff --git a/fastos/src/vespa/fastos/linux_file.cpp b/fastos/src/vespa/fastos/linux_file.cpp
index 1b9556569e2..3817e337490 100644
--- a/fastos/src/vespa/fastos/linux_file.cpp
+++ b/fastos/src/vespa/fastos/linux_file.cpp
@@ -7,9 +7,10 @@
* Implementation of FastOS_Linux_File methods.
*****************************************************************************/
-#include <vespa/fastos/file.h>
+#include "file.h"
#include <sstream>
-#include <stdexcept>
+#include <unistd.h>
+#include <fcntl.h>
const size_t FastOS_Linux_File::_directIOFileAlign = 4096;
const size_t FastOS_Linux_File::_directIOMemAlign = 4096;
diff --git a/fastos/src/vespa/fastos/mutex.h b/fastos/src/vespa/fastos/mutex.h
index 011340b46ca..530e8d007bc 100644
--- a/fastos/src/vespa/fastos/mutex.h
+++ b/fastos/src/vespa/fastos/mutex.h
@@ -9,8 +9,7 @@
#pragma once
-#include <vespa/fastos/types.h>
-
+#include "types.h"
/**
* This class defines a mutual-exclusion object.
@@ -31,7 +30,7 @@ public:
/**
* Destructor
*/
- virtual ~FastOS_MutexInterface () {};
+ virtual ~FastOS_MutexInterface () {}
/**
* Obtain an exclusive lock on the mutex. The result of a recursive lock
@@ -42,7 +41,7 @@ public:
*
* Use @ref Unlock() to unlock the mutex when done.
*/
- virtual void Lock (void)=0;
+ virtual void Lock ()=0;
/**
* Try to obtain an exclusive lock on the mutex. If a lock cannot be
@@ -51,15 +50,15 @@ public:
* the mutex was locked in the attempt, true is returned.
* @return Boolean success/failure
*/
- virtual bool TryLock (void)=0;
+ virtual bool TryLock ()=0;
/**
* Unlock a locked mutex. The result of unlocking a mutex not already
* locked by the calling thread is undefined.
*/
- virtual void Unlock (void)=0;
+ virtual void Unlock ()=0;
};
-#include <vespa/fastos/unix_mutex.h>
+#include "unix_mutex.h"
typedef FastOS_UNIX_Mutex FASTOS_PREFIX(Mutex);
diff --git a/fastos/src/vespa/fastos/process.h b/fastos/src/vespa/fastos/process.h
index 62578f97e44..e29b90d49cd 100644
--- a/fastos/src/vespa/fastos/process.h
+++ b/fastos/src/vespa/fastos/process.h
@@ -10,7 +10,7 @@
#pragma once
-#include <vespa/fastos/types.h>
+#include "types.h"
/**
* This class serves as a sink for redirected (piped) output from
@@ -112,27 +112,13 @@ public:
bool pipeStdin = false,
FastOS_ProcessRedirectListener *stdoutListener = NULL,
FastOS_ProcessRedirectListener *stderrListener = NULL,
- int bufferSize = 65535) :
- _extradoublehackforalignment(0.0),
- _cmdLine(NULL),
- _pipeStdin(pipeStdin),
- _stdoutListener(stdoutListener),
- _stderrListener(stderrListener),
- _bufferSize(bufferSize),
- _next(NULL),
- _prev(NULL)
- {
- _cmdLine = strdup(cmdLine);
- }
+ int bufferSize = 65535);
/**
* Destructor.
* If @ref Wait has not been called yet, it is called here.
*/
- virtual ~FastOS_ProcessInterface ()
- {
- free (_cmdLine);
- };
+ virtual ~FastOS_ProcessInterface ();
/**
* Create and start the process. If your command line includes
diff --git a/fastos/src/vespa/fastos/serversocket.cpp b/fastos/src/vespa/fastos/serversocket.cpp
index 335c34a29b4..2ad8ed32bb3 100644
--- a/fastos/src/vespa/fastos/serversocket.cpp
+++ b/fastos/src/vespa/fastos/serversocket.cpp
@@ -6,7 +6,8 @@
* @author Div, Oivind H. Danielsen
*/
-#include <vespa/fastos/serversocket.h>
+#include "serversocket.h"
+#include <cstring>
/**
@@ -93,6 +94,16 @@ FastOS_Socket *FastOS_ServerSocket::AcceptPlain()
return handlerSocket;
}
+FastOS_ServerSocket::FastOS_ServerSocket(int socketHandle, FastOS_SocketFactory *socketFactory)
+ : _portNumber(-1),
+ _backLog(-1),
+ _socketFactory(socketFactory),
+ _validAddress(false)
+{
+ _socketHandle = socketHandle;
+ memset(&_address, 0, sizeof(_address));
+ _validAddress = true;
+}
bool FastOS_ServerSocket::Listen ()
{
diff --git a/fastos/src/vespa/fastos/serversocket.h b/fastos/src/vespa/fastos/serversocket.h
index 77e7beee55a..8452649015c 100644
--- a/fastos/src/vespa/fastos/serversocket.h
+++ b/fastos/src/vespa/fastos/serversocket.h
@@ -118,17 +118,7 @@ public:
* @param socketHandle OS handle of supplied socket.
* @param socketFactory See @ref SetSocketFactory().
*/
- FastOS_ServerSocket(int socketHandle,
- FastOS_SocketFactory *socketFactory)
- : _portNumber(-1),
- _backLog(-1),
- _socketFactory(socketFactory),
- _validAddress(false)
- {
- _socketHandle = socketHandle;
- memset(&_address, 0, sizeof(_address));
- _validAddress = true;
- }
+ FastOS_ServerSocket(int socketHandle, FastOS_SocketFactory *socketFactory);
/**
* Create a listening socket. This involves creating an OS
diff --git a/fastos/src/vespa/fastos/socket.cpp b/fastos/src/vespa/fastos/socket.cpp
index 522d39c4b32..21f5d788b18 100644
--- a/fastos/src/vespa/fastos/socket.cpp
+++ b/fastos/src/vespa/fastos/socket.cpp
@@ -1,7 +1,10 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/socket.h>
+#include "socket.h"
#include <sstream>
+#include <cassert>
+#include <cstring>
+#include <netinet/tcp.h>
FastOS_SocketInterface::FastOS_SocketInterface()
: _readEventEnabled(false),
diff --git a/fastos/src/vespa/fastos/socketevent.cpp b/fastos/src/vespa/fastos/socketevent.cpp
index 7e5164d2247..e3bc7d28888 100644
--- a/fastos/src/vespa/fastos/socketevent.cpp
+++ b/fastos/src/vespa/fastos/socketevent.cpp
@@ -1,7 +1,10 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/socketevent.h>
-#include <vespa/fastos/socket.h>
+#include "socketevent.h"
+#include "socket.h"
+#include <cassert>
+#include <unistd.h>
+
FastOS_SocketEventObjects *FastOS_SocketEventObjects::_objects = NULL;
FastOS_Mutex FastOS_SocketEventObjects::_listMutex;
diff --git a/fastos/src/vespa/fastos/socketevent.h b/fastos/src/vespa/fastos/socketevent.h
index 5a1e09b1765..e7f67816586 100644
--- a/fastos/src/vespa/fastos/socketevent.h
+++ b/fastos/src/vespa/fastos/socketevent.h
@@ -2,8 +2,8 @@
#pragma once
-#include <vespa/fastos/types.h>
-#include <vespa/fastos/mutex.h>
+#include "types.h"
+#include "mutex.h"
#include <poll.h>
#include <sys/epoll.h>
diff --git a/fastos/src/vespa/fastos/thread.cpp b/fastos/src/vespa/fastos/thread.cpp
index ccf9b544e77..484746a9b0d 100644
--- a/fastos/src/vespa/fastos/thread.cpp
+++ b/fastos/src/vespa/fastos/thread.cpp
@@ -6,7 +6,9 @@
* @author Oivind H. Danielsen
*/
-#include <vespa/fastos/thread.h>
+#include "thread.h"
+#include <cstdio>
+#include <cassert>
// ----------------------------------------------------------------------
// FastOS_ThreadPool
diff --git a/fastos/src/vespa/fastos/thread.h b/fastos/src/vespa/fastos/thread.h
index 24a4b1768fc..b84708eb050 100644
--- a/fastos/src/vespa/fastos/thread.h
+++ b/fastos/src/vespa/fastos/thread.h
@@ -11,9 +11,9 @@
#pragma once
-#include <vespa/fastos/types.h>
-#include <vespa/fastos/mutex.h>
-#include <vespa/fastos/cond.h>
+#include "types.h"
+#include "mutex.h"
+#include "cond.h"
typedef pthread_t FastOS_ThreadId;
diff --git a/fastos/src/vespa/fastos/types.h b/fastos/src/vespa/fastos/types.h
index 08ad40ac8be..506d514f642 100644
--- a/fastos/src/vespa/fastos/types.h
+++ b/fastos/src/vespa/fastos/types.h
@@ -28,29 +28,16 @@
#define __STDC_FORMAT_MACROS
#endif
-#include <assert.h>
-
-#include <pthread.h>
-#include <sys/mman.h>
-
#ifdef __TYPES_H_PTHREAD_U98
#undef __USE_UNIX98
#endif
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <sys/utsname.h>
-#include <rpc/types.h>
-#include <stdarg.h>
-#include <ctype.h>
+
#ifndef __USE_UNIX98
#define __TYPES_H_UNISTD_U98
#define __USE_UNIX98
#endif
-#include <unistd.h>
#ifdef __TYPES_H_UNISTD_U98
#undef __USE_UNIX98
#endif
@@ -74,24 +61,11 @@
#define __TYPES_H_DIRECTIO_GNU
#endif
-#include <fcntl.h>
#ifdef __TYPES_H_DIRECTIO_GNU
#undef __USE_GNU /* for O_DIRECT define */
#endif
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <limits.h>
-#include <float.h>
-#include <netinet/tcp.h>
-#include <inttypes.h>
-#include <getopt.h>
-
#if (__WORDSIZE == 64)
#else
diff --git a/fastos/src/vespa/fastos/unix_app.cpp b/fastos/src/vespa/fastos/unix_app.cpp
index d52813ceb76..e736a157eb8 100644
--- a/fastos/src/vespa/fastos/unix_app.cpp
+++ b/fastos/src/vespa/fastos/unix_app.cpp
@@ -7,10 +7,12 @@
* Implementation of FastOS_UNIX_Application methods.
*****************************************************************************/
-#include <vespa/fastos/app.h>
-#include <vespa/fastos/time.h>
-#include <vespa/fastos/process.h>
-#include <vespa/fastos/unix_ipc.h>
+#include "app.h"
+#include "time.h"
+#include "process.h"
+#include "unix_ipc.h"
+#include <unistd.h>
+#include <getopt.h>
FastOS_UNIX_Application::FastOS_UNIX_Application ()
@@ -33,6 +35,36 @@ unsigned int FastOS_UNIX_Application::GetCurrentProcessId ()
return static_cast<unsigned int>(getpid());
}
+int
+FastOS_UNIX_Application::GetOpt (const char *optionsString,
+ const char* &optionArgument,
+ int &optionIndex)
+{
+ optind = optionIndex;
+
+ int rc = getopt(_argc, _argv, optionsString);
+ optionArgument = optarg;
+ optionIndex = optind;
+ return rc;
+}
+
+int
+FastOS_UNIX_Application::GetOptLong(const char *optionsString,
+ const char* &optionArgument,
+ int &optionIndex,
+ const struct option *longopts,
+ int *longindex)
+{
+ optind = optionIndex;
+
+ int rc = getopt_long(_argc, _argv, optionsString,
+ longopts,
+ longindex);
+
+ optionArgument = optarg;
+ optionIndex = optind;
+ return rc;
+}
bool FastOS_UNIX_Application::
SendIPCMessage (FastOS_UNIX_Process *xproc, const void *buffer,
diff --git a/fastos/src/vespa/fastos/unix_app.h b/fastos/src/vespa/fastos/unix_app.h
index db6669813cf..49a5950c433 100644
--- a/fastos/src/vespa/fastos/unix_app.h
+++ b/fastos/src/vespa/fastos/unix_app.h
@@ -9,8 +9,8 @@
#pragma once
-#include <vespa/fastos/types.h>
-#include <vespa/fastos/app.h>
+#include "types.h"
+#include "app.h"
class FastOS_UNIX_ProcessStarter;
class FastOS_UNIX_IPCHelper;
@@ -34,34 +34,10 @@ public:
FastOS_UNIX_Application ();
virtual ~FastOS_UNIX_Application();
- int GetOpt (const char *optionsString,
- const char* &optionArgument,
- int &optionIndex)
- {
- optind = optionIndex;
+ int GetOpt (const char *optionsString, const char* &optionArgument, int &optionIndex);
- int rc = getopt(_argc, _argv, optionsString);
- optionArgument = optarg;
- optionIndex = optind;
- return rc;
- }
-
- int GetOptLong(const char *optionsString,
- const char* &optionArgument,
- int &optionIndex,
- const struct option *longopts,
- int *longindex)
- {
- optind = optionIndex;
-
- int rc = getopt_long(_argc, _argv, optionsString,
- longopts,
- longindex);
-
- optionArgument = optarg;
- optionIndex = optind;
- return rc;
- }
+ int GetOptLong(const char *optionsString, const char* &optionArgument, int &optionIndex,
+ const struct option *longopts, int *longindex);
static unsigned int GetCurrentProcessId ();
diff --git a/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp b/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp
index f34bc053870..75d3ee9fb27 100644
--- a/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp
+++ b/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp
@@ -56,7 +56,7 @@ FastOS_UNIX_DynamicLibrary::Close()
bool retcode = true;
if (IsOpen()) {
- retcode = (dlclose(_handle) == TRUE);
+ retcode = (dlclose(_handle) == 0);
if (retcode)
_handle = NULL;
}
diff --git a/fastos/src/vespa/fastos/unix_file.cpp b/fastos/src/vespa/fastos/unix_file.cpp
index c4b1448c625..ac474dfcf1a 100644
--- a/fastos/src/vespa/fastos/unix_file.cpp
+++ b/fastos/src/vespa/fastos/unix_file.cpp
@@ -7,9 +7,15 @@
* Implementation of FastOS_UNIX_File methods.
*****************************************************************************/
-#include <vespa/fastos/file.h>
-#include <sys/vfs.h>
+#include "file.h"
#include <sstream>
+#include <cassert>
+#include <cstring>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/vfs.h>
bool
FastOS_UNIX_File::SetPosition(int64_t desiredPosition)
@@ -59,6 +65,8 @@ FastOS_UNIX_File::Stat(const char *filename, FastOS_StatInfo *statInfo)
return rc;
}
+bool FastOS_UNIX_File::SetCurrentDirectory (const char *pathName) { return (chdir(pathName) == 0); }
+
int FastOS_UNIX_File::GetMaximumFilenameLength (const char *pathName)
{
diff --git a/fastos/src/vespa/fastos/unix_file.h b/fastos/src/vespa/fastos/unix_file.h
index 8ac520ccd53..3311782b47a 100644
--- a/fastos/src/vespa/fastos/unix_file.h
+++ b/fastos/src/vespa/fastos/unix_file.h
@@ -43,7 +43,7 @@ public:
static std::string getCurrentDirectory();
- static bool SetCurrentDirectory (const char *pathName) { return (chdir(pathName) == 0); }
+ static bool SetCurrentDirectory (const char *pathName);
static int GetMaximumFilenameLength (const char *pathName);
static int GetMaximumPathLength (const char *pathName);
@@ -56,7 +56,6 @@ public:
_mmapEnabled(false)
{ }
- char *ToString();
bool Open(unsigned int openFlags, const char *filename) override;
bool Close() override;
bool IsOpened() const override { return _filedes >= 0; }
diff --git a/fastos/src/vespa/fastos/unix_ipc.cpp b/fastos/src/vespa/fastos/unix_ipc.cpp
index d02bc4189ca..f8cde75bc7a 100644
--- a/fastos/src/vespa/fastos/unix_ipc.cpp
+++ b/fastos/src/vespa/fastos/unix_ipc.cpp
@@ -1,11 +1,13 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/unix_ipc.h>
-
-#include <vespa/fastos/ringbuffer.h>
+#include "unix_ipc.h"
+#include "ringbuffer.h"
+#include <cassert>
+#include <cstring>
+#include <unistd.h>
+#include <fcntl.h>
FastOS_UNIX_IPCHelper::
-FastOS_UNIX_IPCHelper (FastOS_ApplicationInterface *app,
- int descriptor)
+FastOS_UNIX_IPCHelper (FastOS_ApplicationInterface *app, int descriptor)
: _lock(),
_exitFlag(false),
_app(app),
diff --git a/fastos/src/vespa/fastos/unix_mutex.cpp b/fastos/src/vespa/fastos/unix_mutex.cpp
index a41eb974604..4d802f691ec 100644
--- a/fastos/src/vespa/fastos/unix_mutex.cpp
+++ b/fastos/src/vespa/fastos/unix_mutex.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/mutex.h>
+#include "mutex.h"
+#include <cassert>
FastOS_UNIX_Mutex::FastOS_UNIX_Mutex(void)
: FastOS_MutexInterface(),
diff --git a/fastos/src/vespa/fastos/unix_mutex.h b/fastos/src/vespa/fastos/unix_mutex.h
index 4a1d466e405..30150bc1590 100644
--- a/fastos/src/vespa/fastos/unix_mutex.h
+++ b/fastos/src/vespa/fastos/unix_mutex.h
@@ -12,8 +12,8 @@
#pragma once
-#include <vespa/fastos/mutex.h>
-
+#include "mutex.h"
+#include <pthread.h>
class FastOS_UNIX_Mutex : public FastOS_MutexInterface
{
diff --git a/fastos/src/vespa/fastos/unix_process.cpp b/fastos/src/vespa/fastos/unix_process.cpp
index 6930dc0247e..f3d15561958 100644
--- a/fastos/src/vespa/fastos/unix_process.cpp
+++ b/fastos/src/vespa/fastos/unix_process.cpp
@@ -1,9 +1,13 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/process.h>
-#include <vespa/fastos/app.h>
-#include <vespa/fastos/unix_ipc.h>
-#include <vespa/fastos/time.h>
+#include "process.h"
+#include "unix_ipc.h"
+#include "time.h"
+#include "ringbuffer.h"
#include <vector>
+#include <cstring>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/wait.h>
#ifndef AF_LOCAL
#define AF_LOCAL AF_UNIX
@@ -1408,6 +1412,29 @@ bool FastOS_UNIX_ProcessStarter::CreateSocketPairs ()
return rc;
}
+FastOS_UNIX_ProcessStarter::FastOS_UNIX_ProcessStarter (FastOS_ApplicationInterface *app)
+ : _app(app),
+ _processList(NULL),
+ _pid(-1),
+ _starterSocket(-1),
+ _mainSocket(-1),
+ _starterSocketDescr(-1),
+ _mainSocketDescr(-1),
+ _hasProxiedChildren(false),
+ _closedProxyProcessFiles(false),
+ _hasDetachedProcess(false),
+ _hasDirectChildren(false)
+{
+}
+
+FastOS_UNIX_ProcessStarter::~FastOS_UNIX_ProcessStarter ()
+{
+ if(_starterSocket != -1)
+ close(_starterSocket);
+ if(_mainSocket != -1)
+ close(_mainSocket);
+}
+
bool FastOS_UNIX_ProcessStarter::Start ()
{
bool rc = false;
@@ -1979,3 +2006,41 @@ bool FastOS_UNIX_ProcessStarter::Detach(FastOS_UNIX_Process *process)
process->_app->ProcessUnlock();
return rc;
}
+
+FastOS_UNIX_Process::DescriptorHandle::DescriptorHandle()
+ : _fd(-1),
+ _wantRead(false),
+ _wantWrite(false),
+ _canRead(false),
+ _canWrite(false),
+ _pollIdx(-1),
+ _readBuffer(),
+ _writeBuffer()
+{
+}
+FastOS_UNIX_Process::DescriptorHandle::~DescriptorHandle() { }
+void
+FastOS_UNIX_Process::DescriptorHandle::CloseHandle()
+{
+ _wantRead = false;
+ _wantWrite = false;
+ _canRead = false;
+ _canWrite = false;
+ _pollIdx = -1;
+ if (_fd != -1) {
+ close(_fd);
+ _fd = -1;
+ }
+ if (_readBuffer.get() != NULL)
+ _readBuffer->Close();
+ if (_writeBuffer.get() != NULL)
+ _writeBuffer->Close();
+}
+void
+FastOS_UNIX_Process::DescriptorHandle::CloseHandleDirectChild()
+{
+ if (_fd != -1) {
+ close(_fd);
+ _fd = -1;
+ }
+} \ No newline at end of file
diff --git a/fastos/src/vespa/fastos/unix_process.h b/fastos/src/vespa/fastos/unix_process.h
index 97a5b57c08d..ff034b0e581 100644
--- a/fastos/src/vespa/fastos/unix_process.h
+++ b/fastos/src/vespa/fastos/unix_process.h
@@ -8,15 +8,14 @@
#pragma once
-#include <vespa/fastos/process.h>
-#include <vespa/fastos/app.h>
+#include "process.h"
+#include "app.h"
#include <string>
#include <memory>
class FastOS_BoolCond;
class FastOS_UNIX_RealProcess;
-
-#include <vespa/fastos/ringbuffer.h>
+class FastOS_RingBuffer;
class FastOS_UNIX_Process : public FastOS_ProcessInterface
{
@@ -45,41 +44,10 @@ public:
int _pollIdx;
std::unique_ptr<FastOS_RingBuffer> _readBuffer;
std::unique_ptr<FastOS_RingBuffer> _writeBuffer;
- DescriptorHandle(void)
- : _fd(-1),
- _wantRead(false),
- _wantWrite(false),
- _canRead(false),
- _canWrite(false),
- _pollIdx(-1),
- _readBuffer(),
- _writeBuffer()
- {
- }
- ~DescriptorHandle() { }
- void CloseHandle(void)
- {
- _wantRead = false;
- _wantWrite = false;
- _canRead = false;
- _canWrite = false;
- _pollIdx = -1;
- if (_fd != -1) {
- close(_fd);
- _fd = -1;
- }
- if (_readBuffer.get() != NULL)
- _readBuffer->Close();
- if (_writeBuffer.get() != NULL)
- _writeBuffer->Close();
- }
- void CloseHandleDirectChild(void)
- {
- if (_fd != -1) {
- close(_fd);
- _fd = -1;
- }
- }
+ DescriptorHandle();
+ ~DescriptorHandle();
+ void CloseHandle();
+ void CloseHandleDirectChild();
};
private:
DescriptorHandle _descriptor[4];
@@ -95,8 +63,7 @@ private:
GetProcessStarter();
}
- bool InternalWait (int *returnCode, int timeOutSeconds,
- bool *pollStillRunning);
+ bool InternalWait (int *returnCode, int timeOutSeconds, bool *pollStillRunning);
public:
enum DescriptorType
{
@@ -298,28 +265,8 @@ protected:
void PollReapDirectChildren(void);
public:
- FastOS_UNIX_ProcessStarter (FastOS_ApplicationInterface *app)
- : _app(app),
- _processList(NULL),
- _pid(-1),
- _starterSocket(-1),
- _mainSocket(-1),
- _starterSocketDescr(-1),
- _mainSocketDescr(-1),
- _hasProxiedChildren(false),
- _closedProxyProcessFiles(false),
- _hasDetachedProcess(false),
- _hasDirectChildren(false)
- {
- }
-
- ~FastOS_UNIX_ProcessStarter ()
- {
- if(_starterSocket != -1)
- close(_starterSocket);
- if(_mainSocket != -1)
- close(_mainSocket);
- }
+ FastOS_UNIX_ProcessStarter (FastOS_ApplicationInterface *app);
+ ~FastOS_UNIX_ProcessStarter ();
bool Start ();
void Stop ();
diff --git a/fastos/src/vespa/fastos/unix_socket.cpp b/fastos/src/vespa/fastos/unix_socket.cpp
index ae72c39147d..2bdda49c982 100644
--- a/fastos/src/vespa/fastos/unix_socket.cpp
+++ b/fastos/src/vespa/fastos/unix_socket.cpp
@@ -1,6 +1,10 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/socket.h>
+#include "socket.h"
+#include <cassert>
+#include <cstring>
+#include <unistd.h>
+#include <fcntl.h>
FastOS_UNIX_Socket::~FastOS_UNIX_Socket()
{
diff --git a/fastos/src/vespa/fastos/unix_thread.cpp b/fastos/src/vespa/fastos/unix_thread.cpp
index 3633d1cacc6..eca7a472c6d 100644
--- a/fastos/src/vespa/fastos/unix_thread.cpp
+++ b/fastos/src/vespa/fastos/unix_thread.cpp
@@ -1,7 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/thread.h>
+#include "thread.h"
#include <atomic>
#include <thread>
+#include <unistd.h>
namespace {
std::atomic_size_t _G_nextCpuId(0);
@@ -69,7 +70,7 @@ void FastOS_UNIX_Thread::PreEntry ()
{
}
-FastOS_UNIX_Thread::~FastOS_UNIX_Thread(void)
+FastOS_UNIX_Thread::~FastOS_UNIX_Thread()
{
void *value;
@@ -80,6 +81,18 @@ FastOS_UNIX_Thread::~FastOS_UNIX_Thread(void)
}
}
+bool FastOS_UNIX_Thread::Sleep (int ms)
+{
+ bool rc=false;
+
+ if (ms > 0) {
+ usleep(ms*1000);
+ rc = true;
+ }
+
+ return rc;
+}
+
FastOS_ThreadId FastOS_UNIX_Thread::GetThreadId ()
{
return _handle;
@@ -90,8 +103,7 @@ FastOS_ThreadId FastOS_UNIX_Thread::GetCurrentThreadId ()
return pthread_self();
}
-bool FastOS_UNIX_Thread::CompareThreadIds (FastOS_ThreadId a,
- FastOS_ThreadId b)
+bool FastOS_UNIX_Thread::CompareThreadIds (FastOS_ThreadId a, FastOS_ThreadId b)
{
return (pthread_equal(a, b) != 0);
}
diff --git a/fastos/src/vespa/fastos/unix_thread.h b/fastos/src/vespa/fastos/unix_thread.h
index 691a7909bbb..c6e0b040fc7 100644
--- a/fastos/src/vespa/fastos/unix_thread.h
+++ b/fastos/src/vespa/fastos/unix_thread.h
@@ -9,7 +9,7 @@
#pragma once
-#include <vespa/fastos/thread.h>
+#include "thread.h"
class FastOS_UNIX_Thread : public FastOS_ThreadInterface
{
@@ -36,21 +36,9 @@ public:
~FastOS_UNIX_Thread();
- static bool Sleep (int ms)
- {
- bool rc=false;
-
- if (ms > 0) {
- usleep(ms*1000);
- rc = true;
- }
-
- return rc;
- }
-
+ static bool Sleep (int ms);
FastOS_ThreadId GetThreadId () override;
- static bool CompareThreadIds (FastOS_ThreadId a,
- FastOS_ThreadId b);
+ static bool CompareThreadIds (FastOS_ThreadId a, FastOS_ThreadId b);
static FastOS_ThreadId GetCurrentThreadId ();
};