summaryrefslogtreecommitdiffstats
path: root/fastos
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-08-18 12:04:45 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-08-18 12:04:45 +0200
commit64809ac8367bb4c059f55a8595f47a323237b238 (patch)
tree62af23907c274c398b231340c006a76700c8f90c /fastos
parent7bbbf406f3cd920222aba9039c6a460370a4ab14 (diff)
Remove more clutter in fastos/types.h
Diffstat (limited to 'fastos')
-rw-r--r--fastos/src/tests/backtracetest.cpp2
-rw-r--r--fastos/src/tests/sockettest.cpp1
-rw-r--r--fastos/src/vespa/fastos/process.h1
-rw-r--r--fastos/src/vespa/fastos/serversocket.cpp73
-rw-r--r--fastos/src/vespa/fastos/serversocket.h2
-rw-r--r--fastos/src/vespa/fastos/socket.cpp15
-rw-r--r--fastos/src/vespa/fastos/socket.h17
-rw-r--r--fastos/src/vespa/fastos/socketevent.h4
-rw-r--r--fastos/src/vespa/fastos/timestamp.cpp4
-rw-r--r--fastos/src/vespa/fastos/types.h81
-rw-r--r--fastos/src/vespa/fastos/unix_app.cpp1
-rw-r--r--fastos/src/vespa/fastos/unix_cond.cpp5
-rw-r--r--fastos/src/vespa/fastos/unix_file.cpp5
-rw-r--r--fastos/src/vespa/fastos/unix_file.h3
-rw-r--r--fastos/src/vespa/fastos/unix_process.cpp1
-rw-r--r--fastos/src/vespa/fastos/unix_socket.h10
-rw-r--r--fastos/src/vespa/fastos/unix_time.cpp2
17 files changed, 65 insertions, 162 deletions
diff --git a/fastos/src/tests/backtracetest.cpp b/fastos/src/tests/backtracetest.cpp
index 48935e4b6a3..df0887c6b63 100644
--- a/fastos/src/tests/backtracetest.cpp
+++ b/fastos/src/tests/backtracetest.cpp
@@ -1,7 +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/backtrace.h>
-#include <assert.h>
+#include <cassert>
#include <string.h>
#include "tests.h"
diff --git a/fastos/src/tests/sockettest.cpp b/fastos/src/tests/sockettest.cpp
index 0b6e8c9360d..3a9c9dab565 100644
--- a/fastos/src/tests/sockettest.cpp
+++ b/fastos/src/tests/sockettest.cpp
@@ -4,6 +4,7 @@
#include <vespa/fastos/file.h>
#include <vespa/fastos/serversocket.h>
#include <cassert>
+#include <arpa/inet.h>
#define MAZE_FILE_OFFSET 1078
diff --git a/fastos/src/vespa/fastos/process.h b/fastos/src/vespa/fastos/process.h
index e29b90d49cd..1810a730d9d 100644
--- a/fastos/src/vespa/fastos/process.h
+++ b/fastos/src/vespa/fastos/process.h
@@ -11,6 +11,7 @@
#pragma once
#include "types.h"
+#include <cstddef>
/**
* This class serves as a sink for redirected (piped) output from
diff --git a/fastos/src/vespa/fastos/serversocket.cpp b/fastos/src/vespa/fastos/serversocket.cpp
index 2ad8ed32bb3..a79e163db17 100644
--- a/fastos/src/vespa/fastos/serversocket.cpp
+++ b/fastos/src/vespa/fastos/serversocket.cpp
@@ -1,12 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-//************************************************************************
-/**
- * Implementation of FastOS_ServerSocket methods.
- *
- * @author Div, Oivind H. Danielsen
- */
#include "serversocket.h"
+#include <netinet/in.h>
#include <cstring>
@@ -23,75 +18,57 @@ void FastOS_ServerSocket::SetSocketFactory(FastOS_SocketFactory *socketFactory)
FastOS_SocketInterface *FastOS_ServerSocket::CreateHandlerSocket(void)
{
- FastOS_SocketInterface *newSocket = NULL;
- if (_socketFactory != NULL)
- {
- newSocket = _socketFactory->CreateSocket();
- }
- else
- {
- newSocket = new FastOS_Socket();
- }
-
- return newSocket;
+ return (_socketFactory != nullptr)
+ ? _socketFactory->CreateSocket()
+ : (FastOS_SocketInterface *)new FastOS_Socket();
}
FastOS_SocketInterface *FastOS_ServerSocket::Accept()
{
- FastOS_SocketInterface *handlerSocket = NULL;
- int handlerSocketHandle;
struct sockaddr_storage clientAddress;
socklen_t clientAddressLength = sizeof(clientAddress);
memset(&clientAddress, 0, sizeof(clientAddress));
- handlerSocketHandle = accept(_socketHandle,
- reinterpret_cast<struct sockaddr *>(&clientAddress),
- &clientAddressLength);
+ int handlerSocketHandle = accept(_socketHandle, reinterpret_cast<struct sockaddr *>(&clientAddress),
+ &clientAddressLength);
- if (handlerSocketHandle >= 0)
- {
- handlerSocket = CreateHandlerSocket();
+ if (handlerSocketHandle >= 0) {
+ FastOS_SocketInterface *handlerSocket = CreateHandlerSocket();
- if (handlerSocket != NULL)
- {
- handlerSocket->SetUp(handlerSocketHandle,
- reinterpret_cast<struct sockaddr *>(&clientAddress));
+ if (handlerSocket != nullptr) {
+ handlerSocket->SetUp(handlerSocketHandle, reinterpret_cast<struct sockaddr *>(&clientAddress));
}
+ return handlerSocket;
}
- return handlerSocket;
+ return nullptr;
}
FastOS_Socket *FastOS_ServerSocket::AcceptPlain()
{
- FastOS_Socket *handlerSocket = NULL;
- int handlerSocketHandle;
struct sockaddr_storage clientAddress;
socklen_t clientAddressLength = sizeof(clientAddress);
memset(&clientAddress, 0, sizeof(clientAddress));
- handlerSocketHandle = accept(_socketHandle,
- reinterpret_cast<struct sockaddr *>(&clientAddress),
- &clientAddressLength);
+ int handlerSocketHandle = accept(_socketHandle, reinterpret_cast<struct sockaddr *>(&clientAddress),
+ &clientAddressLength);
- if (handlerSocketHandle >= 0)
- {
- handlerSocket = new FastOS_Socket();
+ if (handlerSocketHandle >= 0) {
+ FastOS_Socket *handlerSocket = new FastOS_Socket();
- if (handlerSocket != NULL)
- {
- handlerSocket->SetUp(handlerSocketHandle,
- reinterpret_cast<struct sockaddr *>(&clientAddress));
+ if (handlerSocket != nullptr) {
+ handlerSocket->SetUp(handlerSocketHandle, reinterpret_cast<struct sockaddr *>(&clientAddress));
}
+ return handlerSocket;
}
- return handlerSocket;
+ return nullptr;
}
FastOS_ServerSocket::FastOS_ServerSocket(int socketHandle, FastOS_SocketFactory *socketFactory)
@@ -117,8 +94,7 @@ bool FastOS_ServerSocket::Listen ()
(_address.ss_family == AF_INET6 &&
reinterpret_cast<const sockaddr_in6 &>(_address).sin6_port != 0))
reuseAddr = true;
- if (SetSoReuseAddr(reuseAddr))
- {
+ if (SetSoReuseAddr(reuseAddr)) {
size_t socketAddrLen;
switch (_address.ss_family)
{
@@ -135,11 +111,8 @@ bool FastOS_ServerSocket::Listen ()
default:
socketAddrLen = sizeof(sockaddr_storage);
}
- if(bind(_socketHandle, reinterpret_cast<struct sockaddr *>(&_address),
- socketAddrLen) >= 0)
- {
- if(listen(_socketHandle, _backLog) >= 0)
- {
+ if(bind(_socketHandle, reinterpret_cast<struct sockaddr *>(&_address), socketAddrLen) >= 0) {
+ if(listen(_socketHandle, _backLog) >= 0) {
rc = true;
}
}
diff --git a/fastos/src/vespa/fastos/serversocket.h b/fastos/src/vespa/fastos/serversocket.h
index 8452649015c..93f1efe21fc 100644
--- a/fastos/src/vespa/fastos/serversocket.h
+++ b/fastos/src/vespa/fastos/serversocket.h
@@ -10,7 +10,7 @@
#pragma once
-#include <vespa/fastos/socket.h>
+#include "socket.h"
/**
diff --git a/fastos/src/vespa/fastos/socket.cpp b/fastos/src/vespa/fastos/socket.cpp
index 21f5d788b18..2732a38cf4c 100644
--- a/fastos/src/vespa/fastos/socket.cpp
+++ b/fastos/src/vespa/fastos/socket.cpp
@@ -5,6 +5,8 @@
#include <cassert>
#include <cstring>
#include <netinet/tcp.h>
+#include <netinet/in.h>
+#include <netdb.h>
FastOS_SocketInterface::FastOS_SocketInterface()
: _readEventEnabled(false),
@@ -264,6 +266,19 @@ int FastOS_SocketInterface::GetLocalPort ()
return result;
}
+unsigned short
+FastOS_SocketInterface::GetPort () const
+{
+ switch (_address.ss_family) {
+ case AF_INET:
+ return reinterpret_cast<const sockaddr_in &>(_address).sin_port;
+ case AF_INET6:
+ return reinterpret_cast<const sockaddr_in6 &>(_address).sin6_port;
+ default:
+ return 0;
+ }
+}
+
std::string
FastOS_SocketInterface::getLastErrorString(void) {
return FastOS_Socket::getErrorString(FastOS_Socket::GetLastError());
diff --git a/fastos/src/vespa/fastos/socket.h b/fastos/src/vespa/fastos/socket.h
index 1d4bf31bf52..6f4650ab64a 100644
--- a/fastos/src/vespa/fastos/socket.h
+++ b/fastos/src/vespa/fastos/socket.h
@@ -3,9 +3,8 @@
#pragma once
#include <vespa/fastos/types.h>
-
#include <string>
-#include <vector>
+#include <sys/socket.h>
class FastOS_SocketInterface;
class FastOS_ServerSocket;
@@ -64,7 +63,7 @@ public:
* Convenience method. Does GetErrorString(GetLastError())
* @return Error string
*/
- static std::string getLastErrorString(void);
+ static std::string getLastErrorString();
static const char *InitializeServices ();
static void CleanupServices ();
@@ -282,17 +281,7 @@ public:
/**
* Return socket port.
*/
- unsigned short GetPort () const
- {
- switch (_address.ss_family) {
- case AF_INET:
- return reinterpret_cast<const sockaddr_in &>(_address).sin_port;
- case AF_INET6:
- return reinterpret_cast<const sockaddr_in6 &>(_address).sin6_port;
- default:
- return 0;
- }
- }
+ unsigned short GetPort () const;
/**
* Tune the socket for transport use.
diff --git a/fastos/src/vespa/fastos/socketevent.h b/fastos/src/vespa/fastos/socketevent.h
index e7f67816586..6ed6b73a86c 100644
--- a/fastos/src/vespa/fastos/socketevent.h
+++ b/fastos/src/vespa/fastos/socketevent.h
@@ -47,8 +47,8 @@ public:
static FastOS_SocketEventObjects *_objects;
static FastOS_SocketEventObjects *ObtainObject (FastOS_SocketEvent *event);
static void ReleaseObject (FastOS_SocketEventObjects *node);
- static void ClassCleanup(void);
- static void InitializeClass(void);
+ static void ClassCleanup();
+ static void InitializeClass();
};
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp
index c671b71de8c..da0aa6bbd01 100644
--- a/fastos/src/vespa/fastos/timestamp.cpp
+++ b/fastos/src/vespa/fastos/timestamp.cpp
@@ -1,7 +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/timestamp.h>
-#include <vespa/fastos/mutex.h>
+#include "timestamp.h"
#include <cmath>
+#include <sys/time.h>
namespace fastos {
diff --git a/fastos/src/vespa/fastos/types.h b/fastos/src/vespa/fastos/types.h
index 506d514f642..c474558cdcc 100644
--- a/fastos/src/vespa/fastos/types.h
+++ b/fastos/src/vespa/fastos/types.h
@@ -1,87 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-//****************************************************************************
-/**
- * @file
- * Type definitions used in FastOS.
- * @author Oivind H. Danielsen
- * @date Creation date: 2000-01-18
- *****************************************************************************/
-
#pragma once
-/**
- * @def __STDC_LIMIT_MACROS
- * According to C99, C++ implementations will only define UINT64_MAX
- * etc when __STDC_LIMIT_MACROS is defined when including stdint.h.
- * UINT64_C etc will only be defined when __STDC_CONSTANT_MACROS is
- * defined. Since this file can be included from any of the files
- * below, we define the behaviour here.
- */
-#ifndef __STDC_LIMIT_MACROS
- #define __STDC_LIMIT_MACROS 1
-#endif
-#ifndef __STDC_CONSTANT_MACROS
- #define __STDC_CONSTANT_MACROS 1
-#endif
-#ifndef __STDC_FORMAT_MACROS
- #define __STDC_FORMAT_MACROS
-#endif
-
-#ifdef __TYPES_H_PTHREAD_U98
-#undef __USE_UNIX98
-#endif
-
-
-
-#ifndef __USE_UNIX98
-#define __TYPES_H_UNISTD_U98
-#define __USE_UNIX98
-#endif
-#ifdef __TYPES_H_UNISTD_U98
-#undef __USE_UNIX98
-#endif
-
-#include <dirent.h>
-
-#include <sys/socket.h>
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-#include <sys/resource.h>
-#include <signal.h>
-
-#include <sys/time.h>
-#include <time.h>
-
-#ifndef __USE_GNU
-#define __USE_GNU /* for O_DIRECT define */
-#define __TYPES_H_DIRECTIO_GNU
-#endif
-
-
-#ifdef __TYPES_H_DIRECTIO_GNU
-#undef __USE_GNU /* for O_DIRECT define */
-#endif
-
-#if (__WORDSIZE == 64)
-
-#else
- #error "Only LP 64 environments are supported."
-#endif
-
#define FASTOS_PREFIX(a) FastOS_##a
-#define FASTOS_EMFILE_VERIFIED (-1)
-#ifdef EMFILE
-#undef FASTOS_EMFILE_VERIFIED
-#define FASTOS_EMFILE_VERIFIED EMFILE
-#endif
-
-#define FASTOS_ENFILE_VERIFIED (-1)
-#ifdef ENFILE
-#undef FASTOS_ENFILE_VERIFIED
-#define FASTOS_ENFILE_VERIFIED ENFILE
-#endif
diff --git a/fastos/src/vespa/fastos/unix_app.cpp b/fastos/src/vespa/fastos/unix_app.cpp
index e736a157eb8..5916017e95c 100644
--- a/fastos/src/vespa/fastos/unix_app.cpp
+++ b/fastos/src/vespa/fastos/unix_app.cpp
@@ -12,6 +12,7 @@
#include "process.h"
#include "unix_ipc.h"
#include <unistd.h>
+#include <csignal>
#include <getopt.h>
diff --git a/fastos/src/vespa/fastos/unix_cond.cpp b/fastos/src/vespa/fastos/unix_cond.cpp
index 6704ba5ea33..f2e541055ff 100644
--- a/fastos/src/vespa/fastos/unix_cond.cpp
+++ b/fastos/src/vespa/fastos/unix_cond.cpp
@@ -1,6 +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/cond.h>
+#include "cond.h"
+#include <sys/time.h>
+#include <cstdint>
FastOS_UNIX_Cond::FastOS_UNIX_Cond(void)
: FastOS_CondInterface(),
@@ -23,6 +25,7 @@ FastOS_UNIX_Cond::Wait(void)
bool
FastOS_UNIX_Cond::TimedWait(int milliseconds)
{
+
struct timeval currentTime;
struct timespec absTime;
int error;
diff --git a/fastos/src/vespa/fastos/unix_file.cpp b/fastos/src/vespa/fastos/unix_file.cpp
index ac474dfcf1a..fb3bcab6b53 100644
--- a/fastos/src/vespa/fastos/unix_file.cpp
+++ b/fastos/src/vespa/fastos/unix_file.cpp
@@ -13,6 +13,7 @@
#include <cstring>
#include <unistd.h>
#include <fcntl.h>
+#include <dirent.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/vfs.h>
@@ -388,10 +389,10 @@ FastOS_UNIX_File::TranslateError (const int osError)
case ENXIO: return ERR_NXIO; // Device not configured
}
- if (osError == FASTOS_ENFILE_VERIFIED)
+ if (osError == ENFILE)
return ERR_NFILE;
- if (osError == FASTOS_EMFILE_VERIFIED)
+ if (osError == EMFILE)
return ERR_MFILE;
return ERR_UNKNOWN;
diff --git a/fastos/src/vespa/fastos/unix_file.h b/fastos/src/vespa/fastos/unix_file.h
index 3311782b47a..aa5ea4edb01 100644
--- a/fastos/src/vespa/fastos/unix_file.h
+++ b/fastos/src/vespa/fastos/unix_file.h
@@ -94,8 +94,7 @@ public:
static int64_t GetFreeDiskSpace (const char *path);
};
-
-
+#include <dirent.h>
/**
* This is the generic UNIX implementation of @ref FastOS_DirectoryScan.
*/
diff --git a/fastos/src/vespa/fastos/unix_process.cpp b/fastos/src/vespa/fastos/unix_process.cpp
index f3d15561958..70e441c64db 100644
--- a/fastos/src/vespa/fastos/unix_process.cpp
+++ b/fastos/src/vespa/fastos/unix_process.cpp
@@ -7,6 +7,7 @@
#include <cstring>
#include <unistd.h>
#include <fcntl.h>
+#include <sys/socket.h>
#include <sys/wait.h>
#ifndef AF_LOCAL
diff --git a/fastos/src/vespa/fastos/unix_socket.h b/fastos/src/vespa/fastos/unix_socket.h
index a4b5d738d32..a1f25a8d159 100644
--- a/fastos/src/vespa/fastos/unix_socket.h
+++ b/fastos/src/vespa/fastos/unix_socket.h
@@ -2,7 +2,7 @@
#pragma once
-#include <vespa/fastos/socket.h>
+#include "socket.h"
class FastOS_UNIX_Socket : public FastOS_SocketInterface
{
@@ -26,8 +26,8 @@ public:
ERR_INPROGRESS = EINPROGRESS,
ERR_WOULDBLOCK = EWOULDBLOCK,
ERR_ADDRNOTAVAIL = EADDRNOTAVAIL,
- ERR_MFILE = FASTOS_EMFILE_VERIFIED,
- ERR_NFILE = FASTOS_ENFILE_VERIFIED,
+ ERR_MFILE = EMFILE,
+ ERR_NFILE = ENFILE,
ERR_CONNRESET = ECONNRESET,
ERR_EAGAIN = EAGAIN, // Old style error codes
@@ -36,8 +36,8 @@ public:
ERR_EINPROGRESS = EINPROGRESS,
ERR_EWOULDBLOCK = EWOULDBLOCK,
ERR_EADDRNOTAVAIL = EADDRNOTAVAIL,
- ERR_EMFILE = FASTOS_EMFILE_VERIFIED,
- ERR_ENFILE = FASTOS_ENFILE_VERIFIED
+ ERR_EMFILE = EMFILE,
+ ERR_ENFILE = ENFILE
};
};
diff --git a/fastos/src/vespa/fastos/unix_time.cpp b/fastos/src/vespa/fastos/unix_time.cpp
index 5961d875840..4b83dcd60f5 100644
--- a/fastos/src/vespa/fastos/unix_time.cpp
+++ b/fastos/src/vespa/fastos/unix_time.cpp
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "time.h"
-#include "types.h"
+#include <sys/time.h>
double
FastOS_UNIX_Time::MicroSecs() const