Article 160719 of comp.os.vms:
Below is my promised patch to V5.5-2 CMA$RTL.EXE that seems to fix 
the problems to be encountered by programs using the PTHREADs
*_cond_timedwait() routine (like OSU_HTTPD) on or after 19-MAY-1997. 

Note that the problem exists in all released versions of VMS;
DEC supposedly provides {VAX,ALP}LIBR_%%_070 patch kits for 
the VMS versions starting at V6.1 .

Is there anyone who can set the time forward on a system
running OSU-HTTPD to confirm that this patch indeed covers
all problems?

BTW, getting beyond the year 2038 is quite another matter ...

Wolfgang J. Moeller, Tel. +49 551 2011516 or -510, moeller@gwdvms.dnet.gwdg.de
GWDG, D-37077 Goettingen, F.R.Germany   |       Disclaimer: No claim intended!
<moeller@decus.decus.de>  ----- <moeller@gwdg.de>  -----  <w.moeller@ieee.org>

--- cut here -------------------------------------------------------------------
CMA$RTL.EXE
!
! Patch VMS V5.5-2 CMA$RTL
!	such that the pthread_cond_timedwait() routines
!	continue working on or after 19-MAY-1997
!	(i.e. 10000 days after the UNIX 'epoch')
!
! w.j.m. 08-DEC-1996
!
! Usage:
!	PATCH @{this file}
!
!*****
!
! OLD CODE at the start of either routine:
!	(ref: [CMARTL] CMA_PTHREAD.LIS, CMA_PTDEXC.LIS)
!
!	input:  struct timespec abstime	- time when "wait" expires,
!						3rd argument to routines
!	output: cma_t_date_time time	- corresponding VMS abs. time quadword
!	temp variable: delta		- VMS (delta) time quadword
!
!	call LIB$CVT_TO_INTERNAL_TIME
!		p1: address of longword holding LIB$K_DELTA_SECONDS (=0x19)
!		p2: address of abstime->tv_sec
!		p3: address of delta
!
!	... signal or return on error ...
!
!	subtract ((abstime->tv_nsec + 99) / 100) from delta.low
!
!	call LIB$ADD_TIMES
!		p1: address of quadword containing VMS abs. time of
!				01-JAN-1970:0:0:0.0
!		p2: address of delta
!		p3: address of time
!
!	... return status not checked ...
!
! BUGS:
!	LIB$CVT_TO_INTERNAL_TIME returns an error when
!		p2 is 10000 days or more
!	LIB$ADD_TIMES returns an error when the delta time
!		given as p2 is 10000 days or more
!	
! SOLUTION:
!	Don't call either LIB$ routine
!
! NOTE:
!	In the year 2038 the UNIX number of seconds will get negative.
!	Cautiously, this patch treats this quantity as an unsigned number
!	(so it might be ok for another 68 years),
!	but other C library routines don't ...
!
!*****
!
set eco 100	! arbitrary "user ECO" number
!
!
!*****	pthread_cond_timedwait()
!
verify/inst 00016E62
'	MOVAB   W^0FED8(SP),SP'		! stack frame
'	MOVAB   @L^0001AC80,R3'		! r3 => ERRNO
'	MOVAB   L^0001963C,R2'		! r2 => local storage
'	MOVL    #00,R4'			! ???
exit
!
replace/inst 00016E78
'	MOVL    #19,B^0F8(FP)'		! LIB$K_DELTA_SECONDS = ^x19
'	NOP'
'	PUSHAB  B^0E8(FP)'		! b^E8(fp) = &DELTA		-> p1
'	MOVAL   @B^0C(AP),R0'		! 3rd arg = &ABSTIME
'	NOP'
'	PUSHAL  (R0)'			! offsetof(tv.secs) = 0		-> p2
'	NOP'
'	PUSHAL  B^0F8(FP)'		! &LIB$K_DELTA_SECONDS		-> p3
'	CALLS   #03,@L^0001AC48'	! call LIB$CVT_TO_INTERNAL_TIME
'	BICL2   #0FFFFFFF8,R0'		! status & 7
'	CMPL    R0,#01'
'	BEQL    L1OLD'
'	MOVL    #16,(R3)'		! ERRNO := EINVAL (^x16)
'	MOVL    #0FFFFFFFF,R0'		! return -1
'	RET'
'L1OLD:	MOVL    B^0C(AP),R0'		! r0 => ABSTIME
'	ADDL3   B^04(R0),#00000063,R0'	! offsetof(tv_nsec) = 4; add 99 (ceil)
'	DIVL2   #00000064,R0'		! divide by 100
'	MOVL    R0,R0'			!
'	SUBL3   R0,B^0E8(FP),R0'	! subtract from DELTA.low
'	MOVL    R0,B^0E8(FP)'
'	NOP'
'	PUSHAB  B^0F0(FP)'		! b^F0(fp) = &TIME		-> p3
'	NOP'
'	PUSHAB  B^0E8(FP)'		! &DELTA			-> p2
'	NOP'
'	PUSHAB  B^04(R2)'		! &epoch = 4(r2)		-> p1
'	CALLS   #03,@L^0001AC58'	! call LIB$ADD_TIMES
exit
'	MOVAL   @B^0C(AP),R0'		! r0 => ABSTIME (= ABSTIME.tv_sec)
'	ADDL3   B^04(R0),#^d99,R1'	! r1 = ABSTIME.tv_nsec + 99 (ceil)
'	DIVL2   #^d100,R1'		! convert to VMS 100 nsec units
'	PUSHL	(r0)'			! save ABSTIME.tv_sec
'	BICL3	#^x80000000,(r0),r0'	! get low 31 bits for signed multiply
'	EMUL	#^d10000000,r0,r1,r0'	! 
'	TSTL	(SP)+'			! take care of bit31 of ABSTIME.tv_sec
'	BGEQ	L1NEW'			! br if not set
'	ADDL2	#^d5000000,r1'		! else add (10^7 * 2^31) to (r0,r1)
'L1NEW: NOP'				! here (r0,r1) = abstime in 100ns units
'	ADDL2	b^4(r2),r0'		! add epoch, low longword first
'	ADWC	b^8(r2),r1'		! hi longword
'	MOVQ	r0,B^0F0(FP)'		! store result in TIME
exit
!
!
!*****	ptdexc_cond_timedwait()
!
verify/inst 00013CA6
'	SUBL2   #18,SP'
'	MOVAB   L^00019630,R2'
exit
!
replace/inst 00013CB0
'	MOVL    #19,B^0F8(FP)'		! LIB$K_DELTA_SECONDS = ^x19
'	NOP'
'	PUSHAB  B^0E8(FP)'		! b^E8(fp) = &DELTA		-> p3
'	MOVAL   @B^0C(AP),R0'		! arg.3 = &ABSTIME
'	NOP'
'	PUSHAL  (R0)'			! &ABSTIME.tv_sec		-> p2
'	NOP'
'	PUSHAL  B^0F8(FP)'		! &LIB$K_DELTA_SECONDS		-> p1
'	CALLS   #03,@L^0001AC48'	! call LIB$CVT_TO_INTERNAL_TIME
'	BICL2   #0FFFFFFF8,R0'		! status & 7
'	CMPL    R0,#01'
'	BEQL    L2OLD'
'	NOP'
'	PUSHL   #00408194'		! signal exception
'	CALLS   #01,L^00010E24'
'L2OLD:	MOVL    B^0C(AP),R0'		! r0 => ABSTIME
'	ADDL3   B^04(R0),#00000063,R0'	! offsetof(tv_nsec) = 4; add 99 (ceil)
'	DIVL2   #00000064,R0'		! divide by 100
'	MOVL    R0,R0'
'	SUBL3   R0,B^0E8(FP),R0'	! subtract from DELTA.low
'	MOVL    R0,B^0E8(FP)'
'	NOP'
'	PUSHAB  B^0F0(FP)'		! b^F0(fp) = &TIME		-> p3
'	NOP'
'	PUSHAB  B^0E8(FP)'		! &DELTA			-> p2
'	NOP'
'	PUSHAB  B^04(R2)'		! 4(r2) = &epoch		-> p1
'	CALLS   #03,@L^0001AC58'	! call LIB$ADD_TIMES
exit
'	MOVAL   @B^0C(AP),R0'		! r0 => ABSTIME (= ABSTIME.tv_sec)
'	ADDL3   B^04(R0),#^d99,R1'	! r1 = ABSTIME.tv_nsec + 99 (ceil)
'	DIVL2   #^d100,R1'		! convert to VMS 100 nsec units
'	PUSHL	(r0)'			! save ABSTIME.tv_sec
'	BICL3	#^x80000000,(r0),r0'	! get low 31 bits for signed multiply
'	EMUL	#^d10000000,r0,r1,r0'	! 
'	TSTL	(SP)+'			! take care of bit31 of ABSTIME.tv_sec
'	BGEQ	L2NEW'			! br if not set
'	ADDL2	#^d5000000,r1'		! else add (10^7 * 2^31) to (r0,r1)
'L2NEW:	NOP'				! here (r0,r1) = abstime in 100ns units
'	ADDL2	b^4(r2),r0'		! add epoch, low longword first
'	ADWC	b^8(r2),r1'		! 
'	MOVQ	r0,B^0F0(FP)'		! store result in TIME
exit
!
!*****
!
update
--- cut here -------------------------------------------------------------------

Wolfgang J. Moeller, Tel. +49 551 2011516 or -510, moeller@gwdvms.dnet.gwdg.de
GWDG, D-37077 Goettingen, F.R.Germany   |       Disclaimer: No claim intended!
<moeller@decus.decus.de>  ----- <moeller@gwdg.de>  -----  <w.moeller@ieee.org>


