`

CTDP linux 程序员手册 C和C++编程(4)Linux POSIX 系统的兼容型

阅读更多


<!-- google_ad_client = "pub-2416224910262877"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_channel = ""; google_color_border = "E1771E"; google_color_bg = "FFFFFF"; google_color_link = "0000FF"; google_color_text = "000000"; google_color_url = "008000"; // -->

这一章将介绍如何去确定您的系统都支持POSIX的哪些部分。最容易的办法是察看系统中的文件/usr/include/unistd.h 。这个文件将定义_POSIX_SOURCE 版本。它也可能包括其他的POSIX 定义头文件。其中的一个是/usr/include/bits/posix_opt.h ,里边应该由更多的POSIX定义。下面的所有参数都列在那里。当然,最好的方法是使用下面的程序。因为在你得系统中可能没有/usr/include/inistd.h 文件。同时你也会关心你的系统不支持哪些功能。它将依赖与编译它的库和编译时使用的选项。内核对于支持POSIX.4的功能将有较大的影响,因为它控制内存的分配和处理,包括它们之间的信号。

测试程序

下面的程序将输出你得系统都支持哪些特性。我称它为 "posixtst.c". 这是一个 tar 和 gz 源代码和二进制程序版本,并且带有一个README 文件和安装命令。 posixtst-1.0.0

#define _POSIX_SOURCE
#define _POSIX_C_SOURCE 199309
#include <unistd.h>
long val;
int errno;
main()
{
#ifndef _POSIX_VERSION
 printf("No support for POSIX on this system!\n");
#else //see what POSIX version
 printf("POSIX_VERSION = %d.\n",_POSIX_VERSION);
 printf("POSIX2_VERSION = %d.\n",_POSIX2_VERSION);
 printf("POSIX2_C_VERSION = %d.\n",_POSIX2_C_VERSION);
 #if _POSIX_VERSION == 199009
 printf("This system supports POSIX.1 without support for POSIX.4.\n");
 #else
 #if _POSIX_VERSION >= 199309
 printf ("This system supports POSIX.1 and POSIX.4. \n");
 #else
 printf("This system supports a strange POSIX version between 199009 and 199309.\n");
 #endif
 //DO POSIX.4 tests
 printf ("POSIX.4 Options Test Results:\n");
 #ifdef _POSIX_REALTIME_SIGNALS
 printf(" POSIX.4 Additional real time signals are supported.\n");
 #ifdef _POSIX_RTSIG_MAX
 printf(" _POSIX_RTSIG_MAX=%d Max real time signals.\n",_POSIX_RTSIG_MAX);
 #else
 printf(" No _POSIX_RTSIG_MAX value exists.\n");
 #endif
 #ifdef _POSIX_SIGQUEUE_MAX
 printf(" _POSIX_SIGQUEUE_MAX=%d Max real time signals at once per process.\n",_POSIX_RTQUEUE_MAX);
 #else
 printf(" No _POSIX_SIGQUEUE_MAX value exists.\n");
 #endif
 #else
 printf(" POSIX.4 Additional real time signals are not supported.\n");
 #endif
 #ifdef _POSIX_PRIORITY_SCHEDULING
 printf(" POSIX.4 Priority scheduling is supported.\n");
 #else
 printf(" POSIX.4 Priority scheduling is not supported.\n");
 #endif
 #ifdef _POSIX_TIMERS
 printf(" POSIX.4 Clocks and timers are supported.\n");
 #ifdef _POSIX_TIMER_MAX
 printf(" _POSIX_TIMER_MAX=%d Max number of concurrent timers a process can have.\n",_POSIX_TIMER_MAX);
 #else
 printf(" No _POSIX_TIMER_MAX value exists.\n");
 #endif
 #ifdef _POSIX_DELAYTIMER_MAX
 printf(" _POSIX_DELAYTIMER_MAX=%d Max number of times a timer can have a detectable overrun.\n",_POSIX_DELAYTIMER_MAX);
 #else
 printf(" No _POSIX_DELAYTIMER_MAX value exists.\n");
 #endif
 #else
 printf(" POSIX.4 Clocks and timers are not supported.\n");
 #endif
 #ifdef _POSIX_ASYNCHRONOUS_IO
 printf(" POSIX.4 Asynchronous I/O is supported.\n");
 #ifdef _POSIX_AIO_LISTIO_MAX
 printf(" _POSIX_AIO_LISTIO_MAX=%d Max operations in one call\n",_POSIX_AIO_LISTIO_MAX);
 #else
 printf(" No _POSIX_AIO_LISTIO_MAX value exists.\n");
 #endif
 #ifdef _POSIX_AIO_MAX
 printf(" _POSIX_AIO_MAX=%d Max concurrent Async I/Os\n",_POSIX_AIO_MAX);
 #else
 printf(" No _POSIX_AIO_MAX value exists.\n");
 #endif
 #else
 printf(" POSIX.4 Asynchronous I/O is not supported.\n");
 #endif
 #ifdef _POSIX_SYNCHRONIZED_IO //Only supported if Asynchronous I/O is supported
 printf(" POSIX.4 Synchronized I/O is supported.\n");
 #else
 printf(" POSIX.4 Synchronized I/O is not supported.\n");
 #endif
 #ifdef _POSIX_PRIORITIZED_IO
 printf(" POSIX.4 Prioritized asynchronous I/O is supported.\n");
 #ifdef _POSIX_AIO_PRIO_DELTA_MAX
 printf(" _POSIX_AIO_PRIO_DELTA_MAX=%d Max amount AIO priority can be decreased.\n",_POSIX_AIO_PRIO_DELTA_MAX);
 #else
 printf(" No _POSIX_AIO_PRIO_DELTA_MAX value exists.\n");
 #endif
 #else
 printf(" POSIX.4 Prioritized asynchronous I/O is not supported.\n");
 #endif
 #ifdef _POSIX_FSYNC
 printf(" POSIX.4 The fsync function is supported.\n");
 #else
 printf(" POSIX.4 The fsync function is not supported.\n");
 #endif
 #ifdef _POSIX_MAPPED_FILES
 printf(" POSIX.4 Mapping files as memory is supported.\n");
 #else
 printf(" POSIX.4 Mapping files as memory is not supported.\n");
 #endif
 #ifdef _POSIX_MEMLOCK
 printf(" POSIX.4 Locking memory is supported.\n");
 #else
 printf(" POSIX.4 Locking memory is not supported.\n");
 #endif
 #ifdef _POSIX_MEMLOCK_RANGE
 printf(" POSIX.4 Locking memory ranges is supported.\n");
 #else
 printf(" POSIX.4 Locking memory ranges is not supported.\n");
 #endif
 #ifdef _POSIX_MEMORY_PROTECTION
 printf(" POSIX.4 Setting memory protection is supported.\n");
 #else
 printf(" POSIX.4 Setting memory protection is not supported.\n");
 #endif
 #ifdef _POSIX_MESSAGE_PASSING
 printf(" POSIX.4 Message Queues are supported.\n");
 #ifdef _POSIX_MQ_OPEN_MAX
 printf(" _POSIX_MQ_OPEN_MAX=%d Max # of message queues per process.\n",_POSIX_MQ_OPEN_MAX);
 #else
 printf(" No _POSIX_MQ_OPEN_MAX value exists.\n");
 #endif
 #ifdef _POSIX_MQ_PRIO_MAX
 printf(" _POSIX_MQ_PRIO_MAX=%d Max # of message priorities.\n",_POSIX_MQ_PRIO_MAX);
 #else
 printf(" No _POSIX_MQ_PRIO_MAX value exists.\n");
 #endif
 #else
 printf(" POSIX.4 Message Queues are not supported.\n");
 #endif
 #ifdef _POSIX_SEMAPHORES
 printf(" POSIX.4 Semaphores are supported.\n");
 #ifdef _POSIX_SEM_NSEMS_MAX
 printf(" _POSIX_SEM_NSEMS_MAX=%d Max # of open semaphores per process.\n",_POSIX_SEM_NSEMS_MAX);
 #else
 printf(" No _POSIX_SEM_NSEMS_MAX value exists.\n");
 #endif
 #ifdef _POSIX_SEM_VALUE_MAX
 printf(" _POSIX_SEM_VALUE_MAX=%d Maximum semaphore value.\n",_POSIX_SEM_VALUE_MAX);
 #else
 printf(" No _POSIX_SEM_VALUE_MAX value exists.\n");
 #endif
 #else
 printf(" POSIX.4 Semaphores are not supported.\n");
 #endif
 #ifdef _POSIX_SHARED_MEMORY_OBJECTS
 printf(" POSIX.4 Shared memory objects are supported.\n");
 #else
 printf(" POSIX.4 Shared memory objects are not supported.\n");
 #endif
 #ifdef _POSIX_THREADS
 printf(" POSIX.1c pthreads are supported.\n");
 #else
 printf(" POSIX.1c pthreads are not supported.\n");
 #endif
 #ifdef _POSIX_THREAD_ATTR_STACKADDRTHREAD_ATTR_STACKADDR
 printf(" POSIX.4 Thread stack address attribute option is supported.\n");
 #else
 printf(" POSIX.4 Thread stack address attribute option is not supported.\n");
 #endif
 #ifdef _POSIX_THREAD_ATTR_STACKSIZE
 printf(" POSIX.4 Thread stack size attribute option is supported.\n");
 #else
 printf(" POSIX.4 Thread stack size attribute option is not supported.\n");
 #endif
 #ifdef _POSIX_THREAD_SAFE_FUNCTIONS
 printf(" POSIX.4 Thread-safe functions are supported.\n");
 #else
 printf(" POSIX.4 Thread-safe functions are not supported.\n");
 #endif
 #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
 printf("  POSIX.1c thread execution scheduling is supported.\n");
 #else
 printf("  POSIX.1c thread execution scheduling is not supported.\n");
 #endif
 #ifdef _POSIX_THREAD_PRIO_INHERIT
 printf(" POSIX.4 Thread priority inheritance option is supported.\n");
 #else
 printf(" POSIX.4 Thread priority inheritance option is not supported.\n");
 #endif
 #ifdef _POSIX_THREAD_PROCESS_SHARED
 printf(" POSIX.4 Process-shared synchronization is supported.\n");
 #else
 printf(" POSIX.4 Process-shared synchronization is not supported.\n");
 #endif
 #ifdef _POSIX_POSIX_PII
 printf(" Protocol-independent interfaces are supported.\n");
 #else
 printf(" Protocol-independent interfaces are not supported.\n");
 #endif
 #ifdef _POSIX_PII_XTI
 printf(" XTI protocol-indep. interfaces are supported.\n");
 #else
 printf(" XTI protocol-indep. interfaces are not supported.\n");
 #endif
 #ifdef _POSIX_PII_SOCKET
 printf(" Socket protocol-indep. interfaces are supported.\n");
 #else
 printf(" Socket protocol-indep. interfaces are not supported.\n");
 #endif
 #ifdef _POSIX_PII_INTERNET
 printf(" Internet family of protocols is supported.\n");
 #else
 printf(" Internet family of protocols is not supported.\n");
 #endif
 #ifdef _POSIX_PII_INTERNET_STREAM
 printf(" Connection-mode Internet protocol is supported.\n");
 #else
 printf(" Connection-mode Internet protocol is not supported.\n");
 #endif
 #ifdef _POSIX_PII_INTERNET_DGRAM
 printf(" Connectionless Internet protocol is supported.\n");
 #else
 printf(" Connectionless Internet protocol is not supported.\n");
 #endif
 #ifdef _POSIX_PII_OSI
 printf("  ISO/OSI family of protocols is supported.\n");
 #else
 printf("  ISO/OSI family of protocols is not supported.\n");
 #endif
 #ifdef _POSIX_PII_OSI_COTS
 printf(" Connection-mode ISO/OSI service is supported.\n");
 #else
 printf(" Connection-mode ISO/OSI service is not supported.\n");
 #endif
 #ifdef _POSIX_PII_OSI_CLTS
 printf(" Connectionless ISO/OSI service is supported.\n");
 #else
 printf(" Connectionless ISO/OSI service is not supported.\n");
 #endif
 #ifdef _POSIX_POLL
 printf(" Implementation supports `poll' function.\n");
 #else
 printf(" poll function is not supported.\n");
 #endif
 #ifdef _POSIX_SELECT
 printf(" Implementation supports `select' and `pselect'.\n");
 #else
 printf(" Implementation does not support `select' and `pselect'.\n");
 #endif
 #ifdef _XOPEN_REALTIME
 printf(" X/Open realtime support is available.\n");

  


  
分享到:
评论

相关推荐

    CTDP:中文文本数据处理

    Chinese-Text-Data-Processing ##一、当前功能 ...1、打开\CTDP\CTDP文件夹 2、在该目录下,运行命令 java -jar CTDP.jar -f lily 3、在目录中会生成output文件夹,输出结果将会保存在这个文件夹中

    型岩溶槽谷区降雨条件下地下河水质短时间尺度变化过程研究―――以重庆南山老龙洞地下河为例① (2012年)

    采用CTDP300多参数水质自动记录仪对重庆市南山老龙洞地下河出口处的地下水在降雨条件下水位、水温、pH值和电导率进行监测,以及2h时间间隔的地下水水化学指标(HCO3- ,Ca2+ ,Mg2+ ,NO3- ,PO34- ,SO24- , Fe2+ ,Mn2+ ,...

    川东槽谷区岩溶泉水物理化学动态特征及其环境效应研究———以重庆青木关岩溶槽谷姜家泉为例 (2009年)

    以重庆青木关岩溶槽谷姜家泉野外观测试验基地为例,利用CTDP300多参数水质自动记录仪、NITRATAXplussc在线硝氮分析仪及HOBO小型气象站,分别对岩溶泉在不同降雨条件下水化学的动态变化特征进行了监测研究。结果表明:...

    课设毕设基于SSM的毕业生就业信息管理系统-LW+PPT+源码可运行

    课设毕设基于SSM的毕业生就业信息管理系统--LW+PPT+源码可运行

    STM32设置闹钟中断-博文程序源码

    发了《STM32设置闹钟中断》一文后,大家都要问我要源码,其实我也找不到,当初也只是做设计时的一部分,根本没留单独的源代码,今天按博文特意重新整理了一下,有需要的自己下载吧。

    node-v0.8.26-sunos-x86.tar.gz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    python非常炫酷的跳动爱心代码

    python爱心代码高级 python非常炫酷的跳动爱心代码 python非常炫酷的跳动爱心代码 python非常炫酷的跳动爱心代码 python非常炫酷的跳动爱心代码 python非常炫酷的跳动爱心代码

    123pan_2.0.5.exe

    123pan_2.0.5

    NOSQL-课程复习资料

    NOSQL-课程复习资料

    node-v0.10.20-x86.msi

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    python爱心代码高级.zip

    python爱心代码高级

    springboot270基于JAVA的社团管理系统的设计与实现.rar

    开发语言:java 框架:springboot,vue JDK版本:JDK1.8 数据库:mysql5.7+(推荐5.7,8.0也可以) 数据库工具:Navicat11+ 开发软件:idea/eclipse(推荐idea)

    ClaudiaIDE.vsix

    ClaudiaIDE

    node-v0.8.20-sunos-x64.tar.gz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    node-v0.8.23-sunos-x86.tar.gz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    基于JavaScript+html+css开发的泊车系统+源码(毕业设计&课程设计&项目开发)

    基于JavaScript+html+css开发的泊车系统+源码,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用~ 基于JavaScript+html+css开发的泊车系统+源码,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用~ 基于JavaScript+html+css开发的泊车系统+源码,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用~ 基于JavaScript+html+css开发的泊车系统+源码,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用~

    node-v0.8.17-x64.msi

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    OpenHarmony下的minicom工具

    1. 发送文件到OpenHarmony: hdc file send minicom /data hdc shell chmod +x /data/minicom hdc shell mkdir -p /data/terminfo/v/ hdc file send vt100 /data/terminfo/v/ 2. 进入串口之后,执行以下命令运行minicom setenforce 0 export TERMINFO=/data/terminfo export TERM=vt100 /data/minicom -D /dev/ttyS9 3. minicom的操作方式,跟在linux系统下一模一样。 备注:这个工具在hdc shell连接终端下使用不友好,只能看到进入的界面,其他的操作都看不到。

    Optimizer-16.4.exe

    Optimizer-16.4

    node-v0.10.42-linux-x64.tar.gz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

Global site tag (gtag.js) - Google Analytics