PreviousUpNext

15.4.1179  src/lib/std/src/psx/posix-error.pkg

## posix-error.pkg
#
# Package for POSIX error codes.
# This is a subpackage of the POSIX 1003.1 based
# 'Posix' package
#
#     src/lib/std/src/psx/posixlib.pkg

# Compiled by:
#     src/lib/std/src/standard-core.sublib




stipulate
    package ci  =  mythryl_callable_c_library_interface;                        # mythryl_callable_c_library_interface  is from   src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkg
    package hug =  host_unt_guts;                                               # host_unt_guts                         is from   src/lib/std/src/bind-sysword-32.pkg
    #
    fun cfun  fun_name
        =
        ci::find_c_function { lib_name => "posix_error",  fun_name };           # posix_error                           def in    src/c/lib/posix-error/cfun-list.h
            #
            ###############################################################
            # The functions in this package are not true syscalls, so the
            # usual issues of minimizing latency do not apply.
            #
            # Consequently I'm not taking the time and effort to switch them
            # over from using find_c_function() to using find_c_function'().
            #                              -- 2012-04-18 CrT
herein

    package posix_error {
        #
        System_Error = Int;                                                     #  = PreBasis::System_Error 


        stipulate
            list_errors
                =
                cfun "listerrors"                                               # listerrors                            def in    src/c/lib/posix-error/listerrors.c
                :
                Void -> List(ci::System_Constant);
        herein
            errors =  list_errors ();                                           # <errno.h> stuff like:  EACCESS, EAGAIN, EWOULDBLOCK ...  -- see src/c/lib/posix-error/errno-sysconsts-table.c
        end;


        fun os_val s
            =
            (ci::bind_system_constant (s, errors)).id;


        fun syserror s
            =
            case (ci::find_system_constant (s, errors))
                #
                THE r =>  THE r.id;
                NULL  =>  NULL;
            esac;


        errmsg   =   cfun "errmsg"  :   Int -> String             ;             # errmsg                def in    src/c/lib/posix-error/errmsg.c
        geterror =   cfun "geterror":   Int -> ci::System_Constant;             # geterror              def in    src/c/lib/posix-error/geterror.c

        fun to_unt   i =  hug::from_int i;
        fun from_unt w =  hug::to_int w;


        fun error_msg i
            =
            errmsg i;


        fun error_name err
            =
            (geterror err).name;


        toobig        = os_val "toobig";
        acces         = os_val "acces";
        again         = os_val "again";
        badf          = os_val "badf";
        badmsg        = os_val "badmsg";
        busy          = os_val "busy";
        canceled      = os_val "canceled";
        child         = os_val "child";
        deadlk        = os_val "deadlk";
        dom           = os_val "dom";
        exist         = os_val "exist";
        fault         = os_val "fault";
        fbig          = os_val "fbig";
        inprogress    = os_val "inprogress";
        intr          = os_val "intr";
        inval         = os_val "inval";
        io            = os_val "io";
        isdir         = os_val "isdir";
        loop          = os_val "loop";
        mfile         = os_val "mfile";
        mlink         = os_val "mlink";
        msgsize       = os_val "msgsize";
        name_too_long = os_val "nametoolong";
        nfile         = os_val "nfile";
        nodev         = os_val "nodev";
        noent         = os_val "noent";
        noexec        = os_val "noexec";
        nolck         = os_val "nolck";
        nomem         = os_val "nomem";
        nospc         = os_val "nospc";
        nosys         = os_val "nosys";
        notdir        = os_val "notdir";
        notempty      = os_val "notempty";
        notsup        = os_val "notsup";
        notty         = os_val "notty";
        nxio          = os_val "nxio";
        perm          = os_val "perm";
        pipe          = os_val "pipe";
        range         = os_val "range";
        rofs          = os_val "rofs";
        spipe         = os_val "spipe";
        srch          = os_val "srch";
        xdev          = os_val "xdev";

    }; #  package posix_error 
end;



Comments and suggestions to: bugs@mythryl.org

PreviousUpNext