Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Move detection of humanize_number and STAILQ to bsd_compat.h. This commit creates humanize_number() linker errors.
Yonas Yanfa committed 10 years ago
commit 73ef692ecdfe760380dfdb45695d3ab5a657c79c
parent 5bd65f8
5 files changed +20 -22
modified compat/bsd_compat.h
@@ -30,6 +30,8 @@
#include "pkg_config.h"

#ifdef __OpenBSD__
+
 #include "../external/libelf/_elftc.h"
+

 #ifndef EPROTO
  #define EPROTO EINTR
 #endif
modified configure.ac
@@ -359,6 +359,19 @@ if test "$ac_cv_func_arc4random_stir" = yes ; then
   AC_DEFINE(HAVE_ARC4RANDOM_STIR, 1, [Define 1 if you have 'arc4random_stir' function.])
fi

+
AC_CACHE_CHECK(for humanize_number,
+
               ac_cv_func_humanize_number,
+
               [ac_save_CFLAGS="$CFLAGS"
+
                CFLAGS="-Werror $CFLAGS"
+
                AC_TRY_COMPILE([#include <libutil.h>],
+
                               [humanize_number(NULL, 0, 0, NULL, 0, 0);],
+
                               [ac_cv_func_humanize_number=yes],
+
                               [ac_cv_func_humanize_number=no])
+
		CFLAGS="$ac_save_CFLAGS"])
+
if test "$ac_cv_func_humanize_number" = yes ; then
+
   AC_DEFINE(HAVE_HUMANIZE_NUMBER, 1, [Define 1 if you have 'humanize_number' function.])
+
fi
+

AC_CACHE_CHECK(for BSD dirname(const char *),
               ac_cv_func_dirname,
               [ac_save_CFLAGS="$CFLAGS"
modified external/libelf/elf.c
@@ -25,13 +25,13 @@
 */

#include <libelf.h>
-
/*
-
#include "/usr/include/sys/exec_elf.h"
-
*/
-

#include "_libelf.h"

-
#define EM_AMD64    62
+
#ifdef __OpenBSD__
+
 #ifndef EM_AMD64
+
  #define EM_AMD64    62
+
 #endif
+
#endif

ELFTC_VCSID("$Id$");

modified src/main.c
@@ -63,22 +63,6 @@

#include "pkgcli.h"

-
#ifndef _HUMANIZE_NUMBER
-
#define _HUMANIZE_NUMBER
-

-
#include <util.h>
-
#include <errno.h>
-
int humanize_number(char *buf, size_t len, int64_t number, const char *suffix, int scale, int flags) {
-
    if (len < FMT_SCALED_STRSIZE) {
-
        return -1;
-
    }
-
    else if (fmt_scaled(number, buf) == 0)
-
        return 0;
-
    else
-
        return errno;
-
}
-
#endif
-

/* Used to define why do we show usage message to a user */
enum pkg_usage_reason {
	PKG_USAGE_ERROR,
modified src/pkgcli.h
@@ -30,7 +30,6 @@

#include <stdint.h>
#include <bsd_compat.h>
-
#include "external/libelf/_elftc.h"

#define pkg_warnx(fmt, ...) pkg_fprintf(stderr, "%S: " fmt, getprogname(), __VA_ARGS__, -1)