merge in jb-release history after reset to master
diff --git a/libc/Android.mk b/libc/Android.mk
index 1ce2feb..5e41741 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -281,8 +281,12 @@
bionic/ssp.c \
bionic/stubs.c \
bionic/system_properties.c \
+ bionic/tdelete.c \
+ bionic/tdestroy.c \
bionic/time64.c \
+ bionic/tfind.c \
bionic/thread_atexit.c \
+ bionic/tsearch.c \
bionic/utime.c \
bionic/utmp.c \
netbsd/gethnamaddr.c \
diff --git a/libc/bionic/dlmalloc.c b/libc/bionic/dlmalloc.c
index 496cd1c..98ea9e9 100644
--- a/libc/bionic/dlmalloc.c
+++ b/libc/bionic/dlmalloc.c
@@ -3332,7 +3332,7 @@
chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD;
chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0;
- if (mm < m->least_addr)
+ if (m->least_addr == 0 || mm < m->least_addr)
m->least_addr = mm;
if ((m->footprint += mmsize) > m->max_footprint)
m->max_footprint = m->footprint;
@@ -3678,7 +3678,9 @@
m->max_footprint = m->footprint;
if (!is_initialized(m)) { /* first-time initialization */
- m->seg.base = m->least_addr = tbase;
+ if (m->least_addr == 0 || tbase < m->least_addr)
+ m->least_addr = tbase;
+ m->seg.base = tbase;
m->seg.size = tsize;
m->seg.sflags = mmap_flag;
m->magic = mparams.magic;
diff --git a/libc/bionic/realpath.c b/libc/bionic/realpath.c
index 4cb847b..b909831 100644
--- a/libc/bionic/realpath.c
+++ b/libc/bionic/realpath.c
@@ -1,4 +1,3 @@
-/* $OpenBSD: realpath.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
/*
* Copyright (c) 2003 Constantin S. Svintsoff <kostik@iclub.nsu.ru>
*
@@ -27,6 +26,12 @@
* SUCH DAMAGE.
*/
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)realpath.c 8.1 (Berkeley) 2/16/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: release/9.0.0/lib/libc/stdlib/realpath.c 217144 2011-01-08 11:04:30Z kib $");
+
#include <sys/param.h>
#include <sys/stat.h>
@@ -36,23 +41,36 @@
#include <unistd.h>
/*
- * char *realpath(const char *path, char resolved[PATH_MAX]);
- *
* Find the real name of path, by removing all ".", ".." and symlink
* components. Returns (resolved) on success, or (NULL) on failure,
* in which case the path which caused trouble is left in (resolved).
*/
char *
-realpath(const char *path, char resolved[PATH_MAX])
+realpath(const char * __restrict path, char * __restrict resolved)
{
struct stat sb;
char *p, *q, *s;
size_t left_len, resolved_len;
unsigned symlinks;
- int serrno, slen;
+ int m, serrno, slen;
char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX];
+ if (path == NULL) {
+ errno = EINVAL;
+ return (NULL);
+ }
+ if (path[0] == '\0') {
+ errno = ENOENT;
+ return (NULL);
+ }
serrno = errno;
+ if (resolved == NULL) {
+ resolved = malloc(PATH_MAX);
+ if (resolved == NULL)
+ return (NULL);
+ m = 1;
+ } else
+ m = 0;
symlinks = 0;
if (path[0] == '/') {
resolved[0] = '/';
@@ -63,13 +81,20 @@
left_len = strlcpy(left, path + 1, sizeof(left));
} else {
if (getcwd(resolved, PATH_MAX) == NULL) {
- strlcpy(resolved, ".", PATH_MAX);
+ if (m)
+ free(resolved);
+ else {
+ resolved[0] = '.';
+ resolved[1] = '\0';
+ }
return (NULL);
}
resolved_len = strlen(resolved);
left_len = strlcpy(left, path, sizeof(left));
}
if (left_len >= sizeof(left) || resolved_len >= PATH_MAX) {
+ if (m)
+ free(resolved);
errno = ENAMETOOLONG;
return (NULL);
}
@@ -85,6 +110,8 @@
p = strchr(left, '/');
s = p ? p : left + left_len;
if (s - left >= sizeof(next_token)) {
+ if (m)
+ free(resolved);
errno = ENAMETOOLONG;
return (NULL);
}
@@ -95,6 +122,8 @@
memmove(left, s + 1, left_len + 1);
if (resolved[resolved_len - 1] != '/') {
if (resolved_len + 1 >= PATH_MAX) {
+ if (m)
+ free(resolved);
errno = ENAMETOOLONG;
return (NULL);
}
@@ -126,6 +155,8 @@
*/
resolved_len = strlcat(resolved, next_token, PATH_MAX);
if (resolved_len >= PATH_MAX) {
+ if (m)
+ free(resolved);
errno = ENAMETOOLONG;
return (NULL);
}
@@ -134,16 +165,23 @@
errno = serrno;
return (resolved);
}
+ if (m)
+ free(resolved);
return (NULL);
}
if (S_ISLNK(sb.st_mode)) {
if (symlinks++ > MAXSYMLINKS) {
+ if (m)
+ free(resolved);
errno = ELOOP;
return (NULL);
}
slen = readlink(resolved, symlink, sizeof(symlink) - 1);
- if (slen < 0)
+ if (slen < 0) {
+ if (m)
+ free(resolved);
return (NULL);
+ }
symlink[slen] = '\0';
if (symlink[0] == '/') {
resolved[1] = 0;
@@ -164,6 +202,8 @@
if (p != NULL) {
if (symlink[slen - 1] != '/') {
if (slen + 1 >= sizeof(symlink)) {
+ if (m)
+ free(resolved);
errno = ENAMETOOLONG;
return (NULL);
}
@@ -172,6 +212,8 @@
}
left_len = strlcat(symlink, left, sizeof(left));
if (left_len >= sizeof(left)) {
+ if (m)
+ free(resolved);
errno = ENAMETOOLONG;
return (NULL);
}
diff --git a/libc/bionic/tdelete.c b/libc/bionic/tdelete.c
new file mode 100644
index 0000000..b64b47a
--- /dev/null
+++ b/libc/bionic/tdelete.c
@@ -0,0 +1,71 @@
+/* $NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $ */
+
+/*
+ * Tree search generalized from Knuth (6.2.2) Algorithm T just like
+ * the AT&T man page says.
+ *
+ * The node_t structure is for internal use only, lint doesn't grok it.
+ *
+ * Written by reading the System V Interface Definition, not the code.
+ *
+ * Totally public domain.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: release/9.0.0/lib/libc/stdlib/tdelete.c 108694 2003-01-05 02:43:18Z tjr $");
+
+#define _SEARCH_PRIVATE
+#include <search.h>
+#include <stdlib.h>
+
+
+/*
+ * delete node with given key
+ *
+ * vkey: key to be deleted
+ * vrootp: address of the root of the tree
+ * compar: function to carry out node comparisons
+ */
+void *
+tdelete(const void * __restrict vkey, void ** __restrict vrootp,
+ int (*compar)(const void *, const void *))
+{
+ node_t **rootp = (node_t **)vrootp;
+ node_t *p, *q, *r;
+ int cmp;
+
+ if (rootp == NULL || (p = *rootp) == NULL)
+ return NULL;
+
+ while ((cmp = (*compar)(vkey, (*rootp)->key)) != 0) {
+ p = *rootp;
+ rootp = (cmp < 0) ?
+ &(*rootp)->llink : /* follow llink branch */
+ &(*rootp)->rlink; /* follow rlink branch */
+ if (*rootp == NULL)
+ return NULL; /* key not found */
+ }
+ r = (*rootp)->rlink; /* D1: */
+ if ((q = (*rootp)->llink) == NULL) /* Left NULL? */
+ q = r;
+ else if (r != NULL) { /* Right link is NULL? */
+ if (r->llink == NULL) { /* D2: Find successor */
+ r->llink = q;
+ q = r;
+ } else { /* D3: Find NULL link */
+ for (q = r->llink; q->llink != NULL; q = r->llink)
+ r = q;
+ r->llink = q->rlink;
+ q->llink = (*rootp)->llink;
+ q->rlink = (*rootp)->rlink;
+ }
+ }
+ free(*rootp); /* D4: Free node */
+ *rootp = q; /* link parent to new node */
+ return p;
+}
diff --git a/libc/bionic/tdestroy.c b/libc/bionic/tdestroy.c
new file mode 100644
index 0000000..70b71f4
--- /dev/null
+++ b/libc/bionic/tdestroy.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#define _SEARCH_PRIVATE
+#include <search.h>
+#include <stdlib.h>
+
+/* destroy a tree and free all allocated resources */
+void
+tdestroy(void *root, void (*destroy_func)(void *))
+{
+ node_t *root_node = (node_t *) root;
+ if (root_node == NULL) return;
+ if (root_node->llink)
+ tdestroy(root_node->llink, destroy_func);
+ if (root_node->rlink)
+ tdestroy(root_node->rlink, destroy_func);
+ (*destroy_func)(root_node->key);
+ free(root);
+}
diff --git a/libc/bionic/tfind.c b/libc/bionic/tfind.c
new file mode 100644
index 0000000..7e2bb0c
--- /dev/null
+++ b/libc/bionic/tfind.c
@@ -0,0 +1,48 @@
+/* $NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $ */
+
+/*
+ * Tree search generalized from Knuth (6.2.2) Algorithm T just like
+ * the AT&T man page says.
+ *
+ * The node_t structure is for internal use only, lint doesn't grok it.
+ *
+ * Written by reading the System V Interface Definition, not the code.
+ *
+ * Totally public domain.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: release/9.0.0/lib/libc/stdlib/tfind.c 108694 2003-01-05 02:43:18Z tjr $");
+
+#define _SEARCH_PRIVATE
+#include <stdlib.h>
+#include <search.h>
+
+/* find a node, or return 0 */
+void *
+tfind(vkey, vrootp, compar)
+ const void *vkey; /* key to be found */
+ void * const *vrootp; /* address of the tree root */
+ int (*compar)(const void *, const void *);
+{
+ node_t **rootp = (node_t **)vrootp;
+
+ if (rootp == NULL)
+ return NULL;
+
+ while (*rootp != NULL) { /* T1: */
+ int r;
+
+ if ((r = (*compar)(vkey, (*rootp)->key)) == 0) /* T2: */
+ return *rootp; /* key found */
+ rootp = (r < 0) ?
+ &(*rootp)->llink : /* T3: follow left branch */
+ &(*rootp)->rlink; /* T4: follow right branch */
+ }
+ return NULL;
+}
diff --git a/libc/bionic/tsearch.c b/libc/bionic/tsearch.c
new file mode 100644
index 0000000..4270e6b
--- /dev/null
+++ b/libc/bionic/tsearch.c
@@ -0,0 +1,58 @@
+/* $NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $ */
+
+/*
+ * Tree search generalized from Knuth (6.2.2) Algorithm T just like
+ * the AT&T man page says.
+ *
+ * The node_t structure is for internal use only, lint doesn't grok it.
+ *
+ * Written by reading the System V Interface Definition, not the code.
+ *
+ * Totally public domain.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: release/9.0.0/lib/libc/stdlib/tsearch.c 108694 2003-01-05 02:43:18Z tjr $");
+
+#define _SEARCH_PRIVATE
+#include <search.h>
+#include <stdlib.h>
+
+/* find or insert datum into search tree */
+void *
+tsearch(vkey, vrootp, compar)
+ const void *vkey; /* key to be located */
+ void **vrootp; /* address of tree root */
+ int (*compar)(const void *, const void *);
+{
+ node_t *q;
+ node_t **rootp = (node_t **)vrootp;
+
+ if (rootp == NULL)
+ return NULL;
+
+ while (*rootp != NULL) { /* Knuth's T1: */
+ int r;
+
+ if ((r = (*compar)(vkey, (*rootp)->key)) == 0) /* T2: */
+ return *rootp; /* we found it! */
+
+ rootp = (r < 0) ?
+ &(*rootp)->llink : /* T3: follow left branch */
+ &(*rootp)->rlink; /* T4: follow right branch */
+ }
+
+ q = malloc(sizeof(node_t)); /* T5: key not found */
+ if (q != 0) { /* make new node */
+ *rootp = q; /* link new node to old */
+ /* LINTED const castaway ok */
+ q->key = (void *)vkey; /* initialize new node */
+ q->llink = q->rlink = NULL;
+ }
+ return q;
+}
diff --git a/libc/include/ar.h b/libc/include/ar.h
new file mode 100644
index 0000000..835290b
--- /dev/null
+++ b/libc/include/ar.h
@@ -0,0 +1,66 @@
+/* $OpenBSD: ar.h,v 1.3 2003/06/02 19:34:12 millert Exp $ */
+/* $NetBSD: ar.h,v 1.4 1994/10/26 00:55:43 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Hugh Smith at The University of Guelph.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ar.h 8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _AR_H_
+#define _AR_H_
+
+/* Pre-4BSD archives had these magic numbers in them. */
+#define OARMAG1 0177555
+#define OARMAG2 0177545
+
+#define ARMAG "!<arch>\n" /* ar "magic number" */
+#define SARMAG 8 /* strlen(ARMAG); */
+
+#define AR_EFMT1 "#1/" /* extended format #1 */
+
+struct ar_hdr {
+ char ar_name[16]; /* name */
+ char ar_date[12]; /* modification time */
+ char ar_uid[6]; /* user id */
+ char ar_gid[6]; /* group id */
+ char ar_mode[8]; /* octal file permissions */
+ char ar_size[10]; /* size in bytes */
+#define ARFMAG "`\n"
+ char ar_fmag[2]; /* consistency check */
+};
+
+#endif /* !_AR_H_ */
diff --git a/libc/include/search.h b/libc/include/search.h
new file mode 100644
index 0000000..ed0d216
--- /dev/null
+++ b/libc/include/search.h
@@ -0,0 +1,46 @@
+/*-
+ * Written by J.T. Conklin <jtc@netbsd.org>
+ * Public domain.
+ *
+ * $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $
+ * $FreeBSD: release/9.0.0/include/search.h 105250 2002-10-16 14:29:23Z robert $
+ */
+
+#ifndef _SEARCH_H_
+#define _SEARCH_H_
+
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+
+#if 0
+#ifndef _SIZE_T_DECLARED
+typedef __size_t size_t;
+#define _SIZE_T_DECLARED
+#endif
+#endif
+
+typedef enum {
+ preorder,
+ postorder,
+ endorder,
+ leaf
+} VISIT;
+
+#ifdef _SEARCH_PRIVATE
+typedef struct node {
+ char *key;
+ struct node *llink, *rlink;
+} node_t;
+#endif
+
+__BEGIN_DECLS
+void *tdelete(const void * __restrict, void ** __restrict,
+ int (*)(const void *, const void *));
+void *tfind(const void *, void * const *,
+ int (*)(const void *, const void *));
+void *tsearch(const void *, void **, int (*)(const void *, const void *));
+void twalk(const void *, void (*)(const void *, VISIT, int));
+void tdestroy(void *, void (*)(void *));
+__END_DECLS
+
+#endif /* !_SEARCH_H_ */
diff --git a/libc/include/string.h b/libc/include/string.h
index 613dcd7..6e6c8e6 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -35,54 +35,54 @@
__BEGIN_DECLS
extern void* memccpy(void *, const void *, int, size_t);
-extern void* memchr(const void *, int, size_t);
-extern void* memrchr(const void *, int, size_t);
-extern int memcmp(const void *, const void *, size_t);
+extern void* memchr(const void *, int, size_t) __purefunc;
+extern void* memrchr(const void *, int, size_t) __purefunc;
+extern int memcmp(const void *, const void *, size_t) __purefunc;
extern void* memcpy(void *, const void *, size_t);
extern void* memmove(void *, const void *, size_t);
extern void* memset(void *, int, size_t);
-extern void* memmem(const void *, size_t, const void *, size_t);
+extern void* memmem(const void *, size_t, const void *, size_t) __purefunc;
extern void memswap(void *, void *, size_t);
-extern char* index(const char *, int);
-extern char* rindex(const char *, int);
-extern char* strchr(const char *, int);
-extern char* strrchr(const char *, int);
+extern char* index(const char *, int) __purefunc;
+extern char* rindex(const char *, int) __purefunc;
+extern char* strchr(const char *, int) __purefunc;
+extern char* strrchr(const char *, int) __purefunc;
-extern size_t strlen(const char *);
-extern int strcmp(const char *, const char *);
+extern size_t strlen(const char *) __purefunc;
+extern int strcmp(const char *, const char *) __purefunc;
extern char* strcpy(char *, const char *);
extern char* strcat(char *, const char *);
-extern int strcasecmp(const char *, const char *);
-extern int strncasecmp(const char *, const char *, size_t);
+extern int strcasecmp(const char *, const char *) __purefunc;
+extern int strncasecmp(const char *, const char *, size_t) __purefunc;
extern char* strdup(const char *);
-extern char* strstr(const char *, const char *);
-extern char* strcasestr(const char *haystack, const char *needle);
+extern char* strstr(const char *, const char *) __purefunc;
+extern char* strcasestr(const char *haystack, const char *needle) __purefunc;
extern char* strtok(char *, const char *);
extern char* strtok_r(char *, const char *, char**);
extern char* strerror(int);
extern int strerror_r(int errnum, char *buf, size_t n);
-extern size_t strnlen(const char *, size_t);
+extern size_t strnlen(const char *, size_t) __purefunc;
extern char* strncat(char *, const char *, size_t);
extern char* strndup(const char *, size_t);
-extern int strncmp(const char *, const char *, size_t);
+extern int strncmp(const char *, const char *, size_t) __purefunc;
extern char* strncpy(char *, const char *, size_t);
extern size_t strlcat(char *, const char *, size_t);
extern size_t strlcpy(char *, const char *, size_t);
-extern size_t strcspn(const char *, const char *);
-extern char* strpbrk(const char *, const char *);
+extern size_t strcspn(const char *, const char *) __purefunc;
+extern char* strpbrk(const char *, const char *) __purefunc;
extern char* strsep(char **, const char *);
extern size_t strspn(const char *, const char *);
extern char* strsignal(int sig);
-extern int strcoll(const char *, const char *);
+extern int strcoll(const char *, const char *) __purefunc;
extern size_t strxfrm(char *, const char *, size_t);
__END_DECLS
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index 92035d4..71b419c 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -306,9 +306,11 @@
#if __GNUC_PREREQ__(2, 96)
#define __noreturn __attribute__((__noreturn__))
#define __mallocfunc __attribute__((malloc))
+#define __purefunc __attribute__((pure))
#else
#define __noreturn
#define __mallocfunc
+#define __purefunc
#endif
/*
diff --git a/libc/kernel/README.TXT b/libc/kernel/README.TXT
index 9ff97d6..1ca3350e 100644
--- a/libc/kernel/README.TXT
+++ b/libc/kernel/README.TXT
@@ -17,26 +17,27 @@
the generation process works as follows:
- * 'bionic/kernel/original/'
+ * 'external/kernel-headers/original/'
contains a set of kernel headers as normally found in the 'include'
directory of a normal Linux kernel source tree. note that this should
only contain the files that are really needed by Android (use
'find_headers.py' to find these automatically).
- * 'bionic/kernel/common'
+ * 'bionic/libc/kernel/common'
contains the non-arch-specific clean headers and directories
(e.g. linux, asm-generic and mtd)
- *'bionic/kernel/arch-arm/'
+ * 'bionic/libc/kernel/arch-arm/'
contains the ARM-specific directory tree of clean headers.
- * 'bionic/kernel/arch-arm/asm'
+ * 'bionic/libc/kernel/arch-arm/asm'
contains the real ARM-specific headers
- * 'bionic/kernel/arch-x86'
+ * 'bionic/libc/kernel/arch-x86'
+ 'bionic/libc/kernel/arch-x86/asm'
similarly contains all headers and symlinks to be used on x86
- * 'bionic/kernel/tools' contains various Python and shell scripts used
+ * 'bionic/libc/kernel/tools' contains various Python and shell scripts used
to manage and re-generate the headers
the tools you can use are:
diff --git a/libc/kernel/arch-x86/asm/acpi.h b/libc/kernel/arch-x86/asm/acpi.h
index 255f7dc..92e6b7d 100644
--- a/libc/kernel/arch-x86/asm/acpi.h
+++ b/libc/kernel/arch-x86/asm/acpi.h
@@ -18,7 +18,7 @@
****************************************************************************/
#ifndef _ASM_X86_ACPI_H
#define _ASM_X86_ACPI_H
-#include "acpi_64.h"
+#include "acpi_32.h"
#include <asm/processor.h>
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif
diff --git a/libc/kernel/arch-x86/asm/alternative.h b/libc/kernel/arch-x86/asm/alternative.h
index 52b937b..107f551 100644
--- a/libc/kernel/arch-x86/asm/alternative.h
+++ b/libc/kernel/arch-x86/asm/alternative.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "alternative_64.h"
+#include "alternative_32.h"
diff --git a/libc/kernel/arch-x86/asm/apic.h b/libc/kernel/arch-x86/asm/apic.h
index d628eb3..bf6ac72 100644
--- a/libc/kernel/arch-x86/asm/apic.h
+++ b/libc/kernel/arch-x86/asm/apic.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "apic_64.h"
+#include "apic_32.h"
diff --git a/libc/kernel/arch-x86/asm/apicdef.h b/libc/kernel/arch-x86/asm/apicdef.h
index 8890eb3..af5b074 100644
--- a/libc/kernel/arch-x86/asm/apicdef.h
+++ b/libc/kernel/arch-x86/asm/apicdef.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "apicdef_64.h"
+#include "apicdef_32.h"
diff --git a/libc/kernel/arch-x86/asm/atomic.h b/libc/kernel/arch-x86/asm/atomic.h
index 0c0037c..9c65347 100644
--- a/libc/kernel/arch-x86/asm/atomic.h
+++ b/libc/kernel/arch-x86/asm/atomic.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "atomic_64.h"
+#include "atomic_32.h"
diff --git a/libc/kernel/arch-x86/asm/auxvec.h b/libc/kernel/arch-x86/asm/auxvec.h
index 4fd3bc9..d3cffec 100644
--- a/libc/kernel/arch-x86/asm/auxvec.h
+++ b/libc/kernel/arch-x86/asm/auxvec.h
@@ -18,9 +18,7 @@
****************************************************************************/
#ifndef _ASM_X86_AUXVEC_H
#define _ASM_X86_AUXVEC_H
-#ifdef __i386__
#define AT_SYSINFO 32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
#define AT_SYSINFO_EHDR 33
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif
diff --git a/libc/kernel/arch-x86/asm/bitops.h b/libc/kernel/arch-x86/asm/bitops.h
index 657534d..491b611 100644
--- a/libc/kernel/arch-x86/asm/bitops.h
+++ b/libc/kernel/arch-x86/asm/bitops.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "bitops_64.h"
+#include "bitops_32.h"
diff --git a/libc/kernel/arch-x86/asm/byteorder.h b/libc/kernel/arch-x86/asm/byteorder.h
index 98fc6b1..74dc9d6 100644
--- a/libc/kernel/arch-x86/asm/byteorder.h
+++ b/libc/kernel/arch-x86/asm/byteorder.h
@@ -22,53 +22,37 @@
#include <linux/compiler.h>
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#ifdef __GNUC__
-#ifdef __i386__
static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
{
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
__asm__("xchgb %b0,%h0\n\t"
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
"rorl $16,%0\n\t"
"xchgb %b0,%h0"
:"=q" (x)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
: "0" (x));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
return x;
}
static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
{
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
union {
struct { __u32 a,b; } s;
__u64 u;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
} v;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
v.u = val;
v.s.a = ___arch__swab32(v.s.a);
v.s.b = ___arch__swab32(v.s.b);
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
__asm__("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
return v.u;
}
-#else
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
-{
- __asm__("bswapq %0" : "=r" (x) : "0" (x));
- return x;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-}
-static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
-{
- __asm__("bswapl %0" : "=r" (x) : "0" (x));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- return x;
-}
-#endif
#define __arch__swab64(x) ___arch__swab64(x)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define __arch__swab32(x) ___arch__swab32(x)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define __BYTEORDER_HAS_U64__
#endif
#include <linux/byteorder/little_endian.h>
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-x86/asm/cmpxchg.h b/libc/kernel/arch-x86/asm/cmpxchg.h
index 0379a49..9447850 100644
--- a/libc/kernel/arch-x86/asm/cmpxchg.h
+++ b/libc/kernel/arch-x86/asm/cmpxchg.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "cmpxchg_64.h"
+#include "cmpxchg_32.h"
diff --git a/libc/kernel/arch-x86/asm/cpufeature.h b/libc/kernel/arch-x86/asm/cpufeature.h
index 23637d1..7fcfacf 100644
--- a/libc/kernel/arch-x86/asm/cpufeature.h
+++ b/libc/kernel/arch-x86/asm/cpufeature.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "cpufeature_64.h"
+#include "cpufeature_32.h"
diff --git a/libc/kernel/arch-x86/asm/current.h b/libc/kernel/arch-x86/asm/current.h
index c6b8b05..da85169 100644
--- a/libc/kernel/arch-x86/asm/current.h
+++ b/libc/kernel/arch-x86/asm/current.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "current_64.h"
+#include "current_32.h"
diff --git a/libc/kernel/arch-x86/asm/desc.h b/libc/kernel/arch-x86/asm/desc.h
index 4566993..b60787e 100644
--- a/libc/kernel/arch-x86/asm/desc.h
+++ b/libc/kernel/arch-x86/asm/desc.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "desc_64.h"
+#include "desc_32.h"
diff --git a/libc/kernel/arch-x86/asm/div64.h b/libc/kernel/arch-x86/asm/div64.h
index 8641ffa..420d9e3 100644
--- a/libc/kernel/arch-x86/asm/div64.h
+++ b/libc/kernel/arch-x86/asm/div64.h
@@ -18,6 +18,8 @@
****************************************************************************/
#ifndef _ASM_X86_DIV64_H
#define _ASM_X86_DIV64_H
-#include <asm-generic/div64.h>
-#endif
+#include <linux/types.h>
+#define do_div(n,base) ({ unsigned long __upper, __low, __high, __mod, __base; __base = (base); asm("":"=a" (__low), "=d" (__high):"A" (n)); __upper = __high; if (__high) { __upper = __high % (__base); __high = __high / (__base); } asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); asm("":"=A" (n):"a" (__low),"d" (__high)); __mod; })
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define div_long_long_rem(a,b,c) div_ll_X_l_rem(a,b,c)
+#endif
diff --git a/libc/kernel/arch-x86/asm/dma-mapping.h b/libc/kernel/arch-x86/asm/dma-mapping.h
index 5e4666c..0a9d23b 100644
--- a/libc/kernel/arch-x86/asm/dma-mapping.h
+++ b/libc/kernel/arch-x86/asm/dma-mapping.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "dma-mapping_64.h"
+#include "dma-mapping_32.h"
diff --git a/libc/kernel/arch-x86/asm/dma.h b/libc/kernel/arch-x86/asm/dma.h
index 33baa8e..1e96d90 100644
--- a/libc/kernel/arch-x86/asm/dma.h
+++ b/libc/kernel/arch-x86/asm/dma.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "dma_64.h"
+#include "dma_32.h"
diff --git a/libc/kernel/arch-x86/asm/dwarf2.h b/libc/kernel/arch-x86/asm/dwarf2.h
index 52c5bf7..916bcb8 100644
--- a/libc/kernel/arch-x86/asm/dwarf2.h
+++ b/libc/kernel/arch-x86/asm/dwarf2.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "dwarf2_64.h"
+#include "dwarf2_32.h"
diff --git a/libc/kernel/arch-x86/asm/elf.h b/libc/kernel/arch-x86/asm/elf.h
index ac01942..2d1edfd 100644
--- a/libc/kernel/arch-x86/asm/elf.h
+++ b/libc/kernel/arch-x86/asm/elf.h
@@ -27,53 +27,24 @@
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
typedef struct user_i387_struct elf_fpregset_t;
-#ifdef __i386__
typedef struct user_fxsr_struct elf_fpxregset_t;
#define R_386_NONE 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define R_386_32 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define R_386_PC32 2
#define R_386_GOT32 3
#define R_386_PLT32 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define R_386_COPY 5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define R_386_GLOB_DAT 6
#define R_386_JMP_SLOT 7
#define R_386_RELATIVE 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define R_386_GOTOFF 9
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define R_386_GOTPC 10
#define R_386_NUM 11
#define ELF_CLASS ELFCLASS32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define ELF_DATA ELFDATA2LSB
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define ELF_ARCH EM_386
-#else
-#define R_X86_64_NONE 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_X86_64_64 1
-#define R_X86_64_PC32 2
-#define R_X86_64_GOT32 3
-#define R_X86_64_PLT32 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_X86_64_COPY 5
-#define R_X86_64_GLOB_DAT 6
-#define R_X86_64_JUMP_SLOT 7
-#define R_X86_64_RELATIVE 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_X86_64_GOTPCREL 9
-#define R_X86_64_32 10
-#define R_X86_64_32S 11
-#define R_X86_64_16 12
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_X86_64_PC16 13
-#define R_X86_64_8 14
-#define R_X86_64_PC8 15
-#define R_X86_64_NUM 16
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELF_CLASS ELFCLASS64
-#define ELF_DATA ELFDATA2LSB
-#define ELF_ARCH EM_X86_64
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif
diff --git a/libc/kernel/arch-x86/asm/fixmap.h b/libc/kernel/arch-x86/asm/fixmap.h
index 363f5a3..f8a1d18 100644
--- a/libc/kernel/arch-x86/asm/fixmap.h
+++ b/libc/kernel/arch-x86/asm/fixmap.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "fixmap_64.h"
+#include "fixmap_32.h"
diff --git a/libc/kernel/arch-x86/asm/genapic.h b/libc/kernel/arch-x86/asm/genapic.h
index 9f9e505..3dc5e45 100644
--- a/libc/kernel/arch-x86/asm/genapic.h
+++ b/libc/kernel/arch-x86/asm/genapic.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "genapic_64.h"
+#include "genapic_32.h"
diff --git a/libc/kernel/arch-x86/asm/hardirq.h b/libc/kernel/arch-x86/asm/hardirq.h
index c8c4e65..4e3b8c1 100644
--- a/libc/kernel/arch-x86/asm/hardirq.h
+++ b/libc/kernel/arch-x86/asm/hardirq.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "hardirq_64.h"
+#include "hardirq_32.h"
diff --git a/libc/kernel/arch-x86/asm/hw_irq.h b/libc/kernel/arch-x86/asm/hw_irq.h
index eb2a64a..d69d8e9 100644
--- a/libc/kernel/arch-x86/asm/hw_irq.h
+++ b/libc/kernel/arch-x86/asm/hw_irq.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "hw_irq_64.h"
+#include "hw_irq_32.h"
diff --git a/libc/kernel/arch-x86/asm/i387.h b/libc/kernel/arch-x86/asm/i387.h
index 07d579d..9333051 100644
--- a/libc/kernel/arch-x86/asm/i387.h
+++ b/libc/kernel/arch-x86/asm/i387.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "i387_64.h"
+#include "i387_32.h"
diff --git a/libc/kernel/arch-x86/asm/io.h b/libc/kernel/arch-x86/asm/io.h
index 11f4db4..4e81b8c 100644
--- a/libc/kernel/arch-x86/asm/io.h
+++ b/libc/kernel/arch-x86/asm/io.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "io_64.h"
+#include "io_32.h"
diff --git a/libc/kernel/arch-x86/asm/io_apic.h b/libc/kernel/arch-x86/asm/io_apic.h
index 03630cf..54bf23a 100644
--- a/libc/kernel/arch-x86/asm/io_apic.h
+++ b/libc/kernel/arch-x86/asm/io_apic.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "io_apic_64.h"
+#include "io_apic_32.h"
diff --git a/libc/kernel/arch-x86/asm/irq.h b/libc/kernel/arch-x86/asm/irq.h
index d6e0493..eaa65db 100644
--- a/libc/kernel/arch-x86/asm/irq.h
+++ b/libc/kernel/arch-x86/asm/irq.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "irq_64.h"
+#include "irq_32.h"
diff --git a/libc/kernel/arch-x86/asm/irqflags.h b/libc/kernel/arch-x86/asm/irqflags.h
index 872a942..4136598 100644
--- a/libc/kernel/arch-x86/asm/irqflags.h
+++ b/libc/kernel/arch-x86/asm/irqflags.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "irqflags_64.h"
+#include "irqflags_32.h"
diff --git a/libc/kernel/arch-x86/asm/linkage.h b/libc/kernel/arch-x86/asm/linkage.h
index 3db2a07..3aae43d 100644
--- a/libc/kernel/arch-x86/asm/linkage.h
+++ b/libc/kernel/arch-x86/asm/linkage.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "linkage_64.h"
+#include "linkage_32.h"
diff --git a/libc/kernel/arch-x86/asm/local.h b/libc/kernel/arch-x86/asm/local.h
index 34d9782..99acf6d 100644
--- a/libc/kernel/arch-x86/asm/local.h
+++ b/libc/kernel/arch-x86/asm/local.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "local_64.h"
+#include "local_32.h"
diff --git a/libc/kernel/arch-x86/asm/mc146818rtc.h b/libc/kernel/arch-x86/asm/mc146818rtc.h
index 4c7f9cc..f7e8781 100644
--- a/libc/kernel/arch-x86/asm/mc146818rtc.h
+++ b/libc/kernel/arch-x86/asm/mc146818rtc.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "mc146818rtc_64.h"
+#include "mc146818rtc_32.h"
diff --git a/libc/kernel/arch-x86/asm/module.h b/libc/kernel/arch-x86/asm/module.h
index 1627050..296ed2b 100644
--- a/libc/kernel/arch-x86/asm/module.h
+++ b/libc/kernel/arch-x86/asm/module.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "module_64.h"
+#include "module_32.h"
diff --git a/libc/kernel/arch-x86/asm/mpspec.h b/libc/kernel/arch-x86/asm/mpspec.h
index f26ad2d..217a7d4 100644
--- a/libc/kernel/arch-x86/asm/mpspec.h
+++ b/libc/kernel/arch-x86/asm/mpspec.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "mpspec_64.h"
+#include "mpspec_32.h"
diff --git a/libc/kernel/arch-x86/asm/msgbuf.h b/libc/kernel/arch-x86/asm/msgbuf.h
index 7580210..99caf76 100644
--- a/libc/kernel/arch-x86/asm/msgbuf.h
+++ b/libc/kernel/arch-x86/asm/msgbuf.h
@@ -22,28 +22,20 @@
struct ipc64_perm msg_perm;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
__kernel_time_t msg_stime;
-#ifdef __i386__
unsigned long __unused1;
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
__kernel_time_t msg_rtime;
-#ifdef __i386__
unsigned long __unused2;
-#endif
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
__kernel_time_t msg_ctime;
-#ifdef __i386__
unsigned long __unused3;
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long msg_cbytes;
unsigned long msg_qnum;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long msg_qbytes;
__kernel_pid_t msg_lspid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
__kernel_pid_t msg_lrpid;
unsigned long __unused4;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long __unused5;
};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif
diff --git a/libc/kernel/arch-x86/asm/msr.h b/libc/kernel/arch-x86/asm/msr.h
index 63da0cc..00fb800 100644
--- a/libc/kernel/arch-x86/asm/msr.h
+++ b/libc/kernel/arch-x86/asm/msr.h
@@ -23,27 +23,4 @@
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#include <linux/types.h>
#endif
-#ifdef __i386__
-#else
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#ifndef __ASSEMBLY__
-#include <linux/errno.h>
-#define rdmsr(msr,val1,val2) __asm__ __volatile__("rdmsr" : "=a" (val1), "=d" (val2) : "c" (msr))
-#define rdmsrl(msr,val) do { unsigned long a__,b__; __asm__ __volatile__("rdmsr" : "=a" (a__), "=d" (b__) : "c" (msr)); val = a__ | (b__<<32); } while(0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define wrmsr(msr,val1,val2) __asm__ __volatile__("wrmsr" : : "c" (msr), "a" (val1), "d" (val2))
-#define wrmsrl(msr,val) wrmsr(msr,(__u32)((__u64)(val)),((__u64)(val))>>32)
-#define rdtsc(low,high) __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
-#define rdtscl(low) __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define rdtscp(low,high,aux) __asm__ __volatile__ (".byte 0x0f,0x01,0xf9" : "=a" (low), "=d" (high), "=c" (aux))
-#define rdtscll(val) do { unsigned int __a,__d; __asm__ __volatile__("rdtsc" : "=a" (__a), "=d" (__d)); (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); } while(0)
-#define rdtscpll(val, aux) do { unsigned long __a, __d; __asm__ __volatile__ (".byte 0x0f,0x01,0xf9" : "=a" (__a), "=d" (__d), "=c" (aux)); (val) = (__d << 32) | __a; } while (0)
-#define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define write_rdtscp_aux(val) wrmsr(0xc0000103, val, 0)
-#define rdpmc(counter,low,high) __asm__ __volatile__("rdpmc" : "=a" (low), "=d" (high) : "c" (counter))
-#endif
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif
diff --git a/libc/kernel/arch-x86/asm/page.h b/libc/kernel/arch-x86/asm/page.h
index 5ea7de5..3b45383 100644
--- a/libc/kernel/arch-x86/asm/page.h
+++ b/libc/kernel/arch-x86/asm/page.h
@@ -16,9 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#ifdef __i386__
#include "page_32.h"
-#else
-#include "page_64.h"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/arch-x86/asm/percpu.h b/libc/kernel/arch-x86/asm/percpu.h
index a51075b..607b92e 100644
--- a/libc/kernel/arch-x86/asm/percpu.h
+++ b/libc/kernel/arch-x86/asm/percpu.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "percpu_64.h"
+#include "percpu_32.h"
diff --git a/libc/kernel/arch-x86/asm/pgalloc.h b/libc/kernel/arch-x86/asm/pgalloc.h
index 37ce815..9175367 100644
--- a/libc/kernel/arch-x86/asm/pgalloc.h
+++ b/libc/kernel/arch-x86/asm/pgalloc.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "pgalloc_64.h"
+#include "pgalloc_32.h"
diff --git a/libc/kernel/arch-x86/asm/pgtable.h b/libc/kernel/arch-x86/asm/pgtable.h
index 2367e0b..a9bed6b 100644
--- a/libc/kernel/arch-x86/asm/pgtable.h
+++ b/libc/kernel/arch-x86/asm/pgtable.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "pgtable_64.h"
+#include "pgtable_32.h"
diff --git a/libc/kernel/arch-x86/asm/posix_types.h b/libc/kernel/arch-x86/asm/posix_types.h
index 21d4bf2..4e26788 100644
--- a/libc/kernel/arch-x86/asm/posix_types.h
+++ b/libc/kernel/arch-x86/asm/posix_types.h
@@ -16,9 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#ifdef __i386__
#include "posix_types_32.h"
-#else
-#include "posix_types_64.h"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/arch-x86/asm/processor.h b/libc/kernel/arch-x86/asm/processor.h
index 38a66b1..e9eaec8 100644
--- a/libc/kernel/arch-x86/asm/processor.h
+++ b/libc/kernel/arch-x86/asm/processor.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "processor_64.h"
+#include "processor_32.h"
diff --git a/libc/kernel/arch-x86/asm/ptrace-abi.h b/libc/kernel/arch-x86/asm/ptrace-abi.h
index 7cd9425..bbc7e86 100644
--- a/libc/kernel/arch-x86/asm/ptrace-abi.h
+++ b/libc/kernel/arch-x86/asm/ptrace-abi.h
@@ -18,63 +18,28 @@
****************************************************************************/
#ifndef _ASM_X86_PTRACE_ABI_H
#define _ASM_X86_PTRACE_ABI_H
-#ifdef __i386__
#define EBX 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define ECX 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define EDX 2
#define ESI 3
#define EDI 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define EBP 5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define EAX 6
#define DS 7
#define ES 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define FS 9
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define GS 10
#define ORIG_EAX 11
#define EIP 12
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define CS 13
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define EFL 14
#define UESP 15
#define SS 16
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define FRAME_SIZE 17
-#else
-#if defined(__ASSEMBLY__) || defined(__FRAME_OFFSETS)
-#define R15 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R14 8
-#define R13 16
-#define R12 24
-#define RBP 32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RBX 40
-#define R11 48
-#define R10 56
-#define R9 64
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R8 72
-#define RAX 80
-#define RCX 88
-#define RDX 96
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RSI 104
-#define RDI 112
-#define ORIG_RAX 120
-#define RIP 128
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CS 136
-#define EFLAGS 144
-#define RSP 152
-#define SS 160
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARGOFFSET R11
-#endif
-#define FRAME_SIZE 168
-#endif
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define PTRACE_GETREGS 12
#define PTRACE_SETREGS 13
diff --git a/libc/kernel/arch-x86/asm/ptrace.h b/libc/kernel/arch-x86/asm/ptrace.h
index 2560e5a..95d381e 100644
--- a/libc/kernel/arch-x86/asm/ptrace.h
+++ b/libc/kernel/arch-x86/asm/ptrace.h
@@ -22,60 +22,28 @@
#include <asm/ptrace-abi.h>
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#ifndef __ASSEMBLY__
-#ifdef __i386__
struct pt_regs {
long ebx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
long ecx;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
long edx;
long esi;
long edi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
long ebp;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
long eax;
int xds;
int xes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
int xfs;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
long orig_eax;
long eip;
int xcs;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
long eflags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
long esp;
int xss;
};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#else
-struct pt_regs {
- unsigned long r15;
- unsigned long r14;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long r13;
- unsigned long r12;
- unsigned long rbp;
- unsigned long rbx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long r11;
- unsigned long r10;
- unsigned long r9;
- unsigned long r8;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long rax;
- unsigned long rcx;
- unsigned long rdx;
- unsigned long rsi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long rdi;
- unsigned long orig_rax;
- unsigned long rip;
- unsigned long cs;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long eflags;
- unsigned long rsp;
- unsigned long ss;
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif
-#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif
diff --git a/libc/kernel/arch-x86/asm/scatterlist.h b/libc/kernel/arch-x86/asm/scatterlist.h
index 376087f..b691d08 100644
--- a/libc/kernel/arch-x86/asm/scatterlist.h
+++ b/libc/kernel/arch-x86/asm/scatterlist.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "scatterlist_64.h"
+#include "scatterlist_32.h"
diff --git a/libc/kernel/arch-x86/asm/segment.h b/libc/kernel/arch-x86/asm/segment.h
index eeb7a1c..145e21d 100644
--- a/libc/kernel/arch-x86/asm/segment.h
+++ b/libc/kernel/arch-x86/asm/segment.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "segment_64.h"
+#include "segment_32.h"
diff --git a/libc/kernel/arch-x86/asm/semaphore.h b/libc/kernel/arch-x86/asm/semaphore.h
index 6ee8244..7a2223e 100644
--- a/libc/kernel/arch-x86/asm/semaphore.h
+++ b/libc/kernel/arch-x86/asm/semaphore.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "semaphore_64.h"
+#include "semaphore_32.h"
diff --git a/libc/kernel/arch-x86/asm/shmbuf.h b/libc/kernel/arch-x86/asm/shmbuf.h
index 81cce3e..5ecfe08 100644
--- a/libc/kernel/arch-x86/asm/shmbuf.h
+++ b/libc/kernel/arch-x86/asm/shmbuf.h
@@ -23,39 +23,32 @@
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
size_t shm_segsz;
__kernel_time_t shm_atime;
-#ifdef __i386__
unsigned long __unused1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
__kernel_time_t shm_dtime;
-#ifdef __i386__
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long __unused2;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
__kernel_time_t shm_ctime;
-#ifdef __i386__
unsigned long __unused3;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
__kernel_pid_t shm_cpid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
__kernel_pid_t shm_lpid;
unsigned long shm_nattch;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long __unused4;
unsigned long __unused5;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
};
struct shminfo64 {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long shmmax;
unsigned long shmmin;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long shmmni;
unsigned long shmseg;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long shmall;
unsigned long __unused1;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long __unused2;
unsigned long __unused3;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long __unused4;
};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif
diff --git a/libc/kernel/arch-x86/asm/sigcontext.h b/libc/kernel/arch-x86/asm/sigcontext.h
index b0b5fd4..390189f 100644
--- a/libc/kernel/arch-x86/asm/sigcontext.h
+++ b/libc/kernel/arch-x86/asm/sigcontext.h
@@ -21,130 +21,73 @@
#include <linux/compiler.h>
#include <asm/types.h>
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#ifdef __i386__
struct _fpreg {
unsigned short significand[4];
unsigned short exponent;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct _fpxreg {
unsigned short significand[4];
unsigned short exponent;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned short padding[3];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
};
struct _xmmreg {
unsigned long element[4];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
};
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct _fpstate {
unsigned long cw;
unsigned long sw;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long tag;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long ipoff;
unsigned long cssel;
unsigned long dataoff;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long datasel;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct _fpreg _st[8];
unsigned short status;
unsigned short magic;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long _fxsr_env[6];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long mxcsr;
unsigned long reserved;
struct _fpxreg _fxsr_st[8];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct _xmmreg _xmm[8];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long padding[56];
};
#define X86_FXSR_MAGIC 0x0000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct sigcontext {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned short gs, __gsh;
unsigned short fs, __fsh;
unsigned short es, __esh;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned short ds, __dsh;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long edi;
unsigned long esi;
unsigned long ebp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long esp;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long ebx;
unsigned long edx;
unsigned long ecx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long eax;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long trapno;
unsigned long err;
unsigned long eip;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned short cs, __csh;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long eflags;
unsigned long esp_at_signal;
unsigned short ss, __ssh;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct _fpstate __user * fpstate;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long oldmask;
unsigned long cr2;
};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#else
-struct _fpstate {
- __u16 cwd;
- __u16 swd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u16 twd;
- __u16 fop;
- __u64 rip;
- __u64 rdp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 mxcsr;
- __u32 mxcsr_mask;
- __u32 st_space[32];
- __u32 xmm_space[64];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 reserved2[24];
-};
-struct sigcontext {
- unsigned long r8;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long r9;
- unsigned long r10;
- unsigned long r11;
- unsigned long r12;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long r13;
- unsigned long r14;
- unsigned long r15;
- unsigned long rdi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long rsi;
- unsigned long rbp;
- unsigned long rbx;
- unsigned long rdx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long rax;
- unsigned long rcx;
- unsigned long rsp;
- unsigned long rip;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long eflags;
- unsigned short cs;
- unsigned short gs;
- unsigned short fs;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned short __pad0;
- unsigned long err;
- unsigned long trapno;
- unsigned long oldmask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long cr2;
- struct _fpstate __user *fpstate;
- unsigned long reserved1[8];
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif
-#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-x86/asm/signal.h b/libc/kernel/arch-x86/asm/signal.h
index a15028c..1c8f2f6 100644
--- a/libc/kernel/arch-x86/asm/signal.h
+++ b/libc/kernel/arch-x86/asm/signal.h
@@ -93,35 +93,20 @@
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#include <asm-generic/signal.h>
#ifndef __ASSEMBLY__
-#ifdef __i386__
struct sigaction {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
__sighandler_t _sa_handler;
void (*_sa_sigaction)(int, struct siginfo *, void *);
} _u;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
sigset_t sa_mask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long sa_flags;
void (*sa_restorer)(void);
};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define sa_handler _u._sa_handler
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define sa_sigaction _u._sa_sigaction
-#else
-struct sigaction {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __sighandler_t sa_handler;
- unsigned long sa_flags;
- __sigrestore_t sa_restorer;
- sigset_t sa_mask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-struct k_sigaction {
- struct sigaction sa;
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
typedef struct sigaltstack {
void __user *ss_sp;
int ss_flags;
diff --git a/libc/kernel/arch-x86/asm/smp.h b/libc/kernel/arch-x86/asm/smp.h
index c69e3ef..4e439d5 100644
--- a/libc/kernel/arch-x86/asm/smp.h
+++ b/libc/kernel/arch-x86/asm/smp.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "smp_64.h"
+#include "smp_32.h"
diff --git a/libc/kernel/arch-x86/asm/spinlock.h b/libc/kernel/arch-x86/asm/spinlock.h
index 4c0f30e..286bf86 100644
--- a/libc/kernel/arch-x86/asm/spinlock.h
+++ b/libc/kernel/arch-x86/asm/spinlock.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "spinlock_64.h"
+#include "spinlock_32.h"
diff --git a/libc/kernel/arch-x86/asm/stat.h b/libc/kernel/arch-x86/asm/stat.h
index a4ccbe8..3878c88 100644
--- a/libc/kernel/arch-x86/asm/stat.h
+++ b/libc/kernel/arch-x86/asm/stat.h
@@ -19,111 +19,73 @@
#ifndef _ASM_X86_STAT_H
#define _ASM_X86_STAT_H
#define STAT_HAVE_NSEC 1
-#ifdef __i386__
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct stat {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long st_dev;
unsigned long st_ino;
unsigned short st_mode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned short st_nlink;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned short st_uid;
unsigned short st_gid;
unsigned long st_rdev;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long st_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long st_blksize;
unsigned long st_blocks;
unsigned long st_atime;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long st_atime_nsec;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long st_mtime;
unsigned long st_mtime_nsec;
unsigned long st_ctime;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long st_ctime_nsec;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long __unused4;
unsigned long __unused5;
};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define STAT64_HAS_BROKEN_ST_INO 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct stat64 {
unsigned long long st_dev;
unsigned char __pad0[4];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long __st_ino;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned int st_mode;
unsigned int st_nlink;
unsigned long st_uid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long st_gid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long long st_rdev;
unsigned char __pad3[4];
long long st_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long st_blksize;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long long st_blocks;
unsigned long st_atime;
unsigned long st_atime_nsec;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long st_mtime;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned int st_mtime_nsec;
unsigned long st_ctime;
unsigned long st_ctime_nsec;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long long st_ino;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
};
-#else
-struct stat {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long st_dev;
- unsigned long st_ino;
- unsigned long st_nlink;
- unsigned int st_mode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned int st_uid;
- unsigned int st_gid;
- unsigned int __pad0;
- unsigned long st_rdev;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long st_size;
- long st_blksize;
- long st_blocks;
- unsigned long st_atime;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long st_atime_nsec;
- unsigned long st_mtime;
- unsigned long st_mtime_nsec;
- unsigned long st_ctime;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long st_ctime_nsec;
- long __unused[3];
-};
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct __old_kernel_stat {
unsigned short st_dev;
unsigned short st_ino;
- unsigned short st_mode;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ unsigned short st_mode;
unsigned short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
- unsigned short st_rdev;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#ifdef __i386__
+ unsigned short st_rdev;
unsigned long st_size;
unsigned long st_atime;
unsigned long st_mtime;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long st_ctime;
-#else
- unsigned int st_size;
- unsigned int st_atime;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned int st_mtime;
- unsigned int st_ctime;
-#endif
};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif
diff --git a/libc/kernel/arch-x86/asm/statfs.h b/libc/kernel/arch-x86/asm/statfs.h
index f137d17..7472605 100644
--- a/libc/kernel/arch-x86/asm/statfs.h
+++ b/libc/kernel/arch-x86/asm/statfs.h
@@ -18,58 +18,6 @@
****************************************************************************/
#ifndef _ASM_X86_STATFS_H
#define _ASM_X86_STATFS_H
-#ifdef __i386__
#include <asm-generic/statfs.h>
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#else
-struct statfs {
- long f_type;
- long f_bsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long f_blocks;
- long f_bfree;
- long f_bavail;
- long f_files;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long f_ffree;
- __kernel_fsid_t f_fsid;
- long f_namelen;
- long f_frsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long f_spare[5];
-};
-struct statfs64 {
- long f_type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long f_bsize;
- long f_blocks;
- long f_bfree;
- long f_bavail;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long f_files;
- long f_ffree;
- __kernel_fsid_t f_fsid;
- long f_namelen;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long f_frsize;
- long f_spare[5];
-};
-struct compat_statfs64 {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 f_type;
- __u32 f_bsize;
- __u64 f_blocks;
- __u64 f_bfree;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u64 f_bavail;
- __u64 f_files;
- __u64 f_ffree;
- __kernel_fsid_t f_fsid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 f_namelen;
- __u32 f_frsize;
- __u32 f_spare[5];
-} __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#endif
-#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-x86/asm/string.h b/libc/kernel/arch-x86/asm/string.h
index e6cda34..874b2f0 100644
--- a/libc/kernel/arch-x86/asm/string.h
+++ b/libc/kernel/arch-x86/asm/string.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "string_64.h"
+#include "string_32.h"
diff --git a/libc/kernel/arch-x86/asm/system.h b/libc/kernel/arch-x86/asm/system.h
index e4faf67..12767cd 100644
--- a/libc/kernel/arch-x86/asm/system.h
+++ b/libc/kernel/arch-x86/asm/system.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "system_64.h"
+#include "system_32.h"
diff --git a/libc/kernel/arch-x86/asm/thread_info.h b/libc/kernel/arch-x86/asm/thread_info.h
index 05d12e4..d15e362 100644
--- a/libc/kernel/arch-x86/asm/thread_info.h
+++ b/libc/kernel/arch-x86/asm/thread_info.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "thread_info_64.h"
+#include "thread_info_32.h"
diff --git a/libc/kernel/arch-x86/asm/tlbflush.h b/libc/kernel/arch-x86/asm/tlbflush.h
index fa924b6..fd576df 100644
--- a/libc/kernel/arch-x86/asm/tlbflush.h
+++ b/libc/kernel/arch-x86/asm/tlbflush.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "tlbflush_64.h"
+#include "tlbflush_32.h"
diff --git a/libc/kernel/arch-x86/asm/types.h b/libc/kernel/arch-x86/asm/types.h
index f5aa99e..b71d89b 100644
--- a/libc/kernel/arch-x86/asm/types.h
+++ b/libc/kernel/arch-x86/asm/types.h
@@ -28,17 +28,11 @@
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
typedef __signed__ int __s32;
typedef unsigned int __u32;
-#ifdef __i386__
#ifdef __GNUC__
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
__extension__ typedef __signed__ long long __s64;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
__extension__ typedef unsigned long long __u64;
#endif
-#else
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef __signed__ long long __s64;
-typedef unsigned long long __u64;
#endif
#endif
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/arch-x86/asm/uaccess.h b/libc/kernel/arch-x86/asm/uaccess.h
index 124e7e1..b167f6d 100644
--- a/libc/kernel/arch-x86/asm/uaccess.h
+++ b/libc/kernel/arch-x86/asm/uaccess.h
@@ -16,4 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#include "uaccess_64.h"
+#include "uaccess_32.h"
diff --git a/libc/kernel/arch-x86/asm/unistd.h b/libc/kernel/arch-x86/asm/unistd.h
index 3c55d9a..d109f5f 100644
--- a/libc/kernel/arch-x86/asm/unistd.h
+++ b/libc/kernel/arch-x86/asm/unistd.h
@@ -16,9 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#ifdef __i386__
#include "unistd_32.h"
-#else
-#include "unistd_64.h"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/arch-x86/asm/user.h b/libc/kernel/arch-x86/asm/user.h
index 0d655d1..054182e 100644
--- a/libc/kernel/arch-x86/asm/user.h
+++ b/libc/kernel/arch-x86/asm/user.h
@@ -16,9 +16,4 @@
***
****************************************************************************
****************************************************************************/
-#ifdef __i386__
#include "user_32.h"
-#else
-#include "user_64.h"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/common/asm-generic/mman-common.h b/libc/kernel/common/asm-generic/mman-common.h
new file mode 100644
index 0000000..157353b
--- /dev/null
+++ b/libc/kernel/common/asm-generic/mman-common.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ *** To edit the content of this header, modify the corresponding
+ *** source file (e.g. under external/kernel-headers/original/) then
+ *** run bionic/libc/kernel/tools/update_all.py
+ ***
+ *** Any manual change here will be lost the next time this script will
+ *** be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_GENERIC_MMAN_COMMON_H
+#define __ASM_GENERIC_MMAN_COMMON_H
+#define PROT_READ 0x1
+#define PROT_WRITE 0x2
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PROT_EXEC 0x4
+#define PROT_SEM 0x8
+#define PROT_NONE 0x0
+#define PROT_GROWSDOWN 0x01000000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PROT_GROWSUP 0x02000000
+#define MAP_SHARED 0x01
+#define MAP_PRIVATE 0x02
+#define MAP_TYPE 0x0f
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MAP_FIXED 0x10
+#define MAP_ANONYMOUS 0x20
+#define MAP_UNINITIALIZED 0x0
+#define MS_ASYNC 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MS_INVALIDATE 2
+#define MS_SYNC 4
+#define MADV_NORMAL 0
+#define MADV_RANDOM 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_SEQUENTIAL 2
+#define MADV_WILLNEED 3
+#define MADV_DONTNEED 4
+#define MADV_REMOVE 9
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_DONTFORK 10
+#define MADV_DOFORK 11
+#define MADV_HWPOISON 100
+#define MADV_SOFT_OFFLINE 101
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_MERGEABLE 12
+#define MADV_UNMERGEABLE 13
+#define MADV_HUGEPAGE 14
+#define MADV_NOHUGEPAGE 15
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MAP_FILE 0
+#endif
diff --git a/libc/kernel/common/asm-generic/mman.h b/libc/kernel/common/asm-generic/mman.h
index d454921..6eaf900 100644
--- a/libc/kernel/common/asm-generic/mman.h
+++ b/libc/kernel/common/asm-generic/mman.h
@@ -16,38 +16,21 @@
***
****************************************************************************
****************************************************************************/
-#ifndef _ASM_GENERIC_MMAN_H
-#define _ASM_GENERIC_MMAN_H
-#define PROT_READ 0x1
-#define PROT_WRITE 0x2
+#ifndef __ASM_GENERIC_MMAN_H
+#define __ASM_GENERIC_MMAN_H
+#include <asm-generic/mman-common.h>
+#define MAP_GROWSDOWN 0x0100
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PROT_EXEC 0x4
-#define PROT_SEM 0x8
-#define PROT_NONE 0x0
-#define PROT_GROWSDOWN 0x01000000
+#define MAP_DENYWRITE 0x0800
+#define MAP_EXECUTABLE 0x1000
+#define MAP_LOCKED 0x2000
+#define MAP_NORESERVE 0x4000
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define PROT_GROWSUP 0x02000000
-#define MAP_SHARED 0x01
-#define MAP_PRIVATE 0x02
-#define MAP_TYPE 0x0f
+#define MAP_POPULATE 0x8000
+#define MAP_NONBLOCK 0x10000
+#define MAP_STACK 0x20000
+#define MAP_HUGETLB 0x40000
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MAP_FIXED 0x10
-#define MAP_ANONYMOUS 0x20
-#define MS_ASYNC 1
-#define MS_INVALIDATE 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MS_SYNC 4
-#define MADV_NORMAL 0
-#define MADV_RANDOM 1
-#define MADV_SEQUENTIAL 2
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MADV_WILLNEED 3
-#define MADV_DONTNEED 4
-#define MADV_REMOVE 9
-#define MADV_DONTFORK 10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define MADV_DOFORK 11
-#define MAP_ANON MAP_ANONYMOUS
-#define MAP_FILE 0
+#define MCL_CURRENT 1
+#define MCL_FUTURE 2
#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/tools/clean_header.py b/libc/kernel/tools/clean_header.py
index 22e62aa..01569fc 100755
--- a/libc/kernel/tools/clean_header.py
+++ b/libc/kernel/tools/clean_header.py
@@ -62,8 +62,11 @@
sys.stderr.write( "error: can't parse '%s'" % path )
sys.exit(1)
+ macros = kernel_known_macros.copy()
+ if arch and arch in kernel_default_arch_macros:
+ macros.update(kernel_default_arch_macros[arch])
- blocks.optimizeMacros( kernel_known_macros )
+ blocks.optimizeMacros( macros )
blocks.optimizeIf01()
blocks.removeVarsAndFuncs( statics )
blocks.replaceTokens( kernel_token_replacements )
diff --git a/libc/kernel/tools/defaults.py b/libc/kernel/tools/defaults.py
index aa68e7c..7fbed46 100644
--- a/libc/kernel/tools/defaults.py
+++ b/libc/kernel/tools/defaults.py
@@ -44,7 +44,7 @@
# toolchain preprocessor
kernel_default_arch_macros = {
"arm": {},
- "x86": {"__i386__": "1"},
+ "x86": {"__i386__": "1", "CONFIG_X86_32": "1"},
}
# Replace tokens in the output according to this mapping
diff --git a/libc/unistd/charclass.h b/libc/unistd/charclass.h
new file mode 100644
index 0000000..5edb2c1
--- /dev/null
+++ b/libc/unistd/charclass.h
@@ -0,0 +1,29 @@
+/*
+ * Public domain, 2008, Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * $OpenBSD: charclass.h,v 1.1 2008/10/01 23:04:13 millert Exp $
+ */
+
+/*
+ * POSIX character class support for fnmatch() and glob().
+ */
+static struct cclass {
+ const char *name;
+ int (*isctype)(int);
+} cclasses[] = {
+ { "alnum", isalnum },
+ { "alpha", isalpha },
+ { "blank", isblank },
+ { "cntrl", iscntrl },
+ { "digit", isdigit },
+ { "graph", isgraph },
+ { "lower", islower },
+ { "print", isprint },
+ { "punct", ispunct },
+ { "space", isspace },
+ { "upper", isupper },
+ { "xdigit", isxdigit },
+ { NULL, NULL }
+};
+
+#define NCCLASSES (sizeof(cclasses) / sizeof(cclasses[0]) - 1)
diff --git a/libc/unistd/fnmatch.c b/libc/unistd/fnmatch.c
index ad31c9e..c3d1a3c 100644
--- a/libc/unistd/fnmatch.c
+++ b/libc/unistd/fnmatch.c
@@ -1,205 +1,480 @@
-/* $OpenBSD: fnmatch.c,v 1.13 2006/03/31 05:34:14 deraadt Exp $ */
+/* $OpenBSD: fnmatch.c,v 1.16 2011/12/06 11:47:46 stsp Exp $ */
-/*
- * Copyright (c) 1989, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Guido van Rossum.
- *
+/* Copyright (c) 2011, VMware, Inc.
+ * All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the VMware, Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * ARE DISCLAIMED. IN NO EVENT SHALL VMWARE, INC. OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
- * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
- * Compares a filename or pathname to a pattern.
+ * Copyright (c) 2008 Todd C. Miller <millert@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
+/* Authored by William A. Rowe Jr. <wrowe; apache.org, vmware.com>, April 2011
+ *
+ * Derived from The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008
+ * as described in;
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/fnmatch.html
+ *
+ * Filename pattern matches defined in section 2.13, "Pattern Matching Notation"
+ * from chapter 2. "Shell Command Language"
+ * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13
+ * where; 1. A bracket expression starting with an unquoted <circumflex> '^'
+ * character CONTINUES to specify a non-matching list; 2. an explicit <period> '.'
+ * in a bracket expression matching list, e.g. "[.abc]" does NOT match a leading
+ * <period> in a filename; 3. a <left-square-bracket> '[' which does not introduce
+ * a valid bracket expression is treated as an ordinary character; 4. a differing
+ * number of consecutive slashes within pattern and string will NOT match;
+ * 5. a trailing '\' in FNM_ESCAPE mode is treated as an ordinary '\' character.
+ *
+ * Bracket expansion defined in section 9.3.5, "RE Bracket Expression",
+ * from chapter 9, "Regular Expressions"
+ * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_05
+ * with no support for collating symbols, equivalence class expressions or
+ * character class expressions. A partial range expression with a leading
+ * hyphen following a valid range expression will match only the ordinary
+ * <hyphen> and the ending character (e.g. "[a-m-z]" will match characters
+ * 'a' through 'm', a <hyphen> '-', or a 'z').
+ *
+ * Supports BSD extensions FNM_LEADING_DIR to match pattern to the end of one
+ * path segment of string, and FNM_CASEFOLD to ignore alpha case.
+ *
+ * NOTE: Only POSIX/C single byte locales are correctly supported at this time.
+ * Notably, non-POSIX locales with FNM_CASEFOLD produce undefined results,
+ * particularly in ranges of mixed case (e.g. "[A-z]") or spanning alpha and
+ * nonalpha characters within a range.
+ *
+ * XXX comments below indicate porting required for multi-byte character sets
+ * and non-POSIX locale collation orders; requires mbr* APIs to track shift
+ * state of pattern and string (rewinding pattern and string repeatedly).
+ *
+ * Certain parts of the code assume 0x00-0x3F are unique with any MBCS (e.g.
+ * UTF-8, SHIFT-JIS, etc). Any implementation allowing '\' as an alternate
+ * path delimiter must be aware that 0x5C is NOT unique within SHIFT-JIS.
+ */
+
#include <fnmatch.h>
+#include <string.h>
+#include <ctype.h>
+#include <limits.h>
-#define EOS '\0'
+#include "charclass.h"
-#define RANGE_MATCH 1
-#define RANGE_NOMATCH 0
-#define RANGE_ERROR (-1)
-
-static int rangematch(const char *, char, int, char **);
-
-int
-fnmatch(const char *pattern, const char *string, int flags)
-{
- const char *stringstart;
- char *newp;
- char c, test;
-
- for (stringstart = string;;)
- switch (c = *pattern++) {
- case EOS:
- if ((flags & FNM_LEADING_DIR) && *string == '/')
- return (0);
- return (*string == EOS ? 0 : FNM_NOMATCH);
- case '?':
- if (*string == EOS)
- return (FNM_NOMATCH);
- if (*string == '/' && (flags & FNM_PATHNAME))
- return (FNM_NOMATCH);
- if (*string == '.' && (flags & FNM_PERIOD) &&
- (string == stringstart ||
- ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
- ++string;
- break;
- case '*':
- c = *pattern;
- /* Collapse multiple stars. */
- while (c == '*')
- c = *++pattern;
-
- if (*string == '.' && (flags & FNM_PERIOD) &&
- (string == stringstart ||
- ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
-
- /* Optimize for pattern with * at end or before /. */
- if (c == EOS) {
- if (flags & FNM_PATHNAME)
- return ((flags & FNM_LEADING_DIR) ||
- strchr(string, '/') == NULL ?
- 0 : FNM_NOMATCH);
- else
- return (0);
- } else if (c == '/' && (flags & FNM_PATHNAME)) {
- if ((string = strchr(string, '/')) == NULL)
- return (FNM_NOMATCH);
- break;
- }
-
- /* General case, use recursion. */
- while ((test = *string) != EOS) {
- if (!fnmatch(pattern, string, flags & ~FNM_PERIOD))
- return (0);
- if (test == '/' && (flags & FNM_PATHNAME))
- break;
- ++string;
- }
- return (FNM_NOMATCH);
- case '[':
- if (*string == EOS)
- return (FNM_NOMATCH);
- if (*string == '/' && (flags & FNM_PATHNAME))
- return (FNM_NOMATCH);
- if (*string == '.' && (flags & FNM_PERIOD) &&
- (string == stringstart ||
- ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
-
- switch (rangematch(pattern, *string, flags, &newp)) {
- case RANGE_ERROR:
- /* not a good range, treat as normal text */
- goto normal;
- case RANGE_MATCH:
- pattern = newp;
- break;
- case RANGE_NOMATCH:
- return (FNM_NOMATCH);
- }
- ++string;
- break;
- case '\\':
- if (!(flags & FNM_NOESCAPE)) {
- if ((c = *pattern++) == EOS) {
- c = '\\';
- --pattern;
- }
- }
- /* FALLTHROUGH */
- default:
- normal:
- if (c != *string && !((flags & FNM_CASEFOLD) &&
- (tolower((unsigned char)c) ==
- tolower((unsigned char)*string))))
- return (FNM_NOMATCH);
- ++string;
- break;
- }
- /* NOTREACHED */
-}
+#define RANGE_MATCH 1
+#define RANGE_NOMATCH 0
+#define RANGE_ERROR (-1)
static int
-rangematch(const char *pattern, char test, int flags, char **newp)
+classmatch(const char *pattern, char test, int foldcase, const char **ep)
{
- int negate, ok;
- char c, c2;
+ struct cclass *cc;
+ const char *colon;
+ size_t len;
+ int rval = RANGE_NOMATCH;
+ const char * const mismatch = pattern;
- /*
- * A bracket expression starting with an unquoted circumflex
- * character produces unspecified results (IEEE 1003.2-1992,
- * 3.13.2). This implementation treats it like '!', for
- * consistency with the regular expression syntax.
- * J.T. Conklin (conklin@ngai.kaleida.com)
+ if (*pattern != '[' || pattern[1] != ':') {
+ *ep = mismatch;
+ return(RANGE_ERROR);
+ }
+
+ pattern += 2;
+
+ if ((colon = strchr(pattern, ':')) == NULL || colon[1] != ']') {
+ *ep = mismatch;
+ return(RANGE_ERROR);
+ }
+ *ep = colon + 2;
+ len = (size_t)(colon - pattern);
+
+ if (foldcase && strncmp(pattern, "upper:]", 7) == 0)
+ pattern = "lower:]";
+ for (cc = cclasses; cc->name != NULL; cc++) {
+ if (!strncmp(pattern, cc->name, len) && cc->name[len] == '\0') {
+ if (cc->isctype((unsigned char)test))
+ rval = RANGE_MATCH;
+ break;
+ }
+ }
+ if (cc->name == NULL) {
+ /* invalid character class, treat as normal text */
+ *ep = mismatch;
+ rval = RANGE_ERROR;
+ }
+ return(rval);
+}
+
+/* Most MBCS/collation/case issues handled here. Wildcard '*' is not handled.
+ * EOS '\0' and the FNM_PATHNAME '/' delimiters are not advanced over,
+ * however the "\/" sequence is advanced to '/'.
+ *
+ * Both pattern and string are **char to support pointer increment of arbitrary
+ * multibyte characters for the given locale, in a later iteration of this code
+ */
+static int fnmatch_ch(const char **pattern, const char **string, int flags)
+{
+ const char * const mismatch = *pattern;
+ const int nocase = !!(flags & FNM_CASEFOLD);
+ const int escape = !(flags & FNM_NOESCAPE);
+ const int slash = !!(flags & FNM_PATHNAME);
+ int result = FNM_NOMATCH;
+ const char *startch;
+ int negate;
+
+ if (**pattern == '[')
+ {
+ ++*pattern;
+
+ /* Handle negation, either leading ! or ^ operators (never both) */
+ negate = ((**pattern == '!') || (**pattern == '^'));
+ if (negate)
+ ++*pattern;
+
+ /* ']' is an ordinary character at the start of the range pattern */
+ if (**pattern == ']')
+ goto leadingclosebrace;
+
+ while (**pattern)
+ {
+ if (**pattern == ']') {
+ ++*pattern;
+ /* XXX: Fix for MBCS character width */
+ ++*string;
+ return (result ^ negate);
+ }
+
+ if (escape && (**pattern == '\\')) {
+ ++*pattern;
+
+ /* Patterns must be terminated with ']', not EOS */
+ if (!**pattern)
+ break;
+ }
+
+ /* Patterns must be terminated with ']' not '/' */
+ if (slash && (**pattern == '/'))
+ break;
+
+ /* Match character classes. */
+ if (classmatch(*pattern, **string, nocase, pattern)
+ == RANGE_MATCH) {
+ result = 0;
+ continue;
+ }
+
+leadingclosebrace:
+ /* Look at only well-formed range patterns;
+ * "x-]" is not allowed unless escaped ("x-\]")
+ * XXX: Fix for locale/MBCS character width
+ */
+ if (((*pattern)[1] == '-') && ((*pattern)[2] != ']'))
+ {
+ startch = *pattern;
+ *pattern += (escape && ((*pattern)[2] == '\\')) ? 3 : 2;
+
+ /* NOT a properly balanced [expr] pattern, EOS terminated
+ * or ranges containing a slash in FNM_PATHNAME mode pattern
+ * fall out to to the rewind and test '[' literal code path
+ */
+ if (!**pattern || (slash && (**pattern == '/')))
+ break;
+
+ /* XXX: handle locale/MBCS comparison, advance by MBCS char width */
+ if ((**string >= *startch) && (**string <= **pattern))
+ result = 0;
+ else if (nocase && (isupper(**string) || isupper(*startch)
+ || isupper(**pattern))
+ && (tolower(**string) >= tolower(*startch))
+ && (tolower(**string) <= tolower(**pattern)))
+ result = 0;
+
+ ++*pattern;
+ continue;
+ }
+
+ /* XXX: handle locale/MBCS comparison, advance by MBCS char width */
+ if ((**string == **pattern))
+ result = 0;
+ else if (nocase && (isupper(**string) || isupper(**pattern))
+ && (tolower(**string) == tolower(**pattern)))
+ result = 0;
+
+ ++*pattern;
+ }
+
+ /* NOT a properly balanced [expr] pattern; Rewind
+ * and reset result to test '[' literal
*/
- if ((negate = (*pattern == '!' || *pattern == '^')))
+ *pattern = mismatch;
+ result = FNM_NOMATCH;
+ }
+ else if (**pattern == '?') {
+ /* Optimize '?' match before unescaping **pattern */
+ if (!**string || (slash && (**string == '/')))
+ return FNM_NOMATCH;
+ result = 0;
+ goto fnmatch_ch_success;
+ }
+ else if (escape && (**pattern == '\\') && (*pattern)[1]) {
+ ++*pattern;
+ }
+
+ /* XXX: handle locale/MBCS comparison, advance by the MBCS char width */
+ if (**string == **pattern)
+ result = 0;
+ else if (nocase && (isupper(**string) || isupper(**pattern))
+ && (tolower(**string) == tolower(**pattern)))
+ result = 0;
+
+ /* Refuse to advance over trailing slash or nulls
+ */
+ if (!**string || !**pattern || (slash && ((**string == '/') || (**pattern == '/'))))
+ return result;
+
+fnmatch_ch_success:
+ ++*pattern;
+ ++*string;
+ return result;
+}
+
+
+int fnmatch(const char *pattern, const char *string, int flags)
+{
+ static const char dummystring[2] = {' ', 0};
+ const int escape = !(flags & FNM_NOESCAPE);
+ const int slash = !!(flags & FNM_PATHNAME);
+ const int leading_dir = !!(flags & FNM_LEADING_DIR);
+ const char *strendseg;
+ const char *dummyptr;
+ const char *matchptr;
+ int wild;
+ /* For '*' wild processing only; surpress 'used before initialization'
+ * warnings with dummy initialization values;
+ */
+ const char *strstartseg = NULL;
+ const char *mismatch = NULL;
+ int matchlen = 0;
+
+ if (strnlen(pattern, PATH_MAX) == PATH_MAX ||
+ strnlen(string, PATH_MAX) == PATH_MAX)
+ return (FNM_NOMATCH);
+
+ if (*pattern == '*')
+ goto firstsegment;
+
+ while (*pattern && *string)
+ {
+ /* Pre-decode "\/" which has no special significance, and
+ * match balanced slashes, starting a new segment pattern
+ */
+ if (slash && escape && (*pattern == '\\') && (pattern[1] == '/'))
+ ++pattern;
+ if (slash && (*pattern == '/') && (*string == '/')) {
+ ++pattern;
+ ++string;
+ }
+
+firstsegment:
+ /* At the beginning of each segment, validate leading period behavior.
+ */
+ if ((flags & FNM_PERIOD) && (*string == '.'))
+ {
+ if (*pattern == '.')
++pattern;
+ else if (escape && (*pattern == '\\') && (pattern[1] == '.'))
+ pattern += 2;
+ else
+ return FNM_NOMATCH;
+ ++string;
+ }
- if (flags & FNM_CASEFOLD)
- test = (char)tolower((unsigned char)test);
-
- /*
- * A right bracket shall lose its special meaning and represent
- * itself in a bracket expression if it occurs first in the list.
- * -- POSIX.2 2.8.3.2
+ /* Determine the end of string segment
+ *
+ * Presumes '/' character is unique, not composite in any MBCS encoding
*/
- ok = 0;
- c = *pattern++;
- do {
- if (c == '\\' && !(flags & FNM_NOESCAPE))
- c = *pattern++;
- if (c == EOS)
- return (RANGE_ERROR);
- if (c == '/' && (flags & FNM_PATHNAME))
- return (RANGE_NOMATCH);
- if ((flags & FNM_CASEFOLD))
- c = (char)tolower((unsigned char)c);
- if (*pattern == '-'
- && (c2 = *(pattern+1)) != EOS && c2 != ']') {
- pattern += 2;
- if (c2 == '\\' && !(flags & FNM_NOESCAPE))
- c2 = *pattern++;
- if (c2 == EOS)
- return (RANGE_ERROR);
- if (flags & FNM_CASEFOLD)
- c2 = (char)tolower((unsigned char)c2);
- if (c <= test && test <= c2)
- ok = 1;
- } else if (c == test)
- ok = 1;
- } while ((c = *pattern++) != ']');
+ if (slash) {
+ strendseg = strchr(string, '/');
+ if (!strendseg)
+ strendseg = strchr(string, '\0');
+ }
+ else {
+ strendseg = strchr(string, '\0');
+ }
- *newp = (char *)pattern;
- return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH);
+ /* Allow pattern '*' to be consumed even with no remaining string to match
+ */
+ while (*pattern)
+ {
+ if ((string > strendseg)
+ || ((string == strendseg) && (*pattern != '*')))
+ break;
+
+ if (slash && ((*pattern == '/')
+ || (escape && (*pattern == '\\')
+ && (pattern[1] == '/'))))
+ break;
+
+ /* Reduce groups of '*' and '?' to n '?' matches
+ * followed by one '*' test for simplicity
+ */
+ for (wild = 0; ((*pattern == '*') || (*pattern == '?')); ++pattern)
+ {
+ if (*pattern == '*') {
+ wild = 1;
+ }
+ else if (string < strendseg) { /* && (*pattern == '?') */
+ /* XXX: Advance 1 char for MBCS locale */
+ ++string;
+ }
+ else { /* (string >= strendseg) && (*pattern == '?') */
+ return FNM_NOMATCH;
+ }
+ }
+
+ if (wild)
+ {
+ strstartseg = string;
+ mismatch = pattern;
+
+ /* Count fixed (non '*') char matches remaining in pattern
+ * excluding '/' (or "\/") and '*'
+ */
+ for (matchptr = pattern, matchlen = 0; 1; ++matchlen)
+ {
+ if ((*matchptr == '\0')
+ || (slash && ((*matchptr == '/')
+ || (escape && (*matchptr == '\\')
+ && (matchptr[1] == '/')))))
+ {
+ /* Compare precisely this many trailing string chars,
+ * the resulting match needs no wildcard loop
+ */
+ /* XXX: Adjust for MBCS */
+ if (string + matchlen > strendseg)
+ return FNM_NOMATCH;
+
+ string = strendseg - matchlen;
+ wild = 0;
+ break;
+ }
+
+ if (*matchptr == '*')
+ {
+ /* Ensure at least this many trailing string chars remain
+ * for the first comparison
+ */
+ /* XXX: Adjust for MBCS */
+ if (string + matchlen > strendseg)
+ return FNM_NOMATCH;
+
+ /* Begin first wild comparison at the current position */
+ break;
+ }
+
+ /* Skip forward in pattern by a single character match
+ * Use a dummy fnmatch_ch() test to count one "[range]" escape
+ */
+ /* XXX: Adjust for MBCS */
+ if (escape && (*matchptr == '\\') && matchptr[1]) {
+ matchptr += 2;
+ }
+ else if (*matchptr == '[') {
+ dummyptr = dummystring;
+ fnmatch_ch(&matchptr, &dummyptr, flags);
+ }
+ else {
+ ++matchptr;
+ }
+ }
+ }
+
+ /* Incrementally match string against the pattern
+ */
+ while (*pattern && (string < strendseg))
+ {
+ /* Success; begin a new wild pattern search
+ */
+ if (*pattern == '*')
+ break;
+
+ if (slash && ((*string == '/')
+ || (*pattern == '/')
+ || (escape && (*pattern == '\\')
+ && (pattern[1] == '/'))))
+ break;
+
+ /* Compare ch's (the pattern is advanced over "\/" to the '/',
+ * but slashes will mismatch, and are not consumed)
+ */
+ if (!fnmatch_ch(&pattern, &string, flags))
+ continue;
+
+ /* Failed to match, loop against next char offset of string segment
+ * until not enough string chars remain to match the fixed pattern
+ */
+ if (wild) {
+ /* XXX: Advance 1 char for MBCS locale */
+ string = ++strstartseg;
+ if (string + matchlen > strendseg)
+ return FNM_NOMATCH;
+
+ pattern = mismatch;
+ continue;
+ }
+ else
+ return FNM_NOMATCH;
+ }
+ }
+
+ if (*string && !((slash || leading_dir) && (*string == '/')))
+ return FNM_NOMATCH;
+
+ if (*pattern && !(slash && ((*pattern == '/')
+ || (escape && (*pattern == '\\')
+ && (pattern[1] == '/')))))
+ return FNM_NOMATCH;
+
+ if (leading_dir && !*pattern && *string == '/')
+ return 0;
+ }
+
+ /* Where both pattern and string are at EOS, declare success
+ */
+ if (!*string && !*pattern)
+ return 0;
+
+ /* pattern didn't match to the end of string */
+ return FNM_NOMATCH;
}
diff --git a/libc/unistd/mmap.c b/libc/unistd/mmap.c
index 848abbb..e097086 100644
--- a/libc/unistd/mmap.c
+++ b/libc/unistd/mmap.c
@@ -32,12 +32,19 @@
extern void* __mmap2(void*, size_t, int, int, int, size_t);
#define MMAP2_SHIFT 12
-void* mmap( void* addr, size_t size, int prot, int flags, int fd, long offset )
+void* mmap(void *addr, size_t size, int prot, int flags, int fd, long offset)
{
- if ( offset & ((1UL << MMAP2_SHIFT)-1) ) {
- errno = EINVAL;
- return MAP_FAILED;
- }
+ void *ret;
- return __mmap2(addr, size, prot, flags, fd, (size_t)offset >> MMAP2_SHIFT);
+ if (offset & ((1UL << MMAP2_SHIFT)-1)) {
+ errno = EINVAL;
+ return MAP_FAILED;
+ }
+
+ ret = __mmap2(addr, size, prot, flags, fd, (size_t)offset >> MMAP2_SHIFT);
+
+ if (ret && (flags & (MAP_PRIVATE | MAP_ANONYMOUS)))
+ madvise(ret, size, MADV_MERGEABLE);
+
+ return ret;
}