Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #120918 > unrolled thread

libwy-0.69.3 is released

Started bywij <wyniijj5@gmail.com>
First post2024-11-19 21:05 +0800
Last post2024-11-20 16:40 +0000
Articles 13 — 4 participants

Back to article view | Back to comp.lang.c++


Contents

  libwy-0.69.3 is released wij <wyniijj5@gmail.com> - 2024-11-19 21:05 +0800
    Re: libwy-0.69.3 is released wij <wyniijj5@gmail.com> - 2024-11-19 21:21 +0800
    Re: libwy-0.69.3 is released Muttley@DastartdlyHQ.org - 2024-11-19 15:13 +0000
      Re: libwy-0.69.3 is released wij <wyniijj5@gmail.com> - 2024-11-20 00:55 +0800
        Re: libwy-0.69.3 is released Muttley@DastartdlyHQ.org - 2024-11-19 17:02 +0000
          Re: libwy-0.69.3 is released wij <wyniijj5@gmail.com> - 2024-11-20 11:36 +0800
            Re: libwy-0.69.3 is released Bonita Montero <Bonita.Montero@gmail.com> - 2024-11-20 07:42 +0100
            Re: libwy-0.69.3 is released Muttley@DastartdlyHQ.org - 2024-11-20 08:22 +0000
              Re: libwy-0.69.3 is released wij <wyniijj5@gmail.com> - 2024-11-20 23:20 +0800
                Re: libwy-0.69.3 is released wij <wyniijj5@gmail.com> - 2024-11-21 00:17 +0800
                  Re: libwy-0.69.3 is released "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-11-20 13:31 -0800
                    Re: libwy-0.69.3 is released "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-11-20 13:32 -0800
                Re: libwy-0.69.3 is released Muttley@DastartdlyHQ.org - 2024-11-20 16:40 +0000

#120918 — libwy-0.69.3 is released

Fromwij <wyniijj5@gmail.com>
Date2024-11-19 21:05 +0800
Subjectlibwy-0.69.3 is released
Message-ID<bda070a6eaad3e6c76ee6d026e5e5fdaf3ff138d.camel@gmail.com>
libwy-0.69.3 is released.

https://sourceforge.net/projects/cscall/
An elementary C++ library by wrapping commonly used C library functions and
system calls into forms suitable for solving problems in fast and effective OO
way. The structure and API of this library are robust, almost fool-proof,
application normally just use it mechanically. This library added few for
developer to learn and remember in hopes that users can focus more on real
things, no need to endless learn things 'backwardly'.
------------------

This release added classes for forking process and memory mapping, because
the range of application of these two are much wider than threads (maybe safer
and easier, too). The following is an example program.

------------------------
/* Copyright is licensed by GNU LGPL, see file COPYING.       by I.J.Wang 2024

   Two proceeses increase one single int from 0 to 200 alternatively by using
   mmap,semaphore
*/
#include <Wy.stdio.h>
#include <Wy.unistd.h>
#include <Wy.semaphore.h>
#include <CSCall/MemMap.h>

using namespace Wy;

int *shared_nptr=NULL;
Semaphore sem(Semaphore::InProcess,1);

// [Syn] Increase $shared_nptr pointer int from 0 to 200 depending on whether
//       $v and the int are both odd, or even.
//
int ftask(int v) {
 Errno r;

 for(;;) {
   if((r=sem.wait())!=Ok) {
     WY_THROW(r);
   }
   if(*shared_nptr>200) {
     break;
   }
   if((*shared_nptr&1)!=v) {
     if((r=sem.post())!=Ok) {
       WY_THROW(r);
     }
     continue;
   }
   cout << (v? 'o':'e')  << *shared_nptr << ' ';
   ++*shared_nptr;
   if((r=sem.post())!=Ok) {
     WY_THROW(r);
   }
 }
 return v;
};

