Friday, July 14, 2023

Digest for comp.lang.c++@googlegroups.com - 20 updates in 5 topics

Muttley@dastardlyhq.com: Jul 14 10:31AM

On Thu, 13 Jul 2023 19:09:52 -0000 (UTC)
 
>I said C65, not C64. Maybe you meant C65, too, but made a typo.
 
>Anyway, this is the machine I was talking about:
 
> https://en.wikipedia.org/wiki/Commodore_65
 
Interesting. Never heard of it but given they'd already had a high powered 16
bit machine in the Amiga for 5 years it seems utterly pointless and I can see
why it was canned.
 
>It is true that C65 was not meant for business, but for
>entertainment. Its hardware was already pretty obsolete
>when it was created. The era of 8-bit computers was over.
 
Well quite.
 
>My main point is that crazy moves like that cause
>monetary losses to the company, and they waste the time of
>those who work with doomed-to-fail projects.
 
Unfortunately a lot of tech companies have great engineers but bad management.
See Sun Microsystems for further examples.
Muttley@dastardlyhq.com: Jul 14 10:32AM

On Thu, 13 Jul 2023 19:15:51 +0200
>> are you're full of shit. As usual.
 
>No, there is no reason for you to be angry with me,
>apparently justified.
 
More meaningless Bonita Babble.
kalevi@kolttonen.fi (Kalevi Kolttonen): Jul 14 11:17AM

> Interesting. Never heard of it but given they'd already had a high powered 16
> bit machine in the Amiga for 5 years it seems utterly pointless and I can see
> why it was canned.
 
Exactly. Commodore's shaky business moves also included
this weird device:
 
https://en.wikipedia.org/wiki/Commodore_CDTV
 
I guess it is basically Amiga hardware that is supposed
to be a gaming console. Again, some Commodore collectors
want to buy them, but I don't think CDTV was at all
successful when it was released.
 
> Unfortunately a lot of tech companies have great
> engineers but bad management. See Sun Microsystems
> for further examples.
 
Yes, I remember very well when Oracle acquired Sun. Some
notable UNIX innovations are Sun's achievements.
Everybody knows NFS and ZFS.
 
We used to have some SPARC Solaris servers, but in the
end Red Hat Enterprise Linux won. I suppose Solaris
is still being developed by Oracle, but some people
have said it is now much slower than Linux.
 
br,
KK
Muttley@dastardlyhq.com: Jul 14 11:30AM

On Fri, 14 Jul 2023 11:17:26 -0000 (UTC)
>end Red Hat Enterprise Linux won. I suppose Solaris
>is still being developed by Oracle, but some people
>have said it is now much slower than Linux.
 
Last proper Solaris update was 5 years ago and that was 11.4. Version 11.0 was
released in 2011 so I think its fair to say its just legacy support now.
kalevi@kolttonen.fi (Kalevi Kolttonen): Jul 14 11:41AM

> Last proper Solaris update was 5 years ago and
> that was 11.4. Version 11.0 was released in 2011
> so I think its fair to say its just legacy support now.
 
I googled "solaris roadmap" and one of the hits was
this Oracle blog:
 
https://blogs.oracle.com/solaris/post/long-live-solaris-11-until-at-least-2034-to-be-exact
 
Its topic says:
 
"Long live Solaris 11! - Until at least 2034 to be exact".
 
So if you are willing to pay for "Extended Support", whatever
that means, your Solaris has over ten years left. In a fast
moving IT world, it is a long time.
 
You must be right about the fact that no major Solaris OS
updates will be available.
 
br,
KK
Muttley@dastardlyhq.com: Jul 14 03:00PM

On Fri, 14 Jul 2023 11:41:48 -0000 (UTC)
>to-be-exact
 
>Its topic says:
 
> "Long live Solaris 11! - Until at least 2034 to be exact".
 
IOW you have 11 years to switch to another OS.
 
>So if you are willing to pay for "Extended Support", whatever
>that means, your Solaris has over ten years left. In a fast
>moving IT world, it is a long time.
 
Indeed. I can't imagine it'll get any significant updates in that time, just
bug fixes.
kalevi@kolttonen.fi (Kalevi Kolttonen): Jul 14 04:04PM

> IOW you have 11 years to switch to another OS.
 
You probably remember that for a brief period of
time, Solaris kernel was open source. Its license
was something called CDDL.
 
The open source status did not last for long
and Oracle reverted back to its original
closed source policy. But they could not take
back what had already been released as OpenSolaris.
 
