• <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 閱讀(442) 評論(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).
            蜜臀av性久久久久蜜臀aⅴ| 少妇人妻综合久久中文字幕| 久久九九兔免费精品6| 无码伊人66久久大杳蕉网站谷歌 | 日韩久久无码免费毛片软件 | a级成人毛片久久| 欧美一区二区精品久久| 一级A毛片免费观看久久精品| 久久精品国产亚洲av日韩| 久久影视国产亚洲| 久久噜噜电影你懂的| 日日狠狠久久偷偷色综合96蜜桃| 亚洲乱码中文字幕久久孕妇黑人| 潮喷大喷水系列无码久久精品| 久久久久国产精品人妻| 国产成人99久久亚洲综合精品| 久久99精品国产自在现线小黄鸭 | 久久激情五月丁香伊人| 久久综合狠狠综合久久激情 | 久久午夜羞羞影院免费观看| 久久久久国产| 曰曰摸天天摸人人看久久久| 欧美大香线蕉线伊人久久| 久久国产AVJUST麻豆| 无码8090精品久久一区| 99久久精品国产一区二区| 精品国产一区二区三区久久久狼| 久久只有这精品99| 99久久国产宗和精品1上映| 狠狠色丁香婷婷久久综合| 久久se这里只有精品| 精品视频久久久久| 亚洲综合婷婷久久| 色综合久久中文综合网| 久久精品国产91久久综合麻豆自制 | 久久精品国产清自在天天线| 久久五月精品中文字幕| 久久综合一区二区无码| 香港aa三级久久三级老师2021国产三级精品三级在 | 亚洲美日韩Av中文字幕无码久久久妻妇| 久久综合丁香激情久久|