ObjFW  Check-in [42ed7e394c]

Overview
Comment:OFException: Cleaner way to check architecture.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 42ed7e394c9ba29f99c96557d66a4888d9d6c08902182755325eae6f09eeb012
User & Date: js on 2013-06-03 21:38:31
Other Links: manifest | tags
Context
2013-06-11
22:55
Use _Unwind_Backtrace() to get a backtrace. check-in: 259f593244 user: js tags: trunk
2013-06-03
21:38
OFException: Cleaner way to check architecture. check-in: 42ed7e394c user: js tags: trunk
15:20
atomic.h: Fix several issues. check-in: 6b15bb229e user: js tags: trunk
Changes

Modified configure.ac from [fe25322d35] to [c5958dcc8b].

748
749
750
751
752
753
754
755
756






757
758
759
760
761
762
763
esac
AS_IF([test x"$have_processes" = x"yes"], [
	AC_SUBST(OFPROCESS_M, "OFProcess.m")
	AC_DEFINE(OF_HAVE_PROCESSES, 1, [Whether we have processes])
])

AC_DEFUN([CHECK_BUILTIN_RETURN_ADDRESS], [
	AC_MSG_CHECKING(for __builtin_return_address)
	AC_TRY_LINK([], [






		__builtin_return_address(1);
	], [
		AC_MSG_RESULT(yes)
		AC_DEFINE(HAVE_BUILTIN_RETURN_ADDRESS, 1,
			[Whether we have __builtin_return_address])
	], [
		AC_MSG_RESULT(no)







|
|
>
>
>
>
>
>







748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
esac
AS_IF([test x"$have_processes" = x"yes"], [
	AC_SUBST(OFPROCESS_M, "OFProcess.m")
	AC_DEFINE(OF_HAVE_PROCESSES, 1, [Whether we have processes])
])

AC_DEFUN([CHECK_BUILTIN_RETURN_ADDRESS], [
	AC_MSG_CHECKING(for working __builtin_return_address)
	AC_TRY_LINK([
		#if defined(__ppc__) || defined(__PPC__)
		/* __builtin_return_address() is known to work correctly */
		#else
		# error
		#endif
	], [
		__builtin_return_address(1);
	], [
		AC_MSG_RESULT(yes)
		AC_DEFINE(HAVE_BUILTIN_RETURN_ADDRESS, 1,
			[Whether we have __builtin_return_address])
	], [
		AC_MSG_RESULT(no)

Modified src/exceptions/OFException.m from [fbd2e39b2b] to [d08e1839ba].

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
- initWithClass: (Class)class
{
	self = [super init];

	_inClass = class;
#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE)
	_backtraceSize = backtrace(_backtrace, 32);
#elif defined(HAVE_BUILTIN_RETURN_ADDRESS) && defined(__ppc__)
	/*
	 * We can't use a loop here, as __builtin_return_address() and
	 * __builtin_frame_address() only allow a constant as parameter.
	 */
# define GET_FRAME(i)							\
	if (__builtin_frame_address(i + 1) == NULL)			\
		goto backtrace_done;					\







|







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
- initWithClass: (Class)class
{
	self = [super init];

	_inClass = class;
#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE)
	_backtraceSize = backtrace(_backtrace, 32);
#elif defined(HAVE_BUILTIN_RETURN_ADDRESS)
	/*
	 * We can't use a loop here, as __builtin_return_address() and
	 * __builtin_frame_address() only allow a constant as parameter.
	 */
# define GET_FRAME(i)							\
	if (__builtin_frame_address(i + 1) == NULL)			\
		goto backtrace_done;					\
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
	}

	objc_autoreleasePoolPop(pool);

	[backtrace makeImmutable];

	return backtrace;
#elif defined(HAVE_BUILTIN_RETURN_ADDRESS) && defined(__ppc__)
	OFMutableArray *backtrace = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();
	uint_fast8_t i;

	for (i = 0; i < 32 && _backtrace[i] != NULL; i++) {
		void *addr =
		    __builtin_extract_return_addr(_backtrace[i]);







|







142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
	}

	objc_autoreleasePoolPop(pool);

	[backtrace makeImmutable];

	return backtrace;
#elif defined(HAVE_BUILTIN_RETURN_ADDRESS)
	OFMutableArray *backtrace = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();
	uint_fast8_t i;

	for (i = 0; i < 32 && _backtrace[i] != NULL; i++) {
		void *addr =
		    __builtin_extract_return_addr(_backtrace[i]);