2016-12-31  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	Fix of all syntax errors.


	* src/pthread.c (pthread_suspend_np) [TDI_SUPPORT]: Issue SIGALRM only
	if TDI support 	available.

	* src/signal.c: (handle_one_signal): Compiler error: invalid storage
	class for function 'aio_handle' fixed.


2016-12-03  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* include/pthread.h: Replaced reserved word "__thread" by "___thread"
	as variable name.
	[!__DJGPP__]: Do not provide read and write prototypes when compiling
	with DJGPP.

	* src/pthread.c (pthread_body): Compiler error: invalid storage class
	for function 'pthread_terminate' and compiler error: static declaration
	of 'pthread_terminate' follows non-static declaration fixed.
	(pthread_init): Compiler warning: extra tokens at end of #endif directive
	[-Wendif-labels] fixed.


2016-12-02  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* include/pthread/dos_setjmp.h: Compiler warning: "/*" within comment
	[-Wcomment] fixed.

	* include/pthread/int_types.h: Compiler warning: "/*" within comment
	[-Wcomment] fixed.

	* include/pthread/signal-sol.h: Compiler warning: "/*" within comment
	[-Wcomment] fixed.

	* include/pthread/signal.h: Compiler warning: "/*" within comment
	[-Wcomment] fixed.

	* include/pthread/types.h: Compiler warning: "/*" within comment
	[-Wcomment] fixed.

	* src/config_header.c (main): Escape % character in printf format string.

	* src/get_offsets.c (main): Escape % character in printf format string.

	* src/queue.c: Compiler warning: "/*" within comment [-Wcomment] fixed.

	* src/sco/signal.h: Compiler warning: "/*" within comment [-Wcomment]
	fixed.

	* src/signal.c: Compiler warning: "/*" within comment [-Wcomment]
	fixed.

	* src/tdi-aux.c: Compiler warning: "/*" within comment [-Wcomment]
	fixed.

	* src/wait.c: Compiler warning: "/*" within comment [-Wcomment] fixed.

	* tdi/include/tdi.h: Compiler warning: "/*" within comment [-Wcomment]
	fixed.






diff -aprNU5 pthreads-3.14.orig/include/pthread/int_types.h pthreads-3.14/include/pthread/int_types.h
--- pthreads-3.14.orig/include/pthread/int_types.h	2000-11-08 13:29:34 +0000
+++ pthreads-3.14/include/pthread/int_types.h	2017-02-16 00:14:06 +0000
@@ -67,22 +67,22 @@ typedef signed char		int8_t;
 #endif
 typedef short			int16_t;
 typedef int			int32_t;
 #ifdef	_LP64
 typedef long			int64_t;
-#else /* /* _ILP32 */ */
+#else /* _ILP32 */
 #if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
 typedef	long long		int64_t;
 #endif
 #endif
 
 typedef unsigned char		uint8_t;
 typedef unsigned short		uint16_t;
 typedef unsigned int		uint32_t;
 #ifdef	_LP64
 typedef unsigned long		uint64_t;
-#else /* /* _ILP32 */ */
+#else /* _ILP32 */
 #if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
 typedef unsigned long long	uint64_t;
 #endif
 #endif
 
@@ -107,11 +107,11 @@ typedef uint32_t		uintmax_t;
 typedef long			intptr_t;
 typedef unsigned long		uintptr_t;
 #else
 typedef int			intptr_t;
 typedef unsigned int		uintptr_t;
-#endif /* /* _LP64 */ */
+#endif /* _LP64 */
 
 /*
  * The following define the smallest integer types that can hold the
  * specified number of bits.
  */
@@ -124,27 +124,27 @@ typedef signed char		int_least8_t;
 #endif
 typedef short			int_least16_t;
 typedef int			int_least32_t;
 #ifdef	_LP64
 typedef long			int_least64_t;
-#else /* /* _ILP32 */ */
+#else /* _ILP32 */
 #if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
 typedef long long		int_least64_t;
 #endif
 #endif
 
 typedef unsigned char		uint_least8_t;
 typedef unsigned short		uint_least16_t;
 typedef unsigned int		uint_least32_t;
 #ifdef	_LP64
 typedef unsigned long		uint_least64_t;
-#else /* /* _ILP32 */ */
+#else /* _ILP32 */
 #if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
 typedef unsigned long long	uint_least64_t;
 #endif
 #endif
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* /* _SYS_INT_TYPES_H */ */
+#endif /* _SYS_INT_TYPES_H */
diff -aprNU5 pthreads-3.14.orig/include/pthread/signal-sol.h pthreads-3.14/include/pthread/signal-sol.h
--- pthreads-3.14.orig/include/pthread/signal-sol.h	2000-11-08 13:29:34 +0000
+++ pthreads-3.14/include/pthread/signal-sol.h	2017-02-16 00:14:06 +0000
@@ -66,11 +66,11 @@ extern int sigfillset(sigset_t *);
 extern int sigismember(const sigset_t *, int);
 #endif
 extern int sigpending(sigset_t *);
 extern int sigprocmask(int, const sigset_t *, sigset_t *);
 extern int sigsuspend(const sigset_t *);
-#endif /* /* defined(__EXTENSIONS__) || __STDC__ == 0 ... */ */
+#endif /* defined(__EXTENSIONS__) || __STDC__ == 0 ... */
 
 #if defined(__EXTENSIONS__) || (__STDC__ == 0 && \
 	!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))
 #include <sys/procset.h>
 extern int gsignal(int);
@@ -78,11 +78,11 @@ extern int (*ssignal(int, int (*)(int)))
 extern int sigsend(idtype_t, id_t, int);
 extern int sigsendset(const procset_t *, int);
 extern int sig2str(int, char *);
 extern int str2sig(const char *, int *);
 #define	SIG2STR_MAX	32
-#endif /* /* defined(__EXTENSIONS__) || (__STDC__ == 0 ... */ */
+#endif /* defined(__EXTENSIONS__) || (__STDC__ == 0 ... */
 
 #if defined(__EXTENSIONS__) || (__STDC__ == 0 && \
 	!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
 	defined(_XPG4_2)
 extern void (*bsd_signal(int, void (*)(int)))(int);
@@ -93,11 +93,11 @@ extern int sighold(int);
 extern int sigignore(int);
 extern int sigpause(int);
 extern int sigrelse(int);
 extern void (*sigset(int, void (*)(int)))(int);
 extern int sigstack(struct sigstack *, struct sigstack *);
-#endif /* /* defined(__EXTENSIONS__) || (__STDC__ == 0 ... */ */
+#endif /* defined(__EXTENSIONS__) || (__STDC__ == 0 ... */
 
 #if defined(__EXTENSIONS__) || (__STDC__ == 0 && \
 	!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
 	(_POSIX_C_SOURCE > 2)
 #include <sys/siginfo.h>
@@ -107,13 +107,13 @@ extern int pthread_kill(pthread_t, int);
 #endif
 extern int pthread_sigmask(int, const sigset_t *, sigset_t *);
 extern int sigwaitinfo(const sigset_t *, siginfo_t *);
 extern int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *);
 extern int sigqueue(pid_t, int, const union sigval);
-#endif /* /* defined(__EXTENSIONS__) || (__STDC__ == 0 ... */ */
+#endif /* defined(__EXTENSIONS__) || (__STDC__ == 0 ... */
 
-#else /* /* __STDC__ */ */
+#else /* __STDC__ */
 
 extern char	**_sys_siglistp;	/* signal descriptions */
 extern int	_sys_siglistn;		/* # of signal descriptions */
 
 #define	_sys_siglist	_sys_siglistp
@@ -140,11 +140,11 @@ extern int sigsuspend();
 	defined(_XPG4_2)
 extern void (*bsd_signal())();
 extern int killpg();
 extern int siginterrupt();
 extern int sigstack();
-#endif /* /* defined(__EXTENSIONS__) ... */ */
+#endif /* defined(__EXTENSIONS__) ... */
 
 #if defined(__EXTENSIONS__) || \
 	(!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))
 extern int gsignal();
 extern int (*ssignal)();
@@ -176,11 +176,11 @@ extern int pthread_sigmask();
 extern int sigwaitinfo();
 extern int sigtimedwait();
 extern int sigqueue();
 #endif
 
-#endif /* /* __STDC__ */ */
+#endif /* __STDC__ */
 
 /*
  * sigwait() prototype is defined here.
  */
 
@@ -193,59 +193,59 @@ extern int sigqueue();
 #if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
 
 #ifdef __PRAGMA_REDEFINE_EXTNAME
 extern int sigwait(const sigset_t *, int *);
 #pragma redefine_extname sigwait __posix_sigwait
-#else /* /* __PRAGMA_REDEFINE_EXTNAME */ */
+#else /* __PRAGMA_REDEFINE_EXTNAME */
 
 static int
 sigwait(const sigset_t *__setp, int *__signo)
 {
 	extern int __posix_sigwait(const sigset_t *, int *);
 	return (__posix_sigwait(__setp, __signo));
 }
-#endif /* /* __PRAGMA_REDEFINE_EXTNAME */ */
+#endif /* __PRAGMA_REDEFINE_EXTNAME */
 
-#else /* /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ */
+#else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
 
 #ifndef SOLARIS_NP
 extern int sigwait(sigset_t *);
 #endif
 
-#endif /* /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ */
+#endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
 
 
-#else /* /* __STDC__ */ */
+#else /* __STDC__ */
 
 
 #if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
 
 #ifdef __PRAGMA_REDEFINE_EXTNAME
 extern int sigwait();
 #pragma redefine_extname sigwait __posix_sigwait
-#else /* /* __PRAGMA_REDEFINE_EXTNAME */ */
+#else /* __PRAGMA_REDEFINE_EXTNAME */
 
 static int
 sigwait(__setp, __signo)
 	sigset_t *__setp;
 	int *__signo;
 {
 	extern int __posix_sigwait();
 	return (__posix_sigwait(__setp, __signo));
 }
-#endif /* /* __PRAGMA_REDEFINE_EXTNAME */ */
+#endif /* __PRAGMA_REDEFINE_EXTNAME */
 
-#else /* /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ */
+#else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
 
 extern int sigwait();
 
-#endif /* /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ */
+#endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
 
-#endif /* /* __STDC__ */ */
+#endif /* __STDC__ */
 
-#endif /* /* defined(__EXTENSIONS__) || (__STDC__ == 0 ... */ */
+#endif /* defined(__EXTENSIONS__) || (__STDC__ == 0 ... */
 
 #ifdef	__cplusplus
 }
 #endif
 
-#endif /* /* _SIGNAL_H */ */
+#endif /* _SIGNAL_H */
diff -aprNU5 pthreads-3.14.orig/include/pthread/signal.h pthreads-3.14/include/pthread/signal.h
--- pthreads-3.14.orig/include/pthread/signal.h	2000-11-08 13:29:32 +0000
+++ pthreads-3.14/include/pthread/signal.h	2017-02-16 00:14:06 +0000
@@ -47,11 +47,11 @@ Report problems and direct all questions
 #define	_SIGVAL
 union sigval {
 	int	sival_int;	/* integer value */
 	void	*sival_ptr;	/* pointer value */
 };
-#endif /* /* _SIGVAL */ */
+#endif /* _SIGVAL */
 
 /* from <time.h>: */
 #ifndef	_SIGEVENT
 #define	_SIGEVENT
 struct sigevent {
@@ -64,11 +64,11 @@ struct sigevent {
 #else
 	pthread_attr_t	*sigev_notify_attributes;
 #endif
 	int		__sigev_pad2;
 };
-#endif /* /* _SIGEVENT */ */
+#endif /* _SIGEVENT */
 
 #define pthread_t int
 
 #endif
 
diff -aprNU5 pthreads-3.14.orig/include/pthread/types.h pthreads-3.14/include/pthread/types.h
--- pthreads-3.14.orig/include/pthread/types.h	2000-11-08 13:29:34 +0000
+++ pthreads-3.14/include/pthread/types.h	2017-02-16 00:14:06 +0000
@@ -41,13 +41,13 @@
 #define _FILE_OFFSET_BITS 32
 #endif
 #else
 #ifdef	_KERNEL
 #include <sys/inttypes.h>
-#else /* /* _KERNEL */ */
+#else /* _KERNEL */
 #include <sys/int_types.h>
-#endif /* /* _KERNEL */ */
+#endif /* _KERNEL */
 #endif
 
 #if defined(_KERNEL) || defined(_SYSCALL32)
 #include <sys/types32.h>
 #endif
@@ -72,11 +72,11 @@ typedef union {
 } longlong_t;
 typedef union {
 	double		_d;
 	uint32_t	_l[2];
 } u_longlong_t;
-#endif /* /* __STDC__ - 0 == 0 && !defined(_NO_LONGLONG) */ */
+#endif /* __STDC__ - 0 == 0 && !defined(_NO_LONGLONG) */
 
 /*
  * These types (t_{u}scalar_t) exist because the XTI/TPI/DLPI standards had
  * to use them instead of int32_t and uint32_t because DEC had
  * shipped 64-bit wide.
@@ -85,11 +85,11 @@ typedef union {
 typedef int32_t		t_scalar_t;
 typedef uint32_t	t_uscalar_t;
 #else
 typedef long		t_scalar_t;	/* historical versions */
 typedef unsigned long	t_uscalar_t;
-#endif /* /* defined(_LP64) || defined(_I32LPx) */ */
+#endif /* defined(_LP64) || defined(_I32LPx) */
 
 /*
  * POSIX Extensions
  */
 typedef	unsigned char	uchar_t;
@@ -150,13 +150,13 @@ typedef longlong_t	off_t;		/* offsets wi
 #ifdef _LP64
 typedef	off_t		off64_t;	/* offsets within files */
 #else
 typedef longlong_t	off64_t;	/* offsets within files */
 #endif
-#endif /* /* _LARGEFILE64_SOURCE */ */
+#endif /* _LARGEFILE64_SOURCE */
 
-#endif /* /* _OFF_T */ */
+#endif /* _OFF_T */
 
 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
 typedef ulong_t		ino_t;		/* expanded inode type	*/
 typedef long		blkcnt_t;	/* count of file blocks */
 typedef ulong_t		fsblkcnt_t;	/* count of file system blocks */
@@ -178,11 +178,11 @@ typedef	fsfilcnt_t	fsfilcnt64_t;	/* coun
 typedef u_longlong_t	ino64_t;	/* expanded inode type	*/
 typedef longlong_t	blkcnt64_t;	/* count of file blocks */
 typedef u_longlong_t	fsblkcnt64_t;	/* count of file system blocks */
 typedef u_longlong_t	fsfilcnt64_t;	/* count of files */
 #endif
-#endif /* /* _LARGEFILE64_SOURCE */ */
+#endif /* _LARGEFILE64_SOURCE */
 
 #ifdef _LP64
 typedef	int		blksize_t;	/* used for block sizes */
 #else
 typedef	long		blksize_t;	/* used for block sizes */
@@ -190,11 +190,11 @@ typedef	long		blksize_t;	/* used for blo
 
 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
 typedef enum { _B_FALSE, _B_TRUE } boolean_t;
 #else
 typedef enum { B_FALSE, B_TRUE } boolean_t;
-#endif /* /* defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) */ */
+#endif /* defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) */
 
 /*
  * The [u]pad64_t is to be used in structures such that those structures
  * may be accessed by code produced by compilation environments which don't
  * support a 64 bit integral datatype.  This intention is not to allow
@@ -291,11 +291,11 @@ typedef	long		id_t;		/* (historical vers
 typedef uint_t		useconds_t;	/* Time, in microseconds */
 
 #ifndef	_SUSECONDS_T
 #define	_SUSECONDS_T
 typedef long	suseconds_t;	/* signed # of microseconds */
-#endif /* /* _SUSECONDS_T */ */
+#endif /* _SUSECONDS_T */
 
 /*
  * Typedefs for dev_t components.
  */
 #if defined(_LP64) || defined(_I32LPx)
@@ -346,11 +346,11 @@ typedef	ulong_t	mode_t;			/* (historical
 #if defined(_LP64) || defined(_I32LPx)
 typedef	int	uid_t;			/* UID type		*/
 #else
 typedef	long	uid_t;			/* (historical version) */
 #endif
-#endif /* /* _UID_T */ */
+#endif /* _UID_T */
 
 typedef	uid_t	gid_t;			/* GID type		*/
 
 /*
  * POSIX definitions are same as defined in thread.h and synch.h.
@@ -451,40 +451,40 @@ typedef	long	pid_t;			/* (historical ver
 #if defined(_LP64) || defined(_I32LPx)
 typedef	ulong_t	size_t;		/* size of something in bytes */
 #else
 typedef	uint_t	size_t;		/* (historical version) */
 #endif
-#endif /* /* _SIZE_T */ */
+#endif /* _SIZE_T */
 
 #ifndef _SSIZE_T
 #define	_SSIZE_T
 #if defined(_LP64) || defined(_I32LPx)
 typedef long	ssize_t;	/* size of something in bytes or -1 */
 #else
 typedef int	ssize_t;	/* (historical version) */
 #endif
-#endif /* /* _SSIZE_T */ */
+#endif /* _SSIZE_T */
 
 #ifndef _TIME_T
 #define	_TIME_T
 typedef	long		time_t;	/* time of day in seconds */
-#endif /* /* _TIME_T */ */
+#endif /* _TIME_T */
 
 #ifndef _CLOCK_T
 #define	_CLOCK_T
 typedef	long		clock_t; /* relative time in a specified resolution */
-#endif /* /* ifndef _CLOCK_T */ */
+#endif /* ifndef _CLOCK_T */
 
 #ifndef _CLOCKID_T
 #define	_CLOCKID_T
 typedef	int	clockid_t;	/* clock identifier type */
-#endif /* /* ifndef _CLOCKID_T */ */
+#endif /* ifndef _CLOCKID_T */
 
 #ifndef _TIMER_T
 #define	_TIMER_T
 typedef	int	timer_t;	/* timer identifier type */
-#endif /* /* ifndef _TIMER_T */ */
+#endif /* ifndef _TIMER_T */
 
 #if defined(__EXTENSIONS__) || \
 	(!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))
 
 /* BEGIN CSTYLED */
@@ -507,18 +507,18 @@ typedef	unsigned long	ulong;
 					/* min value of a "long int" */
 #define	LONG_MAX	9223372036854775807L
 					/* max value of a "long int" */
 #define	ULONG_MAX	18446744073709551615UL
 					/* max of "unsigned long int" */
-#else /* /* _ILP32 */ */
+#else /* _ILP32 */
 #define	LONG_MIN	(-2147483647L-1L)
 					/* min value of a "long int" */
 #define	LONG_MAX	2147483647L	/* max value of a "long int" */
 #define	ULONG_MAX	4294967295UL	/* max of "unsigned long int" */
 #endif
 
-#endif /* /* defined(_KERNEL) */ */
+#endif /* defined(_KERNEL) */
 
 #define	P_MYPID	((pid_t)0)
 
 /*
  * The following is the value of type id_t to use to indicate the
@@ -530,12 +530,12 @@ typedef	unsigned long	ulong;
 
 #ifndef NODEV
 #define	NODEV	(dev_t)(-1l)
 #ifdef _SYSCALL32
 #define	NODEV32	(dev32_t)(-1)
-#endif /* /* _SYSCALL32 */ */
-#endif /* /* NODEV */ */
+#endif /* _SYSCALL32 */
+#endif /* NODEV */
 
 /*
  * The following value of type pfn_t is used to indicate
  * invalid page frame number.
  */
@@ -554,11 +554,11 @@ typedef quad_t		quad;			/* used by UFS *
  * Nested include for BSD/sockets source compatibility.
  * (The select macros used to be defined here).
  */
 #include <sys/select.h>
 
-#endif /* /* defined(__EXTENSIONS__) || (!defined(_POSIX_C_SOURCE) && ... */ */
+#endif /* defined(__EXTENSIONS__) || (!defined(_POSIX_C_SOURCE) && ... */
 
 /*
  * _VOID was defined to be either void or char but this is not
  * required because previous SunOS compilers have accepted the void
  * type. However, because many system header and source files use the
@@ -572,6 +572,6 @@ typedef quad_t		quad;			/* used by UFS *
 
 #ifdef	__cplusplus
 }
 #endif
 
-#endif /* /* _SYS_TYPES_H */ */
+#endif /* _SYS_TYPES_H */
diff -aprNU5 pthreads-3.14.orig/include/pthread.h pthreads-3.14/include/pthread.h
--- pthreads-3.14.orig/include/pthread.h	2000-11-08 13:29:08 +0000
+++ pthreads-3.14/include/pthread.h	2017-02-16 00:14:06 +0000
@@ -484,27 +484,27 @@ typedef struct pthread {
 extern "C" {
 #endif
  
 extern pthread_t pthread_self           _C_PROTOTYPE ((void));
 extern void pthread_init                _C_PROTOTYPE ((void));
-extern int pthread_create               _C_PROTOTYPE((pthread_t *__thread,
+extern int pthread_create               _C_PROTOTYPE((pthread_t *___thread,
                                                       pthread_attr_t *__attr,
                                                       pthread_func_t __func,
                                                       any_t __arg));
 extern int pthread_equal                _C_PROTOTYPE((pthread_t __t1,
                                                       pthread_t __t2));
-extern int pthread_detach               _C_PROTOTYPE((pthread_t __thread));
-extern int pthread_join                 _C_PROTOTYPE((pthread_t __thread,
+extern int pthread_detach               _C_PROTOTYPE((pthread_t ___thread));
+extern int pthread_join                 _C_PROTOTYPE((pthread_t ___thread,
                                                       any_t *__status));
 extern int sched_yield                  _C_PROTOTYPE((void));
 extern void pthread_exit                _C_PROTOTYPE((any_t __status));
 extern int pthread_attr_init            _C_PROTOTYPE((pthread_attr_t *__attr));
 extern int pthread_attr_destroy         _C_PROTOTYPE((pthread_attr_t *__attr));
-extern int pthread_getschedparam        _C_PROTOTYPE((pthread_t __thread,
+extern int pthread_getschedparam        _C_PROTOTYPE((pthread_t ___thread,
 						      int *__policy,
                                                       struct sched_param *__param));
-extern int pthread_setschedparam        _C_PROTOTYPE((pthread_t __thread,
+extern int pthread_setschedparam        _C_PROTOTYPE((pthread_t ___thread,
 						      int __policy,
                                                       struct sched_param *__param));
 extern int pthread_attr_setstacksize    _C_PROTOTYPE((pthread_attr_t *__attr,
                                                       size_t __stacksize));
 extern int pthread_attr_getstacksize    _C_PROTOTYPE((pthread_attr_t *__attr,
@@ -596,13 +596,13 @@ extern int pause               _C_PROTOT
 #endif
 #if defined(M_UNIX)
 #undef raise
 #endif
 extern int raise               _C_PROTOTYPE((int __sig));
-extern int pthread_kill        _C_PROTOTYPE((pthread_t __thread,
+extern int pthread_kill        _C_PROTOTYPE((pthread_t ___thread,
                                              int __sig));
-extern int pthread_cancel      _C_PROTOTYPE((pthread_t __thread));
+extern int pthread_cancel      _C_PROTOTYPE((pthread_t ___thread));
 extern int pthread_setcancelstate _C_PROTOTYPE((int __state, int *__oldstate));
 extern int pthread_setcanceltype  _C_PROTOTYPE((int __type, int *__oldtype));
 extern void pthread_testcancel _C_PROTOTYPE((void));
 extern int sigaction           _C_PROTOTYPE((int __sig,
                                              SIGACTION_CONST struct sigaction *__act,
@@ -657,16 +657,18 @@ extern void siglongjmp    _C_PROTOTYPE((
 
 /******************************/
 /*       I/O Functions        */
 /******************************/
 
+#if !defined(__DJGPP__)
 extern int read  _C_PROTOTYPE((int __fd,
                                void *__buf,
                                IO_SIZE_T __nbytes));
 extern int write _C_PROTOTYPE((int __fd,
                                const void *__buf,
                                IO_SIZE_T __nbytes));
+#endif  /* !__DJGPP__ */
 
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
 
diff -aprNU5 pthreads-3.14.orig/src/config_header.c pthreads-3.14/src/config_header.c
--- pthreads-3.14.orig/src/config_header.c	2000-11-08 13:28:42 +0000
+++ pthreads-3.14/src/config_header.c	2017-02-16 00:14:06 +0000
@@ -75,11 +75,11 @@ main(argc, argv)
   printf("\n");
   printf("Report problems and direct all questions to:\n");
   printf("\n");
   printf("  pthreads-bugs@ada.cs.fsu.edu\n");
   printf("\n");
-  printf("  %@(#)config_header.c	3.14% %11/8/00%\n");
+  printf("  %%@(#)config_header.c	3.14%% %%11/8/00%%\n");
   printf("*/\n");
   printf("\n");
 
   printf("/*\n");
   printf(" * configuration header file to identify compile options\n");
diff -aprNU5 pthreads-3.14.orig/src/dos/setjmp.s pthreads-3.14/src/dos/setjmp.s
--- pthreads-3.14.orig/src/dos/setjmp.s	2000-11-08 13:30:26 +0000
+++ pthreads-3.14/src/dos/setjmp.s	2017-02-16 00:14:06 +0000
@@ -131,11 +131,11 @@ NAME(pt_siglongjmp):
 NAME(pthread_siglongjmp):		/* (buffer, retval, restorefp) */
         pushl   %ebp
         movl    %esp,%ebp
         movl    8(%ebp),%eax		/* %eax = buffer pointer */
         cmpl    $0,24(%eax)
-        je      1f			/* if (buf[6]) {
+        je      1f			/* if (buf[6]) { */
         pushl   $0
         addl    $28,%eax
         pushl   %eax
         pushl   $0
         call    NAME(sigprocmask)	/*   sigprocmask(0, &buf[7], NULL) */
diff -aprNU5 pthreads-3.14.orig/src/get_offsets.c pthreads-3.14/src/get_offsets.c
--- pthreads-3.14.orig/src/get_offsets.c	2000-11-08 13:28:42 +0000
+++ pthreads-3.14/src/get_offsets.c	2017-02-16 00:14:06 +0000
@@ -71,11 +71,11 @@ main()
   printf("\n");
   printf("Report problems and direct all questions to:\n");
   printf("\n");
   printf("  pthreads-bugs@ada.cs.fsu.edu\n");
   printf("\n");
-  printf("  %@(#)get_offsets.c	2.6% %6/16/95%\n");
+  printf("  %%@(#)get_offsets.c	2.6%% %%6/16/95%%\n");
   printf("*/\n");
   printf("\n");
 
   printf("#if defined(LOCORE) || defined(_ASM)\n");
   
diff -aprNU5 pthreads-3.14.orig/src/pthread.c pthreads-3.14/src/pthread.c
--- pthreads-3.14.orig/src/pthread.c	2000-11-08 13:28:36 +0000
+++ pthreads-3.14/src/pthread.c	2017-02-17 20:52:24 +0000
@@ -135,11 +135,11 @@ void pthread_init()
 #ifdef MALLOC
 /*  extern int __malloc_initialized;*/
 #ifdef MALLOC_DEBUG
   pthread_malloc_debug_init();
 #endif
-#endif;
+#endif
 
 #ifdef SOLARIS
   /*
    * This dummy reference ensures that the initialization routine
    * is always linked.
@@ -247,10 +247,11 @@ void pthread_init()
     dsm_init(gnat_argc, gnat_argv);
   }
 #endif /* GNAT */
 }
 
+static void pthread_terminate(void);
 /*------------------------------------------------------------*/
 /*
  * pthread_body - base of the pthreads implementation.
  * Procedure invoked at the base of each pthread (as a wrapper).
  */
@@ -258,11 +259,10 @@ void pthread_body()
 {
   pthread_t t = mac_pthread_self();
 #ifdef REAL_TIME
   struct timespec tp;
 #endif /* REAL_TIME */
-  static void pthread_terminate();
 #ifdef DEBUG
 #ifdef STAND_ALONE
 pthread_timer_q_t pthread_timer;              /* timer queue                 */
 #else
 pthread_timer_q pthread_timer;                /* timer queue                 */
@@ -601,12 +601,14 @@ int pthread_suspend_np(t)
   }
 
   if (t->state & T_RUNNING) {
     pthread_pending_sigaction.func = pthread_suspend_internal;
     pthread_pending_sigaction.arg = t;
+#ifdef TDI_SUPPORT
     /* issue a SIGALRM to force a suspend on the current thread, if requested */
     __pthread_debug_TDI_ignored_signals |= 0x1 << (SIGALRM-1);
+#endif
   }
   else
     pthread_suspend_internal(t);
   CLEAR_KERNEL_FLAG;
   return(0);
diff -aprNU5 pthreads-3.14.orig/src/queue.c pthreads-3.14/src/queue.c
--- pthreads-3.14.orig/src/queue.c	2000-11-08 13:28:38 +0000
+++ pthreads-3.14/src/queue.c	2017-02-16 00:14:08 +0000
@@ -473,11 +473,11 @@ void pthread_q_timer_deq(q, t)
 
 #ifdef DEF_RR
   temp->thread->num_timers--;
 #ifdef MALLOC
   pthread_free(temp);
-#else /* /* !MALLOC */ */
+#else /* !MALLOC */
   free(temp);
 #endif
 #endif
 
 #ifdef TIMER_DEBUG
diff -aprNU5 pthreads-3.14.orig/src/sco/signal.h pthreads-3.14/src/sco/signal.h
--- pthreads-3.14.orig/src/sco/signal.h	2000-11-08 13:29:50 +0000
+++ pthreads-3.14/src/sco/signal.h	2017-02-16 00:14:08 +0000
@@ -46,7 +46,7 @@ extern int pthread_sigsuspend (const sig
 
 #ifdef __cplusplus
 };
 #endif 
 
-#endif /* /* !_SCO_SIGNAL_H_ */ */
+#endif /* !_SCO_SIGNAL_H_ */
 
diff -aprNU5 pthreads-3.14.orig/src/signal.c pthreads-3.14/src/signal.c
--- pthreads-3.14.orig/src/signal.c	2000-11-08 13:28:38 +0000
+++ pthreads-3.14/src/signal.c	2017-02-19 14:51:28 +0000
@@ -568,11 +568,13 @@ int code;
 {
   register pthread_t p = mac_pthread_self();
   struct itimerval it;
   struct timespec now;
   extern pthread_t pthread_q_all_find_receiver();
+#if defined(_M_UNIX)
   static int aio_handle();
+#endif
 
   /*
    * Determine who needs to get the signal (in the following order):
    * (1) signal directed at specific thread: take this thread
    * (2) signal at process level:
@@ -873,20 +875,20 @@ static void sighandler(sig, code, scp, a
   if (__pthread_debug_TDI_sig_ignore > 0) {
 #ifdef TDI_DEBUG   
     char out[100];
     sprintf(out,"ignore signal %d\n",sig);
     write(1,out,strlen(out));
-#endif /* /* TDI_DEBUG */ */
+#endif /* TDI_DEBUG */
     
     /* set the bit for this signal */
     __pthread_debug_TDI_ignored_signals |= 0x1<<(sig-1);
     
     /* we simply return :                                   *
      * - the debugger have to send the ignored signal again */
     return;
   }
-#endif /* /* TDI_SUPPORT */ */
+#endif /* TDI_SUPPORT */
 
   if (sig == SIGILL || sig == SIGBUS || sig == SIGSEGV) {
     if (p != NO_PTHREAD && !(p->state & T_LOCKED))
       default_action(sig);
 
@@ -970,20 +972,20 @@ static void sighandler(sig, code, scp, a
   if (__pthread_debug_TDI_sig_ignore > 0) {
 #ifdef TDI_DEBUG   
     char out[100];
     sprintf(out,"ignore signal %d\n",sig);
     write(1,out,strlen(out));
-#endif /* /* TDI_DEBUG */ */
+#endif /* TDI_DEBUG */
    
     /* set the bit for this signal */
     __pthread_debug_TDI_ignored_signals |= 0x1<<(sig-1);
 
     /* we simply return :                                   *
      * - the debugger have to send the ignored signal again */
     return;
   }
-#endif /* /* TDI_SUPPORT */ */
+#endif /* TDI_SUPPORT */
 
   if (sig == SIGSEGV)
     SCP_CODE = (int) SIG_ADDR;
 #endif /* __linux__ */
 
diff -aprNU5 pthreads-3.14.orig/src/tdi-aux.c pthreads-3.14/src/tdi-aux.c
--- pthreads-3.14.orig/src/tdi-aux.c	2000-11-08 13:28:38 +0000
+++ pthreads-3.14/src/tdi-aux.c	2017-02-16 00:14:08 +0000
@@ -552,6 +552,6 @@ TdiCondIsRegistered   (ObjRefT ObjRef) {
 ObjRefT 
 TdiGetFirstCond   () { TDI_GET_FIRST(ET_COND); }           
 
 ObjRefT 
 TdiGetNextCond    (ObjRefT last) { TDI_GET_NEXT(ET_COND,last); } 
-#endif /* /* TDI_SUPPORT */ */
+#endif /* TDI_SUPPORT */
diff -aprNU5 pthreads-3.14.orig/src/wait.c pthreads-3.14/src/wait.c
--- pthreads-3.14.orig/src/wait.c	2000-11-08 13:28:38 +0000
+++ pthreads-3.14/src/wait.c	2017-02-16 00:14:08 +0000
@@ -50,13 +50,13 @@ Report problems and direct all questions
   MACRO_BEGIN \
     if (*(int *) (pthread_get_sp() - pthread_page_size)) \
       pthread_access_dummy = 0; \
   MACRO_END
 
-#else /* /* !STACK_CHECK || !SIGNAL_STACK */ */
+#else /* !STACK_CHECK || !SIGNAL_STACK */
 #define ACCESS_STACK
-#endif /* /* !STACK_CHECK || !SIGNAL_STACK */ */
+#endif /* !STACK_CHECK || !SIGNAL_STACK */
 
 #if defined(SCO5)
 #include <sys/wait.h>
 
 /*-------------------------------------------------------------
@@ -172,6 +172,6 @@ pid_t wait3(int* status, int options, st
  */
 pid_t wait(int* status)
 {
 	return(waitpid((pid_t)-1, (int *)status, 0));
 }
-#endif /* /* SCO5 */ */
+#endif /* SCO5 */
diff -aprNU5 pthreads-3.14.orig/tdi/include/tdi.h pthreads-3.14/tdi/include/tdi.h
--- pthreads-3.14.orig/tdi/include/tdi.h	2000-11-08 13:30:32 +0000
+++ pthreads-3.14/tdi/include/tdi.h	2017-02-16 00:14:08 +0000
@@ -122,11 +122,11 @@ enum {
 		     * (i.e. FSU, MIT)                           */
   K2UL_MANY_TO_MANY /* a UL-thread can be asociated with one or  *
 		     * more kernel threads (i.e. Solaris threads)*/
 }; 
 
-#endif /* /* __tdi_h__ */ */
+#endif /* __tdi_h__ */
 
 
 
 
 



2017-02-15  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	Fix misc compiler warnings.


	* src/queue.c (pthread_q_timed_deq): Compiler warning: variable 'temp'
	set but not used fixed.

	* src/signal.c (pthread_clear_sighandler): Compiler warning: unused
	variable 'scp' fixed.
	(handle_one_signal): Compiler warning: unused variable 'now' fixed.
	(sighandler): Compiler warning: suggest explicit braces to avoid
	ambiguous 'else' fixed.
	(sigprocmask): Compiler warning: type defaults to 'int' in declaration
	of ... fixed.
	(pause): Compiler warning: unused variable 'sig' fixed.
	(pthread_cancel_timed_sigwait): Compiler warning: suggest explicit
	braces to avoid ambiguous 'else' fixed.
	(pthread_absnanosleep): Compiler warning: suggest parentheses around
	assignment used as truth value fixed.
	(nanosleep): Compiler warning: suggest parentheses around assignment
	used as truth value fixed.
	(sleep): Compiler warning: suggest parentheses around assignment used
	as truth value fixed.
	(SIGPROCMASK): Compiler warning: unused variable 'old'.
	(sigsuspend): Compiler warning: unused variable 'sig' fixed.
	(handle_one_signal): Compiler warning: suggest parentheses around &&
	within || fixed.

	* src/pthread.c (pthread_setschedparam): Compiler warning: variable
	'oldsched' set but not used fixed.


2017-01-03  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/queue.c (pthread_q_deq): Compiler warning: unused variable `tmr'
	and warning: unused variable `now' fixed.


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

	* src/disp.c: Include stdlib.h to provide exit and free prototypes.
	(pthread_fake_call_wrapper): Unused variable framep removed and
	explicit braces added to avoid ambiguous `else'.

	* src/queue.c (pthread_q_wakeup_all): Compiler warning: type of
	'index' defaults to 'int' [-Wimplicit-int] fixed.


2016-12-03  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/get_offsets.c: Include stdio.h to provide function prototypes.
	(main): int return type added to main definition.  Unused variable
	sigenv removed.

	* src/init.c: Compiler warning: type defaults to 'int' in declaration of
	'pthread_body' [-Wimplicit-int] fixed.

	* src/stack.c: Include stdlib.h to provide malloc prototype.


2016-12-02  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* include/pthread/dos_setjmp.h: Compiler warning: "setjmp" redefined
	fixed.

	* src/config_header.c: Include stdio.h and string.h to provide function
	prototypes.
	(main): int return type added to main definition.

	* src/pthread.c (pthread_init): Unused variable removed.
	(pthread_setschedparam): Unused variable removed.








diff -aprNU5 pthreads-3.14.orig/include/pthread/dos_setjmp.h pthreads-3.14/include/pthread/dos_setjmp.h
--- pthreads-3.14.orig/include/pthread/dos_setjmp.h	2000-11-08 13:29:36 +0000
+++ pthreads-3.14/include/pthread/dos_setjmp.h	2017-02-19 14:57:26 +0000
@@ -48,10 +48,14 @@ __BEGIN_DECLS
    names.  This is a potential sore spot if linked with binaries that do
    not include pthread.h! 
 
    These macros are also defined in src/dos/setjmp.S. */
 
+#undef setjmp
+#undef longjmp
+#undef sigsetjmp
+#undef siglongjmp
 #define setjmp pt_setjmp
 #define longjmp pt_longjmp
 #define sigsetjmp pt_sigsetjmp
 #define siglongjmp pt_siglongjmp
 
diff -aprNU5 pthreads-3.14.orig/src/config_header.c pthreads-3.14/src/config_header.c
--- pthreads-3.14.orig/src/config_header.c	2017-02-19 14:55:18 +0000
+++ pthreads-3.14/src/config_header.c	2017-02-19 14:57:26 +0000
@@ -28,10 +28,13 @@ Report problems and direct all questions
 
 /*
  * Create configuration header files depending on compile options
  */
 
+#include <stdio.h>
+#include <string.h>
+
 #ifdef INTERNALS
 #define PTHREAD_KERNEL
 #include "internals.h"
 #endif
 
@@ -42,17 +45,17 @@ Report problems and direct all questions
 
 #ifndef MIN
 #define MIN(x,y) (x < y ? x : y)
 #endif
 
-main(argc, argv)
+int main(argc, argv)
      int argc;
      char *argv[];
 {
   short local = (argv[1][0] == '-' && argv[1][1] == 'l');
   int release_index = (local ? 2 : 1);
-  short old_local;
+  short old_local = FALSE;
   short restore_local = FALSE;
 
   printf("/* Copyright (C) 1992, 1993, 1994, 1995, 1996 the Florida State University\n");
   printf("   Distributed by the Florida State University under the terms of the\n");
   printf("   GNU Library General Public License.\n");
diff -aprNU5 pthreads-3.14.orig/src/disp.c pthreads-3.14/src/disp.c
--- pthreads-3.14.orig/src/disp.c	2000-11-08 13:28:40 +0000
+++ pthreads-3.14/src/disp.c	2017-02-19 14:57:26 +0000
@@ -27,10 +27,12 @@ Report problems and direct all questions
 */
 
 #include "internals.h"
 #include "setjmp.h"
 
+#include <stdlib.h>
+
 static int old_stack_ptr;
 
 #if defined (__FreeBSD__) || defined (_M_UNIX) || defined(__linux__) || defined(__dos__)
 static SYS_SIGJMP_BUF stack_env;
 #else
@@ -402,11 +404,10 @@ void pthread_fake_call_wrapper(user_hand
      pthread_cond_t *cond;
 {
   register pthread_t p = mac_pthread_self();
   sigset_t omask;
   register int saved_errno = errno;
-  register struct frame *framep;
   register int old_pc = scp->sc_pc;
   register int old_sp = scp->sc_sp;
 #if defined (__FreeBSD__) || defined (_M_UNIX) || defined(__linux__) || defined (__dos__)
   register int old_bp = scp->sc_fp;
 #endif
@@ -476,21 +477,22 @@ void pthread_fake_call_wrapper(user_hand
     old_bp = p->context[JB_BP];
 #endif
     old_pc = p->context[JB_PC];
   }
 
-  if (pthread_signonemptyset(smask))
+  if (pthread_signonemptyset(smask)) {
     if (!SAVE_CONTEXT(p))
       pthread_handle_pending_signals_wrapper();
       /* never returns from call */
     else if (restore_context) {
       p->context[JB_SP] = old_sp;
 #if defined (__FreeBSD__) || defined (_M_UNIX) || defined(__linux__) || defined (__dos__)
       p->context[JB_BP] = old_bp;
 #endif
       p->context[JB_PC] = old_pc;
     }
+  }
 
   p->nscp = oscp;
 
   if (restore_context) {
     p->osp = new_sp;
diff -aprNU5 pthreads-3.14.orig/src/get_offsets.c pthreads-3.14/src/get_offsets.c
--- pthreads-3.14.orig/src/get_offsets.c	2017-02-19 14:55:18 +0000
+++ pthreads-3.14/src/get_offsets.c	2017-02-19 14:57:26 +0000
@@ -28,29 +28,34 @@ Report problems and direct all questions
 
 /* Writes the offsets (to be used in assembly code) to the file
  * "pthread_offsets.h".
  */
 
+#include <stdio.h>
+
 #define PTHREAD_KERNEL
 #include "internals.h"
 #include "setjmp.h"
 
-main()
+int main(void)
 {
   pthread_t p = NULL;
   jmp_buf env;
+#if 0
+/*  Superflous.  */
 #if defined (__FreeBSD__) || defined (_M_UNIX) || defined(__linux__) || defined (__dos__)
   SYS_SIGJMP_BUF sigenv;
 #else
   sigjmp_buf sigenv;
 #endif
+#endif
   pthread_mutex_t mutex;
   pthread_cleanup_t cleanup;
 #ifndef C_CONTEXT_SWITCH
   struct context_t *scp = NULL;
 #endif
-  
+
   printf("/* Copyright (C) 1992, 1993, 1994, 1995, 1996 the Florida State University\n");
   printf("   Distributed by the Florida State University under the terms of the\n");
   printf("   GNU Library General Public License.\n");
   printf("\n");
   printf("This file is part of Pthreads.\n");
@@ -145,14 +150,14 @@ main()
 #ifdef _POSIX_THREADS_PRIO_PROTECT
   printf("#define mutex_protocol %d\n", (int) &mutex.protocol - (int) &mutex);
 #endif
   
   /* Size of cleanup structure */
-  printf("#define cleanup_size %d\n", sizeof(*cleanup));
+  printf("#define cleanup_size %zd\n", sizeof(*cleanup));
 
   /* Size of sigset_t structure */
-  printf("#define sigset_t_size %d\n", sizeof(sigset_t));
+  printf("#define sigset_t_size %zd\n", sizeof(sigset_t));
 
   printf("#endif /* defined(LOCORE) || defined(_ASM) */\n");
 
   return(0);
 }
diff -aprNU5 pthreads-3.14.orig/src/init.c pthreads-3.14/src/init.c
--- pthreads-3.14.orig/src/init.c	2000-11-08 13:28:40 +0000
+++ pthreads-3.14/src/init.c	2017-02-19 14:57:26 +0000
@@ -41,11 +41,11 @@ Report problems and direct all questions
  */
 #define PARAM_OFFSET 0+2*sizeof(sigset_t)
 
 #endif /* !C_CONTEXT_SWITCH */
 
-extern pthread_body();
+extern void pthread_body(void);
 #ifdef STACK_CHECK
 extern int pthread_page_size;
 #endif
 
 extern pthread_cond_t *new_cond[NNSIG];     /* cond for user handlers         */
diff -aprNU5 pthreads-3.14.orig/src/pthread.c pthreads-3.14/src/pthread.c
--- pthreads-3.14.orig/src/pthread.c	2017-02-19 14:55:18 +0000
+++ pthreads-3.14/src/pthread.c	2017-02-19 14:57:26 +0000
@@ -124,11 +124,10 @@ void pthread_init(void) __attribute__ ((
 #endif
 
 void pthread_init()
 {
   pthread_t t;
-  int i;
 #if defined (__FreeBSD__) || defined (_M_UNIX) || defined(__linux__) || defined (__dos__)
   SYS_SIGJMP_BUF env;
 #else
   sigjmp_buf env;
 #endif
@@ -898,13 +897,15 @@ int pthread_getschedparam(thread, policy
 int pthread_setschedparam(thread, policy, param)
      pthread_t thread;
      int policy;
      struct sched_param *param;
 {
-  pthread_t p = mac_pthread_self();
   pthread_queue_t q;
-  int oldsched, run_prio;
+#ifdef DEF_RR
+  int oldsched;
+#endif
+  int run_prio;
 
   if (thread == NO_PTHREAD) 
     return(ESRCH);
 
   if (!param)
@@ -934,11 +935,13 @@ int pthread_setschedparam(thread, policy
   if (thread->state & T_RETURNED) {
     CLEAR_KERNEL_FLAG;
     return(EINVAL);
   }
 
+#ifdef DEF_RR
   oldsched = thread->attr.sched;
+#endif
   thread->attr.sched = policy;
 #ifdef DEF_RR
   if (policy != oldsched && p == thread)
     switch (oldsched) {
     case SCHED_FIFO:
diff -aprNU5 pthreads-3.14.orig/src/queue.c pthreads-3.14/src/queue.c
--- pthreads-3.14.orig/src/queue.c	2017-02-19 14:55:18 +0000
+++ pthreads-3.14/src/queue.c	2017-02-19 14:57:26 +0000
@@ -300,12 +300,14 @@ void pthread_q_deq(q, t, index)
      pthread_t t;
      int index;
 {
   pthread_t prev = NO_PTHREAD;
   pthread_t next = q->head;
+#ifdef DEF_RR
   timer_ent_t tmr;
   struct timeval now;
+#endif
 
   while (next != NO_PTHREAD && next != t) {
     prev = next;
     next = next->next[index];
   }
@@ -390,12 +392,14 @@ pthread_t t;
  */
 void pthread_q_timed_deq(q, t)
 	pthread_timer_q_t q;
 	pthread_t t;
 {
-  timer_ent_t temp, prev = NO_TIMER;
-  timer_ent_t next = q->head;
+#ifdef DEF_RR
+  timer_ent_t temp;
+#endif
+  timer_ent_t next = q->head, prev = NO_TIMER;
  
 #ifdef DEF_RR
   while (next != NO_TIMER && next->thread != t) {
 #else
   while (next != NO_TIMER && next != t) {
@@ -409,11 +413,13 @@ void pthread_q_timed_deq(q, t)
     fprintf(stderr, "pthread_q_timed_deq(thread %x) failed\n", t);
 #endif
     return;
   }
  
+#ifdef DEF_RR
   temp = next;
+#endif
   if ((next = next->next[TIMER_QUEUE]) == NO_TIMER)
     q->tail = prev;
  
   if (prev == NO_TIMER)
     q->head = next;
@@ -637,10 +643,11 @@ void pthread_q_wakeup(q, index)
  * return pointer to thread if thread found in queue, NO_PTHREAD otherwise
  */
 void pthread_q_wakeup_thread(q, p, index)
      pthread_queue_t q;
      pthread_t p;
+     int index;
 {
   if (q != NO_QUEUE)
     pthread_q_deq(q, p, index);
 
   if (p != NO_PTHREAD && !(p->state & T_RUNNING)) {
@@ -676,10 +683,11 @@ void pthread_q_timed_wakeup_thread(q, p,
  * change.  See pthread_q_wakeup.
  * Assumes SET_KERNEL_FLAG
  */
 void pthread_q_wakeup_all(q, index)
      pthread_queue_t q;
+     int index;
 {
   pthread_t p;
   
   while ((p = pthread_q_deq_head(q, index)) != NO_PTHREAD)
     if (!(p->state & T_RUNNING)) {
diff -aprNU5 pthreads-3.14.orig/src/signal.c pthreads-3.14/src/signal.c
--- pthreads-3.14.orig/src/signal.c	2017-02-19 14:55:18 +0000
+++ pthreads-3.14/src/signal.c	2017-02-19 14:58:34 +0000
@@ -374,11 +374,13 @@ static void default_action(sig)
 static int handle_thread_signal(p, sig, code)
 pthread_t p;
 int sig;
 int code;
 {
+#ifndef C_CONTEXT_SWITCH
   register struct context_t *scp;
+#endif
 #if defined(IO) && defined(_M_UNIX) && defined(USE_POLL)
   static int aio_calculate();
 #endif
 #ifdef C_CONTEXT_SWITCH
   extern void pthread_fake_call_wrapper_wrapper();
@@ -566,11 +568,13 @@ static void handle_one_signal(sig, code)
 int sig;
 int code;
 {
   register pthread_t p = mac_pthread_self();
   struct itimerval it;
+#ifdef STAND_ALONE
   struct timespec now;
+#endif
   extern pthread_t pthread_q_all_find_receiver();
 #if defined(_M_UNIX)
   static int aio_handle();
 #endif
 
@@ -675,12 +679,12 @@ int code;
    * Pend signal on thread if it's masked out OR
    * if the signal is SIGCANCEL, the interrupt state CONTROLLED, and
    * we are not at an interruption point.
    */
   if (sigismember(&p->mask, sig) ||
-      sig == SIGCANCEL &&
-      p->state & T_CONTROLLED && !(p->state & T_INTR_POINT)) {
+      (sig == SIGCANCEL &&
+       p->state & T_CONTROLLED && !(p->state & T_INTR_POINT))) {
     sigaddset(&p->pending, sig);
     p->sig_info[sig].si_code = code;
     return;
   }
 
@@ -1011,11 +1015,11 @@ static void sighandler(sig, code, scp, a
 #endif
     fprintf(stderr, "signal %d caught\n", sig);
 #endif
 #endif
 
-  if (!sigismember(&new_signals, sig) && pthread_started)
+  if (!sigismember(&new_signals, sig) && pthread_started) {
 #if (defined(_M_UNIX) && !defined(SCO5)) || defined(__linux__) || defined(__dos__)
     if (!is_in_kernel) {
 #else
     if (!is_in_kernel && scp) {
 #endif
@@ -1069,10 +1073,11 @@ static void sighandler(sig, code, scp, a
 #else
       new_scp[sig] = scp;
 #endif
       state_change = TRUE;
     }
+  }
 #ifdef SVR4
   /*
    * Solaris does not seem to have a _sigtramp() wrapper for signal handlers.
    * In fact, it is not quite understood how the signal mask is reset after
    * returning from the signal handler. This is fixed by explicitly setting
@@ -1360,11 +1365,11 @@ int how;
 SIGPROCMASK_CONST sigset_t *set;
 sigset_t *oset;
 {
   sigset_t new, old, pending;
   register pthread_t p = mac_pthread_self();
-  register already_in_kernel = is_in_kernel;
+  register int already_in_kernel = is_in_kernel;
 
 #if defined(SOLARIS) && defined(IO)
   if (pthread_get_retaddr() < 0) /* call from dynamic library */
     return(pthread_p_sigprocmask(how, set, oset));
 #endif /* SOLARIS && IO */
@@ -1462,11 +1467,10 @@ sigset_t *set;
  * Notice: cannot mask SIGKILL, SIGSTOP
  */
 int sigsuspend(set)
 SIGSUSPEND_CONST sigset_t *set;
 {
-  register int sig;
   sigset_t old, pending;
   register pthread_t p = mac_pthread_self();
 
   if (!set) {
     set_errno(EINVAL);
@@ -1513,11 +1517,10 @@ SIGSUSPEND_CONST sigset_t *set;
  * pause - suspend thread until any signal is caught,
  * same as sigsuspend except that the signal mask doesn't change
  */
 int pause()
 {
-  register int sig;
   register pthread_t p = mac_pthread_self();
 
   SET_KERNEL_FLAG;
   pthread_sigcpyset2set(&p->sigwaitset, &p->mask);
   
@@ -1902,23 +1905,24 @@ int pthread_cancel_timed_sigwait(first_p
       tmr = NO_TIMER;
 
     /*
      * check if head of timer queue can be woken up, i.e. now > tmr->tp
      */
-    if (tmr == NO_TIMER && !time_read)
+    if (tmr == NO_TIMER && !time_read) {
 #else
-    if (!time_read)
+    if (!time_read) {
 #endif
       if (gettimeofday(&now, (struct timezone *) NULL)) {
 #ifdef TIMER_DEBUG
         fprintf(stderr, "pthread_cancel_timed_sigwait: exit1\n");
 #endif
         set_errno(EINVAL);
 	return(-1);
       }
       else
         time_read = TRUE;
+    }
 
     if (time_read) {
       tmr = pthread_timer.head;
 #ifdef DEF_RR
       if (tmr)
@@ -2438,15 +2442,15 @@ const struct timespec *rqtp;
 #else /* !STAND_ALONE */
       if (gettimeofday(&now, (struct timezone *) NULL))
         return(EINVAL);
 
 #ifdef DEF_RR
-      if (tmr = pthread_timer.head) {
+      if ((tmr = pthread_timer.head)) {
         while (tmr->thread != p)
           tmr = tmr->next[TIMER_QUEUE];
 #else
-      if (tmr = p) {
+      if ((tmr = p)) {
 #endif
     
         if (GT_TIME(tmr->tp, now)) {
           MINUS_TIME(now, tmr->tp, now);
           U2P_TIME((rmtp), now);
@@ -2521,15 +2525,15 @@ struct timespec *rmtp;
       set_errno(EINVAL);
       return(-1);
     }
 
 #ifdef DEF_RR
-    if (tmr = pthread_timer.head) {
+    if ((tmr = pthread_timer.head)) {
       while (tmr->thread != p)
         tmr = tmr->next[TIMER_QUEUE];
 #else
-    if (tmr = p) {
+    if ((tmr = p)) {
 #endif
       if (GT_TIME(tmr->tp, now)) {
         if (rmtp) {
           MINUS_TIME(now, tmr->tp, now);
           U2P_TIME((*rmtp), now);
@@ -2550,11 +2554,11 @@ struct timespec *rmtp;
 unsigned int sleep(seconds)
 unsigned int seconds;
 {
   struct timespec rqtp, rmtp;
 
-  if (rqtp.ts_sec = seconds) {
+  if ((rqtp.ts_sec = seconds)) {
     rqtp.ts_nsec = 0;
     nanosleep(&rqtp, &rmtp);
     if (get_errno() == EINTR)
       return(rmtp.ts_sec + (rmtp.ts_nsec ? 1 : 0)); /* pessimistic round-up */
   }
@@ -3313,11 +3317,10 @@ const sigset_t *set;
 sigset_t *oset;
 {
 #ifdef SVR4
   return(syscall(SYS_sigprocmask, how, set, oset));
 #else /* !SVR4 */
-  sigset_t old;
 
 #ifndef STAND_ALONE
 #if defined (__FreeBSD__) || defined (_M_UNIX) || defined(__linux__) || defined (__dos__)
   SYS_SIGPROCMASK (how, NULL, &proc_mask);
 #else
diff -aprNU5 pthreads-3.14.orig/src/stack.c pthreads-3.14/src/stack.c
--- pthreads-3.14.orig/src/stack.c	2000-11-08 13:28:38 +0000
+++ pthreads-3.14/src/stack.c	2017-02-19 14:57:28 +0000
@@ -32,10 +32,14 @@ Report problems and direct all questions
  */
 
 #include "internals.h"
 #include <sys/resource.h>
 
+#ifndef MALLOC
+#include <malloc.h>
+#endif
+
 #if !defined (_M_UNIX) || defined(SCO5)
 #include <sys/mman.h>
 #endif
 
 #ifdef __FreeBSD__
@@ -88,11 +92,13 @@ void pthread_stack_init(p)
 pthread_t p;
 {
 #ifndef __dos__
   struct rlimit rlim;
 #endif
+#if defined(MALLOC) || defined(STAND_ALONE)
   extern int pthread_started;
+#endif /* MALLOC || STAND_ALONE */
   
 #if defined(STACK_CHECK) && !defined(STAND_ALONE)
   pthread_page_size = (int) GETPAGESIZE(_SC_PAGESIZE);
 #endif
 



2017-02-18  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	Implementation of DJGPP specific support.

	* src/config_header.c (main) [INTERNALS, __DJGPP__]: __gnuc_extension__
	defined depending on the gcc version used.
	Macro __sigset_t_is_struct__ defined to allow to select version of
	functions that accept sigset_t as struct instead of int.

	* src/internals.h [__dos__]: Compiler warning: operation on 'errno' may
	be undefined [-Wsequence-point] fixed by reemplementing SAVE_CONTEXT
	macro.

	* src/signal.c [__sigset_t_is_struct__]: Functions pthread_sigcpyset2set,
	pthread_sigaddset2set, pthread_sigdelset2set, pthread_sigismemberset2set,
	pthread_signonemptyset, pthread_siggeset2set and pthread_sigeqset2set
	reimplemented to support sigset_t defined as struct instead of int.
	pthread_signalcpyset2set implemented as replacement for pthread_sigcpyset2set.

	* src/disp.c (pthread_fake_call_wrapper_wrapper): Use pthread_signalcpyset2set
	instead of pthread_sigcpyset2set where appropriate.


2017-02-17  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/Makefile.DOS: Added prototypes.h to file list to be removed.

	* src/config_header.c (main) [INTERNALS]: Generate file prototypes.h to
	provide function prototypes.

	* src/cond.c: Include prototypes.h.

	* src/disp.c: Include prototypes.h.

	* src/mutex.c: Include prototypes.h.

	* src/pthread.c: Include prototypes.h.

	* src/signal.c: Include prototypes.h.


2017-02-16  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* include/pthread/signal.h [__dos__]: For DJGPP include sys/version.h.
	For DJGPP 2.05 define the struct context_t as __jmp_buf from setjmp.h.

	* src/config_header.c (main) [INTERNALS]: For DJGPP include sys/version.h


2016-12-31  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/Makefile.DOS: Fix install target so that products can be
	installed in arbitrary directories.


2016-12-02  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/Makefile.DOS:  Various DJGPP specific adjustments like:
	EXEEXT definition, SHELL definition, prefix definition, installation
	paths prefixed by $prefix and copy replaced by cp.
	Added -fgnu89-inline -march=i386 -mtune=i586 to the CFLAGS.
	PINC variable used instead of hard coded backslash path.








diff -aprNU5 pthreads-3.14.orig/include/pthread/signal.h pthreads-3.14/include/pthread/signal.h
--- pthreads-3.14.orig/include/pthread/signal.h	2017-02-19 15:00:54 +0000
+++ pthreads-3.14/include/pthread/signal.h	2017-02-19 15:14:06 +0000
@@ -243,10 +243,16 @@ struct context_t {
 #define siginfo p_siginfo
 typedef struct siginfo siginfo_t;
 #elif defined(__dos__)
 #include <setjmp.h>
 
+#ifdef __DJGPP__
+#include <sys/version.h>
+#endif
+#if __DJGPP__ >= 2 && __DJGPP_MINOR__ >= 5
+#define context_t __jmp_buf
+#else
 /* Hate to do it, but since the dj include files don't define this
    in such a way that I can get to it, I have to repeat the definition
    here.  This is subject to change with new releases of djgpp; let the
    buyer beware. */
 
@@ -256,10 +262,11 @@ struct context_t {
   unsigned short __cs, __ds, __es, __fs, __gs, __ss;
   unsigned long __sigmask; /* for POSIX signals only */
   unsigned long __signum; /* for expansion */
   unsigned char __fpu_state[108]; /* for future use */
 };
+#endif
 
 #define sc_sp   __esp
 #define sc_fp   __ebp
 #define sc_pc   __eip
 #define sc_ps   __eflags
diff -aprNU5 pthreads-3.14.orig/src/cond.c pthreads-3.14/src/cond.c
--- pthreads-3.14.orig/src/cond.c	2000-11-08 13:28:38 +0000
+++ pthreads-3.14/src/cond.c	2017-02-19 15:14:06 +0000
@@ -42,10 +42,14 @@ Report problems and direct all questions
 #define NOERR_CHECK
 #else
 #include "mutex.h"
 #endif
 
+/* To provide the required function prototypes.  */
+#include "prototypes.h"
+
+
 /*------------------------------------------------------------*/
 /*
  * pthread_cond_destroy - Destroys the condition variable.
  * 
  */
diff -aprNU5 pthreads-3.14.orig/src/config_header.c pthreads-3.14/src/config_header.c
--- pthreads-3.14.orig/src/config_header.c	2017-02-19 15:00:58 +0000
+++ pthreads-3.14/src/config_header.c	2017-02-19 16:25:20 +0000
@@ -128,10 +128,116 @@ int main(argc, argv)
     printf("#define PTHREAD_SIGSET_T_SIZE_NP %d\n", sigset_t_size);
     printf("#define PTHREAD_SIGCONTEXT_MASK_T_SIZE_NP %d\n",
 	   sigcontext_mask_t_size);
     printf("#define PTHREAD_SIGSET2SET_SIZE_NP %d\n",
 	   MIN(sigset_t_size, sigcontext_mask_t_size));
+
+#ifdef __DJGPP__
+    printf("\n"
+           "/*  gcc no longer includes this by default.  */\n"
+           "#include <sys/version.h>\n"
+           "\n"
+           "#if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))\n"
+           "# define __gnuc_extension__  __extension__\n"
+           "#else\n"
+           "# define __gnuc_extension__\n"
+           "#endif\n"
+           "\n"
+           "/*\n"
+           " *  DJGPP's sigset_t is a struct with an\n"
+           " *  unsigned lont int array member with 10 elements.\n"
+           " *  Thus it cannot be assumed that it is int and\n"
+           " *  all functions assuming pointer of int must be\n"
+           " *  re-written for pointer of struct.\n"
+           " */\n"
+           "#define __sigset_t_is_struct__\n"
+           "#define BITS __bits\n"
+           "\n");
+#endif
+
+    {
+      FILE *f = fopen("prototypes.h", "w");
+      if (f)
+      {
+        fprintf(f, "/*\n"
+                   " *  Generated by config_header to provide function prototypes.\n"
+                   " */\n"
+                   "\n"
+                   "\n"
+                   "#ifndef _function_prototypes_h\n"
+                   "#define _function_prototypes_h\n"
+                   "\n"
+                   "/*  From cond.c.  */\n"
+                   "void pthread_cond_wait_terminate(pthread_cond_t *_cond);\n"
+                   "\n"
+                   "/*  From disp.c.  */\n"
+                   "void pthread_handle_pending_signals_wrapper(void);\n"
+                   "int pthread_not_called_from_sighandler(int _addr);\n"
+                   "void pthread_process_exit(int _status);\n"
+                   "void pthread_sched(void);\n"
+                   "pthread_t pthread_sched_new_signals(pthread_t _p, int _masked);\n"
+                   "#ifdef C_CONTEXT_SWITCH\n"
+                   "void pthread_sched_wrapper(int _sig, int _code, pthread_t _p);\n"
+                   "#else /* !C_CONTEXT_SWITCH */\n"
+                   "void pthread_sched_wrapper(int _sig, int _code);\n"
+                   "#endif /* !C_CONTEXT_SWITCH */\n"
+                   "void pthread_signal_sched(int _sig, int _code);\n"
+                   "\n"
+                   "/*  From init.c.  */\n"
+                   "void pthread_initialize(pthread_t _t);\n"
+                   "\n"
+                   "/*  From signal.c.  */\n"
+                   "int pthread_cancel_timed_sigwait(pthread_t _first_p, int _signaled, int _mode, int _activate);\n"
+                   "void pthread_clear_sighandler(void);\n"
+                   "void pthread_handle_pending_signals(void);\n"
+                   "void pthread_handle_one_process_signal(int _sig, int _code);\n"
+                   "void pthread_init_signals(void);\n"
+                   "#ifdef __sigset_t_is_struct__\n"
+                   "int pthread_signonemptyset(volatile sigset_t *_set);\n"
+                   "int pthread_siggeset2set(volatile sigset_t *_dst, volatile sigset_t *_src);\n"
+                   "void pthread_sigaddset2set(volatile sigset_t *_dst, volatile sigset_t *_src);\n"
+                   "void pthread_sigcpyset2set(volatile sigset_t *_dst, volatile sigset_t *_src);\n"
+                   "void pthread_sigdelset2set(volatile sigset_t *_dst, volatile sigset_t *_src);\n"
+                   "void pthread_signalcpyset2set(unsigned long *_dst, unsigned long *_src);\n"
+                   "#else /* !__sigset_t_is_struct__ */\n"
+                   "int pthread_signonemptyset(int *_set);\n"
+                   "int pthread_siggeset2set(int *_dst, int *_src);\n"
+                   "void pthread_sigaddset2set(int *_dst, int *_src);\n"
+                   "void pthread_sigcpyset2set(int *_dst, int *_src);\n"
+                   "void pthread_sigdelset2set(int *_dst, int *_src);\n"
+                   "#endif /* !__sigset_t_is_struct__ */\n"
+                   "int pthread_timed_sigwait(pthread_t _p, struct timespec *_timeout, int _mode, pthread_func_t _func, any_t _arg);\n"
+                   "\n"
+                   "/*  From stack.c.  */\n"
+                   "int pthread_alloc_stack(pthread_t _p);\n"
+                   "void pthread_stack_init(pthread_t _p);\n"
+                   "\n"
+                   "/*  From queue.c.  */\n"
+                   "void pthread_mutex_q_adjust(pthread_t _p);\n"
+                   "void pthread_q_all_enq(pthread_queue_t _q, pthread_t _t);\n"
+                   "void pthread_q_deq(pthread_queue_t _q, pthread_t _t, int _index);\n"
+                   "void pthread_q_primary_enq(pthread_queue_t _q, pthread_t _t);\n"
+                   "void pthread_q_primary_enq_first(pthread_queue_t _q, pthread_t _t);\n"
+                   "void pthread_q_sleep(pthread_queue_t _q, int _index);\n"
+                   "void pthread_q_sleep_thread(pthread_queue_t _q, pthread_t _p, int _index);\n"
+                   "#ifdef STAND_ALONE\n"
+                   "void pthread_q_timed_enq(pthread_timer_q_t *_q, pthread_t _p);\n"
+                   "#else /* !STAND_ALONE */\n"
+                   "int pthread_q_timed_enq(pthread_timer_q_t _q, struct timeval _in, int _mode, pthread_t _p);\n"
+                   "#endif /* STAND_ALONE */\n"
+                   "void pthread_q_timed_wakeup_thread(pthread_timer_q_t q, pthread_t p, int activate);\n"
+                   "void pthread_q_wakeup(pthread_queue_t _q, int _index);\n"
+                   "void pthread_q_wakeup_all(pthread_queue_t _q, int _index);\n"
+                   "void pthread_q_wakeup_thread(pthread_queue_t _q, pthread_t _p, int _index);\n"
+                   "pthread_t pthread_q_deq_head(pthread_queue_t _q, int _index);\n"
+                   "\n"
+                   "#endif /*  _function_prototypes_h  */\n");
+        fclose(f);
+      }
+      else
+        return(1);
+    }
   }
 #endif
 
   return(0);
 }
diff -aprNU5 pthreads-3.14.orig/src/disp.c pthreads-3.14/src/disp.c
--- pthreads-3.14.orig/src/disp.c	2017-02-19 15:00:58 +0000
+++ pthreads-3.14/src/disp.c	2017-02-19 16:16:18 +0000
@@ -27,10 +27,14 @@ Report problems and direct all questions
 */
 
 #include "internals.h"
 #include "setjmp.h"
 
+/* To provide the required function prototypes.  */
+#include "prototypes.h"
+
+
 #include <stdlib.h>
 
 static int old_stack_ptr;
 
 #if defined (__FreeBSD__) || defined (_M_UNIX) || defined(__linux__) || defined(__dos__)
@@ -318,11 +322,15 @@ void pthread_fake_call_wrapper_wrapper()
 #endif
   if (new_context) {
 #if defined(SCO5)
     getcontext(&scp);
 #endif
+#ifdef __sigset_t_is_struct__
+    pthread_signalcpyset2set(&scp.sc_mask, (unsigned long *)&(p->mask.BITS[0]));
+#else /* !__sigset_t_is_struct__ */
     pthread_sigcpyset2set(&scp.sc_mask, &p->mask);
+#endif /* !__sigset_t_is_struct__ */
     scp.sc_sp = p->osp;
 #if defined (__FreeBSD__) || defined (_M_UNIX) || defined(__linux__) || defined(__dos__)
     scp.sc_fp = p->obp;
 #endif
     scp.sc_pc = p->opc;
@@ -417,11 +425,15 @@ void pthread_fake_call_wrapper(user_hand
   register int new_bp = p->obp;
 #endif
 
   void pthread_handle_pending_signals_wrapper();
 
+#ifdef __sigset_t_is_struct__
+  pthread_signalcpyset2set((unsigned long *)&(omask.BITS[0]), &scp->sc_mask);
+#else /* !__sigset_t_is_struct__ */
   pthread_sigcpyset2set(&omask, &scp->sc_mask);
+#endif /* !__sigset_t_is_struct__ */
 
   if (cond)
     pthread_cond_wait_terminate(cond);
 
   CLEAR_KERNEL_FLAG;
@@ -454,15 +466,24 @@ void pthread_fake_call_wrapper(user_hand
       p->context[JB_PC] = scp->sc_pc;
     }
 #ifdef ASM_SETJMP
     p->context[JB_PC] -= RETURN_OFFSET;
 #endif /* ASM_SETMP */
+#ifdef __sigset_t_is_struct__
+    pthread_signalcpyset2set(smask->BITS, &scp->sc_mask);
+#else /* !__sigset_t_is_struct__ */
     pthread_sigcpyset2set(smask, &scp->sc_mask);
+#endif /* !__sigset_t_is_struct__ */
   }
   else {
+#ifdef __sigset_t_is_struct__
+    pthread_signalcpyset2set(smask->BITS, &scp->sc_mask);
+    pthread_signalcpyset2set(&scp->sc_mask, (unsigned long *)&(omask.BITS[0]));
+#else /* !__sigset_t_is_struct__ */
     pthread_sigcpyset2set(smask, &scp->sc_mask);
     pthread_sigcpyset2set(&scp->sc_mask, &omask);
+#endif /* !__sigset_t_is_struct__ */
   }
 
   pthread_sigcpyset2set(&p->mask, smask);
 
   pthread_sigcpyset2set(smask, &p->pending);
diff -aprNU5 pthreads-3.14.orig/src/internals.h pthreads-3.14/src/internals.h
--- pthreads-3.14.orig/src/internals.h	2000-11-08 13:28:36 +0000
+++ pthreads-3.14/src/internals.h	2017-02-19 15:14:06 +0000
@@ -328,14 +328,26 @@ extern int errno;
 
 /*
  * context switching macros, implemented via setjmp/longjmp plus saving errno
  */
 #if defined (__FreeBSD__) || defined (_M_UNIX) || defined(__linux__) || defined (__dos__)
+#ifdef __DJGPP__
+# define SAVE_CONTEXT(t)                             \
+  (__gnuc_extension__                                \
+    ({                                               \
+       int orig_errno = errno;                       \
+       (((t)->terrno = errno) == errno &&            \
+        SYS_SIGSETJMP((t)->context, FALSE, TRUE) &&  \
+        (errno = (t)->terrno) == orig_errno);        \
+    })                                               \
+  )
+#else /* !__DJGPP__ */
 #define SAVE_CONTEXT(t) \
   (((t)->terrno = errno) == errno && \
    SYS_SIGSETJMP((t)->context, FALSE, TRUE) && \
    (errno = (t)->terrno) == errno)
+#endif /* !__DJGPP__ */
 
 #define RESTORE_CONTEXT(t) SYS_SIGLONGJMP((t)->context, TRUE, TRUE)
 #else
 #define SAVE_CONTEXT(t) \
   (((t)->terrno = errno) == errno && \
diff -aprNU5 pthreads-3.14.orig/src/Makefile.DOS pthreads-3.14/src/Makefile.DOS
--- pthreads-3.14.orig/src/Makefile.DOS	2000-11-08 13:28:40 +0000
+++ pthreads-3.14/src/Makefile.DOS	2017-02-19 15:14:06 +0000
@@ -91,10 +91,16 @@
 #			BSD (Berkley) UNIX is assumed (currently SunOS 4.1.x).
 #TIMER_DEBUG:		dump out trace information for SIGALRM signals and timer
 #VME_ICACHE_OFF:	turn I-cache off (only w/ STAND_ALONE and sun4m)
 #VME_DCACHE_OFF:	turn D-cache off (only w/ STAND_ALONE and sun4m)
 
+SHELL=/bin/sh
+
+EXEEXT=.exe
+
+DEPS=_dep
+
 #include directory location
 INCS = ../include
 PINC = $(INCS)/pthread
 INC1 = -I$(INCS)
 INC2 = 
@@ -102,12 +108,13 @@ INC2 =
 #for cross-compilation
 #INC2 = -I/home/midasusr/include
 #INC2 = -I/sim/usr/include
 
 #install directory locations
-INSTALL_INCLUDE = /usr/local/include
-INSTALL_LIBS = /usr/local/lib
+prefix=/dev/env/DJDIR
+INSTALL_INCLUDE = $(prefix)/include
+INSTALL_LIBS = $(prefix)/lib
 #for Logware
 #INSTALL_INCLUDE = /usr/contrib/include
 #INSTALL_LIBS = /usr/contrib/lib
 
 FBSD_ASM_INC =
@@ -136,10 +143,18 @@ FBSD_ASM_INC =
 #Linux / SCO port flags
 #CFLAGS =  -DC_CONTEXT_SWITCH -DCLEANUP_HEAP -D_POSIX -DAUTO_INIT
 
 #MS-DOS under DJGPP2 flags
 CFLAGS = -DC_CONTEXT_SWITCH -DCLEANUP_HEAP -D_POSIX -D__dos__
+#Certain debug flags for gcc version greater than 3.4.6
+#CFLAGS += -fgnu89-inline -march=i386
+#CFLAGS += -fgnu89-inline -march=i386 -mtune=i586 -save-temps
+#CFLAGS += -fgnu89-inline -march=i386 -mtune=i586 -Wall -pedantic -save-temps
+#Certain debug flags for gcc version less than 3.4.6
+CFLAGS += -march=i386 -mtune=i586
+#CFLAGS += -march=i386 -mtune=i586 -save-temps
+#CFLAGS += -march=i386 -mtune=i586 -Wall -pedantic -save-temps
 
 #FreeBSD port flags
 #CFLAGS =  -DC_CONTEXT_SWITCH -DCLEANUP_HEAP -D_POSIX -DSTACK_CHECK -DAUTO_INIT
 #FBSD_ASM_INC = -I$(INCS)/../src/freebsd
 
@@ -265,52 +280,55 @@ p_aux.o: p_aux.S $(PINC)/asm.h \
 
 opt.o: opt.S $(PINC)/asm.h \
 		offsets.h $(HDR0) Makefile
 	$(COMP_ASM)
 
-offsets.h: get_offsets
-	get_offsets > offsets.h
+offsets.h: get_offsets$(EXEEXT)
+	./get_offsets$(EXEEXT) > offsets.h
 
-get_offsets: get_offsets.c $(DEP1) setjmp.h
-	$(CC) $(INC1) $(INC2) $(CCFLAGS) -o $@ $@.c
+get_offsets$(EXEEXT): get_offsets.c $(DEP1) setjmp.h
+	$(CC) $(INC1) $(INC2) $(CCFLAGS) -o $@ $<
 
-$(PINC)/config.h: config_header Makefile
-	config_header -D`uname -r | sed "s/\.//g"` $(CCFLAGS) > ..\include\pthread\config.h
+$(PINC)/config.h: config_header$(EXEEXT) Makefile
+	./config_header$(EXEEXT) -D`uname -r | sed "s/\.//g"` $(CCFLAGS) > $(PINC)/config.h
 
 #	csh const.csh >> $@
 
-config_internals.h: config_header2 Makefile
-	./config_header2 -l -D`uname -r | sed "s/\.//"` $(CCFLAGS) > $@
+config_internals.h: config_header2$(EXEEXT) Makefile
+	./config_header2$(EXEEXT) -l -D`uname -r | sed "s/\.//"` $(CCFLAGS) > $@
 
-config_header: config_header.c Makefile
-	$(CC) $(INC1) $(INC2) $(CCFLAGS) $(CCIFLAGS) -o $@ $@.c
+config_header$(EXEEXT): config_header.c Makefile
+	$(CC) $(INC1) $(INC2) $(CCFLAGS) $(CCIFLAGS) -o $@ $<
 
-config_header2: config_header.c Makefile
-	copy $(PINC)config.h config_internals.h
+config_header2$(EXEEXT): config_header.c Makefile
+	cp -f $(PINC)/config.h config_internals.h
 	$(CC) $(INC1) $(INC2) $(CCFLAGS) -DINTERNALS -o $@ $<
-	del config_internals.h
+	rm -f config_internals.h
 
 ifneq ($(MAKECMDGOALS),clean)
--include .dep
+-include $(DEPS)
 endif
 
-.dep: $(HDR0) offsets.h Makefile
-	$(CC) -M $(INC1) $(INC2) $(CFLAGS) *.c *.S > .dep
+$(DEPS): $(HDR0) offsets.h Makefile
+	$(CC) -M $(INC1) $(INC2) $(CFLAGS) *.c *.S > $(DEPS)
 
 
 install:
-	copy $(INCS)/*.h $(INSTALL_INCLUDE)
 	if ( test ! -d $(INSTALL_INCLUDE)/pthread ) ; then \
-	  mkdir $(INSTALL_INCLUDE)/pthread ; \
+	  mkdir -p $(INSTALL_INCLUDE)/pthread ; \
+	fi ;
+	cp -vf $(INCS)/*.h $(INSTALL_INCLUDE)
+	cp -vf $(INCS)/pthread/*.h $(INSTALL_INCLUDE)/pthread
+	if ( test ! -d $(INSTALL_LIBS) ) ; then \
+	  mkdir -p $(INSTALL_LIBS) ; \
 	fi ;
-	copy $(INCS)/pthread/*.h $(INSTALL_INCLUDE)/pthread
-	copy $(LIBS) $(INSTALL_LIBS)
+	cp -vf $(LIBS) $(INSTALL_LIBS)
 
 lint:
 	lint $(LINTFLAGS) $(CSRC)
 
 llib:
 	lint $(LINTFLAGS) -Cthreads $(SRCS)
 
 clean:
-	-rm -f $(LIBS) a.out core errs *.o *.EXE *.BAK *.CKP config_internals.h $(PINC)/config.h config_header config_header2 offsets.h get_offsets *~ #* .dep
+	-rm -f $(LIBS) a.out core errs *.o *.BAK *.CKP prototypes.h config_internals.h $(PINC)/config.h config_header$(EXEEXT) config_header2$(EXEEXT) offsets.h get_offsets *~ #* .dep
 	cd ../malloc; $(MAKE) clean
diff -aprNU5 pthreads-3.14.orig/src/mutex.c pthreads-3.14/src/mutex.c
--- pthreads-3.14.orig/src/mutex.c	2000-11-08 13:28:38 +0000
+++ pthreads-3.14/src/mutex.c	2017-02-19 15:14:06 +0000
@@ -35,10 +35,14 @@ Report problems and direct all questions
 #include "mutex.h"
 #ifdef TDI_SUPPORT
 #include "tdi-aux.h"
 #endif
 
+/* To provide the required function prototypes.  */
+#include "prototypes.h"
+
+
 /*------------------------------------------------------------*/
 /*
  * pthread_mutex_lock - Checks are made to see if the mutex is 
  * currently in use or not.  If the mutex is not in use, then its 
  * locked. Otherwise the currently executing thread is put in the 
diff -aprNU5 pthreads-3.14.orig/src/pthread.c pthreads-3.14/src/pthread.c
--- pthreads-3.14.orig/src/pthread.c	2017-02-19 15:00:58 +0000
+++ pthreads-3.14/src/pthread.c	2017-02-19 15:14:06 +0000
@@ -41,10 +41,14 @@ Report problems and direct all questions
 #include "tdi-aux.h"
 #include "tdi-dl.h"
 #endif
 #include <pthread/asm.h>
 
+/* To provide the required function prototypes.  */
+#include "prototypes.h"
+
+
 #ifdef STAND_ALONE
 extern struct pthread tcb[MAX_THREADS];
 #endif
 
 volatile int pthread_started = FALSE;
diff -aprNU5 pthreads-3.14.orig/src/signal.c pthreads-3.14/src/signal.c
--- pthreads-3.14.orig/src/signal.c	2017-02-19 15:00:58 +0000
+++ pthreads-3.14/src/signal.c	2017-02-19 16:27:10 +0000
@@ -47,10 +47,14 @@ Report problems and direct all questions
 #include "offsets.h"
 #ifdef TDI_SUPPORT
 #include "tdi-aux.h"
 #endif
 
+/* To provide the required function prototypes.  */
+#include "prototypes.h"
+
+
 #if !defined (_M_UNIX) && !defined (__dos__)
 #include <sys/syscall.h>
 #endif
 
 #if defined(__FreeBSD__)
@@ -156,10 +160,143 @@ pthread_cond_t *new_cond[NNSIG];
 struct context_t *new_scp[NNSIG];             /* info for user handlers      */
 static int pending_code[NNSIG];               /* UNIX signal code (pending)  */
 static sigset_t synchronous;                  /* set of synchronous signals  */
 static sigset_t sig_handling;                 /* set of signals being handled*/
 
+#ifdef __sigset_t_is_struct__
+/*------------------------------------------------------------*/
+/*
+ * pthread_sigcpyset2set - add a signal set to another one
+ */
+void pthread_sigcpyset2set(dst, src)
+volatile sigset_t *dst, *src;
+{
+  volatile unsigned long *dst_bits = dst->BITS;
+  volatile unsigned long *src_bits = src->BITS;
+  int i;
+
+  for (i = 0; i < PTHREAD_SIGSET2SET_SIZE_NP; i += sizeof(unsigned long))
+    *(dst_bits++) = *(src_bits++);
+}
+
+/*------------------------------------------------------------*/
+/*
+ * pthread_sigaddset2set - add a signal set to another one
+ */
+void pthread_sigaddset2set(dst, src)
+volatile sigset_t *dst, *src;
+{
+  volatile unsigned long *dst_bits = dst->BITS;
+  volatile unsigned long *src_bits = src->BITS;
+  int i;
+
+  for (i = 0; i < PTHREAD_SIGSET2SET_SIZE_NP; i += sizeof(unsigned long))
+    *(dst_bits++) |= *(src_bits++);
+}
+
+/*------------------------------------------------------------*/
+/*
+ * pthread_sigdelset2set - delete a signal set from another one
+ */
+void pthread_sigdelset2set(dst, src)
+volatile sigset_t *dst, *src;
+{
+  volatile unsigned long *dst_bits = dst->BITS;
+  volatile unsigned long *src_bits = src->BITS;
+  int i;
+
+  for (i = 0; i < PTHREAD_SIGSET2SET_SIZE_NP; i += sizeof(unsigned long))
+    *(dst_bits++) &= ~(*(src_bits++));
+}
+
+/*------------------------------------------------------------*/
+/*
+ * pthread_sigismemberset2set - check if two sets overlap
+ */
+int pthread_sigismemberset2set(dst, src)
+volatile sigset_t *dst, *src;
+{
+  volatile unsigned long *dst_bits = dst->BITS;
+  volatile unsigned long *src_bits = src->BITS;
+  int i;
+
+  for (i = 0; i < PTHREAD_SIGSET2SET_SIZE_NP; i += sizeof(unsigned long))
+    if (*(dst_bits++) & *(src_bits++))
+      return(TRUE);
+
+  return(FALSE);
+}
+
+/*------------------------------------------------------------*/
+/*
+ * pthread_signonemptyset - check if a set has any bits set
+ */
+int pthread_signonemptyset(set)
+volatile sigset_t *set;
+{
+  volatile unsigned long *set_bits = set->BITS;
+  int i;
+
+  for (i = 0; i < PTHREAD_SIGSET2SET_SIZE_NP; i += sizeof(unsigned long))
+    if (*(set_bits++))
+      return(TRUE);
+
+  return(FALSE);
+}
+
+/*------------------------------------------------------------*/
+/*
+ * pthread_siggeset2set - check if dst set is >= src set, i.e.
+ * dst has at least the bits set which src has set
+ */
+int pthread_siggeset2set(dst, src)
+volatile sigset_t *dst, *src;
+{
+  volatile unsigned long *dst_bits = dst->BITS;
+  volatile unsigned long *src_bits = src->BITS;
+  int i;
+
+  for (i = 0; i < PTHREAD_SIGSET2SET_SIZE_NP; i += sizeof(unsigned long))
+    if ((*(dst_bits++) & *(src_bits)) != *(src_bits))
+      return(FALSE);
+    else
+      src_bits++;
+
+  return(TRUE);
+}
+
+/*------------------------------------------------------------*/
+/*
+ * pthread_sigeqset2set - check if dst set is == src set
+ */
+int pthread_sigeqset2set(dst, src)
+volatile sigset_t *dst, *src;
+{
+  volatile unsigned long *dst_bits = dst->BITS;
+  volatile unsigned long *src_bits = src->BITS;
+  int i;
+
+  for (i = 0; i < PTHREAD_SIGSET2SET_SIZE_NP; i += sizeof(unsigned long))
+    if (*(dst_bits++) != *(src_bits++))
+      return(FALSE);
+
+  return(TRUE);
+}
+
+/*------------------------------------------------------------*/
+/*
+ * pthread_signalcpyset2set - add a signal set to another one
+ */
+void pthread_signalcpyset2set(dst, src)
+unsigned long *dst, *src;
+{
+  int i;
+
+  for (i = 0; i < PTHREAD_SIGSET2SET_SIZE_NP; i += sizeof(unsigned long))
+    *(dst++) = *(src++);
+}
+#else /* !__sigset_t_is_struct__ */
 /*------------------------------------------------------------*/
 /*
  * pthread_sigcpyset2set - add a signal set to another one
  */
 void pthread_sigcpyset2set(dst, src)
@@ -261,10 +398,11 @@ int *dst, *src;
     if (*(dst++) != *(src++))
       return(FALSE);
 
   return(TRUE);
 }
+#endif /* !__sigset_t_is_struct__ */
 
 #ifndef STAND_ALONE
 /*------------------------------------------------------------*/
 /*
  * pthread_clear_sighandler - get rid of universal signal handler for all
