summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@heap.zone>2018-04-22 19:48:40 +0200
committerJonathan Schleifer <js@heap.zone>2018-04-22 19:48:40 +0200
commitf74b22dda103ac370289b262a9d0a83b5cd48ee6 (patch)
tree1baec4df15780e9059332003636982a2c1a11a07
parentbd945d82640c9aa84f66931a87609a2eab3750cb (diff)
Make ObjFW compile for AmigaOS 3
-rw-r--r--configure.ac68
-rw-r--r--src/OFApplication.m11
-rw-r--r--src/OFDate.m1
-rw-r--r--src/OFLocalization.m3
-rw-r--r--src/OFNumber.m1
-rw-r--r--src/OFObject.m2
-rw-r--r--src/OFString.h3
-rw-r--r--src/OFString.m5
-rw-r--r--src/OFTarArchiveEntry.m5
-rw-r--r--src/OFThread.m3
-rw-r--r--src/OFZIPArchiveEntry.m4
-rw-r--r--src/exceptions/OFBindFailedException.m2
-rw-r--r--src/exceptions/OFConnectionFailedException.m2
-rw-r--r--src/objfw-defs.h.in28
-rw-r--r--src/platform.h3
-rw-r--r--src/resolver.m4
-rw-r--r--src/runtime/ObjFW_RT.h2
-rw-r--r--src/runtime/private.h4
-rw-r--r--tests/ForwardingTests.m2
-rw-r--r--utils/ofzip/TarArchive.m3
-rw-r--r--utils/ofzip/ZIPArchive.m2
21 files changed, 134 insertions, 24 deletions
diff --git a/configure.ac b/configure.ac
index 72a8e753..d98a37c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,6 +24,58 @@ dnl Used to disable checking for -pedantic on some platforms where it's broken
check_pedantic="yes"
case "$host" in
+ m68k-*-amigaos*)
+ OBJCFLAGS="$OBJCFLAGS -noixemul"
+ LDFLAGS="$LDFLAGS -noixemul"
+
+ enable_shared="no"
+ enable_threads="no"
+ enable_sockets="no"
+ enable_files="yes" # Required for reading ENV:
+ ac_cv_snprintf_useful_ret="yes"
+
+ AC_DEFINE(ULLONG_MAX, 0xFFFFFFFFFFFFFFFFULL,
+ [Maximum value for unsigned long long])
+ AC_DEFINE(LLONG_MAX, 0x7FFFFFFFFFFFFFFFLL,
+ [Maximum value for long long])
+ AC_DEFINE(LLONG_MIN, [(-0x7FFFFFFFFFFFFFFFLL - 1)],
+ [Minimum value for long long])
+
+ AC_DEFINE(PRId8, "hhd", [Format string for 8-bit as decimal])
+ AC_DEFINE(PRId16, "hd", [Format string for 16-bit as decimal])
+ AC_DEFINE(PRId32, "d", [Format string for 32-bit as decimal])
+ AC_DEFINE(PRId64, "lld", [Format string for 64-bit as decimal])
+ AC_DEFINE(PRIi8, "hhi", [Format string for 8-bit as integer])
+ AC_DEFINE(PRIi16, "hi", [Format string for 16-bit as integer])
+ AC_DEFINE(PRIi32, "i", [Format string for 32-bit as integer])
+ AC_DEFINE(PRIi64, "lli", [Format string for 64-bit as integer])
+ AC_DEFINE(PRIo8, "hho", [Format string for 8-bit as octal])
+ AC_DEFINE(PRIo16, "ho", [Format string for 16-bit as octal])
+ AC_DEFINE(PRIo32, "o", [Format string for 32-bit as octal])
+ AC_DEFINE(PRIo64, "llo", [Format string for 64-bit as octal])
+ AC_DEFINE(PRIu8, "hhu", [Format string for 8-bit as unsigned])
+ AC_DEFINE(PRIu16, "hu", [Format string for 16-bit as unsigned])
+ AC_DEFINE(PRIu32, "u", [Format string for 32-bit as unsigned])
+ AC_DEFINE(PRIu64, "llu", [Format string for 64-bit as unsigned])
+ AC_DEFINE(PRIx8, "hhx",
+ [Format string for 8-bit as lowercase hex])
+ AC_DEFINE(PRIx16, "hx",
+ [Format string for 16-bit as lowercase hex])
+ AC_DEFINE(PRIx32, "x",
+ [Format string for 32-bit as lowercase hex])
+ AC_DEFINE(PRIx64, "llx",
+ [Format string for 64-bit as lowercase hex])
+ AC_DEFINE(PRIX8, "hhX",
+ [Format string for 8-bit as uppercase hex])
+ AC_DEFINE(PRIX16, "hX",
+ [Format string for 16-bit as uppercase hex])
+ AC_DEFINE(PRIX32, "X",
+ [Format string for 32-bit as uppercase hex])
+ AC_DEFINE(PRIX64, "llX",
+ [Format string for 64-bit as uppercase hex])
+
+ AC_SUBST(NOIXEMUL, -noixemul)
+ ;;
powerpc-*-amigaos*)
enable_shared="no"
enable_threads="no"
@@ -212,6 +264,14 @@ AX_CHECK_COMPILER_FLAGS([-Wobjc-missing-property-synthesis -Werror],
AX_CHECK_COMPILER_FLAGS([-Wmissing-method-return-type -Werror],
[OBJCFLAGS="$OBJCFLAGS -Wmissing-method-return-type"])
+case "$host" in
+ m68k-*-amigaos*)
+ dnl The inline headers generate code that triggers
+ dnl -Wpointer-sign.
+ OBJCFLAGS="$OBJCFLAGS -Wno-pointer-sign"
+ ;;
+esac
+
AC_MSG_CHECKING(whether Objective C compiler supports properties)
AC_TRY_COMPILE([
#ifdef __has_attribute
@@ -598,8 +658,11 @@ AC_EGREP_CPP(egrep_cpp_yes, [
AC_DEFINE(UINTPTR_MAX, [(~(uintptr_t)0)], [Maximum value for uintptr_t])
])
+AC_CHECK_HEADER(inttypes.h,
+ [AC_DEFINE(OF_HAVE_INTTYPES_H, 1, [Whether we have inttypes.h])])
+
AC_CHECK_HEADER(sys/types.h,
- [AC_DEFINE(OF_HAVE_SYS_TYPES_H, 1, [Whether we have <sys/types.h>])])
+ [AC_DEFINE(OF_HAVE_SYS_TYPES_H, 1, [Whether we have sys/types.h])])
AC_CHECK_TYPE(max_align_t,
[AC_DEFINE(OF_HAVE_MAX_ALIGN_T, 1, [Whether we have max_align_t])])
@@ -1304,11 +1367,10 @@ AC_DEFUN([CHECK_BUILTIN_BSWAP], [
AC_TRY_LINK([
#include <stdint.h>
#include <stdio.h>
- #include <inttypes.h>
#include <errno.h>
], [
uint$1_t i = errno;
- printf("%" PRIu$1, __builtin_bswap$1(i));
+ printf("%d", (int)__builtin_bswap$1(i));
], [
AC_MSG_RESULT(yes)
AC_DEFINE(OF_HAVE_BUILTIN_BSWAP$1, 1,
diff --git a/src/OFApplication.m b/src/OFApplication.m
index 0b951a1d..645ddfb0 100644
--- a/src/OFApplication.m
+++ b/src/OFApplication.m
@@ -36,7 +36,7 @@
#import "OFThread.h"
#import "OFThread+Private.h"
#import "OFSandbox.h"
-#ifdef OF_MORPHOS
+#ifdef OF_AMIGAOS
# import "OFFile.h"
# import "OFFileManager.h"
#endif
@@ -52,7 +52,10 @@
extern int _CRT_glob;
extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
-#elif defined(OF_MORPHOS)
+#elif defined(OF_AMIGAOS)
+# ifdef OF_AMIGAOS3
+# define INTUITION_CLASSES_H
+# endif
# include <proto/exec.h>
# include <proto/dos.h>
#elif !defined(OF_IOS)
@@ -179,6 +182,8 @@ of_application_main(int *argc, char **argv[],
{
#ifndef OF_PSP
exit(status);
+
+ OF_UNREACHABLE
#else
sceKernelExitGame();
@@ -249,7 +254,7 @@ of_application_main(int *argc, char **argv[],
}
FreeEnvironmentStringsW(env0);
-#elif defined(OF_MORPHOS)
+#elif defined(OF_AMIGAOS)
void *pool = objc_autoreleasePoolPush();
OFFileManager *fileManager = [OFFileManager defaultManager];
OFArray *envContents =
diff --git a/src/OFDate.m b/src/OFDate.m
index af364f95..ef271d97 100644
--- a/src/OFDate.m
+++ b/src/OFDate.m
@@ -17,7 +17,6 @@
#include "config.h"
-#include <inttypes.h>
#include <limits.h>
#include <time.h>
#include <math.h>
diff --git a/src/OFLocalization.m b/src/OFLocalization.m
index c4e28a58..7f493960 100644
--- a/src/OFLocalization.m
+++ b/src/OFLocalization.m
@@ -35,6 +35,9 @@
# define __NOGLOBALIFACE__
# define __USE_INLINE__
# endif
+# ifdef OF_AMIGAOS3
+# define INTUITION_CLASSES_H
+# endif
# include <proto/dos.h>
# include <proto/exec.h>
# include <proto/locale.h>
diff --git a/src/OFNumber.m b/src/OFNumber.m
index 30eed689..dd6ce45e 100644
--- a/src/OFNumber.m
+++ b/src/OFNumber.m
@@ -17,7 +17,6 @@
#include "config.h"
-#include <inttypes.h>
#include <math.h>
#import "OFNumber.h"
diff --git a/src/OFObject.m b/src/OFObject.m
index d27716dc..2533ed45 100644
--- a/src/OFObject.m
+++ b/src/OFObject.m
@@ -155,6 +155,8 @@ of_method_not_found(id obj, SEL sel)
* never return.
*/
abort();
+
+ OF_UNREACHABLE
}
void OF_NO_RETURN_FUNC
diff --git a/src/OFString.h b/src/OFString.h
index f7411d7f..c17877e3 100644
--- a/src/OFString.h
+++ b/src/OFString.h
@@ -30,6 +30,9 @@
#include <stdarg.h>
#include <stdint.h>
+#ifdef OF_HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
#import "OFObject.h"
#import "OFSerialization.h"
diff --git a/src/OFString.m b/src/OFString.m
index b79ee6a5..4ee8d5cc 100644
--- a/src/OFString.m
+++ b/src/OFString.m
@@ -69,6 +69,11 @@
# define strtod __strtod
#endif
+#ifdef OF_AMIGAOS3
+/* libnix has strtod, but not strtof */
+# define strtof strtod
+#endif
+
static struct {
Class isa;
} placeholder;
diff --git a/src/OFTarArchiveEntry.m b/src/OFTarArchiveEntry.m
index e17048e2..4b7c8738 100644
--- a/src/OFTarArchiveEntry.m
+++ b/src/OFTarArchiveEntry.m
@@ -17,12 +17,11 @@
#include "config.h"
-#include <inttypes.h>
-
#import "OFTarArchiveEntry.h"
#import "OFTarArchiveEntry+Private.h"
-#import "OFStream.h"
#import "OFDate.h"
+#import "OFStream.h"
+#import "OFString.h"
#import "OFOutOfRangeException.h"
diff --git a/src/OFThread.m b/src/OFThread.m
index 75c1a90a..aab7c04b 100644
--- a/src/OFThread.m
+++ b/src/OFThread.m
@@ -84,6 +84,9 @@
#ifdef OF_DJGPP
# define lrint(x) rint(x)
#endif
+#ifdef OF_AMIGAOS3
+# define lrint(x) ((long)x)
+#endif
#ifdef OF_HAVE_THREADS
# import "threading.h"
diff --git a/src/OFZIPArchiveEntry.m b/src/OFZIPArchiveEntry.m
index 1a42a0db..99aaaf22 100644
--- a/src/OFZIPArchiveEntry.m
+++ b/src/OFZIPArchiveEntry.m
@@ -17,14 +17,12 @@
#include "config.h"
-#include <inttypes.h>
-
#import "OFZIPArchiveEntry.h"
#import "OFZIPArchiveEntry+Private.h"
-#import "OFString.h"
#import "OFData.h"
#import "OFDate.h"
#import "OFStream.h"
+#import "OFString.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
diff --git a/src/exceptions/OFBindFailedException.m b/src/exceptions/OFBindFailedException.m
index 57cf5c6f..f0bf302b 100644
--- a/src/exceptions/OFBindFailedException.m
+++ b/src/exceptions/OFBindFailedException.m
@@ -17,8 +17,6 @@
#include "config.h"
-#include <inttypes.h>
-
#import "OFBindFailedException.h"
#import "OFString.h"
diff --git a/src/exceptions/OFConnectionFailedException.m b/src/exceptions/OFConnectionFailedException.m
index 411dfe75..7ad7e9de 100644
--- a/src/exceptions/OFConnectionFailedException.m
+++ b/src/exceptions/OFConnectionFailedException.m
@@ -17,8 +17,6 @@
#include "config.h"
-#include <inttypes.h>
-
#import "OFConnectionFailedException.h"
#import "OFString.h"
diff --git a/src/objfw-defs.h.in b/src/objfw-defs.h.in
index e03269de..ae101663 100644
--- a/src/objfw-defs.h.in
+++ b/src/objfw-defs.h.in
@@ -1,4 +1,6 @@
#undef INFINITY
+#undef LLONG_MAX
+#undef LLONG_MIN
#undef OF_APPLE_RUNTIME
#undef OF_BIG_ENDIAN
#undef OF_FLOAT_BIG_ENDIAN
@@ -12,6 +14,7 @@
#undef OF_HAVE_FILES
#undef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR
#undef OF_HAVE_IPV6
+#undef OF_HAVE_LIMITS_H
#undef OF_HAVE_LINK
#undef OF_HAVE_MAX_ALIGN_T
#undef OF_HAVE_NETINET_IN_H
@@ -38,5 +41,30 @@
#undef OF_NINTENDO_DS
#undef OF_OBJFW_RUNTIME
#undef OF_UNIVERSAL
+#undef PRId8
+#undef PRId16
+#undef PRId32
+#undef PRId64
+#undef PRIi8
+#undef PRIi16
+#undef PRIi32
+#undef PRIi64
+#undef PRIo8
+#undef PRIo16
+#undef PRIo32
+#undef PRIo64
+#undef PRIu8
+#undef PRIu16
+#undef PRIu32
+#undef PRIu64
+#undef PRIx8
+#undef PRIx16
+#undef PRIx32
+#undef PRIx64
+#undef PRIX8
+#undef PRIX16
+#undef PRIX32
+#undef PRIX64
#undef SIZE_MAX
#undef UINTPTR_MAX
+#undef ULLONG_MAX
diff --git a/src/platform.h b/src/platform.h
index 24c45bc1..10df3e54 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -109,6 +109,9 @@
#elif defined(__amigaos4__)
# define OF_AMIGAOS4
# define OF_AMIGAOS
+#elif defined(__amigaos__)
+# define OF_AMIGAOS3
+# define OF_AMIGAOS
#elif defined(__sun__)
# define OF_SOLARIS
#elif defined(__QNX__)
diff --git a/src/resolver.m b/src/resolver.m
index 9674b692..ab41e62f 100644
--- a/src/resolver.m
+++ b/src/resolver.m
@@ -22,10 +22,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <inttypes.h>
-#import "resolver.h"
+#import "OFString.h"
+#import "resolver.h"
#import "macros.h"
#if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(OF_HAVE_THREADS)
diff --git a/src/runtime/ObjFW_RT.h b/src/runtime/ObjFW_RT.h
index ad5fc57d..0aaa605a 100644
--- a/src/runtime/ObjFW_RT.h
+++ b/src/runtime/ObjFW_RT.h
@@ -29,6 +29,8 @@
#include <stddef.h>
#include <stdint.h>
+#import "platform.h"
+
#ifndef __has_feature
# define __has_feature(x) 0
#endif
diff --git a/src/runtime/private.h b/src/runtime/private.h
index 457dee72..50c013a4 100644
--- a/src/runtime/private.h
+++ b/src/runtime/private.h
@@ -17,7 +17,8 @@
#include "config.h"
-#include "platform.h"
+#import "macros.h"
+#import "platform.h"
#if !defined(__has_feature) || !__has_feature(nullability)
# ifndef _Nonnull
@@ -224,4 +225,5 @@ objc_dtable_get(const struct objc_dtable *_Nonnull dtable, uint32_t idx)
fprintf(stderr, __VA_ARGS__); \
fputs("\n", stderr); \
abort(); \
+ OF_UNREACHABLE \
}
diff --git a/tests/ForwardingTests.m b/tests/ForwardingTests.m
index f2cd0bee..156c1a0c 100644
--- a/tests/ForwardingTests.m
+++ b/tests/ForwardingTests.m
@@ -123,6 +123,8 @@ test(id self, SEL _cmd)
return self;
abort();
+
+ OF_UNREACHABLE
}
@end
diff --git a/utils/ofzip/TarArchive.m b/utils/ofzip/TarArchive.m
index 800db503..f3d8b11c 100644
--- a/utils/ofzip/TarArchive.m
+++ b/utils/ofzip/TarArchive.m
@@ -17,8 +17,6 @@
#include "config.h"
-#include <inttypes.h>
-
#import "OFApplication.h"
#import "OFDate.h"
#import "OFFileManager.h"
@@ -26,6 +24,7 @@
#import "OFNumber.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
+#import "OFString.h"
#import "TarArchive.h"
#import "OFZIP.h"
diff --git a/utils/ofzip/ZIPArchive.m b/utils/ofzip/ZIPArchive.m
index a9d37b07..4811a88f 100644
--- a/utils/ofzip/ZIPArchive.m
+++ b/utils/ofzip/ZIPArchive.m
@@ -17,7 +17,6 @@
#include "config.h"
-#include <inttypes.h>
#include <errno.h>
#import "OFApplication.h"
@@ -27,6 +26,7 @@
#import "OFNumber.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
+#import "OFString.h"
#import "ZIPArchive.h"
#import "OFZIP.h"