Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -208,11 +208,11 @@ #endif ], [ AC_MSG_RESULT(yes) size_max="SIZE_T_MAX"], [ AC_MSG_RESULT(no) - size_max="((size_t)-1)" + size_max="(~(size_t)0)" ]) AC_DEFINE_UNQUOTED(SIZE_MAX, $size_max, [Maximum value for size_t]) ]) AC_CHECK_FUNC(asprintf, [ Index: src/OFDate.h ================================================================== --- src/OFDate.h +++ src/OFDate.h @@ -49,10 +49,20 @@ * \return A new, autoreleased OFDate with the specified date and time */ + dateWithTimeIntervalSince1970: (time_t)sec microseconds: (suseconds_t)usec; +/** + * \return A date in the distant future + */ ++ distantFuture; + +/** + * \return A date in the distant past + */ ++ distantPast; + /** * Initializes an already allocated OFDate with the specified date and time. * * \param sec The seconds since 1970-01-01 00:00:00 * \return An initialized OFDate with the specified date and time Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -9,10 +9,12 @@ * the packaging of this file. */ #include "config.h" +#include +#include #include #include #import "OFDate.h" @@ -112,10 +114,30 @@ microseconds: (suseconds_t)usec { return [[[self alloc] initWithTimeIntervalSince1970: sec microseconds: usec] autorelease]; } + ++ distantFuture +{ + if (sizeof(time_t) == sizeof(int64_t)) + return [[[self alloc] + initWithTimeIntervalSince1970: INT64_MAX] autorelease]; + if (sizeof(time_t) == sizeof(int32_t)) + return [[[self alloc] + initWithTimeIntervalSince1970: INT32_MAX] autorelease]; + + /* Neither 64 nor 32 bit. But it's guaranteed to be at least an int */ + return [[[self alloc] + initWithTimeIntervalSince1970: INT_MAX] autorelease]; +} + ++ distantPast +{ + /* We don't know if time_t is signed or unsigned. Use 0 to be safe */ + return [[[self alloc] initWithTimeIntervalSince1970: 0] autorelease]; +} - init { struct timeval t;