Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ANN: Adare_net Ada network lib

247 views
Skip to first unread message

Daniel Norte Moraes

unread,
Sep 4, 2021, 11:54:54 PM9/4/21
to
Hi All! :-)

Adare_net is a small, portable and easy to use Ada network lib.
It supports ipv4 ipv6 udp and tcp, and can 'listen' with ipv6, too.

The powerfull buffer feature can support all Ada types,
and with a more refined treatment, you can use endian proof records and
unconstrained arrays.

From now, tested and working:
AMD64 :
mswindows 7 sp1 64bits
and ubuntu Hirsute 64bits

Thanks and Enjoy!!

https://gitlab.com/daresoft/network/adare_net

DrPi

unread,
Sep 17, 2021, 5:05:03 PM9/17/21
to
Hi,
I had a quick look at the top level source code. I'm surprised all
packages are declared with "pure" aspect.
From what I understand of the "pure" aspect, these packages are not pure.
Am I wrong ?

Regards,
Nicolas

Joakim Strandberg

unread,
Sep 22, 2021, 4:47:15 AM9/22/21
to
> I had a quick look at the top level source code. I'm surprised all
> packages are declared with "pure" aspect.
> From what I understand of the "pure" aspect, these packages are not pure.
> Am I wrong ?
>
> Regards,
> Nicolas

I agree with you Nicolas, they should not be declared Pure. It makes the GNAT compiler check for example that there are no global variables used in the packages but other than that, they (I didn't check all the packages) are not Pure. The pragma Pure worked as expected in Ada83 but the meaning and utility of it disappeared with the Ada95 standard. It is possible in Ada95 to declare a package as Pure and then import C-functions that can do anything. It is also possible in Ada95 to circumvent the meaning of pragma Pure or the Pure aspect by taking advantage of dynamic dispatch. If there is any use of a tagged type inside a package or there is some C-function that is imported, the package should not be labeled as Pure. It should be possible to develop a libadalang- or ASIS based application to check for this. Well, this is a small issue since it is easy to remove the Pure aspects. In any case, thanks to the author for writing adare_net and sharing it with the World!

Best regards,
Joakim

AdaMagica

unread,
Sep 22, 2021, 5:16:13 AM9/22/21
to
> I agree with you Nicolas, they should not be declared Pure. It makes the GNAT compiler check for example that there are no global variables used in the packages but other than that, they (I didn't check all the packages) are not Pure. The pragma Pure worked as expected in Ada83 but the meaning and utility of it disappeared with the Ada95 standard.
There is no pragma Pure in Ada 83.

Joakim Strandberg

unread,
Sep 22, 2021, 7:07:06 AM9/22/21
to
onsdag 22 september 2021 kl. 11:16:13 UTC+2 skrev AdaMagica:
> > I agree with you Nicolas, they should not be declared Pure. It makes the GNAT compiler check for example that there are no global variables used in the packages but other than that, they (I didn't check all the packages) are not Pure. The pragma Pure worked as expected in Ada83 but the meaning and utility of it disappeared with the Ada95 standard.
> There is no pragma Pure in Ada 83.

Thanks for clearing that up AdaMagica, I wasn't aware.

Best regards,
Joakim

Daniel Norte Moraes

unread,
Sep 27, 2021, 12:32:26 AM9/27/21
to
Really? They _are_ Pure.
I used linters extensively to result in this. one of these linters made hard use o gnat and gprbuild as his backend.
Remember this is target Ada 2012 (update 2016) and beyond => there is
no guarantee of operation for Ada versions earlier than Ada2012.

for now Adare_Net support:
MSwindows and Linux.

was tested in:
Mswindows => starting amd64 windows seven sp1 + msys2 gcc-10.3 gnat-10.3 gprbuild-2021
Linux => amd64 gcc-11.1+ gnat-11.1+ gprbuild-2021.

1o.) We need as many volunteers as possible to testing Adare_Net on as many
operating systems as possible and reporting his/her result to us.
currently linux and mswindows are the targets.

Very Very Very Thanks!
Enjoy!!!




Randy Brukardt

unread,
Sep 28, 2021, 12:52:37 AM9/28/21
to

"AdaMagica" <christ-u...@t-online.de> wrote in message
news:b1650e4c-90c6-4c75...@googlegroups.com...
Pragma Pure was an IMHO failed attempt to control/document access to
globals. It has much too broad of a granularity to be very useful (I've
never found anything that I could make Pure outside of language-defined
things, and some of those cannot be implemented as Pure even though declared
that way). Ada 2022 has aspect Global to do this properly, Global => null
has many fewer holes than Pure.

Note however that one can always lie about any Ada semantics in interfacing
code. But any such lies make your code erroneous, and while it might work on
one compiler today, there's no guarentee that it will work anywhere else
(including the next update of your usual compiler). See B.1(38.1/5):

It is the programmer's responsibility to ensure that the use of
interfacing aspects does
not violate Ada semantics; otherwise, program execution is erroneous. For
example,
passing an object with mode in to imported code that modifies it causes
erroneous
execution. Similarly, calling an imported subprogram that is not pure from
a pure
package causes erroneous execution.

[The latter two sentences were added because programmers didn't seem to get
what the first sentence means. We wanted that to be interpreted in the
broadest possible way.]

Randy.


DrPi

unread,
Sep 30, 2021, 8:24:34 AM9/30/21
to
Le 27/09/2021 à 06:32, Daniel Norte Moraes a écrit :
> Em quarta-feira, 22 de setembro de 2021 às 08:07:06 UTC-3, joak...@kth.se escreveu:
>> onsdag 22 september 2021 kl. 11:16:13 UTC+2 skrev AdaMagica:
>>>> I agree with you Nicolas, they should not be declared Pure. It makes the GNAT compiler check for example that there are no global variables used in the packages but other than that, they (I didn't check all the packages) are not Pure. The pragma Pure worked as expected in Ada83 but the meaning and utility of it disappeared with the Ada95 standard.
>>> There is no pragma Pure in Ada 83.
>> Thanks for clearing that up AdaMagica, I wasn't aware.
>>
>> Best regards,
>> Joakim
>
> Really? They _are_ Pure.
> I used linters extensively to result in this. one of these linters made hard use o gnat and gprbuild as his backend.
> Remember this is target Ada 2012 (update 2016) and beyond => there is
> no guarantee of operation for Ada versions earlier than Ada2012.

In a Pure package, shouldn't the subprograms also be Pure ?

Daniel Norte Moraes

unread,
Sep 30, 2021, 4:10:51 PM9/30/21
to
Well, :-)

Why ?
The functions dont are pure ? why?

Maybe we need fix the ARM 2012+

The ARM2012 allowed it. gprbuild and gnat just follow ARM :-).

To made things as a lib be almost all pure (or yet preelaborate) there are a hard and
time consuming way to study and test. This fact is itself the main motive for almost all libs and apps ignore Ada categorizations.

Then, no one yet say if the lib work... only about pure... why? we need more than a 'freestyle' opinions.

For your use, just fork and make bether (ah and remove all Ada Categorizations :-)

====X=====

DrPi

unread,
Oct 1, 2021, 1:33:45 PM10/1/21
to
A subprogram returning content read from the network can't be pure. Or
there is something I have not understood about the Pure aspect.

> Maybe we need fix the ARM 2012+
>
> The ARM2012 allowed it. gprbuild and gnat just follow ARM :-).
>
> To made things as a lib be almost all pure (or yet preelaborate) there are a hard and
> time consuming way to study and test. This fact is itself the main motive for almost all libs and apps ignore Ada categorizations.
>
> Then, no one yet say if the lib work... only about pure... why? we need more than a 'freestyle' opinions.
>
My intent is to try Adare_Net. So I started by taking a look at the
sources and the first thing I noticed was the Pure aspect of the
packages. As I'm far from a Ada expert, and I like to understand things,
I asked here about it.