int main(int argc, const char* argv[])
try {
 Errno r;

 MemMap mmap(NULL,sizeof(int),PROT_READ|PROT_WRITE,MAP_SHARED);
 shared_nptr= static_cast<int*>(mmap.addr());

 *shared_nptr=0;

 ForkProcess fproc(ftask,1);  // run ftask(1) in a new process

 ftask(0);

 if((r=fproc.wait())!=Ok) {   // wait for change of state
   WY_THROW(r);
 }

 cout << WY_ENDL "OK" WY_ENDL;
 return 0;
}
catch(const Errno& e) {
 cerr << wrd(e) << WY_ENDL;
 return e.c_errno();
}
catch(...) {
 cerr << "main() caught(...)" WY_ENDL;
 throw;
};

[toc] | [next] | [standalone]


#120920

Fromwij <wyniijj5@gmail.com>
Date2024-11-19 21:21 +0800
Message-ID<b71905c24a5991976e65f2fd7afce93ea36bb05a.camel@gmail.com>
In reply to#120918
On Tue, 2024-11-19 at 21:05 +0800, wij wrote:
> libwy-0.69.3 is released.
> 
> https://sourceforge.net/projects/cscall/
> An elementary C++ library by wrapping commonly used C library functions and
> system calls into forms suitable for solving problems in fast and effective OO
> way. The structure and API of this library are robust, almost fool-proof,
> application normally just use it mechanically. This library added few for
> developer to learn and remember in hopes that users can focus more on real
> things, no need to endless learn things 'backwardly'.
> ------------------
> 
> This release added classes for forking process and memory mapping, because
> the range of application of these two are much wider than threads (maybe safer
> and easier, too). The following is an example program.
> 
> ------------------------
> /* Copyright is licensed by GNU LGPL, see file COPYING.       by I.J.Wang 2024
> 
>    Two proceeses increase one single int from 0 to 200 alternatively by using
>    mmap,semaphore
> */
> #include <Wy.stdio.h>
> #include <Wy.unistd.h>
> #include <Wy.semaphore.h>
> #include <CSCall/MemMap.h>
> 
> using namespace Wy;
> 
> int *shared_nptr=NULL;
> Semaphore sem(Semaphore::InProcess,1);
> 
> // [Syn] Increase $shared_nptr pointer int from 0 to 200 depending on whether
> //       $v and the int are both odd, or even.
> //
> int ftask(int v) {
>  Errno r;
> 
>  for(;;) {
>    if((r=sem.wait())!=Ok) {
>      WY_THROW(r);
>    }
>    if(*shared_nptr>200) {
>      break;
>    }
>    if((*shared_nptr&1)!=v) {
>      if((r=sem.post())!=Ok) {
>        WY_THROW(r);
>      }
>      continue;
>    }
>    cout << (v? 'o':'e')  << *shared_nptr << ' ';
>    ++*shared_nptr;
>    if((r=sem.post())!=Ok) {
>      WY_THROW(r);
>    }
>  }
>  return v;
> };
> 
> int main(int argc, const char* argv[])
> try {
>  Errno r;
> 
>  MemMap mmap(NULL,sizeof(int),PROT_READ|PROT_WRITE,MAP_SHARED);
>  shared_nptr= static_cast<int*>(mmap.addr());
> 
>  *shared_nptr=0;
> 
>  ForkProcess fproc(ftask,1);  // run ftask(1) in a new process
> 
>  ftask(0);
> 
>  if((r=fproc.wait())!=Ok) {   // wait for change of state
>    WY_THROW(r);
>  }
> 
>  cout << WY_ENDL "OK" WY_ENDL;
>  return 0;
> }
> catch(const Errno& e) {
>  cerr << wrd(e) << WY_ENDL;
>  return e.c_errno();
> }
> catch(...) {
>  cerr << "main() caught(...)" WY_ENDL;
>  throw;
> };

