Commit e71deb9c authored by Kenton Varda's avatar Kenton Varda

Clean up stuff from the Solaris patch that was merged earlier.

parent a22cb202
...@@ -48,6 +48,7 @@ AS_IF([test "$external_capnp" != "no"], [ ...@@ -48,6 +48,7 @@ AS_IF([test "$external_capnp" != "no"], [
]) ])
AM_CONDITIONAL([USE_EXTERNAL_CAPNP], [test "$external_capnp" != "no"]) AM_CONDITIONAL([USE_EXTERNAL_CAPNP], [test "$external_capnp" != "no"])
# Only used in a test. Cleanup?
AC_SEARCH_LIBS(sched_yield, rt) AC_SEARCH_LIBS(sched_yield, rt)
LIBS="$PTHREAD_LIBS $LIBS" LIBS="$PTHREAD_LIBS $LIBS"
......
...@@ -245,7 +245,7 @@ private: ...@@ -245,7 +245,7 @@ private:
switch (value.which()) { switch (value.which()) {
case schema::Value::VOID: return kj::strTree(" ::capnp::VOID"); case schema::Value::VOID: return kj::strTree(" ::capnp::VOID");
case schema::Value::BOOL: return kj::strTree(value.getBool() ? "true" : "false"); case schema::Value::BOOL: return kj::strTree(value.getBool() ? "true" : "false");
case schema::Value::INT8: return kj::strTree(int(value.getInt8())); case schema::Value::INT8: return kj::strTree(value.getInt8());
case schema::Value::INT16: return kj::strTree(value.getInt16()); case schema::Value::INT16: return kj::strTree(value.getInt16());
case schema::Value::INT32: return kj::strTree(value.getInt32()); case schema::Value::INT32: return kj::strTree(value.getInt32());
case schema::Value::INT64: return kj::strTree(value.getInt64(), "ll"); case schema::Value::INT64: return kj::strTree(value.getInt64(), "ll");
...@@ -667,13 +667,6 @@ private: ...@@ -667,13 +667,6 @@ private:
setterDefault = " = ::capnp::VOID"; setterDefault = " = ::capnp::VOID";
break; 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) \ #define HANDLE_PRIMITIVE(discrim, typeName, defaultName, suffix) \
case schema::Type::discrim: \ case schema::Type::discrim: \
kind = FieldKind::PRIMITIVE; \ kind = FieldKind::PRIMITIVE; \
...@@ -683,7 +676,7 @@ private: ...@@ -683,7 +676,7 @@ private:
break; break;
HANDLE_PRIMITIVE(BOOL, bool, Bool, ); 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(INT16, ::int16_t, Int16, );
HANDLE_PRIMITIVE(INT32, ::int32_t, Int32, ); HANDLE_PRIMITIVE(INT32, ::int32_t, Int32, );
HANDLE_PRIMITIVE(INT64, ::int64_t, Int64, ll); HANDLE_PRIMITIVE(INT64, ::int64_t, Int64, ll);
......
...@@ -447,7 +447,7 @@ public: ...@@ -447,7 +447,7 @@ public:
inline explicit constexpr CappedArray(size_t s): currentSize(s) {} inline explicit constexpr CappedArray(size_t s): currentSize(s) {}
inline size_t size() const { return currentSize; } inline size_t size() const { return currentSize; }
inline void setSize(size_t s) { currentSize = s; } inline void setSize(size_t s) { KJ_IREQUIRE(s <= fixedSize); currentSize = s; }
inline T* begin() { return content; } inline T* begin() { return content; }
inline T* end() { return content + currentSize; } inline T* end() { return content + currentSize; }
inline const T* begin() const { return content; } inline const T* begin() const { return content; }
......
...@@ -28,12 +28,12 @@ ...@@ -28,12 +28,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <exception> #include <exception>
#if !defined(__CYGWIN__) && !defined(__sun) #if __linux__ || __APPLE__
#define KJ_HAS_BACKTRACE 1 #define KJ_HAS_BACKTRACE 1
#include <execinfo.h> #include <execinfo.h>
#endif #endif
#if defined(__linux__) && defined(KJ_DEBUG) #if __linux__ && defined(KJ_DEBUG)
#include <stdio.h> #include <stdio.h>
#include <pthread.h> #include <pthread.h>
#endif #endif
...@@ -43,7 +43,7 @@ namespace kj { ...@@ -43,7 +43,7 @@ namespace kj {
namespace { namespace {
String getStackSymbols(ArrayPtr<void* const> trace) { String getStackSymbols(ArrayPtr<void* const> trace) {
#if defined(__linux__) && defined(KJ_DEBUG) #if __linux__ && defined(KJ_DEBUG)
// We want to generate a human-readable stack trace. // We want to generate a human-readable stack trace.
// TODO(someday): It would be really great if we could avoid farming out to addr2line and do // TODO(someday): It would be really great if we could avoid farming out to addr2line and do
......
...@@ -34,6 +34,8 @@ TEST(String, Str) { ...@@ -34,6 +34,8 @@ TEST(String, Str) {
EXPECT_EQ("1 2 3 4", str(1, " ", 2u, " ", 3l, " ", 4ll)); EXPECT_EQ("1 2 3 4", str(1, " ", 2u, " ", 3l, " ", 4ll));
EXPECT_EQ("1.5 foo 1e15 bar -3", str(1.5f, " foo ", 1e15, " bar ", -3)); EXPECT_EQ("1.5 foo 1e15 bar -3", str(1.5f, " foo ", 1e15, " bar ", -3));
EXPECT_EQ("foo", str('f', 'o', 'o')); EXPECT_EQ("foo", str('f', 'o', 'o'));
EXPECT_EQ("123 234 -123 e7",
str((int8_t)123, " ", (uint8_t)234, " ", (int8_t)-123, " ", hex((uint8_t)0xe7)));
} }
TEST(String, StartsEndsWith) { TEST(String, StartsEndsWith) {
......
...@@ -44,12 +44,13 @@ String heapString(const char* value, size_t size) { ...@@ -44,12 +44,13 @@ String heapString(const char* value, size_t size) {
} }
#define HEXIFY_INT(type, format) \ #define HEXIFY_INT(type, format) \
CappedArray<char, sizeof(type) * 4> hex(type i) { \ CappedArray<char, sizeof(type) * 2 + 1> hex(type i) { \
CappedArray<char, sizeof(type) * 4> result; \ CappedArray<char, sizeof(type) * 2 + 1> result; \
result.setSize(sprintf(result.begin(), format, i)); \ result.setSize(sprintf(result.begin(), format, i)); \
return result; \ return result; \
} }
HEXIFY_INT(unsigned char, "%x");
HEXIFY_INT(unsigned short, "%x"); HEXIFY_INT(unsigned short, "%x");
HEXIFY_INT(unsigned int, "%x"); HEXIFY_INT(unsigned int, "%x");
HEXIFY_INT(unsigned long, "%lx"); HEXIFY_INT(unsigned long, "%lx");
...@@ -64,12 +65,14 @@ StringPtr Stringifier::operator*(bool b) const { ...@@ -64,12 +65,14 @@ StringPtr Stringifier::operator*(bool b) const {
} }
#define STRINGIFY_INT(type, format) \ #define STRINGIFY_INT(type, format) \
CappedArray<char, sizeof(type) * 4> Stringifier::operator*(type i) const { \ CappedArray<char, sizeof(type) * 3 + 2> Stringifier::operator*(type i) const { \
CappedArray<char, sizeof(type) * 4> result; \ CappedArray<char, sizeof(type) * 3 + 2> result; \
result.setSize(sprintf(result.begin(), format, i)); \ result.setSize(sprintf(result.begin(), format, i)); \
return result; \ return result; \
} }
STRINGIFY_INT(signed char, "%d");
STRINGIFY_INT(unsigned char, "%u");
STRINGIFY_INT(short, "%d"); STRINGIFY_INT(short, "%d");
STRINGIFY_INT(unsigned short, "%u"); STRINGIFY_INT(unsigned short, "%u");
STRINGIFY_INT(int, "%d"); STRINGIFY_INT(int, "%d");
......
...@@ -270,17 +270,19 @@ struct Stringifier { ...@@ -270,17 +270,19 @@ struct Stringifier {
StringPtr operator*(bool b) const; StringPtr operator*(bool b) const;
CappedArray<char, sizeof(short) * 4> operator*(short i) const; CappedArray<char, 5> operator*(signed char i) const;
CappedArray<char, sizeof(unsigned short) * 4> operator*(unsigned short i) const; CappedArray<char, 5> operator*(unsigned char i) const;
CappedArray<char, sizeof(int) * 4> operator*(int i) const; CappedArray<char, sizeof(short) * 3 + 2> operator*(short i) const;
CappedArray<char, sizeof(unsigned int) * 4> operator*(unsigned int i) const; CappedArray<char, sizeof(unsigned short) * 3 + 2> operator*(unsigned short i) const;
CappedArray<char, sizeof(long) * 4> operator*(long i) const; CappedArray<char, sizeof(int) * 3 + 2> operator*(int i) const;
CappedArray<char, sizeof(unsigned long) * 4> operator*(unsigned long i) const; CappedArray<char, sizeof(unsigned int) * 3 + 2> operator*(unsigned int i) const;
CappedArray<char, sizeof(long long) * 4> operator*(long long i) const; CappedArray<char, sizeof(long) * 3 + 2> operator*(long i) const;
CappedArray<char, sizeof(unsigned long long) * 4> operator*(unsigned long long i) const; CappedArray<char, sizeof(unsigned long) * 3 + 2> operator*(unsigned long i) const;
CappedArray<char, sizeof(long long) * 3 + 2> operator*(long long i) const;
CappedArray<char, sizeof(unsigned long long) * 3 + 2> operator*(unsigned long long i) const;
CappedArray<char, 24> operator*(float f) const; CappedArray<char, 24> operator*(float f) const;
CappedArray<char, 32> operator*(double f) const; CappedArray<char, 32> operator*(double f) const;
CappedArray<char, sizeof(const void*) * 4> operator*(const void* s) const; CappedArray<char, sizeof(const void*) * 3 + 2> operator*(const void* s) const;
template <typename T> template <typename T>
String operator*(ArrayPtr<T> arr) const; String operator*(ArrayPtr<T> arr) const;
...@@ -304,10 +306,11 @@ auto toCharSequence(T&& value) -> decltype(_::STR * kj::fwd<T>(value)) { ...@@ -304,10 +306,11 @@ auto toCharSequence(T&& value) -> decltype(_::STR * kj::fwd<T>(value)) {
return _::STR * kj::fwd<T>(value); return _::STR * kj::fwd<T>(value);
} }
CappedArray<char, sizeof(unsigned short) * 4> hex(unsigned short i); CappedArray<char, sizeof(unsigned char) * 2 + 1> hex(unsigned char i);
CappedArray<char, sizeof(unsigned int) * 4> hex(unsigned int i); CappedArray<char, sizeof(unsigned short) * 2 + 1> hex(unsigned short i);
CappedArray<char, sizeof(unsigned long) * 4> hex(unsigned long i); CappedArray<char, sizeof(unsigned int) * 2 + 1> hex(unsigned int i);
CappedArray<char, sizeof(unsigned long long) * 4> hex(unsigned long long i); CappedArray<char, sizeof(unsigned long) * 2 + 1> hex(unsigned long i);
CappedArray<char, sizeof(unsigned long long) * 2 + 1> hex(unsigned long long i);
template <typename... Params> template <typename... Params>
String str(Params&&... params) { String str(Params&&... params) {
......
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