public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] bfd: Define func prototype for old mingw
@ 2022-08-15  8:49 Torbjörn SVENSSON
  2022-08-15 10:01 ` Luis Machado
  2022-08-16 14:18 ` Nick Clifton
  0 siblings, 2 replies; 5+ messages in thread
From: Torbjörn SVENSSON @ 2022-08-15  8:49 UTC (permalink / raw)
  To: binutils; +Cc: luis.machado, chigot, nickc, Torbjörn SVENSSON

In commit 68e80d96a84282d547f3b3c1234c99009521630c, the usage of
___lc_codepage_func was introduced to determine the current encoding.
Prior to version 9.0 of MinGW-w64, the function prototype for
___lc_codepage_func was missing and caused
error: implicit declaration of function ‘___lc_codepage_func’
when building.  This changeset adds a conditonal definition of
___lc_codepage_func to allow a sucessful build with MinGW-w64.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
 bfd/bfdio.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index a7c7d5bd363..59f79203b88 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -29,6 +29,11 @@
 #if defined (_WIN32)
 #include <windows.h>
 #include <locale.h>
+
+#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 9
+/* This prototype was added to locale.h in version 9.0 of MinaGW-w64.  */
+_CRTIMP unsigned int __cdecl ___lc_codepage_func(void);
+#endif
 #endif
 
 #ifndef S_IXUSR
-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] bfd: Define func prototype for old mingw
  2022-08-15  8:49 [PATCH] bfd: Define func prototype for old mingw Torbjörn SVENSSON
@ 2022-08-15 10:01 ` Luis Machado
  2022-08-15 10:19   ` Torbjorn SVENSSON
  2022-08-16 14:18 ` Nick Clifton
  1 sibling, 1 reply; 5+ messages in thread
From: Luis Machado @ 2022-08-15 10:01 UTC (permalink / raw)
  To: Torbjörn SVENSSON, binutils

Just some nits...
On 8/15/22 09:49, Torbjörn SVENSSON wrote:
> In commit 68e80d96a84282d547f3b3c1234c99009521630c, the usage of
> ___lc_codepage_func was introduced to determine the current encoding.
> Prior to version 9.0 of MinGW-w64, the function prototype for
> ___lc_codepage_func was missing and caused
> error: implicit declaration of function ‘___lc_codepage_func’
> when building.  This changeset adds a conditonal definition of
> ___lc_codepage_func to allow a sucessful build with MinGW-w64.

sucessful -> successful
> 
> Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
> ---
>   bfd/bfdio.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/bfd/bfdio.c b/bfd/bfdio.c
> index a7c7d5bd363..59f79203b88 100644
> --- a/bfd/bfdio.c
> +++ b/bfd/bfdio.c
> @@ -29,6 +29,11 @@
>   #if defined (_WIN32)
>   #include <windows.h>
>   #include <locale.h>
> +
> +#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 9
> +/* This prototype was added to locale.h in version 9.0 of MinaGW-w64.  */

MinaGW-w64 -> MinGW-w64
> +_CRTIMP unsigned int __cdecl ___lc_codepage_func(void);

I don't see any occurrences of CRTIMP in binutils-gdb. Should we not use that?

> +#endif
>   #endif
>   
>   #ifndef S_IXUSR


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] bfd: Define func prototype for old mingw
  2022-08-15 10:01 ` Luis Machado