Solaris lovers have created their own Unix OS
based on the OpenSolaris kernel:
 
https://en.wikipedia.org/wiki/OpenIndiana
 
According to that Wikipedia page, the project
OpenIndiana is active and their latest release
was on April 21, 2023.
 
 
Then there is OmniOS that is also based on
OpenSolaris. Their homepage is:
 
https://omnios.org/
 
As of this writing, the project is alive:
 
"On the 1st of May 2023, the OmniOSce Association has
released a new stable version of OmniOS - The Open
Source Enterprise Server OS. The release comes with
many tool updates, brand-new features and additional
hardware support"
 
They claim that OmniOS is particularly well-suited
for serving as a virtualization host. Some people
are suspicious of Linux kernel development's quick
pace and they prefer to use an OS that is more
immutable, if you can call it that.
 
I got no experience with OpenIndiana or OmniOS.
I have only booted OmniOS once or twice to take a
quick look.
 
br,
KK
Muttley@dastardlyhq.com: Jul 14 04:20PM

On Fri, 14 Jul 2023 16:04:03 -0000 (UTC)
>and Oracle reverted back to its original
>closed source policy. But they could not take
>back what had already been released as OpenSolaris.
 
I got a CD of opensolaris back in the day. Looked nice but almost none
of the hardware on my laptop worked including sound so it was fairly pointless.
Maybe as a server OS it was good.
 
>I got no experience with OpenIndiana or OmniOS.
>I have only booted OmniOS once or twice to take a
>quick look.
 
No doubt fun for the devs but no sane person would use them as a daily OS.
kalevi@kolttonen.fi (Kalevi Kolttonen): Jul 14 04:56PM

> I got a CD of opensolaris back in the day. Looked nice but almost none
> of the hardware on my laptop worked including sound so it was fairly pointless.
 
The OpenSolaris project never really took off big time.
Most people capable of doing Unix kernel development wanted
to contribute to Linux, FreeBSD, OpenBSD, NetBSD, etc.
Thus it is not surprising that your laptop did not
work properly. No drivers, no fun.
 
> Maybe as a server OS it was good.
 
If you think about stability, Solaris was rock solid
like UNIX in general tends to be. I never saw any crashes
or serious malfunctioning.
 
Running commercial Sun Solaris on Sun SPARC hardware
had the benefit that you knew that *if* something
were to go wrong, you could just report the problem to
Sun Microsystems. They shipped both the hardware and
the software and they would accept responsibility
for finding a fix.
 
Running Linux on some random Intel hardware, you
could report a problem to those who sold the hardware,
and they would say that their hardware is fine, the
fault must be in Linux kernel. I know this has happened.
 
When it comes to performance, at one point in distant
time some benchmarks suggested that Solaris was 10%
slower than Linux, but who knows what they even
measured. I have recently heard that Solaris is
now noticeably slower than Linux.
 
 
There was also a time when Solaris performed better
on desktop than Linux. A colleague once showed me
how. He started a heavily I/O-bound process on
Linux, perhaps untarring a 2GB file or something
like that. Interactive use became hopeless right
away and the GUI was very unresponsive indeed.
 
Next he started the same process on Solaris.
The GUI worked quite flawlessly with no signs
of being stuck.
 
>>I have only booted OmniOS once or twice to take a
>>quick look.
 
> No doubt fun for the devs but no sane person would use them as a daily OS.
 
If by "daily OS" you mean your desktop use, then I
suppose you are right.
 
It is extremely important the virtualization hosts
are super stable. I am guessing that OmniOS probably
is. It would be interesting to hear real experiences.
 
br,
KK
scott@slp53.sl.home (Scott Lurndal): Jul 14 05:43PM

>for finding a fix.
 
>Running Linux on some random Intel hardware, you
>could report a problem to
 
redhat or suse who would be happy to fix it for you.
kalevi@kolttonen.fi (Kalevi Kolttonen): Jul 14 06:11PM

> redhat or suse who would be happy to fix it for you.
 
The incident I was referring to occurred long
time ago in 1999 or 2000. The NFS file
server was running Red Hat Linux 6.0 or
something like that. Red Hat Enterprise Linux
did not exist back then. I don't know about
SUSE.
 
I don't know whether commercial support from
Red Hat was even available during those times, but
the server in question was bought and installed by
the previous system adminstrator who had left the
building for good.
 
