ObjFW  Check-in [c2af363418]

Overview
Comment:Check for atomic ops in configure.ac.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c2af363418c0d7cccee3b040ad3fc95b495ec2951c4cc03ff2779538d3a7e673
User & Date: js on 2010-01-25 22:14:46
Other Links: manifest | tags
Context
2010-01-25
22:34
clang does not reuse constant strings, thus fix test to use the same. check-in: 612a252fdf user: js tags: trunk
22:14
Check for atomic ops in configure.ac. check-in: c2af363418 user: js tags: trunk
15:22
Make retain counter 32 bit due to atomic ops being 32 bit. check-in: 831ebcd4f5 user: js tags: trunk
Changes

Modified configure.ac from [7d51f7e767] to [1f580f5aef].

169
170
171
172
173
174
175


























176

177
178











179
180
181
182
183
184
185
	AC_SUBST(THREADING_H, "threading.h")

	AC_CHECK_FUNC(objc_sync_enter,, [
		AC_SUBST(OBJC_SYNC_M, "objc_sync.m")
		AC_DEFINE(NEED_OBJC_SYNC_INIT, 1,
			[Whether objc_sync_init needs to be called])])



























	AC_CHECK_HEADER(libkern/OSAtomic.h, [

		AC_DEFINE(OF_HAVE_LIBKERN_OSATOMIC_H, 1,
			[Whether we have libkern/OSAtomic.h])])











fi

AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32")

AC_MSG_CHECKING(for getaddrinfo)
AC_TRY_COMPILE([







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
|
>
>
>
>
>
>
>
>
>
>
>







169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
	AC_SUBST(THREADING_H, "threading.h")

	AC_CHECK_FUNC(objc_sync_enter,, [
		AC_SUBST(OBJC_SYNC_M, "objc_sync.m")
		AC_DEFINE(NEED_OBJC_SYNC_INIT, 1,
			[Whether objc_sync_init needs to be called])])

	AC_TRY_LINK([#include <stdint.h>], [
		int32_t i, j;
		if (__sync_add_and_fetch(&i, 1))
			j = __sync_sub_and_fetch(&i, 1);
		while (!__sync_bool_compare_and_swap(&i, 0, 1));
		], [
		have_gcc_atomic_ops="yes"
		AC_DEFINE(OF_HAVE_GCC_ATOMIC_OPS, 1,
			[Whether gcc atomic operations are available])
		], [
		old_OBJCFLAGS="$OBJCFLAGS"
		OBJCFLAGS="$OBJCFLAGS -march=i486"
		AC_TRY_LINK([#include <stdint.h>], [
			int32_t i, j;
			if (__sync_add_and_fetch(&i, 1))
				j = __sync_sub_and_fetch(&i, 1);
			while (!__sync_bool_compare_and_swap(&i, 0, 1));
			], [
			have_gcc_atomic_ops="yes"
			AC_DEFINE(OF_HAVE_GCC_ATOMIC_OPS, 1,
				[Whether gcc atomic operations are available])
			], [
			have_gcc_atomic_ops="no"
			OBJCFLAGS="$old_OBJCFLAGS"])])

	if test x"$have_gcc_atomic_ops" != x"yes"; then
		AC_CHECK_HEADER(libkern/OSAtomic.h, [
			have_libkern_osatomic_h="yes"
			AC_DEFINE(OF_HAVE_LIBKERN_OSATOMIC_H, 1,
				[Whether we have libkern/OSAtomic.h])])
	fi

	AC_MSG_CHECKING(for atomic operations)
	if test x"$have_gcc_atomic_ops" = x"yes"; then
		AC_MSG_RESULT(gcc builtins)
	elif test x"$have_libkern_osatomic_h" = x"yes"; then
		AC_MSG_RESULT(libkern/OSAtomic.h)
	else
		AC_MSG_RESULT(none)
		AC_MSG_ERROR(No atomic operations found! Try --disable-threads.)
	fi
fi

AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32")

AC_MSG_CHECKING(for getaddrinfo)
AC_TRY_COMPILE([

Modified src/atomic.h from [34bfd081ab] to [10a1c95236].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 */

#import "objfw-defs.h"

#if !defined(OF_THREADS)
# define of_atomic_inc32(p) ++(*p)
# define of_atomic_dec32(p) --(*p)
#elif __GNUC_MINOR__ >= 1
# define of_atomic_inc32(p) __sync_add_and_fetch(p, 1)
# define of_atomic_dec32(p) __sync_sub_and_fetch(p, 1)
#elif OF_HAVE_LIBKERN_OSATOMIC_H
# include <libkern/OSAtomic.h>
# define of_atomic_inc32(p) OSAtomicIncrement32Barrier((int32_t*)(p))
# define of_atomic_dec32(p) OSAtomicDecrement32Barrier((int32_t*)(p))
#else
# error No atomic operations available!
#endif







|


|






10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 */

#import "objfw-defs.h"

#if !defined(OF_THREADS)
# define of_atomic_inc32(p) ++(*p)
# define of_atomic_dec32(p) --(*p)
#elif defined(OF_HAVE_GCC_ATOMIC_OPS)
# define of_atomic_inc32(p) __sync_add_and_fetch(p, 1)
# define of_atomic_dec32(p) __sync_sub_and_fetch(p, 1)
#elif defined(OF_HAVE_LIBKERN_OSATOMIC_H)
# include <libkern/OSAtomic.h>
# define of_atomic_inc32(p) OSAtomicIncrement32Barrier((int32_t*)(p))
# define of_atomic_dec32(p) OSAtomicDecrement32Barrier((int32_t*)(p))
#else
# error No atomic operations available!
#endif

Modified src/objfw-defs.h.in from [a4810732ab] to [77d9244302].

1
2
3
4

5
6
7
8
#undef OF_APPLE_RUNTIME
#undef OF_BIG_ENDIAN
#undef OF_GNU_RUNTIME
#undef OF_HAVE_ASPRINTF

#undef OF_HAVE_LIBKERN_OSATOMIC_H
#undef OF_PLUGINS
#undef OF_THREADS
#undef SIZE_MAX




>




1
2
3
4
5
6
7
8
9
#undef OF_APPLE_RUNTIME
#undef OF_BIG_ENDIAN
#undef OF_GNU_RUNTIME
#undef OF_HAVE_ASPRINTF
#undef OF_HAVE_GCC_ATOMIC_OPS
#undef OF_HAVE_LIBKERN_OSATOMIC_H
#undef OF_PLUGINS
#undef OF_THREADS
#undef SIZE_MAX