Commit cbd65e2d authored by Kenton Varda's avatar Kenton Varda

Merge pull request #33 from dmitri-shubin/master

Solaris compatibility
parents 4216cbed ba625d18
......@@ -48,6 +48,8 @@ AS_IF([test "$external_capnp" != "no"], [
])
AM_CONDITIONAL([USE_EXTERNAL_CAPNP], [test "$external_capnp" != "no"])
AC_SEARCH_LIBS(sched_yield, rt)
LIBS="$PTHREAD_LIBS $LIBS"
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
......
......@@ -31,30 +31,30 @@ fail() {
exit 1
}
if test -e ./capnp; then
if test -f ./capnp; then
CAPNP=${CAPNP:-./capnp}
else
CAPNP=${CAPNP:-capnp}
fi
SCHEMA=$(dirname "$0")/../test.capnp
TESTDATA=$(dirname "$0")/../testdata
SCHEMA=`dirname "$0"`/../test.capnp
TESTDATA=`dirname "$0"`/../testdata
$CAPNP encode $SCHEMA TestAllTypes < $TESTDATA/short.txt | cmp $TESTDATA/binary || fail encode
$CAPNP encode --flat $SCHEMA TestAllTypes < $TESTDATA/short.txt | cmp $TESTDATA/flat || fail encode flat
$CAPNP encode --packed $SCHEMA TestAllTypes < $TESTDATA/short.txt | cmp $TESTDATA/packed || fail encode packed
$CAPNP encode $SCHEMA TestAllTypes < $TESTDATA/pretty.txt | cmp $TESTDATA/binary || fail parse pretty
$CAPNP encode $SCHEMA TestAllTypes < $TESTDATA/short.txt | cmp $TESTDATA/binary - || fail encode
$CAPNP encode --flat $SCHEMA TestAllTypes < $TESTDATA/short.txt | cmp $TESTDATA/flat - || fail encode flat
$CAPNP encode --packed $SCHEMA TestAllTypes < $TESTDATA/short.txt | cmp $TESTDATA/packed - || fail encode packed
$CAPNP encode $SCHEMA TestAllTypes < $TESTDATA/pretty.txt | cmp $TESTDATA/binary - || fail parse pretty
$CAPNP decode $SCHEMA TestAllTypes < $TESTDATA/binary | cmp $TESTDATA/pretty.txt || fail decode
$CAPNP decode --flat $SCHEMA TestAllTypes < $TESTDATA/flat | cmp $TESTDATA/pretty.txt || fail decode flat
$CAPNP decode --packed $SCHEMA TestAllTypes < $TESTDATA/packed | cmp $TESTDATA/pretty.txt || fail decode packed
$CAPNP decode --short $SCHEMA TestAllTypes < $TESTDATA/binary | cmp $TESTDATA/short.txt || fail decode short
$CAPNP decode $SCHEMA TestAllTypes < $TESTDATA/binary | cmp $TESTDATA/pretty.txt - || fail decode
$CAPNP decode --flat $SCHEMA TestAllTypes < $TESTDATA/flat | cmp $TESTDATA/pretty.txt - || fail decode flat
$CAPNP decode --packed $SCHEMA TestAllTypes < $TESTDATA/packed | cmp $TESTDATA/pretty.txt - || fail decode packed
$CAPNP decode --short $SCHEMA TestAllTypes < $TESTDATA/binary | cmp $TESTDATA/short.txt - || fail decode short
$CAPNP decode $SCHEMA TestAllTypes < $TESTDATA/segmented | cmp $TESTDATA/pretty.txt || fail decode segmented
$CAPNP decode --packed $SCHEMA TestAllTypes < $TESTDATA/segmented-packed | cmp $TESTDATA/pretty.txt || fail decode segmented-packed
$CAPNP decode $SCHEMA TestAllTypes < $TESTDATA/segmented | cmp $TESTDATA/pretty.txt - || fail decode segmented
$CAPNP decode --packed $SCHEMA TestAllTypes < $TESTDATA/segmented-packed | cmp $TESTDATA/pretty.txt - || fail decode segmented-packed
test_eval() {
test "x$($CAPNP eval $SCHEMA $1)" = "x$2" || fail eval "$1 == $2"
test "x`$CAPNP eval $SCHEMA $1`" = "x$2" || fail eval "$1 == $2"
}
test_eval TestDefaults.uInt32Field 3456789012
......@@ -66,4 +66,4 @@ test_eval TestConstants.enumConst corge
test_eval 'TestListDefaults.lists.int32ListList[2][0]' 12341234
$CAPNP compile -ofoo $TESTDATA/errors.capnp.nobuild 2>&1 | sed -e "s,^.*/errors[.]capnp[.]nobuild,file,g" |
cmp $TESTDATA/errors.txt || fail error output
cmp $TESTDATA/errors.txt - || fail error output
......@@ -241,7 +241,7 @@ private:
switch (value.which()) {
case schema::Value::VOID: return kj::strTree(" ::capnp::VOID");
case schema::Value::BOOL: return kj::strTree(value.getBool() ? "true" : "false");
case schema::Value::INT8: return kj::strTree(value.getInt8());
case schema::Value::INT8: return kj::strTree(int(value.getInt8()));
case schema::Value::INT16: return kj::strTree(value.getInt16());
case schema::Value::INT32: return kj::strTree(value.getInt32());
case schema::Value::INT64: return kj::strTree(value.getInt64(), "ll");
......@@ -652,6 +652,13 @@ private:
setterDefault = " = ::capnp::VOID";
break;
case schema::Type::INT8:
kind = FieldKind::PRIMITIVE;
if (defaultBody.getInt8() != 0) {
defaultMask = kj::str(int(defaultBody.getInt8()), "");
}
break;
#define HANDLE_PRIMITIVE(discrim, typeName, defaultName, suffix) \
case schema::Type::discrim: \
kind = FieldKind::PRIMITIVE; \
......@@ -661,7 +668,7 @@ private:
break;
HANDLE_PRIMITIVE(BOOL, bool, Bool, );
HANDLE_PRIMITIVE(INT8 , ::int8_t , Int8 , );
//HANDLE_PRIMITIVE(INT8 , ::int8_t , Int8 , );
HANDLE_PRIMITIVE(INT16, ::int16_t, Int16, );
HANDLE_PRIMITIVE(INT32, ::int32_t, Int32, );
HANDLE_PRIMITIVE(INT64, ::int64_t, Int64, ll);
......
......@@ -28,7 +28,8 @@
#include <stdlib.h>
#include <exception>
#ifndef __CYGWIN__
#if !defined(__CYGWIN__) && !defined(__sun)
#define KJ_HAS_BACKTRACE 1
#include <execinfo.h>
#endif
......@@ -177,7 +178,7 @@ Exception::Exception(Nature nature, Durability durability, const char* file, int
String description) noexcept
: file(file), line(line), nature(nature), durability(durability),
description(mv(description)) {
#ifdef __CYGWIN__
#ifndef KJ_HAS_BACKTRACE
traceCount = 0;
#else
traceCount = backtrace(trace, 16);
......@@ -188,7 +189,7 @@ Exception::Exception(Nature nature, Durability durability, String file, int line
String description) noexcept
: ownFile(kj::mv(file)), file(ownFile.cStr()), line(line), nature(nature),
durability(durability), description(mv(description)) {
#ifdef __CYGWIN__
#ifndef KJ_HAS_BACKTRACE
traceCount = 0;
#else
traceCount = backtrace(trace, 16);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment