Files
mercury/extras/net/errno.m
Julien Fischer ee69c1432c Fix the networking library.
extras/net/Makefile:
    Build a Mercury.modules as some file names do not match
    their module names and the compiler no longer accepts this.

extras/net/errno.m:
    Ensure we can see the definition of MR_STRERROR_BUF_SIZE.
2020-01-13 21:49:25 +11:00

55 lines
1.7 KiB
Mathematica

%-----------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et
%---------------------------------------------------------------------------%
% Copyright (C) 2014, 2018 The Mercury Team.
% This file is distributed under the terms specified in COPYING.LIB.
%-----------------------------------------------------------------------------%
%
% Module: errno.
% Main Author: Paul Bone <paul@bone.id.au>
% Stability: low
%
% Provide an interface to the C errno type and functions.
%
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- module net.errno.
:- interface.
:- import_module int.
:- import_module string.
:- type errno == int.
:- func strerror(errno) = string.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- implementation.
:- pragma foreign_decl("C", "#include \"mercury_runtime_util.h\"").
%-----------------------------------------------------------------------------%
% Errno handling.
%
strerror(Errno) = String :-
strerror(Errno, String).
:- pred strerror(int::in, string::uo) is det.
:- pragma foreign_proc("C",
strerror(Errno::in, Str::uo),
[will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
char errbuf[MR_STRERROR_BUF_SIZE];
MR_make_aligned_string_copy(Str,
MR_strerror(Errno, errbuf, sizeof(errbuf)));
").
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%