aboutsummaryrefslogtreecommitdiff
path: root/main.h
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2019-03-19 15:15:48 +0100
committerFabian Groffen <grobian@gentoo.org>2019-03-19 15:15:48 +0100
commitc796b47b1382845f699cdcf6718f616bb3aa5f28 (patch)
tree1cf8a8078b740e993c6706c3a6b8cb7e041a4481 /main.h
parentbuild: add autoconf helper files (diff)
downloadportage-utils-c796b47b1382845f699cdcf6718f616bb3aa5f28.tar.gz
portage-utils-c796b47b1382845f699cdcf6718f616bb3aa5f28.tar.bz2
portage-utils-c796b47b1382845f699cdcf6718f616bb3aa5f28.zip
build: add gnulib sources
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'main.h')
-rw-r--r--main.h40
1 files changed, 39 insertions, 1 deletions
diff --git a/main.h b/main.h
index 2508c86e..de4ba316 100644
--- a/main.h
+++ b/main.h
@@ -10,7 +10,14 @@
#ifndef _MAIN_H
#define _MAIN_H 1
-#include "porting.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h" /* make sure we have EPREFIX, if set */
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
#include "i18n.h"
#include "colors.h"
@@ -24,6 +31,37 @@ extern const char *argv0;
# define CONFIG_EPREFIX "/"
#endif
+/* make sure our buffers are as big as they can be */
+#if PATH_MAX > _POSIX_PATH_MAX /* _Q_PATH_MAX */
+# define _Q_PATH_MAX PATH_MAX
+#else
+# define _Q_PATH_MAX _POSIX_PATH_MAX
+#endif
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*(arr)))
+
+#ifndef BUFSIZE
+# define BUFSIZE 8192
+#endif
+
+#ifndef MIN
+# define MIN(x, y) ((x) < (y) ? (x) : (y))
+#endif
+#ifndef MAX
+# define MAX(x, y) ((x) < (y) ? (y) : (x))
+#endif
+
+/* Easy enough to glue to older versions */
+#ifndef O_CLOEXEC
+# define O_CLOEXEC 0
+#endif
+#ifndef O_PATH
+# define O_PATH 0
+#endif
+
+#define likely(x) __builtin_expect((x), 1)
+#define unlikely(x) __builtin_expect((x), 0)
+
#define qfprintf(stream, fmt, args...) do { if (!quiet) fprintf(stream, _( fmt ), ## args); } while (0)
#define qprintf(fmt, args...) qfprintf(stdout, _( fmt ), ## args)