Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made it build on EPICS 3.14.12.6, all unit tests pass. #3

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ jobs:
- gdb
- cmake

- env: BASE=3.14
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gdb
- cmake

- env: BASE=7.0
compiler: clang
addons:
Expand Down
12 changes: 8 additions & 4 deletions example/ticker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ int main(int argc, char* argv[])
}

if(argc>=3) {
double rate = 0.0;

if(epicsParseDouble(argv[2], &rate, nullptr) || rate<=0.0) {
double rate;
try {
rate = std::stod(argv[2]);
if (rate <= 0.0) {
throw std::runtime_error("negative");
}
} catch (...) {
std::cerr<<"Rate must be a positive number, not "<<argv[2]<<"\n";
return 1;
}
Expand Down Expand Up @@ -80,7 +84,7 @@ int main(int argc, char* argv[])

// connect to SIGINT/SIGTERM to break from main loop
SigInt handle([&done]() {
done.trigger();
done.signal();
});

// Start server in background
Expand Down
2 changes: 1 addition & 1 deletion src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void ResultWaiter::complete(Result&& result, bool interrupt)
}
}
if(wakeup)
notify.trigger();
notify.signal();
}

OperationBase::OperationBase(operation_t op, const std::shared_ptr<Channel>& chan)
Expand Down
2 changes: 1 addition & 1 deletion src/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ void Value::traverse(const std::string &expr, bool modify)
maybedot = false;

size_t sep = expr.find_first_of(']', pos);
unsigned long long index=0;
epicsUInt64 index=0;

if(expr[pos]=='['
&& sep!=std::string::npos && sep-pos>=2
Expand Down
6 changes: 3 additions & 3 deletions src/evhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ struct evbase::Pvt : public epicsThreadRunable
if(event_add(keepalive.get(), &tick))
throw std::runtime_error("Can't start keepalive timer");

start_sync.trigger();
start_sync.signal();

log_info_printf(logerr, "Enter loop worker for %p\n", base.get());

Expand All @@ -141,7 +141,7 @@ struct evbase::Pvt : public epicsThreadRunable
}catch(std::exception& e){
log_exc_printf(logerr, "Unhandled exception in event_base run : %s\n",
e.what());
start_sync.trigger();
start_sync.signal();
}
}

Expand All @@ -165,7 +165,7 @@ struct evbase::Pvt : public epicsThreadRunable
}
}
if(work.notify)
work.notify->trigger();
work.notify->signal();
}
}
static
Expand Down
8 changes: 5 additions & 3 deletions src/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
#include <epicsGuard.h>
#include <epicsTime.h>

#if EPICS_VERSION_INT>=VERSION_INT(3,15,0,0)
# include <epicsStackTrace.h>
# define USE_STACKTRACE
#ifdef VERSION_INT
# if EPICS_VERSION_INT>=VERSION_INT(3,15,0,0)
# include <epicsStackTrace.h>
# define USE_STACKTRACE
# endif
#endif

#include "evhelper.h"
Expand Down
1 change: 1 addition & 0 deletions src/pvxs/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <atomic>

#include <cstddef>
#include <stdarg.h>

#include <compilerDependencies.h>
Expand Down
133 changes: 133 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "udp_collector.h"

#include "pvxsVCS.h"
#include "utilpvt.h"

namespace pvxs {

Expand Down Expand Up @@ -408,3 +409,135 @@ void indent(std::ostream& strm, unsigned level) {
}

}}

#ifndef HAVE_EPICSPARSE
PVXS_API int epicsParseInt8(const char* s, epicsInt8* val, int base, char**)
{
try {
size_t idx;
epicsInt8 v = (std::stoi(s, &idx, base) & 0xff);
if (s[idx]=='\0') {
*val = v;
return 0;
}
} catch (...) {}
return -1;
}

PVXS_API int epicsParseInt16(const char* s, epicsInt16* val, int base, char**)
{
try {
size_t idx;
epicsInt16 v = (std::stoi(s, &idx, base) & 0xffff);
if (s[idx]=='\0') {
*val = v;
return 0;
}
} catch (...) {}
return -1;
}

PVXS_API int epicsParseInt32(const char* s, epicsInt32* val, int base, char**)
{
try {
size_t idx;
epicsInt32 v = (std::stoi(s, &idx, base) & 0xffffffff);
if (s[idx]=='\0') {
*val = v;
return 0;
}
} catch (...) {}
return -1;
}

PVXS_API int epicsParseInt64(const char* s, epicsInt64* val, int base, char**)
{
try {
size_t idx;
epicsInt64 v = (std::stoi(s, &idx, base) & 0xffffffffffffffff);
if (s[idx]=='\0') {
*val = v;
return 0;
}
} catch (...) {}
return -1;
}

PVXS_API int epicsParseUInt8(const char* s, epicsUInt8* val, int base, char**)
{
try {
size_t idx;
epicsUInt8 v = (std::stoul(s, &idx, base) & 0xff);
if (s[idx]=='\0') {
*val = v;
return 0;
}
} catch (...) {}
return -1;
}

PVXS_API int epicsParseUInt16(const char* s, epicsUInt16* val, int base, char**)
{
try {
size_t idx;
epicsUInt16 v = (std::stoul(s, &idx, base) & 0xffff);
if (s[idx]=='\0') {
*val = v;
return 0;
}
} catch (...) {}
return -1;
}

PVXS_API int epicsParseUInt32(const char* s, epicsUInt32* val, int base, char**)
{
try {
size_t idx;
epicsUInt32 v = (std::stoul(s, &idx, base) & 0xffffffff);
if (s[idx]=='\0') {
*val = v;
return 0;
}
} catch (...) {}
return -1;
}