Is there a documentation somewhere ?

Simon Wright

unread,
Oct 1, 2021, 3:11:30 PM10/1/21
to
DrPi <3...@drpi.fr> writes:

> A subprogram returning content read from the network can't be pure. Or
> there is something I have not understood about the Pure aspect.

ARM 10.1.1(18)[1] says

"[...] the implementation may omit a call on such a subprogram and
simply reuse the results produced by an earlier call on the same
subprogram, provided that [...]. This permission applies even if the
subprogram produces other side effects when called."

[1] http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-10-2-1.html#p18

Shark8

unread,
Oct 12, 2021, 11:49:58 AM10/12/21
to
On Thursday, September 30, 2021 at 6:24:34 AM UTC-6, DrPi wrote:
> Le 27/09/2021 à 06:32, Daniel Norte Moraes a écrit :
> > Em quarta-feira, 22 de setembro de 2021 às 08:07:06 UTC-3, joak...
> >> onsdag 22 september 2021 kl. 11:16:13 UTC+2 skrev AdaMagica:
> >>>> I agree with you Nicolas, they should not be declared Pure. It makes the GNAT compiler check for example that there are no global variables used in the packages but other than that, they (I didn't check all the packages) are not Pure. The pragma Pure worked as expected in Ada83 but the meaning and utility of it disappeared with the Ada95 standard.
> >>> There is no pragma Pure in Ada 83.
> >> Thanks for clearing that up AdaMagica, I wasn't aware.
> >>
> >> Best regards,
> >> Joakim
> >
> > Really? They _are_ Pure.
> > I used linters extensively to result in this. one of these linters made hard use o gnat and gprbuild as his backend.
> > Remember this is target Ada 2012 (update 2016) and beyond => there is
> > no guarantee of operation for Ada versions earlier than Ada2012.
> In a Pure package, shouldn't the subprograms also be Pure ?
Yes...ish.
As mentioned upthread, you can lie about there being no internal state... and this can still be "interfacially" pure; consider a FIBONACCI function which is memoized (Function F(N: Positive) return Positive) -- internally it has the memo to look up F(N), which is obviously state, but externally any F(X) will return the same value given the same inputs. / Perhaps we should allow aspect PURE on subprograms, as well as introduce an aspect STATIC [having (user-defined) static-functions would, in particular, allow some nice "macro-lite" functionality].

Shark8

unread,
Oct 12, 2021, 12:00:46 PM10/12/21
to
On Friday, October 1, 2021 at 11:33:45 AM UTC-6, DrPi wrote:
>
> My intent is to try Adare_Net. So I started by taking a look at the
> sources and the first thing I noticed was the Pure aspect of the
> packages. As I'm far from a Ada expert, and I like to understand things,
> I asked here about it.
>
> Is there a documentation somewhere ?
The simple explanation of Pure is that it means there is no internal-state in the package; as a consequence, (1) a value-returning call with the same parameters can be treated as idempotent and therefore can be replicated across calls; and (2) in the Distributed Systems Annex, we can replicate this package across partitions w/o worrying about synchronization precisely because there is no internal state.

So, "ideologically" having a networking library marked "pure" is not _necessarily_ a wrong thing -- though treating such calls as idempotent certainly would be -- and perhaps that is a point where some refinement could be made; perhaps allowing subprograms to be marked aspect VOLATILE to indicate that they are not idempotent or some such.

> > For your use, just fork and make bether (ah and remove all Ada Categorizations :-)
The categorizations *are* useful, as shown above... though overloading them with other properties, or rather having so coarse a granularity limits that.

Egil H H

unread,
Oct 12, 2021, 3:44:33 PM10/12/21
to

Daniel Norte Moraes

unread,
Dec 30, 2021, 3:56:05 PM12/30/21
to
We apologize for the delay in responding. I (daniel) was expecting the 'static aspect' to have
more support (I gotted this suggestion, and thanks to you who suggested it).
With the development release of gnat-12 I'll try to answer all the questions and make all the suggested
changes that make sense.

Really Randy, I'm aware about this.
I´ll try answer in order:

1) var'address as mode in: the address in the import functions and procedures don't are changed. when there are a change, the change is just
in the data that address point to. this is a standard pratice in ada bind world. we dont use 'in out' mode because the address don't are changed.

