Declaration of crypt

Ken Brown
Thu Jun 9 14:07:00 GMT 2016

On 6/9/2016 8:32 AM, Corinna Vinschen wrote:
> Can you please define crypt, encrypt and setkey explicitely in unistd.h
> per POSIX, rather than including crypt.h?  This would not only be target
> independent, it would also be more correct.  As a side effect I will
> have to come up with a new version of the crypt package, because our
> crypt.h is using a wrong prototypes for setkey (const is missing).

setkey is supposed to be in stdlib.h rather than unistd.h, so I've done 

One minor question about encrypt: The Posix prototype has 'char 
block[64]' as the first argument, but Cygwin's crypt.h simply has 'char 
*block'.  FreeBSD and glibc also use 'char *block', so I did the same. 
Or would you rather follow Posix here?

> Thanks a lot and sorry again,

No problem.  Revised patch attached.


-------------- next part --------------
From e6ab8bbf44d1042df3dd9e989967a649523d193d Mon Sep 17 00:00:00 2001
From: Ken Brown <>
Date: Wed, 8 Jun 2016 17:04:06 -0400
Subject: [PATCH] Declare crypt, encrypt, and setkey per Posix

 newlib/libc/include/stdlib.h     | 3 +++
 newlib/libc/include/sys/unistd.h | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h
index 3194d6b..3d1b8a9 100644
--- a/newlib/libc/include/stdlib.h
+++ b/newlib/libc/include/stdlib.h
@@ -144,6 +144,9 @@ char *	_EXFUN(realpath, (const char *__restrict path, char *__restrict resolved_
 int	_EXFUN(rpmatch, (const char *response));
+_VOID	_EXFUN(setkey, (const char *__key));
 _VOID	_EXFUN(srand,(unsigned __seed));
 double	_EXFUN(strtod,(const char *__restrict __n, char **__restrict __end_PTR));
 double	_EXFUN(_strtod_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR));
diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
index ef00575..05b4f9d 100644
--- a/newlib/libc/include/sys/unistd.h
+++ b/newlib/libc/include/sys/unistd.h
@@ -31,6 +31,9 @@ int     _EXFUN(close, (int __fildes ));
 #if __POSIX_VISIBLE >= 199209
 size_t	_EXFUN(confstr, (int __name, char *__buf, size_t __len));
+char *  _EXFUN(crypt, (const char *__key, const char *__salt));
 #if __XSI_VISIBLE && __XSI_VISIBLE < 700
 char *  _EXFUN(ctermid, (char *__s ));
@@ -46,6 +49,9 @@ int     _EXFUN(dup2, (int __fildes, int __fildes2 ));
 int     _EXFUN(dup3, (int __fildes, int __fildes2, int flags));
 int	_EXFUN(eaccess, (const char *__path, int __mode));
+void	_EXFUN(encrypt, (char *__block, int __edflag));
 #if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
 void	_EXFUN(endusershell, (void));

More information about the Cygwin-patches mailing list