ADDED .cirrus.yml Index: .cirrus.yml ================================================================== --- .cirrus.yml +++ .cirrus.yml @@ -0,0 +1,22 @@ +task: + name: FreeBSD 12.1 + freebsd_instance: + image_family: freebsd-12-1 + install_script: + pkg install -y autoconf automake + shared_script: + - ./autogen.sh + - ./configure + - make -j4 install + static_script: + - ./autogen.sh + - ./configure --disable-shared + - make -j4 install + shared_seluid24_script: + - ./autogen.sh + - ./configure --enable-seluid24 + - make -j4 install + static_seluid24_script: + - ./autogen.sh + - ./configure --disable-shared --enable-seluid24 + - make -j4 install Index: .travis.yml ================================================================== --- .travis.yml +++ .travis.yml @@ -290,18 +290,10 @@ wget -q https://franke.ms/download/amiga-gcc.tgz; tar -C / -xzf amiga-gcc.tgz; fi script: - # This needs to use ed on macOS, as it has no GNU sed, and sed on Linux, as - # some Travis hosts have no ed. - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then - echo -e '%s/-DSTDOUT$/&_SIMPLE/\nwq' | ed -s tests/Makefile; - else - sed -i 's/-DSTDOUT$/&_SIMPLE/' tests/Makefile; - fi - - build() { if ! git clean -fxd >/tmp/clean_log 2>&1; then cat /tmp/clean_log; exit 1; fi; Index: build-aux/m4/buildsys.m4 ================================================================== --- build-aux/m4/buildsys.m4 +++ build-aux/m4/buildsys.m4 @@ -1,11 +1,11 @@ dnl dnl Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017, dnl 2018, 2020 dnl Jonathan Schleifer dnl -dnl https://git.nil.im/buildsys.git +dnl https://fossil.nil.im/buildsys dnl dnl Permission to use, copy, modify, and/or distribute this software for any dnl purpose with or without fee is hereby granted, provided that the above dnl copyright notice and this permission notice is present in all copies. dnl Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -622,17 +622,18 @@ ], [ AC_MSG_RESULT(exceptions unavailable!) AC_MSG_ERROR([Exceptions not accepted by compiler!]) ]) - AC_CHECK_FUNC($raise_exception, [], [ - AC_CHECK_LIB(c++, $raise_exception, [ - LIBS="-lc++ -lc++abi -lpthread $LIBS" - ], [ - AC_MSG_ERROR([_Unwind_RaiseException missing!]) - ], [-lc++abi -lpthread]) - ]) + AC_SEARCH_LIBS($raise_exception, [c++abi gcc_s gcc], [ + dnl c++abi requires pthread on OpenBSD + AS_IF([test x"$ac_lib" = x"c++abi"], [ + LIBS="$LIBS -lpthread" + ]) + ], [ + AC_MSG_ERROR([$raise_exception missing!]) + ], [-lpthread]) AC_CHECK_FUNCS(_Unwind_GetDataRelBase _Unwind_GetTextRelBase) ;; "Apple runtime") AC_DEFINE(OF_APPLE_RUNTIME, 1, Index: extra.mk.in ================================================================== --- extra.mk.in +++ extra.mk.in @@ -1,10 +1,9 @@ OBJFW_SHARED_LIB = @OBJFW_SHARED_LIB@ OBJFW_STATIC_LIB = @OBJFW_STATIC_LIB@ OBJFW_FRAMEWORK = @OBJFW_FRAMEWORK@ OBJFW_AMIGA_LIB = @OBJFW_AMIGA_LIB@ -# When changing: Be sure to also change these in the Xcode project! OBJFW_LIB_MAJOR = 9 OBJFW_LIB_MINOR = 1 OBJFW_LIB_MAJOR_MINOR = ${OBJFW_LIB_MAJOR}.${OBJFW_LIB_MINOR} OBJFWRT_SHARED_LIB = @OBJFWRT_SHARED_LIB@ Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -7,11 +7,11 @@ amiga-glue.amigalib.dep \ amiga-glue.amigalib.o \ amiga-library-functable.inc \ amiga-library.amigalib.dep \ amiga-library.amigalib.o -DISTCLEAN = objfw-defs.h +DISTCLEAN = Info.plist objfw-defs.h SHARED_LIB = ${OBJFW_SHARED_LIB} STATIC_LIB = ${OBJFW_STATIC_LIB} FRAMEWORK = ${OBJFW_FRAMEWORK} AMIGA_LIB = ${OBJFW_AMIGA_LIB} Index: src/OFSelectKernelEventObserver.m ================================================================== --- src/OFSelectKernelEventObserver.m +++ src/OFSelectKernelEventObserver.m @@ -226,12 +226,13 @@ events = select(_maxFD + 1, &readFDs, &writeFDs, NULL, (timeInterval != -1 ? &timeout : NULL)); #endif if (events < 0) - @throw [OFObserveFailedException exceptionWithObserver: self - errNo: errno]; + @throw [OFObserveFailedException + exceptionWithObserver: self + errNo: of_socket_errno()]; #ifdef OF_AMIGAOS if (execSignalMask != 0 && [_delegate respondsToSelector: @selector(execSignalWasReceived:)]) [_delegate execSignalWasReceived: execSignalMask]; Index: src/platform/amiga/thread.m ================================================================== --- src/platform/amiga/thread.m +++ src/platform/amiga/thread.m @@ -166,16 +166,19 @@ bool of_thread_join(of_thread_t thread) { ObtainSemaphore(&thread->semaphore); - @try { - if (thread->done) { - free(thread); - return true; - } + + if (thread->done) { + ReleaseSemaphore(&thread->semaphore); + + free(thread); + return true; + } + @try { if (thread->detached || thread->joinTask != NULL) { errno = EINVAL; return false; } Index: src/platform/windows/thread.m ================================================================== --- src/platform/windows/thread.m +++ src/platform/windows/thread.m @@ -21,10 +21,23 @@ #import "thread.h" #import "macros.h" #include + +struct thread_context { + void (*function)(id); + id object; +}; + +static WINAPI void +functionWrapper(struct thread_context *context) +{ + context->function(context->object); + + free(context); +} bool of_thread_attr_init(of_thread_attr_t *attr) { attr->priority = 0; @@ -35,29 +48,15 @@ bool of_thread_new(of_thread_t *thread, const char *name, void (*function)(id), id object, const of_thread_attr_t *attr) { - *thread = CreateThread(NULL, (attr != NULL ? attr->stackSize : 0), - (LPTHREAD_START_ROUTINE)function, (void *)object, 0, NULL); - - if (thread == NULL) { - switch (GetLastError()) { - case ERROR_NOT_ENOUGH_MEMORY: - errno = ENOMEM; - return false; - case ERROR_ACCESS_DENIED: - errno = EACCES; - return false; - default: - OF_ENSURE(0); - } - } + DWORD priority = THREAD_PRIORITY_NORMAL; + struct thread_context *context; + DWORD threadID; if (attr != NULL && attr->priority != 0) { - DWORD priority; - if (attr->priority < -1 || attr->priority > 1) { errno = EINVAL; return false; } @@ -67,14 +66,45 @@ (THREAD_PRIORITY_NORMAL - THREAD_PRIORITY_LOWEST); else priority = THREAD_PRIORITY_NORMAL + attr->priority * (THREAD_PRIORITY_HIGHEST - THREAD_PRIORITY_NORMAL); + } + + if ((context = malloc(sizeof(*context))) == NULL) { + errno = ENOMEM; + return false; + } + + context->function = function; + context->object = object; + + *thread = CreateThread(NULL, (attr != NULL ? attr->stackSize : 0), + (LPTHREAD_START_ROUTINE)functionWrapper, context, 0, &threadID); + + if (thread == NULL) { + int errNo; + + switch (GetLastError()) { + case ERROR_NOT_ENOUGH_MEMORY: + errNo = ENOMEM; + break; + case ERROR_ACCESS_DENIED: + errNo = EACCES; + break; + default: + OF_ENSURE(0); + } - OF_ENSURE(!SetThreadPriority(*thread, priority)); + free(context); + errno = errNo; + return false; } + if (attr != NULL && attr->priority != 0) + OF_ENSURE(!SetThreadPriority(*thread, priority)); + return true; } bool of_thread_join(of_thread_t thread) Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -4,10 +4,11 @@ CLEAN = EBOOT.PBP \ boot.dol \ ${PROG_NOINST}.arm9 \ ${PROG_NOINST}.nds +DISTCLEAN = Info.plist PROG_NOINST = tests${PROG_SUFFIX} STATIC_LIB_NOINST = ${TESTS_STATIC_LIB} SRCS = ForwardingTests.m \ OFASN1DERRepresentationTests.m \ Index: tests/OFDNSResolverTests.m ================================================================== --- tests/OFDNSResolverTests.m +++ tests/OFDNSResolverTests.m @@ -17,12 +17,10 @@ #include "config.h" #import "TestsAppDelegate.h" -static OFString *module = @"OFDNSResolverTests"; - @implementation TestsAppDelegate (OFDNSResolverTests) - (void)DNSResolverTests { void *pool = objc_autoreleasePoolPush(); OFDNSResolver *resolver = [OFDNSResolver resolver]; @@ -62,14 +60,14 @@ [of_stdout writeFormat: @"[OFDNSResolver] Min number of dots in absolute name: %u\n", resolver.minNumberOfDotsInAbsoluteName]; [of_stdout writeFormat: @"[OFDNSResolver] Uses TCP: %u\n", - module, resolver.usesTCP]; + resolver.usesTCP]; [of_stdout writeFormat: @"[OFDNSResolver] Config reload interval: %lf\n", resolver.configReloadInterval]; objc_autoreleasePoolPop(pool); } @end Index: tests/OFLocaleTests.m ================================================================== --- tests/OFLocaleTests.m +++ tests/OFLocaleTests.m @@ -24,20 +24,20 @@ { void *pool = objc_autoreleasePoolPush(); of_stdout.foregroundColor = [OFColor lime]; - [of_stdout writeFormat: @"[OFLocale]: Language: %@\n", + [of_stdout writeFormat: @"[OFLocale] Language: %@\n", [OFLocale language]]; - [of_stdout writeFormat: @"[OFLocale]: Territory: %@\n", + [of_stdout writeFormat: @"[OFLocale] Territory: %@\n", [OFLocale territory]]; - [of_stdout writeFormat: @"[OFLocale]: Encoding: %@\n", + [of_stdout writeFormat: @"[OFLocale] Encoding: %@\n", of_string_name_of_encoding([OFLocale encoding])]; - [of_stdout writeFormat: @"[OFLocale]: Decimal point: %@\n", + [of_stdout writeFormat: @"[OFLocale] Decimal point: %@\n", [OFLocale decimalPoint]]; objc_autoreleasePoolPop(pool); } @end Index: tests/OFSPXSocketTests.m ================================================================== --- tests/OFSPXSocketTests.m +++ tests/OFSPXSocketTests.m @@ -163,18 +163,32 @@ memcpy(delegate->_expectedNode, node, IPX_NODE_LEN); delegate->_expectedNetwork = network = of_socket_address_get_ipx_network(&address1); delegate->_expectedPort = port = of_socket_address_get_port(&address1); - [sockClient asyncConnectToNode: node - network: network - port: port]; - - [[OFRunLoop mainRunLoop] runUntilDate: - [OFDate dateWithTimeIntervalSinceNow: 2]]; - - TEST(@"-[asyncAccept] & -[asyncConnectToNode:network:port:]", - delegate->_accepted && delegate->_connected) + @try { + [sockClient asyncConnectToNode: node + network: network + port: port]; + + [[OFRunLoop mainRunLoop] runUntilDate: + [OFDate dateWithTimeIntervalSinceNow: 2]]; + + TEST(@"-[asyncAccept] & -[asyncConnectToNode:network:port:]", + delegate->_accepted && delegate->_connected) + } @catch (OFObserveFailedException *e) { + switch (e.errNo) { + case ENOTSOCK: + of_stdout.foregroundColor = [OFColor lime]; + [of_stdout writeLine: + @"[OFSPXSocket] -[asyncAccept] & " + @"-[asyncConnectToNode:network:port:]: select() " + @"not supported for SPX, skipping test"]; + break; + default: + @throw e; + } + } objc_autoreleasePoolPop(pool); } @end Index: tests/OFSPXStreamSocketTests.m ================================================================== --- tests/OFSPXStreamSocketTests.m +++ tests/OFSPXStreamSocketTests.m @@ -167,18 +167,32 @@ memcpy(delegate->_expectedNode, node, IPX_NODE_LEN); delegate->_expectedNetwork = network = of_socket_address_get_ipx_network(&address1); delegate->_expectedPort = port = of_socket_address_get_port(&address1); - [sockClient asyncConnectToNode: node - network: network - port: port]; - - [[OFRunLoop mainRunLoop] runUntilDate: - [OFDate dateWithTimeIntervalSinceNow: 2]]; - - TEST(@"-[asyncAccept] & -[asyncConnectToNode:network:port:]", - delegate->_accepted && delegate->_connected) + @try { + [sockClient asyncConnectToNode: node + network: network + port: port]; + + [[OFRunLoop mainRunLoop] runUntilDate: + [OFDate dateWithTimeIntervalSinceNow: 2]]; + + TEST(@"-[asyncAccept] & -[asyncConnectToNode:network:port:]", + delegate->_accepted && delegate->_connected) + } @catch (OFObserveFailedException *e) { + switch (e.errNo) { + case ENOTSOCK: + of_stdout.foregroundColor = [OFColor lime]; + [of_stdout writeLine: + @"[OFSPXStreamSocket] -[asyncAccept] & " + @"-[asyncConnectToNode:network:port:]: select() " + @"not supported for SPX, skipping test"]; + break; + default: + @throw e; + } + } objc_autoreleasePoolPop(pool); } @end Index: tests/plugin/Makefile ================================================================== --- tests/plugin/Makefile +++ tests/plugin/Makefile @@ -1,9 +1,11 @@ +DISTCLEAN = Info.plist + PLUGIN_NOINST = TestPlugin${PLUGIN_SUFFIX} SRCS = TestPlugin.m include ../../buildsys.mk include ../../extra.mk CPPFLAGS += -I../.. -I../../src -I../../src/runtime LIBS := ${TESTPLUGIN_LIBS} ${LIBS} LD = ${OBJC}