aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2021-01-11 21:50:40 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-01-11 21:50:40 +0000
commitb1ba762e34850582a1156ac56d280c8ce1980b28 (patch)
treede44db41b56528dbed9fc07329cac817143c55f8 /libc
parent4e67866510aa27445e9d699ed40d55163b66e95f (diff)
parente1dc4f62eb0475244f69b04f77eeaba18ea179a8 (diff)
downloadbionic-b1ba762e34850582a1156ac56d280c8ce1980b28.tar.gz
Merge "Fewer copies of ALIGN()/ALIGNBYTES."
Diffstat (limited to 'libc')
-rw-r--r--libc/Android.bp2
-rw-r--r--libc/bionic/fts.c5
-rw-r--r--libc/dns/net/gethnamaddr.c3
-rw-r--r--libc/dns/net/sethostent.c3
-rw-r--r--libc/private/bsd_sys_param.h21
-rw-r--r--libc/stdio/stdio.cpp3
-rw-r--r--libc/upstream-openbsd/android/include/openbsd-compat.h6
7 files changed, 28 insertions, 15 deletions
diff --git a/libc/Android.bp b/libc/Android.bp
index 9cfe2984f..10f431159 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -266,6 +266,7 @@ cc_library_static {
"-Wno-unused-parameter",
"-include netbsd-compat.h",
"-Wframe-larger-than=66000",
+ "-include private/bsd_sys_param.h",
],
local_include_dirs: [
@@ -576,6 +577,7 @@ cc_library_static {
],
local_include_dirs: [
+ "private",
"upstream-openbsd/android/include/",
"upstream-openbsd/lib/libc/include/",
"upstream-openbsd/lib/libc/gdtoa/",
diff --git a/libc/bionic/fts.c b/libc/bionic/fts.c
index 34de9923c..77b411762 100644
--- a/libc/bionic/fts.c
+++ b/libc/bionic/fts.c
@@ -54,10 +54,9 @@ static FTSENT *fts_sort(FTS *, FTSENT *, int);
static u_short fts_stat(FTS *, FTSENT *, int, int);
static int fts_safe_changedir(FTS *, FTSENT *, int, const char *);
+/* Android: OpenBSD source compatibility workarounds. */
+#include "private/bsd_sys_param.h"
#define DEF_WEAK(s) /* nothing */
-#define ALIGNBYTES (sizeof(uintptr_t) - 1)
-#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES)
-void* reallocarray(void*, size_t, size_t);
void* recallocarray(void*, size_t, size_t, size_t);
#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
diff --git a/libc/dns/net/gethnamaddr.c b/libc/dns/net/gethnamaddr.c
index 84942f876..f8212a295 100644
--- a/libc/dns/net/gethnamaddr.c
+++ b/libc/dns/net/gethnamaddr.c
@@ -75,9 +75,6 @@
#include <syslog.h>
#include <unistd.h>
-#define ALIGNBYTES (sizeof(uintptr_t) - 1)
-#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES)
-
#ifndef LOG_AUTH
# define LOG_AUTH 0
#endif
diff --git a/libc/dns/net/sethostent.c b/libc/dns/net/sethostent.c
index a743a543e..b2b0132c5 100644
--- a/libc/dns/net/sethostent.c
+++ b/libc/dns/net/sethostent.c
@@ -55,9 +55,6 @@ __RCSID("$NetBSD: sethostent.c,v 1.20 2014/03/17 13:24:23 christos Exp $");
#include "hostent.h"
#include "resolv_private.h"
-#define ALIGNBYTES (sizeof(uintptr_t) - 1)
-#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES)
-
#ifndef _REENTRANT
void res_close(void);
#endif
diff --git a/libc/private/bsd_sys_param.h b/libc/private/bsd_sys_param.h
new file mode 100644
index 000000000..8c936c459
--- /dev/null
+++ b/libc/private/bsd_sys_param.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+/* OpenBSD has these in <sys/param.h>, but "ALIGN" isn't something we want to reserve. */
+#define ALIGNBYTES (sizeof(uintptr_t) - 1)
+#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES)
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index b8aced83b..c7b1ba459 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -57,8 +57,7 @@
#include "private/ErrnoRestorer.h"
#include "private/thread_private.h"
-#define ALIGNBYTES (sizeof(uintptr_t) - 1)
-#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES)
+#include "private/bsd_sys_param.h" // For ALIGN/ALIGNBYTES.
#define NDYNAMIC 10 /* add ten more whenever necessary */
diff --git a/libc/upstream-openbsd/android/include/openbsd-compat.h b/libc/upstream-openbsd/android/include/openbsd-compat.h
index 2fc5046ad..6c21c5b49 100644
--- a/libc/upstream-openbsd/android/include/openbsd-compat.h
+++ b/libc/upstream-openbsd/android/include/openbsd-compat.h
@@ -25,6 +25,8 @@
#include <sys/random.h> // For getentropy.
+#include "private/bsd_sys_param.h"
+
#define __BEGIN_HIDDEN_DECLS _Pragma("GCC visibility push(hidden)")
#define __END_HIDDEN_DECLS _Pragma("GCC visibility pop")
@@ -57,10 +59,6 @@ extern const char* __progname;
#define explicit_bzero(p, s) memset(p, 0, s)
-/* OpenBSD has these in <sys/param.h>, but "ALIGN" isn't something we want to reserve. */
-#define ALIGNBYTES (sizeof(uintptr_t) - 1)
-#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES)
-
/* OpenBSD has this in paths.h. But this directory doesn't normally exist.
* Even when it does exist, only the 'shell' user has permissions.
*/