The hardware RAID5 box and the server i686 box
had support contracts. The Red Hat Linux
OS did not.
 
One day one of the disks in the RAID5 failed.
Since we had a support contract, we reported
the issue and a guy appeared with a replacement
disk. The old disk out, the new disk in, so
far so good.
 
But not all was great, as the filesystem kept
getting corrupted. We fixed it with fsck time
after time, but the problem kept occurring
particularly during the nights when the tape
backups caused lots of I/O.
 
The hardware vendor blamed the Linux kernel
and claimed that their RAID5 and the new
disk were functioning 100% properly.
 
After several days, I guess it was me who
finally figured out that the new SCSI disk
had one jumper that was set in an incorrect
position. The service guy had made a costly
mistake.
 
I cannot recall the exact details, but I
guess it was a matter of choosing between
some kind Direct IO and Cached IO. I also
cannot recall which setting was the right
one, but once the jumper was set correctly,
filesystem no longer got corrupted.
 
After that we replaced the Linux file server
with Sun SPARC hardware running Solaris.
 
br,
KK
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jul 14 12:22PM -0700

On 7/14/2023 4:17 AM, Kalevi Kolttonen wrote:
 
> Yes, I remember very well when Oracle acquired Sun. Some
> notable UNIX innovations are Sun's achievements.
> Everybody knows NFS and ZFS.
 
Fwiw, I won a brand new sunfire t2000 with my entry into Sun's
coolthreads project. Right after that, iirc, Oracle acquired Sun.
 
 
scott@slp53.sl.home (Scott Lurndal): Jul 14 10:10PM

>had one jumper that was set in an incorrect
>position. The service guy had made a costly
>mistake.
 
So it wasn't a redhat or kernel problem after all;
so a software service contract wouldn't have been
useful to you.
 
In any case, Redhat offered paid support for Redhat 6
(I ran RH6 for several years up to the mid-aughts
on a web/mail server). From my old logs:
 
$ date
Mon May 10 11:27:56 PDT 2006
$ uptime
11:28am up 1528 days, 6:47, 8 users, load average: 0.23, 0.12, 0.05
kalevi@kolttonen.fi (Kalevi Kolttonen): Jul 14 10:47PM

> So it wasn't a redhat or kernel problem after all;
> so a software service contract wouldn't have been
> useful to you.
 
You are correct about that. But our main goal
when favouring Sun Microsystems and Sun Solaris
was that in case of mysterious problems starting
to occur, we won't have to deal with *two different
companies*.
 
In other words, if both the hardware platform
and OS come from a single source, then you know
who to contact as there is only one option.
 
If you have two companies involved, then it is more
troublesome possibly having to contact both of them.
 
In a bad case they could even blame each other, not
accepting the responsibility to solve the problem.
It would be rare, but could sometimes happen.
 
> Mon May 10 11:27:56 PDT 2006
> $ uptime
> 11:28am up 1528 days, 6:47, 8 users, load average: 0.23, 0.12, 0.05
 
Okay, thanks for the information.
 
br,
KK
kalevi@kolttonen.fi (Kalevi Kolttonen): Jul 14 11:14PM


> In a bad case they could even blame each other, not
> accepting the responsibility to solve the problem.
> It would be rare, but could sometimes happen.
 
I would like to add one more recent example. My Lenovo
laptop runs Fedora Linux. I bought it from a big store
here in Finland, but for politeness reasons, I won't
mention its name.
 
The laptop somehow "died" not long after I had bought
it. The screen just went completely blank and after
that nothing worked, the laptop was dead as a brick.
 
I took the laptop to the big store where they said
that they only care about Lenovos that have Windows
installed. Fedora Linux is not supported and installing
it has voided the warranty.
 
I argued that these Lenovos come preinstalled with
Fedora Linux in some areas of the world. I kept
insisting that the warranty must valid, and they
accepted the laptop to be serviced.
 
After exactly two weeks, the laptop arrived from
Germany to Finland. The service guys had inspected
the machine and concluded that there was nothing
wrong about it.
 
When I fetched it from the big store and I tried
it at home, it worked flawlessly. I have no
clue about what happened.
 
Well, that story was probably too long and boring,
but should illustrate that some companies can
blame Linux even now when it is pretty obvious that
it has to be a hardware related issue.
 
br,
KK
Nikki Locke <nikki@trumphurst.com>: Jul 14 10:23PM

Available C++ Libraries FAQ
 