[]$ g++ a_fmmap.cpp -lwy
[]$ ./a.out 
e0 o1 e2 o3 e4 o5 e6 o7 e8 o9 e10 o11 e12 o13 e14 o15 e16 o17 e18 o19 e20 o21 e22 o23 e24 o25 e26 o27
e28 o29 e30 o31 e32 o33 e34 o35 e36 o37 e38 o39 e40 o41 e42 o43 e44 o45 e46 o47 e48 o49 e50 o51 e52
o53 e54 o55 e56 o57 e58 o59 e60 o61 e62 o63 e64 o65 e66 o67 e68 o69 e70 o71 e72 o73 e74 o75 e76 o77
e78 o79 e80 o81 e82 o83 e84 o85 e86 o87 e88 o89 e90 o91 e92 o93 e94 o95 e96 o97 e98 o99 e100 o101 e102
o103 e104 o105 e106 o107 e108 o109 e110 o111 e112 o113 e114 o115 e116 o117 e118 o119 e120 o121 e122
o123 e124 o125 e126 o127 e128 o129 e130 o131 e132 o133 e134 o135 e136 o137 e138 o139 e140 o141 e142
o143 e144 o145 e146 o147 e148 o149 e150 o151 e152 o153 e154 o155 e156 o157 e158 o159 e160 o161 e162
o163 e164 o165 e166 o167 e168 o169 e170 o171 e172 o173 e174 o175 e176 o177 e178 o179 e180 o181 e182
o183 e184 o185 e186 o187 e188 o189 e190 o191 e192 o193 e194 o195 e196 o197 e198 o199 e200 
OK

[toc] | [prev] | [next] | [standalone]


#120923

FromMuttley@DastartdlyHQ.org
Date2024-11-19 15:13 +0000
Message-ID<vhi9v9$1t36d$1@dont-email.me>
In reply to#120918
On Tue, 19 Nov 2024 21:05:40 +0800
wij <wyniijj5@gmail.com> boring babbled:
>libwy-0.69.3 is released.
>
>https://sourceforge.net/projects/cscall/
>An elementary C++ library by wrapping commonly used C library functions and
>system calls into forms suitable for solving problems in fast and effective=

Pure wrapper functions/classes don't serve much purpose unless they do 
something extra compared to just calling the API functions directly since
we're all capable of spending 5 mins putting fork() (or similar) into a class
which is preferable to having a dependency on someones hobby library.

[toc] | [prev] | [next] | [standalone]


#120926

Fromwij <wyniijj5@gmail.com>
Date2024-11-20 00:55 +0800
Message-ID<7e05636643d671e118187c137c1245156d95cc81.camel@gmail.com>
In reply to#120923
On Tue, 2024-11-19 at 15:13 +0000, Muttley@DastartdlyHQ.org wrote:
> On Tue, 19 Nov 2024 21:05:40 +0800
> wij <wyniijj5@gmail.com> boring babbled:
> > libwy-0.69.3 is released.
> > 
> > https://sourceforge.net/projects/cscall/
> > An elementary C++ library by wrapping commonly used C library functions and
> > system calls into forms suitable for solving problems in fast and effective=
> 
> Pure wrapper functions/classes don't serve much purpose unless they do 
> something extra compared to just calling the API functions directly since
> we're all capable of spending 5 mins putting fork() (or similar) into a class
> which is preferable to having a dependency on someones hobby library.
> 

Such kind of opinion has been around since 2005, so, it seems to be like 
olcott's motto "Talent hits a target no one else can hit; Genius hits a target 
no one else can see."
But, I mean the opposite, it is too obvious (like 0.999!=1, infinitesaml exists
in real number,...) for 'educated' people to see it. You have to try it to know
(and compare it with c++ std library). Or, try build such kind of library by
your own to understand.

libwy does not support stream I/O (may be considered a defect), but it contains 
a class RdBuf which handles 'stream' better than any library I know of.

SYNOPSIS
       Except POD types, C structures, all types are declared in namespace Wy.

       #include <Wy.unistd.h>

       Class  RdBuf  is a buffer for generalizing sequential data reading from
       various ByteFlow devices (with timeout  support),  and  for  recovering
       packet  messages  fromthe  data stream. The data, if necessary, is read
       into a buffer, then split into a certain length according to  the  read
       request:

         1. Explicitly specify the length of data to read
         2. Read till a specific (break) character is read

[cut]
---------

For example:

void recv_msg() {
  RdBuf strm(cin);
  ...
  strm.append_read(buf,512,iseom); // read 512 bytes until a break character
                                   // determined by a short function iseom(char)

  strm.read(str.begin(),100,n_rw,&tm); // read 100 byte until timeout
};

[toc] | [prev] | [next] | [standalone]


#120927

