Re: vax/ddb(4): clean up machine dependent code and improve usability

Rhialto <[email protected]>
Newsgroups gmane.os.netbsd.ports.vax
Message-ID <[email protected]>
On Mon 10 Mar 2025 at 13:08:09 +0100, Hans Rosenfeld wrote:
> Since this is a rather large change, I'd like to give anyone interested
> a chance to do a proper code review before I commit this. I've been

It's not a change you made, but it occurs in the diff a lot:

In functions that take a printf-like function pointer pr:
void (*pr)(const char *, ...), the function is called as

	(*pr)("hallo");

Due to the vagaries of the C type system (a value of type "function"
decays to the function's address), *pr is effectively the same thing as
pr. In fact, also if you write a call like  foo(arg)   this same
mechanism takes effect. So you could equally well write

	(*******pr)("hallo");

but more practical would be simply

	pr("hallo");

And yes, this means you really can use "C++-like syntax" like
ptr->member(arg1, arg2) if you have a struct with function pointers in
it.

For an example of generated code, see https://godbolt.org/z/v8cbvss1r
a.k.a.
https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:15,endLineNumber:6,positionColumn:15,positionLineNumber:6,selectionStartColumn:15,selectionStartLineNumber:6,startColumn:15,startLineNumber:6),source:'static+void%0Adb_trace_process(struct+lwp+*l,+struct+proc+*p,+void+(*pr)(const+char+*,+...))%0A%7B%0A++++++++pr(%22hallo%22)%3B%0A++++++++(*pr)(%22hallo%22)%3B%0A++++++++(******pr)(%22hallo%22)%3B%0A%7D%0A'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:vaxg1050,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+VAX+gcc+NetBSDELF+10.5.0+(Nov+15+03:50:22+2023)+(Editor+%231)',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert                            <rhialto/at/falu.nl>
\X/ There is no AI. There is just someone else's work.           --I. Rose
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEFVAhiiWjqgwBVdQAmYnGRWHD+9MFAmfQbfIACgkQmYnGRWHD
+9Pd1wf/QdMjOuP4jUZuIorsWJbjsY6V1a23pu3GKyrQhAIO0b1bemLo5FpDNeJb
1pSgVVbMem1ZIj2sZnLNhF4Wbx+fWi2a55bi1qd1r7pZdQ7KMOKYQDx4HxegYVKj
o6E+TzIAI/tt9iyA7PAW8BZvoA4wOMY1S4VOIcDqxU6LiYbi9RS5ZvT5szFvT1ah
Ll58klW6BkqfD7OPtLW7AGvWvLe8WXXgffk87dfHVoXAIoyYTp6IUroq+DMEyqPn
g1DSXn3Pwc1rRHBLJ7alU5wQOZbqqRBXgBfGH5lT+PvCjHvBJ784WhldSMRSXFZr
7SMlHhY2KZJYmnw9W5PE07XIFyed+w==
=Ewzs
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.