PVXS_API int epicsParseUInt64(const char* s, epicsUInt64* val, int base, char**)
{
try {
size_t idx;
epicsUInt64 v = (std::stoul(s, &idx, base) & 0xffffffffffffffff);
if (s[idx]=='\0') {
*val = v;
return 0;
}
} catch (...) {}
return -1;
}

PVXS_API int epicsParseFloat(const char* s, epicsFloat32* val, char**)
{
try {
size_t idx;
epicsFloat32 v = std::stof(s, &idx);
if (s[idx]=='\0') {
*val = v;
return 0;
}
} catch (...) {}
return -1;
}

PVXS_API int epicsParseDouble(const char* s, epicsFloat64* val, char**)
{
try {
size_t idx;
epicsFloat64 v = std::stod(s, &idx);
if (s[idx]=='\0') {
*val = v;
return 0;
}
} catch (...) {}
return -1;
}
#endif // HAVE_EPICSPARSE
31 changes: 31 additions & 0 deletions src/utilpvt.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include <compilerDependencies.h>

#include <epicsTypes.h>

#include <pvxs/version.h>
#include <pvxs/util.h>

Expand All @@ -35,6 +37,35 @@
# endif
#endif

#if EPICS_VERSION_INT>=VERSION_INT(3,15,0,0)
# define HAVE_EPICSPARSE
# define HAVE_EPICSINT64
#endif

#ifndef HAVE_EPICSINT64
typedef int64_t epicsInt64;
typedef uint64_t epicsUInt64;
#endif // HAVE_EPICSINT64

#ifndef HAVE_EPICSPARSE
PVXS_API int epicsParseInt8(const char* s, epicsInt8* val, int base, char** units);
PVXS_API int epicsParseInt16(const char* s, epicsInt16* val, int base, char** units);
PVXS_API int epicsParseInt32(const char* s, epicsInt32* val, int base, char** units);
PVXS_API int epicsParseInt64(const char* s, epicsInt64* val, int base, char** units);
PVXS_API int epicsParseUInt8(const char* s, epicsUInt8* val, int base, char** units);
PVXS_API int epicsParseUInt16(const char* s, epicsUInt16* val, int base, char** units);
PVXS_API int epicsParseUInt32(const char* s, epicsUInt32* val, int base, char** units);
PVXS_API int epicsParseUInt64(const char* s, epicsUInt64* val, int base, char** units);
PVXS_API int epicsParseFloat(const char* s, epicsFloat32* val, char** units);
PVXS_API int epicsParseDouble(const char* s, epicsFloat64* val, char** units);
# define epicsParseFloat32(str, to, units) epicsParseFloat(str, to, units)
# define epicsParseFloat64(str, to, units) epicsParseDouble(str, to, units)
# define epicsParseLong(str, to, base, units) epicsParseInt32(str, to, base, units)
# define epicsParseULong(str, to, base, units) epicsParseUInt32(str, to, base, units)
# define epicsParseLLong(str, to, base, units) epicsParseInt64(str, to, base, units)
# define epicsParseULLong(str, to, base, units) epicsParseUInt64(str, to, base, units)
#endif // HAVE_EPICSPARSE

namespace pvxs {namespace impl {

//! in-line string builder (eg. for exception messages)
Expand Down
6 changes: 3 additions & 3 deletions test/testconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void testParse()
testEq(conf.addressList[1], "5.6.7.8:9876");
}

epicsEnvUnset("EPICS_PVA_ADDR_LIST");
epicsEnvUnset("EPICS_PVA_AUTO_ADDR_LIST");
epicsEnvUnset("EPICS_PVA_BROADCAST_PORT");
//epicsEnvUnset("EPICS_PVA_ADDR_LIST");
//epicsEnvUnset("EPICS_PVA_AUTO_ADDR_LIST");
//epicsEnvUnset("EPICS_PVA_BROADCAST_PORT");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd forgotten that this was such a recent addition.

}

}
Expand Down
8 changes: 4 additions & 4 deletions test/testget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct Tester {
auto op = cli.get("mailbox")
.result([&actual, &done](client::Result&& result) {
actual = std::move(result);
done.trigger();
done.signal();
})
.exec();

Expand Down Expand Up @@ -140,7 +140,7 @@ struct Tester {
auto op = cli.info("mailbox")
.result([&actual, &done](client::Result&& result) {
actual = std::move(result);
done.trigger();
done.signal();
})
.exec();

Expand All @@ -162,7 +162,7 @@ struct Tester {
cli.info("mailbox")
.result([&actual, &done](client::Result&& result) {
actual = std::move(result);
done.trigger();
done.signal();
})
.exec();

Expand Down Expand Up @@ -221,7 +221,7 @@ void testError(bool phase)
auto op = cli.get("mailbox")
.result([&actual, &done](client::Result&& result) {
actual = std::move(result);
done.trigger();
done.signal();
})
.exec();

Expand Down
8 changes: 4 additions & 4 deletions test/testinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct Tester {
auto op = cli.info("mailbox")
.result([&actual, &done](client::Result&& result) {
actual = std::move(result);
done.trigger();
done.signal();
})
.exec();

Expand Down Expand Up @@ -116,7 +116,7 @@ struct Tester {
auto op = cli.info("mailbox")
.result([&actual, &done](client::Result&& result) {
actual = std::move(result);
done.trigger();
done.signal();
})
.exec();

Expand All @@ -138,7 +138,7 @@ struct Tester {
cli.info("mailbox")
.result([&actual, &done](client::Result&& result) {
actual = std::move(result);
done.trigger();
done.signal();
})
.exec();

Expand Down Expand Up @@ -183,7 +183,7 @@ void testError()
auto op = cli.info("mailbox")
.result([&actual, &done](client::Result&& result) {
actual = std::move(result);
done.trigger();
done.signal();
})
.exec();

Expand Down
Loading