ObjFW  Diff

Differences From Artifact [2dac0a970f]:

To Artifact [899b5f2c89]:


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
224
225

226
227
228
229

230
231

232
233
234
235
236
237
238
	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_DEFINE(OF_ATOMIC_OPS, 1, [Whether we have atomic operations])
		AC_MSG_RESULT(gcc builtins)
	elif test x"$have_libkern_osatomic_h" = x"yes"; then
		AC_DEFINE(OF_ATOMIC_OPS, 1, [Whether we have atomic operations])
		AC_MSG_RESULT(libkern/OSAtomic.h)
	else

		AC_MSG_RESULT(none)
	fi
else
	dnl We can only have one thread - therefore everything is atomic

	AC_DEFINE(OF_ATOMIC_OPS, 1, [Whether we have atomic operations])
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([
	#include <stddef.h>







>
>
>






>
|











>
|



|


|

|



<
<
<
<
<
<
<
<
|
>
|
|
|
|
>


>







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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
	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])])

	atomic_ops="none"

	AC_MSG_CHECKING(whether __sync_* works)
	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));
		], [
		AC_MSG_RESULT(yes)
		atomic_ops="gcc builtins"
		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));
			], [
			AC_MSG_RESULT(yes, with -march=i486)
			atomic_ops="gcc builtins (with -march=i486)"
			AC_DEFINE(OF_HAVE_GCC_ATOMIC_OPS, 1,
				[Whether gcc atomic operations are available])
			], [
			AC_MSG_RESULT(no)
			OBJCFLAGS="$old_OBJCFLAGS"])])

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








else
	dnl We can only have one thread - therefore everything is atomic
	atomic_ops="not needed"
fi

AC_MSG_CHECKING(for atomic operations)
if test x"$atomic_ops" != x"none"; then
	AC_DEFINE(OF_ATOMIC_OPS, 1, [Whether we have atomic operations])
fi
AC_MSG_RESULT($atomic_ops)

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([
	#include <stddef.h>