URL: http://www.trumphurst.com/cpplibs/
 
This is a searchable list of libraries and utilities (both free
and commercial) available to C++ programmers.
 
If you know of a library which is not in the list, why not fill
in the form at http://www.trumphurst.com/cpplibs/cppsub.php
 
Maintainer: Nikki Locke - if you wish to contact me, please use the form on the website.
Lynn McGuire <lynnmcguire5@gmail.com>: Jul 14 04:33PM -0500

"C++23's Deducing this: what it is, why it is, how to use it" by Sy Brand
https://devblogs.microsoft.com/cppblog/cpp23-deducing-this/
 
"Deducing this (P0847) is a C++23 feature which gives a new way of
specifying non-static member functions. Usually when we call an object's
member function, the object is implicitly passed to the member function,
despite not being present in the parameter list. P0847 allows us to make
this parameter explicit, giving it a name and const/reference
qualifiers. For example:"
 
struct implicit_style {
void do_something(); //object is implicit
};
 
struct explicit_style {
void do_something(this explicit_style& self); //object is explicit
};
 
We use the implicit this a lot.
 
Lynn
Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>: Jul 14 02:19AM -0700

On Thursday, July 13, 2023 at 10:50:35 PM UTC+1, Frederick Virchanza Gotham wrote:
 
> The next step will be to get it to work with return values that are greater
> than 16 bytes (because then the return value will be pushed to the stack).
 
 
I was wrong about this. If the callee returns a struct bigger than 16 bytes, then it is the caller function that allocates memory on the stack, and then the caller passes the address of this allocated memory in the RDI register to the callee. So the stack pointer will always be the same before and after a function call.
 
So it looks like my code is already complete -- I have figured out a way to call _any_ function with a custom stack using the System V x86_64 calling convention.
 
Soon I'll look at allowing it to handle exceptions thrown from the callee.
Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>: Jul 14 05:01AM -0700

On Friday, July 14, 2023 at 10:19:19 AM UTC+1, I wrote:
 
> So it looks like my code is already complete -- I have figured out a way to call _any_ function
> with a custom stack using the System V x86_64 calling convention.
 
 
I figured out how to access thread_local variables from inside "inline assembler" with the GNU compiler, so I've been able to simply my code further:
 
https://godbolt.org/z/jY7G7EMYb
 
And here it is copy-pasted:
 
#include <cassert> // assert
#include <cstddef> // size_t
#include <memory> // unique_ptr
#include <utility> // forward
 
thread_local char *p_original, *p_replacement;
thread_local void (*f)(void);
thread_local char *bottom_of_stack;
 
extern "C" {
void Assembler_set_bottom_of_stack (void) noexcept;
void Assembler_set_stack_pointer_and_invoke(void) noexcept;
}
 
__asm("Assembler_set_bottom_of_stack: \n"
".intel_syntax noprefix \n"
" mov r10, rsp \n"
" add r10, 16 \n" // +8 return addr, +8 to be safe
" mov QWORD PTR fs:bottom_of_stack@tpoff, r10 \n"
" ret \n"
".att_syntax");
 
template<typename R, typename... Params>
class Invoker {
 
Invoker(char *const arg_p, R(*const arg_f)(Params...)) noexcept
{
p_replacement = arg_p; // sets a thread_local variable
f = reinterpret_cast<void (*)(void)>(arg_f); // sets a thread_local variable
}
 
public:
R operator()(Params... args) // This could be static function but I like operator()
{
Assembler_set_bottom_of_stack();
R (*const funcptr)(Params...) = reinterpret_cast<R(*)(Params...)>(Assembler_set_stack_pointer_and_invoke);
return funcptr( std::forward<Params>(args)... );
}
 
friend class Stacker;
};
 
class Stacker {
char *p;
std::unique_ptr<char[]> mystack;
 
public:
 
Stacker(std::size_t const len) noexcept(false) // might throw bad_alloc
{
assert( len >= 128u );
 
mystack.reset( new char[len] );
p = mystack.get() + len - 16u;
}
 
Stacker(char *const arg, std::size_t const len) noexcept
{
assert( nullptr != arg );
assert( len >= 128u );
 
p = arg + len - 16u;
}
 
template<typename R, typename... Params>
Invoker<R,Params...> operator()( R(*const arg)(Params...) )
{
return Invoker<R,Params...>(this->p, arg);
}
};
 
/* In the following function written in x86_64 assembler using
the System V calling convention, we can only clobber r10
and r11 because all of the other caller-saved registers
must be preserved for the 'jmp' to the target function. */
 
__asm("Assembler_set_stack_pointer_and_invoke:\n"
".intel_syntax noprefix \n"
// Step 1: Save the original stack pointer
" mov QWORD PTR fs:p_original@tpoff, rsp \n"
// Step 2: Retrieve the replacement stack pointer
" push r15 \n" // save to restore later
" mov r15, rsp \n" // pointer to the r15 we just pushed onto stack
" add r15, 8 \n" // sets 'r15' to top of old stack
" mov r10, QWORD PTR fs:p_replacement@tpoff \n" // sets 'r10' to top of new stack
" mov rax, QWORD PTR fs:bottom_of_stack@tpoff \n" // sets 'rax' to bottom of old stack
// Right now: R15 is the top of the old stack
// R10 is the top of the new stack
// RAX is the bottom of the old stack
// We want to do:
// while ( rax != r15 ) *r10-- = *rax--;
// Step 3: Copy the old stack to the new stack (it might contain supernumerary arguments or a big return struct)
" jmp cond \n" // Jump to condition of 'while' loop
"loop: \n" // ----<----<----<----<----
" mov r11, qword ptr [rax] \n" // |
" mov qword ptr [r10], r11 \n" // ^
" sub r10, 1 \n" // | Loop
" sub rax, 1 \n" // |
"cond: \n" // ^
" cmp rax, r15 \n" // |
" jne loop \n" // ---->---->---->---->----
" pop r15 \n" // restore original value
// Step 4: Change the stack pointer to the new stack =============================================
" mov rsp, r10 \n" // ================================================= new stack
// Step 5: Set the return address to after the 'jmp' instruction
" lea r10, [Label_Jump_Back] \n"
" add rsp, 8 \n" // This line and the next line replace the return address on the stack
" push r10 \n" // This line and the previous line replace the return address on the stack
// Step 5: Invoke the function
" jmp QWORD PTR fs:f@tpoff \n" // --- Invoke the function!
"Label_Jump_Back: \n"
// Note: The label has already been popped off the stack by the callee
// Step 9: Restore the original stack pointer
" mov rsp, QWORD PTR fs:p_original@tpoff \n"
// Step 10: Jump back to the original address
" ret \n"
".att_syntax");
 
// =================== And now the test code ===============================================
 
#include <iostream> // cout, endl
using std::cout, std::endl;
 
struct VeryBigStruct {
double a[3];
int b[3];
double c[3];
int d[3];
double e[3];
int f[3];
};
 
VeryBigStruct Func2(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10)
{
VeryBigStruct vbs;
vbs.f[2] = a1+a2+a3+a4+a5+a6+a7+a8+a9+a10;
return vbs;
}
 
int main(void)
{
cout << "first line in main\n";
 
VeryBigStruct vbs;
vbs.a[1] = 7;
vbs.b[2] = 8;
vbs.f[2] = 9;
 
cout << "Retval: " << Func2(1,2,3,4,5,6,7,8,9,10).f[2] << endl;
 
cout << "Retval: " << Stacker(1048576000u)(Func2)(1,2,3,4,5,6,7,8,9,10).f[2] << endl;
 
cout << "last line in main\n";
}
wij <wyniijj5@gmail.com>: Jul 13 09:05PM -0700

On Wednesday, July 12, 2023 at 7:56:25 AM UTC+8, wij wrote:
> thinks, it is just an information/mechanism for branching.
 
> Control-flows between modules are similar, just have more room to play tricks.
 
> So, libwy regards returning Errno as primitive.
 
A section about ops-on-self is added to ClassGuidelines. The updated version is at
https://sourceforge.net/projects/cscall/files/MisFiles/ClassGuidelines.txt/download
 
------ Operations on self
Functions that modify something from source info. is what programs do.
But, when the source and destination object overlap (this is possible when the
object is indicated by pointer or reference), things become tricky, e.g.
 
t.reset(t);
str.reset(cstr_ptr); // cstr_ptr points to the inside string of str.
 
Theoretically, semantics of such expression is classified as undefined. In
C/C++, if the source object is indicated const, the promise will be broken, at
least.
 
[Rationale omitted]
 
This library decided to test this situation, if cannot work around, ELOOP is
returned.
----------
 
Such ops-on-self should not be few. How does std library deal with this (e.g. string, vector)?
The cost of checking is not cheap, suggestion and idea?
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: