• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Onway

            我是一只菜菜菜菜鳥...
            posts - 61, comments - 56, trackbacks - 0, articles - 34

            APUE第二章 UNIX標準化及實現

            Posted on 2015-12-08 22:35 Onway 閱讀(436) 評論(0)  編輯 收藏 引用 所屬分類: 使用說明
            1, 三個標準
            1.1, ISO C標準由ISO/IEC維護開發
            最新版本是C11,共有29個標準頭文件。

            1.2, POSIX是一系列由IEEE制定的標準
            POSIX包括ISO C標準庫函數。
            POSIX標準的1988版本是IEEE 1003.1-1988,經過修改后作為IEEE Std.1003.1-1990提交ISO,成為國際標準ISO/IEC 9945-1:1990,該標準通常稱為POSIX.1。
            當前最新版本是POSIX.1-2008,由IEEE和Open Group共同開發。

            1.3, SUS是POSIX的超集,其系統接口全集稱為XSI
            The core specifications of the SUS are developed and maintained by the Austin Group, which is a joint working group of IEEE, ISO JTC 1 SC22 and The Open Group.
            只有遵循XSI的實現才能稱為UNIX系統。
            當前的最新版本是SUSv4。

            1.4, 找到一些網址
            C11
            http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=57853

            POSIX.1-2008
            http://pubs.opengroup.org/onlinepubs/9699919799/
            https://standards.ieee.org/findstds/standard/1003.1-2008.html

            SUSv4
            https://www2.opengroup.org/ogsys/jsp/publications/PublicationDetails.jsp?publicationid=12310
            https://en.wikipedia.org/wiki/Single_UNIX_Specification#cite_note-11

            2, 限制
            2.1 兩種限制
            編譯時限制和運行時限制。
            編譯時限制通過頭文件獲取;
            不與文件或目錄相關的運行時限制通過sysconf函數獲??;
            與文件或目錄相關的運行時限制通過pathconf和fpathconf函數獲取。

            2.2 ISO C限制
            都是編譯時限制,主要定義在<limits.h>里面。
            http://en.cppreference.com/w/c/types/limits

            2.3 POSIX限制和XSI限制
            書中列出的都是實現中必須支持的各種最小值,特定系統實際支持的限制值需要通過頭文件或者三個函數函數獲取。
            三個函數的name參數是限制名前面加_SC_或者_PC_前綴得到。
            http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html

            2.4 書中代碼
            /*
             * If  name  is  invalid, -1 is returned, and errno is set to EINVAL.
             * Otherwise, the value returned is the value of the system resource and errno is not changed.
             * In the case of options, a positive value is returned if a queried option is available, and -1 if it is not.
             * In the case of limits, -1 means that there is no definite limit.
            */

            #include 
            "apue.h"
            #include 
            <errno.h>
            #include 
            <limits.h>

            #ifdef OPEN_MAX
            static long openmax = OPEN_MAX;
            #else
            static long openmax = 0;
            #endif

            /*
             * If OPEN_MAX is indeterminate, we're not
             * guaranteed that this is adequate
             
            */
            #define OPEN_MAX_GUESS 256

            long
            open_max(
            void)
            {
                
            if (openmax == 0) { /* first time through */
                    errno 
            = 0;
                    
            if ((openmax = sysconf(_SC_OPEN_MAX)) < 0) {
                        
            if (errno == 0)
                            openmax 
            = OPEN_MAX_GUESS; /* it's indeterminate */
                        
            else
                            err_sys(
            "sysconf error for _SC_OPEN_MAX";)
                    }
                }

                
            return(openmax);
            }

            3, 選項
            3.1, 選項確定方式
            編譯時選項定義在<unistd.h>中;
            與文件或目錄無關的選項用sysconf確定;
            與文件或目錄有關的選項用pathconf或者fpathconf確定;
            http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html

            3.2, 選項確定流程
            如果符號常量未定義,
            對_POSIX前綴的選項,將_POSIX前綴替換為_SC或_PC前綴,
            對_XOPEN前綴的選項,在_XOPEN前面加上_SC或_PC前綴,
            然后調用sysconf, pathconf或fpathconf函數。
            如果符號常量已經定義,則有三種可能:
            值為-1,不支持相應的選項;
            值大于0,支持相應的選項;
            值為0,需調用函數確定選項是否支持。
            注:某些系統可能出現定義了符號常量,但沒有定義值的情況。

            3.4, 代碼示例
            先占坑。

            4, 功能測試宏
            Feature test macros allow the programmer to control the definitions that are exposed by system header files when a program is compiled.
            NOTE:  In  order  to be effective, a feature test macro must be defined before including any header files.  This can be done either in the compilation command (cc -DMACRO=value) or by defining the macro within the source code before including any headers.
            see man page feature_test_macros(7).
            久久天天躁夜夜躁狠狠躁2022 | 久久国产精品波多野结衣AV| 久久这里只精品国产99热| 69国产成人综合久久精品| 久久这里只有精品视频99| 久久国产精品无码HDAV | 亚洲国产成人精品女人久久久 | 久久99精品久久只有精品| 欧美亚洲日本久久精品| 国内精品综合久久久40p| 国产A级毛片久久久精品毛片| 亚洲精品无码久久久久久| 久久久久99精品成人片牛牛影视| AV无码久久久久不卡蜜桃| 久久久久这里只有精品| 亚洲AV日韩精品久久久久久久| 久久精品水蜜桃av综合天堂| 久久精品国产清自在天天线| 精品久久久久久国产潘金莲| 久久人人爽人人精品视频| av无码久久久久不卡免费网站| 亚洲国产视频久久| 精品久久久久一区二区三区| 日本强好片久久久久久AAA| 久久天天躁夜夜躁狠狠| 久久精品无码av| 99久久精品免费观看国产| 国产视频久久| 色综合久久88色综合天天| 久久精品无码专区免费青青| 综合久久一区二区三区 | 伊人久久成人成综合网222| 大香网伊人久久综合网2020| 国产精品美女久久久久网| 久久久www免费人成精品| 日韩美女18网站久久精品| 国产精品热久久毛片| 国产免费久久精品99久久| 久久激情五月丁香伊人| AA级片免费看视频久久| 激情久久久久久久久久|