*** ./server-client.c.ORIG	Thu Apr  4 12:43:00 2013
--- ./server-client.c	Thu Apr  4 12:43:27 2013
***************
*** 334,339 ****
--- 334,351 ----
  	window_pane_mouse(wp, c->session, m);
  }
  
+ #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? */
  int
  server_client_assume_paste(struct session *s)
*** ./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
***************
*** 730,740 ****
  	struct client		*c = tty->client;
  	struct window		*w = c->session->curw->window;
  	struct window_pane	*wp = w->active;
! 	u_int			 cx, cy, lines;
  
! 	lines = status_line_size(c);
  
! 	if (tty->sx >= w->sx && tty->sy - lines >= w->sy) {
  		*ox = 0;
  		*oy = 0;
  		*sx = w->sx;
--- 730,740 ----
  	struct client		*c = tty->client;
  	struct window		*w = c->session->curw->window;
  	struct window_pane	*wp = w->active;
! 	u_int			 cx, cy, aixlines;
  
! 	aixlines = status_line_size(c);
  
! 	if (tty->sx >= w->sx && tty->sy - aixlines >= w->sy) {
  		*ox = 0;
  		*oy = 0;
  		*sx = w->sx;
***************
*** 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)
***************
*** 896,910 ****
  tty_is_visible(struct tty *tty, const struct tty_ctx *ctx, u_int px, u_int py,
      u_int nx, u_int ny)
  {
! 	u_int	xoff = ctx->xoff + px, yoff = ctx->yoff + py, lines;
  
  	if (!ctx->bigger)
  		return (1);
  
  	if (status_at_line(tty->client) == 0)
! 		lines = status_line_size(tty->client);
  	else
! 		lines = 0;
  
  	if (xoff + nx <= ctx->ox || xoff >= ctx->ox + ctx->sx ||
  	    yoff + ny <= ctx->oy || yoff >= lines + ctx->oy + ctx->sy)
--- 896,910 ----
  tty_is_visible(struct tty *tty, const struct tty_ctx *ctx, u_int px, u_int py,
      u_int nx, u_int ny)
  {
! 	u_int	xoff = ctx->xoff + px, yoff = ctx->yoff + py, aixlines;
  
  	if (!ctx->bigger)
  		return (1);
  
  	if (status_at_line(tty->client) == 0)
! 		aixlines = status_line_size(tty->client);
  	else
! 		aixlines = 0;
  
  	if (xoff + nx <= ctx->ox || xoff >= ctx->ox + ctx->sx ||
  	    yoff + ny <= ctx->oy || yoff >= lines + ctx->oy + ctx->sy)

