• <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 閱讀(435) 評論(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).
            热99re久久国超精品首页| 中文字幕亚洲综合久久菠萝蜜| 亚洲成色www久久网站夜月| 色妞色综合久久夜夜| 成人a毛片久久免费播放| 一本色道久久综合狠狠躁篇| 欧美大香线蕉线伊人久久| 91久久九九无码成人网站| 97香蕉久久夜色精品国产 | 精品久久久无码中文字幕| 亚洲精品成人久久久| 狠狠干狠狠久久| 久久综合鬼色88久久精品综合自在自线噜噜| 无码久久精品国产亚洲Av影片| 久久国产精品免费| 99久久99这里只有免费的精品| 久久亚洲中文字幕精品一区四 | 亚洲va久久久噜噜噜久久天堂| 久久精品成人免费观看97| 国产精品久久久久国产A级| 国产69精品久久久久APP下载 | 国产综合久久久久久鬼色| 久久久久亚洲AV综合波多野结衣 | 亚洲日韩欧美一区久久久久我| 久久福利青草精品资源站免费| 亚洲AV无码久久精品狠狠爱浪潮| 人妻少妇精品久久| 国产高清美女一级a毛片久久w| 精品久久久久久久无码| 麻豆一区二区99久久久久| 亚洲午夜久久久久妓女影院| 午夜精品久久久久久影视777| 蜜臀久久99精品久久久久久| 伊人久久大香线蕉精品| 91精品国产高清久久久久久91 | 午夜精品久久久久久| 久久福利片| 久久无码人妻精品一区二区三区 | 久久综合伊人77777麻豆| 久久精品三级视频| 日韩va亚洲va欧美va久久|