REORG: include: split global.h into haproxy/global{,-t}.h

global.h was one of the messiest files, it has accumulated tons of
implicit dependencies and declares many globals that make almost all
other file include it. It managed to silence a dependency loop between
server.h and proxy.h by being well placed to pre-define the required
structs, forcing struct proxy and struct server to be forward-declared
in a significant number of files.

It was split in to, one which is the global struct definition and the
few macros and flags, and the rest containing the functions prototypes.

The UNIX_MAX_PATH definition was moved to compat.h.
diff --git a/include/haproxy/compat.h b/include/haproxy/compat.h
index 251dfb2..fdd6fa4 100644
--- a/include/haproxy/compat.h
+++ b/include/haproxy/compat.h
@@ -108,6 +108,11 @@
 #define MAXPATHLEN 128
 #endif
 
+/* longest UNIX socket name */
+#ifndef UNIX_MAX_PATH
+#define UNIX_MAX_PATH 108
+#endif
+
 /* On Linux, allows pipes to be resized */
 #ifndef F_SETPIPE_SZ
 #define F_SETPIPE_SZ (1024 + 7)
diff --git a/include/haproxy/dns-t.h b/include/haproxy/dns-t.h
index fe3938a..54c58ee 100644
--- a/include/haproxy/dns-t.h
+++ b/include/haproxy/dns-t.h
@@ -30,8 +30,6 @@
 
 #include <types/connection.h>
 #include <haproxy/proto_udp-t.h>
-#include <types/proxy.h>
-#include <types/server.h>
 #include <types/task.h>
 
 extern struct pool_head *dns_requester_pool;
@@ -346,6 +344,7 @@
 	DNS_UPD_OBSOLETE_IP,      /* The server IP was obsolete, and no other IP was found */
 };
 
