*** ./err.c.ORIG	Wed Jan 18 22:05:08 2017
--- ./err.c	Wed Jan 18 22:07:31 2017
***************
*** 0 ****
--- 1,60 ----
+ /***********************************************************/
+ /*                                                         */
+ /*         AIX replacement functions: err(), errx()        */
+ /*                                                         */
+ /***********************************************************/
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stdarg.h>
+ #include <string.h>
+ #include <errno.h>
+ 
+ 
+ void err( int eval, const char *fmt, ... )
+ {
+   va_list ap;
+   char *txt, *strp;
+ 
+ 
+   txt = strerror( errno );
+ 
+   if (fmt != NULL && strcmp( (void *) fmt, "" ) != 0 )
+   {
+     strp = (char *) malloc( 1024 * sizeof( char ) );
+     va_start( ap, fmt );
+     vsnprintf( strp, 1023, fmt, ap );
+     va_end( ap );
+ 
+     fprintf(stderr, "%s: %s\n", strp, txt);
+     free( strp );
+     exit( eval );
+   }
+   else
+   {
+     fprintf( stderr, "%s\n", txt);
+     free( txt );
+     exit( eval );
+   }
+ }
+ 
+ 
+ void errx( int eval, const char *fmt, ... )
+ {
+   va_list ap;
+   char *strp;
+ 
+   strp = (char *) malloc( 1024 * sizeof( char ) );
+ 
+   va_start( ap,fmt );
+   vsnprintf( strp, 1023, fmt, ap );
+   va_end( ap );
+ 
+   fprintf( stderr, "%s\n", strp );
+ 
+   free( strp );
+ 
+   exit( eval );
+ }
+ 
+ /***********************************************************/

*** ./tty.c.ORIG	Mon May 27 11:32:52 2019
--- ./tty.c	Mon May 27 11:33:29 2019
***************
*** 745,751 ****
  	}
  
  	*sx = tty->sx;
! 	*sy = tty->sy - lines;
  
  	if (c->pan_window == w) {
  		if (*sx >= w->sx)
--- 745,751 ----
  	}
  
  	*sx = tty->sx;
! 	*sy = tty->sy - aixlines;
  
  	if (c->pan_window == w) {
  		if (*sx >= w->sx)
--- ./server-client.c_org	2023-09-21 04:37:15.725848030 +0000
+++ ./server-client.c	2023-09-21 04:38:09.695841047 +0000
@@ -1754,6 +1754,19 @@
 	return (key);
 }
 
+ #ifdef _AIX
+ # define timersub(a, b, result)                                               \
+   do {                                                                        \
+     (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;                             \
+     (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;                          \
+     if ((result)->tv_usec < 0) {                                              \
+       --(result)->tv_sec;                                                     \
+       (result)->tv_usec += 1000000;                                           \
+     }                                                                         \
+   } while (0)
+ #endif
+
+
 /* Is this fast enough to probably be a paste? */
 static int
 server_client_assume_paste(struct session *s)
--- ./tty.c_org	2023-09-21 04:39:36.226039487 +0000
+++ ./tty.c	2023-09-21 04:44:52.696059951 +0000
@@ -885,11 +885,11 @@
 	struct client		*c = tty->client;
 	struct window		*w = c->session->curw->window;
 	struct window_pane	*wp = server_client_get_pane(c);
-	u_int			 cx, cy, lines;
+	u_int			 cx, cy, aixlines;
 
-	lines = status_line_size(c);
+	aixlines = status_line_size(c);
 
-	if (tty->sx >= w->sx && tty->sy - lines >= w->sy) {
+	if (tty->sx >= w->sx && tty->sy - aixlines >= w->sy) {
 		*ox = 0;
 		*oy = 0;
 		*sx = w->sx;
