summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/clang/clang.lib.mk4
-rw-r--r--lib/libc++/Makefile3
-rw-r--r--lib/libc/stdlib/tdelete.c1
-rw-r--r--lib/libc/string/wcslcat.c2
-rw-r--r--lib/libc/string/wcsncat.c2
-rw-r--r--lib/libc/sys/stat.27
-rw-r--r--lib/libdpv/dpv.c6
-rw-r--r--lib/libdpv/dpv.h3
-rw-r--r--lib/libkvm/kvm_i386.h2
-rw-r--r--lib/libmd/mdXhl.c60
-rw-r--r--lib/libthr/thread/thr_umtx.c5
11 files changed, 56 insertions, 39 deletions
diff --git a/lib/clang/clang.lib.mk b/lib/clang/clang.lib.mk
index 13afa85bf4cc..ab3551e2d4f7 100644
--- a/lib/clang/clang.lib.mk
+++ b/lib/clang/clang.lib.mk
@@ -6,4 +6,8 @@ LLVM_SRCS= ${.CURDIR}/../../../contrib/llvm
INTERNALLIB=
+.if ${MACHINE_CPUARCH} == "arm"
+STATIC_CXXFLAGS+= -mlong-calls
+.endif
+
.include <bsd.lib.mk>
diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile
index d81710ef5364..94e91b94b003 100644
--- a/lib/libc++/Makefile
+++ b/lib/libc++/Makefile
@@ -6,6 +6,9 @@ _LIBCXXRTDIR= ${.CURDIR}/../../contrib/libcxxrt
HDRDIR= ${.CURDIR}/../../contrib/libc++/include
SRCDIR= ${.CURDIR}/../../contrib/libc++/src
CXXINCLUDEDIR= ${INCLUDEDIR}/c++/v${SHLIB_MAJOR}
+.if ${MACHINE_CPUARCH} == "arm"
+STATIC_CXXFLAGS+= -mlong-calls
+.endif
.PATH: ${SRCDIR}
diff --git a/lib/libc/stdlib/tdelete.c b/lib/libc/stdlib/tdelete.c
index 7799f35cc1e7..ff63576a1bf5 100644
--- a/lib/libc/stdlib/tdelete.c
+++ b/lib/libc/stdlib/tdelete.c
@@ -62,7 +62,6 @@ __FBSDID("$FreeBSD$");
base = leaf; \
path_init(&path); \
} \
- result = &(*leaf)->key; \
path_taking_right(&path); \
leaf = &(*leaf)->rlink; \
} while (0)
diff --git a/lib/libc/string/wcslcat.c b/lib/libc/string/wcslcat.c
index f5f1e1ee7559..2df94777d51f 100644
--- a/lib/libc/string/wcslcat.c
+++ b/lib/libc/string/wcslcat.c
@@ -54,7 +54,7 @@ wcslcat(wchar_t *dst, const wchar_t *src, size_t siz)
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
- while (*d != '\0' && n-- != 0)
+ while (n-- != 0 && *d != '\0')
d++;
dlen = d - dst;
n = siz - dlen;
diff --git a/lib/libc/string/wcsncat.c b/lib/libc/string/wcsncat.c
index 44f1ff98980c..5a243477db5b 100644
--- a/lib/libc/string/wcsncat.c
+++ b/lib/libc/string/wcsncat.c
@@ -48,7 +48,7 @@ wcsncat(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
p++;
q = p;
r = s2;
- while (*r && n) {
+ while (n && *r) {
*q++ = *r++;
n--;
}
diff --git a/lib/libc/sys/stat.2 b/lib/libc/sys/stat.2
index 5e49b3c0b992..3405d6e3511c 100644
--- a/lib/libc/sys/stat.2
+++ b/lib/libc/sys/stat.2
@@ -28,7 +28,7 @@
.\" @(#)stat.2 8.4 (Berkeley) 5/1/95
.\" $FreeBSD$
.\"
-.Dd June 2, 2012
+.Dd January 14, 2016
.Dt STAT 2
.Os
.Sh NAME
@@ -40,12 +40,11 @@
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
-.In sys/types.h
.In sys/stat.h
.Ft int
-.Fn stat "const char *path" "struct stat *sb"
+.Fn stat "const char * restrict path" "struct stat * restrict sb"
.Ft int
-.Fn lstat "const char *path" "struct stat *sb"
+.Fn lstat "const char * restrict path" "struct stat * restrict sb"
.Ft int
.Fn fstat "int fd" "struct stat *sb"
.Ft int
diff --git a/lib/libdpv/dpv.c b/lib/libdpv/dpv.c
index 6a03922ff9fd..d3506ca9d82d 100644
--- a/lib/libdpv/dpv.c
+++ b/lib/libdpv/dpv.c
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <dialog.h>
#include <err.h>
#include <limits.h>
+#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -482,6 +483,11 @@ dpv(struct dpv_config *config, struct dpv_file_node *file_list)
/* Reads: label_size pbar_size pprompt aprompt dpv_nfiles */
/* Inits: dheight and dwidth */
+ /* Default localeconv(3) settings for dialog(3) status */
+ setlocale(LC_NUMERIC,
+ getenv("LC_ALL") == NULL && getenv("LC_NUMERIC") == NULL ?
+ LC_NUMERIC_DEFAULT : "");
+
if (!debug) {
/* Internally create the initial `--gauge' prompt text */
dprompt_recreate(file_list, (struct dpv_file_node *)NULL, 0);
diff --git a/lib/libdpv/dpv.h b/lib/libdpv/dpv.h
index dbcd59bd67c0..03768a7ced40 100644
--- a/lib/libdpv/dpv.h
+++ b/lib/libdpv/dpv.h
@@ -38,6 +38,9 @@
#define FALSE 0
#endif
+/* localeconv(3) */
+#define LC_NUMERIC_DEFAULT "en_US.ISO8859-1"
+
/* Data to process */
extern long long dpv_overall_read;
diff --git a/lib/libkvm/kvm_i386.h b/lib/libkvm/kvm_i386.h
index 2949e6893024..51eb6f8f7f70 100644
--- a/lib/libkvm/kvm_i386.h
+++ b/lib/libkvm/kvm_i386.h
@@ -70,7 +70,7 @@ _Static_assert(NBPDR == I386_NBPDR, "NBPDR mismatch");
_Static_assert(PG_V == I386_PG_V, "PG_V mismatch");
_Static_assert(PG_PS == I386_PG_PS, "PG_PS mismatch");
-_Static_assert(PG_FRAME == I386_PG_FRAME, "PG_FRAME mismatch");
+_Static_assert((u_int)PG_FRAME == I386_PG_FRAME, "PG_FRAME mismatch");
_Static_assert(PG_PS_FRAME == I386_PG_PS_FRAME, "PG_PS_FRAME mismatch");
#endif
diff --git a/lib/libmd/mdXhl.c b/lib/libmd/mdXhl.c
index 378d8adfafc0..6ed214bce844 100644
--- a/lib/libmd/mdXhl.c
+++ b/lib/libmd/mdXhl.c
@@ -1,4 +1,5 @@
-/* mdXhl.c * ----------------------------------------------------------------------------
+/* mdXhl.c
+ * ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
@@ -52,43 +53,44 @@ MDXFileChunk(const char *filename, char *buf, off_t ofs, off_t len)
unsigned char buffer[16*1024];
MDX_CTX ctx;
struct stat stbuf;
- int f, i, e;
- off_t n;
+ int fd, readrv, e;
+ off_t remain;
- MDXInit(&ctx);
- f = open(filename, O_RDONLY);
- if (f < 0)
- return 0;
- if (fstat(f, &stbuf) < 0) {
- i = -1;
- goto error;
+ if (len < 0) {
+ errno = EINVAL;
+ return NULL;
}
- if (ofs > stbuf.st_size)
- ofs = stbuf.st_size;
- if ((len == 0) || (len > stbuf.st_size - ofs))
- len = stbuf.st_size - ofs;
- if (lseek(f, ofs, SEEK_SET) < 0) {
- i = -1;
- goto error;
+
+ MDXInit(&ctx);
+ fd = open(filename, O_RDONLY);
+ if (fd < 0)
+ return NULL;
+ if (ofs != 0) {
+ errno = 0;
+ if (lseek(fd, ofs, SEEK_SET) != ofs ||
+ (ofs == -1 && errno != 0)) {
+ readrv = -1;
+ goto error;
+ }
}
- n = len;
- i = 0;
- while (n > 0) {
- if (n > sizeof(buffer))
- i = read(f, buffer, sizeof(buffer));
+ remain = len;
+ readrv = 0;
+ while (len == 0 || remain > 0) {
+ if (len == 0 || remain > sizeof(buffer))
+ readrv = read(fd, buffer, sizeof(buffer));
else
- i = read(f, buffer, n);
- if (i <= 0)
+ readrv = read(fd, buffer, remain);
+ if (readrv <= 0)
break;
- MDXUpdate(&ctx, buffer, i);
- n -= i;
+ MDXUpdate(&ctx, buffer, readrv);
+ remain -= readrv;
}
error:
e = errno;
- close(f);
+ close(fd);
errno = e;
- if (i < 0)
- return 0;
+ if (readrv < 0)
+ return NULL;
return (MDXEnd(&ctx, buf));
}
diff --git a/lib/libthr/thread/thr_umtx.c b/lib/libthr/thread/thr_umtx.c
index a61dab023f52..37e5df183eb8 100644
--- a/lib/libthr/thread/thr_umtx.c
+++ b/lib/libthr/thread/thr_umtx.c
@@ -42,7 +42,7 @@ int _umtx_op_err(void *obj, int op, u_long val, void *uaddr, void *uaddr2)
void
_thr_umutex_init(struct umutex *mtx)
{
- static struct umutex default_mtx = DEFAULT_UMUTEX;
+ static const struct umutex default_mtx = DEFAULT_UMUTEX;
*mtx = default_mtx;
}
@@ -50,7 +50,8 @@ _thr_umutex_init(struct umutex *mtx)
void
_thr_urwlock_init(struct urwlock *rwl)
{
- static struct urwlock default_rwl = DEFAULT_URWLOCK;
+ static const struct urwlock default_rwl = DEFAULT_URWLOCK;
+
*rwl = default_rwl;
}