+struct proxy;
 struct dns_srvrq {
 	enum obj_type         obj_type;         /* object type == OBJ_TYPE_SRVRQ */
 	struct dns_resolvers *resolvers;        /* pointer to the resolvers structure used for this server template */
diff --git a/include/haproxy/global-t.h b/include/haproxy/global-t.h
new file mode 100644
index 0000000..bee8de7
--- /dev/null
+++ b/include/haproxy/global-t.h
@@ -0,0 +1,191 @@
+/*
+ * include/haproxy/global-t.h
+ * Global types and macros. Please avoid adding more stuff here!
+ *
+ * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _HAPROXY_GLOBAL_T_H
+#define _HAPROXY_GLOBAL_T_H
+
+#include <haproxy/buf-t.h>
+#include <haproxy/freq_ctr-t.h>
+#include <haproxy/list-t.h>
+#include <haproxy/thread-t.h>
+#include <haproxy/api-t.h>
+#include <haproxy/vars-t.h>
+
+/* modes of operation (global.mode) */
+#define	MODE_DEBUG	0x01
+#define	MODE_DAEMON	0x02
+#define	MODE_QUIET	0x04
+#define	MODE_CHECK	0x08
+#define	MODE_VERBOSE	0x10
+#define	MODE_STARTING	0x20
+#define	MODE_FOREGROUND	0x40
+#define	MODE_MWORKER	0x80    /* Master Worker */
+#define	MODE_MWORKER_WAIT	0x100    /* Master Worker wait mode */
+#define	MODE_ZERO_WARNING       0x200    /* warnings cause a failure */
+
+/* list of last checks to perform, depending on config options */
+#define LSTCHK_CAP_BIND	0x00000001	/* check that we can bind to any port */
+#define LSTCHK_NETADM	0x00000002	/* check that we have CAP_NET_ADMIN */
+
+/* Global tuning options */
+/* available polling mechanisms */
+#define GTUNE_USE_SELECT         (1<<0)
+#define GTUNE_USE_POLL           (1<<1)
+#define GTUNE_USE_EPOLL          (1<<2)
+#define GTUNE_USE_KQUEUE         (1<<3)
+/* platform-specific options */
+#define GTUNE_USE_SPLICE         (1<<4)
+#define GTUNE_USE_GAI            (1<<5)
+#define GTUNE_USE_REUSEPORT      (1<<6)
+#define GTUNE_RESOLVE_DONTFAIL   (1<<7)
+
+#define GTUNE_SOCKET_TRANSFER	 (1<<8)
+#define GTUNE_NOEXIT_ONFAILURE   (1<<9)
+#define GTUNE_USE_SYSTEMD        (1<<10)
+
+#define GTUNE_BUSY_POLLING       (1<<11)
+#define GTUNE_LISTENER_MQ        (1<<12)
+#define GTUNE_SET_DUMPABLE       (1<<13)
+#define GTUNE_USE_EVPORTS        (1<<14)
+#define GTUNE_STRICT_LIMITS      (1<<15)
+#define GTUNE_INSECURE_FORK      (1<<16)
+#define GTUNE_INSECURE_SETUID    (1<<17)
+
+/* SSL server verify mode */
+enum {
+	SSL_SERVER_VERIFY_NONE = 0,
+	SSL_SERVER_VERIFY_REQUIRED = 1,
+};
+
+/* bit values to go with "warned" above */
+#define WARN_ANY                    0x00000001 /* any warning was emitted */
+#define WARN_FORCECLOSE_DEPRECATED  0x00000002
+#define WARN_EXEC_PATH              0x00000004 /* executable path already reported */
+
+/* put there the forward declarations needed for global.h */
+struct proxy;
+
+/* FIXME : this will have to be redefined correctly */
+struct global {
+	int uid;
+	int gid;
+	int external_check;
+	int nbproc;
+	int nbthread;
+	unsigned int hard_stop_after;	/* maximum time allowed to perform a soft-stop */
+	int maxconn, hardmaxconn;
+	int maxsslconn;
+	int ssl_session_max_cost;   /* how many bytes an SSL session may cost */
+	int ssl_handshake_max_cost; /* how many bytes an SSL handshake may use */
+	int ssl_used_frontend;      /* non-zero if SSL is used in a frontend */
+	int ssl_used_backend;       /* non-zero if SSL is used in a backend */
+	int ssl_used_async_engines; /* number of used async engines */
+	unsigned int ssl_server_verify; /* default verify mode on servers side */
+	struct freq_ctr conn_per_sec;
+	struct freq_ctr sess_per_sec;
+	struct freq_ctr ssl_per_sec;
+	struct freq_ctr ssl_fe_keys_per_sec;
+	struct freq_ctr ssl_be_keys_per_sec;
+	struct freq_ctr comp_bps_in;	/* bytes per second, before http compression */
+	struct freq_ctr comp_bps_out;	/* bytes per second, after http compression */
+	struct freq_ctr out_32bps;      /* #of 32-byte blocks emitted per second */
+	unsigned long long out_bytes;   /* total #of bytes emitted */
+	int cps_lim, cps_max;
+	int sps_lim, sps_max;
+	int ssl_lim, ssl_max;
+	int ssl_fe_keys_max, ssl_be_keys_max;
+	unsigned int shctx_lookups, shctx_misses;
+	int comp_rate_lim;           /* HTTP compression rate limit */
+	int maxpipes;		/* max # of pipes */
+	int maxsock;		/* max # of sockets */
+	int rlimit_nofile;	/* default ulimit-n value : 0=unset */
+	int rlimit_memmax_all;	/* default all-process memory limit in megs ; 0=unset */
+	int rlimit_memmax;	/* default per-process memory limit in megs ; 0=unset */
+	long maxzlibmem;        /* max RAM for zlib in bytes */
+	int mode;
+	unsigned int req_count; /* request counter (HTTP or TCP session) for logs and unique_id */
+	int last_checks;
+	int spread_checks;
+	int max_spread_checks;
+	int max_syslog_len;
+	char *chroot;
+	char *pidfile;
+	char *node, *desc;		/* node name & description */
+	struct buffer log_tag;           /* name for syslog */
+	struct list logsrvs;
+	char *log_send_hostname;   /* set hostname in syslog header */
+	char *server_state_base;   /* path to a directory where server state files can be found */
+	char *server_state_file;   /* path to the file where server states are loaded from */
+	struct {
+		int maxpollevents; /* max number of poll events at once */
+		int maxaccept;     /* max number of consecutive accept() */
+		int options;       /* various tuning options */
+		int runqueue_depth;/* max number of tasks to run at once */
+		int recv_enough;   /* how many input bytes at once are "enough" */
+		int bufsize;       /* buffer size in bytes, defaults to BUFSIZE */
+		int maxrewrite;    /* buffer max rewrite size in bytes, defaults to MAXREWRITE */
+		int reserved_bufs; /* how many buffers can only be allocated for response */
+		int buf_limit;     /* if not null, how many total buffers may only be allocated */
+		int client_sndbuf; /* set client sndbuf to this value if not null */
+		int client_rcvbuf; /* set client rcvbuf to this value if not null */
+		int server_sndbuf; /* set server sndbuf to this value if not null */
+		int server_rcvbuf; /* set server rcvbuf to this value if not null */
+		int chksize;       /* check buffer size in bytes, defaults to BUFSIZE */
+		int pipesize;      /* pipe size in bytes, system defaults if zero */
+		int max_http_hdr;  /* max number of HTTP headers, use MAX_HTTP_HDR if zero */
+		int requri_len;    /* max len of request URI, use REQURI_LEN if zero */
+		int cookie_len;    /* max length of cookie captures */
+		int pattern_cache; /* max number of entries in the pattern cache. */
+		int sslcachesize;  /* SSL cache size in session, defaults to 20000 */
+		int comp_maxlevel;    /* max HTTP compression level */
+		int pool_low_ratio;   /* max ratio of FDs used before we stop using new idle connections */
+		int pool_high_ratio;  /* max ratio of FDs used before we start killing idle connections when creating new connections */
+		int pool_low_count;   /* max number of opened fd before we stop using new idle connections */
+		int pool_high_count;  /* max number of opened fd before we start killing idle connections when creating new connections */
+		unsigned short idle_timer; /* how long before an empty buffer is considered idle (ms) */
+	} tune;
+	struct {
+		char *prefix;           /* path prefix of unix bind socket */
+		struct {                /* UNIX socket permissions */
+			uid_t uid;      /* -1 to leave unchanged */
+			gid_t gid;      /* -1 to leave unchanged */
+			mode_t mode;    /* 0 to leave unchanged */
+		} ux;
+	} unix_bind;
+	struct proxy *stats_fe;     /* the frontend holding the stats settings */
+	struct vars   vars;         /* list of variables for the process scope. */
+#ifdef USE_CPU_AFFINITY
+	struct {
+		unsigned long proc[MAX_PROCS];      /* list of CPU masks for the 32/64 first processes */
+		unsigned long proc_t1[MAX_PROCS];   /* list of CPU masks for the 1st thread of each process */
+		unsigned long thread[MAX_THREADS];  /* list of CPU masks for the 32/64 first threads of the 1st process */
+	} cpu_map;
+#endif
+};
+
+#endif /* _HAPROXY_GLOBAL_T_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
diff --git a/include/haproxy/global.h b/include/haproxy/global.h
new file mode 100644
index 0000000..a3f952c
--- /dev/null
+++ b/include/haproxy/global.h
@@ -0,0 +1,156 @@
+/*
+ * include/haproxy/global.h
+ * Exported global variables and functions.
+ *
+ * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _HAPROXY_GLOBAL_H
+#define _HAPROXY_GLOBAL_H
+
+#include <haproxy/global-t.h>
+#include <haproxy/api-t.h>
+#include <haproxy/thread.h>
+#include <haproxy/vars-t.h>
+#include <haproxy/mworker-t.h>
+
+#include <types/proxy.h>
+
+extern struct global global;
+extern int  pid;                /* current process id */
+extern int  relative_pid;       /* process id starting at 1 */
+extern unsigned long pid_bit;   /* bit corresponding to the process id */
+extern unsigned long all_proc_mask; /* mask of all processes */
+extern int  actconn;            /* # of active sessions */
+extern int  listeners;
+extern int  jobs;               /* # of active jobs (listeners, sessions, open devices) */
+extern int  unstoppable_jobs;   /* # of active jobs that can't be stopped during a soft stop */
+extern int  active_peers;       /* # of active peers (connection attempts and successes) */
+extern int  connected_peers;    /* # of really connected peers */
+extern int nb_oldpids;          /* contains the number of old pids found */
+extern const int zero;
+extern const int one;
+extern const struct linger nolinger;
+extern int stopping;	/* non zero means stopping in progress */
+extern int killed;	/* >0 means a hard-stop is triggered, >1 means hard-stop immediately */
+extern char hostname[MAX_HOSTNAME_LEN];
+extern char localpeer[MAX_HOSTNAME_LEN];
+extern unsigned int warned;     /* bitfield of a few warnings to emit just once */
+extern volatile unsigned long sleeping_thread_mask;
+extern struct list proc_list; /* list of process in mworker mode */
+extern struct mworker_proc *proc_self; /* process structure of current process */
+extern int master; /* 1 if in master, 0 otherwise */
+extern unsigned int rlim_fd_cur_at_boot;
+extern unsigned int rlim_fd_max_at_boot;
+extern int atexit_flag;
+extern unsigned char boot_seed[20];  // per-boot random seed (160 bits initially)
+extern THREAD_LOCAL struct buffer trash;
+
+int main(int argc, char **argv);
+void deinit(void);
+void run_poll_loop(void);
+int tell_old_pids(int sig);
+int delete_oldpid(int pid);
+void hap_register_build_opts(const char *str, int must_free);
+void hap_register_post_check(int (*fct)());
+void hap_register_post_proxy_check(int (*fct)(struct proxy *));
+void hap_register_post_server_check(int (*fct)(struct server *));
+void hap_register_post_deinit(void (*fct)());
+void hap_register_proxy_deinit(void (*fct)(struct proxy *));
+void hap_register_server_deinit(void (*fct)(struct server *));
+
+void hap_register_per_thread_alloc(int (*fct)());
+void hap_register_per_thread_init(int (*fct)());
+void hap_register_per_thread_deinit(void (*fct)());
+void hap_register_per_thread_free(int (*fct)());
+
+void mworker_accept_wrapper(int fd);
+void mworker_reload();
+
+/* to be used with warned and WARN_* */
+static inline int already_warned(unsigned int warning)
+{
+	if (warned & warning)
+		return 1;
+	warned |= warning;
+	return 0;
+}
+
+/* returns a mask if set, otherwise all_proc_mask */
+static inline unsigned long proc_mask(unsigned long mask)
+{
+	return mask ? mask : all_proc_mask;
+}
+
+/* returns a mask if set, otherwise all_threads_mask */
+static inline unsigned long thread_mask(unsigned long mask)
+{
+	return mask ? mask : all_threads_mask;
+}
+
+/* simplified way to declare static build options in a file */
+#define REGISTER_BUILD_OPTS(str) \
+	INITCALL2(STG_REGISTER, hap_register_build_opts, (str), 0)
+
+/* simplified way to declare a post-check callback in a file */
+#define REGISTER_POST_CHECK(fct) \
+	INITCALL1(STG_REGISTER, hap_register_post_check, (fct))
+
+/* simplified way to declare a post-proxy-check callback in a file */
+#define REGISTER_POST_PROXY_CHECK(fct) \
+	INITCALL1(STG_REGISTER, hap_register_post_proxy_check, (fct))
+
+/* simplified way to declare a post-server-check callback in a file */
+#define REGISTER_POST_SERVER_CHECK(fct) \
+	INITCALL1(STG_REGISTER, hap_register_post_server_check, (fct))
+
+/* simplified way to declare a post-deinit callback in a file */
+#define REGISTER_POST_DEINIT(fct) \
+	INITCALL1(STG_REGISTER, hap_register_post_deinit, (fct))
+
+/* simplified way to declare a proxy-deinit callback in a file */
+#define REGISTER_PROXY_DEINIT(fct) \
+	INITCALL1(STG_REGISTER, hap_register_proxy_deinit, (fct))
+
+/* simplified way to declare a proxy-deinit callback in a file */
+#define REGISTER_SERVER_DEINIT(fct) \
+	INITCALL1(STG_REGISTER, hap_register_server_deinit, (fct))
+
+/* simplified way to declare a per-thread allocation callback in a file */
+#define REGISTER_PER_THREAD_ALLOC(fct) \
+	INITCALL1(STG_REGISTER, hap_register_per_thread_alloc, (fct))
+
+/* simplified way to declare a per-thread init callback in a file */
+#define REGISTER_PER_THREAD_INIT(fct) \
+	INITCALL1(STG_REGISTER, hap_register_per_thread_init, (fct))
+
+/* simplified way to declare a per-thread deinit callback in a file */
+#define REGISTER_PER_THREAD_DEINIT(fct) \
+	INITCALL1(STG_REGISTER, hap_register_per_thread_deinit, (fct))
+
+/* simplified way to declare a per-thread free callback in a file */
+#define REGISTER_PER_THREAD_FREE(fct) \
+	INITCALL1(STG_REGISTER, hap_register_per_thread_free, (fct))
+
+#endif /* _HAPROXY_GLOBAL_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
diff --git a/include/haproxy/lb_chash.h b/include/haproxy/lb_chash.h
index 0d6410d..77d790f 100644
--- a/include/haproxy/lb_chash.h
+++ b/include/haproxy/lb_chash.h
@@ -24,9 +24,9 @@
 
 #include <haproxy/api.h>
 #include <haproxy/lb_chash-t.h>
-#include <types/proxy.h>
-#include <types/server.h>
 
+struct proxy;
+struct server;
 void chash_init_server_tree(struct proxy *p);
 struct server *chash_get_next_server(struct proxy *p, struct server *srvtoavoid);
 struct server *chash_get_server_hash(struct proxy *p, unsigned int hash, const struct server *avoid);
diff --git a/include/proto/channel.h b/include/proto/channel.h
index d391a4a..3547581 100644
--- a/include/proto/channel.h
+++ b/include/proto/channel.h
@@ -30,12 +30,12 @@
 #include <haproxy/api.h>
 #include <haproxy/chunk.h>
 #include <haproxy/dynbuf.h>
+#include <haproxy/global.h>
 #include <haproxy/htx.h>
 #include <haproxy/ticks.h>
 #include <haproxy/time.h>
 
 #include <types/channel.h>
-#include <types/global.h>
 #include <types/stream.h>
 #include <types/stream_interface.h>
 
diff --git a/include/proto/cli.h b/include/proto/cli.h
index 0668508..13490af 100644
--- a/include/proto/cli.h
+++ b/include/proto/cli.h
@@ -23,10 +23,10 @@
 #ifndef _PROTO_CLI_H
 #define _PROTO_CLI_H
 
+#include <haproxy/global.h>
 #include <types/applet.h>
 #include <types/channel.h>
 #include <types/cli.h>
-#include <types/global.h>
 #include <types/stream.h>
 
 
diff --git a/include/proto/proxy.h b/include/proto/proxy.h
index 5e17ffe..6a9aa55 100644
--- a/include/proto/proxy.h
+++ b/include/proto/proxy.h
@@ -27,7 +27,7 @@
 #include <haproxy/ticks.h>
 #include <haproxy/time.h>
 #include <types/applet.h>
-#include <types/global.h>
+#include <haproxy/global-t.h>
 #include <types/proxy.h>
 #include <haproxy/freq_ctr.h>
 
diff --git a/include/proto/session.h b/include/proto/session.h
index 8a17ad9..01e2d94 100644
--- a/include/proto/session.h
+++ b/include/proto/session.h
@@ -26,7 +26,7 @@
 #include <haproxy/obj_type.h>
 #include <haproxy/pool.h>
 
-#include <types/global.h>
+#include <haproxy/global-t.h>
 #include <types/session.h>
 
 #include <proto/stick_table.h>
diff --git a/include/proto/task.h b/include/proto/task.h
index 17a8288..85ec75a 100644
--- a/include/proto/task.h
+++ b/include/proto/task.h
@@ -27,6 +27,7 @@
 
 #include <haproxy/api.h>
 #include <haproxy/pool.h>
+#include <haproxy/global.h>
 #include <haproxy/intops.h>
 #include <haproxy/list.h>
 #include <haproxy/ticks.h>
@@ -35,7 +36,6 @@
 #include <import/eb32sctree.h>
 #include <import/eb32tree.h>
 
-#include <types/global.h>
 #include <types/task.h>
 
 #include <haproxy/fd.h>
diff --git a/include/types/checks.h b/include/types/checks.h
index 9b914d0..371ed43 100644
--- a/include/types/checks.h
+++ b/include/types/checks.h
@@ -23,9 +23,7 @@
 #include <haproxy/buf-t.h>
 
 #include <types/connection.h>
-#include <types/proxy.h>
 #include <haproxy/sample-t.h>
-#include <types/server.h>
 #include <types/session.h>
 #include <types/task.h>
 
@@ -133,6 +131,8 @@
 	HANA_OBS_SIZE
 };
 
+struct proxy;
+struct server;
 struct check {
 	enum obj_type obj_type;                 /* object type == OBJ_TYPE_CHECK */
 	struct session *sess;			/* Health check session. */
diff --git a/include/types/global.h b/include/types/global.h
deleted file mode 100644
index 56e7678..0000000
--- a/include/types/global.h
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * include/types/global.h
- * Global variables.
- *
- * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation, version 2.1
- * exclusively.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef _TYPES_GLOBAL_H
-#define _TYPES_GLOBAL_H
-
-#include <netinet/in.h>
-
-#include <haproxy/api-t.h>
-#include <haproxy/thread.h>
-#include <haproxy/vars-t.h>
-
-#include <haproxy/freq_ctr-t.h>
-#include <types/proxy.h>
-#include <types/task.h>
-
-#ifndef UNIX_MAX_PATH
-#define UNIX_MAX_PATH 108
-#endif
-
-/* modes of operation (global.mode) */
-#define	MODE_DEBUG	0x01
-#define	MODE_DAEMON	0x02
-#define	MODE_QUIET	0x04
-#define	MODE_CHECK	0x08
-#define	MODE_VERBOSE	0x10
-#define	MODE_STARTING	0x20
-#define	MODE_FOREGROUND	0x40
-#define	MODE_MWORKER	0x80    /* Master Worker */
-#define	MODE_MWORKER_WAIT	0x100    /* Master Worker wait mode */
-#define	MODE_ZERO_WARNING       0x200    /* warnings cause a failure */
-
-/* list of last checks to perform, depending on config options */
-#define LSTCHK_CAP_BIND	0x00000001	/* check that we can bind to any port */
-#define LSTCHK_NETADM	0x00000002	/* check that we have CAP_NET_ADMIN */
-
-/* Global tuning options */
-/* available polling mechanisms */
-#define GTUNE_USE_SELECT         (1<<0)
-#define GTUNE_USE_POLL           (1<<1)
-#define GTUNE_USE_EPOLL          (1<<2)
-#define GTUNE_USE_KQUEUE         (1<<3)
-/* platform-specific options */
-#define GTUNE_USE_SPLICE         (1<<4)
-#define GTUNE_USE_GAI            (1<<5)
-#define GTUNE_USE_REUSEPORT      (1<<6)
-#define GTUNE_RESOLVE_DONTFAIL   (1<<7)
-
-#define GTUNE_SOCKET_TRANSFER	 (1<<8)
-#define GTUNE_NOEXIT_ONFAILURE   (1<<9)
-#define GTUNE_USE_SYSTEMD        (1<<10)
-
-#define GTUNE_BUSY_POLLING       (1<<11)
-#define GTUNE_LISTENER_MQ        (1<<12)
-#define GTUNE_SET_DUMPABLE       (1<<13)
-#define GTUNE_USE_EVPORTS        (1<<14)
-#define GTUNE_STRICT_LIMITS      (1<<15)
-#define GTUNE_INSECURE_FORK      (1<<16)
-#define GTUNE_INSECURE_SETUID    (1<<17)
-
-/* SSL server verify mode */
-enum {
-	SSL_SERVER_VERIFY_NONE = 0,
-	SSL_SERVER_VERIFY_REQUIRED = 1,
-};
-
-/* FIXME : this will have to be redefined correctly */
-struct global {
-	int uid;
-	int gid;
-	int external_check;
-	int nbproc;
-	int nbthread;
-	unsigned int hard_stop_after;	/* maximum time allowed to perform a soft-stop */
-	int maxconn, hardmaxconn;
-	int maxsslconn;
-	int ssl_session_max_cost;   /* how many bytes an SSL session may cost */
-	int ssl_handshake_max_cost; /* how many bytes an SSL handshake may use */
-	int ssl_used_frontend;      /* non-zero if SSL is used in a frontend */
-	int ssl_used_backend;       /* non-zero if SSL is used in a backend */
-	int ssl_used_async_engines; /* number of used async engines */
-	unsigned int ssl_server_verify; /* default verify mode on servers side */
-	struct freq_ctr conn_per_sec;
-	struct freq_ctr sess_per_sec;
-	struct freq_ctr ssl_per_sec;
-	struct freq_ctr ssl_fe_keys_per_sec;
-	struct freq_ctr ssl_be_keys_per_sec;
-	struct freq_ctr comp_bps_in;	/* bytes per second, before http compression */
-	struct freq_ctr comp_bps_out;	/* bytes per second, after http compression */
-	struct freq_ctr out_32bps;      /* #of 32-byte blocks emitted per second */
-	unsigned long long out_bytes;   /* total #of bytes emitted */
-	int cps_lim, cps_max;
-	int sps_lim, sps_max;
-	int ssl_lim, ssl_max;
-	int ssl_fe_keys_max, ssl_be_keys_max;
-	unsigned int shctx_lookups, shctx_misses;
-	int comp_rate_lim;           /* HTTP compression rate limit */
-	int maxpipes;		/* max # of pipes */
-	int maxsock;		/* max # of sockets */
-	int rlimit_nofile;	/* default ulimit-n value : 0=unset */
-	int rlimit_memmax_all;	/* default all-process memory limit in megs ; 0=unset */
-	int rlimit_memmax;	/* default per-process memory limit in megs ; 0=unset */
-	long maxzlibmem;        /* max RAM for zlib in bytes */
-	int mode;
-	unsigned int req_count; /* request counter (HTTP or TCP session) for logs and unique_id */
-	int last_checks;
-	int spread_checks;
-	int max_spread_checks;
-	int max_syslog_len;
-	char *chroot;
-	char *pidfile;
-	char *node, *desc;		/* node name & description */
-	struct buffer log_tag;           /* name for syslog */
-	struct list logsrvs;
-	char *log_send_hostname;   /* set hostname in syslog header */
-	char *server_state_base;   /* path to a directory where server state files can be found */
-	char *server_state_file;   /* path to the file where server states are loaded from */
-	struct {
-		int maxpollevents; /* max number of poll events at once */
-		int maxaccept;     /* max number of consecutive accept() */
-		int options;       /* various tuning options */
-		int runqueue_depth;/* max number of tasks to run at once */
-		int recv_enough;   /* how many input bytes at once are "enough" */
-		int bufsize;       /* buffer size in bytes, defaults to BUFSIZE */
-		int maxrewrite;    /* buffer max rewrite size in bytes, defaults to MAXREWRITE */
-		int reserved_bufs; /* how many buffers can only be allocated for response */
-		int buf_limit;     /* if not null, how many total buffers may only be allocated */
-		int client_sndbuf; /* set client sndbuf to this value if not null */
-		int client_rcvbuf; /* set client rcvbuf to this value if not null */
-		int server_sndbuf; /* set server sndbuf to this value if not null */
-		int server_rcvbuf; /* set server rcvbuf to this value if not null */
-		int chksize;       /* check buffer size in bytes, defaults to BUFSIZE */
-		int pipesize;      /* pipe size in bytes, system defaults if zero */
-		int max_http_hdr;  /* max number of HTTP headers, use MAX_HTTP_HDR if zero */
-		int requri_len;    /* max len of request URI, use REQURI_LEN if zero */
-		int cookie_len;    /* max length of cookie captures */
-		int pattern_cache; /* max number of entries in the pattern cache. */
-		int sslcachesize;  /* SSL cache size in session, defaults to 20000 */
-		int comp_maxlevel;    /* max HTTP compression level */
-		int pool_low_ratio;   /* max ratio of FDs used before we stop using new idle connections */
-		int pool_high_ratio;  /* max ratio of FDs used before we start killing idle connections when creating new connections */
-		int pool_low_count;   /* max number of opened fd before we stop using new idle connections */
-		int pool_high_count;  /* max number of opened fd before we start killing idle connections when creating new connections */
-		unsigned short idle_timer; /* how long before an empty buffer is considered idle (ms) */
-	} tune;
-	struct {
-		char *prefix;           /* path prefix of unix bind socket */
-		struct {                /* UNIX socket permissions */
-			uid_t uid;      /* -1 to leave unchanged */
-			gid_t gid;      /* -1 to leave unchanged */
-			mode_t mode;    /* 0 to leave unchanged */
-		} ux;
-	} unix_bind;
-	struct proxy *stats_fe;     /* the frontend holding the stats settings */
-	struct vars   vars;         /* list of variables for the process scope. */
-#ifdef USE_CPU_AFFINITY
-	struct {
-		unsigned long proc[MAX_PROCS];      /* list of CPU masks for the 32/64 first processes */
-		unsigned long proc_t1[MAX_PROCS];   /* list of CPU masks for the 1st thread of each process */
-		unsigned long thread[MAX_THREADS];  /* list of CPU masks for the 32/64 first threads of the 1st process */
-	} cpu_map;
-#endif
-};
-
-extern struct global global;
-extern int  pid;                /* current process id */
-extern int  relative_pid;       /* process id starting at 1 */
-extern unsigned long pid_bit;   /* bit corresponding to the process id */
-extern unsigned long all_proc_mask; /* mask of all processes */
-extern int  actconn;            /* # of active sessions */
-extern int  listeners;
-extern int  jobs;               /* # of active jobs (listeners, sessions, open devices) */
-extern int  unstoppable_jobs;   /* # of active jobs that can't be stopped during a soft stop */
-extern int  active_peers;       /* # of active peers (connection attempts and successes) */
-extern int  connected_peers;    /* # of really connected peers */
-extern THREAD_LOCAL struct buffer trash;
-extern int nb_oldpids;          /* contains the number of old pids found */
-extern const int zero;
-extern const int one;
-extern const struct linger nolinger;
-extern int stopping;	/* non zero means stopping in progress */
-extern int killed;	/* >0 means a hard-stop is triggered, >1 means hard-stop immediately */
-extern char hostname[MAX_HOSTNAME_LEN];
-extern char localpeer[MAX_HOSTNAME_LEN];
-extern unsigned int warned;     /* bitfield of a few warnings to emit just once */
-extern volatile unsigned long sleeping_thread_mask;
-extern struct list proc_list; /* list of process in mworker mode */
-extern struct mworker_proc *proc_self; /* process structure of current process */
-extern int master; /* 1 if in master, 0 otherwise */
-extern unsigned int rlim_fd_cur_at_boot;
-extern unsigned int rlim_fd_max_at_boot;
-extern int atexit_flag;
-extern unsigned char boot_seed[20];  // per-boot random seed (160 bits initially)
-
-/* bit values to go with "warned" above */
-#define WARN_ANY                    0x00000001 /* any warning was emitted */
-#define WARN_FORCECLOSE_DEPRECATED  0x00000002
-#define WARN_EXEC_PATH              0x00000004 /* executable path already reported */
-
-
-/* to be used with warned and WARN_* */
-static inline int already_warned(unsigned int warning)
-{
-	if (warned & warning)
-		return 1;
-	warned |= warning;
-	return 0;
-}
-
-/* returns a mask if set, otherwise all_proc_mask */
-static inline unsigned long proc_mask(unsigned long mask)
-{
-	return mask ? mask : all_proc_mask;
-}
-
-/* returns a mask if set, otherwise all_threads_mask */
-static inline unsigned long thread_mask(unsigned long mask)
-{
-	return mask ? mask : all_threads_mask;
-}
-
-int tell_old_pids(int sig);
-int delete_oldpid(int pid);
-
-int main(int argc, char **argv);
-void deinit(void);
-void run_poll_loop(void);
-void hap_register_build_opts(const char *str, int must_free);
-void hap_register_post_check(int (*fct)());
-void hap_register_post_proxy_check(int (*fct)(struct proxy *));
-void hap_register_post_server_check(int (*fct)(struct server *));
-void hap_register_post_deinit(void (*fct)());
-void hap_register_proxy_deinit(void (*fct)(struct proxy *));
-void hap_register_server_deinit(void (*fct)(struct server *));
-
-void hap_register_per_thread_alloc(int (*fct)());
-void hap_register_per_thread_init(int (*fct)());
-void hap_register_per_thread_deinit(void (*fct)());
-void hap_register_per_thread_free(int (*fct)());
-
-void mworker_accept_wrapper(int fd);
-void mworker_reload();
-
-/* simplified way to declare static build options in a file */
-#define REGISTER_BUILD_OPTS(str) \
-	INITCALL2(STG_REGISTER, hap_register_build_opts, (str), 0)
-
-/* simplified way to declare a post-check callback in a file */
-#define REGISTER_POST_CHECK(fct) \
-	INITCALL1(STG_REGISTER, hap_register_post_check, (fct))
-
-/* simplified way to declare a post-proxy-check callback in a file */
-#define REGISTER_POST_PROXY_CHECK(fct) \
-	INITCALL1(STG_REGISTER, hap_register_post_proxy_check, (fct))
-
-/* simplified way to declare a post-server-check callback in a file */
-#define REGISTER_POST_SERVER_CHECK(fct) \
-	INITCALL1(STG_REGISTER, hap_register_post_server_check, (fct))
-
-/* simplified way to declare a post-deinit callback in a file */
-#define REGISTER_POST_DEINIT(fct) \
-	INITCALL1(STG_REGISTER, hap_register_post_deinit, (fct))
-
-/* simplified way to declare a proxy-deinit callback in a file */
-#define REGISTER_PROXY_DEINIT(fct) \
-	INITCALL1(STG_REGISTER, hap_register_proxy_deinit, (fct))
-
-/* simplified way to declare a proxy-deinit callback in a file */
-#define REGISTER_SERVER_DEINIT(fct) \
-	INITCALL1(STG_REGISTER, hap_register_server_deinit, (fct))
-
-/* simplified way to declare a per-thread allocation callback in a file */
-#define REGISTER_PER_THREAD_ALLOC(fct) \
-	INITCALL1(STG_REGISTER, hap_register_per_thread_alloc, (fct))
-
-/* simplified way to declare a per-thread init callback in a file */
-#define REGISTER_PER_THREAD_INIT(fct) \
-	INITCALL1(STG_REGISTER, hap_register_per_thread_init, (fct))
-
-/* simplified way to declare a per-thread deinit callback in a file */
-#define REGISTER_PER_THREAD_DEINIT(fct) \
-	INITCALL1(STG_REGISTER, hap_register_per_thread_deinit, (fct))
-
-/* simplified way to declare a per-thread free callback in a file */
-#define REGISTER_PER_THREAD_FREE(fct) \
-	INITCALL1(STG_REGISTER, hap_register_per_thread_free, (fct))
-
-#endif /* _TYPES_GLOBAL_H */
-
-/*
- * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- * End:
- */
diff --git a/include/types/server.h b/include/types/server.h
index 770a472..a9d333e 100644
--- a/include/types/server.h
+++ b/include/types/server.h
@@ -38,7 +38,6 @@
 
 #include <types/connection.h>
 #include <haproxy/freq_ctr-t.h>
-#include <types/proxy.h>
 #include <types/queue.h>
 #include <types/ssl_sock.h>
 #include <types/task.h>
@@ -204,6 +203,7 @@
 	struct eb32_node node;
 };
 
+struct proxy;
 struct server {
 	enum obj_type obj_type;                 /* object type == OBJ_TYPE_SERVER */
 	enum srv_state next_state, cur_state;   /* server state among SRV_ST_* */
diff --git a/include/types/session.h b/include/types/session.h
index 70d10a8..3e49b46 100644
--- a/include/types/session.h
+++ b/include/types/session.h
@@ -33,7 +33,6 @@
 #include <haproxy/obj_type-t.h>
 #include <haproxy/vars-t.h>
 
-#include <types/proxy.h>
 #include <types/stick_table.h>
 #include <types/task.h>
 
@@ -51,6 +50,7 @@
 	SESS_FL_PREFER_LAST   = 0x00000001, /* NTML authent, we should reuse last conn */
 };
 
+struct proxy;
 struct session {
 	struct proxy *fe;               /* the proxy this session depends on for the client side */
 	struct listener *listener;      /* the listener by which the request arrived */