Re: [Mingw-w64-public] [PATCH v4] ntoskrnl: Provide memcmp() on i386.

2019-01-23 Thread Jacek Caban

On 1/23/19 7:46 PM, Zebediah Figura wrote:

It is not exported from the DLL.

The implementation was copied and modified from wmemcmp.c in libmingwex.

v4: fix sign again, move to libntoskrnl



Looks good to me.


Thanks,

Jacek



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


[Mingw-w64-public] [PATCH v4] ntoskrnl: Provide memcmp() on i386.

2019-01-23 Thread Zebediah Figura
It is not exported from the DLL.

The implementation was copied and modified from wmemcmp.c in libmingwex.

v4: fix sign again, move to libntoskrnl
---
 mingw-w64-crt/Makefile.am |  6 ++
 mingw-w64-crt/libsrc/memcmp.c | 26 ++
 2 files changed, 32 insertions(+)
 create mode 100644 mingw-w64-crt/libsrc/memcmp.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 10f3b04c..c38816e6 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -111,6 +111,7 @@ src_libsapi=libsrc/sapi.c
 src_libsensorsapi=libsrc/sensorsapi.c
 src_libportabledeviceguids=libsrc/portabledeviceguids.c
 src_libtaskschd=libsrc/taskschd.c
+src_libntoskrnl=libsrc/memcmp.c
 
 src_libmingw32=include/oscalls.h include/internal.h include/sect_attribs.h \
   crt/crt0_c.ccrt/dll_argv.c  crt/gccmain.c crt/natstart.c  
crt/pseudo-reloc-list.c  crt/wildcard.c \
@@ -632,6 +633,11 @@ lib32_LIBRARIES += lib32/libtaskschd.a
 lib32_libtaskschd_a_SOURCES = $(src_libtaskschd)
 lib32_libtaskschd_a_CPPFLAGS=$(CPPFLAGS32) $(sysincludes)
 
+lib32_LIBRARIES += lib32/libntoskrnl.a
+lib32_libntoskrnl_a_SOURCES = $(src_libntoskrnl)
+lib32_libntoskrnl_a_CPPFLAGS=$(CPPFLAGS32) $(sysincludes)
+lib32_libntoskrnl_a_AR = $(DTLIB32) && $(AR) $(ARFLAGS)
+
 if !W32API
 lib32_LIBRARIES += lib32/libdelayimp.a
 lib32_libdelayimp_a_SOURCES =
diff --git a/mingw-w64-crt/libsrc/memcmp.c b/mingw-w64-crt/libsrc/memcmp.c
new file mode 100644
index ..11f5f9c9
--- /dev/null
+++ b/mingw-w64-crt/libsrc/memcmp.c
@@ -0,0 +1,26 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#define __CRT__NO_INLINE
+#include 
+
+int __cdecl memcmp(const void *_S1, const void *_S2, size_t _N)
+{
+const unsigned char *s1 = _S1, *s2 = _S2;
+
+if (_N == 0 || s1 == s2)
+   return 0;   /* even for NULL pointers */
+
+if ((s1 != NULL) != (s2 != NULL))
+   return s2 == NULL ? 1 : -1; /* robust */
+
+for ( ; 0 < _N; ++s1, ++s2, --_N)
+   if (*s1 != *s2)
+   return (*s1 < *s2 ? -1 : +1);
+
+return 0;
+}
+
-- 
2.20.1



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


Re: [Mingw-w64-public] [PATCH v3] memcmp: Add import library.

2019-01-23 Thread Zebediah Figura

On 1/23/19 6:10 AM, Jacek Caban wrote:

Hi Zebediah,

On 1/23/19 2:27 AM, Zebediah Figura wrote:

This provides memcmp() for x86 kernel-mode drivers, which for some reason is
not exported from ntoskrnl like other CRT functions.

The implementation was copied and modified from wmemcmp.c in libmingwex.

v3: fix types, restrict to i386



Do we really need a separated lib for this? We could provide that
implementation inside libntoskrnl.a like we do for compat code in
libmsvcr*.a. See stdio/acrt_iob_func.c for an example.


Thanks,

Jacek



Sure, I'll send a patch using that approach instead.


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


Re: [Mingw-w64-public] [PATCH v3] memcmp: Add import library.

2019-01-23 Thread Zebediah Figura

On 1/23/19 3:26 AM, Liu Hao wrote:

在 2019/1/23 9:27, Zebediah Figura 写道:

This provides memcmp() for x86 kernel-mode drivers, which for some reason is
not exported from ntoskrnl like other CRT functions.

The implementation was copied and modified from wmemcmp.c in libmingwex.

v3: fix types, restrict to i386
---



+
+int __cdecl memcmp(const void *_S1, const void *_S2, size_t _N)
+{
+const char *s1 = _S1, *s2 = _S2;
+


I have requested you use `unsigned char *` here or you will get
erroneous results because `char` is signed by default on Windows.



Sorry, will fix that (again...)


+if (_N == 0 || s1 == s2)
+   return 0;   /* even for NULL pointers */
+
+if ((s1 != NULL) != (s2 != NULL))
+   return s2 == NULL ? 1 : -1; /* robust */
+
+for ( ; 0 < _N; ++s1, ++s2, --_N)
+   if (*s1 != *s2)
+   return (*s1 < *s2 ? -1 : +1);
+
+return 0;
+}
+








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


