Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
16dd62fc
Commit
16dd62fc
authored
Jul 12, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make predicates for CALL_CFUN inline
parent
d9e63574
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
51 deletions
+19
-51
libcaf_io/CMakeLists.txt
libcaf_io/CMakeLists.txt
+0
-1
libcaf_io/caf/detail/call_cfun.hpp
libcaf_io/caf/detail/call_cfun.hpp
+19
-9
libcaf_io/src/call_cfun.cpp
libcaf_io/src/call_cfun.cpp
+0
-41
No files found.
libcaf_io/CMakeLists.txt
View file @
16dd62fc
...
@@ -46,7 +46,6 @@ set(LIBCAF_IO_SRCS
...
@@ -46,7 +46,6 @@ set(LIBCAF_IO_SRCS
src/tcp.cpp
src/tcp.cpp
src/udp.cpp
src/udp.cpp
src/native_socket.cpp
src/native_socket.cpp
src/call_cfun.cpp
src/socket_guard.cpp
src/socket_guard.cpp
)
)
...
...
libcaf_io/caf/detail/call_cfun.hpp
View file @
16dd62fc
...
@@ -21,22 +21,32 @@
...
@@ -21,22 +21,32 @@
#include <cstdio>
#include <cstdio>
#include <cstdlib>
#include <cstdlib>
#include "caf/error.hpp"
#include "caf/io/network/native_socket.hpp"
#include "caf/io/network/native_socket.hpp"
#include "caf/sec.hpp"
namespace
caf
{
namespace
caf
{
namespace
detail
{
namespace
detail
{
// Predicate for `ccall` meaning "expected result of f is 0".
/// Predicate for `ccall` meaning "expected result of f is 0".
bool
cc_zero
(
int
value
);
inline
bool
cc_zero
(
int
value
)
{
return
value
==
0
;
}
// Predicate for `ccall` meaning "expected result of f is 1".
/// Predicate for `ccall` meaning "expected result of f is 1".
bool
cc_one
(
int
value
);
inline
bool
cc_one
(
int
value
)
{
return
value
==
1
;
}
// Predicate for `ccall` meaning "expected result of f is not -1".
/// Predicate for `ccall` meaning "expected result of f is not -1".
bool
cc_not_minus1
(
int
value
);
inline
bool
cc_not_minus1
(
int
value
)
{
return
value
!=
-
1
;
}
// Predicate for `ccall` meaning "expected result of f is a valid socket".
/// Predicate for `ccall` meaning "expected result of f is a valid socket".
bool
cc_valid_socket
(
caf
::
io
::
network
::
native_socket
fd
);
inline
bool
cc_valid_socket
(
caf
::
io
::
network
::
native_socket
fd
)
{
return
fd
!=
caf
::
io
::
network
::
invalid_native_socket
;
}
/// Calls a C functions and returns an error if `predicate(var)` returns false.
/// Calls a C functions and returns an error if `predicate(var)` returns false.
#define CALL_CFUN(var, predicate, fun_name, expr) \
#define CALL_CFUN(var, predicate, fun_name, expr) \
...
@@ -45,7 +55,7 @@ bool cc_valid_socket(caf::io::network::native_socket fd);
...
@@ -45,7 +55,7 @@ bool cc_valid_socket(caf::io::network::native_socket fd);
return make_error(sec::network_syscall_failed, \
return make_error(sec::network_syscall_failed, \
fun_name, last_socket_error_as_string())
fun_name, last_socket_error_as_string())
// Calls a C functions and calls exit() if `predicate(var)` returns false.
//
/
Calls a C functions and calls exit() if `predicate(var)` returns false.
#define CALL_CRITICAL_CFUN(var, predicate, funname, expr) \
#define CALL_CRITICAL_CFUN(var, predicate, funname, expr) \
auto var = expr; \
auto var = expr; \
if (!predicate(var)) { \
if (!predicate(var)) { \
...
...
libcaf_io/src/call_cfun.cpp
deleted
100644 → 0
View file @
d9e63574
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2018 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/detail/call_cfun.hpp"
namespace
caf
{
namespace
detail
{
bool
cc_zero
(
int
value
)
{
return
value
==
0
;
}
bool
cc_one
(
int
value
)
{
return
value
==
1
;
}
bool
cc_not_minus1
(
int
value
)
{
return
value
!=
-
1
;
}
bool
cc_valid_socket
(
caf
::
io
::
network
::
native_socket
fd
)
{
return
fd
!=
caf
::
io
::
network
::
invalid_native_socket
;
}
}
// namespace detail
}
// namespace caf
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment