On Tuesday 10 December 2024 11:11:59 LIU Hao wrote:
> 在 2024-12-10 05:59, Pali Rohár 写道:
> > What about having one def file kernel32.def.in where would be also
> > @STDCALL suffixes and when building non-I386 variant, the build process
> > will filter that file over sed 's/@[0-9]*$//' and then process by cpp
> > preprocessor? (Or first process by cpp and then by sed)
> 
> This would remove ordinals too. @ is part of a symbol and is a special case.

Ok. So it needs to write sed regex in more fancy way to not remove
ordinal numbers. What about to call this after cpp?

  sed -E 's/^([^ ]+)@[0-9]+( |$)/\1\2/'

(remove @num part of the first identifier if is non-empty on every line)

We need to handle more options where STDCALL suffix is:

  Test@4
  Test2@4 == Test22
  Test3@4 @8

> The C preprocessor treats @ as a single token on its own, so probably will
> not work properly. Can we concatenate an identifier with @ ? how should we
> ensure that CPP will not insert arbitrary space between them?

We are already using @@ fastcall chars in some msvcr*.def.in files which
are processed by the cpp preprocessor. So I think that having
kernel32.def.in for I386 should not be a problem.

Pasting @ with some other string via macro is a problem, I think I tried
this and gcc's cpp refused to do it.

> 
> > This could decrease the need to have more def files for the same library
> > (e.g. kernel32) and also maintenance of different variants of def files.
> 
> Well indeed, I don't disagree. The existent duplication is probably not
> good, however we don't know how to do that in a cleaner way, instead of a
> dirtier way.

I'm trying to come up with some idea, what why I started this
discussion. Maybe we figure out that it is not possible. And maybe we
come up with some solution.

I saw that Biswapriyo Nath changed more def files, so I thought that
could come up with some other idea...


I tried to call that sed on mingw-w64-crt/lib32/kernel32.def and its
output was similar to the content of mingw-w64-crt/lib-common/kernel32.def.in
file. So I think that it should work.

If we define all symbols with @STDCALL in lib-common/kernel32.def.in and
then for non-I386 archs filter it over that sed, then it could be usable.

> This is an example about the cost of evolution [1], and a mistake of someone 
> else [2].
> 
> [1] https://pmc.ncbi.nlm.nih.gov/articles/PMC430849/
> [2] https://devblogs.microsoft.com/oldnewthing/20060403-59/?p=31693


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to