macos - 在 macOS 上调用 pthread_cond_destroy 导致“功能未实现”ENOSYS
问题描述
我正在尝试让一些基于 Linux 的代码在 macOS 上运行。它是 NASA 核心飞行系统的 POSIX OSAL 层,如下所示:https ://github.com/nasa/osal 。
我观察到代码使用 POSIX 条件,特别是有如下调用:
if (pthread_cond_destroy(&(sem->cv)) != 0) {
printf("pthread_cond_destroy %d %s\n", errno, strerror(errno)); // my addition
...
}
在 macOS 上,与 OSAL 存储库中提供的此代码相关的测试总是失败,因为调用pthread_cond_destroy
always 会导致:
pthread_cond_destroy 78 Function not implemented
我在 Apple 文档中找到了一个示例,该示例显示了使用条件(线程编程指南/同步/使用条件)的示例,在该示例中没有调用,pthread_cond_destroy
但我无法就该调用是否应该存在做出任何结论因为这个例子被简化了。
这是标题在我的机器上的样子:
__API_AVAILABLE(macos(10.4), ios(2.0))
int pthread_cond_destroy(pthread_cond_t *);
我想知道pthread_cond_*
macOS 上是否缺少功能,我必须对其进行替换,或者有某种方法可以使其工作。
编辑:最小的例子对我来说很好。问题应该在有问题的代码附近。我仍然不明白为什么我会收到 ENOSYS/78 错误代码,一方面它在手册页man/3/pthread_cond_destroy上没有提到:
#include <iostream>
#include <pthread.h>
int main() {
pthread_cond_t condition;
pthread_cond_init(&condition, NULL);
int result = pthread_cond_destroy(&condition);
assert(result == 0);
assert(errno == 0);
std::cout << "Hello, World!" << std::endl;
return 0;
}
解决方案
推荐阅读
- r - 当 Rselenium 返回错误“NoSuchElement”时继续循环搜索
- javascript - 更改画布Javascript中div的背景颜色
- java - Spring @Service 的“无结果异常”
- python - TypeError:预期的字符串或类似字节的对象python
- typescript - TS - class method is undefined in callback
- ruby-on-rails - Devise issue with LDAP Auth in Prod Only
- python - 如何删除为菜单打开单独窗口的选项?
- javascript - 了解 Vue 中的 panzoom
- java - In Hibernate/JPA how to tell if the ConstraintViolationException is a PK, a FK, or a unique key violation?
- java - 如何在 Firebase 数据库 Android 的子列表中搜索?