我正在尝试在Solaris 10上构建Mono,并遇到了一个错误,错误消息为“ Posix系统缺少对递归互斥的支持”。我正在尝试使用gcc 3.4.3构建它,并且已经安装了gmake,gar,granlib和gstrip来替换其Solaris替代品。我找到了可能的解决方案,但是找不到位于以下行的博客:“ 1)patch /usr/lib/pkgconfig/gthread-2.0.pc替换-{mt选项(请参阅Jonel的博客)”,位于{{ 3}}。该博客不再有效。有谁知道他们指的是什么补丁?预先感谢。
答案 0 :(得分:1)
Solaris 10确实支持递归互斥锁。
每the Solaris 10 pthread_mutexattr_settype
man page:
PTHREAD_MUTEX_RECURSIVE
试图重新锁定此互斥锁而不先对其进行解锁的线程 将成功锁定互斥锁。重新锁定的死锁可以 类型为
PTHREAD_MUTEX_NORMAL
的互斥体不会发生 这种互斥锁。此互斥锁的多个锁要求相同 在另一个线程可以释放之前释放互斥量的解锁次数 获取互斥量。试图解锁另一个互斥锁的线程 线程已锁定将返回错误。线程试图 解锁解锁的互斥锁将返回错误。这种互斥锁 仅支持进程共享属性为的互斥锁PTHREAD_PROCESS_PRIVATE
。
还根据手册页,所需的编译/链接选项以及正确的#include
语句:
cc –mt [ flag... ] file... –lpthread [ library... ]
#include <pthread.h>
请注意添加了-lpthread
。我怀疑您指的博客是用-mt
取代了-mt -lpthread
。
答案 1 :(得分:0)
(对此问题进行了更多的研究,由Unix问题How to install .net Mono on Solaris 11 (source code compile)?促成了this answer,在此我要重复。)
您将_XOPEN_SOURCE
设置为的确切值无关紧要。 Mono错误地定义了_XOPEN_SOURCE_EXTENDED
宏:
case "${host}" in
*solaris* )
AC_MSG_CHECKING(for Solaris XPG4 support)
if test -f /usr/lib/libxnet.so; then
CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600"
CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1" <-- WRONG
LIBS="$LIBS -lxnet"
the POSIX 6或the POSIX 7 standard中都不存在_XOPEN_SOURCE_EXTENDED
宏。
即使Linux同意_XOPEN_SOURCE_EXTENDED
也不应在此处定义。根据{{3}}:
_XOPEN_SOURCE_EXTENDED
如果定义了此宏,并且定义了
_XOPEN_SOURCE
,则公开与XPG4v2(SUSv1)UNIX扩展(UNIX 95)相对应的定义。用500或更大的值定义_XOPEN_SOURCE
也会产生与定义_XOPEN_SOURCE_EXTENDED
相同的效果。应该避免在新的源代码中使用_XOPEN_SOURCE_EXTENDED
。由于将
_XOPEN_SOURCE
的值定义为500或更多,与定义_XOPEN_SOURCE_EXTENDED
的作用相同,因此后者的(过时的)功能测试宏通常不在手册页的提要中进行描述。
请注意准确的措辞:
如果定义了该宏(_XOPEN_SOURCE_EXTENDED
,并且定义了_XOPEN_SOURCE
,则公开对应于XPG4v2(SUSv1)UNIX扩展(UNIX 95)的定义。 ...
将_XOPEN_SOURCE
定义为任何值,同时也定义_XOPEN_SOURCE_EXTENDED
会导致XPG4v2,而不需要则是获得递归互斥锁的XPG6。 / p>
您可能会遇到the Linux feature_test_macros
man page:
/*
* It is invalid to compile an XPG3, XPG4, XPG4v2, or XPG5 application
* using c99. The same is true for POSIX.1-1990, POSIX.2-1992, POSIX.1b,
* and POSIX.1c applications. Likewise, it is invalid to compile an XPG6
* or a POSIX.1-2001 application with anything other than a c99 or later
* compiler. Therefore, we force an error in both cases.
*/
#if defined(_STDC_C99) && (defined(__XOPEN_OR_POSIX) && !defined(_XPG6))
#error "Compiler or options invalid for pre-UNIX 03 X/Open applications \
and pre-2001 POSIX applications"
#elif !defined(_STDC_C99) && \
(defined(__XOPEN_OR_POSIX) && defined(_XPG6))
#error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \
require the use of c99"
#endif
_XPG6
被定义为this check in the Solaris 11 /usr/include/sys/feature_tests.h
:
/*
* Use of _XOPEN_SOURCE
*
* The following X/Open specifications are supported:
*
* X/Open Portability Guide, Issue 3 (XPG3)
* X/Open CAE Specification, Issue 4 (XPG4)
* X/Open CAE Specification, Issue 4, Version 2 (XPG4v2)
* X/Open CAE Specification, Issue 5 (XPG5)
* Open Group Technical Standard, Issue 6 (XPG6), also referred to as
* IEEE Std. 1003.1-2001 and ISO/IEC 9945:2002.
*
* XPG4v2 is also referred to as UNIX 95 (SUS or SUSv1).
* XPG5 is also referred to as UNIX 98 or the Single Unix Specification,
* Version 2 (SUSv2)
* XPG6 is the result of a merge of the X/Open and POSIX specifications
* and as such is also referred to as IEEE Std. 1003.1-2001 in
* addition to UNIX 03 and SUSv3.
*
* When writing a conforming X/Open application, as per the specification
* requirements, the appropriate feature test macros must be defined at
* compile time. These are as follows. For more info, see standards(5).
*
* Feature Test Macro Specification
* ------------------------------------------------ -------------
* _XOPEN_SOURCE XPG3
* _XOPEN_SOURCE && _XOPEN_VERSION = 4 XPG4
* _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1 XPG4v2
* _XOPEN_SOURCE = 500 XPG5
* _XOPEN_SOURCE = 600 (or POSIX_C_SOURCE=200112L) XPG6
*
* In order to simplify the guards within the headers, the following
* implementation private test macros have been created. Applications
* must NOT use these private test macros as unexpected results will
* occur.
*
* Note that in general, the use of these private macros is cumulative.
* For example, the use of _XPG3 with no other restrictions on the X/Open
* namespace will make the symbols visible for XPG3 through XPG6
* compilation environments. The use of _XPG4_2 with no other X/Open
* namespace restrictions indicates that the symbols were introduced in
* XPG4v2 and are therefore visible for XPG4v2 through XPG6 compilation
* environments, but not for XPG3 or XPG4 compilation environments.
*
* _XPG3 X/Open Portability Guide, Issue 3 (XPG3)
* _XPG4 X/Open CAE Specification, Issue 4 (XPG4)
* _XPG4_2 X/Open CAE Specification, Issue 4, Version 2 (XPG4v2/UNIX 95/SUS)
* _XPG5 X/Open CAE Specification, Issue 5 (XPG5/UNIX 98/SUSv2)
* _XPG6 Open Group Technical Standard, Issue 6 (XPG6/UNIX 03/SUSv3)
*/
/* X/Open Portability Guide, Issue 3 */
#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 < 500) && \
(_XOPEN_VERSION - 0 < 4) && !defined(_XOPEN_SOURCE_EXTENDED)
#define _XPG3
/* X/Open CAE Specification, Issue 4 */
#elif (defined(_XOPEN_SOURCE) && _XOPEN_VERSION - 0 == 4)
#define _XPG4
#define _XPG3
/* X/Open CAE Specification, Issue 4, Version 2 */
#elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1)
#define _XPG4_2
#define _XPG4
#define _XPG3
/* X/Open CAE Specification, Issue 5 */
#elif (_XOPEN_SOURCE - 0 == 500)
#define _XPG5
#define _XPG4_2
#define _XPG4
#define _XPG3
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199506L
/* Open Group Technical Standard , Issue 6 */
#elif (_XOPEN_SOURCE - 0 == 600) || (_POSIX_C_SOURCE - 0 == 200112L)
#define _XPG6
#define _XPG5
#define _XPG4_2
#define _XPG4
#define _XPG3
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif