mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Add compat for getdtablesize, GitHub issue 2406.
This commit is contained in:
		
							
								
								
									
										29
									
								
								compat/getdtablesize.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								compat/getdtablesize.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * Permission to use, copy, modify, and distribute this software for any
 | 
			
		||||
 * purpose with or without fee is hereby granted, provided that the above
 | 
			
		||||
 * copyright notice and this permission notice appear in all copies.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 | 
			
		||||
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 | 
			
		||||
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 | 
			
		||||
 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
 | 
			
		||||
 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
#include "compat.h"
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_SYSCONF
 | 
			
		||||
int
 | 
			
		||||
getdtablesize(void)
 | 
			
		||||
{
 | 
			
		||||
	return (sysconf(_SC_OPEN_MAX));
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
/*	$OpenBSD: imsg-buffer.c,v 1.11 2017/12/14 09:27:44 kettenis Exp $	*/
 | 
			
		||||
/*	$OpenBSD: imsg-buffer.c,v 1.12 2019/01/20 02:50:03 bcook Exp $	*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
 | 
			
		||||
@@ -70,7 +70,7 @@ ibuf_dynamic(size_t len, size_t max)
 | 
			
		||||
static int
 | 
			
		||||
ibuf_realloc(struct ibuf *buf, size_t len)
 | 
			
		||||
{
 | 
			
		||||
	u_char	*b;
 | 
			
		||||
	unsigned char	*b;
 | 
			
		||||
 | 
			
		||||
	/* on static buffers max is eq size and so the following fails */
 | 
			
		||||
	if (buf->wpos + len > buf->max) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
/*	$OpenBSD: imsg.h,v 1.4 2017/03/24 09:34:12 nicm Exp $	*/
 | 
			
		||||
/*	$OpenBSD: imsg.h,v 1.5 2019/01/20 02:50:03 bcook Exp $	*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
 | 
			
		||||
@@ -21,13 +21,15 @@
 | 
			
		||||
#ifndef _IMSG_H_
 | 
			
		||||
#define _IMSG_H_
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
#define IBUF_READ_SIZE		65535
 | 
			
		||||
#define IMSG_HEADER_SIZE	sizeof(struct imsg_hdr)
 | 
			
		||||
#define MAX_IMSGSIZE		16384
 | 
			
		||||
 | 
			
		||||
struct ibuf {
 | 
			
		||||
	TAILQ_ENTRY(ibuf)	 entry;
 | 
			
		||||
	u_char			*buf;
 | 
			
		||||
	unsigned char		*buf;
 | 
			
		||||
	size_t			 size;
 | 
			
		||||
	size_t			 max;
 | 
			
		||||
	size_t			 wpos;
 | 
			
		||||
@@ -42,8 +44,8 @@ struct msgbuf {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct ibuf_read {
 | 
			
		||||
	u_char			 buf[IBUF_READ_SIZE];
 | 
			
		||||
	u_char			*rptr;
 | 
			
		||||
	unsigned char		 buf[IBUF_READ_SIZE];
 | 
			
		||||
	unsigned char		*rptr;
 | 
			
		||||
	size_t			 wpos;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -113,6 +113,7 @@ AC_REPLACE_FUNCS([ \
 | 
			
		||||
	fgetln \
 | 
			
		||||
	freezero \
 | 
			
		||||
	getdtablecount \
 | 
			
		||||
	getdtablesize \
 | 
			
		||||
	getline \
 | 
			
		||||
	getprogname \
 | 
			
		||||
	memmem \
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user