@ 2022-08-15 10:19   ` Torbjorn SVENSSON
  0 siblings, 0 replies; 5+ messages in thread
From: Torbjorn SVENSSON @ 2022-08-15 10:19 UTC (permalink / raw)
  To: Luis Machado, binutils



On 2022-08-15 12:01, Luis Machado wrote:
> Just some nits...
> On 8/15/22 09:49, Torbjörn SVENSSON wrote:
>> In commit 68e80d96a84282d547f3b3c1234c99009521630c, the usage of
>> ___lc_codepage_func was introduced to determine the current encoding.
>> Prior to version 9.0 of MinGW-w64, the function prototype for
>> ___lc_codepage_func was missing and caused
>> error: implicit declaration of function ‘___lc_codepage_func’
>> when building.  This changeset adds a conditonal definition of
>> ___lc_codepage_func to allow a sucessful build with MinGW-w64.
> 
> sucessful -> successful
>>
>> Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
>> ---
>>   bfd/bfdio.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/bfd/bfdio.c b/bfd/bfdio.c
>> index a7c7d5bd363..59f79203b88 100644
>> --- a/bfd/bfdio.c
>> +++ b/bfd/bfdio.c
>> @@ -29,6 +29,11 @@
>>   #if defined (_WIN32)
>>   #include <windows.h>
>>   #include <locale.h>
>> +
>> +#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 9
>> +/* This prototype was added to locale.h in version 9.0 of 
>> MinaGW-w64.  */
> 
> MinaGW-w64 -> MinGW-w64
>> +_CRTIMP unsigned int __cdecl ___lc_codepage_func(void);
> 
> I don't see any occurrences of CRTIMP in binutils-gdb. Should we not use 
> that?

I'm not entirely sure if it's needed or not, but it's part of the 
official mingw definition at 
https://github.com/mirror/mingw-w64/blob/v9.0.0/mingw-w64-headers/crt/locale.h. 
 From what I can tell, the _CRTIMP will expand to __declspec(dllimport). 
When the prototype is defined with _CRTIMP, then the call will be made 
using the symbol __imp____lc_codepage_func instead of a direct function 
call. I'm guessing this is something similar to the .got table in ELF files.
Are there other function prototypes added in binutils code that is 
implemented in mingw?

> 
>> +#endif
>>   #endif
>>   #ifndef S_IXUSR
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] bfd: Define func prototype for old mingw
  2022-08-15  8:49 [PATCH] bfd: Define func prototype for old mingw Torbjörn SVENSSON
  2022-08-15 10:01 ` Luis Machado
@ 2022-08-16 14:18 ` Nick Clifton
  2022-08-16 17:09   ` Luis Machado
  1 sibling, 1 reply; 5+ messages in thread
From: Nick Clifton @ 2022-08-16 14:18 UTC (permalink / raw)
  To: Torbjörn SVENSSON, binutils

Hi Torbjörn,

> diff --git a/bfd/bfdio.c b/bfd/bfdio.c
> index a7c7d5bd363..59f79203b88 100644
> --- a/bfd/bfdio.c
> +++ b/bfd/bfdio.c
> @@ -29,6 +29,11 @@
>   #if defined (_WIN32)
>   #include <windows.h>
>   #include <locale.h>
> +
> +#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 9
> +/* This prototype was added to locale.h in version 9.0 of MinaGW-w64.  */
> +_CRTIMP unsigned int __cdecl ___lc_codepage_func(void);
> +#endif
>   #endif
>   
>   #ifndef S_IXUSR

Approved - please apply.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] bfd: Define func prototype for old mingw
  2022-08-16 14:18 ` Nick Clifton
@ 2022-08-16 17:09   ` Luis Machado
  0 siblings, 0 replies; 5+ messages in thread
From: Luis Machado @ 2022-08-16 17:09 UTC (permalink / raw)
  To: Nick Clifton, Torbjörn SVENSSON, binutils

On 8/16/22 15:18, Nick Clifton wrote:
> Hi Torbjörn,
> 
>> diff --git a/bfd/bfdio.c b/bfd/bfdio.c
>> index a7c7d5bd363..59f79203b88 100644
>> --- a/bfd/bfdio.c
>> +++ b/bfd/bfdio.c
>> @@ -29,6 +29,11 @@
>>   #if defined (_WIN32)
>>   #include <windows.h>
>>   #include <locale.h>
>> +
>> +#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 9
>> +/* This prototype was added to locale.h in version 9.0 of MinaGW-w64.  */
>> +_CRTIMP unsigned int __cdecl ___lc_codepage_func(void);
>> +#endif
>>   #endif
>>   #ifndef S_IXUSR
> 
> Approved - please apply.
> 
> Cheers
>    Nick
> 

Pushed on Torbjörn's behalf.

Thanks for the patch.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-16 17:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15  8:49 [PATCH] bfd: Define func prototype for old mingw Torbjörn SVENSSON
2022-08-15 10:01 ` Luis Machado
2022-08-15 10:19   ` Torbjorn SVENSSON
2022-08-16 14:18 ` Nick Clifton
2022-08-16 17:09   ` Luis Machado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).