FromMuttley@DastartdlyHQ.org
Date2024-11-19 17:02 +0000
Message-ID<vhigab$1ud14$1@dont-email.me>
In reply to#120926
On Wed, 20 Nov 2024 00:55:07 +0800
wij <wyniijj5@gmail.com> boring babbled:
>On Tue, 2024-11-19 at 15:13 +0000, Muttley@DastartdlyHQ.org wrote:
>> Pure wrapper functions/classes don't serve much purpose unless they do=
>=20
>> something extra compared to just calling the API functions directly since
>> we're all capable of spending 5 mins putting fork() (or similar) into a c=
>lass
>> which is preferable to having a dependency on someones hobby library.
>>=20
>
>Such kind of opinion has been around since 2005, so, it seems to be like=

Why 2005? Similar comments were probably said about many libraries going back
to the birth of software libraries.

>olcott's motto "Talent hits a target no one else can hit; Genius hits a tar=
>get=20
>no one else can see."
>But, I mean the opposite, it is too obvious (like 0.999!=3D1, infinitesaml =
>exists
>in real number,...) for 'educated' people to see it. You have to try it to =
>know
>(and compare it with c++ std library). Or, try build such kind of library b=
>y
>your own to understand.

Trying to make out you're some kind of genius when you receive some mild
criticism really doesn't do you any favours and just makes you sound like an
arrogant ass.

>
>libwy does not support stream I/O (may be considered a defect), but it cont=
>ains=20
>a class RdBuf which handles 'stream' better than any library I know of.

Which begs the question of how many libraries do you know of.

[toc] | [prev] | [next] | [standalone]


#120929

Fromwij <wyniijj5@gmail.com>
Date2024-11-20 11:36 +0800
Message-ID<483ac6e312d3aa416d8a155cbc8661bcd58910da.camel@gmail.com>
In reply to#120927
On Tue, 2024-11-19 at 17:02 +0000, Muttley@DastartdlyHQ.org wrote:
> On Wed, 20 Nov 2024 00:55:07 +0800
> wij <wyniijj5@gmail.com> boring babbled:
> > On Tue, 2024-11-19 at 15:13 +0000, Muttley@DastartdlyHQ.org wrote:
> > > Pure wrapper functions/classes don't serve much purpose unless they do=
> > =20
> > > something extra compared to just calling the API functions directly since
> > > we're all capable of spending 5 mins putting fork() (or similar) into a c=
> > lass
> > > which is preferable to having a dependency on someones hobby library.
> > > =20
> > 
> > Such kind of opinion has been around since 2005, so, it seems to be like=
> 
> Why 2005? Similar comments were probably said about many libraries going back
> to the birth of software libraries.
> 
> > olcott's motto "Talent hits a target no one else can hit; Genius hits a tar=
> > get=20
> > no one else can see."
> > But, I mean the opposite, it is too obvious (like 0.999!=3D1, infinitesaml =
> > exists
> > in real number,...) for 'educated' people to see it. You have to try it to =
> > know
> > (and compare it with c++ std library). Or, try build such kind of library b=
> > y
> > your own to understand.
> 
> Trying to make out you're some kind of genius when you receive some mild
> criticism really doesn't do you any favours and just makes you sound like an
> arrogant ass.

For now, it seems I am more open to criticism than you are.
What can I get from your criticism?
I explained that your criticism has been around for 20 years, sth I missed?
What is your criticism exactly?

> > 
> > libwy does not support stream I/O (may be considered a defect), but it cont=
> > ains=20
> > a class RdBuf which handles 'stream' better than any library I know of.
> 
> Which begs the question of how many libraries do you know of.

Several, five maybe.

[toc] | [prev] | [next] | [standalone]


#120930

FromBonita Montero <Bonita.Montero@gmail.com>
Date2024-11-20 07:42 +0100
Message-ID<vhk0aj$2am87$1@raubtier-asyl.eternal-september.org>
In reply to#120929
Am 20.11.2024 um 04:36 schrieb wij:

> For now, it seems I am more open to criticism than you are.
> What can I get from your criticism?
> I explained that your criticism has been around for 20 years, sth I missed?
> What is your criticism exactly?
> 

He is simply right.

[toc] | [prev] | [next] | [standalone]


#120932

FromMuttley@DastartdlyHQ.org
Date2024-11-20 08:22 +0000
Message-ID<vhk690$ogt$1@dont-email.me>
In reply to#120929
On Wed, 20 Nov 2024 11:36:44 +0800
wij <wyniijj5@gmail.com> boring babbled:
>On Tue, 2024-11-19 at 17:02 +0000, Muttley@DastartdlyHQ.org wrote:
>> On Wed, 20 Nov 2024 00:55:07 +0800
>> Trying to make out you're some kind of genius when you receive some mild
>> criticism really doesn't do you any favours and just makes you sound like=
> an
>> arrogant ass.
>
>For now, it seems I am more open to criticism than you are.
>What can I get from your criticism?
>I explained that your criticism has been around for 20 years, sth I missed?
>What is your criticism exactly?

Go back and read what I wrote. If you have a problem understanding it use
google translate.

>> >=20
>> > libwy does not support stream I/O (may be considered a defect), but it =
>cont=3D
>> > ains=3D20
>> > a class RdBuf which handles 'stream' better than any library I know of.
>>=20
>> Which begs the question of how many libraries do you know of.
>
>Several, five maybe.

List them.

[toc] | [prev] | [next] | [standalone]


#120939

Fromwij <wyniijj5@gmail.com>
Date2024-11-20 23:20 +0800
Message-ID<b8896fdd029704e94ed80489ce3ab557c57bc229.camel@gmail.com>
In reply to#120932
On Wed, 2024-11-20 at 08:22 +0000, Muttley@DastartdlyHQ.org wrote:
> On Wed, 20 Nov 2024 11:36:44 +0800
> wij <wyniijj5@gmail.com> boring babbled:
> > On Tue, 2024-11-19 at 17:02 +0000, Muttley@DastartdlyHQ.org wrote:
> > > On Wed, 20 Nov 2024 00:55:07 +0800
> > > Trying to make out you're some kind of genius when you receive some mild
> > > criticism really doesn't do you any favours and just makes you sound like=
> > an
> > > arrogant ass.
> > 
> > For now, it seems I am more open to criticism than you are.
> > What can I get from your criticism?
> > I explained that your criticism has been around for 20 years, sth I missed?
> > What is your criticism exactly?
> 
> Go back and read what I wrote. If you have a problem understanding it use
> google translate.
> 
> > > > =20
> > > > libwy does not support stream I/O (may be considered a defect), but it =
> > cont=3D
> > > > ains=3D20
> > > > a class RdBuf which handles 'stream' better than any library I know of.
> > > =20
> > > Which begs the question of how many libraries do you know of.
> > 
> > Several, five maybe.
> 
> List them.
> 

Ok, at least in 3 C++ books, the authors use 'wrapper' library.
More that 2 'wrapper' libraries in sourceforge are 'retired'.

[toc] | [prev] | [next] | [standalone]


#120944

Fromwij <wyniijj5@gmail.com>
Date2024-11-21 00:17 +0800
Message-ID<f1dd10a844d9355ec04cf91c5fbbcb9d712f20f8.camel@gmail.com>
In reply to#120939
On Wed, 2024-11-20 at 23:20 +0800, wij wrote:
> On Wed, 2024-11-20 at 08:22 +0000, Muttley@DastartdlyHQ.org wrote:
> > On Wed, 20 Nov 2024 11:36:44 +0800
> > wij <wyniijj5@gmail.com> boring babbled:
> > > On Tue, 2024-11-19 at 17:02 +0000, Muttley@DastartdlyHQ.org wrote:
> > > > On Wed, 20 Nov 2024 00:55:07 +0800
> > > > Trying to make out you're some kind of genius when you receive some mild
> > > > criticism really doesn't do you any favours and just makes you sound like=
> > > an
> > > > arrogant ass.
> > > 
> > > For now, it seems I am more open to criticism than you are.
> > > What can I get from your criticism?
> > > I explained that your criticism has been around for 20 years, sth I missed?
> > > What is your criticism exactly?
> > 
> > Go back and read what I wrote. If you have a problem understanding it use
> > google translate.
> > 
> > > > > =20
> > > > > libwy does not support stream I/O (may be considered a defect), but it =
> > > cont=3D
> > > > > ains=3D20
> > > > > a class RdBuf which handles 'stream' better than any library I know of.
> > > > =20
> > > > Which begs the question of how many libraries do you know of.
> > > 
> > > Several, five maybe.
> > 
> > List them.
> > 
> 
> Ok, at least in 3 C++ books, the authors use 'wrapper' library.
> More that 2 'wrapper' libraries in sourceforge are 'retired'.
> 
Basically, C programers moving to C++ (esp. in the early days) would try a
'wrapper' library. Why? because, C++ provides lots syntax to make it a better C
However, the result turned out that C++ is good to make sub-languages.

Being too expressive and not (C++ also wants 'standard'), taking advantage of C 
and not (C++ also wants to be independent of C) is the problem.

So, C abstracts Assembly, C++ abstracts C.
So, C wraps Assembly, libwy is, in the same sense, a C++ library that wraps C.

Wrapping C is easy/trivial? that depends on the result.

[toc] | [prev] | [next] | [standalone]


#120947

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2024-11-20 13:31 -0800
Message-ID<vhlkfn$9bih$1@dont-email.me>
In reply to#120944
On 11/20/2024 8:17 AM, wij wrote:
[...]
> So, C abstracts Assembly, C++ abstracts C.
> So, C wraps Assembly, libwy is, in the same sense, a C++ library that wraps C.
[...]

Tell that to pre C/C++ 11. It does not wrap assembly. I had to write 
custom assembly language back then to get my lock/wait/obstruction 
algorithms to work without thinking of a rouge compiler messing things up.

[toc] | [prev] | [next] | [standalone]


#120948

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2024-11-20 13:32 -0800
Message-ID<vhlkgt$9bih$2@dont-email.me>
In reply to#120947
On 11/20/2024 1:31 PM, Chris M. Thomasson wrote:
> On 11/20/2024 8:17 AM, wij wrote:
> [...]
>> So, C abstracts Assembly, C++ abstracts C.
>> So, C wraps Assembly, libwy is, in the same sense, a C++ library that 
>> wraps C.
> [...]
> 
> Tell that to pre C/C++ 11. It does not wrap assembly. I had to write 
> custom assembly language back then to get my lock/wait/obstruction 
> algorithms to work without thinking of a rouge compiler messing things up.

link time optimizations aside for a moment...

[toc] | [prev] | [next] | [standalone]


#120945

FromMuttley@DastartdlyHQ.org
Date2024-11-20 16:40 +0000
Message-ID<vhl3dc$68pf$1@dont-email.me>
In reply to#120939
On Wed, 20 Nov 2024 23:20:06 +0800
wij <wyniijj5@gmail.com> boring babbled:
>On Wed, 2024-11-20 at 08:22 +0000, Muttley@DastartdlyHQ.org wrote:
>> On Wed, 20 Nov 2024 11:36:44 +0800
>> wij <wyniijj5@gmail.com> boring babbled:
>> > On Tue, 2024-11-19 at 17:02 +0000, Muttley@DastartdlyHQ.org=C2=A0wrote:
>> > > On Wed, 20 Nov 2024 00:55:07 +0800
>> > > Trying to make out you're some kind of genius when you receive some m=
>ild
>> > > criticism really doesn't do you any favours and just makes you sound =
>like=3D
>> > an
>> > > arrogant ass.
>> >=20
>> > For now, it seems I am more open to criticism than you are.
>> > What can I get from your criticism?
>> > I explained that your criticism has been around for 20 years, sth I mis=
>sed?
>> > What is your criticism exactly?
>>=20
>> Go back and read what I wrote. If you have a problem understanding it use
>> google translate.
>>=20
>> > > > =3D20
>> > > > libwy does not support stream I/O (may be considered a defect), but=
> it =3D
>> > cont=3D3D
>> > > > ains=3D3D20
>> > > > a class RdBuf which handles 'stream' better than any library I know=
> of.
>> > > =3D20
>> > > Which begs the question of how many libraries do you know of.
>> >=20
>> > Several, five maybe.
>>=20
>> List them.
>>=20
>
>Ok, at least in 3 C++ books, the authors use 'wrapper' library.
>More that 2 'wrapper' libraries in sourceforge are 'retired'.

Oh well, I tried.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c++


csiph-web