2) object'address and for object'address use 'var': a) remember by the src code, the true 'lengths' are saved and used without
violate the address space (really this is my responsability as programmmer) b) and
(besides some bug by off-one not yet hunted). c) this is sure enforced. d) I get a instantaneos segfault if this
dont are enforced. e) this 'enforcement' is transparent to user. f) the user dont have access to this 'internals' , It is isolated from his/her.

3) besides an aparent violation, a) this was necessary to get values, in reality a 'view change' to get the real values. compilers obligied me
to do this, afters some months, figthing against some linux patchs (permantent patchs) and segfault in mswindows. Besides the harmless and legitimate use
without 'view change', gcc gnat linux and mswindows dont permited this.

4) import var convention c: a) the mostly vars is embedded from _c vars in adare-net c sources_. the Ada RM made a excption in this case when this is
imported vars.

etc.

From now:

I can transform mostly imported vars in static functions.

Pleeease All, Say us What you want and or What you complains(with filename and line_number) and yours sugestions.

Ah! The Version of Ada is 202x.

Enjoy with us!

Best Whishes, Dani.

Daniel Norte Moraes

unread,
Dec 30, 2021, 4:15:35 PM12/30/21
to
We will create a pdf with the api, after upgrading to ada202x and adding support for more operating systems, this includes solving reported
issues and adding suggestions from all of you, 'pure' and 'global' and 'nonblocking => false' and etc included.

While this, You can use the programs in 'exemple folder'. it contains working client and server src and programs. mostly time Its are in 'pairs' of filenames.
Thanks,
Best Whishes,
Dani.

Daniel Norte Moraes

unread,
Dec 30, 2021, 4:30:56 PM12/30/21
to
Thanks! I Followed Your Suggestion!
Now that there is good support for ada202x in gcc-12, we have started solving the reported issues and adding everyone's suggestions.

https://gitlab.com/daresoft/network/adare_net/-/tree/202x

Beer with us!

Best Wishes and Happy New Year(!),
Dani.
0 new messages