ObjFW  Check-in [839745fa85]

Overview
Comment:configure: Check for pthread_attr_getschedpolicy()
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 839745fa85cc854499784f2da77b39eaa2b2e2fc1ceaad7395e53e54d427ecea
User & Date: js on 2018-06-17 18:23:51
Other Links: manifest | tags
Context
2018-06-17
18:41
ofarc: LHAArchive: Fix type mismatch check-in: b508aa2625 user: js tags: trunk
18:23
configure: Check for pthread_attr_getschedpolicy() check-in: 839745fa85 user: js tags: trunk
17:51
configure: Prefix Clang-only flags with -Xclang check-in: 670184b60b user: js tags: trunk
Changes

Modified configure.ac from [e02fcf3101] to [934377061f].

899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
	mingw*)
		AC_MSG_RESULT(WinAPI)
		;;
	*)
		AC_MSG_RESULT(POSIX)

		dnl Use -Wp, as we only use it for the preprocessor.
		AX_CHECK_COMPILER_FLAGS(-Wp,-pthread, [
			CPPFLAGS="$CPPFLAGS -Wp,-pthread"
		], [
			CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE"
		])

		AC_CHECK_LIB(pthread, pthread_create, LIBS="$LIBS -lpthread")








|







899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
	mingw*)
		AC_MSG_RESULT(WinAPI)
		;;
	*)
		AC_MSG_RESULT(POSIX)

		dnl Use -Wp, as we only use it for the preprocessor.
		AX_CHECK_COMPILER_FLAGS([-Wp,-pthread], [
			CPPFLAGS="$CPPFLAGS -Wp,-pthread"
		], [
			CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE"
		])

		AC_CHECK_LIB(pthread, pthread_create, LIBS="$LIBS -lpthread")

939
940
941
942
943
944
945

946
947
948
949
950
951
952
		])

		AC_CHECK_FUNC(sched_yield, [
			AC_DEFINE(OF_HAVE_SCHED_YIELD, 1,
				[Whether we have sched_yield()])
		])


		AC_CHECK_FUNCS(pthread_attr_setinheritsched)

		AC_CHECK_HEADERS(pthread_np.h, [], [], [#include <pthread.h>])
		AC_CHECK_FUNCS(pthread_set_name_np pthread_setname_np, break)
		;;
	esac








>







939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
		])

		AC_CHECK_FUNC(sched_yield, [
			AC_DEFINE(OF_HAVE_SCHED_YIELD, 1,
				[Whether we have sched_yield()])
		])

		AC_CHECK_FUNCS(pthread_attr_getschedpolicy)
		AC_CHECK_FUNCS(pthread_attr_setinheritsched)

		AC_CHECK_HEADERS(pthread_np.h, [], [], [#include <pthread.h>])
		AC_CHECK_FUNCS(pthread_set_name_np pthread_setname_np, break)
		;;
	esac

Modified src/threading_pthread.m from [181110ec16] to [5bca66cb41].

37
38
39
40
41
42
43

44

45
46
47

48
49
50

51
52
53
54
55
56
57
/*
 * This is done here to make sure this is done as early as possible in the main
 * thread.
 */
OF_CONSTRUCTOR()
{
	pthread_attr_t pattr;

	int policy;

	struct sched_param param;

	OF_ENSURE(pthread_attr_init(&pattr) == 0);

	OF_ENSURE(pthread_attr_getschedpolicy(&pattr, &policy) == 0);
	OF_ENSURE((minPrio = sched_get_priority_min(policy)) != -1);
	OF_ENSURE((maxPrio = sched_get_priority_max(policy)) != -1);

	OF_ENSURE(pthread_attr_getschedparam(&pattr, &param) == 0);

	normalPrio = param.sched_priority;

	pthread_attr_destroy(&pattr);
}








>

>



>



>







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * This is done here to make sure this is done as early as possible in the main
 * thread.
 */
OF_CONSTRUCTOR()
{
	pthread_attr_t pattr;
#ifdef HAVE_PTHREAD_ATTR_GETSCHEDPOLICY
	int policy;
#endif
	struct sched_param param;

	OF_ENSURE(pthread_attr_init(&pattr) == 0);
#ifdef HAVE_PTHREAD_ATTR_GETSCHEDPOLICY
	OF_ENSURE(pthread_attr_getschedpolicy(&pattr, &policy) == 0);
	OF_ENSURE((minPrio = sched_get_priority_min(policy)) != -1);
	OF_ENSURE((maxPrio = sched_get_priority_max(policy)) != -1);
#endif
	OF_ENSURE(pthread_attr_getschedparam(&pattr, &param) == 0);

	normalPrio = param.sched_priority;

	pthread_attr_destroy(&pattr);
}