2019-06-01  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* lib/stdio-impl.h [__DJGPP__]:  Include sys/file.h to provide _IOERR
	definition to be used in fseterr function.

	* tests/getprogname.c (getprogname) [__DJGPP__]:  Implementation of
	DJGPP support.

	* tests/test-errno.c [__DJGPP__]:  Exclude from test all errnos not
	supported by DJGPP.

	* tests/test-strerror.c (main) [__DJGPP__]:  Exclude ETIMEDOUT check.

	* tests/zerosize-ptr.h [MAP_PRIVATE]:  If not defined define MAP_PRIVATE.
	(zerosize_ptr) [__DJGPP__]:  Return always NULL pointer because DJGPP
	provides no mmap.

	* lib/stdint.in.h [__DJGPP__]:  For DJGPP, the typedef of gl_[u]int32_t
	must be signed long int as in stdint.h.

	* lib/stdint.mini.h [__DJGPP__]:  For DJGPP, the typedef of
	unistring_[u]int32_t must be signed long int as in stdint.h.








diff -aprNU5 libunistring-0.9.10.orig/lib/stdint.in.h libunistring-0.9.10/lib/stdint.in.h
--- libunistring-0.9.10.orig/lib/stdint.in.h	2018-05-25 16:02:10 +0000
+++ libunistring-0.9.10/lib/stdint.in.h	2019-06-02 18:36:38 +0000
@@ -169,12 +169,17 @@ typedef unsigned short int gl_uint16_t;
 # define int16_t gl_int16_t
 # define uint16_t gl_uint16_t
 
 # undef int32_t
 # undef uint32_t
+#if __DJGPP__
+typedef long int gl_int32_t;
+typedef unsigned long int gl_uint32_t;
+#else  /* !__DJGPP__ */
 typedef int gl_int32_t;
 typedef unsigned int gl_uint32_t;
+#endif /* !__DJGPP__ */
 # define int32_t gl_int32_t
 # define uint32_t gl_uint32_t
 
 /* If the system defines INT64_MAX, assume int64_t works.  That way,
    if the underlying platform defines int64_t to be a 64-bit long long
diff -aprNU5 libunistring-0.9.10.orig/lib/stdint.mini.h libunistring-0.9.10/lib/stdint.mini.h
--- libunistring-0.9.10.orig/lib/stdint.mini.h	2018-02-12 12:16:28 +0000
+++ libunistring-0.9.10/lib/stdint.mini.h	2019-06-02 19:28:38 +0000
@@ -110,12 +110,17 @@ typedef unsigned short int unistring_uin
 #define int16_t unistring_int16_t
 #define uint16_t unistring_uint16_t
 
 #undef int32_t
 #undef uint32_t
+#if __DJGPP__
+typedef long int unistring_int32_t;
+typedef unsigned long int unistring_uint32_t;
+#else  /* !__DJGPP__ */
 typedef int unistring_int32_t;
 typedef unsigned int unistring_uint32_t;
+#endif /* !__DJGPP__ */
 #define int32_t unistring_int32_t
 #define uint32_t unistring_uint32_t
 
 /* Avoid collision with Solaris 2.5.1 <pthread.h> etc.  */
 #define _UINT8_T
diff -aprNU5 libunistring-0.9.10.orig/lib/stdio-impl.h libunistring-0.9.10/lib/stdio-impl.h
--- libunistring-0.9.10.orig/lib/stdio-impl.h	2018-05-25 16:02:10 +0000
+++ libunistring-0.9.10/lib/stdio-impl.h	2019-06-02 17:12:28 +0000
@@ -37,10 +37,12 @@
 /* BSD stdio derived implementations.  */
 
 #if defined __NetBSD__                         /* NetBSD */
 /* Get __NetBSD_Version__.  */
 # include <sys/param.h>
+#elif defined __DJGPP__
+# include <libc/file.h>
 #endif
 
 #include <errno.h>                             /* For detecting Plan9.  */
 
 #if defined __sferror || defined __DragonFly__ || defined __ANDROID__
diff -aprNU5 libunistring-0.9.10.orig/tests/getprogname.c libunistring-0.9.10/tests/getprogname.c
--- libunistring-0.9.10.orig/tests/getprogname.c	2018-05-25 16:02:16 +0000
+++ libunistring-0.9.10/tests/getprogname.c	2019-06-02 17:12:28 +0000
@@ -49,10 +49,14 @@
 # include <stdio.h>
 # include <fcntl.h>
 # include <sys/procfs.h>
 #endif
 
+#ifdef __DJGPP__
+# include <crt0.h>
+#endif
+
 #include "dirname.h"
 
 #ifndef HAVE_GETPROGNAME             /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */
 char const *
 getprogname (void)
@@ -174,10 +178,12 @@ getprogname (void)
               return memcpy (namecopy, name, namelen);
             }
         }
     }
   return NULL;