Re: [Mingw-w64-public] [PATCH] headers: Remove C-compatibility parts from dwrite_2.h.

2019-01-23 Thread Nikolay Sivov
On Wed, Jan 23, 2019 at 3:34 PM Jacek Caban  wrote:

> On 1/16/19 2:32 PM, Nikolay Sivov wrote:
> > after it's decided where to go with this patch.
>
>
> FWIW, I don't have a strong opinion, but if supporting pure C is a
> matter of fixing just one struct that uses C++ inheritance, I'd just fix
> it.
>
>
I don't disagree. This structure is in dwrite_1.h, this patch is for
dwrite_2.h. Fixing this structure will help with dwrite_1.h only, because
newer headers have this overloading thing, in addition to structure
inheritance.


>
> Thanks,
>
> Jacek
>
>

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


Re: [Mingw-w64-public] [PATCH] headers: Remove C-compatibility parts from dwrite_2.h.

2019-01-23 Thread Jacek Caban

On 1/16/19 2:32 PM, Nikolay Sivov wrote:

after it's decided where to go with this patch.



FWIW, I don't have a strong opinion, but if supporting pure C is a 
matter of fixing just one struct that uses C++ inheritance, I'd just fix it.



Thanks,

Jacek



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


Re: [Mingw-w64-public] [PATCH v3] memcmp: Add import library.

2019-01-23 Thread Jacek Caban

Hi Zebediah,

On 1/23/19 2:27 AM, Zebediah Figura wrote:

This provides memcmp() for x86 kernel-mode drivers, which for some reason is
not exported from ntoskrnl like other CRT functions.

The implementation was copied and modified from wmemcmp.c in libmingwex.

v3: fix types, restrict to i386



Do we really need a separated lib for this? We could provide that 
implementation inside libntoskrnl.a like we do for compat code in 
libmsvcr*.a. See stdio/acrt_iob_func.c for an example.



Thanks,

Jacek



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


Re: [Mingw-w64-public] [PATCH v3] memcmp: Add import library.

2019-01-23 Thread Liu Hao
在 2019/1/23 9:27, Zebediah Figura 写道:
> This provides memcmp() for x86 kernel-mode drivers, which for some reason is
> not exported from ntoskrnl like other CRT functions.
> 
> The implementation was copied and modified from wmemcmp.c in libmingwex.
> 
> v3: fix types, restrict to i386
> ---

> +
> +int __cdecl memcmp(const void *_S1, const void *_S2, size_t _N)
> +{
> +const char *s1 = _S1, *s2 = _S2;
> +

I have requested you use `unsigned char *` here or you will get
erroneous results because `char` is signed by default on Windows.

> +if (_N == 0 || s1 == s2)
> + return 0;   /* even for NULL pointers */
> +
> +if ((s1 != NULL) != (s2 != NULL))
> + return s2 == NULL ? 1 : -1; /* robust */
> +
> +for ( ; 0 < _N; ++s1, ++s2, --_N)
> + if (*s1 != *s2)
> + return (*s1 < *s2 ? -1 : +1);
> +
> +return 0;
> +}
> +
> 


-- 
Best regards,
LH_Mouse



signature.asc
Description: OpenPGP digital signature
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] Mingw gcc8 plugin support issue

2019-01-23 Thread Labba LolyPop
hi,
i have successfully compiled the GCC 8.2.0 on msys2 on windows OS and this
is the output of the plugin command :

$ ./i386-elf-gcc.exe -print-file-name=plugin
/home/my_user/GCC_8.2.0/i386-elf/lib/gcc/i386-elf/8.2.0/plugin


ls -l /home/my_user/GCC_8.2.0/i386-elf/lib/gcc/i386-elf/8.2.0/plugin
total 3416
-rw-r--r-- 1 my_user Domain Users 1110819 Jan 22 17:43 gtype.state
drwxr-xr-x 1 my_user Domain Users   0 Jan 22 17:43 include
-rw-r--r-- 1 my_user Domain Users  832566 Jan 22 17:43 libcc1plugin.a
-rw-r--r-- 1 my_user Domain Users 958 Jan 22 17:43 libcc1plugin.la
-rw-r--r-- 1 my_user Domain Users 1440806 Jan 22 17:43 libcp1plugin.a
-rw-r--r-- 1 my_user Domain Users 958 Jan 22 17:43 libcp1plugin.la


when i have used a empty plugin source code i'm getting the following error:

/home/my_user/GCC_8.2.0/i386-elf/bin/i386-elf-g++.exe -std=c++11 -Wall
-fno-rtti -g3 -Wno-literal-suffix
-I/home/my_user/GCC_8.2.0/i386-elf/lib/gcc/i386-elf/8.2.0/plugin/include
-o EmptyPlugin.o  -c  EmptyPlugin.c

/home/my_user/GCC_8.2.0/i386-elf/lib/gcc/i386-elf/8.2.0/plugin/include/system.h:427:11:
fatal error: sys/mman.h: No such file or directory
 # include 
   ^~~~


if i add the Msys2 use/sys includes that is wrong since i get re-definition
of structs errors so what should be done here ?

-Shai

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