• <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).
            久久99国产精一区二区三区| 国产V综合V亚洲欧美久久| 99久久er这里只有精品18| 中文字幕无码久久人妻| 久久久久亚洲精品无码网址| 国产精品亚洲美女久久久| 久久99国产精品久久久| 久久综合狠狠综合久久激情 | 国産精品久久久久久久| 99久久国产综合精品五月天喷水| 久久精品中文騷妇女内射| 久久国产精品无码一区二区三区| 无码人妻久久一区二区三区免费 | 久久综合狠狠综合久久 | 精品国产VA久久久久久久冰| 一本久久a久久精品亚洲| 亚洲AV无码久久精品色欲| 日韩AV无码久久一区二区| 久久久久人妻一区精品性色av| 激情伊人五月天久久综合| 久久综合久久综合久久综合| 久久成人精品| 囯产精品久久久久久久久蜜桃 | 色综合合久久天天综合绕视看| 999久久久免费国产精品播放| 精品国产综合区久久久久久| 久久精品无码一区二区app| 久久只这里是精品66| 奇米影视7777久久精品| 久久国产精品久久久| 精品久久久久久国产三级| 久久这里只精品99re66| 久久久噜噜噜久久中文福利| 亚洲欧美日韩精品久久| 欧美大战日韩91综合一区婷婷久久青草 | 久久亚洲sm情趣捆绑调教| 国产亚洲精品自在久久| 久久精品国产一区二区三区不卡| 久久久久久久久久久| 久久久91精品国产一区二区三区 | 国产成人久久777777|