+# elif __DJGPP__
+  return last_component (__crt0_argv ? __crt0_argv[0] : __dos_argv0);
 # else
 #  error "getprogname module not ported to this OS"
 # endif
 }
 
diff -aprNU5 libunistring-0.9.10.orig/tests/test-errno.c libunistring-0.9.10/tests/test-errno.c
--- libunistring-0.9.10.orig/tests/test-errno.c	2018-05-25 16:02:16 +0000
+++ libunistring-0.9.10/tests/test-errno.c	2019-06-02 17:12:28 +0000
@@ -32,11 +32,13 @@ int e6 = ENXIO;
 int e7 = E2BIG;
 int e8 = ENOEXEC;
 int e9 = EBADF;
 int e10 = ECHILD;
 int e11 = EAGAIN;
+#ifdef EWOULDBLOCK
 int e11a = EWOULDBLOCK;
+#endif
 int e12 = ENOMEM;
 int e13 = EACCES;
 int e14 = EFAULT;
 int e16 = EBUSY;
 int e17 = EEXIST;
@@ -46,11 +48,13 @@ int e20 = ENOTDIR;
 int e21 = EISDIR;
 int e22 = EINVAL;
 int e23 = ENFILE;
 int e24 = EMFILE;
 int e25 = ENOTTY;
+#ifdef ETXTBSY
 int e26 = ETXTBSY;
+#endif
 int e27 = EFBIG;
 int e28 = ENOSPC;
 int e29 = ESPIPE;
 int e30 = EROFS;
 int e31 = EMLINK;
@@ -69,10 +73,11 @@ int e67 = ENOLINK;
 int e71 = EPROTO;
 int e72 = EMULTIHOP;
 int e74 = EBADMSG;
 int e75 = EOVERFLOW;
 int e84 = EILSEQ;
+#ifndef DJGPP
 int e88 = ENOTSOCK;
 int e89 = EDESTADDRREQ;
 int e90 = EMSGSIZE;
 int e91 = EPROTOTYPE;
 int e92 = ENOPROTOOPT;
@@ -93,12 +98,15 @@ int e107 = ENOTCONN;
 int e110 = ETIMEDOUT;
 int e111 = ECONNREFUSED;
 int e113 = EHOSTUNREACH;
 int e114 = EALREADY;
 int e115 = EINPROGRESS;
+#endif
 int e116 = ESTALE;
+#ifdef EDQUOT
 int e122 = EDQUOT;
+#endif
 int e125 = ECANCELED;
 int e130 = EOWNERDEAD;
 int e131 = ENOTRECOVERABLE;
 
 /* Don't verify that these errno values are all different, except for possibly
diff -aprNU5 libunistring-0.9.10.orig/tests/test-strerror.c libunistring-0.9.10/tests/test-strerror.c
--- libunistring-0.9.10.orig/tests/test-strerror.c	2018-05-25 16:02:16 +0000
+++ libunistring-0.9.10/tests/test-strerror.c	2019-06-02 17:12:28 +0000
@@ -36,15 +36,17 @@ main (void)
   str = strerror (EACCES);
   ASSERT (str);
   ASSERT (*str);
   ASSERT (errno == 0);
 
+#ifdef ETIMEDOUT
   errno = 0;
   str = strerror (ETIMEDOUT);
   ASSERT (str);
   ASSERT (*str);
   ASSERT (errno == 0);
+#endif
 
   errno = 0;
   str = strerror (EOVERFLOW);
   ASSERT (str);
   ASSERT (*str);
diff -aprNU5 libunistring-0.9.10.orig/tests/zerosize-ptr.h libunistring-0.9.10/tests/zerosize-ptr.h
--- libunistring-0.9.10.orig/tests/zerosize-ptr.h	2018-05-25 16:02:18 +0000
+++ libunistring-0.9.10/tests/zerosize-ptr.h	2019-06-02 17:12:28 +0000
@@ -56,15 +56,18 @@
 static void *
 zerosize_ptr (void)
 {
 /* Use mmap and mprotect when they exist.  Don't test HAVE_MMAP, because it is
    not defined on HP-UX 11 (since it does not support MAP_FIXED).  */
-#if HAVE_SYS_MMAN_H && HAVE_MPROTECT
+#if HAVE_SYS_MMAN_H && HAVE_MPROTECT && !defined(__DJGPP__)
 # if HAVE_MAP_ANONYMOUS
   const int flags = MAP_ANONYMOUS | MAP_PRIVATE;
   const int fd = -1;
 # else /* !HAVE_MAP_ANONYMOUS */
+#  ifndef MAP_PRIVATE
+#   define MAP_PRIVATE  0
+#  endif
   const int flags = MAP_FILE | MAP_PRIVATE;
   int fd = open ("/dev/zero", O_RDONLY, 0666);
   if (fd >= 0)
 # endif
     {
